Skip to content

Commit

Permalink
Only track local player movements history to save resources
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Feb 25, 2024
1 parent 2211424 commit 7353b4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ bool DoWalk(Player &player, int variant)
}

// PVP REBALANCE: Track player movements in arena.
if (player.isOnArenaLevel())
if (player.isOnArenaLevel() && player.isMyPlayer())
player.trackLastPlrMovement(variant);

// We reached the new tile -> update the player's tile position
Expand All @@ -487,7 +487,7 @@ bool DoWalk(Player &player, int variant)

// PVP REBALANCE: Increment _pDiawalkCounter and punish reaching DiawalkDamageThreshold for arena use.
if (player.isOnArenaLevel()) {
if (player.calculateDiagonalMovementPercentage() > DiawalkDamageThreshold && &player == MyPlayer)
if (player.calculateDiagonalMovementPercentage() > DiawalkDamageThreshold && player.isMyPlayer())
// Deal 5 HP worth of damage each diagonal movement multiplied by the amount of percent they are above the threshold.
NetSendCmdDamage(true, player, (player.calculateDiagonalMovementPercentage() - DiawalkDamageThreshold) * 5 * 64, DamageType::Physical);
}
Expand Down
5 changes: 5 additions & 0 deletions Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,11 @@ struct Player {
{
return plrIsOnSetLevel && IsArenaLevel(static_cast<_setlevels>(plrlevel));
}
/** @brief Checks if the player is the local client player. */
bool isMyPlayer() const
{
return this == MyPlayer;
}
void setLevel(uint8_t level)
{
this->plrlevel = level;
Expand Down

0 comments on commit 7353b4e

Please sign in to comment.