Skip to content

Commit

Permalink
Rename Player struct variables: _pmode
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Jul 27, 2024
1 parent 5ae0e5e commit 2a819b0
Show file tree
Hide file tree
Showing 23 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion Source/automap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ void SearchAutomapItem(const Surface &out, const Displacement &myPlayerOffset, i
{
const Player &player = *MyPlayer;
Point tile = player.position.tile;
if (player._pmode == PM_WALK_SIDEWAYS) {
if (player.mode == PM_WALK_SIDEWAYS) {
tile = player.position.future;
if (player._pdir == Direction::West)
tile.x++;
Expand Down
4 changes: 2 additions & 2 deletions Source/controls/plrctrls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,13 +1291,13 @@ void WalkInDir(Player &player, AxisDirection dir)
player._pdir = pdir;

if (IsStandingGround()) {
if (player._pmode == PM_STAND)
if (player.mode == PM_STAND)
StartStand(player, pdir);
return;
}

if (PosOkPlayer(player, delta) && IsPathBlocked(player.position.future, pdir)) {
if (player._pmode == PM_STAND)
if (player.mode == PM_STAND)
StartStand(player, pdir);
return; // Don't start backtrack around obstacles
}
Expand Down
2 changes: 1 addition & 1 deletion Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ void CycleSpellHotkeys(bool next)

bool IsPlayerDead()
{
return MyPlayer->_pmode == PM_DEATH || MyPlayerIsDead;
return MyPlayer->mode == PM_DEATH || MyPlayerIsDead;
}

bool IsGameRunning()
Expand Down
6 changes: 3 additions & 3 deletions Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,14 @@ void DrawDungeon(const Surface &out, Point tilePosition, Point targetBufferPosit
int playerId = static_cast<int>(pid) + 1;
// If sprite is moving southwards or east, we want to draw it offset from the tile it's moving to, so we need negative ID
// This respests the order that tiles are drawn. By using the negative id, we ensure that the sprite is drawn with priority
if (player->_pmode == PM_WALK_SOUTHWARDS || (player->_pmode == PM_WALK_SIDEWAYS && player->_pdir == Direction::East))
if (player->mode == PM_WALK_SOUTHWARDS || (player->mode == PM_WALK_SIDEWAYS && player->_pdir == Direction::East))
playerId = -playerId;
if (dPlayer[tilePosition.x][tilePosition.y] == playerId) {
auto tempTilePosition = tilePosition;
auto tempTargetBufferPosition = targetBufferPosition;

// Offset the sprite to the tile it's moving from
if (player->_pmode == PM_WALK_SOUTHWARDS) {
if (player->mode == PM_WALK_SOUTHWARDS) {
switch (player->_pdir) {
case Direction::SouthWest:
tempTargetBufferPosition += { TILE_WIDTH / 2, -TILE_HEIGHT / 2 };
Expand All @@ -763,7 +763,7 @@ void DrawDungeon(const Surface &out, Point tilePosition, Point targetBufferPosit
DVL_UNREACHABLE();
}
tempTilePosition += Opposite(player->_pdir);
} else if (player->_pmode == PM_WALK_SIDEWAYS && player->_pdir == Direction::East) {
} else if (player->mode == PM_WALK_SIDEWAYS && player->_pdir == Direction::East) {
tempTargetBufferPosition += { -TILE_WIDTH, 0 };
tempTilePosition += Opposite(player->_pdir);
}
Expand Down
6 changes: 3 additions & 3 deletions Source/gamemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void GamemenuUpdateSingle()
{
sgSingleMenu[3].setEnabled(gbValidSaveFile);

bool enable = MyPlayer->_pmode != PM_DEATH && !MyPlayerIsDead;
bool enable = MyPlayer->mode != PM_DEATH && !MyPlayerIsDead;

sgSingleMenu[0].setEnabled(enable);
}
Expand All @@ -102,7 +102,7 @@ void GamemenuPrevious(bool /*bActivate*/)
void GamemenuNewGame(bool /*bActivate*/)
{
for (Player &player : Players) {
player._pmode = PM_QUIT;
player.mode = PM_QUIT;
player._pInvincible = true;
}

Expand Down Expand Up @@ -322,7 +322,7 @@ void gamemenu_save_game(bool /*bActivate*/)
return;
}

if (MyPlayer->_pmode == PM_DEATH || MyPlayerIsDead) {
if (MyPlayer->mode == PM_DEATH || MyPlayerIsDead) {
gamemenu_off();
return;
}
Expand Down
8 changes: 4 additions & 4 deletions Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ bool CanWield(Player &player, const Item &item)
*/
bool CanEquip(Player &player, const Item &item, inv_body_loc bodyLocation)
{
if (!CanEquip(item) || player._pmode > PM_WALK_SIDEWAYS || !player.InvBody[bodyLocation].isEmpty()) {
if (!CanEquip(item) || player.mode > PM_WALK_SIDEWAYS || !player.InvBody[bodyLocation].isEmpty()) {
return false;
}

Expand Down Expand Up @@ -564,7 +564,7 @@ void CheckInvPaste(Player &player, Point cursorPosition)
player.Say(HeroSpeech::ICantUseThisYet);
return;
}
if (player._pmode > PM_WALK_SIDEWAYS)
if (player.mode > PM_WALK_SIDEWAYS)
return;
}

Expand Down Expand Up @@ -603,7 +603,7 @@ void CheckInvPaste(Player &player, Point cursorPosition)

void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool dropItem)
{
if (player._pmode > PM_WALK_SIDEWAYS) {
if (player.mode > PM_WALK_SIDEWAYS) {
return;
}

Expand Down Expand Up @@ -1555,7 +1555,7 @@ void inv_update_rem_item(Player &player, inv_body_loc iv)
{
player.InvBody[iv].clear();

CalcPlrInv(player, player._pmode != PM_DEATH);
CalcPlrInv(player, player.mode != PM_DEATH);
}

void CheckInvSwap(Player &player, const Item &item, int invGridIndex)
Expand Down
2 changes: 1 addition & 1 deletion Source/levels/trigs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ void CheckTriggers()
{
Player &myPlayer = *MyPlayer;

if (myPlayer._pmode != PM_STAND)
if (myPlayer.mode != PM_STAND)
return;

for (int i = 0; i < numtrigs; i++) {
Expand Down
8 changes: 4 additions & 4 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void LoadAndValidateItemData(LoadHelper &file, Item &item)

void LoadPlayer(LoadHelper &file, Player &player)
{
player._pmode = static_cast<PLR_MODE>(file.NextLE<int32_t>());
player.mode = static_cast<PLR_MODE>(file.NextLE<int32_t>());

for (int8_t &step : player.walkpath) {
step = file.NextLE<int8_t>();
Expand Down Expand Up @@ -468,7 +468,7 @@ void LoadPlayer(LoadHelper &file, Player &player)

int32_t tempPositionX = file.NextLE<int32_t>();
int32_t tempPositionY = file.NextLE<int32_t>();
if (player._pmode == PM_WALK_NORTHWARDS) {
if (player.mode == PM_WALK_NORTHWARDS) {
// These values are saved as offsets to remain consistent with old savefiles
tempPositionX += player.position.tile.x;
tempPositionY += player.position.tile.y;
Expand Down Expand Up @@ -1161,7 +1161,7 @@ void SaveItem(SaveHelper &file, const Item &item)

void SavePlayer(SaveHelper &file, const Player &player)
{
file.WriteLE<int32_t>(player._pmode);
file.WriteLE<int32_t>(player.mode);
for (int8_t step : player.walkpath)
file.WriteLE<int8_t>(step);
file.WriteLE<uint8_t>(player.plractive ? 1 : 0);
Expand Down Expand Up @@ -1292,7 +1292,7 @@ void SavePlayer(SaveHelper &file, const Player &player)

int32_t tempPositionX = player.position.temp.x;
int32_t tempPositionY = player.position.temp.y;
if (player._pmode == PM_WALK_NORTHWARDS) {
if (player.mode == PM_WALK_NORTHWARDS) {
// For backwards compatibility, save this as an offset
tempPositionX -= player.position.tile.x;
tempPositionY -= player.position.tile.y;
Expand Down
2 changes: 1 addition & 1 deletion Source/lua/modules/dev/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ std::string DebugCmdPlayerInfo(std::optional<uint8_t> id)
return StrCat("Plr ", playerId, " is ", player._pName,
"\nLvl: ", player.plrlevel, " Changing: ", player._pLvlChanging,
"\nTile.x: ", player.position.tile.x, " Tile.y: ", player.position.tile.y, " Target.x: ", target.x, " Target.y: ", target.y,
"\nMode: ", player._pmode, " destAction: ", player.destAction, " walkpath[0]: ", player.walkpath[0],
"\nMode: ", player.mode, " destAction: ", player.destAction, " walkpath[0]: ", player.walkpath[0],
"\nInvincible: ", player._pInvincible ? 1 : 0, " HitPoints: ", player._pHitPoints);
}

Expand Down
10 changes: 5 additions & 5 deletions Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ bool Plr2PlrMHit(const Player &player, Player &target, int mindam, int maxdam, i

*blocked = false;

if (target.isOnArenaLevel() && target._pmode == PM_WALK_SIDEWAYS)
if (target.isOnArenaLevel() && target.mode == PM_WALK_SIDEWAYS)
return false;

if (target._pInvincible) {
Expand Down Expand Up @@ -341,7 +341,7 @@ bool Plr2PlrMHit(const Player &player, Player &target, int mindam, int maxdam, i
}

int blkper = 100;
if (!shift && (target._pmode == PM_STAND || target._pmode == PM_ATTACK) && target._pBlockFlag) {
if (!shift && (target.mode == PM_STAND || target.mode == PM_ATTACK) && target._pBlockFlag) {
blkper = GenerateRnd(100);
}

Expand Down Expand Up @@ -1022,7 +1022,7 @@ bool PlayerMHit(Player &player, Monster *monster, int dist, int mind, int maxd,
hper = std::max(hper, minhit);

int blk = 100;
if ((player._pmode == PM_STAND || player._pmode == PM_ATTACK) && player._pBlockFlag) {
if ((player.mode == PM_STAND || player.mode == PM_ATTACK) && player._pBlockFlag) {
blk = GenerateRnd(100);
}

Expand Down Expand Up @@ -3336,11 +3336,11 @@ void ProcessTownPortal(Missile &missile)
}

for (Player &player : Players) {
if (player.plractive && player.isOnActiveLevel() && !player._pLvlChanging && player._pmode == PM_STAND && player.position.tile == missile.position.tile) {
if (player.plractive && player.isOnActiveLevel() && !player._pLvlChanging && player.mode == PM_STAND && player.position.tile == missile.position.tile) {
ClrPlrPath(player);
if (&player == MyPlayer) {
NetSendCmdParam1(true, CMD_WARP, missile._misource);
player._pmode = PM_NEWLVL;
player.mode = PM_NEWLVL;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Source/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ void MonsterAttackPlayer(Monster &monster, Player &player, int hit, int minDam,
int minhit = GetMinHit();
hit = std::max(hit, minhit);
int blkper = 100;
if ((player._pmode == PM_STAND || player._pmode == PM_ATTACK) && player._pBlockFlag) {
if ((player.mode == PM_STAND || player.mode == PM_ATTACK) && player._pBlockFlag) {
blkper = GenerateRnd(100);
}
int blk = player.GetBlockChance() - (monster.level(sgGameInitInfo.nDifficulty) * 2);
Expand Down Expand Up @@ -1189,7 +1189,7 @@ void MonsterAttackPlayer(Monster &monster, Player &player, int hit, int minDam,
}
StartPlrHit(player, dam, false);
if ((monster.flags & MFLAG_KNOCKBACK) != 0) {
if (player._pmode != PM_GOTHIT)
if (player.mode != PM_GOTHIT)
StartPlrHit(player, 0, true);

Point newPosition = player.position.tile + monster.direction;
Expand Down Expand Up @@ -3920,7 +3920,7 @@ void PrepDoEnding()
myPlayer.pDiabloKillLevel = std::max(myPlayer.pDiabloKillLevel, static_cast<uint8_t>(sgGameInitInfo.nDifficulty + 1));

for (Player &player : Players) {
player._pmode = PM_QUIT;
player.mode = PM_QUIT;
player._pInvincible = true;
if (gbIsMultiplayer) {
if (player._pHitPoints >> 6 == 0)
Expand Down Expand Up @@ -4449,7 +4449,7 @@ void MissToMonst(Missile &missile, Point position)
if (IsAnyOf(monster.type().type, MT_NSNAKE, MT_RSNAKE, MT_BSNAKE, MT_GSNAKE))
return;

if (player->_pmode != PM_GOTHIT && player->_pmode != PM_DEATH)
if (player->mode != PM_GOTHIT && player->mode != PM_DEATH)
StartPlrHit(*player, 0, true);
Point newPosition = oldPosition + monster.direction;
if (PosOkPlayer(*player, newPosition)) {
Expand Down
2 changes: 1 addition & 1 deletion Source/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2107,7 +2107,7 @@ size_t OnPlayerJoinLevel(const TCmd *pCmd, Player &player)
StartStand(player, Direction::South);
} else {
player._pgfxnum &= ~0xFU;
player._pmode = PM_DEATH;
player.mode = PM_DEATH;
NewPlrAnim(player, player_graphic::Death, Direction::South);
player.AnimInfo.currentFrame = player.AnimInfo.numberOfFrames - 2;
dFlags[player.position.tile.x][player.position.tile.y] |= DungeonFlag::DeadPlayer;
Expand Down
6 changes: 3 additions & 3 deletions Source/multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void NetReceivePlayerData(TPkt *pkt)
Point target = myPlayer.GetTargetPosition();
// Don't send desired target position when we will change our position soon.
// This prevents a desync where the remote client starts a walking to the old target position when the teleport is finished but the the new position isn't received yet.
if (myPlayer._pmode == PM_SPELL && IsAnyOf(myPlayer.executedSpell.spellId, SpellID::Teleport, SpellID::Phasing, SpellID::Warp))
if (myPlayer.mode == PM_SPELL && IsAnyOf(myPlayer.executedSpell.spellId, SpellID::Teleport, SpellID::Phasing, SpellID::Warp))
target = {};

pkt->hdr.wCheck = HeaderCheckVal;
Expand Down Expand Up @@ -374,7 +374,7 @@ void SetupLocalPositions()
myPlayer.setLevel(currlevel);
myPlayer._pLvlChanging = true;
myPlayer.pLvlLoad = 0;
myPlayer._pmode = PM_NEWLVL;
myPlayer.mode = PM_NEWLVL;
myPlayer.destAction = ACTION_NONE;
}

Expand Down Expand Up @@ -867,7 +867,7 @@ void recv_plrinfo(Player &player, const TCmdPlrInfoHdr &header, bool recv)
}

player._pgfxnum &= ~0xFU;
player._pmode = PM_DEATH;
player.mode = PM_DEATH;
NewPlrAnim(player, player_graphic::Death, Direction::South);
player.AnimInfo.currentFrame = player.AnimInfo.numberOfFrames - 2;
dFlags[player.position.tile.x][player.position.tile.y] |= DungeonFlag::DeadPlayer;
Expand Down
2 changes: 1 addition & 1 deletion Source/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ void UpdateBurningCrossDamage(Object &cross)

Player &myPlayer = *MyPlayer;

if (myPlayer._pmode == PM_DEATH)
if (myPlayer.mode == PM_DEATH)
return;

int8_t fireResist = myPlayer._pFireResist;
Expand Down
Loading

0 comments on commit 2a819b0

Please sign in to comment.