View Issue Details

IDProjectCategoryView StatusLast Update
0005185Multi Theft Auto : San AndreasServerpublic2010-01-24 17:21
Reporterd0cAssigned Toccw 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformPCOSWindowsOS VersionXP 32bit
Product Version1.0.3 
Target Version1.0.4Fixed in Version1.0.4 
Summary0005185: nick command can set invalid (too long) nicks
Description

When you change your nick ingame with the /nick command, there seems to be an issue with length checking.
When you pass a nick that is exactly 22 characters long (the last length accepted by the command), the nick will show up ingame with an invalid character at the end, or just as "???" (making it hard to identify the player).
Also, the length limit in the GUI settings seems to be different from the nick command, maybe both should be adjusted.

Steps To Reproduce
  • Connect to a server
  • Enter in chat: /nick 1234567890123456789012
    (22 characters)
  • Notice the invalid char after your nick
TagsNo tags attached.

Activities

d0c

2010-01-24 11:58

viewer   ~~0010995

I dug through the code a little and found the cause for both issues:

a) Server-side (nick command):
In CPlayer::SetNick() (MTA10_Server/mods/deathmatch/logic/CPlayer.cpp, line 166), you need to copy at least MAX_NICK_LENGTH+1 characters to make sure you include the trailing \0. Replace line 166 with:
strncpy ( m_szNick, szNick, MAX_NICK_LENGTH + 1 );

b)Client-side (nick editbox):
In CSettings::CSettings() (MTA10/core/CSettings.cpp, line 314), the maximum length for the CGUIEdit is wrong. I don't know if the MAX_NICK_LENGTH constant is available, if not the value should be 22, not 16.

ccw

2010-01-24 17:19

administrator   ~~0010999

Thanks for that.

Fixed in http://github.com/ccw808/multitheftauto/commit/b0554ee958aefebf2b89eea03aed30fbb821248e

Issue History

Date Modified Username Field Change