refactor(lua): share the engine's flag readers as Game::Lua::ToFlag and Game::StringToFlag

Twenty modules each declared their own typedef or wrapper for
FUN_LUA_TO_BOOLEAN_LOOSE (4.3.4's StringToBOOL(L, index, default)) or
FUN_XML_ATTR_TO_BOOL (StringToBOOL(const char *)). Route them all
through one helper each.

frame/Cooldown.cpp had a C++ copy of both that read unknown attribute
text as true; the engine's reader, which 4.3.4's XML loader uses, reads
it as false. SetReverse/SetDrawEdge now also truncate numbers like
every other 1.12 flag method.
This commit is contained in:
Brues
2026-10-23 01:15:38 -05:00
parent ce4f80518f
commit 165ccf3e9c
23 changed files with 66 additions and 120 deletions
+1 -2
View File
@@ -64,11 +64,10 @@ Kind KindOf(const char *type) {
}
void Push(void *L, Kind kind, const char *text) {
using ToBool_t = int(__fastcall *)(const char *);
using ToFloat_t = float(__stdcall *)(const char *);
switch (kind) {
case Kind::Boolean:
Game::Lua::PushBool(L, reinterpret_cast<ToBool_t>(Offsets::FUN_XML_ATTR_TO_BOOL)(text) != 0);
Game::Lua::PushBool(L, Game::StringToFlag(text));
break;
case Kind::Number:
Game::Lua::PushNumber(L, reinterpret_cast<ToFloat_t>(Offsets::FUN_SSTR_TO_FLOAT)(text));