mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 12:04:55 +02:00
change bot protection
This commit is contained in:
@@ -28,9 +28,11 @@
|
||||
|
||||
LuaInterface g_lua;
|
||||
|
||||
LuaInterface::LuaInterface() :
|
||||
L(NULL), m_weakTableRef(0)
|
||||
LuaInterface::LuaInterface()
|
||||
{
|
||||
L = nullptr;
|
||||
m_cppCallbackDepth = 0;
|
||||
m_weakTableRef = 0;
|
||||
}
|
||||
|
||||
LuaInterface::~LuaInterface()
|
||||
@@ -529,7 +531,9 @@ int LuaInterface::luaCppFunctionCallback(lua_State* L)
|
||||
|
||||
// do the call
|
||||
try {
|
||||
g_lua.m_cppCallbackDepth++;
|
||||
numRets = (*(funcPtr->get()))(&g_lua);
|
||||
g_lua.m_cppCallbackDepth--;
|
||||
assert(numRets == g_lua.stackSize());
|
||||
} catch(LuaException &e) {
|
||||
logError("lua cpp callback failed: ", e.what());
|
||||
|
@@ -181,6 +181,8 @@ public:
|
||||
template<typename R, typename... T>
|
||||
R callGlobalField(const std::string& global, const std::string& field, const T&... args);
|
||||
|
||||
bool isInCppCallback() { return m_cppCallbackDepth != 0; }
|
||||
|
||||
private:
|
||||
/// Load scripts requested by lua 'require'
|
||||
static int luaScriptLoader(lua_State* L);
|
||||
@@ -311,6 +313,7 @@ public:
|
||||
private:
|
||||
lua_State* L;
|
||||
int m_weakTableRef;
|
||||
int m_cppCallbackDepth;
|
||||
};
|
||||
|
||||
extern LuaInterface g_lua;
|
||||
|
@@ -785,6 +785,15 @@ void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
|
||||
m_loadingStyle = true;
|
||||
onStyleApply(styleNode->tag(), styleNode);
|
||||
callLuaField("onStyleApply", styleNode->tag(), styleNode);
|
||||
|
||||
if(m_firstOnStyle) {
|
||||
callLuaField("onSetup");
|
||||
// always focus new child
|
||||
if(isFocusable() && isExplicitlyVisible() && isExplicitlyEnabled())
|
||||
focus();
|
||||
}
|
||||
m_firstOnStyle = false;
|
||||
|
||||
m_loadingStyle = false;
|
||||
} catch(Exception& e) {
|
||||
logError("Failed to apply style to widget '", m_id, "' style: ", e.what());
|
||||
@@ -1156,15 +1165,6 @@ void UIWidget::onStyleApply(const std::string& styleName, const OTMLNodePtr& sty
|
||||
luaSetField(fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
if(m_firstOnStyle) {
|
||||
callLuaField("onSetup");
|
||||
// always focus new child
|
||||
if(isFocusable() && isExplicitlyVisible() && isExplicitlyEnabled())
|
||||
focus();
|
||||
}
|
||||
|
||||
m_firstOnStyle = false;
|
||||
}
|
||||
|
||||
void UIWidget::onGeometryChange(const Rect& oldRect, const Rect& newRect)
|
||||
|
Reference in New Issue
Block a user