Skip to content

Commit a35a9fe

Browse files
committed
TC Retail: Fixes
Fix compat Enable more functions Fix warning TC Retail: Remove duplicate check TC Retail: Adjust method for changed core call TC Retail: GUID difference correction TC Retail: Fix PCH build fail Enable Item Random functions
1 parent ef84407 commit a35a9fe

File tree

11 files changed

+200
-110
lines changed

11 files changed

+200
-110
lines changed

ElunaEventMgr.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ ElunaEventProcessor* EventMgr::GetGlobalProcessor(GlobalEventSpace space)
225225

226226
uint64 EventMgr::CreateObjectProcessor(WorldObject* obj)
227227
{
228-
#if !ELUNA_CMANGOS && !ELUNA_VMANGOS
228+
#if !ELUNA_CMANGOS && !ELUNA_VMANGOS && (ELUNA_EXPANSION != EXP_RETAIL)
229229
uint64 id = obj->GetGUID().GetRawValue();
230+
#elif ELUNA_EXPANSION == EXP_RETAIL
231+
uint64 id = obj->GetGUID().GetCounter();
230232
#else
231233
uint64 id = obj->GetObjectGuid().GetRawValue();
232234
#endif

ElunaIncludes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "DBCStores.h"
2121
#else
2222
#include "DB2Stores.h"
23+
#include "ChatPackets.h"
2324
#endif
2425
#include "GameEventMgr.h"
2526
#include "GossipDef.h"

ElunaTemplate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ MAKE_ELUNA_OBJECT_VALUE_IMPL(unsigned long long);
155155
MAKE_ELUNA_OBJECT_VALUE_IMPL(ObjectGuid);
156156
MAKE_ELUNA_OBJECT_VALUE_IMPL(WorldPacket);
157157
MAKE_ELUNA_OBJECT_VALUE_IMPL(ElunaQuery);
158+
#if ELUNA_EXPANSION == EXP_RETAIL
159+
MAKE_ELUNA_OBJECT_VALUE_IMPL(std::vector<SpellPowerCost>);
160+
#endif
158161

159162
template<typename T = void>
160163
struct ElunaRegister

LuaEngine.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,11 @@ class ELUNA_GAME_API Eluna
576576
void OnRemoveMember(Group* group, ObjectGuid guid, uint8 method);
577577
void OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid);
578578
void OnDisband(Group* group);
579+
#if ELUNA_EXPANSION < EXP_RETAIL
579580
void OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType);
581+
#else
582+
void OnCreate(Group* group, ObjectGuid leaderGuid, GroupFlags groupFlags);
583+
#endif
580584
bool OnMemberAccept(Group* group, Player* player);
581585

582586
/* Map */

hooks/GroupHooks.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ void Eluna::OnDisband(Group* group)
6565
CallAllFunctions(binding, key);
6666
}
6767

68+
#if ELUNA_EXPANSION < EXP_RETAIL
6869
void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType)
6970
{
7071
START_HOOK(GROUP_EVENT_ON_CREATE);
@@ -73,6 +74,16 @@ void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType)
7374
HookPush(groupType);
7475
CallAllFunctions(binding, key);
7576
}
77+
#else
78+
void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupFlags groupFlags)
79+
{
80+
START_HOOK(GROUP_EVENT_ON_CREATE);
81+
HookPush(group);
82+
HookPush(leaderGuid);
83+
HookPush(groupFlags);
84+
CallAllFunctions(binding, key);
85+
}
86+
#endif
7687

