Skip to content

Commit

Permalink
[10717] Revert "[10716][10688] New version of patch for send real dif…
Browse files Browse the repository at this point in the history
…f from last update."

This reverts commit 8398a55.
This reverts commit 06e2d68.
  • Loading branch information
VladimirMangos committed Nov 10, 2010
1 parent 8398a55 commit 925318e
Show file tree
Hide file tree
Showing 36 changed files with 145 additions and 180 deletions.
4 changes: 0 additions & 4 deletions src/framework/GameSystem/Grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,12 @@ class MANGOS_DLL_DECL Grid
return i_container.template remove<SPECIFIC_OBJECT>(obj);
}

uint32 GetLastUpdateTime() const { return m_LastUpdateTime; }
void SetLastUpdateTime(uint32 newtime) { m_LastUpdateTime = newtime; }

private:

TypeMapContainer<GRID_OBJECT_TYPES> i_container;
TypeMapContainer<WORLD_OBJECT_TYPES> i_objects;
typedef std::set<void*> ActiveGridObjects;
ActiveGridObjects m_activeGridObjects;
uint32 m_LastUpdateTime; // last time when Update call has been or current started, used and set Map::Update
};

#endif
22 changes: 11 additions & 11 deletions src/game/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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<Creature>(GetDBTableGUIDLow()) : 0;
Expand All @@ -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();
}
Expand All @@ -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<Creature>(GetDBTableGUIDLow()) : 0;
Expand All @@ -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)
Expand All @@ -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;
}

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/game/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +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 update_diff, uint32 tick_diff); // overwrite WorldObject::Update
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; }

Expand Down
6 changes: 3 additions & 3 deletions src/game/DynamicObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/game/DynamicObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +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 update_diff, uint32 tick_diff); // overwrite WorldObject::Update
void Update(uint32 p_time);
void Delete();
uint32 GetSpellId() const { return m_spellId; }
SpellEffectIndex GetEffIndex() const { return m_effIndex; }
Expand Down
2 changes: 1 addition & 1 deletion src/game/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +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 update_diff, uint32 tick_diff); // overwrite WorldObject::Update
void Update(uint32 p_time);
GameObjectInfo const* GetGOInfo() const;

