Skip to content

Commit 8e8cf20

Browse files
authored
Remove compatibility mode & Custom methods redesign (#510)
* Remove compatibility mode * Change to custom method implementation If you already use the custom methods feature, copy your CustomMethods header file to methods/Custom, re-run cmake and recompile. It should then work like before. The Custom directory will never be changed and should not cause any future merge conflicts
1 parent ddd5736 commit 8e8cf20

File tree

13 files changed

+41
-120
lines changed

13 files changed

+41
-120
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
set(CUSTOM_METHODS_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/methods/Custom/CustomMethods.h")
2+
if(EXISTS "${CUSTOM_METHODS_HEADER}")
3+
target_compile_definitions(lualib PUBLIC ELUNA_USE_CUSTOM_METHODS)
4+
endif()
5+
16
# Define variables for paths
27
set(MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/modules")
38
if(UNIX)

ElunaConfig.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ void ElunaConfig::Initialize()
2929
{
3030
// Load bools
3131
SetConfig(CONFIG_ELUNA_ENABLED, "Eluna.Enabled", true);
32-
SetConfig(CONFIG_ELUNA_COMPATIBILITY_MODE, "Eluna.CompatibilityMode", false);
3332
SetConfig(CONFIG_ELUNA_TRACEBACK, "Eluna.TraceBack", false);
3433
SetConfig(CONFIG_ELUNA_SCRIPT_RELOADER, "Eluna.ScriptReloader", false);
3534

@@ -68,11 +67,6 @@ bool ElunaConfig::IsElunaEnabled()
6867
return GetConfig(CONFIG_ELUNA_ENABLED);
6968
}
7069

71-
bool ElunaConfig::IsElunaCompatibilityMode()
72-
{
73-
return GetConfig(CONFIG_ELUNA_COMPATIBILITY_MODE);
74-
}
75-
7670
bool ElunaConfig::ShouldMapLoadEluna(uint32 id)
7771
{
7872
// if the set is empty (all maps), return true

ElunaConfig.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
enum ElunaConfigBoolValues
1313
{
1414
CONFIG_ELUNA_ENABLED,
15-
CONFIG_ELUNA_COMPATIBILITY_MODE,
1615
CONFIG_ELUNA_TRACEBACK,
1716
CONFIG_ELUNA_SCRIPT_RELOADER,
1817
CONFIG_ELUNA_BOOL_COUNT
@@ -46,7 +45,6 @@ class ElunaConfig
4645
void SetConfig(ElunaConfigStringValues index, std::string value) { _configStringValues[index] = value; }
4746

4847
bool IsElunaEnabled();
49-
bool IsElunaCompatibilityMode();
5048
bool ShouldMapLoadEluna(uint32 mapId);
5149

5250
private:

ElunaTemplate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class ElunaTemplate
325325
}
326326

327327
// if we're in multistate mode, we need to check whether a method is flagged as a world or a map specific method
328-
if (!E->GetCompatibilityMode() && method->regState != METHOD_REG_ALL)
328+
if (method->regState != METHOD_REG_ALL)
329329
{
330330
int32 mapId = E->GetBoundMapId();
331331

LuaEngine.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ void Eluna::_ReloadEluna()
4646
reload = false;
4747
}
4848

49-
Eluna::Eluna(Map* map, bool compatMode) :
49+
Eluna::Eluna(Map* map) :
5050
event_level(0),
5151
push_counter(0),
5252
boundMap(map),
53-
compatibilityMode(compatMode),
5453

5554
L(NULL),
5655
eventMgr(NULL),
@@ -264,15 +263,11 @@ void Eluna::RunScripts()
264263

265264
for (auto it = scripts.begin(); it != scripts.end(); ++it)
266265
{
267-
// if the Eluna state is in compatibility mode, it should load all scripts, including those tagged with a specific map ID
268-
if (!GetCompatibilityMode())
266+
// check that the script file is either global or meant to be loaded for this map
267+
if (it->mapId != -1 && it->mapId != boundMapId)
269268
{
270-
// check that the script file is either global or meant to be loaded for this map
271-
if (it->mapId != -1 && it->mapId != boundMapId)
272-
{
273-
ELUNA_LOG_DEBUG("[Eluna]: `%s` is tagged %i and will not load for map: %i", it->filename.c_str(), it->mapId, boundMapId);
274-
continue;
275-
}
269+
ELUNA_LOG_DEBUG("[Eluna]: `%s` is tagged %i and will not load for map: %i", it->filename.c_str(), it->mapId, boundMapId);
270+
continue;
276271
}
277272

278273
// Check that no duplicate names exist

LuaEngine.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ class ELUNA_GAME_API Eluna
171171

172172
Map* const boundMap;
173173

174-
// Whether or not Eluna is in compatibility mode. Used in some method wrappers.
175-
bool compatibilityMode;
176-
177174
// Map from instance ID -> Lua table ref
178175
std::unordered_map<uint32, int> instanceDataRefs;
179176
// Map from map ID -> Lua table ref
@@ -370,9 +367,7 @@ class ELUNA_GAME_API Eluna
370367
return 0;
371368
}
372369

373-
bool GetCompatibilityMode() const { return compatibilityMode; }
374-
375-
Eluna(Map * map, bool compatMode = false);
370+
Eluna(Map * map);
376371
~Eluna();
377372

378373
// Prevent copy

methods/CMangos/CustomMethods.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

methods/CustomMethodsInterface.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (C) 2010 - 2025 Eluna Lua Engine <https://elunaluaengine.github.io/>
3+
* This program is free software licensed under GPL version 3
4+
* Please see the included DOCS/LICENSE.md for more information
5+
*/
6+
7+
#ifndef CUSTOMMETHODSINT_H
8+
#define CUSTOMMETHODSINT_H
9+
10+
#ifdef ELUNA_USE_CUSTOM_METHODS
11+
#include "CustomMethods.h"
12+
#else
13+
namespace LuaCustom
14+
{
15+
inline void RegisterCustomMethods([[maybe_unused]] Eluna* E) {}
16+
}
17+
#endif
18+
19+
#endif

methods/Mangos/CustomMethods.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

methods/Methods.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
#include "CorpseMethods.h"
3232
#include "VehicleMethods.h"
3333
#include "BattleGroundMethods.h"
34-
35-
// Custom methods
36-
#include "CustomMethods.h"
34+
#include "CustomMethodsInterface.h"
3735

3836
void RegisterMethods(Eluna* E)
3937
{
@@ -115,7 +113,6 @@ void RegisterMethods(Eluna* E)
115113

116114
ElunaTemplate<ObjectGuid>::Register(E, "ObjectGuid");
117115

118-
// Register custom methods
119116
LuaCustom::RegisterCustomMethods(E);
120117

121118
LuaVal::Register(E->L);

0 commit comments

Comments
 (0)