mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 03:28:19 +00:00
Fix division by zero when using random theme with no themes
This commit is contained in:
parent
d203f38f01
commit
98a8507184
|
@ -230,11 +230,14 @@ void CMenuBackground::LoadMenuBackground(bool HasDayHint, bool HasNightHint)
|
||||||
}
|
}
|
||||||
else if(str_comp(pMenuMap, "rand") == 0)
|
else if(str_comp(pMenuMap, "rand") == 0)
|
||||||
{
|
{
|
||||||
//make sure to load themes
|
// make sure to load themes
|
||||||
std::vector<CTheme> &vThemesRef = GetThemes();
|
const std::vector<CTheme> &vThemesRef = GetThemes();
|
||||||
int RandomThemeIndex = rand() % (vThemesRef.size() - PREDEFINED_THEMES_COUNT);
|
if(vThemesRef.size() > PREDEFINED_THEMES_COUNT)
|
||||||
if(RandomThemeIndex + PREDEFINED_THEMES_COUNT < (int)vThemesRef.size())
|
{
|
||||||
pMenuMap = vThemesRef[RandomThemeIndex + PREDEFINED_THEMES_COUNT].m_Name.c_str();
|
int RandomThemeIndex = rand() % (vThemesRef.size() - PREDEFINED_THEMES_COUNT);
|
||||||
|
if(RandomThemeIndex + PREDEFINED_THEMES_COUNT < (int)vThemesRef.size())
|
||||||
|
pMenuMap = vThemesRef[RandomThemeIndex + PREDEFINED_THEMES_COUNT].m_Name.c_str();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char aBuf[128];
|
char aBuf[128];
|
||||||
|
|
Loading…
Reference in a new issue