From b6a450569e64eb944ac6a6ae6cbb31eefa4f82de Mon Sep 17 00:00:00 2001 From: Foereaper Date: Sat, 12 Sep 2020 15:44:02 +0200 Subject: [PATCH] Required changes for latest TC --- CreatureMethods.h | 4 +++- ElunaIncludes.h | 2 -- ElunaInstanceAI.cpp | 9 +++++++++ ElunaInstanceAI.h | 2 ++ GlobalMethods.h | 28 +++++++++++++++++----------- GuildMethods.h | 2 +- ItemMethods.h | 16 ++++++++++++++++ LuaFunctions.cpp | 2 +- PlayerMethods.h | 11 ++++++++++- ServerHooks.cpp | 9 ++++++--- UnitMethods.h | 15 ++++++++++++++- VehicleMethods.h | 4 +++- WorldObjectMethods.h | 4 ++-- 13 files changed, 84 insertions(+), 24 deletions(-) diff --git a/CreatureMethods.h b/CreatureMethods.h index a13ff82..4bef86a 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -1161,7 +1161,9 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); { uint32 msTimeToDespawn = Eluna::CHECKVAL(L, 2, 0); -#if defined TRINITY || AZEROTHCORE +#if defined TRINITY + creature->DespawnOrUnsummon(Milliseconds(msTimeToDespawn)); +#elif defined AZEROTHCORE creature->DespawnOrUnsummon(msTimeToDespawn); #else creature->ForcedDespawn(msTimeToDespawn); diff --git a/ElunaIncludes.h b/ElunaIncludes.h index b9e226e..bf5ac2b 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -42,8 +42,6 @@ #if defined TRINITY #include "GitRevision.h" #include "SpellHistory.h" -#include -#include #endif #if defined TRINITY || defined AZEROTHCORE diff --git a/ElunaInstanceAI.cpp b/ElunaInstanceAI.cpp index 9f99616..7c0155a 100644 --- a/ElunaInstanceAI.cpp +++ b/ElunaInstanceAI.cpp @@ -9,6 +9,7 @@ #include "lmarshal.h" +#ifndef TRINITY void ElunaInstanceAI::Initialize() { LOCK_ELUNA; @@ -22,6 +23,7 @@ void ElunaInstanceAI::Initialize() sEluna->OnInitialize(this); } +#endif void ElunaInstanceAI::Load(const char* data) { @@ -82,7 +84,9 @@ void ElunaInstanceAI::Load(const char* data) lua_pop(L, 1); // Stack: (empty) +#ifndef TRINITY Initialize(); +#endif } } else @@ -92,7 +96,9 @@ void ElunaInstanceAI::Load(const char* data) lua_pop(L, 1); // Stack: (empty) +#ifndef TRINITY Initialize(); +#endif } delete[] decodedData; @@ -100,7 +106,10 @@ void ElunaInstanceAI::Load(const char* data) else { ELUNA_LOG_ERROR("Error while decoding instance data: Data is not valid base-64"); + +#ifndef TRINITY Initialize(); +#endif } } diff --git a/ElunaInstanceAI.h b/ElunaInstanceAI.h index 2d532f7..e950eaf 100644 --- a/ElunaInstanceAI.h +++ b/ElunaInstanceAI.h @@ -65,7 +65,9 @@ public: { } +#ifndef TRINITY void Initialize() override; +#endif /* * These are responsible for serializing/deserializing the instance's diff --git a/GlobalMethods.h b/GlobalMethods.h index 26a4e5d..5af4baf 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -181,7 +181,7 @@ namespace LuaGlobalFunctions #else { #ifdef TRINITY - boost::shared_lock lock(*HashMapHolder::GetLock()); + std::shared_lock lock(*HashMapHolder::GetLock()); #elif defined(AZEROTHCORE) ACORE_READ_GUARD(HashMapHolder::LockType, *HashMapHolder::GetLock()); #else @@ -477,7 +477,7 @@ namespace LuaGlobalFunctions if (!areaEntry) return luaL_argerror(L, 1, "valid Area or Zone ID expected"); - Eluna::Push(L, areaEntry->area_name[locale]); + Eluna::Push(L, areaEntry->AreaName[locale]); return 1; } @@ -2300,10 +2300,10 @@ namespace LuaGlobalFunctions TaxiPathNodeEntry entry; #ifdef TRINITY // mandatory - entry.MapID = Eluna::CHECKVAL(L, start); - entry.LocX = Eluna::CHECKVAL(L, start + 1); - entry.LocY = Eluna::CHECKVAL(L, start + 2); - entry.LocZ = Eluna::CHECKVAL(L, start + 3); + entry.ContinentID = Eluna::CHECKVAL(L, start); + entry.Loc.X = Eluna::CHECKVAL(L, start + 1); + entry.Loc.Y = Eluna::CHECKVAL(L, start + 2); + entry.Loc.Z = Eluna::CHECKVAL(L, start + 3); // optional entry.Flags = Eluna::CHECKVAL(L, start + 4, 0); entry.Delay = Eluna::CHECKVAL(L, start + 5, 0); @@ -2351,10 +2351,10 @@ namespace LuaGlobalFunctions entry.PathID = pathId; entry.NodeIndex = nodeId; nodeEntry->ID = index; - nodeEntry->map_id = entry.MapID; - nodeEntry->x = entry.LocX; - nodeEntry->y = entry.LocY; - nodeEntry->z = entry.LocZ; + nodeEntry->ContinentID = entry.ContinentID; + nodeEntry->Pos.X = entry.Loc.X; + nodeEntry->Pos.Y = entry.Loc.Y; + nodeEntry->Pos.Z = entry.Loc.Z; nodeEntry->MountCreatureID[0] = mountH; nodeEntry->MountCreatureID[1] = mountA; sTaxiNodesStore.SetEntry(nodeId++, nodeEntry); @@ -2381,10 +2381,16 @@ namespace LuaGlobalFunctions return 1; sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price); TaxiPathEntry* pathEntry = new TaxiPathEntry(); +#ifdef TRINITY + pathEntry->FromTaxiNode = startNode; + pathEntry->ToTaxiNode = nodeId - 1; + pathEntry->Cost = price; +#else pathEntry->from = startNode; pathEntry->to = nodeId - 1; - pathEntry->ID = pathId; pathEntry->price = price; +#endif + pathEntry->ID = pathId; sTaxiPathStore.SetEntry(pathId, pathEntry); Eluna::Push(L, pathId); return 1; diff --git a/GuildMethods.h b/GuildMethods.h index 16e7433..3a2b6be 100644 --- a/GuildMethods.h +++ b/GuildMethods.h @@ -37,7 +37,7 @@ namespace LuaGuild #else { #ifdef TRINITY - boost::shared_lock lock(*HashMapHolder::GetLock()); + std::shared_lock lock(*HashMapHolder::GetLock()); #elif defined(AZEROTHCORE) ACORE_READ_GUARD(HashMapHolder::LockType, *HashMapHolder::GetLock()); #else diff --git a/ItemMethods.h b/ItemMethods.h index 4aed44e..719eb60 100644 --- a/ItemMethods.h +++ b/ItemMethods.h @@ -274,24 +274,40 @@ namespace LuaItem #if defined(CATA) || defined (MISTS) char* suffix = NULL; #else +#ifdef TRINITY + std::array const* suffix = NULL; +#elif char* const* suffix = NULL; +#endif #endif if (itemRandPropId < 0) { const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId()); if (itemRandEntry) +#ifdef TRINITY + suffix = &itemRandEntry->Name; +#else suffix = itemRandEntry->nameSuffix; +#endif } else { const ItemRandomPropertiesEntry* itemRandEntry = sItemRandomPropertiesStore.LookupEntry(item->GetItemRandomPropertyId()); if (itemRandEntry) +#ifdef TRINITY + suffix = &itemRandEntry->Name; +#else suffix = itemRandEntry->nameSuffix; +#endif } if (suffix) { name += ' '; +#if defined TRINITY + name += (*suffix)[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)]; +#else name += suffix[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)]; +#endif } } #endif diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index c3375dd..db06749 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -399,7 +399,7 @@ ElunaRegister UnitMethods[] = { "StopSpellCast", &LuaUnit::StopSpellCast }, { "InterruptSpell", &LuaUnit::InterruptSpell }, { "SendChatMessageToPlayer", &LuaUnit::SendChatMessageToPlayer }, - { "Emote", &LuaUnit::Emote }, + { "PerformEmote", &LuaUnit::PerformEmote }, { "EmoteState", &LuaUnit::EmoteState }, { "CountPctFromCurHealth", &LuaUnit::CountPctFromCurHealth }, { "CountPctFromMaxHealth", &LuaUnit::CountPctFromMaxHealth }, diff --git a/PlayerMethods.h b/PlayerMethods.h index 10e9034..1d64832 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -2262,10 +2262,11 @@ namespace LuaPlayer WorldPacket data(MSG_AUCTION_HELLO, 12); #ifdef TRINITY data << uint64(unit->GetGUID().GetCounter()); + data << uint32(ahEntry->ID); #else data << uint64(unit->GetGUIDLow()); -#endif data << uint32(ahEntry->houseId); +#endif data << uint8(1); #ifdef CMANGOS player->GetSession()->SendPacket(data); @@ -3312,11 +3313,19 @@ namespace LuaPlayer { if (SkillLineEntry const* entry = sSkillLineStore.LookupEntry(i)) { +#ifdef TRINITY + if (entry->CategoryID == SKILL_CATEGORY_LANGUAGES || entry->CategoryID == SKILL_CATEGORY_GENERIC) + continue; + + if (player->HasSkill(entry->ID)) + player->UpdateSkill(entry->ID, step); +#else if (entry->categoryId == SKILL_CATEGORY_LANGUAGES || entry->categoryId == SKILL_CATEGORY_GENERIC) continue; if (player->HasSkill(entry->id)) player->UpdateSkill(entry->id, step); +#endif } } diff --git a/ServerHooks.cpp b/ServerHooks.cpp index b420d35..a11ce6a 100644 --- a/ServerHooks.cpp +++ b/ServerHooks.cpp @@ -116,10 +116,13 @@ bool Eluna::OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger) { START_HOOK_WITH_RETVAL(TRIGGER_EVENT_ON_TRIGGER, false); Push(pPlayer); -#ifndef AZEROTHCORE - Push(pTrigger->id); -#else +#ifdef TRINITY + Push(pTrigger->ID); +#elif AZEROTHCORE Push(pTrigger->entry); +#else + Push(pTrigger->id); + #endif return CallAllFunctionsBool(ServerEventBindings, key); } diff --git a/UnitMethods.h b/UnitMethods.h index 38d6a40..5c42396 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -1163,7 +1163,11 @@ namespace LuaUnit if (!entry) return 1; +#ifdef TRINITY + Eluna::Push(L, entry->Name[locale]); +#else Eluna::Push(L, entry->name[locale]); +#endif return 1; } @@ -1202,7 +1206,11 @@ namespace LuaUnit if (!entry) return 1; +#ifdef TRINITY + Eluna::Push(L, entry->Name[locale]); +#else Eluna::Push(L, entry->name[locale]); +#endif return 1; } @@ -2033,9 +2041,14 @@ namespace LuaUnit * * @param uint32 emoteId */ - int Emote(lua_State* L, Unit* unit) + int PerformEmote(lua_State* L, Unit* unit) { +#ifdef TRINITY + Emote emote = static_cast(Eluna::CHECKVAL(L, 2)); + unit->HandleEmoteCommand(emote); +#else unit->HandleEmoteCommand(Eluna::CHECKVAL(L, 2)); +#endif return 0; } diff --git a/VehicleMethods.h b/VehicleMethods.h index 6dc78b2..3bbfea5 100644 --- a/VehicleMethods.h +++ b/VehicleMethods.h @@ -53,7 +53,9 @@ namespace LuaVehicle */ int GetEntry(lua_State* L, Vehicle* vehicle) { -#if defined TRINITY || AZEROTHCORE +#ifdef TRINITY + Eluna::Push(L, vehicle->GetVehicleInfo()->ID); +#elif AZEROTHCORE Eluna::Push(L, vehicle->GetVehicleInfo()->m_ID); #else Eluna::Push(L, vehicle->GetVehicleEntry()->m_ID); diff --git a/WorldObjectMethods.h b/WorldObjectMethods.h index 6205efe..58cc63a 100644 --- a/WorldObjectMethods.h +++ b/WorldObjectMethods.h @@ -717,7 +717,7 @@ namespace LuaWorldObject uint32 respawnDelay = Eluna::CHECKVAL(L, 7, 30); #ifdef TRINITY QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); - Eluna::Push(L, obj->SummonGameObject(entry, Position(x, y, z, o), rot, respawnDelay)); + Eluna::Push(L, obj->SummonGameObject(entry, Position(x, y, z, o), rot, Seconds(respawnDelay))); #elif AZEROTHCORE Eluna::Push(L, obj->SummonGameObject(entry, x, y, z, o, 0, 0, 0, 0, respawnDelay)); #else @@ -804,7 +804,7 @@ namespace LuaWorldObject default: return luaL_argerror(L, 7, "valid SpawnType expected"); } - Eluna::Push(L, obj->SummonCreature(entry, x, y, z, o, type, despawnTimer)); + Eluna::Push(L, obj->SummonCreature(entry, x, y, z, o, type, Seconds(despawnTimer))); return 1; }