From 801d68e2081df0e3590edef2764db5fff0353279 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Wed, 30 Dec 2009 15:02:18 +0000 Subject: [PATCH] sleep overflow fix git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4749 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 12bce3c7..87e7484a 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -423,13 +423,14 @@ void showrespawntimer() } } -struct scriptsleep { int wait; char *cmd; }; +struct scriptsleep { int wait, millis; char *cmd; }; vector sleeps; void addsleep(int msec, const char *cmd) { scriptsleep &s = sleeps.add(); - s.wait = msec+lastmillis; + s.wait = max(msec, 1); + s.millis = lastmillis; s.cmd = newstring(cmd); } @@ -451,7 +452,7 @@ void updateworld(int curtime, int lastmillis) // main game update loop // process command sleeps loopv(sleeps) { - if(sleeps[i].wait && lastmillis > sleeps[i].wait) + if(lastmillis - sleeps[i].millis >= sleeps[i].wait) { char *cmd = sleeps[i].cmd; sleeps[i].cmd = NULL;