-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstants.cpp
More file actions
67 lines (58 loc) · 2.55 KB
/
Constants.cpp
File metadata and controls
67 lines (58 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU Lesser General Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
#include "Game.h"
#include "expansion/Level.h"
namespace Expansion::Constants {
namespace {
// Expansion-level enum values shipped by retail / Classic Era WoW. Addons
// backporting from later expansions often gate code on
// `LE_EXPANSION_LEVEL_CURRENT` or compare specific `LE_EXPANSION_*`
// constants — we ship the full table so those gates compile cleanly on
// 1.12 and resolve to the right branch (`< LE_EXPANSION_BURNING_CRUSADE`
// is always true here).
//
// Values match the canonical retail enum (`Enum.ExpansionLevel` in
// modern Lua). `LE_EXPANSION_LEVEL_CURRENT` is the live client's
// expansion — `LE_EXPANSION_CLASSIC` (0) for us, since we're 1.12.
struct ExpansionConstant {
const char *name;
int value;
};
constexpr ExpansionConstant kExpansionConstants[] = {
{"LE_EXPANSION_CLASSIC", 0},
{"LE_EXPANSION_BURNING_CRUSADE", 1},
{"LE_EXPANSION_WRATH_OF_THE_LICH_KING", 2},
{"LE_EXPANSION_CATACLYSM", 3},
{"LE_EXPANSION_MISTS_OF_PANDARIA", 4},
{"LE_EXPANSION_WARLORDS_OF_DRAENOR", 5},
{"LE_EXPANSION_LEGION", 6},
{"LE_EXPANSION_BATTLE_FOR_AZEROTH", 7},
{"LE_EXPANSION_SHADOWLANDS", 8},
{"LE_EXPANSION_DRAGONFLIGHT", 9},
{"LE_EXPANSION_WAR_WITHIN", 10},
{"LE_EXPANSION_MIDNIGHT", 11},
{"LE_EXPANSION_LEVEL_CURRENT", Expansion::kCurrentExpansionLevel},
};
} // namespace
static void RegisterLuaFunctions() {
void *L = Game::Lua::State();
if (L == nullptr)
return;
for (const auto &c : kExpansionConstants) {
Game::Lua::PushString(L, c.name);
Game::Lua::PushNumber(L, static_cast<double>(c.value));
Game::Lua::SetTable(L, Game::Lua::GLOBALS_INDEX);
}
}
static const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};
} // namespace Expansion::Constants