diff --git a/change_log.txt b/change_log.txt index a4ce3183215a586400773310a829b721879a10e3..61046489786cc213a4ba49748de68c36b0102ff5 100644 --- a/change_log.txt +++ b/change_log.txt @@ -3,6 +3,12 @@ Version 0.8.1 * Release script. +* Compile fixes (contributed by skyfox). + +* Fix bug which prevented reading a wide variety of blocks. + +* API rename: GetBSProperty, SetBSProperty, GetBSProperties, SetBSProperties. + Version 0.8.0 ============= @@ -10,7 +16,7 @@ Version 0.8.0 now fully supports Skyrim, and has plenty of new access functions. * Fix for tangent space flag in NiGeometryData::numUvSets (and - bsNumUvSets) getting erased when nifs were writing nif. + bsNumUvSets) getting erased when nifs were written. * Fix for NiSkinPartition::numTriangles getting erased when writing nif. diff --git a/include/nif_math.h b/include/nif_math.h index 94aa5a1d47c4cd781cd5a426dd1d53759277bc4f..3771fc1a882a0efaec8a89e14cdac291531fb468 100644 --- a/include/nif_math.h +++ b/include/nif_math.h @@ -233,7 +233,7 @@ struct Vector3 { /* Multipies a vector by a scalar and then sets the result to the left-hand vector. * \return This vector is returned. */ - Vector3 & operator*=( const float & rh ); + NIFLIB_API Vector3 & operator*=( const float & rh ); /* Multiplies a vector by a vector using the dot product * \return The dot product of the two vectors. @@ -254,7 +254,7 @@ struct Vector3 { /* Divides a vector by a scalar and then sets the result to the left-hand vector. * \return This vector is returned. */ - Vector3 & operator/=( const float & rh ); + NIFLIB_API Vector3 & operator/=( const float & rh ); /* Sets the components of this Vector3 to those of another Vector3 * \return This vector is returned. diff --git a/include/obj/NiGeometry.h b/include/obj/NiGeometry.h index 8db414c04f3099f3253ef1b24000b9c7ea03710f..dba144c7ebee4e251198c2385a2f8526315e419d 100644 --- a/include/obj/NiGeometry.h +++ b/include/obj/NiGeometry.h @@ -175,24 +175,24 @@ public: // BSProperty // \param[in] index Index of property to be retrieved. // \return The propterty. - NIFLIB_API Ref<NiProperty> getBSProperty(short index); + NIFLIB_API Ref<NiProperty> GetBSProperty(short index); // BSProperty // \param[in] index Index of property to be set. // \param[in] index Property to be set. - NIFLIB_API void setBSProperty(short index, Ref<NiProperty> value); + NIFLIB_API void SetBSProperty(short index, Ref<NiProperty> value); /* * Returns the array of the only 2 properties that are specific to Bethesda * \return Returns the array of the 2 properties */ - NIFLIB_API array<2,Ref<NiProperty > > getBSProperties(); + NIFLIB_API array<2,Ref<NiProperty > > GetBSProperties(); /* * Sets the array of the only 2 properties that are specific to Bethesda * \param[in] The new array of properties */ - NIFLIB_API void setBSProperties( array<2, Ref<NiProperty> > value); + NIFLIB_API void SetBSProperties( array<2, Ref<NiProperty> > value); //--END CUSTOM CODE--// protected: diff --git a/niflib.vcxproj b/niflib.vcxproj index a41e5a7d7fb3337b04e069ba9cb71655da437b2e..1277e0fd45620c026a1f0365fbf7cad63bf7927f 100755 --- a/niflib.vcxproj +++ b/niflib.vcxproj @@ -46,7 +46,7 @@ </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - DLL|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>MultiByte</CharacterSet> + <CharacterSet>Unicode</CharacterSet> <WholeProgramOptimization>false</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - Static|Win32'" Label="Configuration"> @@ -212,10 +212,10 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - DLL|Win32'"> <ClCompile> - <Optimization>Full</Optimization> + <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>$(ProjectDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>BUILDING_NIFLIB_DLL;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <PrecompiledHeader> </PrecompiledHeader> <PrecompiledHeaderFile> diff --git a/src/ComplexShape.cpp b/src/ComplexShape.cpp index 55aba7f35813cdfe8b89bf74c50563e6bd144cf5..4f0eab45d783b3aacc353dcb6ae83bcf10b4f647 100644 --- a/src/ComplexShape.cpp +++ b/src/ComplexShape.cpp @@ -258,7 +258,7 @@ void ComplexShape::Merge( NiAVObject * root ) { vector<NiPropertyRef> current_property_group = (*geom)->GetProperties(); //Special code to handle the Bethesda Skyrim properties - array<2, NiPropertyRef> bs_properties = (*geom)->getBSProperties(); + array<2, NiPropertyRef> bs_properties = (*geom)->GetBSProperties(); if(bs_properties[0] != NULL) { current_property_group.push_back(bs_properties[0]); } @@ -396,14 +396,14 @@ void ComplexShape::Merge( NiAVObject * root ) { if(niProp != NULL) { bsTexProp = DynamicCast<BSShaderTextureSet>(niProp); } - niProp = (*geom)->getBSProperties()[0]; + niProp = (*geom)->GetBSProperties()[0]; if(niProp != NULL && niProp->GetType().IsSameType(BSLightingShaderProperty::TYPE)) { BSLightingShaderPropertyRef bs_shader = DynamicCast<BSLightingShaderProperty>(niProp); if(bs_shader->getTextureSet() != NULL) { bsTexProp = bs_shader->getTextureSet(); } } - niProp = (*geom)->getBSProperties()[1]; + niProp = (*geom)->GetBSProperties()[1]; if(niProp != NULL && niProp->GetType().IsSameType(BSLightingShaderProperty::TYPE)) { BSLightingShaderPropertyRef bs_shader = DynamicCast<BSLightingShaderProperty>(niProp); if(bs_shader->getTextureSet() != NULL) { @@ -952,7 +952,7 @@ Ref<NiAVObject> ComplexShape::Split( NiNode * parent, Matrix44 & transform, int array<2, NiPropertyRef> bs_properties; bs_properties[0] = shader_property; bs_properties[1] = alpha_property; - shapes[shape_num]->setBSProperties(bs_properties); + shapes[shape_num]->SetBSProperties(bs_properties); } } diff --git a/src/niflib.cpp b/src/niflib.cpp index ec123aece3e9cd9356064a509b0b365ca9106add..9cec20f402c67f4c062aba7274efe1695db25052 100644 --- a/src/niflib.cpp +++ b/src/niflib.cpp @@ -307,18 +307,6 @@ vector<NiObjectRef> ReadNifList( istream & in, list<NiObjectRef> & missing_link_ break; } } - - if ( (objectType[0] != 'N' || objectType[1] != 'i') && (objectType[0] != 'R' || objectType[1] != 'o') && (objectType[0] != 'A' || objectType[1] != 'v')) { - errStream << "Read failue - Bad object position. Invalid Type Name: " << objectType << endl; - if ( new_obj != NULL ) { - errStream << "Last successfuly read object was: " << endl; - errStream << "====[ " << "Object " << i - 1 << " | " << new_obj->GetType().GetTypeName() << " ]====" << endl; - errStream << new_obj->asString(); - } else { - errStream << "No objects were read successfully." << endl; - } - throw runtime_error( errStream.str() ); - } } //Create object of the type that was found diff --git a/src/obj/NiGeometry.cpp b/src/obj/NiGeometry.cpp index a4f5a0ebd4f85f20ba55ff63811b8270b8258609..8ae0b8d09ddc9a01a605d05a4e9cc7f3f5028223 100644 --- a/src/obj/NiGeometry.cpp +++ b/src/obj/NiGeometry.cpp @@ -637,23 +637,23 @@ bool NiGeometry::HasShader() const { return hasShader; } -Ref<NiProperty> NiGeometry::getBSProperty(short index) { +Ref<NiProperty> NiGeometry::GetBSProperty(short index) { if ((index < 0) || (index > 1)) return NULL; return bsProperties[index]; } -void NiGeometry::setBSProperty(short index, Niflib::Ref<NiProperty> value) { +void NiGeometry::SetBSProperty(short index, Niflib::Ref<NiProperty> value) { if ((index >= 0) && (index <= 1)) { bsProperties[index] = value; } } -array<2,Ref<NiProperty > > Niflib::NiGeometry::getBSProperties() { +array<2,Ref<NiProperty > > Niflib::NiGeometry::GetBSProperties() { return this->bsProperties; } -void Niflib::NiGeometry::setBSProperties( array<2, Ref<NiProperty> > value ) { +void Niflib::NiGeometry::SetBSProperties( array<2, Ref<NiProperty> > value ) { this->bsProperties = value; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f544ab6d2b11583fd55f83ab803fbc2f56a79f58..0f7a259f801bd04fcf69890c2dba9dd6a9c915bd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,7 +12,9 @@ foreach(TEST skin_test missing_link_stack_test trishape_test - numuvsets_test) + numuvsets_test + bslightingshaderproperty_test + ) add_executable(${TEST} ${TEST}.cpp) target_link_libraries(${TEST} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} niflib) add_test(niflib::${TEST} ${TEST}) diff --git a/test/bslightingshaderproperty_test.cpp b/test/bslightingshaderproperty_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9a007bfb9b6fac148a0d832eca8be7368f12a56e --- /dev/null +++ b/test/bslightingshaderproperty_test.cpp @@ -0,0 +1,30 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN +#include <boost/test/unit_test.hpp> + +#include <sstream> // stringstream + +#include "niflib.h" +#include "obj/NiTriShape.h" +#include "obj/BSLightingShaderProperty.h" + +using namespace Niflib; +using namespace std; + +BOOST_AUTO_TEST_SUITE(bslightingshaderproperty_test_suite) + +BOOST_AUTO_TEST_CASE(bslightingshaderproperty_test) +{ + stringstream ss; + + // create a simple nif tree with BSLightingShaderProperty + NiTriShapeRef shape = new NiTriShape; + BSLightingShaderPropertyRef prop = new BSLightingShaderProperty; + shape->SetBSProperty(0, StaticCast<NiProperty>(prop)); + BOOST_CHECK_NO_THROW(WriteNifTree(ss, shape)); + ss.seekg(0); + NiObjectRef root; + BOOST_CHECK_NO_THROW(root = ReadNifTree(ss)); +} + +BOOST_AUTO_TEST_SUITE_END()