Skip to content

Commit 24fe97a

Browse files
committed
Add Azerothcore methods and necessary changes to defines
1 parent da9266b commit 24fe97a

32 files changed

+17676
-27
lines changed

ElunaConfig.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Please see the included DOCS/LICENSE.md for more information
55
*/
66

7-
#if defined ELUNA_TRINITY
7+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
88
#include "Config.h"
99
#else
1010
#include "Config/Config.h"
@@ -56,6 +56,8 @@ void ElunaConfig::SetConfig(ElunaConfigBoolValues index, char const* fieldname,
5656
{
5757
#if defined ELUNA_TRINITY
5858
SetConfig(index, sConfigMgr->GetBoolDefault(fieldname, defvalue));
59+
#elif defined ELUNA_AZEROTHCORE
60+
SetConfig(index, sConfigMgr->GetOption<bool>(fieldname, defvalue));
5961
#else
6062
SetConfig(index, sConfig.GetBoolDefault(fieldname, defvalue));
6163
#endif
@@ -67,6 +69,8 @@ void ElunaConfig::SetConfig(ElunaConfigStringValues index, char const* fieldname
6769
SetConfig(index, sConfigMgr->GetStringDefault(fieldname, defvalue));
6870
#elif defined ELUNA_CMANGOS
6971
SetConfig(index, sConfig.GetStringDefault(fieldname, defvalue));
72+
#elif defined ELUNA_AZEROTHCORE
73+
SetConfig(index, sConfigMgr->GetOption<std::string>(fieldname, defvalue));
7074
#else
7175
SetConfig(index, sConfig.GetStringDefault(fieldname, defvalue.c_str()));
7276
#endif
@@ -76,6 +80,8 @@ void ElunaConfig::SetConfig(ElunaConfigUInt32Values index, char const* fieldname
7680
{
7781
#if defined ELUNA_TRINITY
7882
SetConfig(index, sConfigMgr->GetIntDefault(fieldname, defvalue));
83+
#elif defined ELUNA_AZEROTHCORE
84+
SetConfig(index, sConfigMgr->GetOption<uint32>(fieldname, defvalue));
7985
#else
8086
SetConfig(index, sConfig.GetIntDefault(fieldname, defvalue));
8187
#endif

ElunaCreatureAI.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "AI/BaseAI/CreatureAI.h"
1313
#endif
1414

15-
#if defined ELUNA_TRINITY
15+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
1616
struct ScriptedAI;
1717
typedef ScriptedAI NativeScriptedAI;
1818
#elif defined ELUNA_CMANGOS || ELUNA_MANGOS
@@ -29,7 +29,7 @@ struct ElunaCreatureAI : NativeScriptedAI
2929
bool justSpawned;
3030
// used to delay movementinform hook (WP hook)
3131
std::vector< std::pair<uint32, uint32> > movepoints;
32-
#if !defined ELUNA_TRINITY
32+
#if !defined ELUNA_TRINITY && !defined ELUNA_AZEROTHCORE
3333
#define me m_creature
3434
#endif
3535
ElunaCreatureAI(Creature* creature) : NativeScriptedAI(creature), justSpawned(true)
@@ -73,7 +73,7 @@ struct ElunaCreatureAI : NativeScriptedAI
7373
}
7474
}
7575

76-
#if defined ELUNA_TRINITY
76+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
7777
// Called for reaction when initially engaged - this will always happen _after_ JustEnteredCombat
7878
// Called at creature aggro either by MoveInLOS or Attack Start
7979
void JustEngagedWith(Unit* target) override
@@ -94,6 +94,8 @@ struct ElunaCreatureAI : NativeScriptedAI
9494
// Called at any Damage from any attacker (before damage apply)
9595
#if defined ELUNA_TRINITY || defined ELUNA_CMANGOS
9696
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override
97+
#elif defined ELUNA_AZEROTHCORE
98+
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask) override
9799
#else
98100
void DamageTaken(Unit* attacker, uint32& damage) override
99101
#endif
@@ -102,6 +104,8 @@ struct ElunaCreatureAI : NativeScriptedAI
102104
{
103105
#if defined ELUNA_TRINITY || defined ELUNA_CMANGOS
104106
NativeScriptedAI::DamageTaken(attacker, damage, damageType, spellInfo);
107+
#elif defined ELUNA_AZEROTHCORE
108+
NativeScriptedAI::DamageTaken(attacker, damage, damagetype, damageSchoolMask);
105109
#else
106110
NativeScriptedAI::DamageTaken(attacker, damage);
107111
#endif
@@ -151,7 +155,7 @@ struct ElunaCreatureAI : NativeScriptedAI
151155
NativeScriptedAI::AttackStart(target);
152156
}
153157

154-
#if defined ELUNA_TRINITY
158+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
155159
// Called for reaction at stopping attack at no attackers or targets
156160
void EnterEvadeMode(EvadeReason /*why*/) override
157161
#else
@@ -199,7 +203,7 @@ struct ElunaCreatureAI : NativeScriptedAI
199203
NativeScriptedAI::CorpseRemoved(respawnDelay);
200204
}
201205

202-
#if !defined ELUNA_TRINITY && !defined ELUNA_VMANGOS
206+
#if !defined ELUNA_TRINITY && !defined ELUNA_VMANGOS && !defined ELUNA_AZEROTHCORE
203207
// Enables use of MoveInLineOfSight
204208
bool IsVisible(Unit* who) const override
205209
{
@@ -237,7 +241,7 @@ struct ElunaCreatureAI : NativeScriptedAI
237241
NativeScriptedAI::SpellHitTarget(target, spell);
238242
}
239243

240-
#if defined ELUNA_TRINITY
244+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
241245
// Called when the creature is summoned successfully by other creature
242246
void IsSummonedBy(WorldObject* summoner) override
243247
{
@@ -266,7 +270,7 @@ struct ElunaCreatureAI : NativeScriptedAI
266270
}
267271
#endif
268272

269-
#if !defined ELUNA_TRINITY
273+
#if !defined ELUNA_TRINITY && !defined ELUNA_AZEROTHCORE
270274
#undef me
271275
#endif
272276
};

ElunaEventMgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#endif
1919
#include <map>
2020

21-
#if defined ELUNA_TRINITY
21+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
2222
#include "Define.h"
2323
#else
2424
#include "Platform/Define.h"

ElunaIncludes.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
#include "GuildMgr.h"
2727
#include "Language.h"
2828
#include "Mail.h"
29+
#if defined ELUNA_AZEROTHCORE
30+
#include "MapMgr.h"
31+
#else
2932
#include "MapManager.h"
33+
#endif
3034
#include "ObjectAccessor.h"
3135
#include "ObjectMgr.h"
3236
#include "Opcodes.h"
@@ -40,7 +44,7 @@
4044
#include "TemporarySummon.h"
4145
#include "WorldPacket.h"
4246
#include "WorldSession.h"
43-
#if defined ELUNA_TRINITY
47+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
4448
#include "Battleground.h"
4549
#include "Config.h"
4650
#include "DatabaseEnv.h"
@@ -49,7 +53,12 @@
4953
#include "MiscPackets.h"
5054
#include "MotionMaster.h"
5155
#include "ScriptedCreature.h"
56+
#if defined ELUNA_TRINITY
5257
#include "SpellHistory.h"
58+
#endif
59+
#if defined ELUNA_AZEROTHCORE
60+
#include "WorldSessionMgr.h"
61+
#endif
5362
#include "SpellInfo.h"
5463
#include "WeatherMgr.h"
5564
#elif defined ELUNA_VMANGOS
@@ -109,7 +118,7 @@
109118
#endif
110119
#endif
111120

112-
#if !defined ELUNA_TRINITY
121+
#if !defined ELUNA_TRINITY && !defined ELUNA_AZEROTHCORE
113122
#include "Config/Config.h"
114123
#include "BattleGroundMgr.h"
115124
#if !defined ELUNA_MANGOS
@@ -154,13 +163,25 @@ typedef Opcodes OpcodesList;
154163
#define REGEN_TIME_FULL
155164
#endif
156165

157-
#if defined ELUNA_TRINITY
166+
#if defined ELUNA_AZEROTHCORE
167+
#define CORE_NAME "AzerothCore"
168+
#define REGEN_TIME_FULL
169+
#endif
170+
171+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
158172
#define CORE_VERSION (GitRevision::GetFullVersion())
159173
#define eWorld (sWorld)
174+
#if defined ELUNA_AZEROTHCORE
175+
#define eWorldSessionMgr (sWorldSessionMgr)
176+
#endif
160177
#define eMapMgr (sMapMgr)
161178
#define eGuildMgr (sGuildMgr)
162179
#define eObjectMgr (sObjectMgr)
180+
#if defined ELUNA_AZEROTHCORE
181+
#define eAccountMgr() AccountMgr::
182+
#else
163183
#define eAccountMgr (sAccountMgr)
184+
#endif
164185
#define eAuctionMgr (sAuctionMgr)
165186
#define eGameEventMgr (sGameEventMgr)
166187
#define eObjectAccessor() ObjectAccessor::

ElunaInstanceAI.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define _ELUNA_INSTANCE_DATA_H
99

1010
#include "LuaEngine.h"
11-
#if defined ELUNA_TRINITY
11+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
1212
#include "InstanceScript.h"
1313
#include "Map.h"
1414
#elif defined ELUNA_CMANGOS
@@ -82,7 +82,7 @@ class ElunaInstanceAI : public InstanceData
8282
* data table to/from the core.
8383
*/
8484
void Load(const char* data) override;
85-
#if defined ELUNA_TRINITY
85+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
8686
// Simply calls Save, since the functions are a bit different in name and data types on different cores
8787
std::string GetSaveData() override
8888
{
@@ -148,7 +148,7 @@ class ElunaInstanceAI : public InstanceData
148148
instance->GetEluna()->OnPlayerEnterInstance(this, player);
149149
}
150150

151-
#if defined ELUNA_TRINITY
151+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
152152
void OnGameObjectCreate(GameObject* gameobject) override
153153
#else
154154
void OnObjectCreate(GameObject* gameobject) override

ElunaLoader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,14 @@ void ElunaLoader::ReloadElunaForMap(int mapId)
356356
if (mapId != RELOAD_CACHE_ONLY)
357357
{
358358
if (mapId == RELOAD_GLOBAL_STATE || mapId == RELOAD_ALL_STATES)
359-
#if defined ELUNA_TRINITY
359+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
360360
if (Eluna* e = sWorld->GetEluna())
361361
#else
362362
if (Eluna* e = sWorld.GetEluna())
363363
#endif
364364
e->ReloadEluna();
365365

366-
#if defined ELUNA_TRINITY
366+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
367367
sMapMgr->DoForAllMaps([&](Map* map)
368368
#else
369369
sMapMgr.DoForAllMaps([&](Map* map)

ElunaUtility.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
uint32 ElunaUtil::GetCurrTime()
2424
{
25-
#if defined ELUNA_TRINITY || ELUNA_MANGOS
25+
#if defined ELUNA_TRINITY || defined ELUNA_MANGOS || defined ELUNA_AZEROTHCORE
2626
return getMSTime();
2727
#else
2828
return WorldTimer::getMSTime();
@@ -31,7 +31,7 @@ uint32 ElunaUtil::GetCurrTime()
3131

3232
uint32 ElunaUtil::GetTimeDiff(uint32 oldMSTime)
3333
{
34-
#if defined ELUNA_TRINITY || ELUNA_MANGOS
34+
#if defined ELUNA_TRINITY || defined ELUNA_MANGOS || defined ELUNA_AZEROTHCORE
3535
return GetMSTimeDiffToNow(oldMSTime);
3636
#else
3737
return WorldTimer::getMSTimeDiff(oldMSTime, WorldTimer::getMSTime());

ElunaUtility.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "SharedDefines.h"
1919
#include "ObjectGuid.h"
2020
#include "Log.h"
21-
#if defined ELUNA_TRINITY
21+
#if defined ELUNA_TRINITY
2222
#include "QueryResult.h"
2323
#else
2424
#include "Database/QueryResult.h"
@@ -35,14 +35,18 @@
3535
#include <mutex>
3636
#include <memory>
3737

38-
#if defined ELUNA_TRINITY || ELUNA_CMANGOS
38+
#if defined ELUNA_TRINITY || ELUNA_CMANGOS || ELUNA_AZEROTHCORE
3939
#define USING_BOOST
4040
#endif
4141

4242
#if defined TRINITY_PLATFORM && defined TRINITY_PLATFORM_WINDOWS
4343
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
4444
#define ELUNA_WINDOWS
4545
#endif
46+
#elif defined AC_PLATFORM && defined AC_PLATFORM_WINDOWS
47+
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
48+
#define ELUNA_WINDOWS
49+
#endif
4650
#elif defined PLATFORM && defined PLATFORM_WINDOWS
4751
#if PLATFORM == PLATFORM_WINDOWS
4852
#define ELUNA_WINDOWS
@@ -51,7 +55,7 @@
5155
#error Eluna could not determine platform
5256
#endif
5357

54-
#if defined ELUNA_TRINITY
58+
#if defined ELUNA_TRINITY || ELUNA_AZEROTHCORE
5559
typedef QueryResult ElunaQuery;
5660
#define GET_GUID GetGUID
5761
#define HIGHGUID_PLAYER HighGuid::Player
@@ -81,6 +85,18 @@ typedef QueryResult ElunaQuery;
8185
#define ELUNA_LOG_INFO(...) ELUNA_LOG_TC_FMT(TC_LOG_INFO, __VA_ARGS__);
8286
#define ELUNA_LOG_ERROR(...) ELUNA_LOG_TC_FMT(TC_LOG_ERROR, __VA_ARGS__);
8387
#define ELUNA_LOG_DEBUG(...) ELUNA_LOG_TC_FMT(TC_LOG_DEBUG, __VA_ARGS__);
88+
#elif defined ELUNA_AZEROTHCORE
89+
#include "fmt/printf.h"
90+
#define ELUNA_LOG_AC_FMT(AC_LOG_MACRO, ...) \
91+
try { \
92+
std::string message = fmt::sprintf(__VA_ARGS__); \
93+
AC_LOG_MACRO("eluna", "{}", message); \
94+
} catch (const std::exception& e) { \
95+
AC_LOG_MACRO("eluna", "Failed to format log message: {}", e.what()); \
96+
}
97+
#define ELUNA_LOG_INFO(...) ELUNA_LOG_AC_FMT(LOG_INFO, __VA_ARGS__);
98+
#define ELUNA_LOG_ERROR(...) ELUNA_LOG_AC_FMT(LOG_ERROR, __VA_ARGS__);
99+
#define ELUNA_LOG_DEBUG(...) ELUNA_LOG_AC_FMT(LOG_DEBUG, __VA_ARGS__);
84100
#elif defined ELUNA_VMANGOS
85101
typedef std::shared_ptr<QueryNamedResult> ElunaQuery;
86102
#define ASSERT MANGOS_ASSERT

LuaEngine.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ class SpellCastTargets;
5959
class Unit;
6060
class Weather;
6161
class WorldPacket;
62+
#if !defined ELUNA_AZEROTHCORE
6263
struct AreaTriggerEntry;
64+
#endif
6365
struct AuctionEntry;
6466

65-
#if defined ELUNA_TRINITY
67+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
6668
class Battleground;
6769
class GameObjectAI;
6870
class InstanceScript;
@@ -72,6 +74,9 @@ struct ItemTemplate;
7274
typedef Battleground BattleGround;
7375
typedef BattlegroundTypeId BattleGroundTypeId;
7476
typedef InstanceScript InstanceData;
77+
#if defined ELUNA_AZEROTHCORE
78+
typedef AreaTrigger AreaTriggerEntry;
79+
#endif
7580
#else
7681
class InstanceData;
7782
struct ItemPrototype;
@@ -141,6 +146,8 @@ enum MethodFlags : uint32
141146
#if defined ELUNA_TRINITY
142147
#define ELUNA_GAME_API TC_GAME_API
143148
#define TRACKABLE_PTR_NAMESPACE ::Trinity::
149+
#elif defined ELUNA_AZEROTHCORE
150+
#define ELUNA_GAME_API AC_GAME_API
144151
#else
145152
#define ELUNA_GAME_API
146153
#if defined ELUNA_CMANGOS
@@ -246,15 +253,15 @@ class ELUNA_GAME_API Eluna
246253
template<typename T>
247254
void HookPush(T const* ptr) { Push(ptr); ++push_counter; }
248255

249-
#if defined ELUNA_TRINITY
256+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
250257
QueryCallbackProcessor queryProcessor;
251258
#endif
252259
public:
253260

254261
lua_State* L;
255262
std::unique_ptr<EventMgr> eventMgr;
256263

257-
#if defined ELUNA_TRINITY
264+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
258265
QueryCallbackProcessor& GetQueryProcessor() { return queryProcessor; }
259266
#endif
260267

hooks/CreatureHooks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ bool Eluna::SpellHitTarget(Creature* me, WorldObject* target, SpellInfo const* s
299299
return CallAllFunctionsBool(CreatureEventBindings, CreatureUniqueBindings, entry_key, unique_key);
300300
}
301301

302-
#if defined ELUNA_TRINITY
302+
#if defined ELUNA_TRINITY || defined ELUNA_AZEROTHCORE
303303

304304
bool Eluna::SummonedCreatureDies(Creature* me, Creature* summon, Unit* killer)
305305
{

0 commit comments

Comments
 (0)