mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[12056] Fix a bug of [11825] that causes wrong offhand attack times for players.
Thx to fr1nge for reporting the bug. Problem spotting and patch by vovk Additional cleanup by fr1nge Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
1c7e46a4a8
commit
4e117d1ee8
2 changed files with 41 additions and 48 deletions
|
|
@ -1160,16 +1160,16 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId)
|
||||||
SendMessageToSet(&data, true);
|
SendMessageToSet(&data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Update( uint32 update_diff, uint32 p_time )
|
void Player::Update(uint32 update_diff, uint32 p_time)
|
||||||
{
|
{
|
||||||
if(!IsInWorld())
|
if (!IsInWorld())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// remove failed timed Achievements
|
// Remove failed timed Achievements
|
||||||
GetAchievementMgr().DoFailedTimedAchievementCriterias();
|
GetAchievementMgr().DoFailedTimedAchievementCriterias();
|
||||||
|
|
||||||
// undelivered mail
|
// Undelivered mail
|
||||||
if(m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL))
|
if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL))
|
||||||
{
|
{
|
||||||
SendNewMail();
|
SendNewMail();
|
||||||
++unReadMails;
|
++unReadMails;
|
||||||
|
|
@ -1178,23 +1178,16 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
m_nextMailDelivereTime = 0;
|
m_nextMailDelivereTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//used to implement delayed far teleports
|
// Used to implement delayed far teleports
|
||||||
SetCanDelayTeleport(true);
|
SetCanDelayTeleport(true);
|
||||||
Unit::Update( update_diff, p_time );
|
Unit::Update(update_diff, p_time);
|
||||||
SetCanDelayTeleport(false);
|
SetCanDelayTeleport(false);
|
||||||
|
|
||||||
// update player only attacks
|
// Update player only attacks
|
||||||
if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
|
if (uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
|
||||||
{
|
setAttackTimer(RANGED_ATTACK, (update_diff >= ranged_att ? 0 : ranged_att - update_diff));
|
||||||
setAttackTimer(RANGED_ATTACK, (update_diff >= ranged_att ? 0 : ranged_att - update_diff) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if(uint32 off_att = getAttackTimer(OFF_ATTACK))
|
time_t now = time(NULL);
|
||||||
{
|
|
||||||
setAttackTimer(OFF_ATTACK, (update_diff >= off_att ? 0 : off_att - update_diff) );
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t now = time (NULL);
|
|
||||||
|
|
||||||
UpdatePvPFlag(now);
|
UpdatePvPFlag(now);
|
||||||
|
|
||||||
|
|
@ -1207,8 +1200,8 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
UpdateAfkReport(now);
|
UpdateAfkReport(now);
|
||||||
|
|
||||||
// Update items that have just a limited lifetime
|
// Update items that have just a limited lifetime
|
||||||
if (now>m_Last_tick)
|
if (now > m_Last_tick)
|
||||||
UpdateItemDuration(uint32(now- m_Last_tick));
|
UpdateItemDuration(uint32(now - m_Last_tick));
|
||||||
|
|
||||||
if (!m_timedquests.empty())
|
if (!m_timedquests.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -1216,10 +1209,10 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
while (iter != m_timedquests.end())
|
while (iter != m_timedquests.end())
|
||||||
{
|
{
|
||||||
QuestStatusData& q_status = mQuestStatus[*iter];
|
QuestStatusData& q_status = mQuestStatus[*iter];
|
||||||
if( q_status.m_timer <= update_diff )
|
if (q_status.m_timer <= update_diff)
|
||||||
{
|
{
|
||||||
uint32 quest_id = *iter;
|
uint32 quest_id = *iter;
|
||||||
++iter; // current iter will be removed in FailQuest
|
++iter; // Current iter will be removed in FailQuest
|
||||||
FailQuest(quest_id);
|
FailQuest(quest_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1235,10 +1228,10 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
{
|
{
|
||||||
UpdateMeleeAttackingState();
|
UpdateMeleeAttackingState();
|
||||||
|
|
||||||
Unit *pVictim = getVictim();
|
Unit* pVictim = getVictim();
|
||||||
if (pVictim && !IsNonMeleeSpellCasted(false))
|
if (pVictim && !IsNonMeleeSpellCasted(false))
|
||||||
{
|
{
|
||||||
Player *vOwner = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself();
|
Player* vOwner = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||||
if (vOwner && vOwner->IsPvP() && !IsInDuelWith(vOwner))
|
if (vOwner && vOwner->IsPvP() && !IsInDuelWith(vOwner))
|
||||||
{
|
{
|
||||||
UpdatePvP(true);
|
UpdatePvP(true);
|
||||||
|
|
@ -1249,14 +1242,14 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
|
|
||||||
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING))
|
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING))
|
||||||
{
|
{
|
||||||
if (roll_chance_i(3) && GetTimeInnEnter() > 0) //freeze update
|
if (roll_chance_i(3) && GetTimeInnEnter() > 0) // Freeze update
|
||||||
{
|
{
|
||||||
time_t time_inn = time(NULL)-GetTimeInnEnter();
|
time_t time_inn = time(NULL) - GetTimeInnEnter();
|
||||||
if (time_inn >= 10) //freeze update
|
if (time_inn >= 10) // Freeze update
|
||||||
{
|
{
|
||||||
float bubble = 0.125f*sWorld.getConfig(CONFIG_FLOAT_RATE_REST_INGAME);
|
float bubble = 0.125f * sWorld.getConfig(CONFIG_FLOAT_RATE_REST_INGAME);
|
||||||
//speed collect rest bonus (section/in hour)
|
// Speed collect rest bonus (section/in hour)
|
||||||
SetRestBonus( float(GetRestBonus()+ time_inn*(GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble ));
|
SetRestBonus(float(GetRestBonus() + time_inn * (GetUInt32Value(PLAYER_NEXT_LEVEL_XP) / 72000) * bubble));
|
||||||
UpdateInnerTime(time(NULL));
|
UpdateInnerTime(time(NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1264,7 +1257,7 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
|
|
||||||
if (m_regenTimer)
|
if (m_regenTimer)
|
||||||
{
|
{
|
||||||
if(update_diff >= m_regenTimer)
|
if (update_diff >= m_regenTimer)
|
||||||
m_regenTimer = 0;
|
m_regenTimer = 0;
|
||||||
else
|
else
|
||||||
m_regenTimer -= update_diff;
|
m_regenTimer -= update_diff;
|
||||||
|
|
@ -1280,18 +1273,18 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
|
|
||||||
if (m_zoneUpdateTimer > 0)
|
if (m_zoneUpdateTimer > 0)
|
||||||
{
|
{
|
||||||
if(update_diff >= m_zoneUpdateTimer)
|
if (update_diff >= m_zoneUpdateTimer)
|
||||||
{
|
{
|
||||||
uint32 newzone, newarea;
|
uint32 newzone, newarea;
|
||||||
GetZoneAndAreaId(newzone,newarea);
|
GetZoneAndAreaId(newzone, newarea);
|
||||||
|
|
||||||
if( m_zoneUpdateId != newzone )
|
if (m_zoneUpdateId != newzone)
|
||||||
UpdateZone(newzone,newarea); // also update area
|
UpdateZone(newzone, newarea); // Also update area
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// use area updates as well
|
// Use area updates as well
|
||||||
// needed for free far all arenas for example
|
// Needed for free for all arenas for example
|
||||||
if( m_areaUpdateId != newarea )
|
if (m_areaUpdateId != newarea)
|
||||||
UpdateArea(newarea);
|
UpdateArea(newarea);
|
||||||
|
|
||||||
m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL;
|
m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL;
|
||||||
|
|
@ -1303,7 +1296,7 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
|
|
||||||
if (m_timeSyncTimer > 0)
|
if (m_timeSyncTimer > 0)
|
||||||
{
|
{
|
||||||
if(update_diff >= m_timeSyncTimer)
|
if (update_diff >= m_timeSyncTimer)
|
||||||
SendTimeSync();
|
SendTimeSync();
|
||||||
else
|
else
|
||||||
m_timeSyncTimer -= update_diff;
|
m_timeSyncTimer -= update_diff;
|
||||||
|
|
@ -1322,9 +1315,9 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
if (m_deathState == JUST_DIED)
|
if (m_deathState == JUST_DIED)
|
||||||
KillPlayer();
|
KillPlayer();
|
||||||
|
|
||||||
if(m_nextSave > 0)
|
if (m_nextSave > 0)
|
||||||
{
|
{
|
||||||
if(update_diff >= m_nextSave)
|
if (update_diff >= m_nextSave)
|
||||||
{
|
{
|
||||||
// m_nextSave reseted in SaveToDB call
|
// m_nextSave reseted in SaveToDB call
|
||||||
SaveToDB();
|
SaveToDB();
|
||||||
|
|
@ -1334,10 +1327,10 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
m_nextSave -= update_diff;
|
m_nextSave -= update_diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle Water/drowning
|
// Handle Water/drowning
|
||||||
HandleDrowning(update_diff);
|
HandleDrowning(update_diff);
|
||||||
|
|
||||||
//Handle detect stealth players
|
// Handle detect stealth players
|
||||||
if (m_DetectInvTimer > 0)
|
if (m_DetectInvTimer > 0)
|
||||||
{
|
{
|
||||||
if (update_diff >= m_DetectInvTimer)
|
if (update_diff >= m_DetectInvTimer)
|
||||||
|
|
@ -1366,10 +1359,10 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
HandleSobering();
|
HandleSobering();
|
||||||
}
|
}
|
||||||
|
|
||||||
// not auto-free ghost from body in instances
|
// Not auto-free ghost from body in instances
|
||||||
if(m_deathTimer > 0 && !GetMap()->Instanceable())
|
if (m_deathTimer > 0 && !GetMap()->Instanceable())
|
||||||
{
|
{
|
||||||
if(p_time >= m_deathTimer)
|
if (p_time >= m_deathTimer)
|
||||||
{
|
{
|
||||||
m_deathTimer = 0;
|
m_deathTimer = 0;
|
||||||
BuildPlayerRepop();
|
BuildPlayerRepop();
|
||||||
|
|
@ -1382,7 +1375,7 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
UpdateEnchantTime(update_diff);
|
UpdateEnchantTime(update_diff);
|
||||||
UpdateHomebindTime(update_diff);
|
UpdateHomebindTime(update_diff);
|
||||||
|
|
||||||
// group update
|
// Group update
|
||||||
SendUpdateToOutOfRangeGroupMembers();
|
SendUpdateToOutOfRangeGroupMembers();
|
||||||
|
|
||||||
Pet* pet = GetPet();
|
Pet* pet = GetPet();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "12055"
|
#define REVISION_NR "12056"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue