Ejemplo n.º 1
0
void CLuaMain::InstructionCountHook(lua_State* luaVM, lua_Debug* pDebug)
{
    // Grab our lua VM
    CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
    if (pLuaMain)
    {
        // Above max time?
        if (pLuaMain->m_FunctionEnterTimer.Get() > HOOK_MAXIMUM_TIME)
        {
            // Print it in the console
            CLogger::ErrorPrintf("Infinite/too long execution (%s)", pLuaMain->GetScriptName());

            SString strAbortInf = "Aborting; infinite running script in ";
            strAbortInf += pLuaMain->GetScriptName();

            // Error out
            lua_pushstring(luaVM, strAbortInf);
            lua_error(luaVM);
        }
    }
}
Ejemplo n.º 2
0
// Helper function
static const char* GetResourceName ( lua_State* luaVM )
{
    CLuaMain * luaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
    return luaMain ? luaMain->GetScriptName () : "";
}