Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Re: client/server authentication (PR#1767)
Home

[Freeciv-Dev] Re: client/server authentication (PR#1767)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: client/server authentication (PR#1767)
From: "Mike Kaufman" <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 9 Jul 2003 21:48:46 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Tue, Jul 08, 2003 at 11:35:42AM -0700, Michael Mielke wrote:
> 
> I also noticed in cvs that when chatting in the box it addresses all users 
> as noname.  When setting a player to a team it only uses noname, and only 
> puts the first 'noname' on the team.

try this patch. it should fix the chatting problem. I'll look into the team
problem.

-mike

diff -Nur -Xsnap/diff_ignore snap/server/handchat.c snap-a7/server/handchat.c
--- snap/server/handchat.c      2003-04-13 15:31:15.000000000 -0500
+++ snap-a7/server/handchat.c   2003-07-09 23:36:57.000000000 -0500
@@ -15,6 +15,7 @@
 #include <config.h>
 #endif
 
+#include <assert.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -34,30 +35,23 @@
 /**************************************************************************
   Formulate a name for this connection, prefering the player name when
   available and unambiguous (since this is the "standard" case), else
-  connection name and/or player name.  Player name is always "plain",
-  and connection name in brackets.  If connection name includes player
-  name, assume connection name is a "modified" player name and don't use
-  both (eg "(1-Shaka)" instead of "Shaka (1-Shaka)").  
+  use the username.
 **************************************************************************/
 static void form_chat_name(struct connection *pconn, char *buffer, size_t len)
 {
   struct player *pplayer = pconn->player;
 
-  if (!pplayer) {
-    my_snprintf(buffer, len, "(%s)", pconn->username);
-  } else if (conn_list_size(&pplayer->connections)==1) {
-    (void) mystrlcpy(buffer, pplayer->name, len);
-  } else if (strstr(pconn->username, pplayer->username)) {
-    /* Fixme: strstr above should be case-independent */
+  if (!pplayer || strcmp(pplayer->name, ANON_PLAYER_NAME) == 0) {
     my_snprintf(buffer, len, "(%s)", pconn->username);
   } else {
-    my_snprintf(buffer, len, "%s (%s)", pplayer->name, pconn->username);
+    my_snprintf(buffer, len, "%s", pplayer->name);
   }
 }
                                
 /**************************************************************************
   Complain to sender that name was ambiguous.
-  'player_conn' is 0 for player names, 1 for connection names.
+  'player_conn' is 0 for player names, 1 for connection names,
+  2 for attempt to send to an anonymous player.
 **************************************************************************/
 static void complain_ambiguous(struct connection *pconn, const char *name,
                               int player_conn)
@@ -65,12 +59,21 @@
   struct packet_generic_message genmsg;
   genmsg.x = genmsg.y = genmsg.event = -1;
 
-  if (player_conn==0) {
+  switch(player_conn) {
+  case 0:
     my_snprintf(genmsg.message, sizeof(genmsg.message),
                _("Game: %s is an ambiguous player name-prefix."), name);
-  } else {
+    break;
+  case 1:
     my_snprintf(genmsg.message, sizeof(genmsg.message),
                _("Game: %s is an ambiguous connection name-prefix."), name);
+    break;
+  case 2:
+    my_snprintf(genmsg.message, sizeof(genmsg.message),
+                _("Game: %s is an anonymous name. Use connection name"), name);
+    break;
+  default:
+    assert(0);
   }
   send_packet_generic_message(pconn, PACKET_CHAT_MSG, &genmsg);
 }
@@ -256,6 +259,10 @@
        complain_ambiguous(pconn, name, 0);
        return;
       }
+      if (pdest && strcmp(pdest->name, ANON_PLAYER_NAME) == 0) {
+        complain_ambiguous(pconn, name, 2);
+        return;
+      }
       if (pdest && match_result_player < M_PRE_AMBIGUOUS) {
        int nconn = conn_list_size(&pdest->connections);
        if (nconn==1) {

[Prev in Thread] Current Thread [Next in Thread]