diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 0cf9bc585..5834d074e 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -907,18 +907,33 @@ void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData) void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; + const char *pString = pResult->GetString(0); + // check for valid option - if(!pSelf->Console()->LineIsValid(pResult->GetString(0))) + if(!pSelf->Console()->LineIsValid(pString)) { char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "skipped invalid option '%s'", pResult->GetString(0)); + str_format(aBuf, sizeof(aBuf), "skipped invalid option '%s'", pString); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); return; } - - int Len = str_length(pResult->GetString(0)); - CGameContext::CVoteOption *pOption = (CGameContext::CVoteOption *)pSelf->m_pVoteOptionHeap->Allocate(sizeof(CGameContext::CVoteOption) + Len); + CGameContext::CVoteOption *pOption = pSelf->m_pVoteOptionFirst; + while(pOption) + { + if(str_comp_nocase(pString, pOption->m_aCommand) == 0) + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "option '%s' already exists", pString); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); + return; + } + pOption = pOption->m_pNext; + } + + int Len = str_length(pString); + + pOption = (CGameContext::CVoteOption *)pSelf->m_pVoteOptionHeap->Allocate(sizeof(CGameContext::CVoteOption) + Len); pOption->m_pNext = 0; pOption->m_pPrev = pSelf->m_pVoteOptionLast; if(pOption->m_pPrev) @@ -927,7 +942,7 @@ void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData) if(!pSelf->m_pVoteOptionFirst) pSelf->m_pVoteOptionFirst = pOption; - mem_copy(pOption->m_aCommand, pResult->GetString(0), Len+1); + mem_copy(pOption->m_aCommand, pString, Len+1); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "added option '%s'", pOption->m_aCommand); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);