MapVote_AddVotable(GetNextMap(), false);
}
-bool GameTypeVote_SetGametype(Gametype type);
-
-// gametype_name can be the name of a custom gametype based on Gametype type
-void GameTypeVote_ApplyGameType(Gametype type, string gametype_name)
-{
- if (gametype_name == "")
- gametype_name = MapInfo_Type_ToString(type);
-
- localcmd("sv_vote_gametype_hook_all\n");
- localcmd("sv_vote_gametype_hook_", gametype_name, "\n");
-
- if (!GameTypeVote_SetGametype(type))
- LOG_TRACE("Selected gametype is not supported by any map");
-}
-
string voted_gametype_string;
Gametype voted_gametype;
Gametype match_gametype;
// In this case apply back match_gametype here so that the "restart" command, if called,
// properly restarts the map applying the current game type.
// Applying voted_gametype before map vote start is needed to properly initialize map vote.
+ string gametype_custom_string = "";
+ if (gametype_custom_enabled)
+ gametype_custom_string = loaded_gametype_custom_string;
if (match_gametype)
- GameTypeVote_ApplyGameType(match_gametype, loaded_gametype_custom_string);
+ GameTypeVote_SetGametype(match_gametype, gametype_custom_string, true);
}
void MapVote_SendPicture(entity to, int id)
currentPlace = 0;
currentVotes = -1;
string current_gametype_string;
- if (loaded_gametype_custom_string != "")
+ if (gametype_custom_enabled)
current_gametype_string = loaded_gametype_custom_string;
else
current_gametype_string = MapInfo_Type_ToString(MapInfo_CurrentGametype());
{
if (voted_gametype)
{
- // clear match_gametype so that GameTypeVote_ApplyGameType
+ // clear match_gametype so that GameTypeVote_SetGametype
// prints the game type switch message
match_gametype = NULL;
- GameTypeVote_ApplyGameType(voted_gametype, voted_gametype_string);
+ GameTypeVote_SetGametype(voted_gametype, voted_gametype_string, true);
}
Map_Goto_SetStr(mapvote_maps[mapvote_winner]);
MapVote_Tick();
}
-bool GameTypeVote_SetGametype(Gametype type)
+// if gametype_string is "" then gametype_string is inferred from Gametype type
+// otherwise gametype_string is the string (short name) of a custom gametype
+bool GameTypeVote_SetGametype(Gametype type, string gametype_string, bool call_hooks)
{
+ if (!call_hooks)
+ {
+ // custom gametype is disabled because gametype hooks can't be executed
+ gametype_custom_enabled = false;
+ }
+ else
+ {
+ if (gametype_string == "")
+ gametype_string = MapInfo_Type_ToString(type);
+ gametype_custom_enabled = (gametype_string != MapInfo_Type_ToString(type));
+
+ localcmd("sv_vote_gametype_hook_all\n");
+ localcmd("sv_vote_gametype_hook_", gametype_string, "\n");
+ }
+
if (MapInfo_CurrentGametype() == type)
return true;
bprint("Cannot use this game type: no map for it found\n");
MapInfo_SwitchGameType(tsave);
MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
+ LOG_TRACE("Selected gametype is not supported by any map");
return false;
}
voted_gametype = GameTypeVote_Type_FromString(mapvote_maps[pos]);
strcpy(voted_gametype_string, mapvote_maps[pos]);
- GameTypeVote_ApplyGameType(voted_gametype, voted_gametype_string);
+ GameTypeVote_SetGametype(voted_gametype, voted_gametype_string, true);
// save to a cvar so it can be applied back when gametype is temporary
// changed on gametype vote end of the next game
if ( mapvote_count > 0 )
strunzone(mapvote_maps[0]);
string current_gametype_string;
- if (loaded_gametype_custom_string != "")
+ if (gametype_custom_enabled)
current_gametype_string = loaded_gametype_custom_string;
else
current_gametype_string = MapInfo_Type_ToString(MapInfo_CurrentGametype());