persistent sleep

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6373 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lucas GAUTHERON
2011-04-27 14:44:35 +00:00
parent e5653c52e2
commit 29f817d608
4 changed files with 23 additions and 10 deletions
+2
View File
@@ -138,7 +138,9 @@ docargument [B] [the upper limit of the random value] [] [0];
docident [sleep] [Executes a command after specified time period.];
docargument [N] [the amount of milliseconds] [] [0];
docargument [C] [the command to execute] [] [0];
docargument [P] [ignore map reset] [] [0];
docexample [sleep 1000 [ echo foo ]] [Prints 'foo' to the screen after 1 second.];
docident [resetsleep] [Reset all current sleeps];
docident [strcmp] [Determines if two strings are equal.];
docargument [A] [the first string] [] [0];
docargument [B] [the second string] [] [0];
+1
View File
@@ -662,6 +662,7 @@
<arguments>
<argument token="N" description="the amount of milliseconds"/>
<argument token="C" description="the command to execute"/>
<argument token="P" description="ignore map change (optionnal)"/>
</arguments>
</command>
+18 -8
View File
@@ -530,29 +530,39 @@ void showrespawntimer()
}
}
struct scriptsleep { int wait, millis; char *cmd; };
struct scriptsleep { int wait, millis; char *cmd; bool persist; };
vector<scriptsleep> sleeps;
void addsleep(int msec, const char *cmd)
void addsleep(int msec, const char *cmd, bool persist)
{
scriptsleep &s = sleeps.add();
s.wait = max(msec, 1);
s.millis = lastmillis;
s.cmd = newstring(cmd);
s.persist = persist;
}
void addsleep_(char *msec, char *cmd)
void addsleep_(char *msec, char *cmd, char *persist)
{
addsleep(atoi(msec), cmd);
addsleep(atoi(msec), cmd, atoi(persist) != 0);
}
void resetsleep()
void resetsleep(bool force)
{
loopv(sleeps) DELETEA(sleeps[i].cmd);
sleeps.shrink(0);
loopv(sleeps) if(!sleeps[i].persist || force)
{
DELETEA(sleeps[i].cmd);
sleeps.remove(i);
}
}
COMMANDN(sleep, addsleep_, ARG_2STR);
void resetsleep_()
{
resetsleep(true);
}
COMMANDN(sleep, addsleep_, ARG_3STR);
COMMANDN(resetsleeps, resetsleep_, ARG_NONE);
void updateworld(int curtime, int lastmillis) // main game update loop
{
+2 -2
View File
@@ -387,8 +387,8 @@ extern void timeupdate(int milliscur, int millismax); // was (int timeremain);
extern void respawnself();
extern void setskin(playerent *pl, int skin, int team = -1);
extern void callvote(int type, char *arg1 = NULL, char *arg2 = NULL);
extern void addsleep(int msec, const char *cmd);
extern void resetsleep();
extern void addsleep(int msec, const char *cmd, bool persist = false);
extern void resetsleep(bool force = false);
//game mode extras
extern void flagpickup(int fln);
extern void tryflagdrop(bool manual = false);