Advertisement
darksoke

ScriptMgr.cpp

Nov 30th, 2014
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 51.13 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
  3.  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify it
  6.  * under the terms of the GNU General Public License as published by the
  7.  * Free Software Foundation; either version 2 of the License, or (at your
  8.  * option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful, but WITHOUT
  11.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12.  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13.  * more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License along
  16.  * with this program. If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. #include "ScriptMgr.h"
  20. #include "Config.h"
  21. #include "DatabaseEnv.h"
  22. #include "DBCStores.h"
  23. #include "ObjectMgr.h"
  24. #include "OutdoorPvPMgr.h"
  25. #include "ScriptLoader.h"
  26. #include "ScriptSystem.h"
  27. #include "Transport.h"
  28. #include "Vehicle.h"
  29. #include "SpellInfo.h"
  30. #include "SpellScript.h"
  31. #include "GossipDef.h"
  32. #include "CreatureAIImpl.h"
  33. #include "Player.h"
  34. #include "WorldPacket.h"
  35.  
  36. namespace
  37. {
  38.     typedef std::set<ScriptObject*> ExampleScriptContainer;
  39.     ExampleScriptContainer ExampleScripts;
  40. }
  41.  
  42. // This is the global static registry of scripts.
  43. template<class TScript>
  44. class ScriptRegistry
  45. {
  46.     public:
  47.  
  48.         typedef std::map<uint32, TScript*> ScriptMap;
  49.         typedef typename ScriptMap::iterator ScriptMapIterator;
  50.  
  51.         // The actual list of scripts. This will be accessed concurrently, so it must not be modified
  52.         // after server startup.
  53.         static ScriptMap ScriptPointerList;
  54.  
  55.         static void AddScript(TScript* const script)
  56.         {
  57.             ASSERT(script);
  58.  
  59.             // See if the script is using the same memory as another script. If this happens, it means that
  60.             // someone forgot to allocate new memory for a script.
  61.             for (ScriptMapIterator it = ScriptPointerList.begin(); it != ScriptPointerList.end(); ++it)
  62.             {
  63.                 if (it->second == script)
  64.                 {
  65.                     TC_LOG_ERROR("scripts", "Script '%s' has same memory pointer as '%s'.",
  66.                         script->GetName().c_str(), it->second->GetName().c_str());
  67.  
  68.                     return;
  69.                 }
  70.             }
  71.  
  72.             if (script->IsDatabaseBound())
  73.             {
  74.                 // Get an ID for the script. An ID only exists if it's a script that is assigned in the database
  75.                 // through a script name (or similar).
  76.                 uint32 id = sObjectMgr->GetScriptId(script->GetName().c_str());
  77.                 if (id)
  78.                 {
  79.                     // Try to find an existing script.
  80.                     bool existing = false;
  81.                     for (ScriptMapIterator it = ScriptPointerList.begin(); it != ScriptPointerList.end(); ++it)
  82.                     {
  83.                         // If the script names match...
  84.                         if (it->second->GetName() == script->GetName())
  85.                         {
  86.                             // ... It exists.
  87.                             existing = true;
  88.                             break;
  89.                         }
  90.                     }
  91.  
  92.                     // If the script isn't assigned -> assign it!
  93.                     if (!existing)
  94.                     {
  95.                         ScriptPointerList[id] = script;
  96.                         sScriptMgr->IncrementScriptCount();
  97.                     }
  98.                     else
  99.                     {
  100.                         // If the script is already assigned -> delete it!
  101.                         TC_LOG_ERROR("scripts", "Script '%s' already assigned with the same script name, so the script can't work.",
  102.                             script->GetName().c_str());
  103.  
  104.                         ASSERT(false); // Error that should be fixed ASAP.
  105.                     }
  106.                 }
  107.                 else
  108.                 {
  109.                     // The script uses a script name from database, but isn't assigned to anything.
  110.                     if (script->GetName().find("example") == std::string::npos && script->GetName().find("Smart") == std::string::npos)
  111.                         TC_LOG_ERROR("sql.sql", "Script named '%s' does not have a script name assigned in database.",
  112.                             script->GetName().c_str());
  113.  
  114.                     // These scripts don't get stored anywhere so throw them into this to avoid leaking memory
  115.                     ExampleScripts.insert(script);
  116.                 }
  117.             }
  118.             else
  119.             {
  120.                 // We're dealing with a code-only script; just add it.
  121.                 ScriptPointerList[_scriptIdCounter++] = script;
  122.                 sScriptMgr->IncrementScriptCount();
  123.             }
  124.         }
  125.  
  126.         // Gets a script by its ID (assigned by ObjectMgr).
  127.         static TScript* GetScriptById(uint32 id)
  128.         {
  129.             ScriptMapIterator it = ScriptPointerList.find(id);
  130.             if (it != ScriptPointerList.end())
  131.                 return it->second;
  132.  
  133.             return NULL;
  134.         }
  135.  
  136.     private:
  137.  
  138.         // Counter used for code-only scripts.
  139.         static uint32 _scriptIdCounter;
  140. };
  141.  
  142. // Utility macros to refer to the script registry.
  143. #define SCR_REG_MAP(T) ScriptRegistry<T>::ScriptMap
  144. #define SCR_REG_ITR(T) ScriptRegistry<T>::ScriptMapIterator
  145. #define SCR_REG_LST(T) ScriptRegistry<T>::ScriptPointerList
  146.  
  147. // Utility macros for looping over scripts.
  148. #define FOR_SCRIPTS(T, C, E) \
  149.     if (SCR_REG_LST(T).empty()) \
  150.         return; \
  151.     for (SCR_REG_ITR(T) C = SCR_REG_LST(T).begin(); \
  152.         C != SCR_REG_LST(T).end(); ++C)
  153. #define FOR_SCRIPTS_RET(T, C, E, R) \
  154.     if (SCR_REG_LST(T).empty()) \
  155.         return R; \
  156.     for (SCR_REG_ITR(T) C = SCR_REG_LST(T).begin(); \
  157.         C != SCR_REG_LST(T).end(); ++C)
  158. #define FOREACH_SCRIPT(T) \
  159.     FOR_SCRIPTS(T, itr, end) \
  160.     itr->second
  161.  
  162. // Utility macros for finding specific scripts.
  163. #define GET_SCRIPT(T, I, V) \
  164.     T* V = ScriptRegistry<T>::GetScriptById(I); \
  165.     if (!V) \
  166.         return;
  167. #define GET_SCRIPT_RET(T, I, V, R) \
  168.     T* V = ScriptRegistry<T>::GetScriptById(I); \
  169.     if (!V) \
  170.         return R;
  171.  
  172. struct TSpellSummary
  173. {
  174.     uint8 Targets;                                          // set of enum SelectTarget
  175.     uint8 Effects;                                          // set of enum SelectEffect
  176. } *SpellSummary;
  177.  
  178. ScriptMgr::ScriptMgr()
  179.     : _scriptCount(0), _scheduledScripts(0) { }
  180.  
  181. ScriptMgr::~ScriptMgr() { }
  182.  
  183. void ScriptMgr::Initialize()
  184. {
  185.     uint32 oldMSTime = getMSTime();
  186.  
  187.     LoadDatabase();
  188.  
  189.     TC_LOG_INFO("server.loading", "Loading C++ scripts");
  190.  
  191.     FillSpellSummary();
  192.     AddScripts();
  193.  
  194.     TC_LOG_INFO("server.loading", ">> Loaded %u C++ scripts in %u ms", GetScriptCount(), GetMSTimeDiffToNow(oldMSTime));
  195. }
  196.  
  197. void ScriptMgr::Unload()
  198. {
  199.     #define SCR_CLEAR(T) \
  200.         for (SCR_REG_ITR(T) itr = SCR_REG_LST(T).begin(); itr != SCR_REG_LST(T).end(); ++itr) \
  201.             delete itr->second; \
  202.         SCR_REG_LST(T).clear();
  203.  
  204.     // Clear scripts for every script type.
  205.     SCR_CLEAR(SpellScriptLoader);
  206.     SCR_CLEAR(ServerScript);
  207.     SCR_CLEAR(WorldScript);
  208.     SCR_CLEAR(FormulaScript);
  209.     SCR_CLEAR(WorldMapScript);
  210.     SCR_CLEAR(InstanceMapScript);
  211.     SCR_CLEAR(BattlegroundMapScript);
  212.     SCR_CLEAR(ItemScript);
  213.     SCR_CLEAR(CreatureScript);
  214.     SCR_CLEAR(GameObjectScript);
  215.     SCR_CLEAR(AreaTriggerScript);
  216.     SCR_CLEAR(BattlegroundScript);
  217.     SCR_CLEAR(OutdoorPvPScript);
  218.     SCR_CLEAR(CommandScript);
  219.     SCR_CLEAR(WeatherScript);
  220.     SCR_CLEAR(AuctionHouseScript);
  221.     SCR_CLEAR(ConditionScript);
  222.     SCR_CLEAR(VehicleScript);
  223.     SCR_CLEAR(DynamicObjectScript);
  224.     SCR_CLEAR(TransportScript);
  225.     SCR_CLEAR(AchievementCriteriaScript);
  226.     SCR_CLEAR(PlayerScript);
  227.     SCR_CLEAR(GuildScript);
  228.     SCR_CLEAR(GroupScript);
  229.     SCR_CLEAR(UnitScript);
  230.  
  231.     #undef SCR_CLEAR
  232.  
  233.     for (ExampleScriptContainer::iterator itr = ExampleScripts.begin(); itr != ExampleScripts.end(); ++itr)
  234.         delete *itr;
  235.     ExampleScripts.clear();
  236.  
  237.     delete[] SpellSummary;
  238.     delete[] UnitAI::AISpellInfo;
  239. }
  240.  
  241. void ScriptMgr::LoadDatabase()
  242. {
  243.     sScriptSystemMgr->LoadScriptWaypoints();
  244. }
  245.  
  246. void ScriptMgr::FillSpellSummary()
  247. {
  248.     UnitAI::FillAISpellInfo();
  249.  
  250.     SpellSummary = new TSpellSummary[sSpellMgr->GetSpellInfoStoreSize()];
  251.  
  252.     SpellInfo const* pTempSpell;
  253.  
  254.     for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
  255.     {
  256.         SpellSummary[i].Effects = 0;
  257.         SpellSummary[i].Targets = 0;
  258.  
  259.         pTempSpell = sSpellMgr->GetSpellInfo(i);
  260.         // This spell doesn't exist.
  261.         if (!pTempSpell)
  262.             continue;
  263.  
  264.         for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
  265.         {
  266.             // Spell targets self.
  267.             if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER)
  268.                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1);
  269.  
  270.             // Spell targets a single enemy.
  271.             if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
  272.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY)
  273.                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1);
  274.  
  275.             // Spell targets AoE at enemy.
  276.             if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY ||
  277.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
  278.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER ||
  279.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
  280.                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1);
  281.  
  282.             // Spell targets an enemy.
  283.             if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
  284.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY ||
  285.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY ||
  286.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
  287.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER ||
  288.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
  289.                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1);
  290.  
  291.             // Spell targets a single friend (or self).
  292.             if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER ||
  293.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
  294.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY)
  295.                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1);
  296.  
  297.             // Spell targets AoE friends.
  298.             if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER_AREA_PARTY ||
  299.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
  300.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER)
  301.                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1);
  302.  
  303.             // Spell targets any friend (or self).
  304.             if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER ||
  305.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
  306.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY ||
  307.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER_AREA_PARTY ||
  308.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
  309.                 pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER)
  310.                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1);
  311.  
  312.             // Make sure that this spell includes a damage effect.
  313.             if (pTempSpell->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE ||
  314.                 pTempSpell->Effects[j].Effect == SPELL_EFFECT_INSTAKILL ||
  315.                 pTempSpell->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
  316.                 pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
  317.                 SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE-1);
  318.  
  319.             // Make sure that this spell includes a healing effect (or an apply aura with a periodic heal).
  320.             if (pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL ||
  321.                 pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL_MAX_HEALTH ||
  322.                 pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL_MECHANICAL ||
  323.                 (pTempSpell->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA  && pTempSpell->Effects[j].ApplyAuraName == 8))
  324.                 SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING-1);
  325.  
  326.             // Make sure that this spell applies an aura.
  327.             if (pTempSpell->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA)
  328.                 SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA-1);
  329.         }
  330.     }
  331. }
  332.  
  333. void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector)
  334. {
  335.     SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
  336.  
  337.     for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
  338.     {
  339.         SpellScriptLoader* tmpscript = ScriptRegistry<SpellScriptLoader>::GetScriptById(itr->second);
  340.         if (!tmpscript)
  341.             continue;
  342.  
  343.         SpellScript* script = tmpscript->GetSpellScript();
  344.  
  345.         if (!script)
  346.             continue;
  347.  
  348.         script->_Init(&tmpscript->GetName(), spellId);
  349.  
  350.         scriptVector.push_back(script);
  351.     }
  352. }
  353.  
  354. void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector)
  355. {
  356.     SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
  357.  
  358.     for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
  359.     {
  360.         SpellScriptLoader* tmpscript = ScriptRegistry<SpellScriptLoader>::GetScriptById(itr->second);
  361.         if (!tmpscript)
  362.             continue;
  363.  
  364.         AuraScript* script = tmpscript->GetAuraScript();
  365.  
  366.         if (!script)
  367.             continue;
  368.  
  369.         script->_Init(&tmpscript->GetName(), spellId);
  370.  
  371.         scriptVector.push_back(script);
  372.     }
  373. }
  374.  
  375. void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> >& scriptVector)
  376. {
  377.     SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
  378.     scriptVector.reserve(std::distance(bounds.first, bounds.second));
  379.  
  380.     for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
  381.     {
  382.         SpellScriptLoader* tmpscript = ScriptRegistry<SpellScriptLoader>::GetScriptById(itr->second);
  383.         if (!tmpscript)
  384.             continue;
  385.  
  386.         scriptVector.push_back(std::make_pair(tmpscript, itr));
  387.     }
  388. }
  389.  
  390. void ScriptMgr::OnNetworkStart()
  391. {
  392.     FOREACH_SCRIPT(ServerScript)->OnNetworkStart();
  393. }
  394.  
  395. void ScriptMgr::OnNetworkStop()
  396. {
  397.     FOREACH_SCRIPT(ServerScript)->OnNetworkStop();
  398. }
  399.  
  400. void ScriptMgr::OnSocketOpen(WorldSocket* socket)
  401. {
  402.     ASSERT(socket);
  403.  
  404.     FOREACH_SCRIPT(ServerScript)->OnSocketOpen(socket);
  405. }
  406.  
  407. void ScriptMgr::OnSocketClose(WorldSocket* socket, bool wasNew)
  408. {
  409.     ASSERT(socket);
  410.  
  411.     FOREACH_SCRIPT(ServerScript)->OnSocketClose(socket, wasNew);
  412. }
  413.  
  414. void ScriptMgr::OnPacketReceive(WorldSocket* socket, WorldPacket packet)
  415. {
  416.     ASSERT(socket);
  417.  
  418.     FOREACH_SCRIPT(ServerScript)->OnPacketReceive(socket, packet);
  419. }
  420.  
  421. void ScriptMgr::OnPacketSend(WorldSocket* socket, WorldPacket packet)
  422. {
  423.     ASSERT(socket);
  424.  
  425.     FOREACH_SCRIPT(ServerScript)->OnPacketSend(socket, packet);
  426. }
  427.  
  428. void ScriptMgr::OnUnknownPacketReceive(WorldSocket* socket, WorldPacket packet)
  429. {
  430.     ASSERT(socket);
  431.  
  432.     FOREACH_SCRIPT(ServerScript)->OnUnknownPacketReceive(socket, packet);
  433. }
  434.  
  435. void ScriptMgr::OnOpenStateChange(bool open)
  436. {
  437.     FOREACH_SCRIPT(WorldScript)->OnOpenStateChange(open);
  438. }
  439.  
  440. void ScriptMgr::OnConfigLoad(bool reload)
  441. {
  442.     FOREACH_SCRIPT(WorldScript)->OnConfigLoad(reload);
  443. }
  444.  
  445. void ScriptMgr::OnMotdChange(std::string& newMotd)
  446. {
  447.     FOREACH_SCRIPT(WorldScript)->OnMotdChange(newMotd);
  448. }
  449.  
  450. void ScriptMgr::OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask)
  451. {
  452.     FOREACH_SCRIPT(WorldScript)->OnShutdownInitiate(code, mask);
  453. }
  454.  
  455. void ScriptMgr::OnShutdownCancel()
  456. {
  457.     FOREACH_SCRIPT(WorldScript)->OnShutdownCancel();
  458. }
  459.  
  460. void ScriptMgr::OnWorldUpdate(uint32 diff)
  461. {
  462.     FOREACH_SCRIPT(WorldScript)->OnUpdate(diff);
  463. }
  464.  
  465. void ScriptMgr::OnHonorCalculation(float& honor, uint8 level, float multiplier)
  466. {
  467.     FOREACH_SCRIPT(FormulaScript)->OnHonorCalculation(honor, level, multiplier);
  468. }
  469.  
  470. void ScriptMgr::OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel)
  471. {
  472.     FOREACH_SCRIPT(FormulaScript)->OnGrayLevelCalculation(grayLevel, playerLevel);
  473. }
  474.  
  475. void ScriptMgr::OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel)
  476. {
  477.     FOREACH_SCRIPT(FormulaScript)->OnColorCodeCalculation(color, playerLevel, mobLevel);
  478. }
  479.  
  480. void ScriptMgr::OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel)
  481. {
  482.     FOREACH_SCRIPT(FormulaScript)->OnZeroDifferenceCalculation(diff, playerLevel);
  483. }
  484.  
  485. void ScriptMgr::OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content)
  486. {
  487.     FOREACH_SCRIPT(FormulaScript)->OnBaseGainCalculation(gain, playerLevel, mobLevel, content);
  488. }
  489.  
  490. void ScriptMgr::OnGainCalculation(uint32& gain, Player* player, Unit* unit)
  491. {
  492.     ASSERT(player);
  493.     ASSERT(unit);
  494.  
  495.     FOREACH_SCRIPT(FormulaScript)->OnGainCalculation(gain, player, unit);
  496. }
  497.  
  498. void ScriptMgr::OnGroupRateCalculation(float& rate, uint32 count, bool isRaid)
  499. {
  500.     FOREACH_SCRIPT(FormulaScript)->OnGroupRateCalculation(rate, count, isRaid);
  501. }
  502.  
  503. #define SCR_MAP_BGN(M, V, I, E, C, T) \
  504.     if (V->GetEntry() && V->GetEntry()->T()) \
  505.     { \
  506.         FOR_SCRIPTS(M, I, E) \
  507.         { \
  508.             MapEntry const* C = I->second->GetEntry(); \
  509.             if (!C) \
  510.                 continue; \
  511.             if (C->MapID == V->GetId()) \
  512.             {
  513.  
  514. #define SCR_MAP_END \
  515.                 return; \
  516.             } \
  517.         } \
  518.     }
  519.  
  520. void ScriptMgr::OnCreateMap(Map* map)
  521. {
  522.     ASSERT(map);
  523.  
  524.     SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
  525.         itr->second->OnCreate(map);
  526.     SCR_MAP_END;
  527.  
  528.     SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
  529.         itr->second->OnCreate((InstanceMap*)map);
  530.     SCR_MAP_END;
  531.  
  532.     SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
  533.         itr->second->OnCreate((BattlegroundMap*)map);
  534.     SCR_MAP_END;
  535. }
  536.  
  537. void ScriptMgr::OnDestroyMap(Map* map)
  538. {
  539.     ASSERT(map);
  540.  
  541.     SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
  542.         itr->second->OnDestroy(map);
  543.     SCR_MAP_END;
  544.  
  545.     SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
  546.         itr->second->OnDestroy((InstanceMap*)map);
  547.     SCR_MAP_END;
  548.  
  549.     SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
  550.         itr->second->OnDestroy((BattlegroundMap*)map);
  551.     SCR_MAP_END;
  552. }
  553.  
  554. void ScriptMgr::OnLoadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy)
  555. {
  556.     ASSERT(map);
  557.     ASSERT(gmap);
  558.  
  559.     SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
  560.         itr->second->OnLoadGridMap(map, gmap, gx, gy);
  561.     SCR_MAP_END;
  562.  
  563.     SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
  564.         itr->second->OnLoadGridMap((InstanceMap*)map, gmap, gx, gy);
  565.     SCR_MAP_END;
  566.  
  567.     SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
  568.         itr->second->OnLoadGridMap((BattlegroundMap*)map, gmap, gx, gy);
  569.     SCR_MAP_END;
  570. }
  571.  
  572. void ScriptMgr::OnUnloadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy)
  573. {
  574.     ASSERT(map);
  575.     ASSERT(gmap);
  576.  
  577.     SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
  578.         itr->second->OnUnloadGridMap(map, gmap, gx, gy);
  579.     SCR_MAP_END;
  580.  
  581.     SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
  582.         itr->second->OnUnloadGridMap((InstanceMap*)map, gmap, gx, gy);
  583.     SCR_MAP_END;
  584.  
  585.     SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
  586.         itr->second->OnUnloadGridMap((BattlegroundMap*)map, gmap, gx, gy);
  587.     SCR_MAP_END;
  588. }
  589.  
  590. void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player)
  591. {
  592.     ASSERT(map);
  593.     ASSERT(player);
  594.  
  595.     FOREACH_SCRIPT(PlayerScript)->OnMapChanged(player);
  596.  
  597.     SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
  598.         itr->second->OnPlayerEnter(map, player);
  599.     SCR_MAP_END;
  600.  
  601.     SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
  602.         itr->second->OnPlayerEnter((InstanceMap*)map, player);
  603.     SCR_MAP_END;
  604.  
  605.     SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
  606.         itr->second->OnPlayerEnter((BattlegroundMap*)map, player);
  607.     SCR_MAP_END;
  608. }
  609.  
  610. void ScriptMgr::OnPlayerLeaveMap(Map* map, Player* player)
  611. {
  612.     ASSERT(map);
  613.     ASSERT(player);
  614.  
  615.     SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
  616.         itr->second->OnPlayerLeave(map, player);
  617.     SCR_MAP_END;
  618.  
  619.     SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
  620.         itr->second->OnPlayerLeave((InstanceMap*)map, player);
  621.     SCR_MAP_END;
  622.  
  623.     SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
  624.         itr->second->OnPlayerLeave((BattlegroundMap*)map, player);
  625.     SCR_MAP_END;
  626. }
  627.  
  628. void ScriptMgr::OnMapUpdate(Map* map, uint32 diff)
  629. {
  630.     ASSERT(map);
  631.  
  632.     SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
  633.         itr->second->OnUpdate(map, diff);
  634.     SCR_MAP_END;
  635.  
  636.     SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
  637.         itr->second->OnUpdate((InstanceMap*)map, diff);
  638.     SCR_MAP_END;
  639.  
  640.     SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
  641.         itr->second->OnUpdate((BattlegroundMap*)map, diff);
  642.     SCR_MAP_END;
  643. }
  644.  
  645. #undef SCR_MAP_BGN
  646. #undef SCR_MAP_END
  647.  
  648. InstanceScript* ScriptMgr::CreateInstanceData(InstanceMap* map)
  649. {
  650.     ASSERT(map);
  651.  
  652.     GET_SCRIPT_RET(InstanceMapScript, map->GetScriptId(), tmpscript, NULL);
  653.     return tmpscript->GetInstanceScript(map);
  654. }
  655.  
  656. bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Item* target)
  657. {
  658.     ASSERT(caster);
  659.     ASSERT(target);
  660.  
  661.     GET_SCRIPT_RET(ItemScript, target->GetScriptId(), tmpscript, false);
  662.     return tmpscript->OnDummyEffect(caster, spellId, effIndex, target);
  663. }
  664.  
  665. bool ScriptMgr::OnQuestAccept(Player* player, Item* item, Quest const* quest)
  666. {
  667.     ASSERT(player);
  668.     ASSERT(item);
  669.     ASSERT(quest);
  670.  
  671.     GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false);
  672.     player->PlayerTalkClass->ClearMenus();
  673.     return tmpscript->OnQuestAccept(player, item, quest);
  674. }
  675.  
  676. bool ScriptMgr::OnItemUse(Player* player, Item* item, SpellCastTargets const& targets)
  677. {
  678.     ASSERT(player);
  679.     ASSERT(item);
  680.  
  681.     GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false);
  682.     return tmpscript->OnUse(player, item, targets);
  683. }
  684.  
  685. bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto)
  686. {
  687.     ASSERT(player);
  688.     ASSERT(proto);
  689.  
  690.     GET_SCRIPT_RET(ItemScript, proto->ScriptId, tmpscript, false);
  691.     return tmpscript->OnExpire(player, proto);
  692. }
  693.  
  694. bool ScriptMgr::OnItemRemove(Player* player, Item* item)
  695. {
  696.     ASSERT(player);
  697.     ASSERT(item);
  698.  
  699.     GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false);
  700.     return tmpscript->OnRemove(player, item);
  701. }
  702.  
  703. bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Creature* target)
  704. {
  705.     ASSERT(caster);
  706.     ASSERT(target);
  707.  
  708.     GET_SCRIPT_RET(CreatureScript, target->GetScriptId(), tmpscript, false);
  709.     return tmpscript->OnDummyEffect(caster, spellId, effIndex, target);
  710. }
  711.  
  712. bool ScriptMgr::OnGossipHello(Player* player, Creature* creature)
  713. {
  714.     ASSERT(player);
  715.     ASSERT(creature);
  716.  
  717.     GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
  718.     player->PlayerTalkClass->ClearMenus();
  719.     return tmpscript->OnGossipHello(player, creature);
  720. }
  721.  
  722. bool ScriptMgr::OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  723. {
  724.     ASSERT(player);
  725.     ASSERT(creature);
  726.  
  727.     GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
  728.     return tmpscript->OnGossipSelect(player, creature, sender, action);
  729. }
  730.  
  731. bool ScriptMgr::OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code)
  732. {
  733.     ASSERT(player);
  734.     ASSERT(creature);
  735.     ASSERT(code);
  736.  
  737.     GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
  738.     return tmpscript->OnGossipSelectCode(player, creature, sender, action, code);
  739. }
  740. // EDITED HERE -----------------------------------------------------------------------------------------------------
  741. void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action)
  742. {
  743.     ASSERT(player);
  744.     ASSERT(item);
  745.  
  746.     FOREACH_SCRIPT(ItemScript)->OnGossipSelect(player, item, sender, action);
  747. }
  748.  
  749. void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code)
  750. {
  751.     ASSERT(player);
  752.     ASSERT(item);
  753.  
  754.     FOREACH_SCRIPT(ItemScript)->OnGossipSelectCode(player, item, sender, action, code);
  755. }
  756. // EDITED HERE -----------------------------------------------------------------------------------------------------
  757.  
  758. bool ScriptMgr::OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
  759. {
  760.     ASSERT(player);
  761.     ASSERT(creature);
  762.     ASSERT(quest);
  763.  
  764.     GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
  765.     player->PlayerTalkClass->ClearMenus();
  766.     return tmpscript->OnQuestAccept(player, creature, quest);
  767. }
  768.  
  769. bool ScriptMgr::OnQuestSelect(Player* player, Creature* creature, Quest const* quest)
  770. {
  771.     ASSERT(player);
  772.     ASSERT(creature);
  773.     ASSERT(quest);
  774.  
  775.     GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
  776.     player->PlayerTalkClass->ClearMenus();
  777.     return tmpscript->OnQuestSelect(player, creature, quest);
  778. }
  779.  
  780. bool ScriptMgr::OnQuestComplete(Player* player, Creature* creature, Quest const* quest)
  781. {
  782.     ASSERT(player);
  783.     ASSERT(creature);
  784.     ASSERT(quest);
  785.  
  786.     GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
  787.     player->PlayerTalkClass->ClearMenus();
  788.     return tmpscript->OnQuestComplete(player, creature, quest);
  789. }
  790.  
  791. bool ScriptMgr::OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt)
  792. {
  793.     ASSERT(player);
  794.     ASSERT(creature);
  795.     ASSERT(quest);
  796.  
  797.     GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
  798.     player->PlayerTalkClass->ClearMenus();
  799.     return tmpscript->OnQuestReward(player, creature, quest, opt);
  800. }
  801.  
  802. uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature)
  803. {
  804.     ASSERT(player);
  805.     ASSERT(creature);
  806.  
  807.     GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS);
  808.     player->PlayerTalkClass->ClearMenus();
  809.     return tmpscript->GetDialogStatus(player, creature);
  810. }
  811.  
  812. CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature)
  813. {
  814.     ASSERT(creature);
  815.  
  816.     GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, NULL);
  817.     return tmpscript->GetAI(creature);
  818. }
  819.  
  820. GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* gameobject)
  821. {
  822.     ASSERT(gameobject);
  823.  
  824.     GET_SCRIPT_RET(GameObjectScript, gameobject->GetScriptId(), tmpscript, NULL);
  825.     return tmpscript->GetAI(gameobject);
  826. }
  827.  
  828. void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff)
  829. {
  830.     ASSERT(creature);
  831.  
  832.     GET_SCRIPT(CreatureScript, creature->GetScriptId(), tmpscript);
  833.     tmpscript->OnUpdate(creature, diff);
  834. }
  835.  
  836. bool ScriptMgr::OnGossipHello(Player* player, GameObject* go)
  837. {
  838.     ASSERT(player);
  839.     ASSERT(go);
  840.  
  841.     GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
  842.     player->PlayerTalkClass->ClearMenus();
  843.     return tmpscript->OnGossipHello(player, go);
  844. }
  845.  
  846. bool ScriptMgr::OnGossipSelect(Player* player, GameObject* go, uint32 sender, uint32 action)
  847. {
  848.     ASSERT(player);
  849.     ASSERT(go);
  850.  
  851.     GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
  852.     return tmpscript->OnGossipSelect(player, go, sender, action);
  853. }
  854.  
  855. bool ScriptMgr::OnGossipSelectCode(Player* player, GameObject* go, uint32 sender, uint32 action, const char* code)
  856. {
  857.     ASSERT(player);
  858.     ASSERT(go);
  859.     ASSERT(code);
  860.  
  861.     GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
  862.     return tmpscript->OnGossipSelectCode(player, go, sender, action, code);
  863. }
  864.  
  865. bool ScriptMgr::OnQuestAccept(Player* player, GameObject* go, Quest const* quest)
  866. {
  867.     ASSERT(player);
  868.     ASSERT(go);
  869.     ASSERT(quest);
  870.  
  871.     GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
  872.     player->PlayerTalkClass->ClearMenus();
  873.     return tmpscript->OnQuestAccept(player, go, quest);
  874. }
  875.  
  876. bool ScriptMgr::OnQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt)
  877. {
  878.     ASSERT(player);
  879.     ASSERT(go);
  880.     ASSERT(quest);
  881.  
  882.     GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
  883.     player->PlayerTalkClass->ClearMenus();
  884.     return tmpscript->OnQuestReward(player, go, quest, opt);
  885. }
  886.  
  887. uint32 ScriptMgr::GetDialogStatus(Player* player, GameObject* go)
  888. {
  889.     ASSERT(player);
  890.     ASSERT(go);
  891.  
  892.     GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS);
  893.     player->PlayerTalkClass->ClearMenus();
  894.     return tmpscript->GetDialogStatus(player, go);
  895. }
  896.  
  897. void ScriptMgr::OnGameObjectDestroyed(GameObject* go, Player* player)
  898. {
  899.     ASSERT(go);
  900.  
  901.     GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
  902.     tmpscript->OnDestroyed(go, player);
  903. }
  904.  
  905. void ScriptMgr::OnGameObjectDamaged(GameObject* go, Player* player)
  906. {
  907.     ASSERT(go);
  908.  
  909.     GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
  910.     tmpscript->OnDamaged(go, player);
  911. }
  912.  
  913. void ScriptMgr::OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit)
  914. {
  915.     ASSERT(go);
  916.  
  917.     GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
  918.     tmpscript->OnLootStateChanged(go, state, unit);
  919. }
  920.  
  921. void ScriptMgr::OnGameObjectStateChanged(GameObject* go, uint32 state)
  922. {
  923.     ASSERT(go);
  924.  
  925.     GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
  926.     tmpscript->OnGameObjectStateChanged(go, state);
  927. }
  928.  
  929. void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff)
  930. {
  931.     ASSERT(go);
  932.  
  933.     GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
  934.     tmpscript->OnUpdate(go, diff);
  935. }
  936.  
  937. bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, GameObject* target)
  938. {
  939.     ASSERT(caster);
  940.     ASSERT(target);
  941.  
  942.     GET_SCRIPT_RET(GameObjectScript, target->GetScriptId(), tmpscript, false);
  943.     return tmpscript->OnDummyEffect(caster, spellId, effIndex, target);
  944. }
  945.  
  946. bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger)
  947. {
  948.     ASSERT(player);
  949.     ASSERT(trigger);
  950.  
  951.     GET_SCRIPT_RET(AreaTriggerScript, sObjectMgr->GetAreaTriggerScriptId(trigger->id), tmpscript, false);
  952.     return tmpscript->OnTrigger(player, trigger);
  953. }
  954.  
  955. Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/)
  956. {
  957.     /// @todo Implement script-side battlegrounds.
  958.     ASSERT(false);
  959.     return NULL;
  960. }
  961.  
  962. OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data)
  963. {
  964.     ASSERT(data);
  965.  
  966.     GET_SCRIPT_RET(OutdoorPvPScript, data->ScriptId, tmpscript, NULL);
  967.     return tmpscript->GetOutdoorPvP();
  968. }
  969.  
  970. std::vector<ChatCommand*> ScriptMgr::GetChatCommands()
  971. {
  972.     std::vector<ChatCommand*> table;
  973.  
  974.     FOR_SCRIPTS_RET(CommandScript, itr, end, table)
  975.         table.push_back(itr->second->GetCommands());
  976.  
  977.     return table;
  978. }
  979.  
  980. void ScriptMgr::OnWeatherChange(Weather* weather, WeatherState state, float grade)
  981. {
  982.     ASSERT(weather);
  983.  
  984.     GET_SCRIPT(WeatherScript, weather->GetScriptId(), tmpscript);
  985.     tmpscript->OnChange(weather, state, grade);
  986. }
  987.  
  988. void ScriptMgr::OnWeatherUpdate(Weather* weather, uint32 diff)
  989. {
  990.     ASSERT(weather);
  991.  
  992.     GET_SCRIPT(WeatherScript, weather->GetScriptId(), tmpscript);
  993.     tmpscript->OnUpdate(weather, diff);
  994. }
  995.  
  996. void ScriptMgr::OnAuctionAdd(AuctionHouseObject* ah, AuctionEntry* entry)
  997. {
  998.     ASSERT(ah);
  999.     ASSERT(entry);
  1000.  
  1001.     FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionAdd(ah, entry);
  1002. }
  1003.  
  1004. void ScriptMgr::OnAuctionRemove(AuctionHouseObject* ah, AuctionEntry* entry)
  1005. {
  1006.     ASSERT(ah);
  1007.     ASSERT(entry);
  1008.  
  1009.     FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionRemove(ah, entry);
  1010. }
  1011.  
  1012. void ScriptMgr::OnAuctionSuccessful(AuctionHouseObject* ah, AuctionEntry* entry)
  1013. {
  1014.     ASSERT(ah);
  1015.     ASSERT(entry);
  1016.  
  1017.     FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionSuccessful(ah, entry);
  1018. }
  1019.  
  1020. void ScriptMgr::OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry)
  1021. {
  1022.     ASSERT(ah);
  1023.     ASSERT(entry);
  1024.  
  1025.     FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionExpire(ah, entry);
  1026. }
  1027.  
  1028. bool ScriptMgr::OnConditionCheck(Condition* condition, ConditionSourceInfo& sourceInfo)
  1029. {
  1030.     ASSERT(condition);
  1031.  
  1032.     GET_SCRIPT_RET(ConditionScript, condition->ScriptId, tmpscript, true);
  1033.     return tmpscript->OnConditionCheck(condition, sourceInfo);
  1034. }
  1035.  
  1036. void ScriptMgr::OnInstall(Vehicle* veh)
  1037. {
  1038.     ASSERT(veh);
  1039.     ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
  1040.  
  1041.     GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
  1042.     tmpscript->OnInstall(veh);
  1043. }
  1044.  
  1045. void ScriptMgr::OnUninstall(Vehicle* veh)
  1046. {
  1047.     ASSERT(veh);
  1048.     ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
  1049.  
  1050.     GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
  1051.     tmpscript->OnUninstall(veh);
  1052. }
  1053.  
  1054. void ScriptMgr::OnReset(Vehicle* veh)
  1055. {
  1056.     ASSERT(veh);
  1057.     ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
  1058.  
  1059.     GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
  1060.     tmpscript->OnReset(veh);
  1061. }
  1062.  
  1063. void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory)
  1064. {
  1065.     ASSERT(veh);
  1066.     ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
  1067.     ASSERT(accessory);
  1068.  
  1069.     GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
  1070.     tmpscript->OnInstallAccessory(veh, accessory);
  1071. }
  1072.  
  1073. void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId)
  1074. {
  1075.     ASSERT(veh);
  1076.     ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
  1077.     ASSERT(passenger);
  1078.  
  1079.     GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
  1080.     tmpscript->OnAddPassenger(veh, passenger, seatId);
  1081. }
  1082.  
  1083. void ScriptMgr::OnRemovePassenger(Vehicle* veh, Unit* passenger)
  1084. {
  1085.     ASSERT(veh);
  1086.     ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
  1087.     ASSERT(passenger);
  1088.  
  1089.     GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
  1090.     tmpscript->OnRemovePassenger(veh, passenger);
  1091. }
  1092.  
  1093. void ScriptMgr::OnDynamicObjectUpdate(DynamicObject* dynobj, uint32 diff)
  1094. {
  1095.     ASSERT(dynobj);
  1096.  
  1097.     FOR_SCRIPTS(DynamicObjectScript, itr, end)
  1098.         itr->second->OnUpdate(dynobj, diff);
  1099. }
  1100.  
  1101. void ScriptMgr::OnAddPassenger(Transport* transport, Player* player)
  1102. {
  1103.     ASSERT(transport);
  1104.     ASSERT(player);
  1105.  
  1106.     GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript);
  1107.     tmpscript->OnAddPassenger(transport, player);
  1108. }
  1109.  
  1110. void ScriptMgr::OnAddCreaturePassenger(Transport* transport, Creature* creature)
  1111. {
  1112.     ASSERT(transport);
  1113.     ASSERT(creature);
  1114.  
  1115.     GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript);
  1116.     tmpscript->OnAddCreaturePassenger(transport, creature);
  1117. }
  1118.  
  1119. void ScriptMgr::OnRemovePassenger(Transport* transport, Player* player)
  1120. {
  1121.     ASSERT(transport);
  1122.     ASSERT(player);
  1123.  
  1124.     GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript);
  1125.     tmpscript->OnRemovePassenger(transport, player);
  1126. }
  1127.  
  1128. void ScriptMgr::OnTransportUpdate(Transport* transport, uint32 diff)
  1129. {
  1130.     ASSERT(transport);
  1131.  
  1132.     GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript);
  1133.     tmpscript->OnUpdate(transport, diff);
  1134. }
  1135.  
  1136. void ScriptMgr::OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z)
  1137. {
  1138.     GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript);
  1139.     tmpscript->OnRelocate(transport, waypointId, mapId, x, y, z);
  1140. }
  1141.  
  1142. void ScriptMgr::OnStartup()
  1143. {
  1144.     FOREACH_SCRIPT(WorldScript)->OnStartup();
  1145. }
  1146.  
  1147. void ScriptMgr::OnShutdown()
  1148. {
  1149.     FOREACH_SCRIPT(WorldScript)->OnShutdown();
  1150. }
  1151.  
  1152. bool ScriptMgr::OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target)
  1153. {
  1154.     ASSERT(source);
  1155.     // target can be NULL.
  1156.  
  1157.     GET_SCRIPT_RET(AchievementCriteriaScript, scriptId, tmpscript, false);
  1158.     return tmpscript->OnCheck(source, target);
  1159. }
  1160.  
  1161. // Player
  1162. void ScriptMgr::OnPVPKill(Player* killer, Player* killed)
  1163. {
  1164.     FOREACH_SCRIPT(PlayerScript)->OnPVPKill(killer, killed);
  1165. }
  1166.  
  1167. void ScriptMgr::OnCreatureKill(Player* killer, Creature* killed)
  1168. {
  1169.     FOREACH_SCRIPT(PlayerScript)->OnCreatureKill(killer, killed);
  1170. }
  1171.  
  1172. void ScriptMgr::OnPlayerKilledByCreature(Creature* killer, Player* killed)
  1173. {
  1174.     FOREACH_SCRIPT(PlayerScript)->OnPlayerKilledByCreature(killer, killed);
  1175. }
  1176.  
  1177. void ScriptMgr::OnPlayerLevelChanged(Player* player, uint8 oldLevel)
  1178. {
  1179.     FOREACH_SCRIPT(PlayerScript)->OnLevelChanged(player, oldLevel);
  1180. }
  1181.  
  1182. void ScriptMgr::OnPlayerFreeTalentPointsChanged(Player* player, uint32 points)
  1183. {
  1184.     FOREACH_SCRIPT(PlayerScript)->OnFreeTalentPointsChanged(player, points);
  1185. }
  1186.  
  1187. void ScriptMgr::OnPlayerTalentsReset(Player* player, bool noCost)
  1188. {
  1189.     FOREACH_SCRIPT(PlayerScript)->OnTalentsReset(player, noCost);
  1190. }
  1191.  
  1192. void ScriptMgr::OnPlayerMoneyChanged(Player* player, int32& amount)
  1193. {
  1194.     FOREACH_SCRIPT(PlayerScript)->OnMoneyChanged(player, amount);
  1195. }
  1196.  
  1197. void ScriptMgr::OnGivePlayerXP(Player* player, uint32& amount, Unit* victim)
  1198. {
  1199.     FOREACH_SCRIPT(PlayerScript)->OnGiveXP(player, amount, victim);
  1200. }
  1201.  
  1202. void ScriptMgr::OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental)
  1203. {
  1204.     FOREACH_SCRIPT(PlayerScript)->OnReputationChange(player, factionID, standing, incremental);
  1205. }
  1206.  
  1207. void ScriptMgr::OnPlayerDuelRequest(Player* target, Player* challenger)
  1208. {
  1209.     FOREACH_SCRIPT(PlayerScript)->OnDuelRequest(target, challenger);
  1210. }
  1211.  
  1212. void ScriptMgr::OnPlayerDuelStart(Player* player1, Player* player2)
  1213. {
  1214.     FOREACH_SCRIPT(PlayerScript)->OnDuelStart(player1, player2);
  1215. }
  1216.  
  1217. void ScriptMgr::OnPlayerDuelEnd(Player* winner, Player* loser, DuelCompleteType type)
  1218. {
  1219.     FOREACH_SCRIPT(PlayerScript)->OnDuelEnd(winner, loser, type);
  1220. }
  1221.  
  1222. void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg)
  1223. {
  1224.     FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg);
  1225. }
  1226.  
  1227. void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver)
  1228. {
  1229.     FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, receiver);
  1230. }
  1231.  
  1232. void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group)
  1233. {
  1234.     FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, group);
  1235. }
  1236.  
  1237. void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild)
  1238. {
  1239.     FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, guild);
  1240. }
  1241.  
  1242. void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel)
  1243. {
  1244.     FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, channel);
  1245. }
  1246.  
  1247. void ScriptMgr::OnPlayerEmote(Player* player, uint32 emote)
  1248. {
  1249.     FOREACH_SCRIPT(PlayerScript)->OnEmote(player, emote);
  1250. }
  1251.  
  1252. void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, uint64 guid)
  1253. {
  1254.     FOREACH_SCRIPT(PlayerScript)->OnTextEmote(player, textEmote, emoteNum, guid);
  1255. }
  1256.  
  1257. void ScriptMgr::OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck)
  1258. {
  1259.     FOREACH_SCRIPT(PlayerScript)->OnSpellCast(player, spell, skipCheck);
  1260. }
  1261.  
  1262. void ScriptMgr::OnPlayerLogin(Player* player)
  1263. {
  1264.     FOREACH_SCRIPT(PlayerScript)->OnLogin(player);
  1265. }
  1266.  
  1267. void ScriptMgr::OnPlayerLogout(Player* player)
  1268. {
  1269.     FOREACH_SCRIPT(PlayerScript)->OnLogout(player);
  1270. }
  1271.  
  1272. void ScriptMgr::OnPlayerCreate(Player* player)
  1273. {
  1274.     FOREACH_SCRIPT(PlayerScript)->OnCreate(player);
  1275. }
  1276.  
  1277. void ScriptMgr::OnPlayerDelete(uint64 guid)
  1278. {
  1279.     FOREACH_SCRIPT(PlayerScript)->OnDelete(guid);
  1280. }
  1281.  
  1282. void ScriptMgr::OnPlayerSave(Player* player)
  1283. {
  1284.     FOREACH_SCRIPT(PlayerScript)->OnSave(player);
  1285. }
  1286.  
  1287. void ScriptMgr::OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent)
  1288. {
  1289.     FOREACH_SCRIPT(PlayerScript)->OnBindToInstance(player, difficulty, mapid, permanent);
  1290. }
  1291.  
  1292. void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea)
  1293. {
  1294.     FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea);
  1295. }
  1296.  
  1297. // EDITED HERE -----------------------------------------------------------------------------------------------------
  1298. void ScriptMgr::OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action)
  1299. {
  1300.     ASSERT(player);
  1301.  
  1302.     FOREACH_SCRIPT(PlayerScript)->OnGossipSelect(player, menu_id, sender, action);
  1303. }
  1304.  
  1305. void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code)
  1306. {
  1307.     ASSERT(player);
  1308.  
  1309.     FOREACH_SCRIPT(PlayerScript)->OnGossipSelectCode(player, menu_id, sender, action, code);
  1310. }
  1311. // EDITED HERE -----------------------------------------------------------------------------------------------------
  1312.  
  1313. // Guild
  1314. void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank)
  1315. {
  1316.     FOREACH_SCRIPT(GuildScript)->OnAddMember(guild, player, plRank);
  1317. }
  1318.  
  1319. void ScriptMgr::OnGuildRemoveMember(Guild* guild, Player* player, bool isDisbanding, bool isKicked)
  1320. {
  1321.     FOREACH_SCRIPT(GuildScript)->OnRemoveMember(guild, player, isDisbanding, isKicked);
  1322. }
  1323.  
  1324. void ScriptMgr::OnGuildMOTDChanged(Guild* guild, const std::string& newMotd)
  1325. {
  1326.     FOREACH_SCRIPT(GuildScript)->OnMOTDChanged(guild, newMotd);
  1327. }
  1328.  
  1329. void ScriptMgr::OnGuildInfoChanged(Guild* guild, const std::string& newInfo)
  1330. {
  1331.     FOREACH_SCRIPT(GuildScript)->OnInfoChanged(guild, newInfo);
  1332. }
  1333.  
  1334. void ScriptMgr::OnGuildCreate(Guild* guild, Player* leader, const std::string& name)
  1335. {
  1336.     FOREACH_SCRIPT(GuildScript)->OnCreate(guild, leader, name);
  1337. }
  1338.  
  1339. void ScriptMgr::OnGuildDisband(Guild* guild)
  1340. {
  1341.     FOREACH_SCRIPT(GuildScript)->OnDisband(guild);
  1342. }
  1343.  
  1344. void ScriptMgr::OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32 &amount, bool isRepair)
  1345. {
  1346.     FOREACH_SCRIPT(GuildScript)->OnMemberWitdrawMoney(guild, player, amount, isRepair);
  1347. }
  1348.  
  1349. void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32 &amount)
  1350. {
  1351.     FOREACH_SCRIPT(GuildScript)->OnMemberDepositMoney(guild, player, amount);
  1352. }
  1353.  
  1354. void ScriptMgr::OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
  1355.             bool isDestBank, uint8 destContainer, uint8 destSlotId)
  1356. {
  1357.     FOREACH_SCRIPT(GuildScript)->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId);
  1358. }
  1359.  
  1360. void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank)
  1361. {
  1362.     FOREACH_SCRIPT(GuildScript)->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank);
  1363. }
  1364.  
  1365. void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId)
  1366. {
  1367.     FOREACH_SCRIPT(GuildScript)->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId);
  1368. }
  1369.  
  1370. // Group
  1371. void ScriptMgr::OnGroupAddMember(Group* group, uint64 guid)
  1372. {
  1373.     ASSERT(group);
  1374.     FOREACH_SCRIPT(GroupScript)->OnAddMember(group, guid);
  1375. }
  1376.  
  1377. void ScriptMgr::OnGroupInviteMember(Group* group, uint64 guid)
  1378. {
  1379.     ASSERT(group);
  1380.     FOREACH_SCRIPT(GroupScript)->OnInviteMember(group, guid);
  1381. }
  1382.  
  1383. void ScriptMgr::OnGroupRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, const char* reason)
  1384. {
  1385.     ASSERT(group);
  1386.     FOREACH_SCRIPT(GroupScript)->OnRemoveMember(group, guid, method, kicker, reason);
  1387. }
  1388.  
  1389. void ScriptMgr::OnGroupChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid)
  1390. {
  1391.     ASSERT(group);
  1392.     FOREACH_SCRIPT(GroupScript)->OnChangeLeader(group, newLeaderGuid, oldLeaderGuid);
  1393. }
  1394.  
  1395. void ScriptMgr::OnGroupDisband(Group* group)
  1396. {
  1397.     ASSERT(group);
  1398.     FOREACH_SCRIPT(GroupScript)->OnDisband(group);
  1399. }
  1400.  
  1401. // Unit
  1402. void ScriptMgr::OnHeal(Unit* healer, Unit* reciever, uint32& gain)
  1403. {
  1404.     FOREACH_SCRIPT(UnitScript)->OnHeal(healer, reciever, gain);
  1405. }
  1406.  
  1407. void ScriptMgr::OnDamage(Unit* attacker, Unit* victim, uint32& damage)
  1408. {
  1409.     FOREACH_SCRIPT(UnitScript)->OnDamage(attacker, victim, damage);
  1410. }
  1411.  
  1412. void ScriptMgr::ModifyPeriodicDamageAurasTick(Unit* target, Unit* attacker, uint32& damage)
  1413. {
  1414.     FOREACH_SCRIPT(UnitScript)->ModifyPeriodicDamageAurasTick(target, attacker, damage);
  1415. }
  1416.  
  1417. void ScriptMgr::ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage)
  1418. {
  1419.     FOREACH_SCRIPT(UnitScript)->ModifyMeleeDamage(target, attacker, damage);
  1420. }
  1421.  
  1422. void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage)
  1423. {
  1424.     FOREACH_SCRIPT(UnitScript)->ModifySpellDamageTaken(target, attacker, damage);
  1425. }
  1426.  
  1427. SpellScriptLoader::SpellScriptLoader(const char* name)
  1428.     : ScriptObject(name)
  1429. {
  1430.     ScriptRegistry<SpellScriptLoader>::AddScript(this);
  1431. }
  1432.  
  1433. ServerScript::ServerScript(const char* name)
  1434.     : ScriptObject(name)
  1435. {
  1436.     ScriptRegistry<ServerScript>::AddScript(this);
  1437. }
  1438.  
  1439. WorldScript::WorldScript(const char* name)
  1440.     : ScriptObject(name)
  1441. {
  1442.     ScriptRegistry<WorldScript>::AddScript(this);
  1443. }
  1444.  
  1445. FormulaScript::FormulaScript(const char* name)
  1446.     : ScriptObject(name)
  1447. {
  1448.     ScriptRegistry<FormulaScript>::AddScript(this);
  1449. }
  1450.  
  1451. UnitScript::UnitScript(const char* name, bool addToScripts)
  1452.     : ScriptObject(name)
  1453. {
  1454.     if (addToScripts)
  1455.         ScriptRegistry<UnitScript>::AddScript(this);
  1456. }
  1457.  
  1458. WorldMapScript::WorldMapScript(const char* name, uint32 mapId)
  1459.     : ScriptObject(name), MapScript<Map>(mapId)
  1460. {
  1461.     if (GetEntry() && !GetEntry()->IsWorldMap())
  1462.         TC_LOG_ERROR("scripts", "WorldMapScript for map %u is invalid.", mapId);
  1463.  
  1464.     ScriptRegistry<WorldMapScript>::AddScript(this);
  1465. }
  1466.  
  1467. InstanceMapScript::InstanceMapScript(const char* name, uint32 mapId)
  1468.     : ScriptObject(name), MapScript<InstanceMap>(mapId)
  1469. {
  1470.     if (GetEntry() && !GetEntry()->IsDungeon())
  1471.         TC_LOG_ERROR("scripts", "InstanceMapScript for map %u is invalid.", mapId);
  1472.  
  1473.     ScriptRegistry<InstanceMapScript>::AddScript(this);
  1474. }
  1475.  
  1476. BattlegroundMapScript::BattlegroundMapScript(const char* name, uint32 mapId)
  1477.     : ScriptObject(name), MapScript<BattlegroundMap>(mapId)
  1478. {
  1479.     if (GetEntry() && !GetEntry()->IsBattleground())
  1480.         TC_LOG_ERROR("scripts", "BattlegroundMapScript for map %u is invalid.", mapId);
  1481.  
  1482.     ScriptRegistry<BattlegroundMapScript>::AddScript(this);
  1483. }
  1484.  
  1485. ItemScript::ItemScript(const char* name)
  1486.     : ScriptObject(name)
  1487. {
  1488.     ScriptRegistry<ItemScript>::AddScript(this);
  1489. }
  1490.  
  1491. CreatureScript::CreatureScript(const char* name)
  1492.     : UnitScript(name, false)
  1493. {
  1494.     ScriptRegistry<CreatureScript>::AddScript(this);
  1495. }
  1496.  
  1497. GameObjectScript::GameObjectScript(const char* name)
  1498.     : ScriptObject(name)
  1499. {
  1500.     ScriptRegistry<GameObjectScript>::AddScript(this);
  1501. }
  1502.  
  1503. AreaTriggerScript::AreaTriggerScript(const char* name)
  1504.     : ScriptObject(name)
  1505. {
  1506.     ScriptRegistry<AreaTriggerScript>::AddScript(this);
  1507. }
  1508.  
  1509. BattlegroundScript::BattlegroundScript(const char* name)
  1510.     : ScriptObject(name)
  1511. {
  1512.     ScriptRegistry<BattlegroundScript>::AddScript(this);
  1513. }
  1514.  
  1515. OutdoorPvPScript::OutdoorPvPScript(const char* name)
  1516.     : ScriptObject(name)
  1517. {
  1518.     ScriptRegistry<OutdoorPvPScript>::AddScript(this);
  1519. }
  1520.  
  1521. CommandScript::CommandScript(const char* name)
  1522.     : ScriptObject(name)
  1523. {
  1524.     ScriptRegistry<CommandScript>::AddScript(this);
  1525. }
  1526.  
  1527. WeatherScript::WeatherScript(const char* name)
  1528.     : ScriptObject(name)
  1529. {
  1530.     ScriptRegistry<WeatherScript>::AddScript(this);
  1531. }
  1532.  
  1533. AuctionHouseScript::AuctionHouseScript(const char* name)
  1534.     : ScriptObject(name)
  1535. {
  1536.     ScriptRegistry<AuctionHouseScript>::AddScript(this);
  1537. }
  1538.  
  1539. ConditionScript::ConditionScript(const char* name)
  1540.     : ScriptObject(name)
  1541. {
  1542.     ScriptRegistry<ConditionScript>::AddScript(this);
  1543. }
  1544.  
  1545. VehicleScript::VehicleScript(const char* name)
  1546.     : ScriptObject(name)
  1547. {
  1548.     ScriptRegistry<VehicleScript>::AddScript(this);
  1549. }
  1550.  
  1551. DynamicObjectScript::DynamicObjectScript(const char* name)
  1552.     : ScriptObject(name)
  1553. {
  1554.     ScriptRegistry<DynamicObjectScript>::AddScript(this);
  1555. }
  1556.  
  1557. TransportScript::TransportScript(const char* name)
  1558.     : ScriptObject(name)
  1559. {
  1560.     ScriptRegistry<TransportScript>::AddScript(this);
  1561. }
  1562.  
  1563. AchievementCriteriaScript::AchievementCriteriaScript(const char* name)
  1564.     : ScriptObject(name)
  1565. {
  1566.     ScriptRegistry<AchievementCriteriaScript>::AddScript(this);
  1567. }
  1568.  
  1569. PlayerScript::PlayerScript(const char* name)
  1570.     : UnitScript(name, false)
  1571. {
  1572.     ScriptRegistry<PlayerScript>::AddScript(this);
  1573. }
  1574.  
  1575. GuildScript::GuildScript(const char* name)
  1576.     : ScriptObject(name)
  1577. {
  1578.     ScriptRegistry<GuildScript>::AddScript(this);
  1579. }
  1580.  
  1581. GroupScript::GroupScript(const char* name)
  1582.     : ScriptObject(name)
  1583. {
  1584.     ScriptRegistry<GroupScript>::AddScript(this);
  1585. }
  1586.  
  1587. // Instantiate static members of ScriptRegistry.
  1588. template<class TScript> std::map<uint32, TScript*> ScriptRegistry<TScript>::ScriptPointerList;
  1589. template<class TScript> uint32 ScriptRegistry<TScript>::_scriptIdCounter = 0;
  1590.  
  1591. // Specialize for each script type class like so:
  1592. template class ScriptRegistry<SpellScriptLoader>;
  1593. template class ScriptRegistry<ServerScript>;
  1594. template class ScriptRegistry<WorldScript>;
  1595. template class ScriptRegistry<FormulaScript>;
  1596. template class ScriptRegistry<WorldMapScript>;
  1597. template class ScriptRegistry<InstanceMapScript>;
  1598. template class ScriptRegistry<BattlegroundMapScript>;
  1599. template class ScriptRegistry<ItemScript>;
  1600. template class ScriptRegistry<CreatureScript>;
  1601. template class ScriptRegistry<GameObjectScript>;
  1602. template class ScriptRegistry<AreaTriggerScript>;
  1603. template class ScriptRegistry<BattlegroundScript>;
  1604. template class ScriptRegistry<OutdoorPvPScript>;
  1605. template class ScriptRegistry<CommandScript>;
  1606. template class ScriptRegistry<WeatherScript>;
  1607. template class ScriptRegistry<AuctionHouseScript>;
  1608. template class ScriptRegistry<ConditionScript>;
  1609. template class ScriptRegistry<VehicleScript>;
  1610. template class ScriptRegistry<DynamicObjectScript>;
  1611. template class ScriptRegistry<TransportScript>;
  1612. template class ScriptRegistry<AchievementCriteriaScript>;
  1613. template class ScriptRegistry<PlayerScript>;
  1614. template class ScriptRegistry<GuildScript>;
  1615. template class ScriptRegistry<GroupScript>;
  1616. template class ScriptRegistry<UnitScript>;
  1617.  
  1618. // Undefine utility macros.
  1619. #undef GET_SCRIPT_RET
  1620. #undef GET_SCRIPT
  1621. #undef FOREACH_SCRIPT
  1622. #undef FOR_SCRIPTS_RET
  1623. #undef FOR_SCRIPTS
  1624. #undef SCR_REG_LST
  1625. #undef SCR_REG_ITR
  1626. #undef SCR_REG_MAP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement