[Freeciv-Dev] (PR#40254) [PATCH] Cancel AI mode when attaching to aifill player.

2008-06-21 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40254 

Committed to S2_2 (r14822) and trunk (r14823).


--
もう〜、遅すぎる。遅すぎるってば!
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40254) [PATCH] Cancel AI mode when attaching to aifill player.

2008-06-20 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40254 

Improved the previous version of this patch by removing
a redundant name copy and adding a comment explaining
the purpose of the added code.


--
見つけられてしまった。なんと大変なこと!
diff --git a/server/connecthand.c b/server/connecthand.c
index 9d17dbd..7bd7090 100644
--- a/server/connecthand.c
+++ b/server/connecthand.c
@@ -493,6 +493,14 @@ bool attach_connection_to_player(struct connection *pconn,
 sz_strlcpy(pplayer-username, pconn-username);
 pplayer-user_turns = 0; /* reset for a new user */
 pplayer-is_connected = TRUE;
+
+/* If we are attached to a player in pregame from
+ * find_uncontrolled_player above, then that player
+ * will be an AI created by aifill. So turn off AI
+ * mode if it is still on. */
+if (server_state() == S_S_INITIAL  pplayer-ai.control) {
+  pplayer-ai.control = FALSE;
+}
   }
 
   pconn-observer = observing;
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40254) [PATCH] Cancel AI mode when attaching to aifill player.

2008-06-17 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40254 

2008/6/17 Madeline Book:

 This patch (+ the one from 40284) fixes a different
 problem then what I originally opened this ticket for.

 I see. So I were against your patch for wrong reasons. After
rechecking I'm no longer against it.

 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) ?


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40254) [PATCH] Cancel AI mode when attaching to aifill player.

2008-06-17 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40254 

 [EMAIL PROTECTED] - Tue Jun 17 12:29:19 2008]:
 
 2008/6/17 Madeline Book:
 
  This patch (+ the one from 40284) fixes a different
  problem then what I originally opened this ticket for.
 
  I see. So I were against your patch for wrong reasons. After
 rechecking I'm no longer against it.

Alright so I will commit this soon, after a final
recheck.
 
  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.

It might be beneficial in the future to wrap all the hard-
coded server command sending into functions that give a
cleaner interface, e.g.:

void client_request_detach(void)
{
  send_chat(/detach);
}

void client_request_take_player(const struct player *pplayer)
{
  if (!pplayer || pplayer == client_player()) {
return;
  }
  send_chat_printf(/take \%s\, player_name(pplayer));
}

etc., so that all the hardcoded command strings are in
one and only one place. This would make the future job
of introducing packets for this functionality somewhat
easier.


--
こちらこそよろしく

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40254) [PATCH] Cancel AI mode when attaching to aifill player.

2008-06-16 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40254 

 [EMAIL PROTECTED] - Mon Jun 16 02:05:45 2008]:
 
 2008/6/5 Marko Lindqvist:
  2008/5/30 Madeline Book:
 
  When a user connected to a server with some
  AI players created by aifill, they were attached
  to an existing AI player but AI mode was not
  reset. So when the game started the player's
  units moved on their own. This patch fixes that
  problem by cancelling AI mode in the attached
  player if AI mode is on and the server is in
  the pregame state.
 
   I looked this problem too when I were working with the
  connectdialog problems (still unsure what to do with the
  remaining patch I have)
 
  Now I can post it here. This requires send_chat_printf()
 patch from #40284.

This patch (+ the one from 40284) fixes a different
problem then what I originally opened this ticket for.

It still occurs that if you connect to a server with
a positive aifill value you are silently attached to
an AI and when the game starts your units move on their
own (wierder still is that the 'A' marking automatic
orders does not appear until the second turn).

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.

But it is not good to expect users to know about
and have to do this, especially since this was not
the case in previous versions.

So I propose that when a new client connection is made,
and the server is trying to attach the connection
to a new player, the server first removes an AI player
created by aifill, and then creates a fresh human player
to which is attached the new connection.


--
感謝していますが、私の問題をあまりよく解きません。

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40254) [PATCH] Cancel AI mode when attaching to aifill player.

2008-06-15 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40254 

2008/6/5 Marko Lindqvist:
 2008/5/30 Madeline Book:

 When a user connected to a server with some
 AI players created by aifill, they were attached
 to an existing AI player but AI mode was not
 reset. So when the game started the player's
 units moved on their own. This patch fixes that
 problem by cancelling AI mode in the attached
 player if AI mode is on and the server is in
 the pregame state.

  I looked this problem too when I were working with the connectdialog
 problems (still unsure what to do with the remaining patch I have)

 Now I can post it here. This requires send_chat_printf() patch from #40284.


 - 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-16 05:00:22.0 +0300
+++ freeciv/client/gui-gtk-2.0/pages.c	2008-06-16 05:00:35.0 +0300
@@ -1000,14 +1000,23 @@
 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));
+const char *name = player_name(client.conn.playing);
+  
+if (client_is_observer()) {
+  if (client.conn.playing-ai.control) {
+send_chat_printf(/aitoggle \%s\, name);
+  }
+  send_chat_printf(/take \%s\, name);
+} else {
+  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\, 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


Re: [Freeciv-Dev] (PR#40254) [PATCH] Cancel AI mode when attaching to aifill player.

2008-06-05 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40254 

2008/5/30 Madeline Book:

 When a user connected to a server with some
 AI players created by aifill, they were attached
 to an existing AI player but AI mode was not
 reset. So when the game started the player's
 units moved on their own. This patch fixes that
 problem by cancelling AI mode in the attached
 player if AI mode is on and the server is in
 the pregame state.

 I looked this problem too when I were working with the connectdialog
problems (still unsure what to do with the remaining patch I have)

 I don't like how things are not symmetric. When human detach from
player, human - ai toggle comes from client. Your patch makes the
opposite in the server side.
 Not that I'm against your patch. IMHO these both toggles should
happen at server side.


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40254) [PATCH] Cancel AI mode when attaching to aifill player.

2008-06-05 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40254 

 [EMAIL PROTECTED] - Thu Jun 05 20:53:32 2008]:
 
 2008/5/30 Madeline Book:
 
  When a user connected to a server with some
  AI players created by aifill, they were attached
  to an existing AI player but AI mode was not
  reset. So when the game started the player's
  units moved on their own. This patch fixes that
  problem by cancelling AI mode in the attached
  player if AI mode is on and the server is in
  the pregame state.
 
  I looked this problem too when I were working with the connectdialog
 problems (still unsure what to do with the remaining patch I have)
 
  I don't like how things are not symmetric. When human detach from
 player, human - ai toggle comes from client. Your patch makes the
 opposite in the server side.
  Not that I'm against your patch. IMHO these both toggles should
 happen at server side.

Possibly there is a better way of handling it. I'll look into
it if you do not beat me to it.


--
ここには絶対ない。

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev