Skip to content

Commit

Permalink
[12372] Use recently introduced performance timer for additional stat…
Browse files Browse the repository at this point in the history
…e updates

This should give a slight performance improvement without visibly disadvantage for players.
Maybe someone is willing to test 200 as default check intervall, how this scales
[ci skip] (mostly rename :P )
  • Loading branch information
Schmoozerd committed Feb 22, 2013
1 parent 3e92774 commit 232f3fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
23 changes: 11 additions & 12 deletions src/game/Player.cpp
Expand Up @@ -414,7 +414,7 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_

m_zoneUpdateId = 0;
m_zoneUpdateTimer = 0;
m_liquidUpdateTimer = 0;
m_positionStatusUpdateTimer = 0;

m_areaUpdateId = 0;

Expand Down Expand Up @@ -1273,12 +1273,12 @@ void Player::Update(uint32 update_diff, uint32 p_time)
m_regenTimer -= update_diff;
}

if (m_liquidUpdateTimer)
if (m_positionStatusUpdateTimer)
{
if (update_diff >= m_liquidUpdateTimer)
m_liquidUpdateTimer = 0;
if (update_diff >= m_positionStatusUpdateTimer)
m_positionStatusUpdateTimer = 0;
else
m_liquidUpdateTimer -= update_diff;
m_positionStatusUpdateTimer -= update_diff;
}

if (m_weaponChangeTimer > 0)
Expand Down Expand Up @@ -6050,9 +6050,14 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele
GetSession()->SendCancelTrade(); // will close both side trade windows
}

if (m_positionStatusUpdateTimer) // Update position's state only on interval
return true;
m_positionStatusUpdateTimer = 100;

// code block for underwater state update
UpdateUnderwaterState(m, x, y, z);

// code block for outdoor state and area-explore check
CheckAreaExploreAndOutdoor();

return true;
Expand Down Expand Up @@ -21532,12 +21537,6 @@ void Player::SetOriginalGroup(Group* group, int8 subgroup)

void Player::UpdateUnderwaterState(Map* m, float x, float y, float z)
{
// Update only on interval
if (m_liquidUpdateTimer)
return;
else
m_liquidUpdateTimer = 100;

GridMapLiquidData liquid_status;
GridMapLiquidStatus res = m->GetTerrain()->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &liquid_status);
if (!res)
Expand Down Expand Up @@ -21577,7 +21576,7 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z)
{
SummonCreature(21508, 0, 0, 0, 0, TEMPSUMMON_TIMED_OOC_DESPAWN, 2000);
// Special update timer for the SSC water
m_liquidUpdateTimer = 2000;
m_positionStatusUpdateTimer = 2000;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/Player.h
Expand Up @@ -1898,7 +1898,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetSemaphoreTeleportFar(bool semphsetting) { mSemaphoreTeleport_Far = semphsetting; }
void ProcessDelayedOperations();

void CheckAreaExploreAndOutdoor(void);
void CheckAreaExploreAndOutdoor();

static Team TeamForRace(uint8 race);
Team GetTeam() const { return m_team; }
Expand Down Expand Up @@ -2502,7 +2502,7 @@ class MANGOS_DLL_SPEC Player : public Unit
uint32 m_zoneUpdateId;
uint32 m_zoneUpdateTimer;
uint32 m_areaUpdateId;
uint32 m_liquidUpdateTimer;
uint32 m_positionStatusUpdateTimer;

uint32 m_deathTimer;
time_t m_deathExpireTime;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12371"
#define REVISION_NR "12372"
#endif // __REVISION_NR_H__

0 comments on commit 232f3fa

Please sign in to comment.