<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40292 >

 From #40254


2008/6/17 Madeline Book:
>
>> cazfi74:
>>
>> 2008/6/17 Madeline Book:
>> > Of course with this patch if you do the "Take this
>> > player" from the connection list menu in pregame then
>> > it aitoggles the player you are attached to into
>> > the correct state.
>>
>>  May I commit this, or do we need longer discussion
>> (in separate ticket) ?
>
> I think ConnectDlgFix_40254.patch could make better use
> of the client_player() helper function to avoid direct
> references to client.conn.playing (e.g. save some typing
> and make "struct player *me = client_player()" at the top
> or whatever). Otherwise it's fine for the intended problem.

  - Updated


 - ML

diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/pages.c freeciv/client/gui-gtk-2.0/pages.c
--- freeciv/client/gui-gtk-2.0/pages.c	2008-06-17 15:34:47.000000000 +0300
+++ freeciv/client/gui-gtk-2.0/pages.c	2008-06-19 02:03:47.000000000 +0300
@@ -999,15 +999,26 @@
 **************************************************************************/
 static void take_callback(GtkWidget *w, gpointer data)
 {
-  if (NULL != client.conn.playing) {
-    if (!client.conn.playing->ai.control) {
-      /* Make sure player reverts to AI control. This is much more neat,
-       * and hides the ugly double username in the name list because
-       * the player username equals the connection username. */
-      send_chat_printf("/aitoggle \"%s\"", player_name(client.conn.playing));
+  struct player *plr = client_player();
+
+  if (NULL != plr) {
+    const char *name = player_name(plr);
+  
+    if (client_is_observer()) {
+      if (plr->ai.control) {
+        send_chat_printf("/aitoggle \"%s\"", name);
+      }
+      send_chat_printf("/take \"%s\"", name);
+    } else {
+      if (!plr->ai.control) {
+        /* Make sure player reverts to AI control. This is much more neat,
+         * and hides the ugly double username in the name list because
+         * the player username equals the connection username. */
+        send_chat_printf("/aitoggle \"%s\"", name);
+      }
+      send_chat("/detach");
+      send_chat("/observe");
     }
-    send_chat("/detach");
-    send_chat("/observe");
   } else if (!client.conn.observer) {
     send_chat("/observe");
   } else {
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to