Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] (PR#4741) new client function city_set_worklist
Home

[Freeciv-Dev] (PR#4741) new client function city_set_worklist

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#4741) new client function city_set_worklist
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 1 Aug 2003 16:08:23 -0700
Reply-to: rt@xxxxxxxxxxxxxx

This continues the PR#4708 series of patches with a new function 
city_set_worklist.  This sends the worklist request to the server.

It simplifies the GUI code and avoids sending uninitialized data over 
the network.

jason

? confdefs.h
? conftest.c
Index: client/citydlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.c,v
retrieving revision 1.21
diff -u -r1.21 citydlg_common.c
--- client/citydlg_common.c     2003/08/01 20:27:09     1.21
+++ client/citydlg_common.c     2003/08/01 22:57:59
@@ -395,6 +395,29 @@
 }
 
 /**************************************************************************
+  Set the worklist for a given city.  Return the request ID.
+**************************************************************************/
+int city_set_worklist(struct city *pcity, struct worklist *pworklist)
+{
+  struct packet_city_request packet;
+
+  packet.city_id = pcity->id;
+  copy_worklist(&packet.worklist, pworklist);
+
+  /* Don't send the worklist name to the server. */
+  packet.worklist.name[0] = '\0';
+
+  /* Fill out unused fields. */
+  packet.build_id = -1;
+  packet.is_build_id_unit_id = FALSE;
+  packet.worker_x = packet.worker_y = -1;
+  packet.specialist_from = packet.specialist_to = -1;
+
+  return send_packet_city_request(&aconnection, &packet,
+                                 PACKET_CITY_WORKLIST);
+}
+
+/**************************************************************************
   Change the production of a given city.  Return the request ID.
 **************************************************************************/
 int city_sell_improvement(struct city *pcity, Impr_Type_id sell_id)
Index: client/citydlg_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.h,v
retrieving revision 1.14
diff -u -r1.14 citydlg_common.h
--- client/citydlg_common.h     2003/08/01 20:27:09     1.14
+++ client/citydlg_common.h     2003/08/01 22:57:59
@@ -54,6 +54,7 @@
 void activate_all_units(int map_x, int map_y);
 
 int city_change_production(struct city *pcity, bool is_unit, int build_id);
+int city_set_worklist(struct city *pcity, struct worklist *pworklist);
 int city_sell_improvement(struct city *pcity, Impr_Type_id sell_id);
 int city_change_specialist(struct city *pcity, enum specialist_type from,
                           enum specialist_type to);
Index: client/gui-gtk/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v
retrieving revision 1.168
diff -u -r1.168 citydlg.c
--- client/gui-gtk/citydlg.c    2003/08/01 20:27:09     1.168
+++ client/gui-gtk/citydlg.c    2003/08/01 22:57:59
@@ -3214,8 +3214,7 @@
 *****************************************************************/
 static void commit_city_worklist(struct worklist *pwl, void *data)
 {
-  struct packet_city_request packet;
-  struct city_dialog *pdialog = (struct city_dialog *) data;
+  struct city_dialog *pdialog = data;
   int k, id;
   bool is_unit;
 
@@ -3260,10 +3259,7 @@
   }
 
   /* Send the rest of the worklist on its way. */
-  packet.city_id = pdialog->pcity->id;
-  copy_worklist(&packet.worklist, pwl);
-  packet.worklist.name[0] = '\0';
-  send_packet_city_request(&aconnection, &packet, PACKET_CITY_WORKLIST);
+  city_set_worklist(pdialog->pcity, pwl);
 }
 
 /******* Callbacks for stuff on the Misc. Settings page *********/
Index: client/gui-gtk-2.0/wldlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/wldlg.c,v
retrieving revision 1.25
diff -u -r1.25 wldlg.c
--- client/gui-gtk-2.0/wldlg.c  2003/07/28 04:00:29     1.25
+++ client/gui-gtk-2.0/wldlg.c  2003/08/01 22:57:59
@@ -1201,13 +1201,6 @@
   strcpy(pwl->name, name);
 
   if (ptr->pcity) {
-    struct packet_city_request packet;
-
-    packet.city_id = ptr->pcity->id;
-    copy_worklist(&packet.worklist, pwl);
-    packet.worklist.name[0] = '\0';
-    
-    send_packet_city_request(&aconnection, &packet, PACKET_CITY_WORKLIST);
+    city_set_worklist(ptr->pcity, pwl);
   }
 }
