diff options
-rw-r--r-- | src/server/game/Maps/Map.cpp | 16 | ||||
-rw-r--r-- | src/server/game/Miscellaneous/Formulas.h | 11 | ||||
-rw-r--r-- | src/server/game/Scripting/ScriptMgr.cpp | 62 | ||||
-rw-r--r-- | src/server/game/Scripting/ScriptMgr.h | 61 | ||||
-rw-r--r-- | src/server/game/Server/Protocol/Handlers/MiscHandler.cpp | 2 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 2 |
6 files changed, 77 insertions, 77 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 6a4e02a9d1b..202d01aa928 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -62,8 +62,7 @@ struct ScriptAction Map::~Map() { - if (!Instanceable()) - sScriptMgr.OnDestroyMap(this); + sScriptMgr.OnDestroyMap(this); UnloadAll(); @@ -170,10 +169,10 @@ void Map::LoadMap(int gx,int gy, bool reload) if (GridMaps[gx][gy]) { sLog.outDetail("Unloading previously loaded map %u before reloading.",GetId()); + sScriptMgr.OnUnloadGridMap(this, GridMaps[gx][gy], gx, gy); + delete (GridMaps[gx][gy]); GridMaps[gx][gy]=NULL; - - sScriptMgr.OnUnloadGridMap(this, gx, gy); } // map file name @@ -190,7 +189,7 @@ void Map::LoadMap(int gx,int gy, bool reload) } delete [] tmp; - sScriptMgr.OnLoadGridMap(this, gx, gy); + sScriptMgr.OnLoadGridMap(this, GridMaps[gx][gy], gx, gy); } void Map::LoadMapAndVMap(int gx,int gy) @@ -237,8 +236,7 @@ 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); + sScriptMgr.OnCreateMap(this); } void Map::InitVisibilityDistance() @@ -447,7 +445,7 @@ bool Map::Add(Player *player) player->m_clientGUIDs.clear(); player->UpdateObjectVisibility(true); - sScriptMgr.OnPlayerEnter(this, player); + sScriptMgr.OnPlayerEnterMap(this, player); return true; } @@ -739,7 +737,7 @@ void Map::Remove(Player *player, bool remove) if (remove) DeleteFromWorld(player); - sScriptMgr.OnPlayerLeave(this, player); + sScriptMgr.OnPlayerLeaveMap(this, player); } template<class T> diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h index bd73326852e..5d992d972d4 100644 --- a/src/server/game/Miscellaneous/Formulas.h +++ b/src/server/game/Miscellaneous/Formulas.h @@ -58,7 +58,7 @@ namespace Trinity else level = pl_level - 9; - sScriptMgr.OnGetGrayLevel(level, pl_level); + sScriptMgr.OnGrayLevelCalculation(level, pl_level); return level; } @@ -77,7 +77,7 @@ namespace Trinity else color = XP_GRAY; - sScriptMgr.OnGetColorCode(color, pl_level, mob_level); + sScriptMgr.OnColorCodeCalculation(color, pl_level, mob_level); return color; } @@ -110,6 +110,7 @@ namespace Trinity else diff = 17; + sScriptMgr.OnZeroDifferenceCalculation(diff, pl_level); return diff; } @@ -155,7 +156,7 @@ namespace Trinity baseGain = 0; } - sScriptMgr.OnGetBaseGain(baseGain, pl_level, mob_level, content); + sScriptMgr.OnBaseGainCalculation(baseGain, pl_level, mob_level, content); return baseGain; } @@ -182,7 +183,7 @@ namespace Trinity } gain *= sWorld.getRate(RATE_XP_KILL); - sScriptMgr.OnGetGain(gain, pl, u); + sScriptMgr.OnGainCalculation(gain, pl, u); return gain; } @@ -213,7 +214,7 @@ namespace Trinity } } - sScriptMgr.OnGetGroupRate(rate, count, isRaid); + sScriptMgr.OnGroupRateCalculation(rate, count, isRaid); return rate; } } diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 082ae1ea5ca..9487baa5811 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -374,9 +374,9 @@ void ScriptMgr::OnMotdChange(std::string& newMotd) FOREACH_SCRIPT(WorldScript)->OnMotdChange(newMotd); } -void ScriptMgr::OnShutdown(ShutdownExitCode code, ShutdownMask mask) +void ScriptMgr::OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask) { - FOREACH_SCRIPT(WorldScript)->OnShutdown(code, mask); + FOREACH_SCRIPT(WorldScript)->OnShutdownInitiate(code, mask); } void ScriptMgr::OnShutdownCancel() @@ -399,37 +399,37 @@ void ScriptMgr::OnHonorCalculation(uint32& honor, uint8 level, uint32 count) FOREACH_SCRIPT(FormulaScript)->OnHonorCalculation(honor, level, count); } -void ScriptMgr::OnGetGrayLevel(uint8& grayLevel, uint8 playerLevel) +void ScriptMgr::OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel) { - FOREACH_SCRIPT(FormulaScript)->OnGetGrayLevel(grayLevel, playerLevel); + FOREACH_SCRIPT(FormulaScript)->OnGrayLevelCalculation(grayLevel, playerLevel); } -void ScriptMgr::OnGetColorCode(XPColorChar& color, uint8 playerLevel, uint8 mobLevel) +void ScriptMgr::OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel) { - FOREACH_SCRIPT(FormulaScript)->OnGetColorCode(color, playerLevel, mobLevel); + FOREACH_SCRIPT(FormulaScript)->OnColorCodeCalculation(color, playerLevel, mobLevel); } -void ScriptMgr::OnGetZeroDifference(uint8& diff, uint8 playerLevel) +void ScriptMgr::OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel) { - FOREACH_SCRIPT(FormulaScript)->OnGetZeroDifference(diff, playerLevel); + FOREACH_SCRIPT(FormulaScript)->OnZeroDifferenceCalculation(diff, playerLevel); } -void ScriptMgr::OnGetBaseGain(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content) +void ScriptMgr::OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content) { - FOREACH_SCRIPT(FormulaScript)->OnGetBaseGain(gain, playerLevel, mobLevel, content); + FOREACH_SCRIPT(FormulaScript)->OnBaseGainCalculation(gain, playerLevel, mobLevel, content); } -void ScriptMgr::OnGetGain(uint32& gain, Player* player, Unit* unit) +void ScriptMgr::OnGainCalculation(uint32& gain, Player* player, Unit* unit) { ASSERT(player); ASSERT(unit); - FOREACH_SCRIPT(FormulaScript)->OnGetGain(gain, player, unit); + FOREACH_SCRIPT(FormulaScript)->OnGainCalculation(gain, player, unit); } -void ScriptMgr::OnGetGroupRate(float& rate, uint32 count, bool isRaid) +void ScriptMgr::OnGroupRateCalculation(float& rate, uint32 count, bool isRaid) { - FOREACH_SCRIPT(FormulaScript)->OnGetGroupRate(rate, count, isRaid); + FOREACH_SCRIPT(FormulaScript)->OnGroupRateCalculation(rate, count, isRaid); } #define SCR_MAP_BGN(M,V,I,E,C,T) \ @@ -483,41 +483,41 @@ void ScriptMgr::OnDestroyMap(Map* map) SCR_MAP_END; } -void ScriptMgr::OnLoadGridMap(Map* map, uint32 gx, uint32 gy) +void ScriptMgr::OnLoadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy) { ASSERT(map); SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsContinent); - itr->second->OnLoadGridMap(map, gx, gy); + itr->second->OnLoadGridMap(map, gmap, gx, gy); SCR_MAP_END; SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon); - itr->second->OnLoadGridMap((InstanceMap*)map, gx, gy); + itr->second->OnLoadGridMap((InstanceMap*)map, gmap, gx, gy); SCR_MAP_END; SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleGround); - itr->second->OnLoadGridMap((BattleGroundMap*)map, gx, gy); + itr->second->OnLoadGridMap((BattleGroundMap*)map, gmap, gx, gy); SCR_MAP_END; } -void ScriptMgr::OnUnloadGridMap(Map* map, uint32 gx, uint32 gy) +void ScriptMgr::OnUnloadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy) { ASSERT(map); SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsContinent); - itr->second->OnUnloadGridMap(map, gx, gy); + itr->second->OnUnloadGridMap(map, gmap, gx, gy); SCR_MAP_END; SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon); - itr->second->OnUnloadGridMap((InstanceMap*)map, gx, gy); + itr->second->OnUnloadGridMap((InstanceMap*)map, gmap, gx, gy); SCR_MAP_END; SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleGround); - itr->second->OnUnloadGridMap((BattleGroundMap*)map, gx, gy); + itr->second->OnUnloadGridMap((BattleGroundMap*)map, gmap, gx, gy); SCR_MAP_END; } -void ScriptMgr::OnPlayerEnter(Map* map, Player* player) +void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player) { ASSERT(map); ASSERT(player); @@ -535,7 +535,7 @@ void ScriptMgr::OnPlayerEnter(Map* map, Player* player) SCR_MAP_END; } -void ScriptMgr::OnPlayerLeave(Map* map, Player* player) +void ScriptMgr::OnPlayerLeaveMap(Map* map, Player* player) { ASSERT(map); ASSERT(player); @@ -578,7 +578,7 @@ InstanceData* ScriptMgr::CreateInstanceData(InstanceMap* map) ASSERT(map); GET_SCRIPT_RET(InstanceMapScript, map->GetScriptId(), tmpscript, NULL); - return tmpscript->OnGetInstanceData(map); + return tmpscript->GetInstanceData(map); } bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Item* target) @@ -711,7 +711,7 @@ uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature) // TODO: 100 is a funny magic number to have hanging around here... GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, 100); player->PlayerTalkClass->ClearMenus(); - return tmpscript->OnDialogStatus(player, creature); + return tmpscript->GetDialogStatus(player, creature); } CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature) @@ -719,7 +719,7 @@ CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature) ASSERT(creature); GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, NULL); - return tmpscript->OnGetAI(creature); + return tmpscript->GetAI(creature); } void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff) @@ -791,7 +791,7 @@ uint32 ScriptMgr::GetDialogStatus(Player* player, GameObject* go) // TODO: 100 is a funny magic number to have hanging around here... GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, 100); player->PlayerTalkClass->ClearMenus(); - return tmpscript->OnDialogStatus(player, go); + return tmpscript->GetDialogStatus(player, go); } void ScriptMgr::OnGameObjectDestroyed(Player* player, GameObject* go, uint32 eventId) @@ -820,7 +820,7 @@ bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effInd return tmpscript->OnDummyEffect(caster, spellId, effIndex, target); } -bool ScriptMgr::OnTrigger(Player* player, AreaTriggerEntry const* trigger) +bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger) { ASSERT(player); ASSERT(trigger); @@ -841,7 +841,7 @@ OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data) ASSERT(data); GET_SCRIPT_RET(OutdoorPvPScript, data->ScriptId, tmpscript, NULL); - return tmpscript->OnGetOutdoorPvP(); + return tmpscript->GetOutdoorPvP(); } std::vector<ChatCommand*> ScriptMgr::GetChatCommands() @@ -849,7 +849,7 @@ std::vector<ChatCommand*> ScriptMgr::GetChatCommands() std::vector<ChatCommand*> table; FOR_SCRIPTS_RET(CommandScript, itr, end, table) - table.push_back(itr->second->OnGetCommands()); + table.push_back(itr->second->GetCommands()); return table; } diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 2a29edf4840..7cb81724497 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -135,10 +135,11 @@ class ScriptObject public: - // Called when the script is initialized. Use it to initialize any properties of the script. + // Called when the script is initialized. Use it to initialize any properties of the script. Do not use + // the constructor for this. virtual void OnInitialize() { } - // Called when the script is deleted. Use it to free memory, etc. + // Called when the script is deleted. Use it to free memory, etc. Do not use the destructor for this. virtual void OnTeardown() { } // Do not override this in scripts; it should be overridden by the various script type classes. It indicates @@ -284,7 +285,7 @@ class WorldScript : public ScriptObject, public UpdatableScript<void> virtual void OnMotdChange(std::string& newMotd) { } // Called when a world shutdown is initiated. - virtual void OnShutdown(ShutdownExitCode code, ShutdownMask mask) { } + virtual void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask) { } // Called when a world shutdown is cancelled. virtual void OnShutdownCancel() { } @@ -312,21 +313,21 @@ class FormulaScript : public ScriptObject virtual void OnHonorCalculation(uint32& honor, uint8 level, uint32 count) { } // Called after gray level calculation. - virtual void OnGetGrayLevel(uint8& grayLevel, uint8 playerLevel) { } + virtual void OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel) { } // Called after calculating experience color. - virtual void OnGetColorCode(XPColorChar& color, uint8 playerLevel, uint8 mobLevel) { } + virtual void OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel) { } // Called after calculating zero difference. - virtual void OnGetZeroDifference(uint8& diff, uint8 playerLevel) { } + virtual void OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel) { } // Called after calculating base experience gain. - virtual void OnGetBaseGain(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content) { } + virtual void OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content) { } // Called after calculating experience gain. - virtual void OnGetGain(uint32& gain, Player* player, Unit* unit) { } + virtual void OnGainCalculation(uint32& gain, Player* player, Unit* unit) { } - virtual void OnGetGroupRate(float& rate, uint32 count, bool isRaid) { } + virtual void OnGroupRateCalculation(float& rate, uint32 count, bool isRaid) { } }; template<class TMap> class MapScript : public UpdatableScript<TMap> @@ -354,10 +355,10 @@ template<class TMap> class MapScript : public UpdatableScript<TMap> virtual void OnDestroy(TMap* map) { } // Called when a grid map is loaded. - virtual void OnLoadGridMap(TMap* map, uint32 gx, uint32 gy) { } + virtual void OnLoadGridMap(TMap* map, GridMap* gmap, uint32 gx, uint32 gy) { } // Called when a grid map is unloaded. - virtual void OnUnloadGridMap(TMap* map, uint32 gx, uint32 gy) { } + virtual void OnUnloadGridMap(TMap* map, GridMap* gmap, uint32 gx, uint32 gy) { } // Called when a player enters the map. virtual void OnPlayerEnter(TMap* map, Player* player) { } @@ -401,7 +402,7 @@ class InstanceMapScript : public ScriptObject, public MapScript<InstanceMap> bool IsDatabaseBound() const { return true; } // Gets an InstanceData object for this instance. - virtual InstanceData* OnGetInstanceData(InstanceMap* map) { return NULL; } + virtual InstanceData* GetInstanceData(InstanceMap* map) { return NULL; } }; class BattlegroundMapScript : public ScriptObject, public MapScript<BattleGroundMap> @@ -484,10 +485,10 @@ class CreatureScript : public ScriptObject, public UpdatableScript<Creature> virtual bool OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt) { return false; } // Called when the dialog status between a player and the creature is requested. - virtual uint32 OnDialogStatus(Player* player, Creature* creature) { return 0; } + virtual uint32 GetDialogStatus(Player* player, Creature* creature) { return 0; } // Called when a CreatureAI object is needed for the creature. - virtual CreatureAI* OnGetAI(Creature* creature) const { return NULL; } + virtual CreatureAI* GetAI(Creature* creature) const { return NULL; } }; class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject> @@ -523,7 +524,7 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject> virtual bool OnQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt) { return false; } // Called when the dialog status between a player and the gameobject is requested. - virtual uint32 OnDialogStatus(Player* player, GameObject* go) { return 0; } + virtual uint32 GetDialogStatus(Player* player, GameObject* go) { return 0; } // Called when the gameobject is destroyed (destructible buildings only). virtual void OnDestroyed(Player* player, GameObject* go, uint32 eventId) { } @@ -562,7 +563,7 @@ class BattlegroundScript : public ScriptObject bool IsDatabaseBound() const { return true; } // Should return a fully valid BattleGround object for the type ID. - virtual BattleGround* OnGetBattleground() = 0; + virtual BattleGround* GetBattleground() = 0; }; class OutdoorPvPScript : public ScriptObject @@ -580,7 +581,7 @@ class OutdoorPvPScript : public ScriptObject bool IsDatabaseBound() const { return true; } // Should return a fully valid OutdoorPvP object for the type ID. - virtual OutdoorPvP* OnGetOutdoorPvP() = 0; + virtual OutdoorPvP* GetOutdoorPvP() = 0; }; class CommandScript : public ScriptObject @@ -596,7 +597,7 @@ class CommandScript : public ScriptObject public: // Should return a pointer to a valid command table (ChatCommand array) to be used by ChatHandler. - virtual ChatCommand* OnGetCommands() = 0; + virtual ChatCommand* GetCommands() = 0; }; class WeatherScript : public ScriptObject, public UpdatableScript<Weather> @@ -780,7 +781,7 @@ class ScriptMgr void OnOpenStateChange(bool open); void OnConfigLoad(bool reload); void OnMotdChange(std::string& newMotd); - void OnShutdown(ShutdownExitCode code, ShutdownMask mask); + void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask); void OnShutdownCancel(); void OnWorldUpdate(uint32 diff); @@ -788,21 +789,21 @@ class ScriptMgr void OnHonorCalculation(float& honor, uint8 level, uint32 count); void OnHonorCalculation(uint32& honor, uint8 level, uint32 count); - void OnGetGrayLevel(uint8& grayLevel, uint8 playerLevel); - void OnGetColorCode(XPColorChar& color, uint8 playerLevel, uint8 mobLevel); - void OnGetZeroDifference(uint8& diff, uint8 playerLevel); - void OnGetBaseGain(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content); - void OnGetGain(uint32& gain, Player* player, Unit* unit); - void OnGetGroupRate(float& rate, uint32 count, bool isRaid); + void OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel); + void OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel); + void OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel); + void OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content); + void OnGainCalculation(uint32& gain, Player* player, Unit* unit); + void OnGroupRateCalculation(float& rate, uint32 count, bool isRaid); public: /* MapScript */ void OnCreateMap(Map* map); void OnDestroyMap(Map* map); - void OnLoadGridMap(Map* map, uint32 gx, uint32 gy); - void OnUnloadGridMap(Map* map, uint32 gx, uint32 gy); - void OnPlayerEnter(Map* map, Player* player); - void OnPlayerLeave(Map* map, Player* player); + void OnLoadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy); + void OnUnloadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy); + void OnPlayerEnterMap(Map* map, Player* player); + void OnPlayerLeaveMap(Map* map, Player* player); void OnMapUpdate(Map* map, uint32 diff); public: /* InstanceMapScript */ @@ -844,7 +845,7 @@ class ScriptMgr public: /* AreaTriggerScript */ - bool OnTrigger(Player* player, AreaTriggerEntry const* trigger); + bool OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger); public: /* BattlegroundScript */ diff --git a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp index 264f48b7265..722c7258e49 100644 --- a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp @@ -884,7 +884,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) } } - if (sScriptMgr.OnTrigger(GetPlayer(), atEntry)) + if (sScriptMgr.OnAreaTrigger(GetPlayer(), atEntry)) return; uint32 quest_id = objmgr.GetQuestForAreaTrigger(Trigger_ID); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 0554bf5e5a7..238a0e4d312 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -2386,7 +2386,7 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) ShutdownMsg(true); } - sScriptMgr.OnShutdown(ShutdownExitCode(exitcode), ShutdownMask(options)); + sScriptMgr.OnShutdownInitiate(ShutdownExitCode(exitcode), ShutdownMask(options)); } /// Display a shutdown message to the user(s) |