From: Rudolf Polzer Date: Thu, 29 Dec 2011 11:04:03 +0000 (+0100) Subject: remove GAME_ globals, they're stupid now X-Git-Tag: xonotic-v0.6.0~74^2~28 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9bc87b511c6daf711937735365adf93db767752d;p=xonotic%2Fxonotic-data.pk3dir.git remove GAME_ globals, they're stupid now --- diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 931e7ea24..3cca609fd 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -1084,7 +1084,7 @@ void Gamemode_Init() { if not(isdemo()) { - localcmd("\n_cl_hook_gamestart ", GametypeNameFromType(gametype), "\n"); + localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n"); calledhooks |= HOOK_START; } } @@ -1120,7 +1120,7 @@ void Ent_ScoresInfo() { float i; self.classname = "ent_client_scores_info"; - gametype = ReadByte(); + gametype = ReadInt24_t(); for(i = 0; i < MAX_SCORE; ++i) { scores_label[i] = strzone(ReadString()); diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index ac2f12cb5..556859a46 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -10,7 +10,7 @@ void Porto_Draw() vector p, dir, ang, q, nextdir; float idx, portal_number, portal1_idx; - if(activeweapon != WEP_PORTO || spectatee_status || gametype == GAME_NEXBALL) + if(activeweapon != WEP_PORTO || spectatee_status || gametype == MAPINFO_TYPE_NEXBALL) return; if(intermission == 1) return; @@ -961,7 +961,7 @@ void CSQC_UpdateView(float w, float h) if(menu_visible) menu_show(); - /*if(gametype == GAME_CTF) + /*if(gametype == MAPINFO_TYPE_CTF) { ctf_view(); } else */ @@ -995,7 +995,7 @@ void CSQC_UpdateView(float w, float h) //else { - if(gametype == GAME_FREEZETAG) + if(gametype == MAPINFO_TYPE_FREEZETAG) { if(getstati(STAT_FROZEN)) drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); @@ -1450,7 +1450,7 @@ void CSQC_common_hud(void) { // do some accuracy var caching float i; - if(!(gametype == GAME_RACE || gametype == GAME_CTS)) + if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) { if(autocvar_accuracy_color_levels != acc_color_levels) { diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index fcdd73601..bf9d7d3a4 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1519,7 +1519,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages); - if ((msg == MSG_SUICIDE || msg == MSG_KILL || msg == MSG_KILL_ACTION) && gametype == GAME_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel + if ((msg == MSG_SUICIDE || msg == MSG_KILL || msg == MSG_KILL_ACTION) && gametype == MAPINFO_TYPE_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel return; if(msg == MSG_SUICIDE) { @@ -2672,7 +2672,7 @@ void HUD_Score(void) if(!autocvar__hud_configure) { if(!autocvar_hud_panel_score) return; - if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return; + if(spectatee_status == -1 && (gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return; } else hud_configure_active_panel = HUD_PANEL_SCORE; @@ -2860,7 +2860,7 @@ void HUD_RaceTimer (void) if(!autocvar__hud_configure) { if(!autocvar_hud_panel_racetimer) return; - if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return; + if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return; if(spectatee_status == -1) return; } else @@ -3012,7 +3012,7 @@ float vote_change; // "time" when vote_active changed void HUD_VoteWindow(void) { - if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE || (serverflags & SERVERFLAG_PLAYERSTATS))) + if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS))) { vote_active = 1; if (autocvar__hud_configure) @@ -3583,7 +3583,7 @@ void HUD_Mod_Race(vector pos, vector mySize) // clientside personal record string rr; - if(gametype == GAME_CTS) + if(gametype == MAPINFO_TYPE_CTS) rr = CTS_RECORD; else rr = RACE_RECORD; @@ -3811,7 +3811,7 @@ void HUD_ModIcons(void) if(!autocvar__hud_configure) { if(!autocvar_hud_panel_modicons) return; - if (gametype != GAME_CTF && gametype != GAME_KEYHUNT && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && gametype != GAME_FREEZETAG && gametype != GAME_KEEPAWAY && gametype != GAME_DOMINATION) return; + if (gametype != MAPINFO_TYPE_CTF && gametype != MAPINFO_TYPE_KEYHUNT && gametype != MAPINFO_TYPE_NEXBALL && gametype != MAPINFO_TYPE_CTS && gametype != MAPINFO_TYPE_RACE && gametype != MAPINFO_TYPE_CA && gametype != MAPINFO_TYPE_FREEZETAG && gametype != MAPINFO_TYPE_KEEPAWAY && gametype != MAPINFO_TYPE_DOMINATION) return; } else hud_configure_active_panel = HUD_PANEL_MODICONS; @@ -3842,19 +3842,19 @@ void HUD_ModIcons(void) } // these MUST be ran in order to update mod_active - if(gametype == GAME_KEYHUNT) + if(gametype == MAPINFO_TYPE_KEYHUNT) HUD_Mod_KH(pos, mySize); - else if(gametype == GAME_CTF || autocvar__hud_configure) + else if(gametype == MAPINFO_TYPE_CTF || autocvar__hud_configure) HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode - else if(gametype == GAME_NEXBALL) + else if(gametype == MAPINFO_TYPE_NEXBALL) HUD_Mod_NexBall(pos, mySize); - else if(gametype == GAME_CTS || gametype == GAME_RACE) + else if(gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE) HUD_Mod_Race(pos, mySize); - else if(gametype == GAME_CA || gametype == GAME_FREEZETAG) + else if(gametype == MAPINFO_TYPE_CA || gametype == MAPINFO_TYPE_FREEZETAG) HUD_Mod_CA(pos, mySize); - else if(gametype == GAME_DOMINATION) + else if(gametype == MAPINFO_TYPE_DOMINATION) HUD_Mod_Dom(pos, mySize); - else if(gametype == GAME_KEEPAWAY) + else if(gametype == MAPINFO_TYPE_KEEPAWAY) HUD_Mod_Keepaway(pos, mySize); } @@ -4149,9 +4149,9 @@ void HUD_InfoMessages(void) s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info")); drawInfoMessage(s) - if(gametype == GAME_ARENA) + if(gametype == MAPINFO_TYPE_ARENA) s = _("^1Wait for your turn to join"); - else if(gametype == GAME_LMS) + else if(gametype == MAPINFO_TYPE_LMS) { entity sk; sk = playerslots[player_localnum]; @@ -4212,7 +4212,7 @@ void HUD_InfoMessages(void) drawInfoMessage(s) } - if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger) + if(teamplay && !intermission && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger) { float ts_min, ts_max; tm = teams.sort_next; @@ -4263,7 +4263,7 @@ void HUD_Physics(void) { if(!autocvar_hud_panel_physics) return; if(spectatee_status == -1 && (autocvar_hud_panel_physics == 1 || autocvar_hud_panel_physics == 3)) return; - if(autocvar_hud_panel_physics == 3 && !(gametype == GAME_RACE || gametype == GAME_CTS)) return; + if(autocvar_hud_panel_physics == 3 && !(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return; } else hud_configure_active_panel = HUD_PANEL_PHYSICS; @@ -4787,9 +4787,9 @@ Main HUD system void HUD_Reset (void) { // reset gametype specific icons - if(gametype == GAME_KEYHUNT) + if(gametype == MAPINFO_TYPE_KEYHUNT) HUD_Mod_KH_Reset(); - else if(gametype == GAME_CTF) + else if(gametype == MAPINFO_TYPE_CTF) HUD_Mod_CTF_Reset(); } diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 3124b4b9b..9b93aa8a2 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -924,7 +924,7 @@ float HUD_WouldDrawScoreboard() { return 1; else if (intermission == 2) return 0; - else if (spectatee_status != -1 && getstati(STAT_HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != GAME_CTS) + else if (spectatee_status != -1 && getstati(STAT_HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS) return 1; else if (scoreboard_showscores_force) return 1; @@ -1263,7 +1263,7 @@ void HUD_DrawScoreboard() } } - if(gametype == GAME_CTS || gametype == GAME_RACE) { + if(gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE) { if(race_speedaward) { drawcolorcodedstring(pos, sprintf(_("Speed award: %d ^7(%s^7)"), race_speedaward, race_speedaward_holder), hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL); pos_y += 1.25 * hud_fontsize_y; @@ -1312,7 +1312,7 @@ void HUD_DrawScoreboard() tl = getstatf(STAT_TIMELIMIT); fl = getstatf(STAT_FRAGLIMIT); ll = getstatf(STAT_LEADLIMIT); - if(gametype == GAME_LMS) + if(gametype == MAPINFO_TYPE_LMS) { if(tl > 0) str = strcat(str, sprintf(_(" for up to ^1%1.0f minutes^7"), tl)); diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 55834f1a6..d4d0e3a0d 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -23,25 +23,6 @@ // Revision 22: hook shot origin #define CSQC_REVISION 22 -// probably put these in common/ -// so server/ and client/ can be synced better -const float GAME_DEATHMATCH = 1; -const float GAME_TEAM_DEATHMATCH = 2; -const float GAME_DOMINATION = 3; -const float GAME_CTF = 4; -const float GAME_RUNEMATCH = 5; -const float GAME_LMS = 6; -const float GAME_ARENA = 7; -const float GAME_KEYHUNT = 8; -const float GAME_ASSAULT = 9; -const float GAME_ONSLAUGHT = 10; -const float GAME_RACE = 11; -const float GAME_NEXBALL = 12; -const float GAME_CTS = 13; -const float GAME_CA = 14; -const float GAME_FREEZETAG = 15; -const float GAME_KEEPAWAY = 16; - const float AS_STRING = 1; const float AS_INT = 2; const float AS_FLOAT_TRUNCATED = 2; diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index f38b1156b..9daab8b4f 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -396,27 +396,6 @@ void buf_save(float buf, string pFilename) fclose(fh); } -string GametypeNameFromType(float g) -{ - if (g == GAME_DEATHMATCH) return "dm"; - else if (g == GAME_TEAM_DEATHMATCH) return "tdm"; - else if (g == GAME_DOMINATION) return "dom"; - else if (g == GAME_CTF) return "ctf"; - else if (g == GAME_RUNEMATCH) return "rune"; - else if (g == GAME_LMS) return "lms"; - else if (g == GAME_ARENA) return "arena"; - else if (g == GAME_CA) return "ca"; - else if (g == GAME_KEYHUNT) return "kh"; - else if (g == GAME_ONSLAUGHT) return "ons"; - else if (g == GAME_ASSAULT) return "as"; - else if (g == GAME_RACE) return "rc"; - else if (g == GAME_NEXBALL) return "nexball"; - else if (g == GAME_CTS) return "cts"; - else if (g == GAME_FREEZETAG) return "freezetag"; - else if (g == GAME_KEEPAWAY) return "ka"; - return "dm"; -} - string mmsss(float tenths) { float minutes; @@ -1410,7 +1389,7 @@ string textShortenToLength(string theText, float maxWidth, textLengthUpToLength_ float isGametypeInFilter(float gt, float tp, float ts, string pattern) { string subpattern, subpattern2, subpattern3, subpattern4; - subpattern = strcat(",", GametypeNameFromType(gt), ","); + subpattern = strcat(",", MapInfo_Type_ToString(gt), ","); if(tp) subpattern2 = ",teams,"; else @@ -1419,7 +1398,7 @@ float isGametypeInFilter(float gt, float tp, float ts, string pattern) subpattern3 = ",teamspawns,"; else subpattern3 = ",noteamspawns,"; - if(gt == GAME_RACE || gt == GAME_CTS) + if(gt == MAPINFO_TYPE_RACE || gt == MAPINFO_TYPE_CTS) subpattern4 = ",race,"; else subpattern4 = string_null; diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 470a826ed..6d4eb6113 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -59,7 +59,6 @@ void buf_save(float buf, string filename); float mod(float a, float b) { return a - (floor(a / b) * b); } #endif -string GametypeNameFromType(float g); #define TIME_TO_NTHS(t,n) floor((t) * (n) + 0.4) string mmsss(float t); string mmssss(float t); diff --git a/qcsrc/menu/xonotic/serverlist.c b/qcsrc/menu/xonotic/serverlist.c index b7757f299..82fdbfb5e 100644 --- a/qcsrc/menu/xonotic/serverlist.c +++ b/qcsrc/menu/xonotic/serverlist.c @@ -427,24 +427,24 @@ void ServerList_TypeSort_Click(entity btn, entity me) else s = ""; - for(i = 1; ; ++i) // 20 modes ought to be enough for anyone + for(i = 1; ; i *= 2) // 20 modes ought to be enough for anyone { - t = GametypeNameFromType(i); + t = MapInfo_Type_ToString(i); if(i > 1) - if(t == GametypeNameFromType(0)) // it repeats (default case) + if(t == "") // it repeats (default case) { // no type was found // choose the first one - s = t; + s = MapInfo_Type_ToString(1); break; } - if(s == GametypeNameFromType(i)) + if(s == t) { // the type was found // choose the next one - s = GametypeNameFromType(i + 1); - if(s == GametypeNameFromType(0)) - s = ""; + s = MapInfo_Type_ToString(i * 2); + if(s == "") + s = MapInfo_Type_ToString(1); break; } } diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index f504e14bb..c409b343a 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1504,8 +1504,6 @@ void ClientConnect (void) else stuffcmd(self, "set _teams_available 0\n"); - stuffcmd(self, strcat("set gametype ", ftos(game), "\n")); - if(g_arena || g_ca) { self.classname = "observer"; diff --git a/qcsrc/server/constants.qh b/qcsrc/server/constants.qh index 7cefb530d..b95c72613 100644 --- a/qcsrc/server/constants.qh +++ b/qcsrc/server/constants.qh @@ -133,8 +133,6 @@ float MSG_ENTITY = 5; // csqc //float GAME_FULLBRIGHT_PLAYERS = 64; /// makes the players model fullbright //float GAME_TEAMS = 128; /// Teams, red/green/yellow/blue -float game; // set to "gamecfg" on spawnfunc_worldspawn - //float POWERUP_STRENGTH_DAMAGE = 2; // damage multiplier for strength powerup //float POWERUP_STRENGTH_FORCE = 4; // force multiplier for strength powerup diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 4d24b5a91..f115434a2 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -993,7 +993,7 @@ void spawnfunc_light (void) string GetGametype() { - return GametypeNameFromType(game); + return MapInfo_Type_ToString(MapInfo_LoadedGametype); } string getmapname_stored; diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 698e947da..b56065ded 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -173,7 +173,7 @@ float ScoreInfo_SendEntity(entity to, float sf) { float i; WriteByte(MSG_ENTITY, ENT_CLIENT_SCORES_INFO); - WriteByte(MSG_ENTITY, game); + WriteInt24_t(MSG_ENTITY, MapInfo_LoadedGametype); for(i = 0; i < MAX_SCORE; ++i) { WriteString(MSG_ENTITY, scores_label[i]); diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index 7ec4b49d6..cefba0374 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -245,8 +245,9 @@ void StartFrame (void) float DoesQ3ARemoveThisEntity(); void SV_OnEntityPreSpawnFunction() { - if(self.gametypefilter != "") - if not(isGametypeInFilter(game, teamplay, have_team_spawns, self.gametypefilter)) + if (self) + if (self.gametypefilter != "") + if not(isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, self.gametypefilter)) { remove(self); return; diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 59428ef60..cfadcf699 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -135,13 +135,11 @@ void InitGameplayMode() if(g_dm) { - game = GAME_DEATHMATCH; gamemode_name = "Deathmatch"; } if(g_tdm) { - game = GAME_TEAM_DEATHMATCH; gamemode_name = "Team Deathmatch"; ActivateTeamplay(); tdm_init(); @@ -151,7 +149,6 @@ void InitGameplayMode() if(g_domination) { - game = GAME_DOMINATION; gamemode_name = "Domination"; ActivateTeamplay(); fraglimit_override = autocvar_g_domination_point_limit; @@ -162,7 +159,6 @@ void InitGameplayMode() if(g_ctf) { - game = GAME_CTF; gamemode_name = "Capture the Flag"; ActivateTeamplay(); g_ctf_ignore_frags = autocvar_g_ctf_ignore_frags; @@ -182,7 +178,6 @@ void InitGameplayMode() if(g_runematch) { - game = GAME_RUNEMATCH; gamemode_name = "Rune Match"; // ActivateTeamplay(); fraglimit_override = autocvar_g_runematch_point_limit; @@ -192,7 +187,6 @@ void InitGameplayMode() if(g_lms) { - game = GAME_LMS; gamemode_name = "Last Man Standing"; fraglimit_override = autocvar_g_lms_lives_override; leadlimit_override = 0; // not supported by LMS @@ -205,7 +199,6 @@ void InitGameplayMode() if(g_arena) { - game = GAME_ARENA; gamemode_name = "Arena"; fraglimit_override = autocvar_g_arena_point_limit; leadlimit_override = autocvar_g_arena_point_leadlimit; @@ -217,7 +210,6 @@ void InitGameplayMode() if(g_ca) { - game = GAME_CA; gamemode_name = "Clan Arena"; ActivateTeamplay(); fraglimit_override = autocvar_g_ca_point_limit; @@ -227,7 +219,6 @@ void InitGameplayMode() } if(g_keyhunt) { - game = GAME_KEYHUNT; gamemode_name = "Key Hunt"; ActivateTeamplay(); fraglimit_override = autocvar_g_keyhunt_point_limit; @@ -237,7 +228,6 @@ void InitGameplayMode() if(g_freezetag) { - game = GAME_FREEZETAG; gamemode_name = "Freeze Tag"; ActivateTeamplay(); fraglimit_override = autocvar_g_freezetag_point_limit; @@ -247,7 +237,6 @@ void InitGameplayMode() if(g_assault) { - game = GAME_ASSAULT; gamemode_name = "Assault"; ActivateTeamplay(); ScoreRules_assault(); @@ -256,7 +245,6 @@ void InitGameplayMode() if(g_onslaught) { - game = GAME_ONSLAUGHT; gamemode_name = "Onslaught"; ActivateTeamplay(); have_team_spawns = -1; // request team spawns @@ -264,7 +252,6 @@ void InitGameplayMode() if(g_race) { - game = GAME_RACE; gamemode_name = "Race"; if(autocvar_g_race_teams) @@ -283,7 +270,6 @@ void InitGameplayMode() if(g_cts) { - game = GAME_CTS; gamemode_name = "CTS"; g_race_qualifying = 1; fraglimit_override = 0; @@ -292,7 +278,6 @@ void InitGameplayMode() if(g_nexball) { - game = GAME_NEXBALL; gamemode_name = "Nexball"; fraglimit_override = autocvar_g_nexball_goallimit; leadlimit_override = autocvar_g_nexball_goalleadlimit; @@ -303,7 +288,6 @@ void InitGameplayMode() if(g_keepaway) { - game = GAME_KEEPAWAY; gamemode_name = "Keepaway"; MUTATOR_ADD(gamemode_keepaway); } @@ -311,9 +295,6 @@ void InitGameplayMode() if(teamplay) entcs_init(); - // save it (for the next startup) - cvar_set("gamecfg", ftos(game)); - cache_mutatormsg = strzone(""); cache_lastmutatormsg = strzone("");