aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps/Map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r--src/server/game/Maps/Map.cpp139
1 files changed, 16 insertions, 123 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index eed56efd026..6a4e02a9d1b 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -41,7 +41,7 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "GossipDef.h"
-
+#include "ScriptMgr.h"
#include "MapInstanced.h"
#include "InstanceSaveMgr.h"
#include "VMapFactory.h"
@@ -62,6 +62,9 @@ struct ScriptAction
Map::~Map()
{
+ if (!Instanceable())
+ sScriptMgr.OnDestroyMap(this);
+
UnloadAll();
while (!i_worldObjects.empty())
@@ -169,6 +172,8 @@ void Map::LoadMap(int gx,int gy, bool reload)
sLog.outDetail("Unloading previously loaded map %u before reloading.",GetId());
delete (GridMaps[gx][gy]);
GridMaps[gx][gy]=NULL;
+
+ sScriptMgr.OnUnloadGridMap(this, gx, gy);
}
// map file name
@@ -184,6 +189,8 @@ void Map::LoadMap(int gx,int gy, bool reload)
sLog.outError("Error loading map file: \n %s\n", tmp);
}
delete [] tmp;
+
+ sScriptMgr.OnLoadGridMap(this, gx, gy);
}
void Map::LoadMapAndVMap(int gx,int gy)
@@ -229,6 +236,9 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _par
//lets initialize visibility distance for map
Map::InitVisibilityDistance();
+
+ if (!Instanceable())
+ sScriptMgr.OnCreateMap(this);
}
void Map::InitVisibilityDistance()
@@ -437,6 +447,7 @@ bool Map::Add(Player *player)
player->m_clientGUIDs.clear();
player->UpdateObjectVisibility(true);
+ sScriptMgr.OnPlayerEnter(this, player);
return true;
}
@@ -480,102 +491,6 @@ Map::Add(T *obj)
obj->UpdateObjectVisibility(true);
}
-/*
-void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self)
-{
- CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
-
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
- {
- sLog.outError("Map::MessageBroadcast: Player (GUID: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord);
- return;
- }
-
- Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)))
- return;
-
- Trinity::MessageDeliverer post_man(*player, msg, to_self);
- TypeContainerVisitor<Trinity::MessageDeliverer, WorldTypeMapContainer > message(post_man);
- CellLock<ReadGuard> cell_lock(cell, p);
- cell_lock->Visit(cell_lock, message, *this, *player, GetVisibilityDistance());
-}
-
-void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg)
-{
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
-
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
- {
- sLog.outError("Map::MessageBroadcast: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
- return;
- }
-
- Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)))
- return;
-
- //TODO: currently on continents when Visibility.Distance.InFlight > Visibility.Distance.Continents
- //we have alot of blinking mobs because monster move packet send is broken...
- Trinity::ObjectMessageDeliverer post_man(*obj,msg);
- TypeContainerVisitor<Trinity::ObjectMessageDeliverer, WorldTypeMapContainer > message(post_man);
- CellLock<ReadGuard> cell_lock(cell, p);
- cell_lock->Visit(cell_lock, message, *this, *obj, GetVisibilityDistance());
-}
-
-void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only)
-{
- CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
-
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
- {
- sLog.outError("Map::MessageBroadcast: Player (GUID: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord);
- return;
- }
-
- Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)))
- return;
-
- Trinity::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only);
- TypeContainerVisitor<Trinity::MessageDistDeliverer , WorldTypeMapContainer > message(post_man);
- CellLock<ReadGuard> cell_lock(cell, p);
- cell_lock->Visit(cell_lock, message, *this, *player, dist);
-}
-
-void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist)
-{
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
-
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
- {
- sLog.outError("Map::MessageBroadcast: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
- return;
- }
-
- Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)))
- return;
-
- Trinity::ObjectMessageDistDeliverer post_man(*obj, msg, dist);
- TypeContainerVisitor<Trinity::ObjectMessageDistDeliverer, WorldTypeMapContainer > message(post_man);
- CellLock<ReadGuard> cell_lock(cell, p);
- cell_lock->Visit(cell_lock, message, *this, *obj, dist);
-}
-*/
-
bool Map::loaded(const GridPair &p) const
{
return (getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord));
@@ -704,6 +619,8 @@ void Map::Update(const uint32 &t_diff)
if (!m_mapRefManager.isEmpty() || !m_activeNonPlayers.empty())
ProcessRelocationNotifies(t_diff);
+
+ sScriptMgr.OnMapUpdate(this, t_diff);
}
struct ResetNotifier
@@ -821,6 +738,8 @@ void Map::Remove(Player *player, bool remove)
if (remove)
DeleteFromWorld(player);
+
+ sScriptMgr.OnPlayerLeave(this, player);
}
template<class T>
@@ -1993,32 +1912,6 @@ void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellPair cellpai
// send data
notifier.SendToSelf();
}
-/*
-void Map::PlayerRelocationNotify(Player* player, Cell cell, CellPair cellpair)
-{
- Trinity::PlayerRelocationNotifier relocationNotifier(*player);
- cell.data.Part.reserved = ALL_DISTRICT;
-
- TypeContainerVisitor<Trinity::PlayerRelocationNotifier, GridTypeMapContainer > p2grid_relocation(relocationNotifier);
- TypeContainerVisitor<Trinity::PlayerRelocationNotifier, WorldTypeMapContainer > p2world_relocation(relocationNotifier);
-
- cell.Visit(cellpair, p2grid_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS);
- cell.Visit(cellpair, p2world_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS);
-}
-
-void Map::CreatureRelocationNotify(Creature *creature, Cell cell, CellPair cellpair)
-{
- Trinity::CreatureRelocationNotifier relocationNotifier(*creature);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate(); // not trigger load unloaded grids at notifier call
-
- TypeContainerVisitor<Trinity::CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocationNotifier);
- TypeContainerVisitor<Trinity::CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocationNotifier);
-
- cell.Visit(cellpair, c2world_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS);
- cell.Visit(cellpair, c2grid_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS);
-}
-*/
void Map::SendInitSelf(Player * player)
{