integrate paused and pausegame
parent
a4fc8d386f
commit
e3f271bc7c
|
@ -82,8 +82,8 @@ bind RCTRL "allowspedit"
|
|||
bind KP_MINUS "conskip 5"
|
||||
bind KP_PLUS "conskip -1000"
|
||||
|
||||
bindvar F1 paused
|
||||
bindvar PAUSE paused
|
||||
bindvarquiet F1 paused
|
||||
bindvarquiet PAUSE paused
|
||||
|
||||
bind F11 "toggleconsole"
|
||||
bind F12 "screenshot"
|
||||
|
|
|
@ -11,11 +11,17 @@ macro = [
|
|||
bindvar = [
|
||||
bind $arg1 [@arg2 (= $@arg2 0); if (= $@arg2 0) [echo @@arg2 OFF] [ echo @@arg2 ON]]
|
||||
]
|
||||
bindvarquiet = [
|
||||
bind $arg1 [@arg2 (= $@arg2 0)]
|
||||
]
|
||||
|
||||
// same as above, but only binds for edit mode
|
||||
editbindvar = [
|
||||
editbind $arg1 [@arg2 (= $@arg2 0); if (= $@arg2 0) [echo @@arg2 OFF] [ echo @@arg2 ON]]
|
||||
]
|
||||
editbindvarquiet = [
|
||||
editbind $arg1 [@arg2 (= $@arg2 0)]
|
||||
]
|
||||
|
||||
// binds a key so that it will set a modifier while held down
|
||||
bindmod = [
|
||||
|
|
|
@ -641,7 +641,7 @@ bool addcommand(const char *name, identfun fun, const char *args)
|
|||
for(const char *fmt = args; *fmt; fmt++) switch(*fmt)
|
||||
{
|
||||
case 'i': case 'b': case 'f': case 't': case 'N': case 'D': if(numargs < MAXARGS) numargs++; break;
|
||||
case 's': case 'e': case 'r': if(numargs < MAXARGS) { argmask |= 1<<numargs; numargs++; } break;
|
||||
case 's': case 'e': case 'r': case '$': if(numargs < MAXARGS) { argmask |= 1<<numargs; numargs++; } break;
|
||||
case '1': case '2': case '3': case '4': if(numargs < MAXARGS) fmt -= *fmt-'0'+1; break;
|
||||
case 'C': case 'V': limit = false; break;
|
||||
default: fatal("builtin %s declared with illegal type: %s", name, args); break;
|
||||
|
@ -854,10 +854,14 @@ static inline void compileblock(vector<uint> &code)
|
|||
code[start] |= uint(code.length() - (start + 1))<<8;
|
||||
}
|
||||
|
||||
static inline void compileident(vector<uint> &code, ident *id)
|
||||
{
|
||||
code.add((id->index < MAXARGS ? CODE_IDENTARG : CODE_IDENT)|(id->index<<8));
|
||||
}
|
||||
|
||||
static inline void compileident(vector<uint> &code, const char *word = NULL)
|
||||
{
|
||||
ident *id = word ? newident(word, IDF_UNKNOWN) : dummyident;
|
||||
code.add((id->index < MAXARGS ? CODE_IDENTARG : CODE_IDENT)|(id->index<<8));
|
||||
compileident(code, word ? newident(word, IDF_UNKNOWN) : dummyident);
|
||||
}
|
||||
|
||||
static inline void compileint(vector<uint> &code, const char *word = NULL)
|
||||
|
@ -943,18 +947,19 @@ static void compilelookup(vector<uint> &code, const char *&p, int ltype)
|
|||
case ID_ALIAS: code.add((id->index < MAXARGS ? CODE_LOOKUPARG : CODE_LOOKUP)|((ltype >= VAL_ANY ? VAL_STR : ltype)<<CODE_RET)|(id->index<<8)); goto done;
|
||||
case ID_COMMAND:
|
||||
{
|
||||
int comtype = CODE_COM, fakeargs = 0, numargs = 0;
|
||||
int comtype = CODE_COM, numargs = 0;
|
||||
code.add(CODE_ENTER);
|
||||
for(const char *fmt = id->args; *fmt; fmt++) switch(*fmt)
|
||||
{
|
||||
case 's': compilestr(code, NULL, 0, true); fakeargs++; numargs++; break;
|
||||
case 'i': compileint(code); fakeargs++; numargs++; break;
|
||||
case 'b': compileint(code, INT_MIN); fakeargs++; numargs++; break;
|
||||
case 'f': compilefloat(code); fakeargs++; numargs++; break;
|
||||
case 't': compilenull(code); fakeargs++; numargs++; break;
|
||||
case 'e': compileblock(code); fakeargs++; numargs++; break;
|
||||
case 'r': compileident(code); fakeargs++; numargs++; break;
|
||||
case 'N': compileint(code, numargs-fakeargs); numargs++; break;
|
||||
case 's': compilestr(code, NULL, 0, true); numargs++; break;
|
||||
case 'i': compileint(code); numargs++; break;
|
||||
case 'b': compileint(code, INT_MIN); numargs++; break;
|
||||
case 'f': compilefloat(code); numargs++; break;
|
||||
case 't': compilenull(code); numargs++; break;
|
||||
case 'e': compileblock(code); numargs++; break;
|
||||
case 'r': compileident(code); numargs++; break;
|
||||
case '$': compileident(code, id); numargs++; break;
|
||||
case 'N': compileint(code, -1); numargs++; break;
|
||||
#ifndef STANDALONE
|
||||
case 'D': comtype = CODE_COMD; numargs++; break;
|
||||
#endif
|
||||
|
@ -1296,6 +1301,7 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
|
|||
case 't': if(more) more = compilearg(code, p, VAL_ANY); if(!more) { if(rep) break; compilenull(code); fakeargs++; } numargs++; break;
|
||||
case 'e': if(more) more = compilearg(code, p, VAL_CODE); if(!more) { if(rep) break; compileblock(code); fakeargs++; } numargs++; break;
|
||||
case 'r': if(more) more = compilearg(code, p, VAL_IDENT); if(!more) { if(rep) break; compileident(code); fakeargs++; } numargs++; break;
|
||||
case '$': compileident(code, id); numargs++; break;
|
||||
case 'N': compileint(code, numargs-fakeargs); numargs++; break;
|
||||
#ifndef STANDALONE
|
||||
case 'D': comtype = CODE_COMD; numargs++; break;
|
||||
|
@ -1423,26 +1429,32 @@ void freecode(uint *code)
|
|||
}
|
||||
}
|
||||
|
||||
static void printvar(ident *id)
|
||||
void printvar(ident *id, int i)
|
||||
{
|
||||
if(i < 0) conoutf("%s = %d", id->name, i);
|
||||
else if(id->flags&IDF_HEX && id->maxval==0xFFFFFF)
|
||||
conoutf("%s = 0x%.6X (%d, %d, %d)", id->name, i, (i>>16)&0xFF, (i>>8)&0xFF, i&0xFF);
|
||||
else
|
||||
conoutf(id->flags&IDF_HEX ? "%s = 0x%X" : "%s = %d", id->name, i);
|
||||
}
|
||||
|
||||
void printfvar(ident *id, float f)
|
||||
{
|
||||
conoutf("%s = %s", id->name, floatstr(f));
|
||||
}
|
||||
|
||||
void printsvar(ident *id, const char *s)
|
||||
{
|
||||
conoutf(strchr(s, '"') ? "%s = [%s]" : "%s = \"%s\"", id->name, s);
|
||||
}
|
||||
|
||||
void printvar(ident *id)
|
||||
{
|
||||
switch(id->type)
|
||||
{
|
||||
case ID_VAR:
|
||||
{
|
||||
int i = *id->storage.i;
|
||||
if(i < 0) conoutf("%s = %d", id->name, i);
|
||||
else if(id->flags&IDF_HEX && id->maxval==0xFFFFFF)
|
||||
conoutf("%s = 0x%.6X (%d, %d, %d)", id->name, i, (i>>16)&0xFF, (i>>8)&0xFF, i&0xFF);
|
||||
else
|
||||
conoutf(id->flags&IDF_HEX ? "%s = 0x%X" : "%s = %d", id->name, i);
|
||||
break;
|
||||
}
|
||||
case ID_FVAR:
|
||||
conoutf("%s = %s", id->name, floatstr(*id->storage.f));
|
||||
break;
|
||||
case ID_SVAR:
|
||||
conoutf(strchr(*id->storage.s, '"') ? "%s = [%s]" : "%s = \"%s\"", id->name, *id->storage.s);
|
||||
break;
|
||||
case ID_VAR: printvar(id, *id->storage.i); break;
|
||||
case ID_FVAR: printfvar(id, *id->storage.f); break;
|
||||
case ID_SVAR: printsvar(id, *id->storage.s); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1523,6 +1535,7 @@ static inline void callcommand(ident *id, tagval *args, int numargs)
|
|||
}
|
||||
break;
|
||||
case 'r': if(++i >= numargs) { if(rep) break; args[i].setident(dummyident); fakeargs++; } else forceident(args[i]); break;
|
||||
case '$': if(++i < numargs) freearg(args[i]); args[i].setident(id); break;
|
||||
case 'N': if(++i < numargs) freearg(args[i]); args[i].setint(i-fakeargs); fakeargs++; break;
|
||||
#ifndef STANDALONE
|
||||
case 'D': if(++i < numargs) freearg(args[i]); args[i].setint(addreleaseaction(conc(args, i, true, id->name)) ? 1 : 0); fakeargs++; break;
|
||||
|
|
|
@ -883,8 +883,6 @@ void swapbuffers()
|
|||
|
||||
VARF(gamespeed, 10, 100, 1000, if(multiplayer()) gamespeed = 100);
|
||||
|
||||
VARF(paused, 0, 0, 1, if(multiplayer()) paused = 0);
|
||||
|
||||
VAR(menufps, 0, 60, 1000);
|
||||
VARP(maxfps, 0, 200, 1000);
|
||||
|
||||
|
@ -1240,7 +1238,7 @@ int main(int argc, char **argv)
|
|||
curtime = scaledtime/100;
|
||||
timeerr = scaledtime%100;
|
||||
if(curtime>200) curtime = 200;
|
||||
if(paused || game::ispaused()) curtime = 0;
|
||||
if(game::ispaused()) curtime = 0;
|
||||
}
|
||||
lastmillis += curtime;
|
||||
totalmillis = millis;
|
||||
|
|
|
@ -1149,7 +1149,6 @@ void resetmap()
|
|||
clearmapcrc();
|
||||
|
||||
setvar("gamespeed", 100, false);
|
||||
setvar("paused", 0, false);
|
||||
|
||||
entities::clearents();
|
||||
outsideents.setsize(0);
|
||||
|
|
|
@ -691,9 +691,17 @@ namespace game
|
|||
|
||||
void pausegame(int *val)
|
||||
{
|
||||
addmsg(N_PAUSEGAME, "ri", *val > 0 ? 1 : 0);
|
||||
if(!connected) return;
|
||||
if(!remote) server::forcepaused(*val > 0);
|
||||
else addmsg(N_PAUSEGAME, "ri", *val > 0 ? 1 : 0);
|
||||
}
|
||||
COMMAND(pausegame, "i");
|
||||
ICOMMAND(paused, "iN$", (int *val, int *numargs, ident *id),
|
||||
{
|
||||
if(*numargs > 0) pausegame(val);
|
||||
else if(*numargs < 0) intret(gamepaused ? 1 : 0);
|
||||
else printvar(id, gamepaused ? 1 : 0);
|
||||
});
|
||||
|
||||
bool ispaused() { return gamepaused; }
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace game
|
|||
|
||||
void respawnself()
|
||||
{
|
||||
if(paused || ispaused()) return;
|
||||
if(ispaused()) return;
|
||||
if(m_mp(gamemode))
|
||||
{
|
||||
if(player1->respawned!=player1->lifesequence)
|
||||
|
|
|
@ -776,6 +776,7 @@ namespace server
|
|||
extern void startintermission();
|
||||
extern void stopdemo();
|
||||
extern void forcemap(const char *map, int mode);
|
||||
extern void forcepaused(bool paused);
|
||||
extern void hashpassword(int cn, int sessionid, const char *pwd, char *result, int maxlen = MAXSTRLEN);
|
||||
extern int msgsizelookup(int msg);
|
||||
extern bool serveroption(const char *arg);
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace game
|
|||
g.poplist();
|
||||
}
|
||||
}
|
||||
if(paused || ispaused()) { g.separator(); g.text("paused", 0xFFFF80); }
|
||||
if(ispaused()) { g.separator(); g.text("paused", 0xFFFF80); }
|
||||
g.spring();
|
||||
g.poplist();
|
||||
|
||||
|
|
|
@ -1212,6 +1212,11 @@ namespace server
|
|||
if(!admins) pausegame(false);
|
||||
}
|
||||
|
||||
void forcepaused(bool paused)
|
||||
{
|
||||
pausegame(paused);
|
||||
}
|
||||
|
||||
SVAR(serverauth, "");
|
||||
|
||||
struct userkey
|
||||
|
|
|
@ -148,6 +148,10 @@ extern bool validateblock(const char *s);
|
|||
extern void explodelist(const char *s, vector<char *> &elems, int limit = -1);
|
||||
extern char *indexlist(const char *s, int pos);
|
||||
extern int listlen(const char *s);
|
||||
extern void printvar(ident *id);
|
||||
extern void printvar(ident *id, int i);
|
||||
extern void printfvar(ident *id, float f);
|
||||
extern void printsvar(ident *id, const char *s);
|
||||
|
||||
// console
|
||||
|
||||
|
|
Loading…
Reference in New Issue