Skip to content

Commit

Permalink
Rename Player struct variables: _pLvlVisited
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Jul 27, 2024
1 parent 5ae0e5e commit 36545ff
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 37 deletions.
6 changes: 3 additions & 3 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2959,13 +2959,13 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
bool visited = false;
for (const Player &player : Players) {
if (player.plractive)
visited = visited || player._pLvlVisited[currlevel];
visited = visited || player.isLevelVisited[currlevel];
}

SetRndSeed(DungeonSeeds[currlevel]);

if (leveltype != DTYPE_TOWN) {
if (firstflag || lvldir == ENTRY_LOAD || !myPlayer._pLvlVisited[currlevel] || gbIsMultiplayer) {
if (firstflag || lvldir == ENTRY_LOAD || !myPlayer.isLevelVisited[currlevel] || gbIsMultiplayer) {
HoldThemeRooms();
[[maybe_unused]] uint32_t mid1Seed = GetLCGEngineState();
InitGolems();
Expand Down Expand Up @@ -3010,7 +3010,7 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
InitMissiles();
IncProgress();

if (!firstflag && lvldir != ENTRY_LOAD && myPlayer._pLvlVisited[currlevel] && !gbIsMultiplayer)
if (!firstflag && lvldir != ENTRY_LOAD && myPlayer.isLevelVisited[currlevel] && !gbIsMultiplayer)
LoadLevel();
if (gbIsMultiplayer)
DeltaLoadLevel();
Expand Down
6 changes: 3 additions & 3 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ void LoadPlayer(LoadHelper &file, Player &player)
file.Skip<uint32_t>(); // Skip actionFrame

for (uint8_t i = 0; i < giNumberOfLevels; i++)
player._pLvlVisited[i] = file.NextBool8();
player.isLevelVisited[i] = file.NextBool8();

for (uint8_t i = 0; i < giNumberOfLevels; i++)
player._pSLvlVisited[i] = file.NextBool8();
Expand Down Expand Up @@ -1307,7 +1307,7 @@ void SavePlayer(SaveHelper &file, const Player &player)
file.WriteLE<int32_t>(offset2.deltaY);
file.Skip<int32_t>(); // Skip _pVar8
for (uint8_t i = 0; i < giNumberOfLevels; i++)
file.WriteLE<uint8_t>(player._pLvlVisited[i] ? 1 : 0);
file.WriteLE<uint8_t>(player.isLevelVisited[i] ? 1 : 0);
for (uint8_t i = 0; i < giNumberOfLevels; i++)
file.WriteLE<uint8_t>(player._pSLvlVisited[i] ? 1 : 0); // only 10 used

Expand Down Expand Up @@ -1904,7 +1904,7 @@ void SaveLevel(SaveWriter &saveWriter, LevelConversionData *levelConversionData)
}

if (!setlevel)
myPlayer._pLvlVisited[currlevel] = true;
myPlayer.isLevelVisited[currlevel] = true;
else
myPlayer._pSLvlVisited[setlvlnum] = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/lua/modules/dev/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ std::string DebugCmdResetLevel(uint8_t level, std::optional<int> seed)
if (myPlayer.isOnLevel(level))
return "Unable to reset dungeon levels occupied by players!";

myPlayer._pLvlVisited[level] = false;
myPlayer.isLevelVisited[level] = false;
DeltaClearLevel(level);

if (seed.has_value()) {
Expand Down
2 changes: 1 addition & 1 deletion Source/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,7 @@ void DeltaSaveLevel()
MyPlayer->_pSLvlVisited[static_cast<uint8_t>(setlvlnum)] = true;
} else {
localLevel = GetLevelForMultiplayer(currlevel, setlevel);
MyPlayer->_pLvlVisited[currlevel] = true;
MyPlayer->isLevelVisited[currlevel] = true;
}
DeltaLeaveSync(localLevel);
}
Expand Down
20 changes: 10 additions & 10 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void InitLevelChange(Player &player)
if (&player == MyPlayer) {
player.occupyTile(player.position.tile, false);
} else {
player._pLvlVisited[player.plrlevel] = true;
player.isLevelVisited[player.plrlevel] = true;
}

ClrPlrPath(player);
Expand Down Expand Up @@ -2314,7 +2314,7 @@ void CreatePlayer(Player &player, HeroClass c)
// CreatePlrItems calls AutoEquip which will overwrite the player graphic if required
player._pgfxnum = static_cast<uint8_t>(PlayerWeaponGraphic::Unarmed);

for (bool &levelVisited : player._pLvlVisited) {
for (bool &levelVisited : player.isLevelVisited) {
levelVisited = false;
}

Expand Down Expand Up @@ -3417,19 +3417,19 @@ void PlayDungMsgs()
assert(MyPlayer != nullptr);
Player &myPlayer = *MyPlayer;

if (!setlevel && currlevel == 1 && !myPlayer._pLvlVisited[1] && (myPlayer.pDungMsgs & DungMsgCathedral) == 0) {
if (!setlevel && currlevel == 1 && !myPlayer.isLevelVisited[1] && (myPlayer.pDungMsgs & DungMsgCathedral) == 0) {
myPlayer.Say(HeroSpeech::TheSanctityOfThisPlaceHasBeenFouled, 40);
myPlayer.pDungMsgs = myPlayer.pDungMsgs | DungMsgCathedral;
} else if (!setlevel && currlevel == 5 && !myPlayer._pLvlVisited[5] && (myPlayer.pDungMsgs & DungMsgCatacombs) == 0) {
} else if (!setlevel && currlevel == 5 && !myPlayer.isLevelVisited[5] && (myPlayer.pDungMsgs & DungMsgCatacombs) == 0) {
myPlayer.Say(HeroSpeech::TheSmellOfDeathSurroundsMe, 40);
myPlayer.pDungMsgs |= DungMsgCatacombs;
} else if (!setlevel && currlevel == 9 && !myPlayer._pLvlVisited[9] && (myPlayer.pDungMsgs & DungMsgCaves) == 0) {
} else if (!setlevel && currlevel == 9 && !myPlayer.isLevelVisited[9] && (myPlayer.pDungMsgs & DungMsgCaves) == 0) {
myPlayer.Say(HeroSpeech::ItsHotDownHere, 40);
myPlayer.pDungMsgs |= DungMsgCaves;
} else if (!setlevel && currlevel == 13 && !myPlayer._pLvlVisited[13] && (myPlayer.pDungMsgs & DungMsgHell) == 0) {
} else if (!setlevel && currlevel == 13 && !myPlayer.isLevelVisited[13] && (myPlayer.pDungMsgs & DungMsgHell) == 0) {
myPlayer.Say(HeroSpeech::IMustBeGettingClose, 40);
myPlayer.pDungMsgs |= DungMsgHell;
} else if (!setlevel && currlevel == 16 && !myPlayer._pLvlVisited[16] && (myPlayer.pDungMsgs & DungMsgDiablo) == 0) {
} else if (!setlevel && currlevel == 16 && !myPlayer.isLevelVisited[16] && (myPlayer.pDungMsgs & DungMsgDiablo) == 0) {
for (auto &monster : Monsters) {
if (monster.type().type != MT_DIABLO) continue;
if (monster.hitPoints > 0) {
Expand All @@ -3439,19 +3439,19 @@ void PlayDungMsgs()
}
break;
}
} else if (!setlevel && currlevel == 17 && !myPlayer._pLvlVisited[17] && (myPlayer.pDungMsgs2 & 1) == 0) {
} else if (!setlevel && currlevel == 17 && !myPlayer.isLevelVisited[17] && (myPlayer.pDungMsgs2 & 1) == 0) {
sfxdelay = 10;
sfxdnum = SfxID::Defiler1;
Quests[Q_DEFILER]._qactive = QUEST_ACTIVE;
Quests[Q_DEFILER]._qlog = true;
Quests[Q_DEFILER]._qmsg = TEXT_DEFILER1;
NetSendCmdQuest(true, Quests[Q_DEFILER]);
myPlayer.pDungMsgs2 |= 1;
} else if (!setlevel && currlevel == 19 && !myPlayer._pLvlVisited[19] && (myPlayer.pDungMsgs2 & 4) == 0) {
} else if (!setlevel && currlevel == 19 && !myPlayer.isLevelVisited[19] && (myPlayer.pDungMsgs2 & 4) == 0) {
sfxdelay = 10;
sfxdnum = SfxID::Defiler3;
myPlayer.pDungMsgs2 |= 4;
} else if (!setlevel && currlevel == 21 && !myPlayer._pLvlVisited[21] && (myPlayer.pDungMsgs & 32) == 0) {
} else if (!setlevel && currlevel == 21 && !myPlayer.isLevelVisited[21] && (myPlayer.pDungMsgs & 32) == 0) {
myPlayer.Say(HeroSpeech::ThisIsAPlaceOfGreatPower, 30);
myPlayer.pDungMsgs |= 32;
} else if (setlevel && setlvlnum == SL_SKELKING && !gbIsSpawn && !myPlayer._pSLvlVisited[SL_SKELKING] && Quests[Q_SKELKING]._qactive == QUEST_ACTIVE) {
Expand Down
2 changes: 1 addition & 1 deletion Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ struct Player {
/** Player's direction when ending movement. Also used for casting direction of SpellID::FireWall. */
Direction tempDirection;

bool _pLvlVisited[NUMLEVELS];
bool isLevelVisited[NUMLEVELS]; // _pLvlVisited
bool _pSLvlVisited[NUMLEVELS]; // only 10 used

item_misc_id _pOilType;
Expand Down
2 changes: 1 addition & 1 deletion Source/stores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ void SetupTownStores()
if (!gbIsMultiplayer) {
l = 0;
for (int i = 0; i < NUMLEVELS; i++) {
if (myPlayer._pLvlVisited[i])
if (myPlayer.isLevelVisited[i])
l = i;
}
} else {
Expand Down
26 changes: 13 additions & 13 deletions Source/towners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ void TownerTalk(_speech_id message)

void TalkToBarOwner(Player &player, Towner &barOwner)
{
if (!player._pLvlVisited[0]) {
if (!player.isLevelVisited[0]) {
InitQTextMsg(TEXT_INTRO);
return;
}

auto &kingQuest = Quests[Q_SKELKING];
if (kingQuest._qactive != QUEST_NOTAVAIL) {
if (player._pLvlVisited[2] || player._pLvlVisited[4]) {
if (player.isLevelVisited[2] || player.isLevelVisited[4]) {
if (kingQuest._qvar2 == 0) {
kingQuest._qvar2 = 1;
kingQuest._qlog = true;
Expand All @@ -315,7 +315,7 @@ void TalkToBarOwner(Player &player, Towner &barOwner)

auto &bannerQuest = Quests[Q_LTBANNER];
if (bannerQuest._qactive != QUEST_NOTAVAIL) {
if ((player._pLvlVisited[3] || player._pLvlVisited[4]) && bannerQuest._qactive != QUEST_DONE) {
if ((player.isLevelVisited[3] || player.isLevelVisited[4]) && bannerQuest._qactive != QUEST_DONE) {
if (bannerQuest._qvar2 == 0) {
bannerQuest._qvar2 = 1;
if (bannerQuest._qactive == QUEST_INIT) {
Expand Down Expand Up @@ -365,7 +365,7 @@ void TalkToDeadguy(Player &player, Towner & /*deadguy*/)
void TalkToBlackSmith(Player &player, Towner &blackSmith)
{
if (Quests[Q_ROCK]._qactive != QUEST_NOTAVAIL) {
if ((player._pLvlVisited[4] || player._pLvlVisited[5]) && Quests[Q_ROCK]._qactive != QUEST_DONE) {
if ((player.isLevelVisited[4] || player.isLevelVisited[5]) && Quests[Q_ROCK]._qactive != QUEST_DONE) {
if (Quests[Q_ROCK]._qvar2 == 0) {
Quests[Q_ROCK]._qvar2 = 1;
Quests[Q_ROCK]._qlog = true;
Expand All @@ -387,7 +387,7 @@ void TalkToBlackSmith(Player &player, Towner &blackSmith)
}
}
if (IsNoneOf(Quests[Q_ANVIL]._qactive, QUEST_NOTAVAIL, QUEST_DONE)) {
if ((player._pLvlVisited[9] || player._pLvlVisited[10]) && Quests[Q_ANVIL]._qvar2 == 0) {
if ((player.isLevelVisited[9] || player.isLevelVisited[10]) && Quests[Q_ANVIL]._qvar2 == 0) {
Quests[Q_ANVIL]._qvar2 = 1;
Quests[Q_ANVIL]._qlog = true;
if (Quests[Q_ANVIL]._qactive == QUEST_INIT) {
Expand Down Expand Up @@ -463,7 +463,7 @@ void TalkToWitch(Player &player, Towner & /*witch*/)

void TalkToBarmaid(Player &player, Towner & /*barmaid*/)
{
if (!player._pLvlVisited[21] && HasInventoryItemWithId(player, IDI_MAPOFDOOM) && Quests[Q_GRAVE]._qmsg != TEXT_GRAVE8) {
if (!player.isLevelVisited[21] && HasInventoryItemWithId(player, IDI_MAPOFDOOM) && Quests[Q_GRAVE]._qmsg != TEXT_GRAVE8) {
Quests[Q_GRAVE]._qactive = QUEST_ACTIVE;
Quests[Q_GRAVE]._qlog = true;
Quests[Q_GRAVE]._qmsg = TEXT_GRAVE8;
Expand All @@ -486,7 +486,7 @@ void TalkToHealer(Player &player, Towner &healer)
{
Quest &poisonWater = Quests[Q_PWATER];
if (poisonWater._qactive != QUEST_NOTAVAIL) {
if ((poisonWater._qactive == QUEST_INIT && (player._pLvlVisited[1] || player._pLvlVisited[5])) || (poisonWater._qactive == QUEST_ACTIVE && !poisonWater._qlog)) {
if ((poisonWater._qactive == QUEST_INIT && (player.isLevelVisited[1] || player.isLevelVisited[5])) || (poisonWater._qactive == QUEST_ACTIVE && !poisonWater._qlog)) {
// Play the dialog and make the quest visible in the log if the player has not started the quest but has
// visited the dungeon at least once, or if they've found the poison water cave before speaking to Pepin
poisonWater._qactive = QUEST_ACTIVE;
Expand Down Expand Up @@ -609,13 +609,13 @@ void TalkToFarmer(Player &player, Towner &farmer)
break;
}

if (!player._pLvlVisited[9] && player.getCharacterLevel() < 15) {
if (!player.isLevelVisited[9] && player.getCharacterLevel() < 15) {
_speech_id qt = TEXT_FARMER8;
if (player._pLvlVisited[2])
if (player.isLevelVisited[2])
qt = TEXT_FARMER5;
if (player._pLvlVisited[5])
if (player.isLevelVisited[5])
qt = TEXT_FARMER7;
if (player._pLvlVisited[7])
if (player.isLevelVisited[7])
qt = TEXT_FARMER9;
InitQTextMsg(qt);
break;
Expand Down Expand Up @@ -700,7 +700,7 @@ void TalkToCowFarmer(Player &player, Towner &cowFarmer)
NetSendCmdQuest(true, quest);
break;
case QUEST_HIVE_ACTIVE:
if (!player._pLvlVisited[9] && player.getCharacterLevel() < 15) {
if (!player.isLevelVisited[9] && player.getCharacterLevel() < 15) {
InitQTextMsg(PickRandomlyAmong({ TEXT_JERSEY9, TEXT_JERSEY10, TEXT_JERSEY11, TEXT_JERSEY12 }));
break;
}
Expand Down Expand Up @@ -808,7 +808,7 @@ bool IsTownerPresent(_talker_id npc)
case TOWN_COWFARM:
return gbIsHellfire && sgGameInitInfo.bCowQuest != 0;
case TOWN_GIRL:
return gbIsHellfire && sgGameInitInfo.bTheoQuest != 0 && MyPlayer->_pLvlVisited[17] && Quests[Q_GIRL]._qactive != QUEST_DONE;
return gbIsHellfire && sgGameInitInfo.bTheoQuest != 0 && MyPlayer->isLevelVisited[17] && Quests[Q_GIRL]._qactive != QUEST_DONE;
default:
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/memory_map/player.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ R 32 _pVar5
R 32 offset2.x
R 32 offset2.y
R 32 actionFrame
M_DA 17 8 _pLvlVisited
M_HF 25 8 _pLvlVisited
M_DA 17 8 isLevelVisited
M_HF 25 8 isLevelVisited
M_DA 17 8 _pSLvlVisited
M_HF 25 8 _pSLvlVisited
R 16 alignment
Expand Down
2 changes: 1 addition & 1 deletion test/player_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static void AssertPlayer(Player &player)
ASSERT_EQ(player._pMagResist, 0);
ASSERT_EQ(player._pFireResist, 0);
ASSERT_EQ(player._pLghtResist, 0);
ASSERT_EQ(CountBool(player._pLvlVisited, NUMLEVELS), 0);
ASSERT_EQ(CountBool(player.isLevelVisited, NUMLEVELS), 0);
ASSERT_EQ(CountBool(player._pSLvlVisited, NUMLEVELS), 0);
// This test case uses a Rogue, starting loadout is a short bow with damage 1-4
ASSERT_EQ(player._pIMinDam, 1);
Expand Down
2 changes: 1 addition & 1 deletion test/writehero_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void AssertPlayer(Player &player)
ASSERT_EQ(player._pMagResist, 75);
ASSERT_EQ(player._pFireResist, 16);
ASSERT_EQ(player._pLghtResist, 75);
ASSERT_EQ(CountBool(player._pLvlVisited, NUMLEVELS), 0);
ASSERT_EQ(CountBool(player.isLevelVisited, NUMLEVELS), 0);
ASSERT_EQ(CountBool(player._pSLvlVisited, NUMLEVELS), 0);
ASSERT_EQ(player._pNFrames, 20);
ASSERT_EQ(player._pWFrames, 8);
Expand Down

0 comments on commit 36545ff

Please sign in to comment.