From 8bce460f3446df7347d9426675beae2b94e03c1f Mon Sep 17 00:00:00 2001 From: Marco Melletti Date: Wed, 3 Sep 2014 14:40:32 +0200 Subject: [PATCH 1/5] loadnpc is still unfinished, bodypartcheck.cpp mFlags check fix --- apps/opencs/model/tools/bodypartcheck.cpp | 4 ++-- components/esm/aipackage.hpp | 4 ++-- components/esm/loadarmo.hpp | 2 +- components/esm/loadbody.hpp | 8 ++++---- components/esm/loadnpc.hpp | 11 +++++++---- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/opencs/model/tools/bodypartcheck.cpp b/apps/opencs/model/tools/bodypartcheck.cpp index f1f898440..da7fe7b57 100644 --- a/apps/opencs/model/tools/bodypartcheck.cpp +++ b/apps/opencs/model/tools/bodypartcheck.cpp @@ -33,7 +33,7 @@ void CSMTools::BodyPartCheckStage::perform ( int stage, Messages &messages ) if ( bodyPart.mData.mVampire < 0 ) messages.push_back(std::make_pair( id, bodyPart.mId + " has negative vampire flag." )); - if ( bodyPart.mData.mFlags < 0 || bodyPart.mData.mFlags > 2 ) + if ( bodyPart.mData.mFlags < 0 || bodyPart.mData.mFlags > 3 ) messages.push_back(std::make_pair( id, bodyPart.mId + " has out of range flags value." )); if ( bodyPart.mData.mType < 0 || bodyPart.mData.mType > 2 ) @@ -52,4 +52,4 @@ void CSMTools::BodyPartCheckStage::perform ( int stage, Messages &messages ) messages.push_back(std::make_pair( id, bodyPart.mId + " has no race." )); else if ( mRaces.searchId( bodyPart.mRace ) == -1 ) messages.push_back(std::make_pair( id, bodyPart.mId + " has invalid race." )); -} \ No newline at end of file +} diff --git a/components/esm/aipackage.hpp b/components/esm/aipackage.hpp index 8a31aadf5..2e054c3e7 100644 --- a/components/esm/aipackage.hpp +++ b/components/esm/aipackage.hpp @@ -16,8 +16,8 @@ namespace ESM struct AIData { - // These are probabilities - char mHello, mU1, mFight, mFlee, mAlarm, mU2, mU3, mU4; + char mU1, mU2, mU3, mU4; // Unknown values + unsigned char mHello, mFight, mFlee, mAlarm; // These are probabilities [0, 100] int mServices; // See the Services enum void blank(); diff --git a/components/esm/loadarmo.hpp b/components/esm/loadarmo.hpp index 991f4e185..41fbcf818 100644 --- a/components/esm/loadarmo.hpp +++ b/components/esm/loadarmo.hpp @@ -46,7 +46,7 @@ enum PartReferenceType // Reference to body parts struct PartReference { - char mPart; + unsigned char mPart; // declared values [0, 26] std::string mMale, mFemale; }; diff --git a/components/esm/loadbody.hpp b/components/esm/loadbody.hpp index 286e3f96e..5e9869d24 100644 --- a/components/esm/loadbody.hpp +++ b/components/esm/loadbody.hpp @@ -49,10 +49,10 @@ struct BodyPart struct BYDTstruct { - char mPart; - char mVampire; - char mFlags; - char mType; + unsigned char mPart; // mesh part + unsigned char mVampire; // boolean + unsigned char mFlags; + unsigned char mType; // mesh type }; BYDTstruct mData; diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index fd3e45bdc..ff255608f 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -81,9 +81,11 @@ struct NPC mLuck; char mSkills[Skill::Length]; - char mReputation; + + // at opencs/model/tools/referenceablecheck.cpp:679 is assumed that negative reputation values are invalid, can we assume we won't find any negative value? + unsigned char mReputation; unsigned short mHealth, mMana, mFatigue; - char mDisposition, mFactionID, mRank; + signed char mDisposition, mFactionID, mRank; char mUnknown; int mGold; }; // 52 bytes @@ -91,7 +93,8 @@ struct NPC struct NPDTstruct12 { short mLevel; - char mDisposition, mReputation, mRank; + unsigned char mReputation; // see NPTDstruct52.mReputation + signed char mDisposition, mRank; char mUnknown1, mUnknown2, mUnknown3; int mGold; // ?? not certain }; // 12 bytes @@ -103,7 +106,7 @@ struct NPC }; #pragma pack(pop) - char mNpdtType; + unsigned char mNpdtType; NPDTstruct52 mNpdt52; NPDTstruct12 mNpdt12; //for autocalculated characters From bc7e154643329d08c9230d9041c54ff114aaf3fe Mon Sep 17 00:00:00 2001 From: Marco Melletti Date: Thu, 4 Sep 2014 13:23:29 +0200 Subject: [PATCH 2/5] done with header files, unsure about mSkills and mReputation in loadnpc.hpp --- components/esm/loadnpc.hpp | 3 ++- components/esm/loadregn.hpp | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index ff255608f..31104a71f 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -80,7 +80,8 @@ struct NPC mPersonality, mLuck; - char mSkills[Skill::Length]; + // mSkill vals are used only in MWMechanics::AttributeValue.setBase(), if less than 0 they are not considered + unsigned char mSkills[Skill::Length]; // at opencs/model/tools/referenceablecheck.cpp:679 is assumed that negative reputation values are invalid, can we assume we won't find any negative value? unsigned char mReputation; diff --git a/components/esm/loadregn.hpp b/components/esm/loadregn.hpp index 1992c951b..c231b6aa0 100644 --- a/components/esm/loadregn.hpp +++ b/components/esm/loadregn.hpp @@ -24,10 +24,11 @@ struct Region #pragma pack(1) struct WEATstruct { - // I guess these are probabilities - char mClear, mCloudy, mFoggy, mOvercast, mRain, mThunder, mAsh, mBlight, + // These are probabilities that add up to 100 + unsigned char mClear, mCloudy, mFoggy, mOvercast, mRain, mThunder, mAsh, mBlight, // Unknown weather, probably snow and something. Only // present in file version 1.3. + // the engine uses mA as "snow" and mB as "blizard" mA, mB; }; // 10 bytes @@ -35,7 +36,7 @@ struct Region struct SoundRef { NAME32 mSound; - char mChance; + unsigned char mChance; }; // 33 bytes #pragma pack(pop) From 2e47290ed0e327b63372feb3e136a6a640744d70 Mon Sep 17 00:00:00 2001 From: Marco Melletti Date: Fri, 5 Sep 2014 21:23:25 +0200 Subject: [PATCH 3/5] finished loadnpc.hpp, fixed npdt 52byte structure --- components/esm/loadnpc.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index 31104a71f..5e78432f6 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -80,14 +80,14 @@ struct NPC mPersonality, mLuck; - // mSkill vals are used only in MWMechanics::AttributeValue.setBase(), if less than 0 they are not considered + // mSkill cang grow up to 200, it must be unsigned unsigned char mSkills[Skill::Length]; // at opencs/model/tools/referenceablecheck.cpp:679 is assumed that negative reputation values are invalid, can we assume we won't find any negative value? - unsigned char mReputation; + char mUnknown1; unsigned short mHealth, mMana, mFatigue; - signed char mDisposition, mFactionID, mRank; - char mUnknown; + signed char mDisposition, mReputation, mRank; + char mUnknown2; int mGold; }; // 52 bytes From e1393ad2df81ade31ee468235b11c909417eb890 Mon Sep 17 00:00:00 2001 From: Marco Melletti Date: Sat, 6 Sep 2014 15:16:04 +0200 Subject: [PATCH 4/5] reputation sorted out --- components/esm/loadnpc.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index 5e78432f6..5ea9c995d 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -83,7 +83,7 @@ struct NPC // mSkill cang grow up to 200, it must be unsigned unsigned char mSkills[Skill::Length]; - // at opencs/model/tools/referenceablecheck.cpp:679 is assumed that negative reputation values are invalid, can we assume we won't find any negative value? + // reputation values does not char mUnknown1; unsigned short mHealth, mMana, mFatigue; signed char mDisposition, mReputation, mRank; @@ -94,10 +94,10 @@ struct NPC struct NPDTstruct12 { short mLevel; - unsigned char mReputation; // see NPTDstruct52.mReputation - signed char mDisposition, mRank; + // see above + signed char mReputation, mDisposition, mRank; char mUnknown1, mUnknown2, mUnknown3; - int mGold; // ?? not certain + int mGold; }; // 12 bytes struct Dest From 9b6faa2ffaa79777b54297a52ace4bcb03967d15 Mon Sep 17 00:00:00 2001 From: Marco Melletti Date: Sat, 6 Sep 2014 17:04:50 +0200 Subject: [PATCH 5/5] wrong rearrangement fixes misleading comments fixed --- components/esm/aipackage.hpp | 6 ++++-- components/esm/loadarmo.hpp | 2 +- components/esm/loadnpc.hpp | 9 ++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/esm/aipackage.hpp b/components/esm/aipackage.hpp index 2e054c3e7..cbe82f16e 100644 --- a/components/esm/aipackage.hpp +++ b/components/esm/aipackage.hpp @@ -16,8 +16,10 @@ namespace ESM struct AIData { - char mU1, mU2, mU3, mU4; // Unknown values - unsigned char mHello, mFight, mFlee, mAlarm; // These are probabilities [0, 100] + unsigned char mHello; + char mU1; + unsigned char mFight, mFlee, mAlarm; // These are probabilities [0, 100] + char mU2, mU3, mU4; // Unknown values int mServices; // See the Services enum void blank(); diff --git a/components/esm/loadarmo.hpp b/components/esm/loadarmo.hpp index 41fbcf818..6be9dd971 100644 --- a/components/esm/loadarmo.hpp +++ b/components/esm/loadarmo.hpp @@ -46,7 +46,7 @@ enum PartReferenceType // Reference to body parts struct PartReference { - unsigned char mPart; // declared values [0, 26] + unsigned char mPart; // possible values [0, 26] std::string mMale, mFemale; }; diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index 5ea9c995d..0e90108c3 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -80,14 +80,13 @@ struct NPC mPersonality, mLuck; - // mSkill cang grow up to 200, it must be unsigned + // mSkill can grow up to 200, it must be unsigned unsigned char mSkills[Skill::Length]; - // reputation values does not - char mUnknown1; + char mFactionID; unsigned short mHealth, mMana, mFatigue; signed char mDisposition, mReputation, mRank; - char mUnknown2; + char mUnknown; int mGold; }; // 52 bytes @@ -95,7 +94,7 @@ struct NPC { short mLevel; // see above - signed char mReputation, mDisposition, mRank; + signed char mDisposition, mReputation, mRank; char mUnknown1, mUnknown2, mUnknown3; int mGold; }; // 12 bytes