From: Mario Date: Sat, 18 Jul 2020 09:48:09 +0000 (+1000) Subject: Store the current gametype as a shortname rather than registry ID, fixes some issues... X-Git-Tag: xonotic-v0.8.5~853 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=36c060287c80e935205582a163ceeac7559fe47f;p=xonotic%2Fxonotic-data.pk3dir.git Store the current gametype as a shortname rather than registry ID, fixes some issues related to starting maps with an older menu --- diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index c025bdd46..2129b7802 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -636,7 +636,7 @@ void GameTypeVote_ReadOption(int i) } else { - Gametype type = MapInfo_Type_FromString(gt); + Gametype type = MapInfo_Type_FromString(gt, 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 36c32a057..dce55aa86 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -589,7 +589,7 @@ void _MapInfo_Map_ApplyGametypeEx(string s, Gametype pWantedType, Gametype pThis } } -Gametype MapInfo_Type_FromString(string gtype) +Gametype MapInfo_Type_FromString(string gtype, bool dowarn) { string replacement = ""; switch (gtype) @@ -603,7 +603,7 @@ Gametype MapInfo_Type_FromString(string gtype) } if (replacement != "") { - if (WARN_COND) + if (dowarn && WARN_COND) LOG_WARNF("MapInfo_Type_FromString (probably %s): using deprecated name '%s'. Should use '%s'.", MapInfo_Map_bspname, gtype, replacement); gtype = replacement; } @@ -921,7 +921,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); + Gametype f = MapInfo_Type_FromString(t, true); //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) @@ -932,7 +932,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); + Gametype f = MapInfo_Type_FromString(t, true); if(f) _MapInfo_Map_ApplyGametypeEx (s, pGametypeToSet, f); else if(WARN_COND) @@ -983,7 +983,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))) + if(all || (f = MapInfo_Type_FromString(t, true))) { if((all ? MAPINFO_TYPE_ALL : f.m_flags) & pGametypeToSet.m_flags) { @@ -1000,7 +1000,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))) + if(all || (f = MapInfo_Type_FromString(t, true))) { if((all ? MAPINFO_TYPE_ALL : f.m_flags) & pGametypeToSet.m_flags) { @@ -1148,7 +1148,7 @@ int MapInfo_CurrentFeatures() Gametype MapInfo_CurrentGametype() { - Gametype prev = REGISTRY_GET(Gametypes, cvar("gamecfg")); + Gametype prev = MapInfo_Type_FromString(cvar_string("gamecfg"), false); FOREACH(Gametypes, cvar(it.netname) && it != prev, return it); return prev ? prev : MAPINFO_TYPE_DEATHMATCH; } @@ -1232,7 +1232,7 @@ string MapInfo_ListAllAllowedMaps(float pRequiredFlags, float pForbiddenFlags) void MapInfo_LoadMapSettings_SaveGameType(Gametype t) { MapInfo_SwitchGameType(t); - cvar_set("gamecfg", ftos(t.m_id)); + cvar_set("gamecfg", t.mdl); MapInfo_LoadedGametype = t; } diff --git a/qcsrc/common/mapinfo.qh b/qcsrc/common/mapinfo.qh index 7059a122d..68b5d0b3b 100644 --- a/qcsrc/common/mapinfo.qh +++ b/qcsrc/common/mapinfo.qh @@ -174,7 +174,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); +Gametype MapInfo_Type_FromString(string t, bool dowarn); 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 7166e46ca..876fed7a7 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)); + MapInfo_SwitchGameType(MapInfo_Type_FromString(this.gametype, 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 5745ce072..cf542f39c 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); // try and get the real name of the game type + Gametype j = MapInfo_Type_FromString(typestr, 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 1a01868fb..784288a6e 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -33,7 +33,7 @@ float Campaign_Invalid() string thismapname, wantedmapname; thismapname = GetMapname(); wantedmapname = campaign_gametype[0]; - if(MapInfo_CurrentGametype() != MapInfo_Type_FromString(wantedmapname)) + if(MapInfo_CurrentGametype() != MapInfo_Type_FromString(wantedmapname, false)) return CampaignBailout("wrong game type!"); wantedmapname = campaign_mapname[0]; if(wantedmapname != thismapname) @@ -67,7 +67,7 @@ void CampaignPreInit() if(autocvar_sv_cheats) { - MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0])); + MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0], false)); CampaignFile_Unload(); CampaignBailout("JOLLY CHEATS AHAHAHAHAHAHAH))"); return; @@ -96,7 +96,7 @@ void CampaignPreInit() cvar_settemp("skill", ftos(baseskill)); cvar_settemp("bot_number", ftos(campaign_bots[0])); - MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0])); + MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0], false)); if(Campaign_Invalid()) return; diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 62edb992f..034bd6cb9 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), tsave = MapInfo_CurrentGametype(); + Gametype t = MapInfo_Type_FromString(s, false), tsave = MapInfo_CurrentGametype(); if (t) { diff --git a/qcsrc/server/mapvoting.qc b/qcsrc/server/mapvoting.qc index fe8748f38..e42748306 100644 --- a/qcsrc/server/mapvoting.qc +++ b/qcsrc/server/mapvoting.qc @@ -47,10 +47,10 @@ entity mapvote_ent; */ Gametype GameTypeVote_Type_FromString(string type_name) { - Gametype type = MapInfo_Type_FromString(type_name); + Gametype type = MapInfo_Type_FromString(type_name, false); if (type == NULL) type = MapInfo_Type_FromString(cvar_string( - strcat("sv_vote_gametype_",type_name,"_type"))); + strcat("sv_vote_gametype_",type_name,"_type")), false); return type; } @@ -58,11 +58,11 @@ int GameTypeVote_AvailabilityStatus(string type_name) { int flag = GTV_FORBIDDEN; - Gametype type = MapInfo_Type_FromString(type_name); + Gametype type = MapInfo_Type_FromString(type_name, false); if ( type == NULL ) { type = MapInfo_Type_FromString(cvar_string( - strcat("sv_vote_gametype_",type_name,"_type"))); + strcat("sv_vote_gametype_",type_name,"_type")), false); flag |= GTV_CUSTOM; }