bool IsTransport() const;
Expand Down
4 changes: 3 additions & 1 deletion src/game/GridNotifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ template<class T> void
ObjectUpdater::Visit(GridRefManager<T> &m)
{
for(typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
iter->getSource()->Update(i_realdiff, i_diff);
{
iter->getSource()->Update(i_timeDiff);
}
}

bool CannibalizeObjectCheck::operator()(Corpse* u)
Expand Down
5 changes: 2 additions & 3 deletions src/game/GridNotifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ namespace MaNGOS

struct MANGOS_DLL_DECL ObjectUpdater
{
uint32 i_realdiff; // time from last update in msecs
uint32 i_diff; // current tick time diff in msecs
explicit ObjectUpdater(uint32 realdiff, uint32 diff) : i_realdiff(realdiff), i_diff(diff) {}
uint32 i_timeDiff;
explicit ObjectUpdater(const uint32 &diff) : i_timeDiff(diff) {}
template<class T> void Visit(GridRefManager<T> &m);
void Visit(PlayerMapType &) {}
void Visit(CorpseMapType &) {}
Expand Down
2 changes: 1 addition & 1 deletion src/game/GridNotifiersImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ inline void MaNGOS::VisibleNotifier::Visit(GridRefManager<T> &m)
inline void MaNGOS::ObjectUpdater::Visit(CreatureMapType &m)
{
for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
iter->getSource()->Update(i_realdiff, i_diff);
iter->getSource()->Update(i_timeDiff);
}

inline void PlayerCreatureRelocationWorker(Player* pl, WorldObject const* viewPoint, Creature* c)
Expand Down
65 changes: 19 additions & 46 deletions src/game/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _par
i_id(id), i_InstanceId(InstanceId), m_unloadTimer(0),
m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), m_instanceSave(NULL),
m_activeNonPlayersIter(m_activeNonPlayers.end()),
i_gridExpiry(expiry), m_parentMap(_parent ? _parent : this),
m_lastUpdateTime(getMSTime()) // expected that next update call will not long after map creating
i_gridExpiry(expiry), m_parentMap(_parent ? _parent : this)
{
for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
{
Expand Down Expand Up @@ -511,19 +510,25 @@ 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)
{
m_lastUpdateTime = time_;

/// 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->Update(diff, 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(t_diff);
// for creature
TypeContainerVisitor<MaNGOS::ObjectUpdater, GridTypeMapContainer > grid_object_update(updater);
// for pets
TypeContainerVisitor<MaNGOS::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater);

// the player iterator is stored in the map object
// to make sure calls to Map::Remove don't invalidate it
for(m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
Expand All @@ -546,25 +551,9 @@ void Map::Update(uint32 time_, uint32 diff)
if(!isCellMarked(cell_id))
{
markCell(cell_id);

CellPair pair(x,y);
Cell cell(pair);
cell.SetNoCreate();

uint32 realdiff = diff;
if (loaded(cell.gridPair()) )
{
GridType& celldata = (*getNGrid(cell.GridX(), cell.GridY()))(cell.CellX(), cell.CellY());
realdiff = getMSTimeDiff(celldata.GetLastUpdateTime(), time_);
celldata.SetLastUpdateTime(time_);
}

MaNGOS::ObjectUpdater updater(realdiff, diff);
// for creature
TypeContainerVisitor<MaNGOS::ObjectUpdater, GridTypeMapContainer > grid_object_update(updater);
// for pets
TypeContainerVisitor<MaNGOS::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater);

Visit(cell, grid_object_update);
Visit(cell, world_object_update);
}
Expand Down Expand Up @@ -600,25 +589,9 @@ void Map::Update(uint32 time_, uint32 diff)
if(!isCellMarked(cell_id))
{
markCell(cell_id);

CellPair pair(x,y);
Cell cell(pair);
cell.SetNoCreate();

uint32 realdiff = diff;
if (loaded(cell.gridPair()) )
{
GridType& celldata = (*getNGrid(cell.GridX(), cell.GridY()))(cell.CellX(), cell.CellY());
realdiff = getMSTimeDiff(celldata.GetLastUpdateTime(), time_);
celldata.SetLastUpdateTime(time_);
}

MaNGOS::ObjectUpdater updater(realdiff, diff);
// for creature
TypeContainerVisitor<MaNGOS::ObjectUpdater, GridTypeMapContainer > grid_object_update(updater);
// for pets
TypeContainerVisitor<MaNGOS::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater);

Visit(cell, grid_object_update);
Visit(cell, world_object_update);
}
Expand All @@ -640,7 +613,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);
}
}

Expand Down Expand Up @@ -1852,17 +1825,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);
}
Expand Down
10 changes: 3 additions & 7 deletions src/game/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
template<class T> void Add(T *);
template<class T> 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 *);
Expand Down Expand Up @@ -270,8 +270,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
uint32 GenerateLocalLowGuid(HighGuid guidhigh);
bool GetAreaInfo(float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const;
bool IsOutdoors(float x, float y, float z) const;

uint32 GetLastUpdateTime() const { return m_lastUpdateTime; }
private:
void LoadMapAndVMap(int gx, int gy);
void LoadVMap(int gx, int gy);
Expand Down Expand Up @@ -348,8 +346,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
std::set<WorldObject *> i_objectsToRemove;
std::multimap<time_t, ScriptAction> m_scriptSchedule;

uint32 m_lastUpdateTime; // time in past when called Update last time, set to object at adding to Map

// Map local low guid counters
ObjectGuidGenerator<HIGHGUID_DYNAMICOBJECT> m_DynObjectGuids;
ObjectGuidGenerator<HIGHGUID_PET> m_PetGuids;
Expand All @@ -376,7 +372,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(InstanceResetMethod method);
uint32 GetScriptId() { return i_script_id; }
Expand All @@ -401,7 +397,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);
Expand Down
8 changes: 4 additions & 4 deletions src/game/MapInstanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/MapInstanced.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

2 comments on commit 925318e

@insider42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't helps, the problem just modified a bit (for example in one time all totems, all temp enchant and mob corpses are disappears/deleted/despawned in one moment at whole server). I found the originally source of problem - it's 10687, with reverted both commits seems all works ok.

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this revert not related directly to your problems. it reverted in result more deep problems in added system per-Cell update time store design.

Please sign in to comment.