Skip to content

Commit f1f3d7c

Browse files
committed
simplify algorithm for bot names
1 parent 1d5f888 commit f1f3d7c

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

src/game/server/hl2mp/bot/hl2mp_bot.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,10 @@ void LoadBotNames(void)
131131
const char* GetRandomBotName(void)
132132
{
133133
if (m_botScriptNames.Count() == 0)
134-
return "MISSINGNO";
134+
return "Bot Name";
135135

136-
int iStartIndex = rand() % m_botScriptNames.Count();
137-
138-
for (int i = 0; i < m_botScriptNames.Count(); ++i)
139-
{
140-
int index = i + iStartIndex;
141-
142-
if (index >= m_botScriptNames.Count())
143-
index -= m_botScriptNames.Count();
144-
145-
string_t iszName = m_botScriptNames[index];
146-
147-
return STRING(iszName);
148-
}
149-
150-
return "Bot Name";
136+
string_t iszName = m_botScriptNames.Random();
137+
return STRING(iszName);
151138
}
152139
#else
153140
//-----------------------------------------------------------------------------------------------------

src/game/server/tf/bot/tf_bot.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,23 +172,10 @@ void LoadBotNames(void)
172172
const char *GetRandomBotName(void)
173173
{
174174
if (m_botScriptNames.Count() == 0)
175-
return "MISSINGNO";
175+
return "Bot Name";
176176

177-
int iStartIndex = rand() % m_botScriptNames.Count();
178-
179-
for (int i = 0; i < m_botScriptNames.Count(); ++i)
180-
{
181-
int index = i + iStartIndex;
182-
183-
if (index >= m_botScriptNames.Count())
184-
index -= m_botScriptNames.Count();
185-
186-
string_t iszName = m_botScriptNames[index];
187-
188-
return STRING(iszName);
189-
}
190-
191-
return "Bot Name";
177+
string_t iszName = m_botScriptNames.Random();
178+
return STRING(iszName);
192179
}
193180
#else
194181
//-----------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)