mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user