Skip to content

Conversation

@DESTROYGIRL
Copy link
Contributor

Description

More bot names, and there should never be any duplicate names on a 32 player server now

Toolchain

  • Windows MSVC VS2022

@DESTROYGIRL DESTROYGIRL requested a review from a team August 18, 2025 22:46
continue;
}

for (int k = availableList.Count() - 1; k >= 0; --k)
Copy link
Contributor

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:

CUtlStringMap<bool> usedNames;
for (int j = 1; j <= gpGlobals->maxClients; ++j) {
    auto player = UTIL_PlayerByIndex(j);
    if (player) {
        usedNames.Insert(player->GetPlayerName(), true);
    }
}

@sunzenshen sunzenshen requested a review from a team August 19, 2025 04:54

for (int k = availableList.Count() - 1; k >= 0; --k)
{
if (V_stristr(player->GetPlayerName(), nameList[availableList[k]]))
Copy link
Contributor

Choose a reason for hiding this comment

The 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.


return nameList[availableList[RandomInt(0, availableList.Count() - 1)]];

//return nameList[RandomInt(0, ARRAYSIZE(nameList) - 1)];
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@sunzenshen sunzenshen requested a review from a team August 19, 2025 05:07
@DESTROYGIRL DESTROYGIRL marked this pull request as draft August 19, 2025 10:31
@DESTROYGIRL
Copy link
Contributor Author

This will probably be closed in favour of #1289 but will leave it up until it gets merged.

@DESTROYGIRL DESTROYGIRL deleted the bot_names branch September 11, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants