mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 01:59:09 +00:00
feat(Core/ScriptMgr): replace macro and cleanup (#9598)
This commit is contained in:
124
src/server/game/Scripting/ScriptDefines/GlobalScript.cpp
Normal file
124
src/server/game/Scripting/ScriptDefines/GlobalScript.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by the
|
||||
* Free Software Foundation; either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "ScriptMgrMacros.h"
|
||||
|
||||
void ScriptMgr::OnGlobalItemDelFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
|
||||
{
|
||||
ASSERT(trans);
|
||||
ASSERT(itemGuid);
|
||||
|
||||
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
script->OnItemDelFromDB(trans, itemGuid);
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGlobalMirrorImageDisplayItem(const Item* item, uint32& display)
|
||||
{
|
||||
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
script->OnMirrorImageDisplayItem(item, display);
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<ObjectGuid, uint32>& ap)
|
||||
{
|
||||
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
script->OnBeforeUpdateArenaPoints(at, ap);
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAfterRefCount(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, uint32& maxcount, LootStore const& store)
|
||||
{
|
||||
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
script->OnAfterRefCount(player, LootStoreItem, loot, canRate, lootMode, maxcount, store);
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnBeforeDropAddItem(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, LootStore const& store)
|
||||
{
|
||||
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
script->OnBeforeDropAddItem(player, loot, canRate, lootMode, LootStoreItem, store);
|
||||
});
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnItemRoll(Player const* player, LootStoreItem const* lootStoreItem, float& chance, Loot& loot, LootStore const& store)
|
||||
{
|
||||
auto ret = IsValidBoolScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
return !script->OnItemRoll(player, lootStoreItem, chance, loot, store);
|
||||
});
|
||||
|
||||
if (ret && *ret)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnBeforeLootEqualChanced(Player const* player, LootStoreItemList EqualChanced, Loot& loot, LootStore const& store)
|
||||
{
|
||||
auto ret = IsValidBoolScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
return !script->OnBeforeLootEqualChanced(player, EqualChanced, loot, store);
|
||||
});
|
||||
|
||||
if (ret && *ret)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScriptMgr::OnInitializeLockedDungeons(Player* player, uint8& level, uint32& lockData, lfg::LFGDungeonData const* dungeon)
|
||||
{
|
||||
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
script->OnInitializeLockedDungeons(player, level, lockData, dungeon);
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAfterInitializeLockedDungeons(Player* player)
|
||||
{
|
||||
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
script->OnAfterInitializeLockedDungeons(player);
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAfterUpdateEncounterState(Map* map, EncounterCreditType type, uint32 creditEntry, Unit* source, Difficulty difficulty_fixed, DungeonEncounterList const* encounters, uint32 dungeonCompleted, bool updated)
|
||||
{
|
||||
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
script->OnAfterUpdateEncounterState(map, type, creditEntry, source, difficulty_fixed, encounters, dungeonCompleted, updated);
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnBeforeWorldObjectSetPhaseMask(WorldObject const* worldObject, uint32& oldPhaseMask, uint32& newPhaseMask, bool& useCombinedPhases, bool& update)
|
||||
{
|
||||
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||
{
|
||||
script->OnBeforeWorldObjectSetPhaseMask(worldObject, oldPhaseMask, newPhaseMask, useCombinedPhases, update);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user