Complete.Org: Mailing Lists: Archives: freeciv-dev: February 1999:
[Freeciv-Dev] [chris@xxxxxxxxxxxxxxxxxxxxxx: Re: New debian CVS snapsho
Home

[Freeciv-Dev] [chris@xxxxxxxxxxxxxxxxxxxxxx: Re: New debian CVS snapsho

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [chris@xxxxxxxxxxxxxxxxxxxxxx: Re: New debian CVS snapshot package]
From: Lalo Martins <lalo@xxxxxxxxxx>
Date: Wed, 24 Feb 1999 01:09:45 -0300

This is from an Alpha (architeture) Debian developer - the guy
who usually compiles FreeCiv for the Alpha. If this is OK,
Nicholas will probably want to apply the patch.

----- Forwarded message from Christopher C Chimelis 
<chris@xxxxxxxxxxxxxxxxxxxxxx> -----

Date: Tue, 23 Feb 1999 22:58:06 -0500 (EST)
From: Christopher C Chimelis <chris@xxxxxxxxxxxxxxxxxxxxxx>
To: Lalo Martins <lalo@xxxxxxxxxx>
Subject: Re: New debian CVS snapshot package
Message-Id: <Pine.LNX.3.96.990223225347.27396A-100000@xxxxxxxxxxxxxxxxxxxx>
Content-Type: TEXT/PLAIN; charset=US-ASCII


I worked up a few patches for freeciv to correct some improper casts of
pointers to/from ints (int on Alpha is 4 bytes and pointers are 8 bytes).
I've attached them below.  There are still some changes that can be made
(basically, anything cast to an int from a pointer), but they are harder
to fix and more widespread.  I should be able to get to those later, fyi.

Anyway, these patches should be clean for all archs and should fix some
64-bit issues on other platforms.  Please test them on i386 to make sure.
I substituted size_t in place of int since it always seems to equal the
size of the pointer on the destination system.

C

diff -ruN freeciv-1.7.2+cvs19990117/client/citydlg.c 
freeciv-patched/client/citydlg.c
--- freeciv-1.7.2+cvs19990117/client/citydlg.c  Tue Jan 12 12:21:56 1999
+++ freeciv-patched/client/citydlg.c    Wed Feb 24 04:43:38 1999
@@ -708,7 +708,7 @@
 {
   struct unit *punit;
 
-  if((punit=unit_list_find(&game.player_ptr->units, (int)client_data)))
+  if((punit=unit_list_find(&game.player_ptr->units, (size_t)client_data)))
     activate_unit(punit);
   destroy_message_dialog(w);
 }
@@ -726,7 +726,7 @@
 
   destroy_message_dialog(w);
 
-  if((punit=unit_list_find(&game.player_ptr->units, (int)client_data)))  {
+  if((punit=unit_list_find(&game.player_ptr->units, (size_t)client_data)))  {
     activate_unit(punit);
     if((pcity=map_get_city(punit->x, punit->y)))
       if((pdialog=get_city_dialog(pcity)))
@@ -746,7 +746,7 @@
 
   destroy_message_dialog(w);
 
-  if((punit=unit_list_find(&game.player_ptr->units, (int)client_data)))  {
+  if((punit=unit_list_find(&game.player_ptr->units, (size_t)client_data)))  {
     activate_unit(punit);
     if((pcity=city_list_find_id(&game.player_ptr->cities, punit->homecity)))
       if((pdialog=get_city_dialog(pcity)))
@@ -764,7 +764,7 @@
 {
   struct unit *punit;
 
-  if((punit=unit_list_find(&game.player_ptr->units, (int)client_data)))
+  if((punit=unit_list_find(&game.player_ptr->units, (size_t)client_data)))
     request_unit_disband(punit);
 
   destroy_message_dialog(w);
@@ -779,7 +779,7 @@
 {
   struct unit *punit;
   
-  if((punit=unit_list_find(&game.player_ptr->units, (int)client_data)))
+  if((punit=unit_list_find(&game.player_ptr->units, (size_t)client_data)))
     request_unit_change_homecity(punit);
 
   destroy_message_dialog(w);
@@ -808,7 +808,7 @@
   Widget wd;
   XEvent *e = (XEvent*)call_data;
   
-  if((punit=unit_list_find(&game.player_ptr->units, (int)client_data)) &&
+  if((punit=unit_list_find(&game.player_ptr->units, (size_t)client_data)) &&
      (pcity=map_get_city(punit->x, punit->y)) &&
      (pdialog=get_city_dialog(pcity))) {
     
@@ -1131,7 +1131,7 @@
   struct city_dialog *pdialog;
   XEvent *e = (XEvent*)call_data;
   
-  if((punit=unit_list_find(&game.player_ptr->units, (int)client_data)))
+  if((punit=unit_list_find(&game.player_ptr->units, (size_t)client_data)))
     if((pcity=find_city_by_id(punit->homecity)))
       if((pdialog=get_city_dialog(pcity)))  {
        if(e->type==ButtonRelease && e->xbutton.button==2)  {
@@ -1463,7 +1463,7 @@
 {
   struct unit *punit;
 
-  if((punit=unit_list_find(&game.player_ptr->units, (int)client_data))) {
+  if((punit=unit_list_find(&game.player_ptr->units, (size_t)client_data))) {
     request_unit_upgrade(punit);
   }
   destroy_message_dialog(w);
@@ -1489,7 +1489,7 @@
   int ut1,ut2;
   int value;
 
-  if((punit=unit_list_find(&game.player_ptr->units, (int)client_data))) {
+  if((punit=unit_list_find(&game.player_ptr->units, (size_t)client_data))) {
     ut1 = punit->type;
     /* printf("upgrade_callback for %s\n", unit_types[ut1].name); */
 
diff -ruN freeciv-1.7.2+cvs19990117/client/dialogs.c 
freeciv-patched/client/dialogs.c
--- freeciv-1.7.2+cvs19990117/client/dialogs.c  Tue Oct 20 14:32:39 1998
+++ freeciv-patched/client/dialogs.c    Wed Feb 24 04:28:19 1999
@@ -1664,11 +1664,12 @@
 **************************************************************************/
 void taxrates_callback(Widget w, XtPointer client_data, XtPointer call_data)
 {
-  int i,tax_end,lux_end,sci_end;
+  int tax_end,lux_end,sci_end;
+  size_t i;
   int delta=10;
 
   struct packet_player_request packet;
-  i= (int)client_data;
+  i= (size_t)client_data;
   
   lux_end= game.player_ptr->economic.luxury;
   sci_end= lux_end + game.player_ptr->economic.science;
diff -ruN freeciv-1.7.2+cvs19990117/client/diplodlg.c 
freeciv-patched/client/diplodlg.c
--- freeciv-1.7.2+cvs19990117/client/diplodlg.c Sun Jan 17 10:44:27 1999
+++ freeciv-patched/client/diplodlg.c   Wed Feb 24 04:39:45 1999
@@ -617,10 +617,10 @@
 void diplomacy_dialog_tech_callback(Widget w, XtPointer client_data, 
                                    XtPointer call_data)
 {
-  int choice;
+  size_t choice;
   struct packet_diplomacy_info pa;
   
-  choice=(int)client_data;
+  choice=(size_t)client_data;
 
   pa.plrno0=choice/10000;
   pa.plrno1=(choice/100)%100;
@@ -639,10 +639,10 @@
 void diplomacy_dialog_city_callback(Widget w, XtPointer client_data, 
                                    XtPointer call_data)
 {
-  int choice;
+  size_t choice;
   struct packet_diplomacy_info pa;
   
-  choice=(int)client_data;
+  choice=(size_t)client_data;
 
   pa.plrno0=choice/100000;
   choice -= pa.plrno0 * 100000;
diff -ruN freeciv-1.7.2+cvs19990117/client/helpdlg.c 
freeciv-patched/client/helpdlg.c
--- freeciv-1.7.2+cvs19990117/client/helpdlg.c  Wed Nov 25 08:17:37 1998
+++ freeciv-patched/client/helpdlg.c    Wed Feb 24 04:38:04 1999
@@ -1099,7 +1099,7 @@
 void help_tree_node_callback(Widget w, XtPointer client_data, 
                             XtPointer call_data)
 {
-  int tech=(int)client_data;
+  size_t tech=(size_t)client_data;
   
   if(!help_tree_destroy_children(w)) {
     if(advances[tech].req[0]!=A_NONE)
diff -ruN freeciv-1.7.2+cvs19990117/client/mapctrl.c 
freeciv-patched/client/mapctrl.c
--- freeciv-1.7.2+cvs19990117/client/mapctrl.c  Tue Jan 12 11:55:44 1999
+++ freeciv-patched/client/mapctrl.c    Wed Feb 24 04:34:02 1999
@@ -75,9 +75,9 @@
 void name_new_city_callback(Widget w, XtPointer client_data, 
                           XtPointer call_data)
 {
-  int unit_id;
+  size_t unit_id;
   
-  if((unit_id=(int)client_data)) {
+  if((unit_id=(size_t)client_data)) {
     struct packet_unit_request req;
     req.unit_id=unit_id;
     strncpy(req.name, input_dialog_get_input(w), MAX_LENGTH_NAME);
diff -ruN freeciv-1.7.2+cvs19990117/client/mapview.c 
freeciv-patched/client/mapview.c
--- freeciv-1.7.2+cvs19990117/client/mapview.c  Sat Jan 16 12:15:44 1999
+++ freeciv-patched/client/mapview.c    Wed Feb 24 04:40:56 1999
@@ -1522,7 +1522,7 @@
 void scrollbar_scroll_callback(Widget w, XtPointer client_data,
                             XtPointer position_val)
 {
-  int position=(int)position_val;
+  size_t position=(size_t)position_val;
 
 
   if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
diff -ruN freeciv-1.7.2+cvs19990117/client/menu.c freeciv-patched/client/menu.c
--- freeciv-1.7.2+cvs19990117/client/menu.c     Tue Jan  5 13:05:42 1999
+++ freeciv-patched/client/menu.c       Wed Feb 24 04:40:44 1999
@@ -321,7 +321,7 @@
 *****************************************************************/
 void game_menu_callback(Widget w, XtPointer client_data, XtPointer garbage)
 {
-  int pane_num = (int)client_data;
+  size_t pane_num = (size_t)client_data;
 
   switch(pane_num) {
   case MENU_GAME_FIND_CITY:
@@ -377,7 +377,7 @@
 *****************************************************************/
 void orders_menu_callback(Widget w, XtPointer client_data, XtPointer garbage)
 {
-  int pane_num = (int)client_data;
+  size_t pane_num = (size_t)client_data;
 
   switch(pane_num) {
    case MENU_ORDER_AUTO:
@@ -466,7 +466,7 @@
 *****************************************************************/
 void reports_menu_callback(Widget w, XtPointer client_data, XtPointer garbage)
 {
-  int pane_num = (int)client_data;
+  size_t pane_num = (size_t)client_data;
 
   switch(pane_num) {
    case MENU_REPORT_CITY:
@@ -499,7 +499,7 @@
 *****************************************************************/
 void help_menu_callback(Widget w, XtPointer client_data, XtPointer garbage)
 {
-  int pane_num = (int)client_data;
+  size_t pane_num = (size_t)client_data;
 
   switch(pane_num) {
   case MENU_HELP_CONTROLS:
diff -ruN freeciv-1.7.2+cvs19990117/client/ratesdlg.c 
freeciv-patched/client/ratesdlg.c
--- freeciv-1.7.2+cvs19990117/client/ratesdlg.c Mon Jul 27 16:29:00 1998
+++ freeciv-patched/client/ratesdlg.c   Wed Feb 24 04:28:42 1999
@@ -361,7 +361,7 @@
 void rates_scroll_scroll_callback(Widget w, XtPointer client_data,
                                  XtPointer position_val)
 {
-  int pos=(int)position_val;
+  size_t pos=(size_t)position_val;
   int val;
   
   if(w==rates_tax_scroll) {
diff -ruN freeciv-1.7.2+cvs19990117/client/repodlgs.c 
freeciv-patched/client/repodlgs.c
--- freeciv-1.7.2+cvs19990117/client/repodlgs.c Tue Dec 15 10:51:03 1998
+++ freeciv-patched/client/repodlgs.c   Wed Feb 24 04:32:41 1999
@@ -500,7 +500,8 @@
   Widget  close_command;
   static char *tech_list_names_ptrs[A_LAST+1];
   static char tech_list_names[A_LAST+1][200];
-  int i, j, flag, num_list;
+  int j, flag, num_list;
+  size_t i;
   Dimension width;
   char current_text[512];
   char goal_text[512];
@@ -662,10 +663,10 @@
 {
   char current_text[512];
   struct packet_player_request packet;
-  int to;
+  size_t to;
   Boolean b;
 
-  to=(int)client_data;
+  to=(size_t)client_data;
 
   XtVaGetValues(science_help_toggle, XtNstate, &b, NULL);
   if (b == TRUE)
@@ -691,10 +692,10 @@
 {
   char goal_text[512];
   struct packet_player_request packet;
-  int to;
+  size_t to;
   Boolean b;
 
-  to=(int)client_data;
+  to=(size_t)client_data;
 
   XtVaGetValues(science_help_toggle, XtNstate, &b, NULL);
   if (b == TRUE)
@@ -754,7 +755,8 @@
     char text[512];
     static char *tech_list_names_ptrs[A_LAST+1];
     static char tech_list_names[A_LAST+1][200];
-    int i, j, flag;
+    int j, flag;
+    size_t i;
     char *report_title;
     
     report_title=get_report_title("Science Advisor");
@@ -982,7 +984,8 @@
 
   if(ret->list_index!=XAW_LIST_NONE && 
(pcity=find_city_by_id(cities_in_list[ret->list_index])))
     {
-      int flag,i;
+      int flag;
+      size_t i;
       char buf[512];
 
       XtSetSensitive(city_change_command, TRUE);
@@ -1049,7 +1052,7 @@
       int build_nr;
       Boolean unit;
       
-      build_nr = (int) client_data;
+      build_nr = (size_t) client_data;
 
       if (build_nr >= B_LAST)
        {
@@ -1677,7 +1680,7 @@
 void upgrade_callback_yes(Widget w, XtPointer client_data, 
                                  XtPointer call_data)
 {
-  send_packet_unittype_info(&aconnection, (int)client_data, 
PACKET_UNITTYPE_UPGRADE);
+  send_packet_unittype_info(&aconnection, (size_t)client_data, 
PACKET_UNITTYPE_UPGRADE);
   destroy_message_dialog(w);
 }
 




----- End forwarded message -----

[]s,
                                               |alo
                                               +----
--
      I am Lalo of deB-org. You will be freed.
                 Resistance is futile.

http://www.webcom.com/lalo      mailto:lalo@xxxxxxxxxx
                 pgp key in the web page

Debian GNU/Linux       --        http://www.debian.org


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] [chris@xxxxxxxxxxxxxxxxxxxxxx: Re: New debian CVS snapshot package], Lalo Martins <=