From 95e0ab5eeb287846e99bf2dd41475d1f3aff58b8 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 5 Aug 2020 12:00:50 +1000 Subject: [PATCH] Replace "arena" with "ca" when parsing Q3 .arena and .defi files --- qcsrc/client/mapvoting.qc | 2 +- qcsrc/common/mapinfo.qc | 15 ++++++++------- qcsrc/common/mapinfo.qh | 2 +- qcsrc/common/mapobjects/target/changelevel.qc | 2 +- .../xonotic/dialog_multiplayer_join_serverinfo.qc | 2 +- qcsrc/server/campaign.qc | 6 +++--- qcsrc/server/command/sv_cmd.qc | 2 +- qcsrc/server/mapvoting.qc | 8 ++++---- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index a38bb76cf..76c1e75fc 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -637,7 +637,7 @@ void GameTypeVote_ReadOption(int i) } else { - Gametype type = MapInfo_Type_FromString(gt, false); + Gametype type = MapInfo_Type_FromString(gt, false, false); mv_pk3[i] = strzone(MapInfo_Type_ToText(type)); mv_desc[i] = MapInfo_Type_Description(type); } diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 9e0648db4..08db62281 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -610,7 +610,7 @@ void _MapInfo_Map_ApplyGametypeEx(string s, Gametype pWantedType, Gametype pThis } } -Gametype MapInfo_Type_FromString(string gtype, bool dowarn) +Gametype MapInfo_Type_FromString(string gtype, bool dowarn, bool is_q3compat) { string replacement = ""; bool do_warn = true; @@ -628,6 +628,7 @@ Gametype MapInfo_Type_FromString(string gtype, bool dowarn) case "oneflag": replacement = "ctf"; do_warn = false; break; case "team": replacement = "tdm"; do_warn = false; break; case "tourney": replacement = "duel"; do_warn = false; break; + case "arena": if(is_q3compat) { replacement = "ca"; do_warn = false; } break; } if (replacement != "") { @@ -900,7 +901,7 @@ bool _MapInfo_ParseArena(string arena_filename, int fh, string pFilename, Gamety // type in quake 3 holds all the supported gametypes, so we must loop through all of them FOREACH_WORD(s, true, { - Gametype f = MapInfo_Type_FromString(it, false); + Gametype f = MapInfo_Type_FromString(it, false, true); if(f) stored_supportedGametypes |= f.m_flags; }); @@ -1155,7 +1156,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet else if(t == "type") { t = car(s); s = cdr(s); - Gametype f = MapInfo_Type_FromString(t, true); + Gametype f = MapInfo_Type_FromString(t, true, false); //if(WARN_COND) //LOG_WARN("Map ", pFilename, " contains the legacy 'type' keyword which is deprecated and will be removed in the future. Please migrate the mapinfo file to 'gametype'."); if(f) @@ -1166,7 +1167,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet else if(t == "gametype") { t = car(s); s = cdr(s); - Gametype f = MapInfo_Type_FromString(t, true); + Gametype f = MapInfo_Type_FromString(t, true, false); if(f) _MapInfo_Map_ApplyGametypeEx (s, pGametypeToSet, f); else if(WARN_COND) @@ -1217,7 +1218,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet t = car(s); s = cdr(s); bool all = t == "all"; Gametype f = NULL; - if(all || (f = MapInfo_Type_FromString(t, true))) + if(all || (f = MapInfo_Type_FromString(t, true, false))) { if((all ? MAPINFO_TYPE_ALL : f.m_flags) & pGametypeToSet.m_flags) { @@ -1234,7 +1235,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet t = car(s); s = cdr(s); bool all = t == "all"; Gametype f = NULL; - if(all || (f = MapInfo_Type_FromString(t, true))) + if(all || (f = MapInfo_Type_FromString(t, true, false))) { if((all ? MAPINFO_TYPE_ALL : f.m_flags) & pGametypeToSet.m_flags) { @@ -1383,7 +1384,7 @@ int MapInfo_CurrentFeatures() Gametype MapInfo_CurrentGametype() { - Gametype prev = MapInfo_Type_FromString(cvar_string("gamecfg"), false); + Gametype prev = MapInfo_Type_FromString(cvar_string("gamecfg"), false, false); FOREACH(Gametypes, cvar(it.netname) && it != prev, return it); return prev ? prev : MAPINFO_TYPE_DEATHMATCH; } diff --git a/qcsrc/common/mapinfo.qh b/qcsrc/common/mapinfo.qh index 18044b1b4..b10f930d0 100644 --- a/qcsrc/common/mapinfo.qh +++ b/qcsrc/common/mapinfo.qh @@ -175,7 +175,7 @@ string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden); // gets a gametype from a string string _MapInfo_GetDefaultEx(Gametype t); float _MapInfo_GetTeamPlayBool(Gametype t); -Gametype MapInfo_Type_FromString(string t, bool dowarn); +Gametype MapInfo_Type_FromString(string t, bool dowarn, bool is_q3compat); string MapInfo_Type_Description(Gametype t); string MapInfo_Type_ToString(Gametype t); string MapInfo_Type_ToText(Gametype t); diff --git a/qcsrc/common/mapobjects/target/changelevel.qc b/qcsrc/common/mapobjects/target/changelevel.qc index 876fed7a7..2cc3c58ba 100644 --- a/qcsrc/common/mapobjects/target/changelevel.qc +++ b/qcsrc/common/mapobjects/target/changelevel.qc @@ -28,7 +28,7 @@ void target_changelevel_use(entity this, entity actor, entity trigger) } if(this.gametype != "") - MapInfo_SwitchGameType(MapInfo_Type_FromString(this.gametype, false)); + MapInfo_SwitchGameType(MapInfo_Type_FromString(this.gametype, false, false)); if (this.chmap == "") { diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc index cf542f39c..a4577d31f 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc @@ -84,7 +84,7 @@ void XonoticServerInfoDialog_loadServerInfo(entity me, float i) if(s != "data") modname = sprintf("%s (%s)", modname, s); - Gametype j = MapInfo_Type_FromString(typestr, false); // try and get the real name of the game type + Gametype j = MapInfo_Type_FromString(typestr, false, false); // try and get the real name of the game type if(j) { typestr = MapInfo_Type_ToText(j); } // only set it if we actually found it me.currentServerType = strzone(typestr); diff --git a/qcsrc/server/campaign.qc b/qcsrc/server/campaign.qc index de46e57d5..8f78d5667 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -34,7 +34,7 @@ float Campaign_Invalid() string thismapname, wantedmapname; thismapname = GetMapname(); wantedmapname = campaign_gametype[0]; - if(MapInfo_CurrentGametype() != MapInfo_Type_FromString(wantedmapname, false)) + if(MapInfo_CurrentGametype() != MapInfo_Type_FromString(wantedmapname, false, false)) return CampaignBailout("wrong game type!"); wantedmapname = campaign_mapname[0]; if(wantedmapname != thismapname) @@ -68,7 +68,7 @@ void CampaignPreInit() if(autocvar_sv_cheats) { - MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0], false)); + MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0], false, false)); CampaignFile_Unload(); CampaignBailout("JOLLY CHEATS AHAHAHAHAHAHAH))"); return; @@ -97,7 +97,7 @@ void CampaignPreInit() cvar_settemp("skill", ftos(baseskill)); cvar_settemp("bot_number", ftos(campaign_bots[0])); - MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0], false)); + MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0], false, false)); if(Campaign_Invalid()) return; diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 7de740bdd..f316a14bc 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -723,7 +723,7 @@ void GameCommand_gametype(int request, int argc) if (argv(1) != "") { string s = argv(1); - Gametype t = MapInfo_Type_FromString(s, false), tsave = MapInfo_CurrentGametype(); + Gametype t = MapInfo_Type_FromString(s, false, false), tsave = MapInfo_CurrentGametype(); if (t) { diff --git a/qcsrc/server/mapvoting.qc b/qcsrc/server/mapvoting.qc index ac64f630f..dea10ac32 100644 --- a/qcsrc/server/mapvoting.qc +++ b/qcsrc/server/mapvoting.qc @@ -49,10 +49,10 @@ entity mapvote_ent; */ Gametype GameTypeVote_Type_FromString(string type_name) { - Gametype type = MapInfo_Type_FromString(type_name, false); + Gametype type = MapInfo_Type_FromString(type_name, false, false); if (type == NULL) type = MapInfo_Type_FromString(cvar_string( - strcat("sv_vote_gametype_",type_name,"_type")), false); + strcat("sv_vote_gametype_",type_name,"_type")), false, false); return type; } @@ -60,11 +60,11 @@ int GameTypeVote_AvailabilityStatus(string type_name) { int flag = GTV_FORBIDDEN; - Gametype type = MapInfo_Type_FromString(type_name, false); + Gametype type = MapInfo_Type_FromString(type_name, false, false); if ( type == NULL ) { type = MapInfo_Type_FromString(cvar_string( - strcat("sv_vote_gametype_",type_name,"_type")), false); + strcat("sv_vote_gametype_",type_name,"_type")), false, false); flag |= GTV_CUSTOM; } -- 2.39.2