7788
bool Eluna::OnMemberAccept(Group* group, Player* player)
7889
{

hooks/Hooks.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#if defined ELUNA_CMANGOS
1111
#include "Platform/Define.h"
12+
#elif defined ELUNA_TRINITY
13+
#include "Define.h"
1214
#endif
1315
#include <utility>
1416

methods/TrinityCore/GlobalMethods.h

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ namespace LuaGlobalFunctions
366366
#endif
367367
return 1;
368368
}
369-
#if ELUNA_EXPANSION < EXP_RETAIL
369+
370370
/**
371371
* Builds a [GameObject]'s GUID.
372372
*
@@ -382,7 +382,11 @@ namespace LuaGlobalFunctions
382382
{
383383
uint32 lowguid = E->CHECKVAL<uint32>(1);
384384
uint32 entry = E->CHECKVAL<uint32>(2);
385+
#if ELUNA_EXPANSION < EXP_RETAIL
385386
E->Push(ObjectGuid::Create<HIGHGUID_GAMEOBJECT>(entry, lowguid));
387+
#else
388+
E->Push(ObjectGuid::Create<HighGuid::GameObject>(E->GetBoundMapId(), entry, lowguid));
389+
#endif
386390
return 1;
387391
}
388392

@@ -401,10 +405,13 @@ namespace LuaGlobalFunctions
401405
{
402406
uint32 lowguid = E->CHECKVAL<uint32>(1);
403407
uint32 entry = E->CHECKVAL<uint32>(2);
408+
#if ELUNA_EXPANSION < EXP_RETAIL
404409
E->Push(ObjectGuid::Create<HIGHGUID_UNIT>(entry, lowguid));
410+
#else
411+
E->Push(ObjectGuid::Create<HighGuid::Creature>(E->GetBoundMapId(), entry, lowguid));
412+
#endif
405413
return 1;
406414
}
407-
#endif
408415

409416
/**
410417
* Returns the low GUID from a GUID.
@@ -1661,7 +1668,6 @@ namespace LuaGlobalFunctions
16611668
return 0;
16621669
}
16631670

1664-
#if ELUNA_EXPANSION < EXP_RETAIL
16651671
/**
16661672
* Performs an in-game spawn and returns the [Creature] or [GameObject] spawned.
16671673
*
@@ -1690,13 +1696,15 @@ namespace LuaGlobalFunctions
16901696
float o = E->CHECKVAL<float>(8);
16911697
bool save = E->CHECKVAL<bool>(9, false);
16921698
uint32 durorresptime = E->CHECKVAL<uint32>(10, 0);
1699+
#if ELUNA_EXPANSION < EXP_RETAIL
16931700
uint32 phase = E->CHECKVAL<uint32>(11, PHASEMASK_NORMAL);
16941701

16951702
if (!phase)
16961703
{
16971704
E->Push();
16981705
return 1;
16991706
}
1707+
#endif
17001708

17011709
Map* map = eMapMgr->FindMap(mapID, instanceID);
17021710
if (!map)
@@ -1712,14 +1720,21 @@ namespace LuaGlobalFunctions
17121720
if (save)
17131721
{
17141722
Creature* creature = new Creature();
1723+
#if ELUNA_EXPANSION < EXP_RETAIL
17151724
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, phase, entry, pos))
1725+
#else
1726+
if (!creature->CreateCreature(entry, map, pos))
1727+
#endif
17161728
{
17171729
delete creature;
17181730
E->Push();
17191731
return 1;
17201732
}
1721-
1733+
#if ELUNA_EXPANSION < EXP_RETAIL
17221734
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase);
1735+
#else
1736+
creature->SaveToDB();
1737+
#endif
17231738

17241739
uint32 db_guid = creature->GetSpawnId();
17251740

@@ -1735,13 +1750,20 @@ namespace LuaGlobalFunctions
17351750
E->Push();
17361751
return 1;
17371752
}
1738-
1753+
#if ELUNA_EXPANSION < EXP_RETAIL
17391754
eObjectMgr->AddCreatureToGrid(db_guid, eObjectMgr->GetCreatureData(db_guid));
1755+
#else
1756+
eObjectMgr->AddCreatureToGrid(eObjectMgr->GetCreatureData(db_guid));
1757+
#endif
17401758
E->Push(creature);
17411759
}
17421760
else
17431761
{
1762+
#if ELUNA_EXPANSION < EXP_RETAIL
17441763
TempSummon* creature = map->SummonCreature(entry, pos, NULL, durorresptime);
1764+
#else
1765+
TempSummon* creature = map->SummonCreature(entry, pos, NULL, Milliseconds(durorresptime));
1766+
#endif
17451767
if (!creature)
17461768
{
17471769
E->Push();
@@ -1778,7 +1800,11 @@ namespace LuaGlobalFunctions
17781800
uint32 guidLow = map->GenerateLowGuid<HighGuid::GameObject>();
17791801
QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f);
17801802

1803+
#if ELUNA_EXPANSION < EXP_RETAIL
17811804
if (!object->Create(guidLow, objectInfo->entry, map, phase, Position(x, y, z, o), rot, 0, GO_STATE_READY))
1805+
#else
1806+
if (!object->CreateGameObject(objectInfo->entry, map, Position(x, y, z, o), rot, 0, GO_STATE_READY))
1807+
#endif
17821808
{
17831809
delete object;
17841810
E->Push();
@@ -1791,7 +1817,11 @@ namespace LuaGlobalFunctions
17911817
if (save)
17921818
{
17931819
// fill the gameobject data and save to the db
1820+
#if ELUNA_EXPANSION < EXP_RETAIL
17941821
object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase);
1822+
#else
1823+
object->SaveToDB();
1824+
#endif
17951825
guidLow = object->GetSpawnId();
17961826

17971827
// delete the old object and do a clean load from DB with a fresh new GameObject instance.
@@ -1806,7 +1836,11 @@ namespace LuaGlobalFunctions
18061836
E->Push();
18071837
return 1;
18081838
}
1839+
#if ELUNA_EXPANSION < EXP_RETAIL
18091840
eObjectMgr->AddGameobjectToGrid(guidLow, eObjectMgr->GetGameObjectData(guidLow));
1841+
#else
1842+
eObjectMgr->AddGameobjectToGrid(eObjectMgr->GetGameObjectData(guidLow));
1843+
#endif
18101844
}
18111845
else
18121846
map->AddToMap(object);
@@ -1817,7 +1851,6 @@ namespace LuaGlobalFunctions
18171851
E->Push();
18181852
return 1;
18191853
}
1820-
#endif
18211854

18221855
/**
18231856
* Creates a [WorldPacket].
@@ -2025,7 +2058,6 @@ namespace LuaGlobalFunctions
20252058
return 0;
20262059
}
20272060

2028-
#if ELUNA_EXPANSION < EXP_RETAIL
20292061
/**
20302062
* Sends mail to a [Player].
20312063
*
@@ -2098,7 +2130,11 @@ namespace LuaGlobalFunctions
20982130
luaL_error(E->L, "Item entry %d has invalid amount %d", entry, amount);
20992131
continue;
21002132
}
2133+
#if ELUNA_EXPANSION < EXP_RETAIL
21012134
if (Item* item = Item::CreateItem(entry, amount))
2135+
#else
2136+
if (Item* item = Item::CreateItem(entry, amount, ItemContext::NONE))
2137+
#endif
21022138
{
21032139
item->SaveToDB(trans);
21042140
draft.AddItem(item);
@@ -2117,7 +2153,6 @@ namespace LuaGlobalFunctions
21172153

21182154
return addedItems;
21192155
}
2120-
#endif
21212156

21222157
/**
21232158
* Performs a bitwise AND (a & b).
@@ -2207,7 +2242,6 @@ namespace LuaGlobalFunctions
22072242
return 1;
22082243
}
22092244

2210-
#if ELUNA_EXPANSION < EXP_RETAIL
22112245
/**
22122246
* Adds a taxi path to a specified map, returns the used pathId.
22132247
*
@@ -2326,7 +2360,9 @@ namespace LuaGlobalFunctions
23262360
}
23272361
if (startNode >= nodeId)
23282362
return 1;
2363+
#if ELUNA_EXPANSION < EXP_RETAIL
23292364
sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price);
2365+
#endif
23302366
TaxiPathEntry* pathEntry = new TaxiPathEntry();
23312367

23322368
pathEntry->FromTaxiNode = startNode;
@@ -2339,7 +2375,6 @@ namespace LuaGlobalFunctions
23392375
E->Push(pathId);
23402376
return 1;
23412377
}
2342-
#endif
23432378
/**
23442379
* Returns `true` if Eluna is in compatibility mode, `false` if in multistate.
23452380
*
@@ -3217,17 +3252,12 @@ namespace LuaGlobalFunctions
32173252
{ "GetPlayerCount", &LuaGlobalFunctions::GetPlayerCount },
32183253
{ "GetPlayerGUID", &LuaGlobalFunctions::GetPlayerGUID },
32193254
{ "GetItemGUID", &LuaGlobalFunctions::GetItemGUID },
3255+
{ "GetObjectGUID", &LuaGlobalFunctions::GetObjectGUID },
3256+
{ "GetUnitGUID", &LuaGlobalFunctions::GetUnitGUID },
32203257
{ "GetGUIDLow", &LuaGlobalFunctions::GetGUIDLow },
32213258
{ "GetGUIDType", &LuaGlobalFunctions::GetGUIDType },
32223259
{ "GetGUIDEntry", &LuaGlobalFunctions::GetGUIDEntry },
32233260
{ "GetAreaName", &LuaGlobalFunctions::GetAreaName },
3224-
#if ELUNA_EXPANSION < EXP_RETAIL
3225-
{ "GetObjectGUID", &LuaGlobalFunctions::GetObjectGUID },
3226-
{ "GetUnitGUID", &LuaGlobalFunctions::GetUnitGUID },
3227-
#else
3228-
{ "GetObjectGUID", METHOD_REG_NONE },
3229-
{ "GetUnitGUID", METHOD_REG_NONE },
3230-
#endif
32313261
{ "bit_not", &LuaGlobalFunctions::bit_not },
32323262
{ "bit_xor", &LuaGlobalFunctions::bit_xor },
32333263
{ "bit_rshift", &LuaGlobalFunctions::bit_rshift },
@@ -3267,22 +3297,16 @@ namespace LuaGlobalFunctions
32673297
{ "CreateLuaEvent", &LuaGlobalFunctions::CreateLuaEvent },
32683298
{ "RemoveEventById", &LuaGlobalFunctions::RemoveEventById },
32693299
{ "RemoveEvents", &LuaGlobalFunctions::RemoveEvents },
3270-
{ "CreatePacket", &LuaGlobalFunctions::CreatePacket },
3271-
#if ELUNA_EXPANSION < EXP_RETAIL
32723300
{ "PerformIngameSpawn", &LuaGlobalFunctions::PerformIngameSpawn },
3273-
{ "SendMail", &LuaGlobalFunctions::SendMail },
3274-
{ "AddTaxiPath", &LuaGlobalFunctions::AddTaxiPath },
3275-
#else
3276-
{ "PerformIngameSpawn", METHOD_REG_NONE },
3277-
{ "SendMail", METHOD_REG_NONE },
3278-
{ "AddTaxiPath", METHOD_REG_NONE },
3279-
#endif
3301+
{ "CreatePacket", &LuaGlobalFunctions::CreatePacket },
32803302
{ "AddVendorItem", &LuaGlobalFunctions::AddVendorItem },
32813303
{ "VendorRemoveItem", &LuaGlobalFunctions::VendorRemoveItem },
32823304
{ "VendorRemoveAllItems", &LuaGlobalFunctions::VendorRemoveAllItems },
32833305
{ "Kick", &LuaGlobalFunctions::Kick },
32843306
{ "Ban", &LuaGlobalFunctions::Ban },
32853307
{ "SaveAllPlayers", &LuaGlobalFunctions::SaveAllPlayers },
3308+
{ "SendMail", &LuaGlobalFunctions::SendMail },
3309+
{ "AddTaxiPath", &LuaGlobalFunctions::AddTaxiPath },
32863310
{ "CreateInt64", &LuaGlobalFunctions::CreateLongLong },
32873311
{ "CreateUint64", &LuaGlobalFunctions::CreateULongLong },
32883312
{ "StartGameEvent", &LuaGlobalFunctions::StartGameEvent },

0 commit comments

Comments
 (0)