From a5bb6c7d8dc814e87f77c31a9c54b9811423de20 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sat, 3 Jun 2023 13:27:45 +0200 Subject: [PATCH] Use std::array in NPDTstruct52 --- apps/esmtool/record.cpp | 4 ++-- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 2 +- components/esm3/loadnpc.cpp | 3 +-- components/esm3/loadnpc.hpp | 3 ++- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp index 519d3b8f06..fba1291a4c 100644 --- a/apps/esmtool/record.cpp +++ b/apps/esmtool/record.cpp @@ -1100,8 +1100,8 @@ namespace EsmTool std::cout << " Luck: " << (int)mData.mNpdt.mLuck << std::endl; std::cout << " Skills:" << std::endl; - for (int i = 0; i != ESM::Skill::Length; i++) - std::cout << " " << skillLabel(i) << ": " << (int)(mData.mNpdt.mSkills[i]) << std::endl; + for (size_t i = 0; i != mData.mNpdt.mSkills.size(); i++) + std::cout << " " << skillLabel(i) << ": " << int(mData.mNpdt.mSkills[i]) << std::endl; std::cout << " Health: " << mData.mNpdt.mHealth << std::endl; std::cout << " Magicka: " << mData.mNpdt.mMana << std::endl; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 2119434515..9e3ca67759 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -314,7 +314,7 @@ namespace MWClass { gold = ref->mBase->mNpdt.mGold; - for (unsigned int i = 0; i < ESM::Skill::Length; ++i) + for (size_t i = 0; i < ref->mBase->mNpdt.mSkills.size(); ++i) data->mNpcStats.getSkill(i).setBase(ref->mBase->mNpdt.mSkills[i]); data->mNpcStats.setAttribute(ESM::Attribute::Strength, ref->mBase->mNpdt.mStrength); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index f5fa410725..62d7f47873 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -128,7 +128,7 @@ namespace MWMechanics creatureStats.getSpells().clear(true); creatureStats.getActiveSpells().clear(ptr); - for (int i = 0; i < 27; ++i) + for (size_t i = 0; i < player->mNpdt.mSkills.size(); ++i) npcStats.getSkill(i).setBase(player->mNpdt.mSkills[i]); creatureStats.setAttribute(ESM::Attribute::Strength, player->mNpdt.mStrength); diff --git a/components/esm3/loadnpc.cpp b/components/esm3/loadnpc.cpp index 2425341b1f..24a79d2e4c 100644 --- a/components/esm3/loadnpc.cpp +++ b/components/esm3/loadnpc.cpp @@ -215,8 +215,7 @@ namespace ESM mNpdt.mLevel = 0; mNpdt.mStrength = mNpdt.mIntelligence = mNpdt.mWillpower = mNpdt.mAgility = mNpdt.mSpeed = mNpdt.mEndurance = mNpdt.mPersonality = mNpdt.mLuck = 0; - for (int i = 0; i < Skill::Length; ++i) - mNpdt.mSkills[i] = 0; + mNpdt.mSkills.fill(0); mNpdt.mReputation = 0; mNpdt.mHealth = mNpdt.mMana = mNpdt.mFatigue = 0; mNpdt.mDisposition = 0; diff --git a/components/esm3/loadnpc.hpp b/components/esm3/loadnpc.hpp index 6c90e80994..f0d726434b 100644 --- a/components/esm3/loadnpc.hpp +++ b/components/esm3/loadnpc.hpp @@ -1,6 +1,7 @@ #ifndef OPENMW_ESM_NPC_H #define OPENMW_ESM_NPC_H +#include #include #include @@ -82,7 +83,7 @@ namespace ESM unsigned char mStrength, mIntelligence, mWillpower, mAgility, mSpeed, mEndurance, mPersonality, mLuck; // mSkill can grow up to 200, it must be unsigned - unsigned char mSkills[Skill::Length]; + std::array mSkills; char mUnknown1; unsigned short mHealth, mMana, mFatigue;