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

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)

View File

@@ -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;

View File

@@ -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);
}
}