diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b9314264..21eba8db5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,8 @@ option(BUILD_NIFTEST "build nif file tester" OFF) option(BUILD_MYGUI_PLUGIN "build MyGUI plugin for OpenMW resources, to use with MyGUI tools" ON) option(BUILD_DOCS "build documentation." OFF ) +option(ENABLE_PVS "Enable PVS Studio Analyzer" FALSE) + if (NOT BUILD_LAUNCHER AND NOT BUILD_BROWSER AND NOT BUILD_OPENCS AND NOT BUILD_WIZARD) set(USE_QT FALSE) else() diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 9b68ce353..c79523826 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -220,7 +220,9 @@ if (MSVC) add_definitions("-D_USE_MATH_DEFINES") endif (MSVC) +if (ENABLE_PVS) pvs_studio_add_target(TARGET tes3mp-server.analyze ALL OUTPUT FORMAT errorfile ANALYZE tes3mp-server LOG target_tes3mp-server.err) +endif() diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 5efdd917e..2e2bea457 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -265,3 +265,10 @@ endif (MSVC) if (WIN32) INSTALL(TARGETS tes3mp RUNTIME DESTINATION ".") endif (WIN32) + +if (ENABLE_PVS) +pvs_studio_add_target(TARGET tes3mp.analyze ALL + OUTPUT FORMAT errorfile + ANALYZE tes3mp + LOG target_tes3mp.err) +endif() diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 77298434f..dac965703 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -307,7 +307,9 @@ endif() # Make the variable accessible for other subdirectories set(COMPONENT_FILES ${COMPONENT_FILES} PARENT_SCOPE) +if (ENABLE_PVS) pvs_studio_add_target(TARGET components.analyze ALL OUTPUT FORMAT errorfile ANALYZE components LOG target_components.err) +endif() diff --git a/components/openmw-mp/Packets/Worldstate/PacketRecordDynamic.cpp b/components/openmw-mp/Packets/Worldstate/PacketRecordDynamic.cpp index f3d6600c6..0d2e3085e 100644 --- a/components/openmw-mp/Packets/Worldstate/PacketRecordDynamic.cpp +++ b/components/openmw-mp/Packets/Worldstate/PacketRecordDynamic.cpp @@ -91,9 +91,7 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send) RW(record.baseId, send, true); RW(recordData.mId, send, true); RW(recordData.mName, send, true); - RW(recordData.mData.mType, send); - RW(recordData.mData.mCost, send); - RW(recordData.mData.mFlags, send); + RW(recordData.mData, send, true); ProcessEffects(recordData.mEffects, send); if (!record.baseId.empty()) @@ -118,9 +116,7 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send) RW(recordData.mName, send, true); RW(recordData.mModel, send, true); RW(recordData.mIcon, send, true); - RW(recordData.mData.mWeight, send); - RW(recordData.mData.mValue, send); - RW(recordData.mData.mAutoCalc, send); + RW(recordData.mData, send, true); RW(recordData.mScript, send, true); ProcessEffects(recordData.mEffects, send); @@ -146,10 +142,7 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send) RW(record.baseId, send, true); RW(recordData.mId, send, true); - RW(recordData.mData.mType, send); - RW(recordData.mData.mCost, send); - RW(recordData.mData.mCharge, send); - RW(recordData.mData.mAutocalc, send); + RW(recordData.mData, send, true); ProcessEffects(recordData.mEffects, send); if (!record.baseId.empty()) @@ -259,12 +252,7 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send) RW(recordData.mName, send, true); RW(recordData.mModel, send, true); RW(recordData.mIcon, send, true); - RW(recordData.mData.mType, send); - RW(recordData.mData.mWeight, send); - RW(recordData.mData.mValue, send); - RW(recordData.mData.mHealth, send); - RW(recordData.mData.mArmor, send); - RW(recordData.mData.mEnchant, send); + RW(recordData.mData, send, true); RW(recordData.mEnchant, send, true); RW(recordData.mScript, send, true); ProcessBodyParts(recordData.mParts, send); @@ -299,11 +287,7 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send) RW(recordData.mModel, send, true); RW(recordData.mIcon, send, true); RW(recordData.mText, send, true); - RW(recordData.mData.mWeight, send); - RW(recordData.mData.mValue, send); - RW(recordData.mData.mIsScroll, send); - RW(recordData.mData.mSkillId, send); - RW(recordData.mData.mEnchant, send); + RW(recordData.mData, send, true); RW(recordData.mEnchant, send, true); RW(recordData.mScript, send, true); @@ -462,14 +446,7 @@ void PacketRecordDynamic::ProcessEffects(ESM::EffectList &effectList, bool send) for (auto &&effect : effectList.mList) { - RW(effect.mEffectID, send); - RW(effect.mAttribute, send); - RW(effect.mSkill, send); - RW(effect.mRange, send); - RW(effect.mArea, send); - RW(effect.mDuration, send); - RW(effect.mMagnMax, send); - RW(effect.mMagnMin, send); + RW(effect, send, true); } }