Skip to content

Commit

Permalink
Refactor Player::golem()
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Mar 12, 2024
1 parent 5d933d7 commit 40a6c25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2096,9 +2096,9 @@ bool Player::isLevelOwnedByLocalClient() const
return false;
}

Monster *Player::golem() const
Monster &Player::golem() const
{
return &Monsters[getId()];
return Monsters[getId()];
}

Player *PlayerAtPosition(Point position, bool ignoreMovingPlayers /*= false*/)
Expand Down
2 changes: 1 addition & 1 deletion Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ struct Player {
/** @brief Checks if the player level is owned by local client. */
bool isLevelOwnedByLocalClient() const;

Monster *golem() const;
Monster &golem() const;
};

extern DVL_API_FOR_TEST uint8_t MyPlayerId;
Expand Down
4 changes: 2 additions & 2 deletions Source/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ int GetManaAmount(const Player &player, SpellID sn)
void ConsumeSpell(Player &player, SpellID sn)
{
if (sn == SpellID::Golem && &player == MyPlayer) {
Monster *golem = player.golem();
Monster &golem = player.golem();

if (golem->hitPoints <= 0)
if (golem.hitPoints <= 0)
return;
}
switch (player.executedSpell.spellType) {
Expand Down

0 comments on commit 40a6c25

Please sign in to comment.