diff --git a/Source/items.cpp b/Source/items.cpp index ac61ba57e9f..47185d9572b 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1991,7 +1991,7 @@ _item_indexes RndPremiumItem(const Player &player, int minlvl, int maxlvl) void SpawnOnePremium(Item &premiumItem, int plvl, const Player &player) { - int strength = std::max(player.GetMaximumAttributeValue(CharacterAttribute::Strength), player._pStrength); + int strength = std::max(player.GetMaximumAttributeValue(CharacterAttribute::Strength), player.strength); int dexterity = std::max(player.GetMaximumAttributeValue(CharacterAttribute::Dexterity), player._pDexterity); int magic = std::max(player.GetMaximumAttributeValue(CharacterAttribute::Magic), player._pMagic); strength += strength / 5; @@ -2594,7 +2594,7 @@ void CalcPlrPrimaryStats(Player &player, int strength, int &magic, int dexterity vitality -= 2 * playerLevel; } - player._pStrength = std::max(0, strength + player._pBaseStr); + player.strength = std::max(0, strength + player._pBaseStr); player._pMagic = std::max(0, magic + player._pBaseMag); player._pDexterity = std::max(0, dexterity + player._pBaseDex); player._pVitality = std::max(0, vitality + player._pBaseVit); @@ -2617,8 +2617,8 @@ void CalcPlrDamageMod(Player &player) const uint8_t playerLevel = player.getCharacterLevel(); const Item &leftHandItem = player.InvBody[INVLOC_HAND_LEFT]; const Item &rightHandItem = player.InvBody[INVLOC_HAND_RIGHT]; - const int strMod = playerLevel * player._pStrength; - const int strDexMod = playerLevel * (player._pStrength + player._pDexterity); + const int strMod = playerLevel * player.strength; + const int strDexMod = playerLevel * (player.strength + player._pDexterity); switch (player._pClass) { case HeroClass::Rogue: @@ -4460,7 +4460,7 @@ void SpawnBoy(int lvl) Player &myPlayer = *MyPlayer; HeroClass pc = myPlayer._pClass; - int strength = std::max(myPlayer.GetMaximumAttributeValue(CharacterAttribute::Strength), myPlayer._pStrength); + int strength = std::max(myPlayer.GetMaximumAttributeValue(CharacterAttribute::Strength), myPlayer.strength); int dexterity = std::max(myPlayer.GetMaximumAttributeValue(CharacterAttribute::Dexterity), myPlayer._pDexterity); int magic = std::max(myPlayer.GetMaximumAttributeValue(CharacterAttribute::Magic), myPlayer._pMagic); strength += strength / 5; diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 0c0dd1533ad..19ccb3e6449 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -432,7 +432,7 @@ void LoadPlayer(LoadHelper &file, Player &player) file.NextBytes(player._pName, PlayerNameLength); player._pClass = static_cast(file.NextLE()); file.Skip(3); // Alignment - player._pStrength = file.NextLE(); + player.strength = file.NextLE(); player._pBaseStr = file.NextLE(); player._pMagic = file.NextLE(); player._pBaseMag = file.NextLE(); @@ -1255,7 +1255,7 @@ void SavePlayer(SaveHelper &file, const Player &player) file.WriteBytes(player._pName, PlayerNameLength); file.WriteLE(static_cast(player._pClass)); file.Skip(3); // Alignment - file.WriteLE(player._pStrength); + file.WriteLE(player.strength); file.WriteLE(player._pBaseStr); file.WriteLE(player._pMagic); file.WriteLE(player._pBaseMag); diff --git a/Source/pack.cpp b/Source/pack.cpp index d1c0f37c2c6..789ed839d29 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -356,7 +356,7 @@ void PackNetPlayer(PlayerNetPack &packed, const Player &player) packed.friendlyMode = player.friendlyMode ? 1 : 0; packed.isOnSetLevel = player.plrIsOnSetLevel; - packed.pStrength = SDL_SwapLE32(player._pStrength); + packed.pStrength = SDL_SwapLE32(player.strength); packed.pMagic = SDL_SwapLE32(player._pMagic); packed.pDexterity = SDL_SwapLE32(player._pDexterity); packed.pVitality = SDL_SwapLE32(player._pVitality); @@ -466,7 +466,7 @@ void UnPackPlayer(const PlayerPack &packed, Player &player) InitPlayer(player, true); player._pBaseStr = std::min(packed.pBaseStr, player.GetMaximumAttributeValue(CharacterAttribute::Strength)); - player._pStrength = player._pBaseStr; + player.strength = player._pBaseStr; player._pBaseMag = std::min(packed.pBaseMag, player.GetMaximumAttributeValue(CharacterAttribute::Magic)); player._pMagic = player._pBaseMag; player._pBaseDex = std::min(packed.pBaseDex, player.GetMaximumAttributeValue(CharacterAttribute::Dexterity)); @@ -601,7 +601,7 @@ bool UnPackNetPlayer(const PlayerNetPack &packed, Player &player) InitPlayer(player, true); player._pBaseStr = packed.pBaseStr; - player._pStrength = player._pBaseStr; + player.strength = player._pBaseStr; player._pBaseMag = packed.pBaseMag; player._pMagic = player._pBaseMag; player._pBaseDex = packed.pBaseDex; @@ -675,7 +675,7 @@ bool UnPackNetPlayer(const PlayerNetPack &packed, Player &player) CalcPlrInv(player, false); player._pGold = CalculateGold(player); - ValidateFields(player._pStrength, SDL_SwapLE32(packed.pStrength), player._pStrength == SDL_SwapLE32(packed.pStrength)); + ValidateFields(player.strength, SDL_SwapLE32(packed.pStrength), player.strength == SDL_SwapLE32(packed.pStrength)); ValidateFields(player._pMagic, SDL_SwapLE32(packed.pMagic), player._pMagic == SDL_SwapLE32(packed.pMagic)); ValidateFields(player._pDexterity, SDL_SwapLE32(packed.pDexterity), player._pDexterity == SDL_SwapLE32(packed.pDexterity)); ValidateFields(player._pVitality, SDL_SwapLE32(packed.pVitality), player._pVitality == SDL_SwapLE32(packed.pVitality)); diff --git a/Source/panels/charpanel.cpp b/Source/panels/charpanel.cpp index 10c3e513963..9cf0ffecfa5 100644 --- a/Source/panels/charpanel.cpp +++ b/Source/panels/charpanel.cpp @@ -147,7 +147,7 @@ PanelEntry panelEntries[] = { { N_("Strength"), { LeftColumnLabelX, 135 }, 45, LeftColumnLabelWidth, []() { return StyledText { GetBaseStatColor(CharacterAttribute::Strength), StrCat(InspectPlayer->_pBaseStr) }; } }, { "", { 135, 135 }, 45, 0, - []() { return StyledText { GetCurrentStatColor(CharacterAttribute::Strength), StrCat(InspectPlayer->_pStrength) }; } }, + []() { return StyledText { GetCurrentStatColor(CharacterAttribute::Strength), StrCat(InspectPlayer->strength) }; } }, { N_("Magic"), { LeftColumnLabelX, 163 }, 45, LeftColumnLabelWidth, []() { return StyledText { GetBaseStatColor(CharacterAttribute::Magic), StrCat(InspectPlayer->_pBaseMag) }; } }, { "", { 135, 163 }, 45, 0, diff --git a/Source/pfile.cpp b/Source/pfile.cpp index f2baa6c75ce..76a7f2576b8 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -184,7 +184,7 @@ void Game2UiPlayer(const Player &player, _uiheroinfo *heroinfo, bool bHasSaveFil CopyUtf8(heroinfo->name, player._pName, sizeof(heroinfo->name)); heroinfo->level = player.getCharacterLevel(); heroinfo->heroclass = player._pClass; - heroinfo->strength = player._pStrength; + heroinfo->strength = player.strength; heroinfo->magic = player._pMagic; heroinfo->dexterity = player._pDexterity; heroinfo->vitality = player._pVitality; diff --git a/Source/player.cpp b/Source/player.cpp index 7f21af54eff..7c8cd563b2f 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -1473,8 +1473,8 @@ void ValidatePlayer() void CheckCheatStats(Player &player) { - if (player._pStrength > 750) { - player._pStrength = 750; + if (player.strength > 750) { + player.strength = 750; } if (player._pDexterity > 750) { @@ -1651,7 +1651,7 @@ int Player::GetCurrentAttributeValue(CharacterAttribute attribute) const case CharacterAttribute::Magic: return this->_pMagic; case CharacterAttribute::Strength: - return this->_pStrength; + return this->strength; case CharacterAttribute::Vitality: return this->_pVitality; default: @@ -2275,7 +2275,7 @@ void CreatePlayer(Player &player, HeroClass c) const ClassAttributes &attr = player.getClassAttributes(); player._pBaseStr = attr.baseStr; - player._pStrength = player._pBaseStr; + player.strength = player._pBaseStr; player._pBaseMag = attr.baseMag; player._pMagic = player._pBaseMag; @@ -3281,7 +3281,7 @@ void ModifyPlrStr(Player &player, int l) { l = std::clamp(l, 0 - player._pBaseStr, player.GetMaximumAttributeValue(CharacterAttribute::Strength) - player._pBaseStr); - player._pStrength += l; + player.strength += l; player._pBaseStr += l; CalcPlrInv(player, true); diff --git a/Source/player.h b/Source/player.h index a6c392c5413..3fa258dc1f2 100644 --- a/Source/player.h +++ b/Source/player.h @@ -226,7 +226,7 @@ struct Player { int lightId; int _pNumInv; - int _pStrength; + int strength; // _pStrength int _pBaseStr; int _pMagic; int _pBaseMag; @@ -400,7 +400,7 @@ struct Player { bool CanUseItem(const Item &item) const { - return _pStrength >= item._iMinStr + return strength >= item._iMinStr && _pMagic >= item._iMinMag && _pDexterity >= item._iMinDex; } diff --git a/test/fixtures/memory_map/player.txt b/test/fixtures/memory_map/player.txt index 3707e38f8f1..1345700c142 100644 --- a/test/fixtures/memory_map/player.txt +++ b/test/fixtures/memory_map/player.txt @@ -64,7 +64,7 @@ R 8 _pLvlChanging R 256 _pName R 8 _pClass R 24 alignment -R 32 _pStrength +R 32 strength R 32 _pBaseStr R 32 _pMagic R 32 _pBaseMag diff --git a/test/pack_test.cpp b/test/pack_test.cpp index 79d78e8d23b..c3e2172562f 100644 --- a/test/pack_test.cpp +++ b/test/pack_test.cpp @@ -1057,7 +1057,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_numInv) TEST_F(NetPackTest, UnPackNetPlayer_invalid_strength) { - MyPlayer->_pStrength++; + MyPlayer->strength++; ASSERT_FALSE(TestNetPackValidation()); } diff --git a/test/player_test.cpp b/test/player_test.cpp index 40dec523fac..442e8e89dd6 100644 --- a/test/player_test.cpp +++ b/test/player_test.cpp @@ -108,7 +108,7 @@ static void AssertPlayer(Player &player) ASSERT_STREQ(player._pName, ""); ASSERT_EQ(player._pClass, HeroClass::Rogue); ASSERT_EQ(player._pBaseStr, 20); - ASSERT_EQ(player._pStrength, 20); + ASSERT_EQ(player.strength, 20); ASSERT_EQ(player._pBaseMag, 15); ASSERT_EQ(player._pMagic, 15); ASSERT_EQ(player._pBaseDex, 30); diff --git a/test/writehero_test.cpp b/test/writehero_test.cpp index adef0be6db6..43ba35753b0 100644 --- a/test/writehero_test.cpp +++ b/test/writehero_test.cpp @@ -274,7 +274,7 @@ void AssertPlayer(Player &player) ASSERT_STREQ(player._pName, "TestPlayer"); ASSERT_EQ(player._pClass, HeroClass::Rogue); ASSERT_EQ(player._pBaseStr, 55); - ASSERT_EQ(player._pStrength, 124); + ASSERT_EQ(player.strength, 124); ASSERT_EQ(player._pBaseMag, 70); ASSERT_EQ(player._pMagic, 80); ASSERT_EQ(player._pBaseDex, 250);