Add missing files from e54eeae

This commit is contained in:
Simon Robertshaw 2012-08-21 12:27:13 +01:00
parent 4b8ebe4abd
commit 7b8647cf15
3 changed files with 10 additions and 8 deletions

View File

@ -302,7 +302,7 @@ bool LuaScriptInterface::OnKeyRelease(int key, Uint16 character, bool shift, boo
void LuaScriptInterface::OnTick() void LuaScriptInterface::OnTick()
{ {
LoopTime = clock(); ui::Engine::Ref().LastTick(clock());
if(luacon_mousedown) if(luacon_mousedown)
luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS, 0); 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); 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; int ret;
lastError = ""; lastError = "";
currentCommand = true; currentCommand = true;
LoopTime = clock(); ui::Engine::Ref().LastTick(clock());
if((ret = luaL_dostring(l, command.c_str()))) if((ret = luaL_dostring(l, command.c_str())))
{ {
lastError = luacon_geterror(); 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")) 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_pushcfunction(luacon_ci->l, &luatpt_unregister_step);
lua_rawgeti(luacon_ci->l, LUA_REGISTRYINDEX, step_functions[i]); lua_rawgeti(luacon_ci->l, LUA_REGISTRYINDEX, step_functions[i]);
lua_pcall(luacon_ci->l, 1, 0, 0); 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){ int luacon_eval(char *command){
luacon_ci->LoopTime = clock(); ui::Engine::Ref().LastTick(clock());
return luaL_dostring (luacon_ci->l, command); return luaL_dostring (luacon_ci->l, command);
} }
void luacon_hook(lua_State * l, lua_Debug * ar) 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")) 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"); luaL_error(l, "Error: Script not responding");
luacon_ci->LoopTime = clock(); ui::Engine::Ref().LastTick(clock());
} }
} }

View File

@ -40,7 +40,6 @@ class LuaScriptInterface: public CommandInterface {
bool currentCommand; bool currentCommand;
TPTScriptInterface * legacy; TPTScriptInterface * legacy;
public: public:
int LoopTime;
lua_State *l; lua_State *l;
LuaScriptInterface(GameModel * m); LuaScriptInterface(GameModel * m);
virtual bool OnBrushChanged(int brushType, int rx, int ry); virtual bool OnBrushChanged(int brushType, int rx, int ry);

View File

@ -1,6 +1,7 @@
#include <iostream> #include <iostream>
#include <stack> #include <stack>
#include <cstdio> #include <cstdio>
#include <time.h>
#include "Config.h" #include "Config.h"
#include "interface/Window.h" #include "interface/Window.h"
@ -25,7 +26,8 @@ Engine::Engine():
FrameIndex(0), FrameIndex(0),
Fullscreen(false), Fullscreen(false),
Scale(1), Scale(1),
break_(false) break_(false),
lastTick(0)
{ {
} }
@ -152,6 +154,7 @@ void Engine::Tick()
state_->DoTick(dt); state_->DoTick(dt);
lastTick = clock();
if(windowOpenState<1.0f) if(windowOpenState<1.0f)
{ {
if(lastBuffer) if(lastBuffer)