diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Scripting/ScriptMgr.cpp | 181 | ||||
-rwxr-xr-x | src/server/game/Scripting/ScriptMgr.h | 109 |
2 files changed, 170 insertions, 120 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 6f170225cde..d0b56ee1ddf 100755 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -32,94 +32,97 @@ template<class TScript> class ScriptRegistry { - // Counter used for code-only scripts. - static uint32 _scriptIdCounter; + public: -public: - typedef std::map<uint32, TScript*> ScriptMap; - typedef typename ScriptMap::iterator ScriptMapIterator; + typedef std::map<uint32, TScript*> ScriptMap; + typedef typename ScriptMap::iterator ScriptMapIterator; - // The actual list of scripts. This will be accessed concurrently, so it must not be modified - // after server startup. - static ScriptMap ScriptPointerList; + // The actual list of scripts. This will be accessed concurrently, so it must not be modified + // after server startup. + static ScriptMap ScriptPointerList; - static void AddScript(TScript* const script) - { - ASSERT(script); - - // See if the script is using the same memory as another script. If this happens, it means that - // someone forgot to allocate new memory for a script. - for (ScriptMapIterator it = ScriptPointerList.begin(); it != ScriptPointerList.end(); ++it) + static void AddScript(TScript* const script) { - if (it->second == script) + ASSERT(script); + + // See if the script is using the same memory as another script. If this happens, it means that + // someone forgot to allocate new memory for a script. + for (ScriptMapIterator it = ScriptPointerList.begin(); it != ScriptPointerList.end(); ++it) { - sLog->outError("Script '%s' has same memory pointer as '%s'.", - script->GetName().c_str(), it->second->GetName().c_str()); + if (it->second == script) + { + sLog->outError("Script '%s' has same memory pointer as '%s'.", + script->GetName().c_str(), it->second->GetName().c_str()); - return; + return; + } } - } - if (script->IsDatabaseBound()) - { - // Get an ID for the script. An ID only exists if it's a script that is assigned in the database - // through a script name (or similar). - uint32 id = sObjectMgr->GetScriptId(script->GetName().c_str()); - if (id) + if (script->IsDatabaseBound()) { - // Try to find an existing script. - bool existing = false; - for (ScriptMapIterator it = ScriptPointerList.begin(); it != ScriptPointerList.end(); ++it) + // Get an ID for the script. An ID only exists if it's a script that is assigned in the database + // through a script name (or similar). + uint32 id = sObjectMgr->GetScriptId(script->GetName().c_str()); + if (id) { - // If the script names match... - if (it->second->GetName() == script->GetName()) + // Try to find an existing script. + bool existing = false; + for (ScriptMapIterator it = ScriptPointerList.begin(); it != ScriptPointerList.end(); ++it) { - // ... It exists. - existing = true; - break; + // If the script names match... + if (it->second->GetName() == script->GetName()) + { + // ... It exists. + existing = true; + break; + } } - } - // If the script isn't assigned -> assign it! - if (!existing) - { - ScriptPointerList[id] = script; - sScriptMgr->IncrementScriptCount(); + // If the script isn't assigned -> assign it! + if (!existing) + { + ScriptPointerList[id] = script; + sScriptMgr->IncrementScriptCount(); + } + else + { + // If the script is already assigned -> delete it! + sLog->outError("Script '%s' already assigned with the same script name, so the script can't work.", + script->GetName().c_str()); + + ASSERT(false); // Error that should be fixed ASAP. + } } else { - // If the script is already assigned -> delete it! - sLog->outError("Script '%s' already assigned with the same script name, so the script can't work.", - script->GetName().c_str()); - - ASSERT(false); // Error that should be fixed ASAP. + // The script uses a script name from database, but isn't assigned to anything. + if (script->GetName().find("example") == std::string::npos && script->GetName().find("Smart") == std::string::npos) + sLog->outErrorDb("Script named '%s' does not have a script name assigned in database.", + script->GetName().c_str()); } } else { - // The script uses a script name from database, but isn't assigned to anything. - if (script->GetName().find("example") == std::string::npos && script->GetName().find("Smart") == std::string::npos) - sLog->outErrorDb("Script named '%s' does not have a script name assigned in database.", - script->GetName().c_str()); + // We're dealing with a code-only script; just add it. + ScriptPointerList[_scriptIdCounter++] = script; + sScriptMgr->IncrementScriptCount(); } } - else + + // Gets a script by its ID (assigned by ObjectMgr). + static TScript* GetScriptById(uint32 id) { - // We're dealing with a code-only script; just add it. - ScriptPointerList[_scriptIdCounter++] = script; - sScriptMgr->IncrementScriptCount(); + ScriptMapIterator it = ScriptPointerList.find(id); + if (it != ScriptPointerList.end()) + return it->second; + + return NULL; } - } - // Gets a script by its ID (assigned by ObjectMgr). - static TScript* GetScriptById(uint32 id) - { - ScriptMapIterator it = ScriptPointerList.find(id); - if (it != ScriptPointerList.end()) - return it->second; + private: - return NULL; - } + // Counter used for code-only scripts. + static uint32 _scriptIdCounter; }; // Utility macros to refer to the script registry. @@ -316,29 +319,29 @@ void ScriptMgr::FillSpellSummary() SpellSummary[i].Targets = 0; pTempSpell = sSpellMgr->GetSpellInfo(i); - //This spell doesn't exist + // This spell doesn't exist. if (!pTempSpell) continue; for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j) { - //Spell targets self + // Spell targets self. if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER) SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1); - //Spell targets a single enemy + // Spell targets a single enemy. if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DST_TARGET_ENEMY) SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1); - //Spell targets AoE at enemy + // Spell targets AoE at enemy. if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_AREA_ENEMY_SRC || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_AREA_ENEMY_DST || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY) SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1); - //Spell targets an enemy + // Spell targets an enemy. if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DST_TARGET_ENEMY || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_AREA_ENEMY_SRC || @@ -347,19 +350,19 @@ void ScriptMgr::FillSpellSummary() pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY) SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1); - //Spell targets a single friend(or self) + // Spell targets a single friend (or self). if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY) SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1); - //Spell targets aoe friends + // Spell targets AoE friends. if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_PARTY_CASTER || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY_PARTY || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER) SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1); - //Spell targets any friend(or self) + // Spell targets any friend (or self). if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY || pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY || @@ -368,30 +371,30 @@ void ScriptMgr::FillSpellSummary() pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER) SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1); - //Make sure that this spell includes a damage effect + // Make sure that this spell includes a damage effect. if (pTempSpell->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE || pTempSpell->Effects[j].Effect == SPELL_EFFECT_INSTAKILL || pTempSpell->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE || pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH) SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE-1); - //Make sure that this spell includes a healing effect (or an apply aura with a periodic heal) + // Make sure that this spell includes a healing effect (or an apply aura with a periodic heal). if (pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL || pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL_MAX_HEALTH || pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL_MECHANICAL || (pTempSpell->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && pTempSpell->Effects[j].ApplyAuraName == 8)) SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING-1); - //Make sure that this spell applies an aura + // Make sure that this spell applies an aura. if (pTempSpell->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA) SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA-1); } } } -void ScriptMgr::CreateSpellScripts(uint32 spell_id, std::list<SpellScript *> & script_vector) +void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector) { - SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spell_id); + SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); for (SpellScriptsMap::iterator itr = bounds.first; itr != bounds.second; ++itr) { @@ -404,15 +407,15 @@ void ScriptMgr::CreateSpellScripts(uint32 spell_id, std::list<SpellScript *> & s if (!script) continue; - script->_Init(&tmpscript->GetName(), spell_id); + script->_Init(&tmpscript->GetName(), spellId); - script_vector.push_back(script); + scriptVector.push_back(script); } } -void ScriptMgr::CreateAuraScripts(uint32 spell_id, std::list<AuraScript *> & script_vector) +void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector) { - SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spell_id); + SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); for (SpellScriptsMap::iterator itr = bounds.first; itr != bounds.second; ++itr) { @@ -425,16 +428,16 @@ void ScriptMgr::CreateAuraScripts(uint32 spell_id, std::list<AuraScript *> & scr if (!script) continue; - script->_Init(&tmpscript->GetName(), spell_id); + script->_Init(&tmpscript->GetName(), spellId); - script_vector.push_back(script); + scriptVector.push_back(script); } } -void ScriptMgr::CreateSpellScriptLoaders(uint32 spell_id, std::vector<std::pair<SpellScriptLoader *, SpellScriptsMap::iterator> > & script_vector) +void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector<std::pair<SpellScriptLoader*, SpellScriptsMap::iterator> >& scriptVector) { - SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spell_id); - script_vector.reserve(std::distance(bounds.first, bounds.second)); + SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); + scriptVector.reserve(std::distance(bounds.first, bounds.second)); for (SpellScriptsMap::iterator itr = bounds.first; itr != bounds.second; ++itr) { @@ -442,7 +445,7 @@ void ScriptMgr::CreateSpellScriptLoaders(uint32 spell_id, std::vector<std::pair< if (!tmpscript) continue; - script_vector.push_back(std::make_pair(tmpscript, itr)); + scriptVector.push_back(std::make_pair(tmpscript, itr)); } } @@ -1195,9 +1198,9 @@ void ScriptMgr::OnPlayerFreeTalentPointsChanged(Player* player, uint32 points) FOREACH_SCRIPT(PlayerScript)->OnFreeTalentPointsChanged(player, points); } -void ScriptMgr::OnPlayerTalentsReset(Player* player, bool no_cost) +void ScriptMgr::OnPlayerTalentsReset(Player* player, bool noCost) { - FOREACH_SCRIPT(PlayerScript)->OnTalentsReset(player, no_cost); + FOREACH_SCRIPT(PlayerScript)->OnTalentsReset(player, noCost); } void ScriptMgr::OnPlayerMoneyChanged(Player* player, int32& amount) @@ -1260,9 +1263,9 @@ void ScriptMgr::OnPlayerEmote(Player* player, uint32 emote) FOREACH_SCRIPT(PlayerScript)->OnEmote(player, emote); } -void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 text_emote, uint32 emoteNum, uint64 guid) +void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, uint64 guid) { - FOREACH_SCRIPT(PlayerScript)->OnTextEmote(player, text_emote, emoteNum, guid); + FOREACH_SCRIPT(PlayerScript)->OnTextEmote(player, textEmote, emoteNum, guid); } void ScriptMgr::OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck) diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 9372a7e71c2..75325b5319b 100755 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -199,9 +199,10 @@ class SpellScriptLoader : public ScriptObject bool IsDatabaseBound() const { return true; } // Should return a fully valid SpellScript pointer. - virtual SpellScript* GetSpellScript() const { return NULL; }; + virtual SpellScript* GetSpellScript() const { return NULL; } + // Should return a fully valid AuraScript pointer. - virtual AuraScript* GetAuraScript() const { return NULL; }; + virtual AuraScript* GetAuraScript() const { return NULL; } }; class ServerScript : public ScriptObject @@ -464,9 +465,10 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject> // Called when the dialog status between a player and the gameobject is requested. virtual uint32 GetDialogStatus(Player* /*player*/, GameObject* /*go*/) { return 100; } - // Called when the gameobject is destroyed (destructible buildings only). + // Called when the game object is destroyed (destructible buildings only). virtual void OnDestroyed(GameObject* /*go*/, Player* /*player*/) { } - // Called when the gameobject is damaged (destructible buildings only). + + // Called when the game object is damaged (destructible buildings only). virtual void OnDamaged(GameObject* /*go*/, Player* /*player*/) { } }; @@ -668,7 +670,7 @@ class PlayerScript : public ScriptObject virtual void OnFreeTalentPointsChanged(Player* /*player*/, uint32 /*points*/) { } // Called when a player's talent points are reset (right before the reset is done) - virtual void OnTalentsReset(Player* /*player*/, bool /*no_cost*/) { } + virtual void OnTalentsReset(Player* /*player*/, bool /*noCost*/) { } // Called when a player's money is modified (before the modification is done) virtual void OnMoneyChanged(Player* /*player*/, int32& /*amount*/) { } @@ -677,7 +679,7 @@ class PlayerScript : public ScriptObject virtual void OnGiveXP(Player* /*player*/, uint32& /*amount*/, Unit* /*victim*/) { } // Called when a player's reputation changes (before it is actually changed) - virtual void OnReputationChange(Player* /*player*/, uint32 /*factionID*/, int32& /*standing*/, bool /*incremental*/) { } + virtual void OnReputationChange(Player* /*player*/, uint32 /*factionId*/, int32& /*standing*/, bool /*incremental*/) { } // Called when a duel is requested virtual void OnDuelRequest(Player* /*target*/, Player* /*challenger*/) { } @@ -688,30 +690,39 @@ class PlayerScript : public ScriptObject // Called when a duel ends virtual void OnDuelEnd(Player* /*winner*/, Player* /*loser*/, DuelCompleteType /*type*/) { } - // The following methods are called when a player sends a chat message + // The following methods are called when a player sends a chat message. virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/) { } + virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Player* /*receiver*/) { } + virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Group* /*group*/) { } + virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Guild* /*guild*/) { } + virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Channel* /*channel*/) { } - // Both of the below are called on emote opcodes + // Both of the below are called on emote opcodes. virtual void OnEmote(Player* /*player*/, uint32 /*emote*/) { } - virtual void OnTextEmote(Player* /*player*/, uint32 /*text_emote*/, uint32 /*emoteNum*/, uint64 /*guid*/) { } - // Called in Spell::cast + virtual void OnTextEmote(Player* /*player*/, uint32 /*textEmote*/, uint32 /*emoteNum*/, uint64 /*guid*/) { } + + // Called in Spell::Cast. virtual void OnSpellCast(Player* /*player*/, Spell* /*spell*/, bool /*skipCheck*/) { } - // Called when a player logs in or out + // Called when a player logs in. virtual void OnLogin(Player* /*player*/) { } + + // Called when a player logs out. virtual void OnLogout(Player* /*player*/) { } - // Called when a player is created/deleted + // Called when a player is created. virtual void OnCreate(Player* /*player*/) { } + + // Called when a player is deleted. virtual void OnDelete(uint64 /*guid*/) { } - // Called when a player is binded to an instance - virtual void OnBindToInstance(Player* /*player*/, Difficulty /*difficulty*/, uint32 /*mapid*/, bool /*permanent*/) { } + // Called when a player is bound to an instance + virtual void OnBindToInstance(Player* /*player*/, Difficulty /*difficulty*/, uint32 /*mapId*/, bool /*permanent*/) { } }; class GuildScript : public ScriptObject @@ -724,33 +735,63 @@ class GuildScript : public ScriptObject bool IsDatabaseBound() const { return false; } + // Called when a member is added to the guild. virtual void OnAddMember(Guild* /*guild*/, Player* /*player*/, uint8& /*plRank*/) { } + + // Called when a member is removed from the guild. virtual void OnRemoveMember(Guild* /*guild*/, Player* /*player*/, bool /*isDisbanding*/, bool /*isKicked*/) { } + + // Called when the guild MOTD (message of the day) changes. virtual void OnMOTDChanged(Guild* /*guild*/, const std::string& /*newMotd*/) { } + + // Called when the guild info is altered. virtual void OnInfoChanged(Guild* /*guild*/, const std::string& /*newInfo*/) { } + + // Called when a guild is created. virtual void OnCreate(Guild* /*guild*/, Player* /*leader*/, const std::string& /*name*/) { } + + // Called when a guild is disbanded. virtual void OnDisband(Guild* /*guild*/) { } + + // Called when a guild member withdraws money from a guild bank. virtual void OnMemberWitdrawMoney(Guild* /*guild*/, Player* /*player*/, uint32& /*amount*/, bool /*isRepair*/) { } + + // Called when a guild member deposits money in a guild bank. virtual void OnMemberDepositMoney(Guild* /*guild*/, Player* /*player*/, uint32& /*amount*/) { } + + // Called when a guild member moves an item in a guild bank. virtual void OnItemMove(Guild* /*guild*/, Player* /*player*/, Item* /*pItem*/, bool /*isSrcBank*/, uint8 /*srcContainer*/, uint8 /*srcSlotId*/, bool /*isDestBank*/, uint8 /*destContainer*/, uint8 /*destSlotId*/) { } + virtual void OnEvent(Guild* /*guild*/, uint8 /*eventType*/, uint32 /*playerGuid1*/, uint32 /*playerGuid2*/, uint8 /*newRank*/) { } + virtual void OnBankEvent(Guild* /*guild*/, uint8 /*eventType*/, uint8 /*tabId*/, uint32 /*playerGuid*/, uint32 /*itemOrMoney*/, uint16 /*itemStackCount*/, uint8 /*destTabId*/) { } }; class GroupScript : public ScriptObject { -protected: - GroupScript(const char* name); + protected: + + GroupScript(const char* name); + + public: + + bool IsDatabaseBound() const { return false; } + + // Called when a member is added to a group. + virtual void OnAddMember(Group* /*group*/, uint64 /*guid*/) { } -public: - bool IsDatabaseBound() const { return false; } + // Called when a member is invited to join a group. + virtual void OnInviteMember(Group* /*group*/, uint64 /*guid*/) { } - virtual void OnAddMember(Group* /*group*/, uint64 /*guid*/) { } - virtual void OnInviteMember(Group* /*group*/, uint64 /*guid*/) { } - virtual void OnRemoveMember(Group* /*group*/, uint64 /*guid*/, RemoveMethod& /*method*/, uint64 /*kicker*/, const char* /*reason*/) { } - virtual void OnChangeLeader(Group* /*group*/, uint64 /*newLeaderGuid*/, uint64 /*oldLeaderGuid*/) { } - virtual void OnDisband(Group* /*group*/) { } + // Called when a member is removed from a group. + virtual void OnRemoveMember(Group* /*group*/, uint64 /*guid*/, RemoveMethod& /*method*/, uint64 /*kicker*/, const char* /*reason*/) { } + + // Called when the leader of a group is changed. + virtual void OnChangeLeader(Group* /*group*/, uint64 /*newLeaderGuid*/, uint64 /*oldLeaderGuid*/) { } + + // Called when a group is disbanded. + virtual void OnDisband(Group* /*group*/) { } }; // Placed here due to ScriptRegistry::AddScript dependency. @@ -763,6 +804,7 @@ class ScriptMgr friend class ScriptObject; private: + ScriptMgr(); virtual ~ScriptMgr(); @@ -778,13 +820,14 @@ class ScriptMgr uint32 GetScriptCount() const { return _scriptCount; } public: /* Unloading */ + void Unload(); public: /* SpellScriptLoader */ - void CreateSpellScripts(uint32 spell_id, std::list<SpellScript*>& script_vector); - void CreateAuraScripts(uint32 spell_id, std::list<AuraScript*>& script_vector); - void CreateSpellScriptLoaders(uint32 spell_id, std::vector<std::pair<SpellScriptLoader*, std::multimap<uint32, uint32>::iterator> >& script_vector); + void CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector); + void CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector); + void CreateSpellScriptLoaders(uint32 spellId, std::vector<std::pair<SpellScriptLoader*, std::multimap<uint32, uint32>::iterator> >& scriptVector); public: /* ServerScript */ @@ -929,7 +972,7 @@ class ScriptMgr void OnPlayerKilledByCreature(Creature* killer, Player* killed); void OnPlayerLevelChanged(Player* player, uint8 oldLevel); void OnPlayerFreeTalentPointsChanged(Player* player, uint32 newPoints); - void OnPlayerTalentsReset(Player* player, bool no_cost); + void OnPlayerTalentsReset(Player* player, bool noCost); void OnPlayerMoneyChanged(Player* player, int32& amount); void OnGivePlayerXP(Player* player, uint32& amount, Unit* victim); void OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental); @@ -942,7 +985,7 @@ class ScriptMgr void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild); void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel); void OnPlayerEmote(Player* player, uint32 emote); - void OnPlayerTextEmote(Player* player, uint32 text_emote, uint32 emoteNum, uint64 guid); + void OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, uint64 guid); void OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck); void OnPlayerLogin(Player* player); void OnPlayerLogout(Player* player); @@ -951,6 +994,7 @@ class ScriptMgr void OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent); public: /* GuildScript */ + void OnGuildAddMember(Guild* guild, Player* player, uint8& plRank); void OnGuildRemoveMember(Guild* guild, Player* player, bool isDisbanding, bool isKicked); void OnGuildMOTDChanged(Guild* guild, const std::string& newMotd); @@ -965,6 +1009,7 @@ class ScriptMgr void OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); public: /* GroupScript */ + void OnGroupAddMember(Group* group, uint64 guid); void OnGroupInviteMember(Group* group, uint64 guid); void OnGroupRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, const char* reason); @@ -972,12 +1017,14 @@ class ScriptMgr void OnGroupDisband(Group* group); public: /* Scheduled scripts */ - uint32 IncreaseScheduledScriptsCount() { return uint32(++_scheduledScripts); } - uint32 DecreaseScheduledScriptCount() { return uint32(--_scheduledScripts); } - uint32 DecreaseScheduledScriptCount(size_t count) { return uint32(_scheduledScripts -= count); } + + uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; } + uint32 DecreaseScheduledScriptCount() { return --_scheduledScripts; } + uint32 DecreaseScheduledScriptCount(size_t count) { return _scheduledScripts -= count; } bool IsScriptScheduled() const { return _scheduledScripts > 0; } private: + uint32 _scriptCount; //atomic op counter for active scripts amount |