mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 21:13:26 +02:00
Update otml and casts
Improve casts performance OTML can now understand value escaped sequences Use long instead of int for lua integer
This commit is contained in:
@@ -962,10 +962,10 @@ void LuaInterface::pop(int n)
|
||||
}
|
||||
}
|
||||
|
||||
int LuaInterface::popInteger()
|
||||
long LuaInterface::popInteger()
|
||||
{
|
||||
assert(hasIndex(-1));
|
||||
int v = toInteger(-1);
|
||||
long v = toInteger(-1);
|
||||
pop();
|
||||
return v;
|
||||
}
|
||||
@@ -1021,7 +1021,7 @@ void LuaInterface::pushNil()
|
||||
checkStack();
|
||||
}
|
||||
|
||||
void LuaInterface::pushInteger(int v)
|
||||
void LuaInterface::pushInteger(long v)
|
||||
{
|
||||
lua_pushinteger(L, v);
|
||||
checkStack();
|
||||
|
@@ -270,7 +270,7 @@ public:
|
||||
void* newUserdata(int size);
|
||||
|
||||
void pop(int n = 1);
|
||||
int popInteger();
|
||||
long popInteger();
|
||||
double popNumber();
|
||||
bool popBoolean();
|
||||
std::string popString();
|
||||
@@ -279,7 +279,7 @@ public:
|
||||
LuaObjectPtr popObject();
|
||||
|
||||
void pushNil();
|
||||
void pushInteger(int v);
|
||||
void pushInteger(long v);
|
||||
void pushNumber(double v);
|
||||
void pushBoolean(bool v);
|
||||
void pushCString(const char* v);
|
||||
|
@@ -112,13 +112,13 @@ bool luavalue_cast(int index, Color& color)
|
||||
{
|
||||
if(g_lua.isTable(index)) {
|
||||
g_lua.getField("r", index);
|
||||
color.setRed(g_lua.popInteger());
|
||||
color.setRed((int)g_lua.popInteger());
|
||||
g_lua.getField("g", index);
|
||||
color.setGreen(g_lua.popInteger());
|
||||
color.setGreen((int)g_lua.popInteger());
|
||||
g_lua.getField("b", index);
|
||||
color.setBlue(g_lua.popInteger());
|
||||
color.setBlue((int)g_lua.popInteger());
|
||||
g_lua.getField("a", index);
|
||||
color.setAlpha(g_lua.popInteger());
|
||||
color.setAlpha((int)g_lua.popInteger());
|
||||
return true;
|
||||
} else if(g_lua.isString()) {
|
||||
return stdext::cast(g_lua.toString(index), color);
|
||||
@@ -225,11 +225,20 @@ bool luavalue_cast(int index, Size& size)
|
||||
void push_otml_subnode_luavalue(const OTMLNodePtr& node)
|
||||
{
|
||||
if(node->hasValue()) {
|
||||
// convert boolean types
|
||||
if(node->value() == "true" || node->value() == "false")
|
||||
g_lua.pushBoolean(node->value<bool>());
|
||||
union {
|
||||
bool b;
|
||||
double d;
|
||||
long l;
|
||||
};
|
||||
std::string value = node->rawValue();
|
||||
if(stdext::cast(value, b))
|
||||
g_lua.pushBoolean(b);
|
||||
else if(stdext::cast(value, l))
|
||||
g_lua.pushInteger(l);
|
||||
else if(stdext::cast(value, d))
|
||||
g_lua.pushNumber(d);
|
||||
else
|
||||
g_lua.pushString(node->value());
|
||||
g_lua.pushString(value);
|
||||
} else if(node->hasChildren()) {
|
||||
g_lua.newTable();
|
||||
bool pushedChild = false;
|
||||
|
Reference in New Issue
Block a user