From 9ddd00d3479c56a93e210d16f4870c803e23c680 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 29 May 2020 17:31:23 +1000 Subject: [PATCH] Remove the cvar wrappers that existed for the campaign, which are now useless thanks to the move to autocvars --- qcsrc/lib/log.qh | 14 +++----- qcsrc/server/campaign.qc | 65 +++------------------------------- qcsrc/server/command/common.qc | 2 +- qcsrc/server/g_world.qc | 19 ++++------ qcsrc/server/miscfunctions.qh | 18 ---------- qcsrc/server/sys-post.qh | 6 ---- qcsrc/server/sys-pre.qh | 3 -- 7 files changed, 15 insertions(+), 112 deletions(-) diff --git a/qcsrc/lib/log.qh b/qcsrc/lib/log.qh index 16875c8bc..e05ad261a 100644 --- a/qcsrc/lib/log.qh +++ b/qcsrc/lib/log.qh @@ -96,23 +96,17 @@ string(string, string...) strcat1n = #115; noref int autocvar_developer; noref bool autocvar_prvm_backtraceforwarnings; -#ifdef SVQC -#define bt_cvar_set(cvar, value) builtin_cvar_set(cvar, value) -#else -#define bt_cvar_set(cvar, value) cvar_set(cvar, value) -#endif - #define backtrace(msg) \ MACRO_BEGIN \ int dev = autocvar_developer; \ bool war = autocvar_prvm_backtraceforwarnings; \ - bt_cvar_set("developer", "1"); \ - bt_cvar_set("prvm_backtraceforwarnings", "1"); \ + cvar_set("developer", "1"); \ + cvar_set("prvm_backtraceforwarnings", "1"); \ print("\n--- CUT HERE ---\n", msg); \ _backtrace(); \ print("\n--- CUT UNTIL HERE ---\n"); \ - bt_cvar_set("developer", ftos(dev)); \ - bt_cvar_set("prvm_backtraceforwarnings", ftos(war)); \ + cvar_set("developer", ftos(dev)); \ + cvar_set("prvm_backtraceforwarnings", ftos(war)); \ MACRO_END void print_assertfailed_severe(string expr) diff --git a/qcsrc/server/campaign.qc b/qcsrc/server/campaign.qc index 110704f2b..1a01868fb 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -21,11 +21,6 @@ string campaign_index_var; float CampaignBailout(string s) { -#if 0 - cvar = cvar_normal; - cvar_string = cvar_string_normal; - cvar_set = cvar_set_normal; -#endif cvar_set("g_campaign", "0"); LOG_INFO("^4campaign initialization failed: ", s); if(autocvar__campaign_testrun) @@ -33,35 +28,6 @@ float CampaignBailout(string s) return 1; } -#if 0 -string cvar_campaignwrapper_list; // string of format ; var value; var value; var value; -string cvar_string_campaignwrapper(string theCvar) -{ - float p, q; - p = strstrofs(cvar_campaignwrapper_list, strcat("; ", theCvar, " "), 0); - if(p < 0) - return cvar_defstring(theCvar); - p += strlen(theCvar) + 3; - q = strstrofs(cvar_campaignwrapper_list, ";", p); - if(q < 0) - return cvar_defstring(theCvar); - return substring(cvar_campaignwrapper_list, p, q - p); -} -float cvar_campaignwrapper(string theCvar) -{ - return stof(cvar_string_campaignwrapper(theCvar)); -} -void cvar_set_campaignwrapper(string theCvar, string theValue) -{ - if(cvar_string_campaignwrapper(theCvar) == theValue) - return; - string s = cvar_campaignwrapper_list; - cvar_campaignwrapper_list = strzone(strcat("; ", theCvar, " ", theValue, s)); - strunzone(s); - //print(cvar_campaignwrapper_list, "\n"); -} -#endif - float Campaign_Invalid() { string thismapname, wantedmapname; @@ -113,9 +79,6 @@ void CampaignPreInit() cvar_set("sv_public", "0"); cvar_set("pausable", "1"); -#if 0 - cvar_campaignwrapper_list = strzone(strcat("; ", campaign_mutators[0], "; ")); -#else string cvar_campaignwrapper_list = strcat("; ", campaign_mutators[0], "; "); int argc = tokenizebyseparator(cvar_campaignwrapper_list, "; "); if(argc > 0) @@ -127,27 +90,13 @@ void CampaignPreInit() _MapInfo_Parse_Settemp(mapname, MAPINFO_SETTEMP_ACL_USER, 0, arg, 1); } } -#endif - -#if 0 - cvar = cvar_campaignwrapper; - cvar_string = cvar_string_campaignwrapper; - cvar_set = cvar_set_campaignwrapper; - cvar_set("g_campaign", "1"); - cvar_set("g_dm", "0"); - cvar_set("skill", ftos(baseskill)); - cvar_set("bot_number", ftos(campaign_bots[0])); -#else + cvar_settemp("g_campaign", "1"); cvar_settemp("g_dm", "0"); cvar_settemp("skill", ftos(baseskill)); cvar_settemp("bot_number", ftos(campaign_bots[0])); -#endif - MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0])); - // copy sv_gravity cvar, as the engine needs it too (sorry, this will mess - // with the menu a little still...) - cvar_set_normal("sv_gravity", ftos(autocvar_sv_gravity)); + MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0])); if(Campaign_Invalid()) return; @@ -163,9 +112,6 @@ void CampaignPostInit() cvar_set("fraglimit", "0"); cvar_set("leadlimit", "0"); cvar_set("timelimit", "0.01"); - cvar_set_normal("fraglimit", "0"); - cvar_set_normal("leadlimit", "0"); - cvar_set_normal("timelimit", "0.01"); } else { @@ -173,15 +119,12 @@ void CampaignPostInit() tokenizebyseparator(campaign_fraglimit[0], "+"); if(argv(0) != "default") { cvar_set("fraglimit", argv(0)); - cvar_set_normal("fraglimit", argv(0)); } if(argv(1) != "default") { cvar_set("leadlimit", argv(1)); - cvar_set_normal("leadlimit", argv(1)); } if(campaign_timelimit[0] != "default") { cvar_set("timelimit", campaign_timelimit[0]); - cvar_set_normal("timelimit", campaign_timelimit[0]); } } } @@ -194,7 +137,7 @@ void CampaignSaveCvar(string cvarname, float value) string l; registercvar(cvarname, ftos(value)); - cvar_set_normal(cvarname, ftos(value)); + cvar_set(cvarname, ftos(value)); // note: cvarname must be remembered fh = fopen("campaign.cfg", FILE_READ); @@ -279,7 +222,7 @@ void CampaignPreIntermission() if(campaign_won && cheatcount_total == 0 && !autocvar__campaign_testrun) { - if(campaign_level == cvar_normal(campaign_index_var)) + if(campaign_level == cvar(campaign_index_var)) { if(campaign_entries < 2) { diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index 6121867e2..f791446eb 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -475,7 +475,7 @@ void CommonCommand_info(int request, entity caller, int argc) { case CMD_REQUEST_COMMAND: { - string command = builtin_cvar_string(strcat("sv_info_", argv(1))); + string command = cvar_string(strcat("sv_info_", argv(1))); if (command) wordwrap_sprint(caller, command, 1000); else print_to(caller, "ERROR: unsupported info command"); diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index d9ca813aa..af6b7b64d 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -568,9 +568,6 @@ spawnfunc(__init_dedicated_server) // handler for _init/_init map (only for dedicated server initialization) world_initialized = -1; // don't complain - cvar = cvar_normal; - cvar_string = cvar_string_normal; - cvar_set = cvar_set_normal; delete_fn = remove_unsafely; @@ -680,8 +677,8 @@ spawnfunc(worldspawn) // localcmd("\nfs_rescan\n"); // FIXME: does more harm than good, has unintended side effects. What we really want is to unload temporary pk3s only // restore csqc_progname too string expect = "csprogs.dat"; - wantrestart = cvar_string_normal("csqc_progname") != expect; - cvar_set_normal("csqc_progname", expect); + wantrestart = cvar_string("csqc_progname") != expect; + cvar_set("csqc_progname", expect); } else { @@ -692,9 +689,9 @@ spawnfunc(worldspawn) // This always works; fall back to it if a versioned csprogs.dat is suddenly missing string select = "csprogs.dat"; if (fexists(pk3csprogs)) select = pk3csprogs; - if (cvar_string_normal("csqc_progname") != select) + if (cvar_string("csqc_progname") != select) { - cvar_set_normal("csqc_progname", select); + cvar_set("csqc_progname", select); wantrestart = true; } // Check for updates on startup @@ -713,13 +710,13 @@ spawnfunc(worldspawn) string newprogs = sprintf("progs-%s.dat", switchversion); if (fexists(newprogs)) { - cvar_set_normal("sv_progs", newprogs); + cvar_set("sv_progs", newprogs); wantrestart = true; } string newcsprogs = sprintf("csprogs-%s.dat", switchversion); if (fexists(newcsprogs)) { - cvar_set_normal("csqc_progname", newcsprogs); + cvar_set("csqc_progname", newcsprogs); wantrestart = true; } } @@ -733,10 +730,6 @@ spawnfunc(worldspawn) } } - cvar = cvar_normal; - cvar_string = cvar_string_normal; - cvar_set = cvar_set_normal; - if(world_already_spawned) error("world already spawned - you may have EXACTLY ONE worldspawn!"); world_already_spawned = true; diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index cb11057ef..35fc07bea 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -11,24 +11,6 @@ #include #include -#if 1 -#define cvar_string_normal builtin_cvar_string -#define cvar_normal builtin_cvar -#else -string cvar_string_normal(string n) -{ - if (!(cvar_type(n) & CVAR_TYPEFLAG_EXISTS)) - backtrace(strcat("Attempt to access undefined cvar: ", n)); - return builtin_cvar_string(n); -} - -float cvar_normal(string n) -{ - return stof(cvar_string_normal(n)); -} -#endif -#define cvar_set_normal builtin_cvar_set - .vector dropped_origin; entity eliminatedPlayers; diff --git a/qcsrc/server/sys-post.qh b/qcsrc/server/sys-post.qh index 1ccf6695a..6ccb5918c 100644 --- a/qcsrc/server/sys-post.qh +++ b/qcsrc/server/sys-post.qh @@ -2,13 +2,7 @@ #undef droptofloor #undef sound -#undef cvar_set -#undef cvar_string -#undef cvar -var float(string name) cvar; -var string(string name) cvar_string; -var void(string name, string value) cvar_set; var void delete_fn(entity e); #undef IT_SHOTGUN diff --git a/qcsrc/server/sys-pre.qh b/qcsrc/server/sys-pre.qh index 9799a087e..f60bb9984 100644 --- a/qcsrc/server/sys-pre.qh +++ b/qcsrc/server/sys-pre.qh @@ -1,9 +1,6 @@ #pragma once #define droptofloor builtin_droptofloor -#define cvar_set builtin_cvar_set -#define cvar_string builtin_cvar_string -#define cvar builtin_cvar #define IT_SHOTGUN _IT_SHOTGUN /* BIT(0) */ #define IT_SUPER_SHOTGUN _IT_SUPER_SHOTGUN /* BIT(1) */ -- 2.39.2