Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Player struct variables: _pStrength #7224

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void LoadPlayer(LoadHelper &file, Player &player)
file.NextBytes(player._pName, PlayerNameLength);
player._pClass = static_cast<HeroClass>(file.NextLE<int8_t>());
file.Skip(3); // Alignment
player._pStrength = file.NextLE<int32_t>();
player.strength = file.NextLE<int32_t>();
player._pBaseStr = file.NextLE<int32_t>();
player._pMagic = file.NextLE<int32_t>();
player._pBaseMag = file.NextLE<int32_t>();
Expand Down Expand Up @@ -1255,7 +1255,7 @@ void SavePlayer(SaveHelper &file, const Player &player)
file.WriteBytes(player._pName, PlayerNameLength);
file.WriteLE<int8_t>(static_cast<int8_t>(player._pClass));
file.Skip(3); // Alignment
file.WriteLE<int32_t>(player._pStrength);
file.WriteLE<int32_t>(player.strength);
file.WriteLE<int32_t>(player._pBaseStr);
file.WriteLE<int32_t>(player._pMagic);
file.WriteLE<int32_t>(player._pBaseMag);
Expand Down
8 changes: 4 additions & 4 deletions Source/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -466,7 +466,7 @@ void UnPackPlayer(const PlayerPack &packed, Player &player)
InitPlayer(player, true);

player._pBaseStr = std::min<uint8_t>(packed.pBaseStr, player.GetMaximumAttributeValue(CharacterAttribute::Strength));
player._pStrength = player._pBaseStr;
player.strength = player._pBaseStr;
player._pBaseMag = std::min<uint8_t>(packed.pBaseMag, player.GetMaximumAttributeValue(CharacterAttribute::Magic));
player._pMagic = player._pBaseMag;
player._pBaseDex = std::min<uint8_t>(packed.pBaseDex, player.GetMaximumAttributeValue(CharacterAttribute::Dexterity));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion Source/panels/charpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Source/pfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ struct Player {
int lightId;

int _pNumInv;
int _pStrength;
int strength; // _pStrength
int _pBaseStr;
int _pMagic;
int _pBaseMag;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/memory_map/player.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/pack_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_numInv)

TEST_F(NetPackTest, UnPackNetPlayer_invalid_strength)
{
MyPlayer->_pStrength++;
MyPlayer->strength++;
ASSERT_FALSE(TestNetPackValidation());
}

Expand Down
2 changes: 1 addition & 1 deletion test/player_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/writehero_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading