Don't allow random_map when no maps are available in votes

This commit is contained in:
def 2014-01-29 02:04:02 +01:00
parent fea96c411a
commit 69df267bb1

View file

@ -1547,6 +1547,7 @@ void CGameContext::ConRandomMap(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
int NumMaps = 0;
int NumVotes = 0;
int OurMap;
char* pMapName;
char pQuotedMapName[64];
@ -1554,13 +1555,23 @@ void CGameContext::ConRandomMap(IConsole::IResult *pResult, void *pUserData)
CVoteOptionServer *pOption = pSelf->m_pVoteOptionFirst;
while(pOption)
{
NumMaps++;
if(strncmp(pOption->m_aCommand, "change_map ", 11) == 0
|| strncmp(pOption->m_aCommand, "sv_map ", 7) == 0)
NumMaps++;
NumVotes++;
pOption = pOption->m_pNext;
}
if(!NumMaps)
{
pSelf->SendChat(-1, CGameContext::CHAT_ALL, "random_map called, but no maps available in votes");
return;
}
while(true)
{
OurMap = rand() % NumMaps;
OurMap = rand() % NumVotes;
pOption = pSelf->m_pVoteOptionFirst;
while(OurMap > 0)