summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-21 11:27:13 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-21 11:27:13 (GMT)
commit7b8647cf152f575dd9a210b9d8b6ca5aebe388e8 (patch)
tree21acd82ada23ae310805026bf9d09e5b6b595417 /src
parent4b8ebe4abd98d65c97cf1dbd571d448f53669bc3 (diff)
downloadpowder-7b8647cf152f575dd9a210b9d8b6ca5aebe388e8.zip
powder-7b8647cf152f575dd9a210b9d8b6ca5aebe388e8.tar.gz
Add missing files from e54eeae
Diffstat (limited to 'src')
-rw-r--r--src/cat/LuaScriptInterface.cpp12
-rw-r--r--src/cat/LuaScriptInterface.h1
-rw-r--r--src/interface/Engine.cpp5
3 files changed, 10 insertions, 8 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index 95573a0..9d563a8 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 8c3e33e..44ad279 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 0d709e6..1a8ad95 100644
--- a/src/interface/Engine.cpp
+++ b/src/interface/Engine.cpp
@@ -1,6 +1,7 @@
#include <iostream>
#include <stack>
#include <cstdio>
+#include <time.h>
#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)