News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

Network games: don't allow clients to use a nickname that's already taken

Started by Nazalassa, August 10, 2025, 10:10:53 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nazalassa

Right now (r11737), when, in a network game, a client attempts to change its nickname to one that's already taken, the client will assume the change was successful, whereas the server will assign it a randomly-generated name, thus leading to desynchronization between server and clients.
This patch modifies this behaviour so that, if the server detects that the new nickname is already taken, it sends back to the client (and only this one) its old nickname, thus effectively preventing the client from changing its nickname.

The changes are perhaps a bit heavy, but this way it should be easy to add a "nickname already taken" field to nwc_nick_t that would cause the serverlist window to display "Nickname already taken". (Right now, nothing specific is displayed, the nickname is just reset.)

ceeac

Thanks, incorporated in r11755 (with one little change that adds an error window when the name change fails).