feat(Core/Modules): add separated lib for modules (#9281)

This commit is contained in:
Kargatum
2021-12-02 20:28:58 +07:00
committed by GitHub
parent 8668a03e14
commit 51adbffae4
56 changed files with 1904 additions and 1014 deletions
+3 -12
View File
@@ -53,10 +53,6 @@
// there is probably some underlying problem with imports which should properly addressed
#include "GridNotifiersImpl.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif
TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
{
TrainerSpellMap::const_iterator itr = spellList.find(spell_id);
@@ -242,12 +238,8 @@ void Creature::AddToWorld()
{
GetZoneScript()->OnCreatureCreate(this);
}
#ifdef ELUNA
sEluna->OnAddToWorld(this);
if (IsGuardian() && ToTempSummon() && ToTempSummon()->GetSummonerGUID().IsPlayer())
sEluna->OnPetAddedToWorld(ToTempSummon()->GetSummonerUnit()->ToPlayer(), this);
#endif
sScriptMgr->OnCreatureAddWorld(this);
}
}
@@ -255,9 +247,8 @@ void Creature::RemoveFromWorld()
{
if (IsInWorld())
{
#ifdef ELUNA
sEluna->OnRemoveFromWorld(this);
#endif
sScriptMgr->OnCreatureRemoveWorld(this);
if (GetZoneScript())
GetZoneScript()->OnCreatureRemove(this);
@@ -38,10 +38,6 @@
#include <G3D/CoordinateFrame.h>
#include <G3D/Quat.h>
#ifdef ELUNA
#include "LuaEngine.h"
#endif
GameObject::GameObject() : WorldObject(false), MovableMapObject(),
m_model(nullptr), m_goValue(), m_AI(nullptr)
{
@@ -161,9 +157,8 @@ void GameObject::AddToWorld()
EnableCollision(GetGoState() == GO_STATE_READY || IsTransport()); // pussywizard: this startOpen is unneeded here, collision depends entirely on GOState
WorldObject::AddToWorld();
#ifdef ELUNA
sEluna->OnAddToWorld(this);
#endif
sScriptMgr->OnGameObjectAddWorld(this);
}
}
@@ -172,9 +167,8 @@ void GameObject::RemoveFromWorld()
///- Remove the gameobject from the accessor
if (IsInWorld())
{
#ifdef ELUNA
sEluna->OnRemoveFromWorld(this);
#endif
sScriptMgr->OnGameObjectRemoveWorld(this);
if (m_zoneScript)
m_zoneScript->OnGameObjectRemove(this);
@@ -411,9 +405,6 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
void GameObject::Update(uint32 diff)
{
#ifdef ELUNA
sEluna->UpdateAI(this, diff);
#endif
if (AI())
AI()->UpdateAI(diff);
else if (!AIM_Initialize())
@@ -840,6 +831,7 @@ void GameObject::Update(uint32 diff)
break;
}
}
sScriptMgr->OnGameObjectUpdate(this, diff);
}
@@ -1424,10 +1416,6 @@ void GameObject::Use(Unit* user)
if (Player* playerUser = user->ToPlayer())
{
#ifdef ELUNA
if (sEluna->OnGossipHello(playerUser, this))
return;
#endif
if (sScriptMgr->OnGossipHello(playerUser, this))
return;
@@ -2287,11 +2275,10 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
break;
case GO_DESTRUCTIBLE_DAMAGED:
{
#ifdef ELUNA
sEluna->OnDamaged(this, eventInvoker);
#endif
EventInform(m_goInfo->building.damagedEvent);
sScriptMgr->OnGameObjectDamaged(this, eventInvoker);
if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
if (Battleground* bg = bgMap->GetBG())
bg->EventPlayerDamagedGO(eventInvoker, this, m_goInfo->building.damagedEvent);
@@ -2318,11 +2305,10 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
}
case GO_DESTRUCTIBLE_DESTROYED:
{
#ifdef ELUNA
sEluna->OnDestroyed(this, eventInvoker);
#endif
sScriptMgr->OnGameObjectDestroyed(this, eventInvoker);
EventInform(m_goInfo->building.destroyedEvent);
if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
{
if (Battleground* bg = bgMap->GetBG())
@@ -2375,9 +2361,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
void GameObject::SetLootState(LootState state, Unit* unit)
{
m_lootState = state;
#ifdef ELUNA
sEluna->OnLootStateChanged(this, state);
#endif
AI()->OnStateChanged(state, unit);
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
// pussywizard: lootState has nothing to do with collision, it depends entirely on GOState. Loot state is for timed close/open door and respawning, which then sets GOState
@@ -2400,10 +2384,9 @@ void GameObject::SetLootState(LootState state, Unit* unit)
void GameObject::SetGoState(GOState state)
{
SetByteValue(GAMEOBJECT_BYTES_1, 0, state);
#ifdef ELUNA
sEluna->OnGameObjectStateChanged(this, state);
#endif
sScriptMgr->OnGameObjectStateChanged(this, state);
if (m_model)
{
if (!IsInWorld())
+16 -26
View File
@@ -55,11 +55,6 @@
// there is probably some underlying problem with imports which should properly addressed
#include "GridNotifiersImpl.h"
#ifdef ELUNA
#include "ElunaEventMgr.h"
#include "LuaEngine.h"
#endif
constexpr float VisibilityDistances[AsUnderlyingType(VisibilityDistanceType::Max)] =
{
DEFAULT_VISIBILITY_DISTANCE,
@@ -87,10 +82,7 @@ Object::Object() : m_PackGUID(sizeof(uint64) + 1)
WorldObject::~WorldObject()
{
#ifdef ELUNA
delete elunaEvents;
elunaEvents = nullptr;
#endif
sScriptMgr->OnWorldObjectDestroy(this);
// this may happen because there are many !create/delete
if (IsWorldObject() && m_currMap)
@@ -1106,23 +1098,20 @@ void MovementInfo::OutDebug()
}
WorldObject::WorldObject(bool isWorldObject) : WorldLocation(),
#ifdef ELUNA
elunaEvents(nullptr),
#endif
LastUsedScriptID(0), m_name(""), m_isActive(false), m_visibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
_zoneId(0), _areaId(0), _floorZ(INVALID_HEIGHT), _outdoors(false), _liquidData(), _updatePositionData(false), m_transport(nullptr),
m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
{
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
sScriptMgr->OnWorldObjectCreate(this);
}
#ifdef ELUNA
void WorldObject::Update(uint32 time_diff)
{
elunaEvents->Update(time_diff);
sScriptMgr->OnWorldObjectUpdate(this, time_diff);
}
#endif
void WorldObject::SetWorldObject(bool on)
{
@@ -2227,22 +2216,23 @@ void WorldObject::SetMap(Map* map)
{
ASSERT(map);
ASSERT(!IsInWorld());
if (m_currMap == map) // command add npc: first create, than loadfromdb
{
return;
}
if (m_currMap)
{
LOG_FATAL("entities.object", "WorldObject::SetMap: obj %u new map %u %u, old map %u %u", (uint32)GetTypeId(), map->GetId(), map->GetInstanceId(), m_currMap->GetId(), m_currMap->GetInstanceId());
ABORT();
}
m_currMap = map;
m_mapId = map->GetId();
m_InstanceId = map->GetInstanceId();
#ifdef ELUNA
delete elunaEvents;
// On multithread replace this with a pointer to map's Eluna pointer stored in a map
elunaEvents = new ElunaEventProcessor(&Eluna::GEluna, this);
#endif
sScriptMgr->OnWorldObjectSetMap(this, map);
if (IsWorldObject())
m_currMap->AddWorldObject(this);
@@ -2252,13 +2242,13 @@ void WorldObject::ResetMap()
{
ASSERT(m_currMap);
ASSERT(!IsInWorld());
if (IsWorldObject())
m_currMap->RemoveWorldObject(this);
#ifdef ELUNA
delete elunaEvents;
elunaEvents = nullptr;
#endif
if (IsWorldObject())
{
m_currMap->RemoveWorldObject(this);
}
sScriptMgr->OnWorldObjectResetMap(this);
m_currMap = nullptr;
//maybe not for corpse
+3 -10
View File
@@ -33,9 +33,7 @@
#include <sstream>
#include <string>
#ifdef ELUNA
class ElunaEventProcessor;
#endif
enum TempSummonType
{
@@ -673,20 +671,13 @@ protected:
public:
~WorldObject() override;
#ifdef ELUNA
virtual void Update(uint32 /*time_diff*/);
#else
virtual void Update(uint32 /*time_diff*/) { };
#endif
void _Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask);
void AddToWorld() override;
void RemoveFromWorld() override;
#ifdef ELUNA
ElunaEventProcessor* elunaEvents;
#endif
void GetNearPoint2D(WorldObject const* searcher, float& x, float& y, float distance, float absAngle, Position const* startPos = nullptr) const;
void GetNearPoint2D(float& x, float& y, float distance, float absAngle, Position const* startPos = nullptr) const;
void GetNearPoint(WorldObject const* searcher, float& x, float& y, float& z, float searcher_size, float distance2d, float absAngle, float controlZ = 0, Position const* startPos = nullptr) const;
@@ -899,6 +890,8 @@ public:
[[nodiscard]] bool HasAllowedLooter(ObjectGuid guid) const;
[[nodiscard]] GuidUnorderedSet const& GetAllowedLooters() const;
ElunaEventProcessor* elunaEvents;
protected:
std::string m_name;
bool m_isActive;
+3 -7
View File
@@ -35,10 +35,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif
Pet::Pet(Player* owner, PetType type) : Guardian(nullptr, owner ? owner->GetGUID() : ObjectGuid::Empty, true),
m_usedTalentCount(0), m_removed(false), m_owner(owner),
m_happinessTimer(PET_LOSE_HAPPINES_INTERVAL), m_petType(type), m_duration(0),
@@ -98,10 +94,10 @@ void Pet::AddToWorld()
GetCharmInfo()->SetIsReturning(false);
}
#ifdef ELUNA
if (GetOwnerGUID().IsPlayer())
sEluna->OnPetAddedToWorld(GetOwner(), this);
#endif
{
sScriptMgr->OnPetAddToWorld(this);
}
}
void Pet::RemoveFromWorld()
+26 -30
View File
@@ -92,10 +92,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif
enum CharacterFlags
{
CHARACTER_FLAG_NONE = 0x00000000,
@@ -4356,12 +4352,12 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
// update visibility
UpdateObjectVisibility();
#ifdef ELUNA
sEluna->OnResurrect(this);
#endif
sScriptMgr->OnPlayerResurrect(this, restore_percent, applySickness);
if(!applySickness)
if (!applySickness)
{
return;
}
//Characters from level 1-10 are not affected by resurrection sickness.
//Characters from level 11-19 will suffer from one minute of sickness
@@ -8774,11 +8770,12 @@ void Player::StopCastingCharm()
void Player::Say(std::string_view text, Language language, WorldObject const* /*= nullptr*/)
{
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
#ifdef ELUNA
if (!sEluna->OnChat(this, CHAT_MSG_SAY, language, _text))
if (!sScriptMgr->CanPlayerUseChat(this, CHAT_MSG_SAY, language, _text))
{
return;
#endif
}
sScriptMgr->OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, language, this, this, _text);
@@ -8793,11 +8790,13 @@ void Player::Say(uint32 textId, WorldObject const* target /*= nullptr*/)
void Player::Yell(std::string_view text, Language language, WorldObject const* /*= nullptr*/)
{
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
#ifdef ELUNA
if (!sEluna->OnChat(this, CHAT_MSG_YELL, language, _text))
if (!sScriptMgr->CanPlayerUseChat(this, CHAT_MSG_YELL, language, _text))
{
return;
#endif
}
sScriptMgr->OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_YELL, language, this, this, _text);
@@ -8812,11 +8811,13 @@ void Player::Yell(uint32 textId, WorldObject const* target /*= nullptr*/)
void Player::TextEmote(std::string_view text, WorldObject const* /*= nullptr*/, bool /*= false*/)
{
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text);
#ifdef ELUNA
if (!sEluna->OnChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text))
if (!sScriptMgr->CanPlayerUseChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text))
{
return;
#endif
}
sScriptMgr->OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, _text);
@@ -8838,13 +8839,13 @@ void Player::Whisper(std::string_view text, Language language, Player* target, b
language = LANG_UNIVERSAL; // whispers should always be readable
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, target);
#ifdef ELUNA
if (!sEluna->OnChat(this, CHAT_MSG_WHISPER, language, _text, target))
if (!sScriptMgr->CanPlayerUseChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text, target))
{
return;
}
#endif
sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, target);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, language, this, this, _text);
@@ -12803,9 +12804,6 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
if (loot->containerGUID)
sLootItemStorage->RemoveStoredLootItem(loot->containerGUID, item->itemid, item->count, loot, item->itemIndex);
#ifdef ELUNA
sEluna->OnLootItem(this, newitem, item->count, this->GetLootGUID());
#endif
sScriptMgr->OnLootItem(this, newitem, item->count, this->GetLootGUID());
}
else
@@ -13235,9 +13233,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
m_usedTalentCount += talentPointsChange;
SetFreeTalentPoints(CurTalentPoints - talentPointsChange);
#ifdef ELUNA
sEluna->OnLearnTalents(this, talentId, talentRank, spellId);
#endif
sScriptMgr->OnPlayerLearnTalents(this, talentId, talentRank, spellId);
}
void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank)
@@ -30,10 +30,6 @@
#include "SpellMgr.h"
#include "WorldSession.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif
/*********************************************************/
/*** QUEST SYSTEM ***/
/*********************************************************/
@@ -429,10 +425,7 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver)
switch (questGiver->GetTypeId())
{
case TYPEID_UNIT:
#ifdef ELUNA
sEluna->OnQuestAccept(this, questGiver->ToCreature(), quest);
#endif
sScriptMgr->OnQuestAccept(this, (questGiver->ToCreature()), quest);
sScriptMgr->OnQuestAccept(this, questGiver->ToCreature(), quest);
questGiver->ToCreature()->AI()->sQuestAccept(this, quest);
break;
case TYPEID_ITEM:
@@ -458,9 +451,6 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver)
break;
}
case TYPEID_GAMEOBJECT:
#ifdef ELUNA
sEluna->OnQuestAccept(this, questGiver->ToGameObject(), quest);
#endif
sScriptMgr->OnQuestAccept(this, questGiver->ToGameObject(), quest);
questGiver->ToGameObject()->AI()->QuestAccept(this, quest);
break;
@@ -1566,13 +1556,12 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
QuestRelationBounds qr;
QuestRelationBounds qir;
sScriptMgr->GetDialogStatus(this, questgiver);
switch (questgiver->GetTypeId())
{
case TYPEID_GAMEOBJECT:
{
#ifdef ELUNA
sEluna->GetDialogStatus(this, questgiver->ToGameObject());
#endif
QuestGiverStatus questStatus = QuestGiverStatus(sScriptMgr->GetDialogStatus(this, questgiver->ToGameObject()));
if (questStatus != DIALOG_STATUS_SCRIPTED_NO_STATUS)
return questStatus;
@@ -1582,9 +1571,6 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
}
case TYPEID_UNIT:
{
#ifdef ELUNA
sEluna->GetDialogStatus(this, questgiver->ToCreature());
#endif
QuestGiverStatus questStatus = QuestGiverStatus(sScriptMgr->GetDialogStatus(this, questgiver->ToCreature()));
if (questStatus != DIALOG_STATUS_SCRIPTED_NO_STATUS)
return questStatus;
@@ -76,10 +76,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif
/*********************************************************/
/*** STORAGE SYSTEM ***/
/*********************************************************/
@@ -2340,13 +2336,6 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
}
InventoryResult result = EQUIP_ERR_OK;
if (!sScriptMgr->CanUseItem(const_cast<Player*>(this), proto, result))
{
return result;
}
if (getLevel() < proto->RequiredLevel)
{
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
@@ -2358,13 +2347,12 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
}
#ifdef ELUNA
InventoryResult eres = sEluna->OnCanUseItem(this, proto->ItemId);
if (eres != EQUIP_ERR_OK)
InventoryResult result = EQUIP_ERR_OK;
if (!sScriptMgr->CanUseItem(const_cast<Player*>(this), proto, result))
{
return eres;
return result;
}
#endif
return EQUIP_ERR_OK;
}
@@ -2851,9 +2839,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
pItem2->SetState(ITEM_CHANGED, this);
ApplyEquipCooldown(pItem2);
#ifdef ELUNA
sEluna->OnEquip(this, pItem2, bag, slot);
#endif
sScriptMgr->OnEquip(this, pItem2, bag, slot, update);
return pItem2;
}
@@ -2861,10 +2847,6 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);
#ifdef ELUNA
sEluna->OnEquip(this, pItem, bag, slot);
#endif
sScriptMgr->OnEquip(this, pItem, bag, slot, update);
UpdateForQuestWorldObjects();
return pItem;
@@ -2889,9 +2871,7 @@ void Player::QuickEquipItem(uint16 pos, Item* pItem)
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);
#ifdef ELUNA
sEluna->OnEquip(this, pItem, (pos >> 8), slot);
#endif
sScriptMgr->OnEquip(this, pItem, (pos >> 8), slot, true);
}
}
+10 -14
View File
@@ -70,11 +70,6 @@
#include "WorldSession.h"
#include <math.h>
#ifdef ELUNA
#include "ElunaEventMgr.h"
#include "LuaEngine.h"
#endif
float baseMoveSpeed[MAX_MOVE_TYPE] =
{
2.5f, // MOVE_WALK
@@ -387,9 +382,8 @@ Unit::~Unit()
void Unit::Update(uint32 p_time)
{
#ifdef ELUNA
elunaEvents->Update(p_time);
#endif
sScriptMgr->OnUnitUpdate(this, p_time);
// WARNING! Order of execution here is important, do not change.
// Spells must be processed with event system BEFORE they go to _UpdateSpells.
// Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
@@ -12991,10 +12985,11 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration)
controlled->SetInCombatState(PvP, enemy, duration);
}
#ifdef ELUNA
if (Player* player = this->ToPlayer())
sEluna->OnPlayerEnterCombat(player, enemy);
#endif
{
sScriptMgr->OnPlayerEnterCombat(player, enemy);
}
}
void Unit::ClearInCombat()
@@ -13025,10 +13020,11 @@ void Unit::ClearInCombat()
for (uint8 i = 0; i < MAX_RUNES; ++i)
player->SetGracePeriod(i, 0);
}
#ifdef ELUNA
if (Player* player = this->ToPlayer())
sEluna->OnPlayerLeaveCombat(player);
#endif
{
sScriptMgr->OnPlayerLeaveCombat(player);
}
}
void Unit::ClearInPetCombat()