DoktorSAS / H1Mapvote

Call of Duty: Modern Warfare Remastered multiplayer mapvote
GNU General Public License v3.0
16 stars 7 forks source link

Fix for "Invalid" appearing on maps and/or gametypes during voting #13

Open piergud opened 3 weeks ago

piergud commented 3 weeks ago

When mv_maps_norepeat/mp_gametypes_norepeat is set, and the amount of maps/game types is less than the amount of selection options, the rest of the options show up as "Invalid".

Instead, it should cycle through the available maps/game types again.

Screenshot below shows the issue. In this example, the two selections near the end have invalid game types. This happens because the server only has 3 game types but there's 6 options.

image

DoktorSAS commented 3 weeks ago

It should not cycle to the one are already selected. If it cycle mv_gametypes_norepeat will lose its use. The issue you are running into is the mapvote can't find another gametypes because it already got selected and so it got removed from the list.

You can solve it by setting mv_gametypes_norepeat to 0 or repeat the gametype in mv_gametypes.

Thanks.

piergud commented 3 weeks ago

It would only cycle if the amount of game types is less than the amount of selection options. It's impossible to not have some duplicates in such a scenario.

Setting mv_gametypes_no_repeat to 0 is different. That would pick at random with chances of many duplicates.

Repeating game types in mv_gametypes works. Although, I don't think users would know to do that unless they were already familiar with why this issue happens.

DoktorSAS commented 2 weeks ago

Oh pardon. Then its a fine solution. ArrayCopy should not be required in this game so a probable solution like yours would be the following

MapvoteChooseRandomGametypesSelection(gametypesIDsList, times) // Select random map from the list
{
    gametypeschoosed = [];
    _gametypesIDsList = gametypesIDsList;
    for (i = 0; i < times; i++)
    {
        index = randomIntRange(0, gametypesIDsList.size);
        gametype = gametypesIDsList[index];
        gametypeschoosed[i] = gametype;
        if (GetDvarInt("mv_gametypes_norepeat"))
        {
            gametypesIDsList = ArrayRemoveElement(gametypesIDsList, gametype);
            if(gametypesIDsList.size == 0)
            {
                gametypesIDsList = _gametypesIDsList;
            }
        }

        // arrayremovevalue(mapsIDsList , map);
    }

    return gametypeschoosed;

Could you test the following and let me know of an issue?

Thanks in regards

piergud commented 2 weeks ago

Yup it works. Thanks, I updated the PR