From: Mattia Basaglia Date: Wed, 8 Jul 2015 21:10:42 +0000 (+0200) Subject: Allow cvar-based gametype vote options X-Git-Tag: xonotic-v0.8.1~43^2~8 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9610bde983891e6c1992bb559ca1f5542f2e7224;p=xonotic%2Fxonotic-data.pk3dir.git Allow cvar-based gametype vote options --- diff --git a/qcsrc/server/mapvoting.qc b/qcsrc/server/mapvoting.qc index cf5df9da3..104478120 100644 --- a/qcsrc/server/mapvoting.qc +++ b/qcsrc/server/mapvoting.qc @@ -9,9 +9,22 @@ #include "../common/playerstats.qh" #include "../common/util.qh" +/** + * Returns the gamtype ID from its name, if type_name isn't a real gametype it + * checks for sv_vote_gametype_(type_name)_type + */ +float GameTypeVote_Type_FromString(string type_name) +{ + float type = MapInfo_Type_FromString(type_name); + if ( type == 0 ) + type = MapInfo_Type_FromString(cvar_string( + strcat("sv_vote_gametype_",type_name,"_type"))); + return type; +} + float GameTypeVote_AvailabilityStatus(string gtname) { - float type = MapInfo_Type_FromString(gtname); + float type = GameTypeVote_Type_FromString(gtname); if( type == 0 ) return GTV_FORBIDDEN; @@ -33,7 +46,7 @@ float GameTypeVote_GetMask() n = min(MAPVOTE_COUNT, n); gametype_mask = 0; for(j = 0; j < n; ++j) - gametype_mask |= MapInfo_Type_FromString(argv(j)); + gametype_mask |= GameTypeVote_Type_FromString(argv(j)); return gametype_mask; } @@ -658,7 +671,7 @@ float GameTypeVote_Finished(float pos) if(!gametypevote || gametypevote_finished) return false; - if ( !GameTypeVote_SetGametype(MapInfo_Type_FromString(mapvote_maps[pos])) ) + if ( !GameTypeVote_SetGametype(GameTypeVote_Type_FromString(mapvote_maps[pos])) ) { dprint("Selected gametype is not supported by any map"); } @@ -674,7 +687,7 @@ float GameTypeVote_Finished(float pos) float GameTypeVote_AddVotable(string nextMode) { float j; - if ( nextMode == "" || MapInfo_Type_FromString(nextMode) == 0 ) + if ( nextMode == "" || GameTypeVote_Type_FromString(nextMode) == 0 ) return false; for(j = 0; j < mapvote_count; ++j) if(mapvote_maps[j] == nextMode)