Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2000:
[Freeciv-Dev] patch: stricter player-name checking (PR#523)
Home

[Freeciv-Dev] patch: stricter player-name checking (PR#523)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] patch: stricter player-name checking (PR#523)
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Thu, 17 Aug 2000 01:03:01 -0700 (PDT)

This patch make the name checking in handle_alloc_nation() stricter,
to avoid possible cases where players could have the same name (or 
same name except for case).  See comments added in patch for more
details.

-- David
--- freeciv-cvs/server/srv_main.c       Thu Aug 17 17:40:19 2000
+++ fc-adv/server/srv_main.c    Thu Aug 17 17:42:29 2000
@@ -1274,11 +1274,20 @@
     if(game.players[i].nation==packet->nation_no) {
        send_select_nation(pplayer); /* it failed - nation taken */
        return;
-    } else /* check to see if name has been taken */
-       if (!strcmp(game.players[i].name,packet->name) && 
-            game.players[i].nation != MAX_NUM_NATIONS) { 
-       notify_player(pplayer,
-                    _("Another player named '%s' has already joined the game.  
"
+    } else
+      /* Check to see if name has been taken.
+       * Ignore case because matches elsewhere are case-insenstive.
+       * Don't limit this check to just players with allocated nation:
+       * otherwise could end up with same name as pre-created AI player
+       * (which have no nation yet, but will keep current player name).
+       * Also want to keep all player names strictly distinct at all
+       * times (for server commands etc), including during nation
+       * allocation phase.
+       */
+      if (i != pplayer->player_no
+         && mystrcasecmp(game.players[i].name,packet->name) == 0) {
+       notify_player(pplayer,
+                    _("Another player already has the name '%s'.  "
                       "Please choose another name."), packet->name);
        send_select_nation(pplayer);
        return;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] patch: stricter player-name checking (PR#523), David Pfitzner <=