@@ -292,17 +292,22 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
292292 // TheSuperHackers @bugfix slurmlord 18/09/2025 need to validate the name of the connecting player before
293293 // allowing them to join to prevent messing up the format of game state string. Commas, colons, semicolons etc.
294294 // should not be in a player name. It should also not consist of only space characters.
295- constexpr WideChar IllegalNameChars[] = L" ,:;|\f\n\r\t\v " ;
296- if (canJoin && (wcscspn (msg->name , IllegalNameChars) || wcsspn (msg->name , L" " ) == wcslen (msg->name )))
295+ if (canJoin)
297296 {
298- // Just deny with a duplicate name reason, for backwards compatibility with retail
299- reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
300- reply.GameNotJoined .reason = LANAPIInterface::RET_DUPLICATE_NAME;
301- reply.GameNotJoined .gameIP = m_localIP;
302- reply.GameNotJoined .playerIP = senderIP;
303- canJoin = false ;
297+ constexpr WideChar IllegalNameChars[] = L" ,:;|\f\n\r\t\v " ;
298+ const Bool containsIllegalChars = wcscspn (msg->name , IllegalNameChars);
299+ const Bool isEffectivelyEmpty = wcsspn (msg->name , L" " ) == wcslen (msg->name );
300+ if (containsIllegalChars || isEffectivelyEmpty)
301+ {
302+ // Just deny with a duplicate name reason, for backwards compatibility with retail
303+ reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
304+ reply.GameNotJoined .reason = LANAPIInterface::RET_DUPLICATE_NAME;
305+ reply.GameNotJoined .gameIP = m_localIP;
306+ reply.GameNotJoined .playerIP = senderIP;
307+ canJoin = false ;
304308
305- DEBUG_LOG ((" LANAPI::handleRequestJoin - join denied because of illegal characters in the player name." ));
309+ DEBUG_LOG ((" LANAPI::handleRequestJoin - join denied because of illegal characters in the player name." ));
310+ }
306311 }
307312
308313 // Then see if the player has a duplicate name
0 commit comments