mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[11161] Implement Map copy local grid spawn data support.
Currently this functionality not used, but soon planned be used in connection wiht map persistent state specific pool system data. In different from grid spawn data stored in ObjectMgr and used for global (comon for all map copies) spawns from DB data or from gameevent system, map locla spawn data used for independet grid spawns like expected to be for pool system case when it will work in full power in instances. Maybe for something other, like script dependent "static" spawns not dependent from grid load state.
This commit is contained in:
parent
30cb26d86a
commit
387f8a965a
5 changed files with 66 additions and 10 deletions
|
|
@ -128,6 +128,38 @@ void MapPersistentState::ClearRespawnTimes()
|
|||
UnloadIfEmpty();
|
||||
}
|
||||
|
||||
void MapPersistentState::AddCreatureToGrid( uint32 guid, CreatureData const* data )
|
||||
{
|
||||
CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY);
|
||||
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
|
||||
|
||||
m_gridObjectGuids[cell_id].creatures.insert(guid);
|
||||
}
|
||||
|
||||
void MapPersistentState::RemoveCreatureFromGrid( uint32 guid, CreatureData const* data )
|
||||
{
|
||||
CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY);
|
||||
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
|
||||
|
||||
m_gridObjectGuids[cell_id].creatures.erase(guid);
|
||||
}
|
||||
|
||||
void MapPersistentState::AddGameobjectToGrid( uint32 guid, GameObjectData const* data )
|
||||
{
|
||||
CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY);
|
||||
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
|
||||
|
||||
m_gridObjectGuids[cell_id].gameobjects.insert(guid);
|
||||
}
|
||||
|
||||
void MapPersistentState::RemoveGameobjectFromGrid( uint32 guid, GameObjectData const* data )
|
||||
{
|
||||
CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY);
|
||||
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
|
||||
|
||||
m_gridObjectGuids[cell_id].gameobjects.erase(guid);
|
||||
}
|
||||
|
||||
//== WorldPersistentState functions ========================
|
||||
|
||||
bool WorldPersistentState::CanBeUnload() const
|
||||
|
|
|
|||
|
|
@ -34,10 +34,23 @@
|
|||
struct InstanceTemplate;
|
||||
struct MapEntry;
|
||||
struct MapDifficulty;
|
||||
struct GameObjectData;
|
||||
struct CreatureData;
|
||||
|
||||
class Player;
|
||||
class Group;
|
||||
class Map;
|
||||
|
||||
typedef std::set<uint32> CellGuidSet;
|
||||
|
||||
struct MapCellObjectGuids
|
||||
{
|
||||
CellGuidSet creatures;
|
||||
CellGuidSet gameobjects;
|
||||
};
|
||||
|
||||
typedef UNORDERED_MAP<uint32/*cell_id*/,MapCellObjectGuids> MapCellObjectGuidsMap;
|
||||
|
||||
class MapPersistentStateManager;
|
||||
|
||||
class MapPersistentState
|
||||
|
|
@ -87,6 +100,12 @@ class MapPersistentState
|
|||
}
|
||||
void SaveGORespawnTime(uint32 loguid, time_t t);
|
||||
|
||||
// grid objects (Dynamic map/instance specific added/removed grid spawns from pool system/etc)
|
||||
MapCellObjectGuids const& GetCellObjectGuids(uint32 cell_id) { return m_gridObjectGuids[cell_id]; }
|
||||
void AddCreatureToGrid(uint32 guid, CreatureData const* data);
|
||||
void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data);
|
||||
void AddGameobjectToGrid(uint32 guid, GameObjectData const* data);
|
||||
void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data);
|
||||
protected:
|
||||
virtual bool CanBeUnload() const =0; // body provided for subclasses
|
||||
|
||||
|
|
@ -109,6 +128,7 @@ class MapPersistentState
|
|||
// persistent data
|
||||
RespawnTimes m_creatureRespawnTimes; // lock MapPersistentState from unload, for example for temporary bound dungeon unload delay
|
||||
RespawnTimes m_goRespawnTimes; // lock MapPersistentState from unload, for example for temporary bound dungeon unload delay
|
||||
MapCellObjectGuidsMap m_gridObjectGuids; // Single map copy specific grid spawn data, like pool spawns
|
||||
};
|
||||
|
||||
inline bool MapPersistentState::CanBeUnload() const
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include "ObjectGridLoader.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "MapPersistentStateMgr.h"
|
||||
#include "Creature.h"
|
||||
#include "GameObject.h"
|
||||
#include "DynamicObject.h"
|
||||
|
|
@ -179,6 +180,7 @@ ObjectGridLoader::Visit(GameObjectMapType &m)
|
|||
|
||||
GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY())) (i_cell.CellX(),i_cell.CellY());
|
||||
LoadHelper(cell_guids.gameobjects, cell_pair, m, i_gameObjects, i_map, grid);
|
||||
LoadHelper(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).gameobjects, cell_pair, m, i_gameObjects, i_map, grid);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -193,6 +195,7 @@ ObjectGridLoader::Visit(CreatureMapType &m)
|
|||
|
||||
GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY())) (i_cell.CellX(),i_cell.CellY());
|
||||
LoadHelper(cell_guids.creatures, cell_pair, m, i_creatures, i_map, grid);
|
||||
LoadHelper(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).creatures, cell_pair, m, i_creatures, i_map, grid);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "NPCHandler.h"
|
||||
#include "Database/DatabaseEnv.h"
|
||||
#include "Map.h"
|
||||
#include "MapPersistentStateMgr.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Policies/Singleton.h"
|
||||
|
|
@ -91,7 +92,6 @@ struct AreaTrigger
|
|||
float target_Orientation;
|
||||
};
|
||||
|
||||
typedef std::set<uint32> CellGuidSet;
|
||||
typedef std::map<uint32/*player guid*/,uint32/*instance*/> CellCorpseSet;
|
||||
struct CellObjectGuids
|
||||
{
|
||||
|
|
@ -758,11 +758,6 @@ class ObjectMgr
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id)
|
||||
{
|
||||
return mMapObjectGuids[MAKE_PAIR32(mapid,spawnMode)][cell_id];
|
||||
}
|
||||
|
||||
CreatureDataPair const* GetCreatureDataPair(uint32 guid) const
|
||||
{
|
||||
CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid);
|
||||
|
|
@ -879,14 +874,20 @@ class ObjectMgr
|
|||
int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; }
|
||||
void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); }
|
||||
|
||||
void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance);
|
||||
void DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid);
|
||||
// global grid objects state (static DB spawns, global spawn mods from gameevent system)
|
||||
CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id)
|
||||
{
|
||||
return mMapObjectGuids[MAKE_PAIR32(mapid,spawnMode)][cell_id];
|
||||
}
|
||||
|
||||
// grid objects
|
||||
// modifiers for global grid objects state (static DB spawns, global spawn mods from gameevent system)
|
||||
// Don't must be used for modify instance specific spawn state modifications
|
||||
void AddCreatureToGrid(uint32 guid, CreatureData const* data);
|
||||
void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data);
|
||||
void AddGameobjectToGrid(uint32 guid, GameObjectData const* data);
|
||||
void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data);
|
||||
void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance);
|
||||
void DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid);
|
||||
|
||||
// reserved names
|
||||
void LoadReservedPlayersNames();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11160"
|
||||
#define REVISION_NR "11161"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue