Fix wrong selection in vote menu when selected player leaves

The selection in the kickvote/specvote menu was reset to the first player when the previously selected player leaves or if the filter string does not match it. Now the selection is cleared in these cases, to prevent players from accidentally starting kickvotes/specvotes on the wrong player.

Remove unnecessary `static` variable. Improve readability by not nesting post-increment in another statement.
This commit is contained in:
Robert Müller 2024-01-01 12:15:17 +01:00
parent 5cee4177cd
commit c99d77ab84

View file

@ -568,8 +568,8 @@ bool CMenus::RenderServerControlServer(CUIRect MainView)
bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
{
int NumOptions = 0;
int Selected = 0;
static int aPlayerIDs[MAX_CLIENTS];
int Selected = -1;
int aPlayerIDs[MAX_CLIENTS];
for(const auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
{
if(!pInfoByName)
@ -584,7 +584,8 @@ bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
if(m_CallvoteSelectedPlayer == Index)
Selected = NumOptions;
aPlayerIDs[NumOptions++] = Index;
aPlayerIDs[NumOptions] = Index;
NumOptions++;
}
static CListBox s_ListBox;