-
Notifications
You must be signed in to change notification settings - Fork 20
More bot names #1285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More bot names #1285
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,18 +107,72 @@ const char* GetRandomBotName(void) | |
| static const char* nameList[] = | ||
| { | ||
| "Deej", | ||
| "Ed", | ||
| "0edit", | ||
| "Filter Decay", | ||
| "Gato", | ||
| "Grey", | ||
| "Glasseater", | ||
| "Ivy", | ||
| "Operation Ivy", | ||
| "KillahMo", | ||
| "pushBAK", | ||
| "Tatsur0", | ||
| "rain", | ||
| "The Major", | ||
| "Wolf", | ||
| "Sanjuro Executive", | ||
| "Grumpy Old Man", | ||
| "Biodroid Prototype", | ||
| "TGR", | ||
| "Jinball", | ||
| "Pequod", | ||
| "The Chimpanzee", | ||
| "Marchenko", | ||
| "Jeff", | ||
| "M.A.W.S.", | ||
| "Tin Soldier", | ||
| "SUKKIT", | ||
| "Supaman", | ||
| "Hadaly", | ||
| "Komatsu Lifthelper", | ||
| "HE Specialist", | ||
| "Left Leaner", | ||
| "Super Class A Hacker", | ||
| "and You", | ||
| }; | ||
|
|
||
| return nameList[RandomInt(0, ARRAYSIZE(nameList) - 1)]; | ||
| const int nameCount = ARRAYSIZE(nameList); | ||
|
|
||
| CUtlVector<int> availableList; | ||
| for (int i = 0; i < nameCount; ++i) | ||
| { | ||
| availableList.AddToTail(i); | ||
| } | ||
|
|
||
| for (int j = 1; j <= gpGlobals->maxClients && availableList.Count() > 0; ++j) | ||
| { | ||
| auto player = UTIL_PlayerByIndex(j); | ||
| if (!player) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| for (int k = availableList.Count() - 1; k >= 0; --k) | ||
| { | ||
| if (V_stristr(player->GetPlayerName(), nameList[availableList[k]])) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably fine for the current list, but if we ever add more short names like "Ed" to the list, a partial match could potentially lead to an accidental collision. Changing "Ed" to "0edit" made this case even more rare, but up to you if you think this would be worth being more explicit about. A more explicit string comparison would be along the lines of: if (V_stricmp(playerName, nameList[availableList[k]]) == 0)An exact match could also be faster than a substring match, but I'd be surprised if it makes a difference here. |
||
| { | ||
| availableList.FastRemove(k); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (availableList.Count() == 0) | ||
| { | ||
| return nameList[RandomInt(0, nameCount - 1)]; | ||
| } | ||
|
|
||
| return nameList[availableList[RandomInt(0, availableList.Count() - 1)]]; | ||
|
|
||
| //return nameList[RandomInt(0, ARRAYSIZE(nameList) - 1)]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you come back with another commit, might be worth cleaning up this previous line. |
||
| } | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be an optimization nit, but it might be cleaner to use a hashmap to check if a name was used, instead of using a double nest of for loops.
Something like: