From ba4141a6950f5b19fab01fd39734670c99d11f32 Mon Sep 17 00:00:00 2001 From: div0 Date: Thu, 23 Apr 2009 16:08:27 +0000 Subject: [PATCH] remove all 2.4.2 compatibility code (do not merge this into 2.5 bugfix releases) git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6579 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/client/Main.qc | 56 ++--- data/qcsrc/client/View.qc | 14 +- data/qcsrc/client/bgmscript.qc | 2 +- data/qcsrc/client/csqc_builtins.qc | 6 +- data/qcsrc/client/hook.qc | 5 +- data/qcsrc/client/main.qh | 4 +- data/qcsrc/client/mapvoting.qc | 9 +- data/qcsrc/client/miscfunctions.qc | 219 ++---------------- data/qcsrc/client/projectile.qc | 7 +- data/qcsrc/client/teamradar.qc | 15 +- data/qcsrc/common/campaign_file.qc | 2 +- data/qcsrc/common/gamecommand.qc | 26 +-- data/qcsrc/common/mapinfo.qc | 2 +- data/qcsrc/common/util-pre.qh | 5 - data/qcsrc/common/util.qc | 182 +-------------- data/qcsrc/common/util.qh | 13 -- data/qcsrc/menu/gamecommand.qc | 8 +- data/qcsrc/menu/mbuiltin.qh | 4 + data/qcsrc/menu/menu.qc | 2 +- .../dialog_multiplayer_create_mutators.c | 4 +- data/qcsrc/menu/nexuiz/dialog_singleplayer.c | 2 +- data/qcsrc/menu/nexuiz/keybinder.c | 8 +- data/qcsrc/menu/nexuiz/maplist.c | 4 +- data/qcsrc/menu/nexuiz/playerlist.c | 2 +- data/qcsrc/menu/nexuiz/slider_resolution.c | 2 +- data/qcsrc/menu/nexuiz/util.qc | 4 +- data/qcsrc/menu/nexuiz/weaponslist.c | 4 +- data/qcsrc/server/campaign.qc | 2 +- data/qcsrc/server/cl_player.qc | 8 +- data/qcsrc/server/cl_weapons.qc | 2 +- data/qcsrc/server/clientcommands.qc | 6 +- data/qcsrc/server/func_breakable.qc | 4 +- data/qcsrc/server/g_subs.qc | 2 +- data/qcsrc/server/g_triggers.qc | 4 +- data/qcsrc/server/g_world.qc | 4 +- data/qcsrc/server/gamecommand.qc | 4 +- data/qcsrc/server/ipban.qc | 14 +- data/qcsrc/server/miscfunctions.qc | 2 +- data/qcsrc/server/t_items.qc | 4 +- data/qcsrc/server/t_plats.qc | 2 +- data/qcsrc/server/target_spawn.qc | 2 +- data/qcsrc/server/vote.qc | 12 +- 42 files changed, 137 insertions(+), 546 deletions(-) diff --git a/data/qcsrc/client/Main.qc b/data/qcsrc/client/Main.qc index becdee4ac..b0dee71c1 100644 --- a/data/qcsrc/client/Main.qc +++ b/data/qcsrc/client/Main.qc @@ -293,7 +293,7 @@ float CSQC_ConsoleCommand(string strMessage) float argc; // Tokenize String //argc = tokenize(strMessage); - argc = tokenize_sane(strMessage); + argc = tokenize_console(strMessage); // Acquire Command local string strCmd; @@ -378,7 +378,7 @@ void ShotOrg_Draw2D() s = vtos(self.view_ofs); s = substring(s, 1, strlen(s) - 2); - if(tokenize_sane(s) == 3) + if(tokenize_console(s) == 3) s = strcat(argv(0), " ", argv(1), " ", argv(2)); coord2d_topleft = project_3d_to_2d(self.origin + view_up * 4 - view_right * 4); @@ -413,7 +413,7 @@ void ShotOrg_Spawn() void GameCommand(string msg) { float argc; - argc = tokenize_sane(msg); + argc = tokenize_console(msg); if(argv(0) == "help" || argc == 0) { @@ -887,27 +887,6 @@ void Ent_Init() PostInit(); } -string Net_ReadPicture() -{ - string img; - if(csqc_flags & CSQC_FLAG_READPICTURE) - { - img = ReadPicture(); - print(strcat("Got Picture: ", img, "\n")); - } else { - img = ReadString(); - print(strcat("^3Warning: ^7Couldn't download ", img, ". This is probably because your engine build is outdated.\n")); - float psize, i; - psize = ReadShort(); - // Can I be sure that ReadShort is 2 bytes and ReadLong is 4 bytes? - // Because then this could be optimized to first get all 4-byte-groups, - // then the remaining 2, then the remaining 1 - for(i = 0; i < psize; ++i) - ReadByte(); - } - return img; -} - void Net_ReadRace() { float b; @@ -1041,28 +1020,25 @@ string getcommandkey(string text, string command) return text; keys = db_get(binddb, command); - if(csqc_flags & CSQC_FLAG_READPICTURE) + if (!keys) { - if (!keys) + n = tokenize(findkeysforcommand(command)); // uses '...' strings + for(j = 0; j < n; ++j) { - n = tokenize_insane(findkeysforcommand(command)); // uses '...' strings - for(j = 0; j < n; ++j) + k = stof(argv(j)); + if(k != -1) { - k = stof(argv(j)); - if(k != -1) - { - if ("" == keys) - keys = keynumtostring(k); - else - keys = strcat(keys, ", ", keynumtostring(k)); - - ++l; - if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break; - } + if ("" == keys) + keys = keynumtostring(k); + else + keys = strcat(keys, ", ", keynumtostring(k)); + ++l; + if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break; } - db_put(binddb, command, keys); + } + db_put(binddb, command, keys); } if ("" == keys) { diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index 69eeb8013..c4ff851bc 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -223,18 +223,8 @@ void CSQC_UpdateView(float w, float h) view_set = 1; } - if(csqc_flags & CSQC_FLAG_COLORCODES) - { - // supporting engine - vid_width = w; - vid_height = h; - } - else - { - // non-supporting engine - vid_width = cvar("vid_width"); - vid_height = cvar("vid_height"); - } + vid_width = w; + vid_height = h; #ifdef BLURTEST if(time > blurtest_time0 && time < blurtest_time1) diff --git a/data/qcsrc/client/bgmscript.qc b/data/qcsrc/client/bgmscript.qc index 5bb414b4c..587a2e96c 100644 --- a/data/qcsrc/client/bgmscript.qc +++ b/data/qcsrc/client/bgmscript.qc @@ -199,7 +199,7 @@ float BGMScript(entity e) // find the CURRENT line for(;;) { - tokenize_sane(bufstr_get(bgmscriptbuf, e.bgmscriptline)); + tokenize_console(bufstr_get(bgmscriptbuf, e.bgmscriptline)); if(stof(argv(1)) >= t || argv(0) != e.bgmscript) { e.bgmscripttime = t; diff --git a/data/qcsrc/client/csqc_builtins.qc b/data/qcsrc/client/csqc_builtins.qc index 6efdec1ab..9a2b3bc4a 100644 --- a/data/qcsrc/client/csqc_builtins.qc +++ b/data/qcsrc/client/csqc_builtins.qc @@ -98,7 +98,7 @@ float drawfill(vector position, vector size, vector rgb, float alpha, float flag void drawsetcliparea(float x, float y, float width, float height) = #324; void drawresetcliparea(void) = #325; float drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) = #326; -float stringwidth_engine(string text, float handleColors) = #327; +float stringwidth(string text, float handleColors) = #327; float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328; @@ -281,3 +281,7 @@ entity(vector org, float rad) findradius = #22; string(float uselocaltime, string format, ...) strftime = #478; float(float timer) gettime = #519; #define GETTIME_CDTRACK 4 + +float(string s) tokenize_console = #514; +float(float i) argv_start_index = #515; +float(float i) argv_end_index = #516; diff --git a/data/qcsrc/client/hook.qc b/data/qcsrc/client/hook.qc index 15f0dff9e..e814e19fb 100644 --- a/data/qcsrc/client/hook.qc +++ b/data/qcsrc/client/hook.qc @@ -71,10 +71,7 @@ void Draw_GrapplingHook() tex = "particles/hook_green"; rgb = '.3 1 .3'; } - if(csqc_flags & CSQC_FLAG_READPICTURE) - Draw_CylindricLine(b, a, 8, tex, 0.25, random(), '1 1 1', 1, DRAWFLAG_NORMAL); - else - Draw_CylindricLine(b, a, 1, "", 0.25, 0, rgb, 1, DRAWFLAG_NORMAL); + Draw_CylindricLine(b, a, 8, tex, 0.25, random(), '1 1 1', 1, DRAWFLAG_NORMAL); } void Net_GrapplingHook() diff --git a/data/qcsrc/client/main.qh b/data/qcsrc/client/main.qh index e3eb30a3f..b2e7f16a6 100644 --- a/data/qcsrc/client/main.qh +++ b/data/qcsrc/client/main.qh @@ -97,9 +97,7 @@ float teamscores_flags[MAX_SCORE]; vector sbar_fontsize; -float csqc_flags; -#define CSQC_FLAG_READPICTURE 1 -#define CSQC_FLAG_COLORCODES 2 +//float csqc_flags; entity playerslots[255]; // 255 is engine limit on maxclients entity teamslots[17]; // 17 teams (including "spectator team") diff --git a/data/qcsrc/client/mapvoting.qc b/data/qcsrc/client/mapvoting.qc index 8db4f6ad3..35fee5ce4 100644 --- a/data/qcsrc/client/mapvoting.qc +++ b/data/qcsrc/client/mapvoting.qc @@ -227,11 +227,9 @@ void Cmd_MapVote_MapDownload(float argc) mv_preview[id] = true; //print("^2Found...\n"); return; - } else if(csqc_flags & CSQC_FLAG_READPICTURE) { + } else { print("Requesting preview...\n"); localcmd(strcat("\ncmd mv_getpic ", ftos(id), "\n")); - } else { - print("^3Missing map preview - Update to a newer build to be able to see them.\n"); } } @@ -252,7 +250,7 @@ void MapVote_CheckPK3(string pic, string pk3, float id) } else { - Cmd_MapVote_MapDownload(tokenize_sane(strcat("mv_download ", ftos(id)))); + Cmd_MapVote_MapDownload(tokenize_console(strcat("mv_download ", ftos(id)))); } } @@ -388,11 +386,10 @@ void Ent_MapVote() MapVote_UpdateVotes(); } -string Net_ReadPicture(); void Net_MapVote_Picture() { float type; type = ReadByte(); mv_preview[type] = true; - mv_pics[type] = strzone(Net_ReadPicture()); + mv_pics[type] = strzone(ReadPicture()); } diff --git a/data/qcsrc/client/miscfunctions.qc b/data/qcsrc/client/miscfunctions.qc index bf0be8bfe..da5df24ca 100644 --- a/data/qcsrc/client/miscfunctions.qc +++ b/data/qcsrc/client/miscfunctions.qc @@ -146,96 +146,35 @@ entity GetTeam(float Team, float add) return tm; } -float stringwidth_oldfont(string text, float handleColors) -{ - float i, len, ch, width; - len = strlen(text); - if(!handleColors) - return len; - width = 0; - for(i = 0; i < len; ++i) - { - if(substring(text, i, 1) == "^") - { - ch = str2chr(text, i+1); - if(ch >= '0' && ch <= '9') - ++i; - else if(i+4 < len && ch == 'x') - { - ch = str2chr(text, i+2); - if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') ) - { - ch = str2chr(text, i+3); - if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') ) - { - ch = str2chr(text, i+4); - if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') ) - i+=4; - else ++width; - } else ++width; - } else ++width; - } else ++width; - } else ++width; - } - return width; -} - void CSQC_CheckEngine() { - /* - registercvar("csqc_flags", "0"); - csqc_flags = cvar("csqc_flags"); - */ - - csqc_flags = 0; - - if(checkextension("DP_SV_WRITEPICTURE")) - { - stringwidth = stringwidth_engine; - sbar_font = FONT_USER+1; - sbar_bigfont = FONT_USER+2; - csqc_flags |= CSQC_FLAG_READPICTURE; - } else { - stringwidth = stringwidth_oldfont; - sbar_font = FONT_DEFAULT; - sbar_bigfont = FONT_DEFAULT; - } - - if(strlennocol("^xFFF") == 0) - csqc_flags |= CSQC_FLAG_COLORCODES; + sbar_font = FONT_USER+1; + sbar_bigfont = FONT_USER+2; } vector Sbar_GetFontsize(string cvarname) { - if(csqc_flags & CSQC_FLAG_READPICTURE) - { - vector v; - v = stov(cvar_string(cvarname)); - if(v_x == 0) - v = '8 8 0'; - if(v_y == 0) - v_y = v_x; - v_z = 0; - return v; - } - return '8 8 0' ; + vector v; + v = stov(cvar_string(cvarname)); + if(v_x == 0) + v = '8 8 0'; + if(v_y == 0) + v_y = v_x; + v_z = 0; + return v; } float Sbar_GetWidth(float teamcolumnwidth) { - if(csqc_flags & CSQC_FLAG_READPICTURE) - { - float f; - f = stof(cvar_string("sbar_width")); - if(f == 0) - f = 640; - if(f < 320) - f = 320; - if(f > vid_conwidth - 2 * teamcolumnwidth) - f = vid_conwidth - 2 * teamcolumnwidth; - return f; - } - return 640; + float f; + f = stof(cvar_string("sbar_width")); + if(f == 0) + f = 640; + if(f < 320) + f = 320; + if(f > vid_conwidth - 2 * teamcolumnwidth) + f = vid_conwidth - 2 * teamcolumnwidth; + return f; } float PreviewExists(string name) @@ -292,122 +231,10 @@ float ColorTranslateMode; string ColorTranslateRGB(string s) { - if not(ColorTranslateMode & 2) - if(csqc_flags & CSQC_FLAG_COLORCODES) - { - if(ColorTranslateMode & 1) - return strdecolorize(s); - else - return s; - } - - // running on an OLD engine! - // must translate ^xRGB codes to regular color codes - float i, n; - string s2, ch, ch2; - vector theTempColor, hsv; - float component; - - s2 = ""; - - n = strlen(s); - for(i = 0; i < n; ++i) - { - ch = substring(s, i, 1); - if(ch == "^") - { - ch2 = substring(s, i+1, 1); - if(ch2 == "^") - { - s2 = strcat(s2, ch, ch2); - } - else if(ch2 == "0" || stof(ch2)) // digit? - { - if not(ColorTranslateMode & 1) - s2 = strcat(s2, ch, ch2); - } - else if(ch2 == "x") // ^x found - { - theTempColor = '0 0 0'; - - component = HEXDIGIT_TO_DEC(substring(s, i+2, 1)); - if (component >= 0) // ^xr found - { - theTempColor_x = component/15; - - component = HEXDIGIT_TO_DEC(substring(s, i+3, 1)); - if (component >= 0) // ^xrg found - { - theTempColor_y = component/15; - - component = HEXDIGIT_TO_DEC(substring(s, i+4, 1)); - if (component >= 0) // ^xrgb found - { - theTempColor_z = component/15; - - if not(ColorTranslateMode & 1) - { - hsv = rgb_to_hsv(theTempColor); - - if(hsv_y < 0.2) - { - if(hsv_z < 0.5) - s2 = strcat(s2, "^0"); - else - s2 = strcat(s2, "^7"); - } - else - { - if(hsv_x < 0.6) - s2 = strcat(s2, "^1"); - else if(hsv_x < 1.33333333333333333333) - s2 = strcat(s2, "^3"); - else if(hsv_x < 2.5) - s2 = strcat(s2, "^2"); - else if(hsv_x < 3.33333333333333333333) - s2 = strcat(s2, "^5"); - else if(hsv_x < 4.5) - s2 = strcat(s2, "^4"); - else if(hsv_x < 5.5) - s2 = strcat(s2, "^6"); - else - s2 = strcat(s2, "^1"); - } - } - - i += 3; - } - else - { - // blue missing - s2 = strcat(s2, substring(s, i, 4)); - i += 2; - } - } - else - { - // green missing - s2 = strcat(s, substring(s2, i, 3)); - i += 1; - } - } - else - { - // red missing - s2 = strcat(s, substring(s2, i, 2)); - } - } - else - { - s2 = strcat(s2, ch, ch2); - } - ++i; - continue; - } - s2 = strcat(s2, ch); - } - - return s2; + if(ColorTranslateMode & 1) + return strdecolorize(s); + else + return s; } float cvar_or(string cv, float v) diff --git a/data/qcsrc/client/projectile.qc b/data/qcsrc/client/projectile.qc index f86a3384a..0910be1e5 100644 --- a/data/qcsrc/client/projectile.qc +++ b/data/qcsrc/client/projectile.qc @@ -166,11 +166,8 @@ void Projectile_Draw() void loopsound(entity e, float ch, string samp, float vol, float attn) { - if(csqc_flags & CSQC_FLAG_COLORCODES) - { - sound(e, ch, samp, vol, attn); - e.snd_looping = 1; - } + sound(e, ch, samp, vol, attn); + e.snd_looping = 1; } void Ent_RemoveProjectile() diff --git a/data/qcsrc/client/teamradar.qc b/data/qcsrc/client/teamradar.qc index 8ecf67d4a..403758c07 100644 --- a/data/qcsrc/client/teamradar.qc +++ b/data/qcsrc/client/teamradar.qc @@ -67,18 +67,9 @@ void draw_teamradar_background(float bg, float fg) if(fg > 0 && minimapname != "") { - if(csqc_flags & CSQC_FLAG_READPICTURE) // not 2.4.2 - { - fga = 1; - fgc = '1 1 1' * fg; - R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP); - } - else - { - fga = fg; - fgc = '1 1 1'; - R_BeginPolygon(minimapname, DRAWFLAG_ADDITIVE); - } + fga = 1; + fgc = '1 1 1' * fg; + R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP); if(v_flipped) { R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga); diff --git a/data/qcsrc/common/campaign_file.qc b/data/qcsrc/common/campaign_file.qc index 4babab30c..89b24ce51 100644 --- a/data/qcsrc/common/campaign_file.qc +++ b/data/qcsrc/common/campaign_file.qc @@ -36,7 +36,7 @@ float CampaignFile_Load(float offset, float n) continue; // comment if(lineno >= offset) { - entlen = tokenize_insane(l); // using insane tokenizer for CSV + entlen = tokenize(l); // using insane tokenizer for CSV #define CAMPAIGN_GETARG0 if(i >= entlen) #define CAMPAIGN_GETARG1 CAMPAIGN_GETARG0 error("syntax error in campaign file: line has not enough fields"); diff --git a/data/qcsrc/common/gamecommand.qc b/data/qcsrc/common/gamecommand.qc index cdeea1707..6c54a026b 100644 --- a/data/qcsrc/common/gamecommand.qc +++ b/data/qcsrc/common/gamecommand.qc @@ -172,7 +172,7 @@ float GameCommand_Generic(string command) float i, j, f, n; vector rgb; string s, s2, c; - argc = tokenize_sane(command); + argc = tokenize_console(command); if(argv(0) == "help") { print(" rpn EXPRESSION... - a RPN calculator.\n"); @@ -646,8 +646,8 @@ float GameCommand_Generic(string command) // s s2 union s2 = rpn_pop(); s = rpn_get(); - f = tokenize_sane(s); - f2 = tokenize_sane(strcat(s, " ", s2)); + f = tokenize_console(s); + f2 = tokenize_console(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 @@ -664,13 +664,13 @@ float GameCommand_Generic(string command) if(substring(s, 0, 1) == " ") s = substring(s, 1, 99999); rpn_set(s); - tokenize_sane(command); + tokenize_console(command); } else if(rpncmd == "intersection") { // s s2 intersection s2 = rpn_pop(); s = rpn_get(); - f = tokenize_sane(s); - f2 = tokenize_sane(strcat(s, " ", s2)); + f = tokenize_console(s); + f2 = tokenize_console(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 @@ -686,13 +686,13 @@ float GameCommand_Generic(string command) if(substring(s, 0, 1) == " ") s = substring(s, 1, 99999); rpn_set(s); - tokenize_sane(command); + tokenize_console(command); } else if(rpncmd == "difference") { // s s2 difference s2 = rpn_pop(); s = rpn_get(); - f = tokenize_sane(s); - f2 = tokenize_sane(strcat(s, " ", s2)); + f = tokenize_console(s); + f2 = tokenize_console(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 @@ -707,11 +707,11 @@ float GameCommand_Generic(string command) if(substring(s, 0, 1) == " ") s = substring(s, 1, 99999); rpn_set(s); - tokenize_sane(command); + tokenize_console(command); } else if(rpncmd == "shuffle") { // s shuffle s = rpn_get(); - f = tokenize_sane(s); + f = tokenize_console(s); for(i = 0; i < f - 1; ++i) { // move a random item from i..f-1 to position i @@ -723,13 +723,13 @@ float GameCommand_Generic(string command) for(j = i; j < f; ++j) if(j != f2) s = strcat(s, " ", argv(j)); - f = tokenize_sane(s); + f = tokenize_console(s); } if(substring(s, 0, 1) == " ") s = substring(s, 1, 99999); rpn_set(s); - tokenize_sane(command); + tokenize_console(command); } else if(rpncmd == "fexists_assert") { s = rpn_pop(); if(!rpn_error) diff --git a/data/qcsrc/common/mapinfo.qc b/data/qcsrc/common/mapinfo.qc index dd3f75e8b..8f470b64f 100644 --- a/data/qcsrc/common/mapinfo.qc +++ b/data/qcsrc/common/mapinfo.qc @@ -589,7 +589,7 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype } else { - n = tokenize_sane(cvar_string("g_cdtracks_remaplist")); + n = tokenize_console(cvar_string("g_cdtracks_remaplist")); s = strcat(" ", cvar_string("g_cdtracks_dontusebydefault"), " "); for(;;) { diff --git a/data/qcsrc/common/util-pre.qh b/data/qcsrc/common/util-pre.qh index d7765a3b4..e69de29bb 100644 --- a/data/qcsrc/common/util-pre.qh +++ b/data/qcsrc/common/util-pre.qh @@ -1,5 +0,0 @@ -#define tokenize DO_NOT_DEFINE_THIS_MONSTER_tokenize -#define tokenizebyseparator DO_NOT_DEFINE_THIS_MONSTER_tokenizebyseparator -#define argv DO_NOT_DEFINE_THIS_MONSTER_argv -#define argv_start_index DO_NOT_DEFINE_THIS_MONSTER_argv_start_index -#define argv_end_index DO_NOT_DEFINE_THIS_MONSTER_argv_end_index diff --git a/data/qcsrc/common/util.qc b/data/qcsrc/common/util.qc index c4028ca47..c6c9eb90e 100644 --- a/data/qcsrc/common/util.qc +++ b/data/qcsrc/common/util.qc @@ -647,7 +647,7 @@ string fixPriorityList(string order, float from, float to, float subtract, float string neworder; float i, n, w; - n = tokenize_sane(order); + n = tokenize_console(order); for(i = 0; i < n; ++i) { w = stof(argv(i)); @@ -666,7 +666,7 @@ string fixPriorityList(string order, float from, float to, float subtract, float if(complete) { - n = tokenize_sane(neworder); + n = tokenize_console(neworder); for(w = to; w >= from; --w) { for(i = 0; i < n; ++i) @@ -685,7 +685,7 @@ string swapInPriorityList(string order, float i, float j) string s; float w, n; - n = tokenize_sane(order); + n = tokenize_console(order); if(i >= 0 && i < n && j >= 0 && j < n && i != j) { @@ -885,7 +885,7 @@ void cvar_settemp_restore() { // undo what cvar_settemp did float n, i; - n = tokenize_sane(cvar_string("settemp_list")); + n = tokenize_console(cvar_string("settemp_list")); for(i = 0; i < n - 3; i += 3) cvar_set(argv(i + 1), cvar_string(argv(i + 2))); cvar_set("settemp_list", "0"); @@ -908,178 +908,6 @@ float almost_in_bounds(float a, float b, float c) return b == median(a - eps, b, c + eps); } - - -#ifdef MENUQC -float (string s) _tokenize_builtin = #58; -string (float argnum) _argv_builtin = #59; -float (string s, string sep) _tokenizebyseparator_builtin = #479; -#else -float (string s) _tokenize_builtin = #441; -string (float argnum) _argv_builtin = #442; -float (string s, string sep) _tokenizebyseparator_builtin = #479; -#endif -float(string s) _tokenize_console = #514; -float(float i) _argv_start_index_builtin = #515; -float(float i) _argv_end_index_builtin = #516; - -float MAX_TOKENS = 256; -string _argv_sane_buffer[MAX_TOKENS]; -float _argv_sane_startpos[MAX_TOKENS]; -float _argv_sane_endpos[MAX_TOKENS]; -float _argc_sane; - -string _argv_sane(float i) -{ - // Perl-ish -1 for the last argument - if(i < 0) - i = _argc_sane + i; - return strcat("", _argv_sane_buffer[i]); // force tempstring -} - -float _argv_start_index_sane(float i) -{ - // Perl-ish -1 for the last argument - if(i < 0) - i = _argc_sane + i; - return _argv_sane_startpos[i]; -} - -float _argv_end_index_sane(float i) -{ - // Perl-ish -1 for the last argument - if(i < 0) - i = _argc_sane + i; - return _argv_sane_endpos[i]; -} - -//string TOKENIZE_SANE_WHITESPACE_CHARS = "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"; -string TOKENIZE_SANE_WHITESPACE_CHARS = "\x20\x0d\x0a\x09"; -string TOKENIZE_SANE_COMMENT_BREAKERS = "\x0d\x0a"; -// change this if DP changes its type to "char"! - -float _tokenize_sane(string s) -{ - // This MUST match COM_ParseToken_Console! - string com_token, tmp; - float data; - float end; - float i; - - for(i = 0; i < _argc_sane; ++i) - { - if(_argv_sane_buffer[i]) - strunzone(_argv_sane_buffer[i]); - _argv_sane_buffer[i] = string_null; - _argv_sane_startpos[i] = 0; - } - - _argc_sane = 0; - data = 0; - end = strlen(s); - - for(;;) - { - // skip whitespace - for(; data < end && strstrofs(TOKENIZE_SANE_WHITESPACE_CHARS, substring(s, data, 1), 0) >= 0; ++data) - ; - if(data == end) - break; - - if(substring(s, data, 2) == "//") - { - // comment - - // Any call to the tokenizer ALREADY assumes it's a single line, so we can safely abort if we see a comment. - /* - data += 2; - while(data < end && strstrofs(TOKENIZE_SANE_COMMENT_BREAKERS, substring(s, data, 1), 0) >= 0) - ++data; - continue; // go to skipwhite again - */ - - // I'd like to simply put a "break" here, but then fteqcc says this function has unreachable code - return _argc_sane; - } - else if(substring(s, data, 1) == "\"") - { - // quoted string - com_token = ""; - _argv_sane_startpos[_argc_sane] = data; - for(++data; data < end && substring(s, data, 1) != "\""; ++data) - { - // allow escaped " and \ case - tmp = substring(s, data, 2); - if(tmp == "\\\"" || tmp == "\\\\") - ++data; - com_token = strcat(com_token, substring(s, data, 1)); - } - if(substring(s, data, 1) == "\"") - ++data; - _argv_sane_endpos[_argc_sane] = data; - _argv_sane_buffer[_argc_sane] = strzone(com_token); - ++_argc_sane; - } - else - { - // regular word - com_token = ""; - _argv_sane_startpos[_argc_sane] = data; - for(; data < end && strstrofs(TOKENIZE_SANE_WHITESPACE_CHARS, substring(s, data, 1), 0) < 0; ++data) - com_token = strcat(com_token, substring(s, data, 1)); - _argv_sane_endpos[_argc_sane] = data; - _argv_sane_buffer[_argc_sane] = strzone(com_token); - ++_argc_sane; - } - } - - return _argc_sane; -} - - - -// "sane" tokenizer -// matching the console 1:1 - -float tokenize_sane_force_native(string s) -{ - argv = _argv_builtin; - argv_start_index = _argv_start_index_builtin; - argv_end_index = _argv_end_index_builtin; - return _tokenize_console(s); -} - -float tokenize_sane_force_emulation(string s) -{ - argv = _argv_sane; - argv_start_index = _argv_start_index_sane; - argv_end_index = _argv_end_index_sane; - return _tokenize_sane(s); -} - -float tokenize_sane(string s) -{ - if(checkextension("DP_QC_TOKENIZE_CONSOLE")) - return tokenize_sane_force_native(s); - return tokenize_sane_force_emulation(s); -} - -float tokenize_insane(string s) -{ - argv = _argv_builtin; - argv_start_index = _argv_start_index_builtin; - argv_end_index = _argv_end_index_builtin; - return _tokenize_builtin(s); -} - -float tokenizebyseparator(string s, string sep) -{ - argv = _argv_builtin; - argv_start_index = _argv_start_index_builtin; - argv_end_index = _argv_end_index_builtin; - return _tokenizebyseparator_builtin(s, sep); -} - float power2of(float e) { return pow(2, e); @@ -1625,7 +1453,7 @@ void check_unacceptable_compiler_bugs() { if(cvar("_allow_unacceptable_compiler_bugs")) return; - tokenize_sane("foo bar"); + tokenize_console("foo bar"); if(strcat(argv(0), substring("foo bar", 4, 7 - argv_start_index(1))) == "barbar") error("fteqcc bug introduced with revision 3178 detected. Please upgrade fteqcc to a later revision, downgrade fteqcc to revision 3177, or pester Spike until he fixes it. You can set _allow_unacceptable_compiler_bugs 1 to skip this check, but expect stuff to be horribly broken then."); } diff --git a/data/qcsrc/common/util.qh b/data/qcsrc/common/util.qh index 50de1cd75..dde9ba2c5 100644 --- a/data/qcsrc/common/util.qh +++ b/data/qcsrc/common/util.qh @@ -106,19 +106,6 @@ void get_mi_min_max_texcoords(float mode); float almost_equals(float a, float b); float almost_in_bounds(float a, float b, float c); -#undef tokenize -#undef tokenizebyseparator -#undef argv - -var string(float) argv; -var float(float) argv_start_index; -var float(float) argv_end_index; -float tokenize_sane(string s); -float tokenize_sane_force_emulation(string s); -float tokenize_sane_force_native(string s); -float tokenize_insane(string s); -float tokenizebyseparator(string s, string sep); - float power2of(float e); float log2of(float x); diff --git a/data/qcsrc/menu/gamecommand.qc b/data/qcsrc/menu/gamecommand.qc index 0e6160bbe..265af912f 100644 --- a/data/qcsrc/menu/gamecommand.qc +++ b/data/qcsrc/menu/gamecommand.qc @@ -34,7 +34,7 @@ void _dumptree_close(entity pass, entity me) void GameCommand(string theCommand) { float argc; - argc = tokenize_sane(theCommand); + argc = tokenize_console(theCommand); if(argv(0) == "help" || argc == 0) { @@ -82,7 +82,7 @@ void GameCommand(string theCommand) print("SANE tokenizer:\n"); s = cvar_string("tokentest"); - n = tokenize_sane_force_builtin(s); + n = tokenize_console_force_builtin(s); for(i = -n; i < n; ++i) { print("token ", ftos(i), ": '", argv(i), "' = "); @@ -92,7 +92,7 @@ void GameCommand(string theCommand) print("INSANE tokenizer:\n"); s = cvar_string("tokentest"); - n = tokenize_insane(s); + n = tokenize(s); for(i = -n; i < n; ++i) { print("token ", ftos(i), ": '", argv(i), "' = "); @@ -102,7 +102,7 @@ void GameCommand(string theCommand) print("EMULATED tokenizer:\n"); s = cvar_string("tokentest"); - n = tokenize_sane_force_emulation(s); + n = tokenize_console_force_emulation(s); for(i = -n; i < n; ++i) { print("token ", ftos(i), ": '", argv(i), "' = "); diff --git a/data/qcsrc/menu/mbuiltin.qh b/data/qcsrc/menu/mbuiltin.qh index 63ee088f2..ffccf5eee 100644 --- a/data/qcsrc/menu/mbuiltin.qh +++ b/data/qcsrc/menu/mbuiltin.qh @@ -337,3 +337,7 @@ float fopen( string filename, float mode ) = return handle; }; #endif + +float(string s) tokenize_console = #514; +float(float i) argv_start_index = #515; +float(float i) argv_end_index = #516; diff --git a/data/qcsrc/menu/menu.qc b/data/qcsrc/menu/menu.qc index c3f22cd6b..e16e10923 100644 --- a/data/qcsrc/menu/menu.qc +++ b/data/qcsrc/menu/menu.qc @@ -91,7 +91,7 @@ void() m_init_delayed = continue; if(substring(s, 0, 7) == "author ") continue; - n = tokenize_sane(s); + n = tokenize_console(s); if(n >= 2) Skin_ApplySetting(argv(0), substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))); } diff --git a/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c b/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c index 1e609ebe7..2e3461f49 100644 --- a/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c +++ b/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c @@ -42,7 +42,7 @@ string WeaponArenaString() weaponarenastring_cvar = strzone(s); - n = tokenize_sane(s); + n = tokenize_console(s); s = ""; for(i = 0; i < n; ++i) { @@ -103,7 +103,7 @@ string toStringNexuizMutatorsDialog(entity me) // WARNING: dirty hack. TODO clean this up by putting this behaviour in extra classes. void loadCvarsLaserWeaponArenaWeaponButton(entity me) { - tokenize_sane(cvar_string("g_weaponarena")); + tokenize_console(cvar_string("g_weaponarena")); me.checked = (argv(0) == me.cvarValue); } diff --git a/data/qcsrc/menu/nexuiz/dialog_singleplayer.c b/data/qcsrc/menu/nexuiz/dialog_singleplayer.c index f4e4bb67d..1f957de95 100644 --- a/data/qcsrc/menu/nexuiz/dialog_singleplayer.c +++ b/data/qcsrc/menu/nexuiz/dialog_singleplayer.c @@ -28,7 +28,7 @@ void InstantAction_LoadMap(entity btn, entity dummy) { if(substring(s, 0, 4) == "set ") s = substring(s, 4, strlen(s) - 4); - n = tokenize_sane(s); + n = tokenize_console(s); if(argv(0) == "bot_number") cvar_set("bot_number", argv(1)); else if(argv(0) == "skill") diff --git a/data/qcsrc/menu/nexuiz/keybinder.c b/data/qcsrc/menu/nexuiz/keybinder.c index 46c79449a..7161bf7c1 100644 --- a/data/qcsrc/menu/nexuiz/keybinder.c +++ b/data/qcsrc/menu/nexuiz/keybinder.c @@ -50,7 +50,7 @@ void Nexuiz_KeyBinds_Read() return; while((s = fgets(fh))) { - if(tokenize_sane(s) != 2) + if(tokenize_console(s) != 2) continue; Nexuiz_KeyBinds_Functions[Nexuiz_KeyBinds_Count] = strzone(argv(0)); Nexuiz_KeyBinds_Descriptions[Nexuiz_KeyBinds_Count] = strzone(argv(1)); @@ -116,7 +116,7 @@ void keyGrabbedNexuizKeyBinder(entity me, float key, float ascii) if(func == "") return; - n = tokenize_insane(findkeysforcommand(func)); // uses '...' strings + n = tokenize(findkeysforcommand(func)); // uses '...' strings nvalid = 0; for(j = 0; j < n; ++j) { @@ -186,7 +186,7 @@ void KeyBinder_Bind_Clear(entity btn, entity me) if(func == "") return; - n = tokenize_insane(findkeysforcommand(func)); // uses '...' strings + n = tokenize(findkeysforcommand(func)); // uses '...' strings for(j = 0; j < n; ++j) { k = stof(argv(j)); @@ -300,7 +300,7 @@ void drawListBoxItemNexuizKeyBinder(entity me, float i, vector absSize, float is draw_Text(me.realUpperMargin * eY + extraMargin * eX, descr, me.realFontSize, theColor, theAlpha, 0); if(func != "") { - n = tokenize_insane(findkeysforcommand(func)); // uses '...' strings + n = tokenize(findkeysforcommand(func)); // uses '...' strings s = ""; for(j = 0; j < n; ++j) { diff --git a/data/qcsrc/menu/nexuiz/maplist.c b/data/qcsrc/menu/nexuiz/maplist.c index 0daaf09e8..58ae942a0 100644 --- a/data/qcsrc/menu/nexuiz/maplist.c +++ b/data/qcsrc/menu/nexuiz/maplist.c @@ -102,7 +102,7 @@ void g_maplistCacheToggleNexuizMapList(entity me, float i) else { s = ""; - n = tokenize_sane(cvar_string("g_maplist")); + n = tokenize_console(cvar_string("g_maplist")); for(i = 0; i < n; ++i) if(argv(i) != bspname) s = strcat(s, " ", argv(i)); @@ -210,7 +210,7 @@ void refilterNexuizMapList(entity me) s = "0"; for(i = 1; i < MapInfo_count; i *= 2) s = strcat(s, s); - n = tokenize_sane(cvar_string("g_maplist")); + n = tokenize_console(cvar_string("g_maplist")); for(i = 0; i < n; ++i) { j = MapInfo_FindName(argv(i)); diff --git a/data/qcsrc/menu/nexuiz/playerlist.c b/data/qcsrc/menu/nexuiz/playerlist.c index 35b21ed54..9ae656378 100644 --- a/data/qcsrc/menu/nexuiz/playerlist.c +++ b/data/qcsrc/menu/nexuiz/playerlist.c @@ -51,7 +51,7 @@ void setPlayerListNexuizPlayerList(entity me, string plist) for(i = 0; i < me.nItems; ++i) { s = bufstr_get(buf, i * PLAYERPARM_COUNT + PLAYERPARM_NAME); - n = tokenize_sane(s); + n = tokenize_console(s); if(n == 4) { diff --git a/data/qcsrc/menu/nexuiz/slider_resolution.c b/data/qcsrc/menu/nexuiz/slider_resolution.c index f9dbce473..39ffd9cfc 100644 --- a/data/qcsrc/menu/nexuiz/slider_resolution.c +++ b/data/qcsrc/menu/nexuiz/slider_resolution.c @@ -47,7 +47,7 @@ void saveCvarsNexuizResolutionSlider(entity me) { if(me.value >= 0 || me.value < me.nValues) { - tokenize_sane(me.getIdentifier(me)); + tokenize_console(me.getIdentifier(me)); cvar_set("vid_width", argv(0)); cvar_set("vid_height", argv(1)); cvar_set("vid_conwidth", argv(2)); diff --git a/data/qcsrc/menu/nexuiz/util.qc b/data/qcsrc/menu/nexuiz/util.qc index 768d97348..947823a24 100644 --- a/data/qcsrc/menu/nexuiz/util.qc +++ b/data/qcsrc/menu/nexuiz/util.qc @@ -36,7 +36,7 @@ void saveCvarsMulti(entity me) me.saveCvars_Multi(me); s = cvar_string(me.cvarName); - n = tokenize_sane(me.cvarNames_Multi); + n = tokenize_console(me.cvarNames_Multi); for(i = 0; i < n; ++i) cvar_set(argv(i), s); } @@ -224,7 +224,7 @@ void() Item_Nex_ExtResponseSystem_CheckForResponse = local float argc; while(strlen((s = getextresponse()))) { - argc = tokenize_sane(s); + argc = tokenize_console(s); Item_Nex_ExtResponseSystem_Parse(argc); } } diff --git a/data/qcsrc/menu/nexuiz/weaponslist.c b/data/qcsrc/menu/nexuiz/weaponslist.c index de1fd87b1..4aa01befe 100644 --- a/data/qcsrc/menu/nexuiz/weaponslist.c +++ b/data/qcsrc/menu/nexuiz/weaponslist.c @@ -40,7 +40,7 @@ void drawNexuizWeaponsList(entity me) print("AUTOFIXED\n"); cvar_set("cl_weaponpriority", t); } - me.nItems = tokenize_sane(t); + me.nItems = tokenize_console(t); drawListBox(me); } void WeaponsList_MoveUp_Click(entity box, entity me) @@ -81,7 +81,7 @@ string toStringNexuizWeaponsList(entity me) float n, i; string s; entity e; - n = tokenize_sane(cvar_string("cl_weaponpriority")); + n = tokenize_console(cvar_string("cl_weaponpriority")); s = ""; for(i = 0; i < n; ++i) { diff --git a/data/qcsrc/server/campaign.qc b/data/qcsrc/server/campaign.qc index af391b7e4..1363deb58 100644 --- a/data/qcsrc/server/campaign.qc +++ b/data/qcsrc/server/campaign.qc @@ -136,7 +136,7 @@ void CampaignSaveCvar(string cvarname, float value) { while((l = fgets(fh))) { - len = tokenize_sane(l); + len = tokenize_console(l); if(len != 3) continue; if(argv(0) != "set") diff --git a/data/qcsrc/server/cl_player.qc b/data/qcsrc/server/cl_player.qc index d98d7450a..545a429ce 100644 --- a/data/qcsrc/server/cl_player.qc +++ b/data/qcsrc/server/cl_player.qc @@ -881,7 +881,7 @@ float GetPlayerSoundSampleField_fixed; void PrecacheGlobalSound(string samplestring) { float n, i; - tokenize_sane(samplestring); + tokenize_console(samplestring); n = stof(argv(1)); if(n > 0) { @@ -903,7 +903,7 @@ void PrecachePlayerSounds(string f) return; while((s = fgets(fh))) { - if(tokenize_sane(s) != 3) + if(tokenize_console(s) != 3) { dprint("Invalid sound info line: ", s, "\n"); continue; @@ -939,7 +939,7 @@ void LoadPlayerSounds(string f, float first) return; while((s = fgets(fh))) { - if(tokenize_sane(s) != 3) + if(tokenize_console(s) != 3) continue; field = GetPlayerSoundSampleField(argv(0)); if(GetPlayerSoundSampleField_notFound) @@ -975,7 +975,7 @@ void GlobalSound(string sample, float chan, float voicetype) if(sample == "") return; - tokenize_sane(sample); + tokenize_console(sample); n = stof(argv(1)); if(n > 0) sample = strcat(argv(0), ftos(floor(random() * n + 1)), ".wav"); // randomization diff --git a/data/qcsrc/server/cl_weapons.qc b/data/qcsrc/server/cl_weapons.qc index 3e6e45d84..442afd162 100644 --- a/data/qcsrc/server/cl_weapons.qc +++ b/data/qcsrc/server/cl_weapons.qc @@ -23,7 +23,7 @@ void W_SwitchWeapon(float imp) float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain) { float n, i, weaponwant, first_valid, prev_valid, switchtonext, switchtolast, c; - n = tokenize_sane(weaponorder); + n = tokenize_console(weaponorder); switchtonext = switchtolast = 0; first_valid = prev_valid = 0; diff --git a/data/qcsrc/server/clientcommands.qc b/data/qcsrc/server/clientcommands.qc index a8051373b..504d269ca 100644 --- a/data/qcsrc/server/clientcommands.qc +++ b/data/qcsrc/server/clientcommands.qc @@ -105,7 +105,7 @@ void SV_ParseClientCommand(string s) { local float tokens, f, effectnum; local vector start, end; - tokens = tokenize_sane(s); + tokens = tokenize_console(s); if(GameCommand_Vote(s, self)) { return; @@ -146,14 +146,14 @@ void SV_ParseClientCommand(string s) { if(substring(argv(2), 0, 1) == "$") // undefined cvar: use the default value on the server then { s = strcat(substring(s, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\""); - tokens = tokenize_sane(s); + tokens = tokenize_console(s); } GetCvars(1); } else if(argv(0) == "sentcvar") { // new system if(tokens == 2) // undefined cvar: use the default value on the server then { s = strcat(substring(s, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\""); - tokens = tokenize_sane(s); + tokens = tokenize_console(s); } GetCvars(1); } else if(argv(0) == "spectate") { diff --git a/data/qcsrc/server/func_breakable.qc b/data/qcsrc/server/func_breakable.qc index aceb7a4fd..7d31ffcb6 100644 --- a/data/qcsrc/server/func_breakable.qc +++ b/data/qcsrc/server/func_breakable.qc @@ -135,7 +135,7 @@ void func_breakable_destroy() { RadiusDamage(self, activator, self.dmg, self.dmg_edge, self.dmg_radius, self, self.dmg_force, DEATH_HURTTRIGGER, world); // now throw around the debris - n = tokenize_sane(self.debris); + n = tokenize_console(self.debris); for(i = 0; i < n; ++i) LaunchDebris(argv(i)); @@ -202,7 +202,7 @@ void spawnfunc_func_breakable() { // precache all the models if (self.mdl_dead) precache_model(self.mdl_dead); - n = tokenize_sane(self.debris); + n = tokenize_console(self.debris); for(i = 0; i < n; ++i) precache_model(argv(i)); if(self.noise) diff --git a/data/qcsrc/server/g_subs.qc b/data/qcsrc/server/g_subs.qc index e297020bb..bb92cc023 100644 --- a/data/qcsrc/server/g_subs.qc +++ b/data/qcsrc/server/g_subs.qc @@ -53,7 +53,7 @@ vector animparseline(float animfile) if (animfile < 0) return '0 1 2'; line = fgets(animfile); - c = tokenize_sane(line); + c = tokenize_console(line); if (c != 3) { animparseerror = TRUE; diff --git a/data/qcsrc/server/g_triggers.qc b/data/qcsrc/server/g_triggers.qc index 88486fac5..c46b7c2c2 100644 --- a/data/qcsrc/server/g_triggers.qc +++ b/data/qcsrc/server/g_triggers.qc @@ -1510,7 +1510,7 @@ void target_voicescript_next(entity pl) if(time >= pl.voicescript_nextthink) { // get the next voice... - n = tokenize_sane(vs.message); + n = tokenize_console(vs.message); if(pl.voicescript_index < vs.cnt) i = pl.voicescript_index * 2; @@ -1544,7 +1544,7 @@ void spawnfunc_target_voicescript() float i, n; self.use = target_voicescript_use; - n = tokenize_sane(self.message); + n = tokenize_console(self.message); self.cnt = n / 2; for(i = 0; i+1 < n; i += 2) { diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 92755376c..d8e694a11 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -553,7 +553,7 @@ void spawnfunc_worldspawn (void) { while((s = fgets(fd))) { - l = tokenize_sane(s); + l = tokenize_console(s); if(l < 2) continue; if(argv(0) == "cd") @@ -615,7 +615,7 @@ void spawnfunc_worldspawn (void) lsmaps_reply = strzone(strcat(lsmaps_reply, "\n")); maplist_reply = "^7Maps in list: "; - n = tokenize_sane(cvar_string("g_maplist")); + n = tokenize_console(cvar_string("g_maplist")); for(i = 0, j = 0; i < n; ++i) { if(MapInfo_CheckMap(argv(i))) diff --git a/data/qcsrc/server/gamecommand.qc b/data/qcsrc/server/gamecommand.qc index 4a1716823..b1a721782 100644 --- a/data/qcsrc/server/gamecommand.qc +++ b/data/qcsrc/server/gamecommand.qc @@ -543,7 +543,7 @@ void EffectIndexDump() fh = fopen("effectinfo.txt", FILE_READ); while((s = fgets(fh))) { - tokenize_insane(s); // tokenize_sane would hit the loop counter :( + tokenize(s); // tokenize_console would hit the loop counter :( if(argv(0) == "effect") { if(db_get(d, argv(1)) != "1") @@ -580,7 +580,7 @@ void GameCommand(string command) entity client, e; vector v; float entno, i; - argc = tokenize_sane(command); + argc = tokenize_console(command); if(argv(0) == "help" || argc == 0) { diff --git a/data/qcsrc/server/ipban.qc b/data/qcsrc/server/ipban.qc index 9fa2a9875..2eff9d16e 100644 --- a/data/qcsrc/server/ipban.qc +++ b/data/qcsrc/server/ipban.qc @@ -31,7 +31,7 @@ void OnlineBanList_SendBan(string ip, float bantime, string reason) uri = strcat(uri, "&duration=", ftos(bantime)); uri = strcat(uri, "&reason=", uri_escape(reason)); - n = tokenize_sane(cvar_string("g_ban_sync_uri")); + n = tokenize_console(cvar_string("g_ban_sync_uri")); if(n >= MAX_IPBAN_URIS) n = MAX_IPBAN_URIS; for(i = 0; i < n; ++i) @@ -46,7 +46,7 @@ void OnlineBanList_SendUnban(string ip) uri = strcat( "?action=unban&hostname=", uri_escape(cvar_string("hostname"))); uri = strcat(uri, "&ip=", uri_escape(ip)); - n = tokenize_sane(cvar_string("g_ban_sync_uri")); + n = tokenize_console(cvar_string("g_ban_sync_uri")); if(n >= MAX_IPBAN_URIS) n = MAX_IPBAN_URIS; for(i = 0; i < n; ++i) @@ -75,7 +75,7 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data) return; } - tokenize_sane(cvar_string("g_ban_sync_uri")); + tokenize_console(cvar_string("g_ban_sync_uri")); uri = argv(id); print("Received ban list from ", uri, ": "); @@ -183,7 +183,7 @@ void OnlineBanList_Think() return; if(cvar("g_ban_sync_interval") == 0) // < 0 is okay, it means "sync on level start only" return; - argc = tokenize_sane(cvar_string("g_ban_sync_trusted_servers")); + argc = tokenize_console(cvar_string("g_ban_sync_trusted_servers")); if(argc == 0) return; @@ -199,7 +199,7 @@ void OnlineBanList_Think() OnlineBanList_Timeout = time + cvar("g_ban_sync_timeout"); - n = tokenize_sane(cvar_string("g_ban_sync_uri")); + n = tokenize_console(cvar_string("g_ban_sync_uri")); if(n >= MAX_IPBAN_URIS) n = MAX_IPBAN_URIS; for(i = 0; i < n; ++i) @@ -274,7 +274,7 @@ void Ban_LoadBans() Ban_Delete(i); ban_count = 0; ban_loaded = TRUE; - n = tokenize_sane(cvar_string("g_banned_list")); + n = tokenize_console(cvar_string("g_banned_list")); if(stof(argv(0)) == 1) { ban_count = (n - 1) / 2; @@ -525,7 +525,7 @@ float GameCommand_Ban(string command) string reason; float reasonarg; - argc = tokenize_sane(command); + argc = tokenize_console(command); if(argv(0) == "help") { print(" kickban # n m p reason - kickban player n for m seconds, using mask size p (1 to 4)\n"); diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 86945229c..e7f152305 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -791,7 +791,7 @@ void readplayerstartcvars() } else { - t = tokenize_sane(s); + t = tokenize_console(s); g_weaponarena_list = ""; for(i = 0; i < t; ++i) { diff --git a/data/qcsrc/server/t_items.qc b/data/qcsrc/server/t_items.qc index e30d93ce1..5b0b2052a 100644 --- a/data/qcsrc/server/t_items.qc +++ b/data/qcsrc/server/t_items.qc @@ -675,7 +675,7 @@ void weapon_defaultspawnfunc(float wpn) startitem_failed = TRUE; return; } - t = tokenize_sane(s); + t = tokenize_console(s); if(t >= 2) { self.team = --internalteam; @@ -1221,7 +1221,7 @@ void spawnfunc_target_items (void) precache_sound("misc/poweroff.wav"); precache_sound("weapons/weaponpickup.wav"); - n = tokenize_sane(self.netname); + n = tokenize_console(self.netname); for(i = 0; i < n; ++i) { if(argv(i) == "unlimited_ammo") self.items |= IT_UNLIMITED_AMMO; diff --git a/data/qcsrc/server/t_plats.qc b/data/qcsrc/server/t_plats.qc index 74ab526d3..304802bf2 100644 --- a/data/qcsrc/server/t_plats.qc +++ b/data/qcsrc/server/t_plats.qc @@ -1628,7 +1628,7 @@ void func_fourier_controller_think() self.nextthink = time + 0.1; - n = floor((tokenize_sane(self.owner.netname)) / 5); + n = floor((tokenize_console(self.owner.netname)) / 5); t = self.nextthink * self.owner.cnt + self.owner.phase * 360; v = self.owner.destvec; diff --git a/data/qcsrc/server/target_spawn.qc b/data/qcsrc/server/target_spawn.qc index 4177d9511..4d2198ab1 100644 --- a/data/qcsrc/server/target_spawn.qc +++ b/data/qcsrc/server/target_spawn.qc @@ -32,7 +32,7 @@ void target_spawn_useon(entity e) entity oldactivator; entity kt, t2, t3, t4; - n = tokenize_sane(self.message); + n = tokenize_console(self.message); self.target_spawn_activator = activator; kt = find(world, targetname, self.killtarget); diff --git a/data/qcsrc/server/vote.qc b/data/qcsrc/server/vote.qc index 58de8330f..72323afda 100644 --- a/data/qcsrc/server/vote.qc +++ b/data/qcsrc/server/vote.qc @@ -22,7 +22,7 @@ entity GetKickVoteVictim(string vote, string cmd, entity caller) entity e; string reason; - tokens = tokenize_sane(vote); + tokens = tokenize_console(vote); ns = ""; if(tokens >= 2) @@ -96,13 +96,13 @@ float RemapVote(string vote, string cmd, entity e) { float vote_argc; entity victim; - vote_argc = tokenize_sane(vote); + vote_argc = tokenize_console(vote); if(!VoteAllowed(argv(0), cmd)) return FALSE; // VoteAllowed tokenizes! - vote_argc = tokenize_sane(vote); + vote_argc = tokenize_console(vote); // remap chmap to gotomap (forces intermission) if(vote_argc < 2) @@ -111,14 +111,14 @@ float RemapVote(string vote, string cmd, entity e) if(argv(0) == "chmap") { vote = strcat("gotomap ", substring(vote, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))); - vote_argc = tokenize_sane(vote); + vote_argc = tokenize_console(vote); } if(argv(0) == "gotomap") { if(!(vote = ValidateMap(substring(vote, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), e))) return FALSE; vote = strcat("gotomap ", vote); - vote_argc = tokenize_sane(vote); // ValidateMap may have done some stuff to it + vote_argc = tokenize_console(vote); // ValidateMap may have done some stuff to it } // make kick and kickban votes a bit nicer (and reject them if formatted badly) @@ -140,7 +140,7 @@ float RemapVote(string vote, string cmd, entity e) float GameCommand_Vote(string s, entity e) { float argc; - argc = tokenize_sane(s); + argc = tokenize_console(s); if(argv(0) == "help") { print_to(e, " vote COMMANDS ARGUMENTS. See 'vhelp' for more info."); return TRUE; -- 2.39.2