-
Index: client/gui-mui/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/citydlg.c,v
retrieving revision 1.71
diff -u -r1.71 citydlg.c
--- client/gui-mui/citydlg.c    2003/08/01 20:27:09     1.71
+++ client/gui-mui/citydlg.c    2003/08/01 22:57:59
@@ -820,8 +820,7 @@
 *****************************************************************/
 static void commit_city_worklist(struct worklist *pwl, void *data)
 {
-  struct packet_city_request packet;
-  struct city_dialog *pdialog = (struct city_dialog *) data;
+  struct city_dialog *pdialog = data;
   int k, id;
   bool is_unit;
 
@@ -866,10 +865,7 @@
   }
 
   /* Send the rest of the worklist on its way. */
-  packet.city_id = pdialog->pcity->id;
-  copy_worklist(&packet.worklist, pwl);
-  packet.worklist.name[0] = '\0';
-  send_packet_city_request(&aconnection, &packet, PACKET_CITY_WORKLIST);
+  city_set_worklist(pdialog->pcity, pwl);
 }
 
 /****************************************************************
Index: client/gui-sdl/wldlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/wldlg.c,v
retrieving revision 1.6
diff -u -r1.6 wldlg.c
--- client/gui-sdl/wldlg.c      2003/07/28 04:00:30     1.6
+++ client/gui-sdl/wldlg.c      2003/08/01 22:57:59
@@ -158,10 +158,6 @@
   }
   
   if(pCity) {
-    struct packet_city_request packet;
-      
-    packet.city_id = pCity->id;
-    
     /* remove duplicate entry of currently building impv./wonder from worklist 
*/
     if(!pEditor->is_building_unit) {
       for(i = 0; i < MAX_LEN_WORKLIST; i++) {
@@ -184,10 +180,7 @@
     }
     
     /* commit new city worklist */
-    copy_worklist(&packet.worklist, pEditor->pCopy_WorkList);
-    packet.worklist.name[0] = '\n';
-    send_packet_city_request(&aconnection, &packet, PACKET_CITY_WORKLIST);
-    
+    city_set_worklist(pCity, pEditor->pCopy_WorkList);
   } else {
     /* commit global worklist */
     copy_worklist(pEditor->pOrginal_WorkList, pEditor->pCopy_WorkList);
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.57
diff -u -r1.57 citydlg.c
--- client/gui-win32/citydlg.c  2003/08/01 20:27:09     1.57
+++ client/gui-win32/citydlg.c  2003/08/01 22:57:59
@@ -1220,8 +1220,7 @@
 *****************************************************************/
 static void commit_city_worklist(struct worklist *pwl, void *data)
 {
-  struct packet_city_request packet;
-  struct city_dialog *pdialog = (struct city_dialog *) data;
+  struct city_dialog *pdialog = data;
   int k, id;
   bool is_unit;
 
@@ -1266,10 +1265,7 @@
   }
 
   /* Send the rest of the worklist on its way. */
-  packet.city_id = pdialog->pcity->id;
-  copy_worklist(&packet.worklist, pwl);
-  packet.worklist.name[0] = '\0';
-  send_packet_city_request(&aconnection, &packet, PACKET_CITY_WORKLIST);
+  city_set_worklist(pdialog->pcity, pwl);
 }
 
 /**************************************************************************
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.100
diff -u -r1.100 citydlg.c
--- client/gui-xaw/citydlg.c    2003/08/01 20:27:10     1.100
+++ client/gui-xaw/citydlg.c    2003/08/01 22:57:59
@@ -2286,8 +2286,7 @@
 *****************************************************************/
 void commit_city_worklist(struct worklist *pwl, void *data)
 {
-  struct packet_city_request packet;
-  struct city_dialog *pdialog = (struct city_dialog *)data;
+  struct city_dialog *pdialog = data;
   int k, id;
   bool is_unit;
 
@@ -2331,10 +2330,7 @@
   }
 
   /* Send the rest of the worklist on its way. */
-  packet.city_id=pdialog->pcity->id;
-  copy_worklist(&packet.worklist, pwl);
-  packet.worklist.name[0] = '\0';
-  send_packet_city_request(&aconnection, &packet, PACKET_CITY_WORKLIST);
+  city_set_worklist(pdialog->pcity, pwl);
 
   pdialog->worklist_shell = NULL;
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#4741) new client function city_set_worklist, Jason Short <=