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

Bug [for global observers, not attached to player] :
- 'Wonders of the World' and 'Top Five Cities' should be
available but doesn't currently have any effect when selected.

The server did not allow PACKET_REPORT_REQ packets for non-attached
connections The patches add this type as allowed.

The patch for trunk is easy.

To patch 2.1 branch, I backported changes from r11590 to flag the packet
PACKET_SINGLE_WANT_HACK_REQ with handle-via-packet; then it 
too can be handled by server_handle_packet, generalizing the code. 
Due to this patch, 2.1 becomes much more similar in the code structure 
in the handle_packet_input function in srv_main.c


QUESTION: This patch allows even detached connections to send report
packets and get the reports back. Is this a fundamental problem? If
observers are not allowed at all in a game, they could still get this
information.
Index: server/srv_main.c
===================================================================
--- server/srv_main.c	(revision 13116)
+++ server/srv_main.c	(arbetskopia)
@@ -1110,6 +1110,7 @@
   if (type == PACKET_CHAT_MSG_REQ
       || type == PACKET_SINGLE_WANT_HACK_REQ
       || type == PACKET_NATION_SELECT_REQ
+      || type == PACKET_REPORT_REQ
       || type == PACKET_EDIT_MODE
       || type == PACKET_EDIT_TILE
       || type == PACKET_EDIT_UNIT
Index: server/hand_gen.c
===================================================================
--- server/hand_gen.c	(revision 13116)
+++ server/hand_gen.c	(arbetskopia)
@@ -312,6 +312,10 @@
       ((struct packet_spaceship_place *)packet)->num);
     return TRUE;
 
+  case PACKET_SINGLE_WANT_HACK_REQ:
+    handle_single_want_hack_req(pconn, packet);
+    return TRUE;
+
   default:
     return FALSE;
   }
Index: server/hand_gen.h
===================================================================
--- server/hand_gen.h	(revision 13116)
+++ server/hand_gen.h	(arbetskopia)
@@ -73,5 +73,7 @@
 void handle_conn_pong(struct connection *pc);
 void handle_spaceship_launch(struct player *pplayer);
 void handle_spaceship_place(struct player *pplayer, enum spaceship_place_type type, int num);
+struct packet_single_want_hack_req;
+void handle_single_want_hack_req(struct connection *pc, struct packet_single_want_hack_req *packet);
 
 #endif /* FC__HAND_GEN_H */
Index: server/srv_main.c
===================================================================
--- server/srv_main.c	(revision 13116)
+++ server/srv_main.c	(arbetskopia)
@@ -1068,18 +1068,16 @@
   }
   
   /* valid packets from established connections but non-players */
-  if (type == PACKET_CHAT_MSG_REQ) {
-    handle_chat_msg_req(pconn,
-			((struct packet_chat_msg_req *) packet)->message);
+  if (type == PACKET_CHAT_MSG_REQ
+      || type == PACKET_SINGLE_WANT_HACK_REQ
+      || type == PACKET_REPORT_REQ) {
+    if (!server_handle_packet(type, packet, NULL, pconn)) {
+      freelog(LOG_ERROR, "Received unknown packet %d from %s",
+	      type, conn_description(pconn));
+    }
     return TRUE;
   }
 
-  if (type == PACKET_SINGLE_WANT_HACK_REQ) {
-    handle_single_want_hack_req(pconn,
-		                (struct packet_single_want_hack_req *) packet);
-    return TRUE;
-  }
-
   pplayer = pconn->player;
 
   if(!pplayer) {
Index: server/gamehand.c
===================================================================
--- server/gamehand.c	(revision 13116)
+++ server/gamehand.c	(arbetskopia)
@@ -508,8 +508,7 @@
 the file values. Sends an answer to the client once it's done.
 **************************************************************************/
 void handle_single_want_hack_req(struct connection *pc,
-    				 const struct packet_single_want_hack_req
-				 *packet)
+                                 struct packet_single_want_hack_req *packet)
 {
   struct section_file file;
   char *token = NULL;
Index: server/gamehand.h
===================================================================
--- server/gamehand.h	(revision 13116)
+++ server/gamehand.h	(arbetskopia)
@@ -28,10 +28,4 @@
 
 const char *new_challenge_filename(struct connection *pc);
 
-struct packet_single_want_hack_req;
-
-void handle_single_want_hack_req(struct connection *pc,
-    				 const struct packet_single_want_hack_req
-				 *packet);
-
 #endif  /* FC__GAMEHAND_H */
Index: common/packets.def
===================================================================
--- common/packets.def	(revision 13116)
+++ common/packets.def	(arbetskopia)
@@ -1279,7 +1279,7 @@
 /*********************************************************
  Below are the packets that control single-player mode.  
 *********************************************************/
-PACKET_SINGLE_WANT_HACK_REQ=108;cs,handle-per-conn,no-handle
+PACKET_SINGLE_WANT_HACK_REQ=108;cs,handle-per-conn,handle-via-packet
  STRING token[MAX_LEN_NAME];
 end
 
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to