From 7b8647cf152f575dd9a210b9d8b6ca5aebe388e8 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 21 Aug 2012 12:27:13 +0100 Subject: [PATCH] Add missing files from e54eeae --- src/cat/LuaScriptInterface.cpp | 12 ++++++------ src/cat/LuaScriptInterface.h | 1 - src/interface/Engine.cpp | 5 ++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 95573a0be..9d563a8e7 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -302,7 +302,7 @@ bool LuaScriptInterface::OnKeyRelease(int key, Uint16 character, bool shift, boo void LuaScriptInterface::OnTick() { - LoopTime = clock(); + ui::Engine::Ref().LastTick(clock()); if(luacon_mousedown) luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS, 0); luacon_step(luacon_mousex, luacon_mousey, luacon_selectedl, luacon_selectedr, luacon_brushx, luacon_brushy); @@ -322,7 +322,7 @@ int LuaScriptInterface::Command(std::string command) int ret; lastError = ""; currentCommand = true; - LoopTime = clock(); + ui::Engine::Ref().LastTick(clock()); if((ret = luaL_dostring(l, command.c_str()))) { lastError = luacon_geterror(); @@ -886,7 +886,7 @@ int luacon_step(int mx, int my, int selectl, int selectr, int bsx, int bsy){ { if (!strcmp(luacon_geterror(),"Error: Script not responding")) { - luacon_ci->LoopTime = clock(); + ui::Engine::Ref().LastTick(clock()); lua_pushcfunction(luacon_ci->l, &luatpt_unregister_step); lua_rawgeti(luacon_ci->l, LUA_REGISTRYINDEX, step_functions[i]); lua_pcall(luacon_ci->l, 1, 0, 0); @@ -900,17 +900,17 @@ int luacon_step(int mx, int my, int selectl, int selectr, int bsx, int bsy){ int luacon_eval(char *command){ - luacon_ci->LoopTime = clock(); + ui::Engine::Ref().LastTick(clock()); return luaL_dostring (luacon_ci->l, command); } void luacon_hook(lua_State * l, lua_Debug * ar) { - if(ar->event == LUA_HOOKCOUNT && clock()-luacon_ci->LoopTime > CLOCKS_PER_SEC*3) + if(ar->event == LUA_HOOKCOUNT && clock()-ui::Engine::Ref().LastTick() > CLOCKS_PER_SEC*3) { if(ConfirmPrompt::Blocking("Script not responding", "The Lua script may have stopped responding. There might be an infinite loop. Press \"Stop\" to stop it", "Stop")) luaL_error(l, "Error: Script not responding"); - luacon_ci->LoopTime = clock(); + ui::Engine::Ref().LastTick(clock()); } } diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h index 8c3e33eb7..44ad279eb 100644 --- a/src/cat/LuaScriptInterface.h +++ b/src/cat/LuaScriptInterface.h @@ -40,7 +40,6 @@ class LuaScriptInterface: public CommandInterface { bool currentCommand; TPTScriptInterface * legacy; public: - int LoopTime; lua_State *l; LuaScriptInterface(GameModel * m); virtual bool OnBrushChanged(int brushType, int rx, int ry); diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp index 0d709e680..1a8ad957a 100644 --- a/src/interface/Engine.cpp +++ b/src/interface/Engine.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "Config.h" #include "interface/Window.h" @@ -25,7 +26,8 @@ Engine::Engine(): FrameIndex(0), Fullscreen(false), Scale(1), - break_(false) + break_(false), + lastTick(0) { } @@ -152,6 +154,7 @@ void Engine::Tick() state_->DoTick(dt); + lastTick = clock(); if(windowOpenState<1.0f) { if(lastBuffer)