mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fix exception in GetAnnouncementLine with empty list
This commit is contained in:
parent
8ffc7967f8
commit
fbda0468c6
|
@ -3667,7 +3667,12 @@ const char *CServer::GetAnnouncementLine(char const *pFileName)
|
|||
if(str_length(pLine))
|
||||
if(pLine[0] != '#')
|
||||
Lines.push_back(pLine);
|
||||
if(Lines.size() == 1)
|
||||
|
||||
if(Lines.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if(Lines.size() == 1)
|
||||
{
|
||||
m_AnnouncementLastLine = 0;
|
||||
}
|
||||
|
@ -3680,8 +3685,9 @@ const char *CServer::GetAnnouncementLine(char const *pFileName)
|
|||
{
|
||||
unsigned Rand;
|
||||
do
|
||||
{
|
||||
Rand = rand() % Lines.size();
|
||||
while(Rand == m_AnnouncementLastLine);
|
||||
} while(Rand == m_AnnouncementLastLine);
|
||||
|
||||
m_AnnouncementLastLine = Rand;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue