r2317 - in trunk/data: . qcsrc/common qcsrc/menu qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Apr 15 16:07:21 EDT 2007
Author: div0
Date: 2007-04-15 16:07:21 -0400 (Sun, 15 Apr 2007)
New Revision: 2317
Added:
trunk/data/qcsrc/common/gamecommand.qc
trunk/data/qcsrc/menu/gamecommand.qc
trunk/data/qcsrc/server/gamecommand.qc
Modified:
trunk/data/default.cfg
trunk/data/qcsrc/common/util.qh
trunk/data/qcsrc/menu/mbuiltin.qc
trunk/data/qcsrc/menu/menu.qc
trunk/data/qcsrc/menu/msys.qc
trunk/data/qcsrc/menu/progs.src
trunk/data/qcsrc/server/cl_weapons.qc
trunk/data/qcsrc/server/defs.qh
trunk/data/qcsrc/server/g_world.qc
trunk/data/qcsrc/server/miscfunctions.qc
trunk/data/qcsrc/server/progs.src
trunk/data/qcsrc/server/t_items.qc
Log:
now using DP_SV_CMD/DP_QC_CMD; removed cvar abuse by g_maplist_add etc. and changed them to real commands; fixed a fteqcc warning
Modified: trunk/data/default.cfg
===================================================================
--- trunk/data/default.cfg 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/default.cfg 2007-04-15 20:07:21 UTC (rev 2317)
@@ -213,10 +213,6 @@
seta g_maplist_index 0 // this is used internally for saving position in maplist cycle
seta g_maplist_selectrandom 0 // if 1, a random map will be chosen as next map - DEPRECATED in favor of g_maplist_shuffle
seta g_maplist_shuffle 0 // new randomization method: like selectrandom, but avoid playing the same maps in short succession. This works by taking out the first element and inserting it into g_maplist with a bias to the end of the list.
-alias g_maplist_shufflenow "set _g_maplist_shufflenow 1"
-alias g_maplist_add "set _g_maplist_add $1"
-alias g_maplist_remove "set _g_maplist_remove $1"
-alias g_maplist_putfirst "set _g_maplist_putfirst $1"
// timeout for kill credit when your damage knocks someone into a death trap
set g_maxpushtime 8.0
@@ -599,7 +595,6 @@
set g_balance_nixnex_ammoincr_cells 2
// score log
-alias printstats "set _printstats 1" // print status on demand
set sv_logscores_console 0 // print scores to server console
set sv_logscores_file 0 // print scores to file
set sv_logscores_filename scores.log // filename
@@ -648,8 +643,6 @@
seta cl_shownames 1 // show player names pointed to (0: never, 1: teamplay only, 2: always)
set sv_allow_shownames 1
-alias teamstatus "set _scoreboard 1"
-
con_chatwidth 0.6
con_chat 5
con_chatpos -7
@@ -707,3 +700,13 @@
alias "g_waypointsprite_toggle" "impulse 49"
// key for that?
seta cl_hidewaypoints 0
+
+// command extensions
+alias qc_cmd sv_cmd
+alias adminmsg "sv_cmd adminmsg $*"
+alias teamstatus "sv_cmd teamstatus"
+alias printstats "sv_cmd printstats" // print status on demand
+alias g_maplist_add "qc_cmd rpn /maps/$1.mapcfg fexists_assert /g_maplist g_maplist /$1 union def"
+alias g_maplist_remove "qc_cmd rpn /g_maplist g_maplist /$1 difference def"
+alias g_maplist_putfirst "qc_cmd rpn /maps/$1.mapcfg fexists_assert /g_maplist /$1 g_maplist union def"
+alias g_maplist_shufflenow "qc_cmd rpn /g_maplist g_maplist shuffle def"
Added: trunk/data/qcsrc/common/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/common/gamecommand.qc (rev 0)
+++ trunk/data/qcsrc/common/gamecommand.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -0,0 +1,253 @@
+#define MAX_RPN_STACK 8
+float rpn_error;
+float rpn_sp;
+string rpn_stack[MAX_RPN_STACK];
+string rpn_pop() {
+ if(rpn_sp > 0) {
+ --rpn_sp;
+ return rpn_stack[rpn_sp];
+ } else {
+ print("rpn: stack underflow\n");
+ rpn_error = TRUE;
+ return "";
+ }
+}
+void rpn_push(string s) {
+ if(rpn_sp < MAX_RPN_STACK) {
+ rpn_stack[rpn_sp] = s;
+ ++rpn_sp;
+ } else {
+ print("rpn: stack overflow\n");
+ rpn_error = TRUE;
+ }
+}
+string rpn_get() {
+ if(rpn_sp > 0) {
+ return rpn_stack[rpn_sp - 1];
+ } else {
+ print("rpn: empty stack\n");
+ rpn_error = TRUE;
+ return "";
+ }
+}
+void rpn_set(string s) {
+ if(rpn_sp > 0) {
+ rpn_stack[rpn_sp - 1] = s;
+ } else {
+ print("rpn: empty stack\n");
+ rpn_error = TRUE;
+ }
+}
+float rpn_getf() { return stof(rpn_get()); }
+float rpn_popf() { return stof(rpn_pop()); }
+void rpn_pushf(float f) { return rpn_push(ftos(f)); }
+void rpn_setf(float f) { return rpn_set(ftos(f)); }
+
+float GameCommand_Generic(string command)
+{
+ float argc;
+ argc = tokenize(command);
+ if(argv(0) == "help")
+ {
+ print(" rpn EXPRESSION... - a RPN calculator.\n");
+ print(" Operator description (x: string, s: set, f: float):\n");
+ print(" x pop -----------------------------> : removes the top\n");
+ print(" x dup -----------------------------> x x : duplicates the top\n");
+ print(" x x exch --------------------------> x x : swap the top two\n");
+ print(" /cvarname load --------------------> x : loads a cvar\n");
+ print(" /cvarname x def -------------------> : writes to a cvar\n");
+ print(" f f add|sub|mul|div|mod -----------> f : adds/... two numbers\n");
+ print(" f neg|abs|sgn|rand ----------------> f : negates/... a number\n");
+ print(" s s union|intersection|difference -> s : set operations\n");
+ print(" s shuffle -------------------------> s : randomly arrange elements\n");
+ print(" Set operations operate on 'such''strings' like g_maplist.\n");
+ print(" Unknown tokens insert their cvar value.\n");
+ return TRUE;
+ }
+
+ if(argv(0) == "rpn")
+ {
+ if(argc >= 2)
+ {
+ float rpnpos;
+ string rpncmd;
+ string s, s2;
+ float f, f2;
+ float i, j;
+ rpn_sp = 0;
+ rpn_error = FALSE;
+ for(rpnpos = 1; rpnpos < argc; ++rpnpos)
+ {
+ rpncmd = argv(rpnpos);
+ f = strlen(rpncmd);
+ if(rpncmd == "") {
+ } else if(stof(substring(rpncmd, 0, 1)) > 0) {
+ rpn_push(rpncmd);
+ } else if(substring(rpncmd, 0, 1) == "0") {
+ rpn_push(rpncmd);
+ } else if(f >= 2 && substring(rpncmd, 0, 1) == "+") {
+ rpn_push(rpncmd);
+ } else if(f >= 2 && substring(rpncmd, 0, 1) == "-") {
+ rpn_push(rpncmd);
+ } else if(f >= 2 && substring(rpncmd, 0, 1) == "/") {
+ rpn_push(substring(rpncmd, 1, strlen(rpncmd) - 1));
+ } else if(rpncmd == "def" || rpncmd == "=") {
+ s = rpn_pop();
+ s2 = rpn_pop();
+#ifdef MENUQC
+ registercvar(s2, "", 0);
+#else
+ registercvar(s2, "");
+#endif
+ if(!rpn_error) // don't change cvars if a stack error had happened!
+ cvar_set(s2, s);
+ } else if(rpncmd == "load") {
+ rpn_set(cvar_string(rpn_get()));
+ } else if(rpncmd == "exch") {
+ s = rpn_pop();
+ s2 = rpn_get();
+ rpn_set(s);
+ rpn_push(s2);
+ } else if(rpncmd == "dup") {
+ rpn_push(rpn_get());
+ } else if(rpncmd == "pop") {
+ rpn_pop();
+ } else if(rpncmd == "add" || rpncmd == "+") {
+ f = rpn_popf();
+ rpn_setf(rpn_getf() + f);
+ } else if(rpncmd == "sub" || rpncmd == "-") {
+ f = rpn_popf();
+ rpn_setf(rpn_getf() - f);
+ } else if(rpncmd == "mul" || rpncmd == "*") {
+ f = rpn_popf();
+ rpn_setf(rpn_getf() * f);
+ } else if(rpncmd == "div" || rpncmd == "/") {
+ f = rpn_popf();
+ rpn_setf(rpn_getf() / f);
+ } else if(rpncmd == "mod" || rpncmd == "%") {
+ f = rpn_popf();
+ f2 = rpn_getf();
+ rpn_setf(f2 - f * floor(f2 / f));
+ } else if(rpncmd == "abs") {
+ rpn_setf(fabs(rpn_getf()));
+ } else if(rpncmd == "sgn") {
+ f = rpn_getf();
+ if(f < 0)
+ rpn_set("-1");
+ else if(f > 0)
+ rpn_set("1");
+ else
+ rpn_set("0");
+ } else if(rpncmd == "neg" || rpncmd == "~") {
+ rpn_setf(-rpn_getf());
+ } else if(rpncmd == "rand") {
+ rpn_setf(ceil(random() * rpn_getf()) - 1);
+ } else if(rpncmd == "union") {
+ // s s2 union
+ s2 = rpn_pop();
+ s = rpn_get();
+ f = tokenize(s);
+ f2 = tokenize(strcat(s, s2));
+ // tokens 0..(f-1) represent s
+ // tokens f..f2 represent s2
+ // UNION: add all tokens to s that are in s2 but not in s
+ s = "";
+ for(i = 0; i < f; ++i)
+ s = strcat(s, "'", argv(i), "'");
+ for(i = f; i < f2; ++i) {
+ for(j = 0; j < f; ++j)
+ if(argv(i) == argv(j))
+ goto skip_union;
+ s = strcat(s, "'", argv(i), "'");
+:skip_union
+ }
+ rpn_set(s);
+ tokenize(command);
+ } else if(rpncmd == "intersection") {
+ // s s2 intersection
+ s2 = rpn_pop();
+ s = rpn_get();
+ f = tokenize(s);
+ f2 = tokenize(strcat(s, s2));
+ // tokens 0..(f-1) represent s
+ // tokens f..f2 represent s2
+ // INTERSECTION: keep only the tokens from s that are also in s2
+ s = "";
+ for(i = 0; i < f; ++i) {
+ for(j = f; j < f2; ++j)
+ if(argv(i) == argv(j))
+ {
+ s = strcat(s, "'", argv(i), "'");
+ break;
+ }
+ }
+ rpn_set(s);
+ tokenize(command);
+ } else if(rpncmd == "difference") {
+ // s s2 difference
+ s2 = rpn_pop();
+ s = rpn_get();
+ f = tokenize(s);
+ f2 = tokenize(strcat(s, s2));
+ // tokens 0..(f-1) represent s
+ // tokens f..f2 represent s2
+ // DIFFERENCE: keep only the tokens from s that are not in s2
+ s = "";
+ for(i = 0; i < f; ++i) {
+ for(j = f; j < f2; ++j)
+ if(argv(i) == argv(j))
+ goto skip_difference;
+ s = strcat(s, "'", argv(i), "'");
+:skip_difference
+ }
+ rpn_set(s);
+ tokenize(command);
+ } else if(rpncmd == "shuffle") {
+ // s shuffle
+ s = rpn_get();
+ f = tokenize(s);
+
+ for(i = 0; i < f - 1; ++i) {
+ // move a random item from i..f-1 to position i
+ s = "";
+ f2 = ceil(random() * (f - i) + i) - 1;
+ for(j = 0; j < i; ++j)
+ s = strcat(s, "'", argv(j), "'");
+ s = strcat(s, "'", argv(f2), "'");
+ for(j = i; j < f; ++j)
+ if(j != f2)
+ s = strcat(s, "'", argv(j), "'");
+ f = tokenize(s);
+ }
+
+ rpn_set(s);
+ tokenize(command);
+ } else if(rpncmd == "fexists_assert") {
+ s = rpn_pop();
+ if(!rpn_error)
+ {
+ f = fopen(s, FILE_READ);
+ if(f != -1)
+ fclose(f);
+ else {
+ print("rpn: ERROR: ", s, " does not exist!\n");
+ rpn_error = TRUE;
+ }
+ }
+ } else {
+ rpn_push(cvar_string(rpncmd));
+ }
+ if(rpn_error)
+ break;
+ }
+ while(rpn_sp > 0)
+ {
+ s = rpn_pop();
+ print("rpn: still on stack: ", s, "\n");
+ }
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/common/util.qh 2007-04-15 20:07:21 UTC (rev 2317)
@@ -6,3 +6,7 @@
void wordwrap_sprint(string s, float l);
#endif
void wordwrap_cb(string s, float l, void(string) callback)
+
+float GameCommand_Generic(string cmd);
+// returns TRUE if handled, FALSE otherwise
+// uses tokenize on its argument!
Added: trunk/data/qcsrc/menu/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/menu/gamecommand.qc (rev 0)
+++ trunk/data/qcsrc/menu/gamecommand.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -0,0 +1,23 @@
+void GameCommand_Init()
+{
+ // make gg call menu QC commands
+ localcmd("alias qc_cmd \"menu_cmd $*\"\n");
+}
+
+void GameCommand(string command)
+{
+ float argc;
+ argc = tokenize(command);
+
+ if(argv(0) == "help" || argc == 0)
+ {
+ print("Usage: menu_cmd COMMAND..., where possible commands are:\n");
+ GameCommand_Generic("help");
+ return;
+ }
+
+ if(GameCommand_Generic(command))
+ return;
+
+ print("Invalid command. For a list of supported commands, try menu_cmd help.\n");
+}
Modified: trunk/data/qcsrc/menu/mbuiltin.qc
===================================================================
--- trunk/data/qcsrc/menu/mbuiltin.qc 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/menu/mbuiltin.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -122,7 +122,8 @@
void strunzone(string s) = #57;
#endif
-float tokenize(string s) = #58
+float tokenize(string s) = #58;
+float(string s, string separator1, ...) tokenizebyseparator = #479;
string argv(float n) = #59;
float isserver(void) = #60;
Modified: trunk/data/qcsrc/menu/menu.qc
===================================================================
--- trunk/data/qcsrc/menu/menu.qc 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/menu/menu.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -31,6 +31,9 @@
// init menu
Menu_Init();
+
+ // menu QC is running; make the aliases use its GameCommand()
+ GameCommand_Init();
};
// required menu functions
@@ -148,4 +151,4 @@
// make sure everything is reset
setkeydest( KEY_GAME );
setmousetarget( MT_CLIENT );
-};
\ No newline at end of file
+};
Modified: trunk/data/qcsrc/menu/msys.qc
===================================================================
--- trunk/data/qcsrc/menu/msys.qc 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/menu/msys.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -267,7 +267,7 @@
float ERR_NULLSTRING = -1;
float ERR_BADDRAWFLAG = -2;
float ERR_BADSCALE = -3;
-float ERR_BADSIZE = ERR_BADSCALE;
+//float ERR_BADSIZE = ERR_BADSCALE;
float ERR_NOTCACHED = -4;
/* not supported at the moment
Modified: trunk/data/qcsrc/menu/progs.src
===================================================================
--- trunk/data/qcsrc/menu/progs.src 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/menu/progs.src 2007-04-15 20:07:21 UTC (rev 2317)
@@ -185,4 +185,8 @@
../common/campaign_setup.qc
../common/campaign_file.qc
+// GameCommand() extension
+../common/gamecommand.qc
+gamecommand.qc
+
menu.qc
Modified: trunk/data/qcsrc/server/cl_weapons.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weapons.qc 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/server/cl_weapons.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -110,7 +110,7 @@
remove(wep);
goto leave;
}
- (Item_SpawnFunc(w))();
+ Item_SpawnByItemCode(w);
if(startitem_failed)
goto leave;
if(doreduce)
Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/server/defs.qh 2007-04-15 20:07:21 UTC (rev 2317)
@@ -286,10 +286,9 @@
typedef .float floatfield;
-typedef void(void) spawnfunc;
floatfield Item_CounterField(float it);
float Item_WeaponCode(float it);
-spawnfunc Item_SpawnFunc(float it);
+void Item_SpawnByItemCode(float it);
float W_AmmoItemCode(float wpn);
float W_ItemCode(float wpn);
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/server/g_world.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -2,7 +2,7 @@
string GetMapname();
void GotoNextMap();
-void HandleMaplistShuffleCommands();
+void ShuffleMaplist()
float() DoNextMapOverride;
void SetDefaultAlpha()
@@ -57,7 +57,8 @@
if(cvar("_sv_init"))
{
cvar_set("_sv_init", "0");
- HandleMaplistShuffleCommands();
+ if(cvar("g_maplist_shuffle"))
+ ShuffleMaplist();
tokenize(cvar_string("g_maplist"));
if(argv(0) != GetMapname())
{
@@ -343,12 +344,6 @@
// 63 testing
lightstyle(63, "a");
- registercvar("_g_maplist_shufflenow", "0");
- registercvar("_g_maplist_have_shuffled", "0");
- registercvar("_g_maplist_add", "");
- registercvar("_g_maplist_remove", "");
- registercvar("_g_maplist_putfirst", "");
-
player_count = 0;
lms_lowest_lives = 0;
lms_next_place = 0;
@@ -892,31 +887,41 @@
===============================================================================
*/
-void() DumpStats =
+void(float final) DumpStats =
{
local float file;
local string s;
+ local float to_console;
+ local float to_eventlog;
+ local float to_file;
- if(cvar("_printstats"))
- cvar_set("_printstats", "0");
- else if(!gameover)
- return;
+ to_console = cvar("sv_logscores_console");
+ to_eventlog = cvar("sv_eventlog");
+ to_file = cvar("sv_logscores_file");
- if(gameover)
+ if(!final)
+ {
+ to_console = TRUE; // always print printstats replies
+ to_eventlog = FALSE; // but never print them to the event log
+ }
+
+ if(final)
s = ":scores:";
else
s = ":status:";
-
s = strcat(s, GetMapname(), ":", ftos(rint(time)));
- if(cvar("sv_eventlog") && gameover)
- GameLogEcho(s, FALSE);
- else if(cvar("sv_logscores_console"))
+ if(to_console)
ServerConsoleEcho(s, FALSE);
- if(cvar("sv_logscores_file"))
+ if(to_eventlog)
+ GameLogEcho(s, FALSE);
+ if(to_file)
{
file = fopen(cvar_string("sv_logscores_filename"), FILE_APPEND);
- fputs(file, strcat(s, "\n"));
+ if(file == -1)
+ to_file = FALSE;
+ else
+ fputs(file, strcat(s, "\n"));
}
FOR_EACH_CLIENT(other)
@@ -928,20 +933,20 @@
s = strcat(s, ftos(rint(time - other.jointime)), ":");
s = strcat(s, ftos(other.team), ":");
- if(cvar("sv_logscores_file"))
- fputs(file, strcat(s, other.netname, "\n"));
- if(cvar("sv_eventlog") && gameover)
- GameLogEcho(strcat(s, ftos(other.playerid), ":", other.netname), TRUE);
- else if(cvar("sv_logscores_console"))
+ if(to_console)
ServerConsoleEcho(strcat(s, other.netname), TRUE);
+ if(to_eventlog)
+ GameLogEcho(strcat(s, ftos(other.playerid), ":", other.netname), TRUE);
+ if(to_file)
+ fputs(file, strcat(s, other.netname, "\n"));
}
}
- if(cvar("sv_eventlog") && gameover)
- GameLogEcho(":end", FALSE);
- else if(cvar("sv_logscores_console"))
+ if(to_console)
ServerConsoleEcho(":end", FALSE);
- if(cvar("sv_logscores_file"))
+ if(to_eventlog)
+ GameLogEcho(":end", FALSE);
+ if(to_file)
{
fputs(file, ":end\n");
fclose(file);
@@ -1006,7 +1011,7 @@
VoteReset();
- DumpStats();
+ DumpStats(TRUE);
if(cvar("sv_eventlog"))
GameLogEcho(":gameover", FALSE);
@@ -1441,91 +1446,6 @@
print_to(e, ".");
}
-void RemoveFromMaplist(string m)
-{
- string result;
- float litems;
- float i;
- float found;
-
- litems = tokenize(cvar_string("g_maplist"));
- found = 0;
- result = "";
- for(i = 0; i < litems; ++i)
- {
- m = strcat1(m);
- result = strcat1(result);
- if(argv(i) == m)
- found += 1;
- else
- result = strcat(result, "'", argv(i), "'");
- }
- if(found)
- cvar_set("g_maplist", result);
- ServerConsoleEcho(strcat("Removed ", ftos(found), " items."), FALSE);
-}
-
-void AddToMaplist(string m)
-{
- string result;
- float found;
- float litems;
- float i;
- float ipos;
- float inserted;
-
- if(!TryFile(strcat("maps/", m, ".mapcfg")))
- {
- ServerConsoleEcho("Map not found.", FALSE);
- return;
- }
-
- litems = tokenize(cvar_string("g_maplist"));
- if(cvar("g_maplist_shuffle"))
- ipos = ceil(random() * (litems + 1)) - 1;
- else
- ipos = litems;
- found = 0;
- inserted = 0;
- for(i = 0; i < litems; ++i)
- {
- m = strcat1(m);
- if(i == ipos)
- {
- result = strcat(result, "'", m, "'");
- inserted = 1;
- }
- result = strcat(result, "'", argv(i), "'");
- if(argv(i) == m)
- found += 1;
- }
- if(!inserted)
- result = strcat(result, "'", m, "'");
- if(!found)
- {
- cvar_set("g_maplist", result);
- ServerConsoleEcho("Map added.", FALSE);
- }
- else
- ServerConsoleEcho("Map already in list.", FALSE);
-}
-
-void MakeFirstInMaplist(string m)
-{
- if(!TryFile(strcat("maps/", m, ".mapcfg")))
- {
- ServerConsoleEcho("Map not found.", FALSE);
- return;
- }
-
- m = strzone(m);
- RemoveFromMaplist(m);
- cvar_set("g_maplist", strcat("'", m, "'", cvar_string("g_maplist")));
- strunzone(m);
-
- ServerConsoleEcho("Map added as first one.", FALSE);
-}
-
void ShuffleMaplist()
{
string result;
@@ -1560,36 +1480,6 @@
cvar_set("g_maplist", result);
}
-void() HandleMaplistShuffleCommands =
-{
- // automatically shuffle when setting g_maplist_shuffle
- if(cvar_string("_g_maplist_add") != "")
- {
- AddToMaplist(cvar_string("_g_maplist_add"));
- cvar_set("_g_maplist_add", "");
- }
- if(cvar_string("_g_maplist_remove") != "")
- {
- RemoveFromMaplist(cvar_string("_g_maplist_remove"));
- cvar_set("_g_maplist_remove", "");
- }
- if(cvar_string("_g_maplist_putfirst") != "")
- {
- MakeFirstInMaplist(cvar_string("_g_maplist_putfirst"));
- cvar_set("_g_maplist_putfirst", "");
- }
- if(cvar("_g_maplist_shufflenow") || (cvar("g_maplist_shuffle") && !cvar("_g_maplist_have_shuffled")))
- {
- ShuffleMaplist();
- cvar_set("_g_maplist_shufflenow", "0");
- cvar_set("_g_maplist_have_shuffled", "1");
- ServerConsoleEcho("Shuffled map list.", FALSE);
- }
- if(cvar("_g_maplist_have_shuffled"))
- if(!cvar("g_maplist_shuffle"))
- cvar_set("_g_maplist_have_shuffled", "0");
-}
-
/*
============
CheckRules_World
@@ -1618,16 +1508,6 @@
if (gameover) // someone else quit the game already
return;
- DumpStats();
-
- if(cvar("_scoreboard"))
- {
- cvar_set("_scoreboard", "0");
- PrintScoreboard(world);
- }
-
- HandleMaplistShuffleCommands();
-
timelimit = cvar("timelimit") * 60;
fraglimit = cvar("fraglimit");
Added: trunk/data/qcsrc/server/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/server/gamecommand.qc (rev 0)
+++ trunk/data/qcsrc/server/gamecommand.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -0,0 +1,54 @@
+void GameCommand(string command)
+{
+ float argc;
+ argc = tokenize(command);
+
+ if(argv(0) == "help" || argc == 0)
+ {
+ print("Usage: sv_cmd COMMAND..., where possible commands are:\n");
+ print(" adminmsg clientnumber \"message\"\n");
+ print(" teamstatus\n");
+ print(" printstats\n");
+ GameCommand_Generic("help");
+ return;
+ }
+
+ if(GameCommand_Generic(command))
+ return;
+
+ if(argv(0) == "teamstatus")
+ {
+ PrintScoreboard(world);
+ return;
+ }
+
+ if(argv(0) == "printstats")
+ {
+ DumpStats(FALSE);
+ return;
+ }
+
+ if(argv(0) == "adminmsg")
+ {
+ if(argc == 3)
+ {
+ entity client;
+ float entno;
+ entno = stof(argv(1));
+ for(client = world; entno > 0; --entno, client = nextent(client))
+ ;
+ if(client.flags & FL_CLIENT)
+ {
+ centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3SERVER ADMIN:\n\n^7", argv(2)));
+ sprint(client, strcat("\{1}\{13}^3SERVER ADMIN^7: ", argv(2), "\n"));
+ print("Message sent to ", client.netname, "\n");
+ }
+ else
+ print("Client not found\n");
+ return;
+ }
+ }
+
+ print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
+}
+
Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/server/miscfunctions.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -513,6 +513,7 @@
#define CENTERPRIO_VOTE 4
#define CENTERPRIO_NORMAL 5
#define CENTERPRIO_MAPVOTE 9
+#define CENTERPRIO_ADMIN 99
.float centerprint_priority;
.float centerprint_expires;
void centerprint_atprio(entity e, float prio, string s)
Modified: trunk/data/qcsrc/server/progs.src
===================================================================
--- trunk/data/qcsrc/server/progs.src 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/server/progs.src 2007-04-15 20:07:21 UTC (rev 2317)
@@ -81,3 +81,6 @@
campaign.qc
../common/campaign_file.qc
../common/campaign_setup.qc
+
+../common/gamecommand.qc
+gamecommand.qc
Modified: trunk/data/qcsrc/server/t_items.qc
===================================================================
--- trunk/data/qcsrc/server/t_items.qc 2007-04-15 09:22:56 UTC (rev 2316)
+++ trunk/data/qcsrc/server/t_items.qc 2007-04-15 20:07:21 UTC (rev 2317)
@@ -687,19 +687,20 @@
}
}
-spawnfunc Item_SpawnFunc(float it)
+void Item_SpawnByItemCode(float it)
{
switch(it)
{
- case IT_SHOTGUN: return weapon_shotgun;
- case IT_UZI: return weapon_uzi;
- case IT_GRENADE_LAUNCHER: return weapon_grenadelauncher;
- case IT_ELECTRO: return weapon_electro;
- case IT_CRYLINK: return weapon_crylink;
- case IT_NEX: return weapon_nex;
- case IT_HAGAR: return weapon_hagar;
- case IT_ROCKET_LAUNCHER: return weapon_rocketlauncher;
+ case IT_SHOTGUN: weapon_shotgun(); break;
+ case IT_UZI: weapon_uzi(); break;
+ case IT_GRENADE_LAUNCHER: weapon_grenadelauncher(); break;
+ case IT_ELECTRO: weapon_electro(); break;
+ case IT_CRYLINK: weapon_crylink(); break;
+ case IT_NEX: weapon_nex(); break;
+ case IT_HAGAR: weapon_hagar(); break;
+ case IT_ROCKET_LAUNCHER: weapon_rocketlauncher(); break;
// add all other item spawn functions here
- default: error("requested item can't be spawned");
+ default:
+ error("requested item can't be spawned");
}
}
More information about the nexuiz-commits
mailing list