diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 35f4e83c9..436db01f3 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -406,7 +406,7 @@ uint32 Creature::ChooseDisplayId(const CreatureInfo *cinfo, const CreatureData * return display_id; } -void Creature::Update(uint32 update_diff, uint32 tick_diff) +void Creature::Update(uint32 diff) { if (m_needNotify) { @@ -467,7 +467,7 @@ void Creature::Update(uint32 update_diff, uint32 tick_diff) if (m_isDeadByDefault) break; - if (m_corpseDecayTimer <= update_diff) + if (m_corpseDecayTimer <= diff) { // since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool(GetDBTableGUIDLow()) : 0; @@ -482,11 +482,11 @@ void Creature::Update(uint32 update_diff, uint32 tick_diff) } else { - m_corpseDecayTimer -= update_diff; + m_corpseDecayTimer -= diff; if (m_groupLootId) { - if(update_diff < m_groupLootTimer) - m_groupLootTimer -= update_diff; + if(diff < m_groupLootTimer) + m_groupLootTimer -= diff; else StopGroupLoot(); } @@ -498,7 +498,7 @@ void Creature::Update(uint32 update_diff, uint32 tick_diff) { if (m_isDeadByDefault) { - if (m_corpseDecayTimer <= update_diff) + if (m_corpseDecayTimer <= diff) { // since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool(GetDBTableGUIDLow()) : 0; @@ -516,11 +516,11 @@ void Creature::Update(uint32 update_diff, uint32 tick_diff) } else { - m_corpseDecayTimer -= update_diff; + m_corpseDecayTimer -= diff; } } - Unit::Update(update_diff, tick_diff); + Unit::Update( diff ); // creature can be dead after Unit::Update call // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly) @@ -531,7 +531,7 @@ void Creature::Update(uint32 update_diff, uint32 tick_diff) { // do not allow the AI to be changed during update m_AI_locked = true; - i_AI->UpdateAI(tick_diff); // AI not react good at real update delays (while freeze in non-active part of map) + i_AI->UpdateAI(diff); m_AI_locked = false; } @@ -541,10 +541,10 @@ void Creature::Update(uint32 update_diff, uint32 tick_diff) break; if(m_regenTimer > 0) { - if(update_diff >= m_regenTimer) + if(diff >= m_regenTimer) m_regenTimer = 0; else - m_regenTimer -= update_diff; + m_regenTimer -= diff; } if (m_regenTimer != 0) break; diff --git a/src/game/Creature.h b/src/game/Creature.h index b818ec5a1..e1d2fc438 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -402,6 +402,7 @@ class MANGOS_DLL_SPEC Creature : public Unit uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } char const* GetSubName() const { return GetCreatureInfo()->SubName; } + void Update(uint32 time); // overwrite Unit::Update void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; uint32 GetEquipmentId() const { return m_equipmentId; } @@ -638,7 +639,6 @@ class MANGOS_DLL_SPEC Creature : public Unit void SendAreaSpiritHealerQueryOpcode(Player *pl); protected: - void Update(uint32 update_diff, uint32 tick_diff); // overwrite Unit::Update bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL); bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL); void RelocationNotify(); diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index 0dd3a5ae4..b2d88f95e 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -106,7 +106,7 @@ Unit* DynamicObject::GetCaster() const return ObjectAccessor::GetUnit(*this, GetCasterGUID()); } -void DynamicObject::Update(uint32 update_diff, uint32 /*tick_diff*/) +void DynamicObject::Update(uint32 p_time) { // caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor Unit* caster = GetCaster(); @@ -118,8 +118,8 @@ void DynamicObject::Update(uint32 update_diff, uint32 /*tick_diff*/) bool deleteThis = false; - if(m_aliveDuration > int32(update_diff)) - m_aliveDuration -= update_diff; + if(m_aliveDuration > int32(p_time)) + m_aliveDuration -= p_time; else deleteThis = true; diff --git a/src/game/DynamicObject.h b/src/game/DynamicObject.h index 01dae278e..09076649b 100644 --- a/src/game/DynamicObject.h +++ b/src/game/DynamicObject.h @@ -35,6 +35,7 @@ class DynamicObject : public WorldObject void RemoveFromWorld(); bool Create(uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius); + void Update(uint32 p_time); void Delete(); uint32 GetSpellId() const { return m_spellId; } SpellEffectIndex GetEffIndex() const { return m_effIndex; } @@ -66,8 +67,6 @@ class DynamicObject : public WorldObject GridReference &GetGridRef() { return m_gridRef; } protected: - void Update(uint32 update_diff, uint32 tick_diff); // overwrite WorldObject::Update - uint32 m_spellId; SpellEffectIndex m_effIndex; int32 m_aliveDuration; diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index d42a18c26..32bedb366 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -159,7 +159,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa return true; } -void GameObject::Update(uint32 /*update_diff*/, uint32 /*tick_diff*/) +void GameObject::Update(uint32 /*p_time*/) { if (GetObjectGuid().IsMOTransport()) { diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 6b310f9d7..f09e74958 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -588,6 +588,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject void RemoveFromWorld(); bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint8 animprogress, GOState go_state); + void Update(uint32 p_time); GameObjectInfo const* GetGOInfo() const; bool IsTransport() const; @@ -710,8 +711,6 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject uint64 GetRotation() const { return m_rotation; } protected: - void Update(uint32 update_diff, uint32 tick_diff); // overwrite WorldObject::Update - uint32 m_spellId; time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()), uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index 3e9406426..ba2eb06db 100644 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -187,7 +187,9 @@ template void ObjectUpdater::Visit(GridRefManager &m) { for(typename GridRefManager::iterator iter = m.begin(); iter != m.end(); ++iter) - iter->getSource()->UpdateCall(i_time, i_diff); + { + iter->getSource()->Update(i_timeDiff); + } } bool CannibalizeObjectCheck::operator()(Corpse* u) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index acde37ebb..e7ce0813b 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -61,14 +61,13 @@ namespace MaNGOS struct MANGOS_DLL_DECL GridUpdater { GridType &i_grid; - uint32 i_time; uint32 i_timeDiff; - GridUpdater(GridType &grid, uint32 time_, uint32 diff) : i_grid(grid), i_time(time_), i_timeDiff(diff) {} + GridUpdater(GridType &grid, uint32 diff) : i_grid(grid), i_timeDiff(diff) {} template void updateObjects(GridRefManager &m) { for(typename GridRefManager::iterator iter = m.begin(); iter != m.end(); ++iter) - iter->getSource()->UpdateCall(i_time, i_timeDiff); + iter->getSource()->Update(i_timeDiff); } void Visit(PlayerMapType &m) { updateObjects(m); } @@ -137,9 +136,8 @@ namespace MaNGOS struct MANGOS_DLL_DECL ObjectUpdater { - uint32 i_time; // current tick time in msecs - uint32 i_diff; // current tick time diff in msecs - explicit ObjectUpdater(uint32 time_, uint32 diff) : i_time(time_), i_diff(diff) {} + uint32 i_timeDiff; + explicit ObjectUpdater(const uint32 &diff) : i_timeDiff(diff) {} template void Visit(GridRefManager &m); void Visit(PlayerMapType &) {} void Visit(CorpseMapType &) {} diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 798ae3384..48e119b01 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -41,7 +41,7 @@ inline void MaNGOS::VisibleNotifier::Visit(GridRefManager &m) inline void MaNGOS::ObjectUpdater::Visit(CreatureMapType &m) { for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) - iter->getSource()->UpdateCall(i_time, i_diff); + iter->getSource()->Update(i_timeDiff); } inline void PlayerCreatureRelocationWorker(Player* pl, WorldObject const* viewPoint, Creature* c) diff --git a/src/game/Map.cpp b/src/game/Map.cpp index fb2192365..e6e0d339c 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -510,18 +510,20 @@ bool Map::loaded(const GridPair &p) const return ( getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord) ); } -void Map::Update(uint32 time_, uint32 diff) +void Map::Update(const uint32 &t_diff) { /// update players at tick for(m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) - if (Player* plr = m_mapRefIter->getSource()) - if (plr->IsInWorld()) - plr->UpdateCall(time_, diff); + { + Player* plr = m_mapRefIter->getSource(); + if(plr && plr->IsInWorld()) + plr->Update(t_diff); + } /// update active cells around players and active objects resetMarkedCells(); - MaNGOS::ObjectUpdater updater(time_, diff); + MaNGOS::ObjectUpdater updater(t_diff); // for creature TypeContainerVisitor grid_object_update(updater); // for pets @@ -630,7 +632,7 @@ void Map::Update(uint32 time_, uint32 diff) GridInfo *info = i->getSource()->getGridInfoRef(); ++i; // The update might delete the map and we need the next map before the iterator gets invalid MANGOS_ASSERT(grid->GetGridState() >= 0 && grid->GetGridState() < MAX_GRID_STATE); - sMapMgr.UpdateGridState(grid->GetGridState(), *this, *grid, *info, grid->getX(), grid->getY(), diff); + sMapMgr.UpdateGridState(grid->GetGridState(), *this, *grid, *info, grid->getX(), grid->getY(), t_diff); } } @@ -1838,17 +1840,17 @@ bool InstanceMap::Add(Player *player) return true; } -void InstanceMap::Update(uint32 time_, uint32 diff) +void InstanceMap::Update(const uint32& t_diff) { - Map::Update(time_, diff); + Map::Update(t_diff); if(i_data) - i_data->Update(diff); + i_data->Update(t_diff); } -void BattleGroundMap::Update(uint32 time_, uint32 diff) +void BattleGroundMap::Update(const uint32& diff) { - Map::Update(time_, diff); + Map::Update(diff); GetBG()->Update(diff); } diff --git a/src/game/Map.h b/src/game/Map.h index d0142e85e..661ff1487 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -108,7 +108,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj template void Add(T *); template void Remove(T *, bool); - virtual void Update(uint32 time_, uint32 diff); + virtual void Update(const uint32&); void MessageBroadcast(Player *, WorldPacket *, bool to_self); void MessageBroadcast(WorldObject *, WorldPacket *); @@ -382,7 +382,7 @@ class MANGOS_DLL_SPEC InstanceMap : public Map ~InstanceMap(); bool Add(Player *); void Remove(Player *, bool); - void Update(uint32 time_, uint32 diff); + void Update(const uint32&); void CreateInstanceData(bool load); bool Reset(uint8 method); uint32 GetScriptId() { return i_script_id; } @@ -407,7 +407,7 @@ class MANGOS_DLL_SPEC BattleGroundMap : public Map BattleGroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode); ~BattleGroundMap(); - void Update(uint32 time_, uint32 diff); + void Update(const uint32&); bool Add(Player *); void Remove(Player *, bool); bool CanEnter(Player* player); diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index bf0966e1e..9780d8ede 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -43,24 +43,24 @@ void MapInstanced::InitVisibilityDistance() } } -void MapInstanced::Update(uint32 time_, uint32 diff) +void MapInstanced::Update(const uint32& t) { // take care of loaded GridMaps (when unused, unload it!) - Map::Update(time_, diff); + Map::Update(t); // update the instanced maps InstancedMaps::iterator i = m_InstancedMaps.begin(); while (i != m_InstancedMaps.end()) { - if(i->second->CanUnload(diff)) + if(i->second->CanUnload(t)) { DestroyInstance(i); // iterator incremented } else { // update only here, because it may schedule some bad things before delete - i->second->Update(time_, diff); + i->second->Update(t); ++i; } } diff --git a/src/game/MapInstanced.h b/src/game/MapInstanced.h index 784bae0fc..1a3884b2c 100644 --- a/src/game/MapInstanced.h +++ b/src/game/MapInstanced.h @@ -34,7 +34,7 @@ class MANGOS_DLL_DECL MapInstanced : public Map ~MapInstanced() {} // functions overwrite Map versions - void Update(uint32 time_, uint32 diff); + void Update(const uint32&); void RemoveAllObjectsInRemoveList(); void UnloadAll(bool pForce); diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index aec88a179..9b12a063a 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -239,17 +239,17 @@ void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId) } void -MapManager::Update(const uint32 time_, const uint32 diff) +MapManager::Update(uint32 diff) { i_timer.Update(diff); if( !i_timer.Passed() ) return; for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) - iter->second->Update(time_, (uint32)i_timer.GetCurrent()); + iter->second->Update((uint32)i_timer.GetCurrent()); for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter) - (*iter)->UpdateCall(time_, (uint32)i_timer.GetCurrent()); + (*iter)->Update((uint32)i_timer.GetCurrent()); i_timer.SetCurrent(0); } diff --git a/src/game/MapManager.h b/src/game/MapManager.h index b5fe14b0c..a578c2f4b 100644 --- a/src/game/MapManager.h +++ b/src/game/MapManager.h @@ -67,7 +67,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton 0) { - if (m_duration > (int32)update_diff) - m_duration -= (int32)update_diff; + if(m_duration > (int32)diff) + m_duration -= (int32)diff; else { Remove(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED:PET_SAVE_NOT_IN_SLOT); @@ -530,7 +530,7 @@ void Pet::Update(uint32 update_diff, uint32 tick_diff) } //regenerate focus for hunter pets or energy for deathknight's ghoul - if (m_regenTimer <= update_diff) + if(m_regenTimer <= diff) { switch (getPowerType()) { @@ -544,25 +544,25 @@ void Pet::Update(uint32 update_diff, uint32 tick_diff) m_regenTimer = 4000; } else - m_regenTimer -= update_diff; + m_regenTimer -= diff; - if (getPetType() != HUNTER_PET) + if(getPetType() != HUNTER_PET) break; - if (m_happinessTimer <= update_diff) + if(m_happinessTimer <= diff) { LooseHappiness(); m_happinessTimer = 7500; } else - m_happinessTimer -= update_diff; + m_happinessTimer -= diff; break; } default: break; } - Creature::Update(update_diff, tick_diff); + Creature::Update(diff); } void Pet::Regenerate(Powers power) diff --git a/src/game/Pet.h b/src/game/Pet.h index 1a5d473d9..15d3a6e8d 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -157,6 +157,7 @@ class Pet : public Creature static void DeleteFromDB(uint32 guidlow); void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState + void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update uint8 GetPetAutoSpellSize() const { return m_autospells.size(); } uint32 GetPetAutoSpellOnPos(uint8 pos) const @@ -247,8 +248,6 @@ class Pet : public Creature bool m_removed; // prevent overwrite pet state in DB at next Pet::Update if pet already removed(saved) protected: - void Update(uint32 update_diff, uint32 tick_diff); // overwrite virtual Creature::Update and Unit::Update - uint32 m_happinessTimer; PetType m_petType; int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 56a7ae4ba..93f896f7b 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1175,7 +1175,7 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId) SendMessageToSet(&data, true); } -void Player::Update(uint32 update_diff, uint32 tick_diff) +void Player::Update( uint32 p_time ) { if(!IsInWorld()) return; @@ -1195,21 +1195,25 @@ void Player::Update(uint32 update_diff, uint32 tick_diff) //used to implement delayed far teleports SetCanDelayTeleport(true); - Unit::Update(update_diff, tick_diff); + Unit::Update( p_time ); SetCanDelayTeleport(false); // update player only attacks - if (uint32 ranged_att = getAttackTimer(RANGED_ATTACK)) - setAttackTimer(RANGED_ATTACK, (update_diff >= ranged_att ? 0 : ranged_att - update_diff) ); + if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK)) + { + setAttackTimer(RANGED_ATTACK, (p_time >= ranged_att ? 0 : ranged_att - p_time) ); + } - if (uint32 off_att = getAttackTimer(OFF_ATTACK)) - setAttackTimer(OFF_ATTACK, (update_diff >= off_att ? 0 : off_att - update_diff) ); + if(uint32 off_att = getAttackTimer(OFF_ATTACK)) + { + setAttackTimer(OFF_ATTACK, (p_time >= off_att ? 0 : off_att - p_time) ); + } time_t now = time (NULL); UpdatePvPFlag(now); - UpdateContestedPvP(update_diff); + UpdateContestedPvP(p_time); UpdateDuelFlag(now); @@ -1227,7 +1231,7 @@ void Player::Update(uint32 update_diff, uint32 tick_diff) while (iter != m_timedquests.end()) { QuestStatusData& q_status = mQuestStatus[*iter]; - if (q_status.m_timer <= update_diff) + if( q_status.m_timer <= p_time ) { uint32 quest_id = *iter; ++iter; // current iter will be removed in FailQuest @@ -1235,7 +1239,7 @@ void Player::Update(uint32 update_diff, uint32 tick_diff) } else { - q_status.m_timer -= update_diff; + q_status.m_timer -= p_time; if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; ++iter; } @@ -1338,49 +1342,49 @@ void Player::Update(uint32 update_diff, uint32 tick_diff) if (m_regenTimer) { - if (update_diff >= m_regenTimer) + if(p_time >= m_regenTimer) m_regenTimer = 0; else - m_regenTimer -= update_diff; + m_regenTimer -= p_time; } if (m_weaponChangeTimer > 0) { - if (update_diff >= m_weaponChangeTimer) + if(p_time >= m_weaponChangeTimer) m_weaponChangeTimer = 0; else - m_weaponChangeTimer -= update_diff; + m_weaponChangeTimer -= p_time; } if (m_zoneUpdateTimer > 0) { - if (update_diff >= m_zoneUpdateTimer) + if(p_time >= m_zoneUpdateTimer) { uint32 newzone, newarea; GetZoneAndAreaId(newzone,newarea); - if (m_zoneUpdateId != newzone) + if( m_zoneUpdateId != newzone ) UpdateZone(newzone,newarea); // also update area else { // use area updates as well // needed for free far all arenas for example - if (m_areaUpdateId != newarea) + if( m_areaUpdateId != newarea ) UpdateArea(newarea); m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL; } } else - m_zoneUpdateTimer -= update_diff; + m_zoneUpdateTimer -= p_time; } if (m_timeSyncTimer > 0) { - if (update_diff >= m_timeSyncTimer) + if(p_time >= m_timeSyncTimer) SendTimeSync(); else - m_timeSyncTimer -= update_diff; + m_timeSyncTimer -= p_time; } if (isAlive()) @@ -1396,31 +1400,31 @@ void Player::Update(uint32 update_diff, uint32 tick_diff) if (m_deathState == JUST_DIED) KillPlayer(); - if (m_nextSave > 0) + if(m_nextSave > 0) { - if (update_diff >= m_nextSave) + if(p_time >= m_nextSave) { // m_nextSave reseted in SaveToDB call SaveToDB(); DETAIL_LOG("Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow()); } else - m_nextSave -= update_diff; + m_nextSave -= p_time; } //Handle Water/drowning - HandleDrowning(update_diff); + HandleDrowning(p_time); //Handle detect stealth players if (m_DetectInvTimer > 0) { - if (update_diff >= m_DetectInvTimer) + if (p_time >= m_DetectInvTimer) { HandleStealthedUnitsDetection(); m_DetectInvTimer = 3000; } else - m_DetectInvTimer -= update_diff; + m_DetectInvTimer -= p_time; } // Played time @@ -1434,27 +1438,27 @@ void Player::Update(uint32 update_diff, uint32 tick_diff) if (m_drunk) { - m_drunkTimer += update_diff; + m_drunkTimer += p_time; if (m_drunkTimer > 10*IN_MILLISECONDS) HandleSobering(); } // not auto-free ghost from body in instances - if (m_deathTimer > 0 && !GetBaseMap()->Instanceable()) + if(m_deathTimer > 0 && !GetBaseMap()->Instanceable()) { - if(update_diff >= m_deathTimer) + if(p_time >= m_deathTimer) { m_deathTimer = 0; BuildPlayerRepop(); RepopAtGraveyard(); } else - m_deathTimer -= update_diff; + m_deathTimer -= p_time; } - UpdateEnchantTime(update_diff); - UpdateHomebindTime(update_diff); + UpdateEnchantTime(p_time); + UpdateHomebindTime(p_time); // group update SendUpdateToOutOfRangeGroupMembers(); diff --git a/src/game/Player.h b/src/game/Player.h index 3257ba5f4..eb2a194ba 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1123,6 +1123,8 @@ class MANGOS_DLL_SPEC Player : public Unit bool Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ); + void Update( uint32 time ); + static bool BuildEnumData( QueryResult * result, WorldPacket * p_data ); void SetInWater(bool apply); @@ -2401,7 +2403,6 @@ class MANGOS_DLL_SPEC Player : public Unit bool canSeeSpellClickOn(Creature const* creature) const; protected: - void Update(uint32 update_diff, uint32 tick_diff); // overwrite Unit::Update uint32 m_contestedPvPTimer; diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index c93656d30..f1fdd64db 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -26,7 +26,7 @@ Creature(CREATURE_SUBTYPE_TEMPORARY_SUMMON), m_type(TEMPSUMMON_TIMED_OR_CORPSE_D { } -void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) +void TemporarySummon::Update( uint32 diff ) { switch(m_type) { @@ -34,26 +34,26 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) break; case TEMPSUMMON_TIMED_DESPAWN: { - if (m_timer <= update_diff) + if (m_timer <= diff) { UnSummon(); return; } - m_timer -= update_diff; + m_timer -= diff; break; } case TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT: { if (!isInCombat()) { - if (m_timer <= update_diff) + if (m_timer <= diff) { UnSummon(); return; } - m_timer -= update_diff; + m_timer -= diff; } else if (m_timer != m_lifetime) m_timer = m_lifetime; @@ -63,22 +63,22 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) case TEMPSUMMON_CORPSE_TIMED_DESPAWN: { - if (m_deathState == CORPSE) + if ( m_deathState == CORPSE) { - if (m_timer <= update_diff) + if (m_timer <= diff) { UnSummon(); return; } - m_timer -= update_diff; + m_timer -= diff; } break; } case TEMPSUMMON_CORPSE_DESPAWN: { // if m_deathState is DEAD, CORPSE was skipped - if (m_deathState == CORPSE || m_deathState == DEAD) + if ( m_deathState == CORPSE || m_deathState == DEAD) { UnSummon(); return; @@ -88,7 +88,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) } case TEMPSUMMON_DEAD_DESPAWN: { - if (m_deathState == DEAD) + if ( m_deathState == DEAD ) { UnSummon(); return; @@ -98,7 +98,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN: { // if m_deathState is DEAD, CORPSE was skipped - if (m_deathState == CORPSE || m_deathState == DEAD) + if ( m_deathState == CORPSE || m_deathState == DEAD) { UnSummon(); return; @@ -106,13 +106,13 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) if (!isInCombat()) { - if (m_timer <= update_diff) + if (m_timer <= diff) { UnSummon(); return; } else - m_timer -= update_diff; + m_timer -= diff; } else if (m_timer != m_lifetime) m_timer = m_lifetime; @@ -129,13 +129,13 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) if (!isInCombat() && isAlive() ) { - if (m_timer <= update_diff) + if (m_timer <= diff) { UnSummon(); return; } else - m_timer -= update_diff; + m_timer -= diff; } else if (m_timer != m_lifetime) m_timer = m_lifetime; @@ -147,7 +147,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) break; } - Creature::Update(update_diff, tick_diff); + Creature::Update( diff ); } void TemporarySummon::Summon(TempSummonType type, uint32 lifetime) diff --git a/src/game/TemporarySummon.h b/src/game/TemporarySummon.h index ecc85e8fa..24f8569a1 100644 --- a/src/game/TemporarySummon.h +++ b/src/game/TemporarySummon.h @@ -27,13 +27,12 @@ class TemporarySummon : public Creature public: explicit TemporarySummon(ObjectGuid summoner = ObjectGuid()); virtual ~TemporarySummon(){}; + void Update(uint32 time); void Summon(TempSummonType type, uint32 lifetime); void MANGOS_DLL_SPEC UnSummon(); void SaveToDB(); ObjectGuid const& GetSummonerGuid() const { return m_summoner ; } Unit* GetSummoner() const { return ObjectAccessor::GetUnit(*this, m_summoner); } - protected: - void Update(uint32 update_diff, uint32 tick_diff); // overwrite Creature::Update private: TempSummonType m_type; uint32 m_timer; diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp index 4169e8766..d3c6757cf 100644 --- a/src/game/Totem.cpp +++ b/src/game/Totem.cpp @@ -31,7 +31,7 @@ Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM) m_type = TOTEM_PASSIVE; } -void Totem::Update(uint32 update_diff, uint32 tick_diff) +void Totem::Update( uint32 time ) { Unit *owner = GetOwner(); if (!owner || !owner->isAlive() || !isAlive()) @@ -40,15 +40,15 @@ void Totem::Update(uint32 update_diff, uint32 tick_diff) return; } - if (m_duration <= update_diff) + if (m_duration <= time) { UnSummon(); // remove self return; } else - m_duration -= update_diff; + m_duration -= time; - Creature::Update(update_diff, tick_diff); + Creature::Update( time ); } void Totem::Summon(Unit* owner) diff --git a/src/game/Totem.h b/src/game/Totem.h index 8a4bc6c7f..57c1686c6 100644 --- a/src/game/Totem.h +++ b/src/game/Totem.h @@ -33,6 +33,7 @@ class Totem : public Creature public: explicit Totem(); virtual ~Totem(){}; + void Update( uint32 time ); void Summon(Unit* owner); void UnSummon(); uint32 GetSpell() const { return m_spells[0]; } @@ -55,8 +56,6 @@ class Totem : public Creature bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const; protected: - void Update(uint32 update_diff, uint32 tick_diff); // overwrite Creature::Update - TotemType m_type; uint32 m_duration; }; diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 179d75ecf..0c3431d07 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -487,7 +487,7 @@ bool Transport::RemovePassenger(Player* passenger) return true; } -void Transport::Update(uint32 /*update_diff*/, uint32 /*tick_diff*/) +void Transport::Update(uint32 /*p_time*/) { if (m_WayPoints.size() <= 1) return; diff --git a/src/game/Transports.h b/src/game/Transports.h index d0525c8ab..a7917d69d 100644 --- a/src/game/Transports.h +++ b/src/game/Transports.h @@ -32,15 +32,13 @@ class Transport : public GameObject bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicHighValue); bool GenerateWaypoints(uint32 pathid, std::set &mapids); + void Update(uint32 p_time); bool AddPassenger(Player* passenger); bool RemovePassenger(Player* passenger); typedef std::set PlayerSet; PlayerSet const& GetPassengers() const { return m_passengers; } - protected: - void Update(uint32 update_diff, uint32 tick_diff); - private: struct WayPoint { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index b89042e3d..da86ded52 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -291,7 +291,7 @@ Unit::~Unit() MANGOS_ASSERT(m_deletedHolders.size() == 0); } -void Unit::Update(uint32 update_diff, uint32 tick_diff) +void Unit::Update( uint32 p_time ) { if(!IsInWorld()) return; @@ -306,21 +306,21 @@ void Unit::Update(uint32 update_diff, uint32 tick_diff) // WARNING! Order of execution here is important, do not change. // Spells must be processed with event system BEFORE they go to _UpdateSpells. // Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad. - m_Events.Update(update_diff); - _UpdateSpells(update_diff); + m_Events.Update( p_time ); + _UpdateSpells( p_time ); CleanupDeletedAuras(); if (m_lastManaUseTimer) { - if (update_diff >= m_lastManaUseTimer) + if (p_time >= m_lastManaUseTimer) m_lastManaUseTimer = 0; else - m_lastManaUseTimer -= update_diff; + m_lastManaUseTimer -= p_time; } if (CanHaveThreatList()) - getThreatManager().UpdateForClient(update_diff); + getThreatManager().UpdateForClient(p_time); // update combat timer only for players and pets if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->IsPet() || ((Creature*)this)->isCharmed())) @@ -331,24 +331,26 @@ void Unit::Update(uint32 update_diff, uint32 tick_diff) if (m_HostileRefManager.isEmpty()) { // m_CombatTimer set at aura start and it will be freeze until aura removing - if (m_CombatTimer <= update_diff) + if (m_CombatTimer <= p_time) CombatStop(); else - m_CombatTimer -= update_diff; + m_CombatTimer -= p_time; } } if (uint32 base_att = getAttackTimer(BASE_ATTACK)) - setAttackTimer(BASE_ATTACK, (update_diff >= base_att ? 0 : base_att - update_diff) ); + { + setAttackTimer(BASE_ATTACK, (p_time >= base_att ? 0 : base_att - p_time) ); + } // update abilities available only for fraction of time - UpdateReactives(update_diff); + UpdateReactives( p_time ); ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth()*0.20f); ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth()*0.35f); ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, GetHealth() > GetMaxHealth()*0.75f); - i_motionMaster.UpdateMotion(tick_diff); // movegens expected non freeze time diff + i_motionMaster.UpdateMotion(p_time); } bool Unit::haveOffhandWeapon() const diff --git a/src/game/Unit.h b/src/game/Unit.h index c114cff62..3861caabd 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1168,6 +1168,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void ApplyDiminishingAura(DiminishingGroup group, bool apply); void ClearDiminishings() { m_Diminishing.clear(); } + virtual void Update( uint32 time ); + void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; } void resetAttackTimer(WeaponAttackType type = BASE_ATTACK); uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; } @@ -1927,7 +1929,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject protected: explicit Unit (); - void Update(uint32 update_diff, uint32 tick_diff); // overwrite WorldObject::Update void _UpdateSpells(uint32 time); void _UpdateAutoRepeatSpell(); diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index b12ae8276..21db9ab8b 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -56,9 +56,9 @@ void Vehicle::SetDeathState(DeathState s) // overwrite vir Creature::SetDeathState(s); } -void Vehicle::Update(uint32 update_diff, uint32 tick_diff) +void Vehicle::Update(uint32 diff) { - Creature::Update(update_diff, tick_diff); + Creature::Update(diff); } bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team) diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h index c9bb96bac..c191c094f 100644 --- a/src/game/Vehicle.h +++ b/src/game/Vehicle.h @@ -36,6 +36,7 @@ class Vehicle : public Creature bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team); void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState + void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update uint32 GetVehicleId() { return m_vehicleId; } void SetVehicleId(uint32 vehicleid) { m_vehicleId = vehicleid; } @@ -43,8 +44,6 @@ class Vehicle : public Creature void Dismiss(); protected: - void Update(uint32 update_diff, uint32 tick_diff); // overwrite virtual Creature::Update and Unit::Update - uint32 m_vehicleId; private: diff --git a/src/game/World.cpp b/src/game/World.cpp index 9d67dbc4d..289971995 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1380,7 +1380,7 @@ void World::DetectDBCLang() } /// Update the World ! -void World::Update(uint32 time_, uint32 diff) +void World::Update(uint32 diff) { ///- Update the different timers for(int i = 0; i < WUPDATE_COUNT; ++i) @@ -1467,7 +1467,7 @@ void World::Update(uint32 time_, uint32 diff) { m_timers[WUPDATE_OBJECTS].Reset(); ///- Update objects when the timer has passed (maps, transport, creatures,...) - sMapMgr.Update(time_, diff); // As interval = 0 + sMapMgr.Update(diff); // As interval = 0 sBattleGroundMgr.Update(diff); } diff --git a/src/game/World.h b/src/game/World.h index 213577f09..099ad5961 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -509,7 +509,7 @@ class World static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; } static bool IsStopped() { return m_stopEvent; } - void Update(uint32 time_, uint32 diff); + void Update(uint32 diff); void UpdateSessions( uint32 diff ); diff --git a/src/mangosd/WorldRunnable.cpp b/src/mangosd/WorldRunnable.cpp index 617096b8e..4575a6e31 100644 --- a/src/mangosd/WorldRunnable.cpp +++ b/src/mangosd/WorldRunnable.cpp @@ -57,7 +57,7 @@ void WorldRunnable::run() uint32 diff = getMSTimeDiff(realPrevTime,realCurrTime); - sWorld.Update(realCurrTime, diff); + sWorld.Update( diff ); realPrevTime = realCurrTime; // diff (D0) include time of previous sleep (d0) + tick time (t0) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d2c69d16d..e399704d0 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10682" + #define REVISION_NR "10683" #endif // __REVISION_NR_H__