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: _pVitality #7230

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
4 changes: 2 additions & 2 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2597,7 +2597,7 @@ void CalcPlrPrimaryStats(Player &player, int strength, int &magic, int dexterity
player._pStrength = 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);
player.vitality = std::max(0, vitality + player._pBaseVit);
}

void CalcPlrLightRadius(Player &player, int lrad)
Expand Down Expand Up @@ -2654,7 +2654,7 @@ void CalcPlrDamageMod(Player &player)
else if (rightHandItem._itype == ItemType::Shield)
player._pIAC -= rightHandItem._iAC / 2;
} else if (!player.isHoldingItem(ItemType::Staff) && !player.isHoldingItem(ItemType::Bow)) {
player._pDamageMod += playerLevel * player._pVitality / 100;
player._pDamageMod += playerLevel * player.vitality / 100;
}
player._pIAC += playerLevel / 4;
return;
Expand Down
4 changes: 2 additions & 2 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ void LoadPlayer(LoadHelper &file, Player &player)
player._pBaseMag = file.NextLE<int32_t>();
player._pDexterity = file.NextLE<int32_t>();
player._pBaseDex = file.NextLE<int32_t>();
player._pVitality = file.NextLE<int32_t>();
player.vitality = file.NextLE<int32_t>();
player._pBaseVit = file.NextLE<int32_t>();
player._pStatPts = file.NextLE<int32_t>();
player._pDamageMod = file.NextLE<int32_t>();
Expand Down Expand Up @@ -1261,7 +1261,7 @@ void SavePlayer(SaveHelper &file, const Player &player)
file.WriteLE<int32_t>(player._pBaseMag);
file.WriteLE<int32_t>(player._pDexterity);
file.WriteLE<int32_t>(player._pBaseDex);
file.WriteLE<int32_t>(player._pVitality);
file.WriteLE<int32_t>(player.vitality);
file.WriteLE<int32_t>(player._pBaseVit);
file.WriteLE<int32_t>(player._pStatPts);
file.WriteLE<int32_t>(player._pDamageMod);
Expand Down
8 changes: 4 additions & 4 deletions Source/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void PackNetPlayer(PlayerNetPack &packed, const Player &player)
packed.pStrength = SDL_SwapLE32(player._pStrength);
packed.pMagic = SDL_SwapLE32(player._pMagic);
packed.pDexterity = SDL_SwapLE32(player._pDexterity);
packed.pVitality = SDL_SwapLE32(player._pVitality);
packed.pVitality = SDL_SwapLE32(player.vitality);
packed.pHitPoints = SDL_SwapLE32(player._pHitPoints);
packed.pMaxHP = SDL_SwapLE32(player._pMaxHP);
packed.pMana = SDL_SwapLE32(player._pMana);
Expand Down Expand Up @@ -472,7 +472,7 @@ void UnPackPlayer(const PlayerPack &packed, Player &player)
player._pBaseDex = std::min<uint8_t>(packed.pBaseDex, player.GetMaximumAttributeValue(CharacterAttribute::Dexterity));
player._pDexterity = player._pBaseDex;
player._pBaseVit = std::min<uint8_t>(packed.pBaseVit, player.GetMaximumAttributeValue(CharacterAttribute::Vitality));
player._pVitality = player._pBaseVit;
player.vitality = player._pBaseVit;
player._pStatPts = packed.pStatPts;

player._pExperience = SDL_SwapLE32(packed.pExperience);
Expand Down Expand Up @@ -607,7 +607,7 @@ bool UnPackNetPlayer(const PlayerNetPack &packed, Player &player)
player._pBaseDex = packed.pBaseDex;
player._pDexterity = player._pBaseDex;
player._pBaseVit = packed.pBaseVit;
player._pVitality = player._pBaseVit;
player.vitality = player._pBaseVit;
player._pStatPts = packed.pStatPts;

player._pExperience = SDL_SwapLE32(packed.pExperience);
Expand Down Expand Up @@ -678,7 +678,7 @@ bool UnPackNetPlayer(const PlayerNetPack &packed, Player &player)
ValidateFields(player._pStrength, SDL_SwapLE32(packed.pStrength), player._pStrength == 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));
ValidateFields(player.vitality, SDL_SwapLE32(packed.pVitality), player.vitality == SDL_SwapLE32(packed.pVitality));
ValidateFields(player._pHitPoints, SDL_SwapLE32(packed.pHitPoints), player._pHitPoints == SDL_SwapLE32(packed.pHitPoints));
ValidateFields(player._pMaxHP, SDL_SwapLE32(packed.pMaxHP), player._pMaxHP == SDL_SwapLE32(packed.pMaxHP));
ValidateFields(player._pMana, SDL_SwapLE32(packed.pMana), player._pMana == SDL_SwapLE32(packed.pMana));
Expand Down
2 changes: 1 addition & 1 deletion Source/panels/charpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ PanelEntry panelEntries[] = {
[]() { return StyledText { GetCurrentStatColor(CharacterAttribute::Dexterity), StrCat(InspectPlayer->_pDexterity) }; } },
{ N_("Vitality"), { LeftColumnLabelX, 219 }, 45, LeftColumnLabelWidth, []() { return StyledText { GetBaseStatColor(CharacterAttribute::Vitality), StrCat(InspectPlayer->_pBaseVit) }; } },
{ "", { 135, 219 }, 45, 0,
[]() { return StyledText { GetCurrentStatColor(CharacterAttribute::Vitality), StrCat(InspectPlayer->_pVitality) }; } },
[]() { return StyledText { GetCurrentStatColor(CharacterAttribute::Vitality), StrCat(InspectPlayer->vitality) }; } },
{ N_("Points to distribute"), { LeftColumnLabelX, 248 }, 45, LeftColumnLabelWidth,
[]() {
InspectPlayer->_pStatPts = std::min(CalcStatDiff(*InspectPlayer), InspectPlayer->_pStatPts);
Expand Down
2 changes: 1 addition & 1 deletion Source/pfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Game2UiPlayer(const Player &player, _uiheroinfo *heroinfo, bool bHasSaveFil
heroinfo->strength = player._pStrength;
heroinfo->magic = player._pMagic;
heroinfo->dexterity = player._pDexterity;
heroinfo->vitality = player._pVitality;
heroinfo->vitality = player.vitality;
heroinfo->hassaved = bHasSaveFile;
heroinfo->herorank = player.pDiabloKillLevel;
heroinfo->spawned = gbIsSpawn;
Expand Down
10 changes: 5 additions & 5 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,8 +1485,8 @@ void CheckCheatStats(Player &player)
player._pMagic = 750;
}

if (player._pVitality > 750) {
player._pVitality = 750;
if (player.vitality > 750) {
player.vitality = 750;
}

if (player._pHitPoints > 128000) {
Expand Down Expand Up @@ -1653,7 +1653,7 @@ int Player::GetCurrentAttributeValue(CharacterAttribute attribute) const
case CharacterAttribute::Strength:
return this->_pStrength;
case CharacterAttribute::Vitality:
return this->_pVitality;
return this->vitality;
default:
app_fatal("Unsupported attribute");
}
Expand Down Expand Up @@ -2284,7 +2284,7 @@ void CreatePlayer(Player &player, HeroClass c)
player._pDexterity = player._pBaseDex;

player._pBaseVit = attr.baseVit;
player._pVitality = player._pBaseVit;
player.vitality = player._pBaseVit;

player._pHitPoints = player.calculateBaseLife();
player._pMaxHP = player._pHitPoints;
Expand Down Expand Up @@ -3332,7 +3332,7 @@ void ModifyPlrVit(Player &player, int l)
{
l = std::clamp(l, 0 - player._pBaseVit, player.GetMaximumAttributeValue(CharacterAttribute::Vitality) - player._pBaseVit);

player._pVitality += l;
player.vitality += l;
player._pBaseVit += l;

int ms = l;
Expand Down
2 changes: 1 addition & 1 deletion Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ struct Player {
int _pBaseMag;
int _pDexterity;
int _pBaseDex;
int _pVitality;
int vitality; // _pVitality
int _pBaseVit;
int _pStatPts;
int _pDamageMod;
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 @@ -70,7 +70,7 @@ R 32 _pMagic
R 32 _pBaseMag
R 32 _pDexterity
R 32 _pBaseDex
R 32 _pVitality
R 32 vitality
R 32 _pBaseVit
R 32 _pStatPts
R 32 _pDamageMod
Expand Down
2 changes: 1 addition & 1 deletion test/pack_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_dexterity)

TEST_F(NetPackTest, UnPackNetPlayer_invalid_vitality)
{
MyPlayer->_pVitality++;
MyPlayer->vitality++;
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 @@ -114,7 +114,7 @@ static void AssertPlayer(Player &player)
ASSERT_EQ(player._pBaseDex, 30);
ASSERT_EQ(player._pDexterity, 30);
ASSERT_EQ(player._pBaseVit, 20);
ASSERT_EQ(player._pVitality, 20);
ASSERT_EQ(player.vitality, 20);
ASSERT_EQ(player.getCharacterLevel(), 1);
ASSERT_EQ(player._pStatPts, 0);
ASSERT_EQ(player._pExperience, 0);
Expand Down
2 changes: 1 addition & 1 deletion test/writehero_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void AssertPlayer(Player &player)
ASSERT_EQ(player._pBaseDex, 250);
ASSERT_EQ(player._pDexterity, 281);
ASSERT_EQ(player._pBaseVit, 80);
ASSERT_EQ(player._pVitality, 90);
ASSERT_EQ(player.vitality, 90);
ASSERT_EQ(player.getCharacterLevel(), 50);
ASSERT_EQ(player._pStatPts, 0);
ASSERT_EQ(player._pExperience, 1583495809);
Expand Down
Loading