Eluna implementation (#847)

* azerothcore + eluna done.

* Remove the Eluna single thread limit.

* Read Eluna Settings file.

* submodule change.

* fix(test)  Ubuntu - Cant Link Library after Compile

* The ELUNA is disabled by default.

* remove submodule luaEngine.

* some change

* fix a error

* change cmake

* fix: some onplayerchat does not have hooks.

* Eluna: Add BG event Hooks.

* fix:cmake hook AFTER_LOAD_CONF not work.

* Remove the eluna switch.

* Remove some define in the core.

* fix conf file not read in the linux.

* eluna : change bg hook parameter type

* Remove TC log function call

* change bg hook OnBGEnd parameter type.


Note: to enable Eluna, the module is required
This commit is contained in:
ayase
2018-05-23 02:22:11 +08:00
committed by Barbz
parent 0da1f8c706
commit 00777a80ae
38 changed files with 854 additions and 62 deletions

View File

@@ -75,6 +75,10 @@
#include "TicketMgr.h"
#include "ScriptMgr.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif
#define ZONE_UPDATE_INTERVAL (2*IN_MILLISECONDS)
#define PLAYER_SKILL_INDEX(x) (PLAYER_SKILL_INFO_1_1 + ((x)*3))
@@ -5223,6 +5227,10 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
// update visibility
UpdateObjectVisibility();
#ifdef ELUNA
sEluna->OnResurrect(this);
#endif
if(!applySickness)
return;
@@ -12337,7 +12345,11 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
return EQUIP_ERR_OK;
}
#ifdef ELUNA
InventoryResult eres = sEluna->OnCanUseItem(this, proto->ItemId);
if (eres != EQUIP_ERR_OK)
return eres;
#endif
return EQUIP_ERR_ITEM_NOT_FOUND;
}
@@ -12783,7 +12795,9 @@ 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
return pItem2;
}
@@ -12791,6 +12805,10 @@ 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);
return pItem;
}
@@ -12813,6 +12831,10 @@ 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
}
}
@@ -13027,6 +13049,8 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
sScriptMgr->OnItemRemove(this, pItem);
if (bag == INVENTORY_SLOT_BAG_0)
{
SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0);
@@ -15529,6 +15553,9 @@ 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);
questGiver->ToCreature()->AI()->sQuestAccept(this, quest);
break;
@@ -15555,6 +15582,9 @@ 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;
@@ -16615,6 +16645,9 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
{
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;
@@ -16624,6 +16657,9 @@ 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;
@@ -19548,6 +19584,9 @@ void Player::SaveToDB(bool create, bool logout)
#endif
outDebugValues();
if (!create)
sScriptMgr->OnPlayerSave(this);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
_SaveCharacter(create, trans);
@@ -20751,6 +20790,10 @@ void Player::Say(const std::string& text, const uint32 language)
{
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
#ifdef ELUNA
if (!sEluna->OnChat(this, CHAT_MSG_SAY, language, _text))
return;
#endif
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, Language(language), this, this, _text);
@@ -20761,6 +20804,10 @@ void Player::Yell(const std::string& text, const uint32 language)
{
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
#ifdef ELUNA
if (!sEluna->OnChat(this, CHAT_MSG_YELL, language, _text))
return;
#endif
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_YELL, Language(language), this, this, _text);
@@ -20771,7 +20818,10 @@ void Player::TextEmote(const std::string& text)
{
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))
return;
#endif
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, _text);
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true, !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT));
@@ -20788,6 +20838,10 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver)
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer);
#ifdef ELUNA
if (!sEluna->OnChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer))
return;
#endif
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, Language(language), this, this, _text);
@@ -25099,6 +25153,9 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
if (loot->containerId > 0)
sLootItemStorage->RemoveStoredLootItem(loot->containerId, item->itemid, item->count, loot);
#ifdef ELUNA
sEluna->OnLootItem(this, newitem, item->count, this->GetLootGUID());
#endif
sScriptMgr->OnLootItem(this, newitem, item->count, this->GetLootGUID());
}
else
@@ -25538,6 +25595,10 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
// xinef: update free talent points count
m_usedTalentCount += talentPointsChange;
SetFreeTalentPoints(CurTalentPoints - talentPointsChange);
#ifdef ELUNA
sEluna->OnLearnTalents(this, talentId, talentRank, spellId);
#endif
}
void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)