r5189 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Dec 11 08:18:05 EST 2008
Author: div0
Date: 2008-12-11 08:18:04 -0500 (Thu, 11 Dec 2008)
New Revision: 5189
Modified:
trunk/data/qcsrc/server/clientcommands.qc
trunk/data/qcsrc/server/defs.qh
trunk/data/qcsrc/server/g_world.qc
trunk/data/qcsrc/server/gamecommand.qc
trunk/data/qcsrc/server/miscfunctions.qc
Log:
cache replies of some cmd commands that take long
Modified: trunk/data/qcsrc/server/clientcommands.qc
===================================================================
--- trunk/data/qcsrc/server/clientcommands.qc 2008-12-11 13:07:35 UTC (rev 5188)
+++ trunk/data/qcsrc/server/clientcommands.qc 2008-12-11 13:18:04 UTC (rev 5189)
@@ -224,7 +224,7 @@
float readyrestart_happened;
void SV_ParseClientCommand(string s) {
local string cmd;
- local float i, j, tokens, f, effectnum;
+ local float tokens, f, effectnum;
local vector start, end;
tokens = tokenize_sane(s);
@@ -345,39 +345,11 @@
}
}
} else if(argv(0) == "maplist") {
- local float n;
- local string col;
- n = tokenize_sane(cvar_string("g_maplist"));
- sprint(self, "^7Maps in list: ");
- for(i = 0, j = 0; i < n; ++i)
- {
- if(MapInfo_CheckMap(argv(i)))
- {
- if(mod(j, 2))
- col = "^2";
- else
- col = "^3";
- sprint(self, strcat(col, argv(i), " "));
- ++j;
- }
- }
- sprint(self, "\n");
+ sprint(self, maplist_reply);
} else if(argv(0) == "lsmaps") {
- sprint(self, "^7Maps available: ");
- for(i = 0, j = 0; i < MapInfo_count; ++i)
- {
- if(MapInfo_Get_ByID(i))
- if not(MapInfo_Map_flags & MAPINFO_FLAG_HIDDEN)
- {
- if(mod(i, 2))
- col = "^2";
- else
- col = "^3";
- ++j;
- sprint(self, strcat(col, MapInfo_Map_bspname, " "));
- }
- }
- sprint(self, "\n");
+ sprint(self, lsmaps_reply);
+ } else if(argv(0) == "records") {
+ sprint(self, records_reply);
} else if(argv(0) == "voice") {
VoiceMessage(argv(1));
} else if(argv(0) == "say") {
@@ -449,8 +421,6 @@
}
else
print("Usage: sv_cheats 1; restart; cmd trailparticles effectname shotorigin\n");
- } else if(argv(0) == "records") {
- printrecords(self);
} else {
//if(ctf_clientcommand())
// return;
Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh 2008-12-11 13:07:35 UTC (rev 5188)
+++ trunk/data/qcsrc/server/defs.qh 2008-12-11 13:18:04 UTC (rev 5189)
@@ -16,6 +16,8 @@
// Globals
+string records_reply, lsmaps_reply, maplist_reply; // cached replies
+
float ctf_score_value(string parameter);
float g_dm, g_domination, g_ctf, g_tdm, g_keyhunt, g_onslaught, g_assault, g_arena, g_lms, g_runematch, g_race;
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2008-12-11 13:07:35 UTC (rev 5188)
+++ trunk/data/qcsrc/server/g_world.qc 2008-12-11 13:18:04 UTC (rev 5189)
@@ -229,8 +229,8 @@
void Nagger_Init();
void spawnfunc_worldspawn (void)
{
- float fd, l;
- string s;
+ float fd, l, i, j, n;
+ string s, col;
dprint_load(); // load dprint status from cvar
@@ -444,6 +444,40 @@
detect_maptype();
+ lsmaps_reply = "^7Maps available: ";
+ for(i = 0, j = 0; i < MapInfo_count; ++i)
+ {
+ if(MapInfo_Get_ByID(i))
+ if not(MapInfo_Map_flags & MAPINFO_FLAG_HIDDEN)
+ {
+ if(mod(i, 2))
+ col = "^2";
+ else
+ col = "^3";
+ ++j;
+ lsmaps_reply = strcat(lsmaps_reply, col, MapInfo_Map_bspname, " ");
+ }
+ }
+ lsmaps_reply = strzone(strcat(lsmaps_reply, "\n"));
+
+ maplist_reply = "^7Maps in list: ";
+ n = tokenize_sane(cvar_string("g_maplist"));
+ for(i = 0, j = 0; i < n; ++i)
+ {
+ if(MapInfo_CheckMap(argv(i)))
+ {
+ if(mod(j, 2))
+ col = "^2";
+ else
+ col = "^3";
+ maplist_reply = strcat(maplist_reply, col, argv(i), " ");
+ ++j;
+ }
+ }
+ maplist_reply = strzone(strcat(maplist_reply, "\n"));
+
+ records_reply = strzone(getrecords());
+
world_initialized = 1;
}
Modified: trunk/data/qcsrc/server/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/server/gamecommand.qc 2008-12-11 13:07:35 UTC (rev 5188)
+++ trunk/data/qcsrc/server/gamecommand.qc 2008-12-11 13:18:04 UTC (rev 5189)
@@ -681,7 +681,9 @@
}
if (argv(0) == "records")
{
- printrecords(world);
+ strunzone(records_reply);
+ records_reply = strzone(getrecords());
+ print(records_reply);
return;
}
Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc 2008-12-11 13:07:35 UTC (rev 5188)
+++ trunk/data/qcsrc/server/miscfunctions.qc 2008-12-11 13:18:04 UTC (rev 5189)
@@ -1688,14 +1688,17 @@
print(s, "\n");
}
-void printrecords(entity to)
+string getrecords()
{
float rec;
string h;
float r;
float i;
+ string s;
rec = 0;
+
+ s = "";
if(g_ctf)
{
@@ -1707,7 +1710,7 @@
if(r == 0)
continue;
h = db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, "/captimerecord/netname"));
- print_to(to, strcat(strpad(32, MapInfo_Map_bspname), " ", strpad(-6, ftos_decimals(r, 2)), " ", h));
+ s = strcat(s, strpad(32, MapInfo_Map_bspname), " ", strpad(-6, ftos_decimals(r, 2)), " ", h, "\n");
++rec;
}
}
@@ -1723,12 +1726,14 @@
if(r == 0)
continue;
h = db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, "/racerecord/netname"));
- print_to(to, strcat(strpad(32, MapInfo_Map_bspname), " ", strpad(-8, mmsss(r)), " ", h));
+ s = strcat(s, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, mmsss(r)), " ", h, "\n");
++rec;
}
}
}
- if(!rec)
- print_to(to, "No records are available on this server.");
+ if(s == "")
+ return "No records are available on this server.\n";
+ else
+ return strcat("Records on this server:\n", s);
}
More information about the nexuiz-commits
mailing list