]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'drjaska/invalid-sv_vote_gametype_options' into 'master'
authorterencehill <piuntn@gmail.com>
Mon, 5 Jun 2023 17:09:40 +0000 (17:09 +0000)
committerterencehill <piuntn@gmail.com>
Mon, 5 Jun 2023 17:09:40 +0000 (17:09 +0000)
Fixed `sv_vote_gametype_options` so that it defaults to the current gametype if it has no valid gametypes.

See merge request xonotic/xonotic-data.pk3dir!1190

1  2 
qcsrc/server/mapvoting.qc

index d68b35f435bd0ecced8049fc5886ba0dab5c4dc2,d29927234070968cb86242140367de60c28fc0ce..051968eb00c488cbef6ebc9d53f2dcca818a9fca
@@@ -89,6 -89,10 +89,10 @@@ int GameTypeVote_GetMask(
        gametype_mask = 0;
        for(j = 0; j < n; ++j)
                gametype_mask |= GameTypeVote_Type_FromString(argv(j)).m_flags;
+       if (gametype_mask == 0)
+               gametype_mask |= MapInfo_CurrentGametype().m_flags;
        return gametype_mask;
  }
  
@@@ -197,32 -201,9 +201,32 @@@ void MapVote_AddVotable(string nextMap
        mapvote_count += 1;
  }
  
 +void MapVote_AddVotableMaps(int nmax, int smax)
 +{
 +      int available_maps = 0;
 +      if (autocvar_g_maplist != "")
 +      {
 +              int c = tokenizebyseparator(autocvar_g_maplist, " ");
 +              for (int i = 0; i < c; ++i)
 +              {
 +                      if (Map_Check(i, 1) || Map_Check(i, 2))
 +                              ++available_maps;
 +              }
 +      }
 +      int max_attempts = available_maps;
 +      if (available_maps >= 2)
 +              max_attempts = min(available_maps * 5, 100);
 +
 +      if (smax && mapvote_suggestion_ptr)
 +              for(int i = 0; i < max_attempts && mapvote_count < smax; ++i)
 +                      MapVote_AddVotable(mapvote_suggestions[floor(random() * mapvote_suggestion_ptr)], true);
 +
 +      for (int i = 0; i < max_attempts && mapvote_count < nmax; ++i)
 +              MapVote_AddVotable(GetNextMap(), false);
 +}
 +
  void MapVote_Init()
  {
 -      int i;
        int nmax, smax;
  
        MapVote_ClearAllVotes();
        if(mapvote_screenshot_dirs_count == 0)
                mapvote_screenshot_dirs_count = tokenize_console("maps levelshots");
        mapvote_screenshot_dirs_count = min(mapvote_screenshot_dirs_count, MAPVOTE_SCREENSHOT_DIRS_COUNT);
 -      for(i = 0; i < mapvote_screenshot_dirs_count; ++i)
 +      for(int i = 0; i < mapvote_screenshot_dirs_count; ++i)
                mapvote_screenshot_dirs[i] = strzone(argv(i));
  
 -      if(mapvote_suggestion_ptr)
 -              for(i = 0; i < 100 && mapvote_count < smax; ++i)
 -                      MapVote_AddVotable(mapvote_suggestions[floor(random() * mapvote_suggestion_ptr)], true);
 -
 -      for(i = 0; i < 100 && mapvote_count < nmax; ++i)
 -              MapVote_AddVotable(GetNextMap(), false);
 +      MapVote_AddVotableMaps(nmax, smax);
  
        if(mapvote_count == 0)
        {
                if(autocvar_g_maplist_shuffle)
                        ShuffleMaplist();
                localcmd("\nmenu_cmd sync\n");
 -              for(i = 0; i < 100 && mapvote_count < nmax; ++i)
 -                      MapVote_AddVotable(GetNextMap(), false);
 +              MapVote_AddVotableMaps(nmax, 0);
        }
  
        mapvote_count_real = mapvote_count;