Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#9916) unit's obsoleted_by flag
Home

[Freeciv-Dev] (PR#9916) unit's obsoleted_by flag

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#9916) unit's obsoleted_by flag
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 20 Nov 2004 00:49:14 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9916 >

> [jdorje - Fri Sep 03 03:54:20 2004]:
> 
> A unit type has an obsoleted_by field.  This holds the ID of the unit 
> that obsoletes this unit, or -1 for none.
> 
> This -1 should be a #define: U_NONE.

This patch adds a #define U_NOT_OBSOLETED.  It's defined to -1 so no
code is actually changed.

jason

Index: ai/advmilitary.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v
retrieving revision 1.178
diff -u -r1.178 advmilitary.c
--- ai/advmilitary.c    19 Nov 2004 01:57:36 -0000      1.178
+++ ai/advmilitary.c    20 Nov 2004 08:48:22 -0000
@@ -821,7 +821,7 @@
     if ((move_type == LAND_MOVING || (move_type == SEA_MOVING && shore))
         && tech_req != A_LAST
         && (tech_dist > 0 
-            || unit_types[unit_type].obsoleted_by == -1
+            || unit_types[unit_type].obsoleted_by == U_NOT_OBSOLETED
             || !can_build_unit_direct(pcity, 
                                       unit_types[unit_type].obsoleted_by))
         && unit_types[unit_type].attack_strength > 0 /* or we'll get SIGFPE */
Index: client/gui-gtk/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/helpdlg.c,v
retrieving revision 1.70
diff -u -r1.70 helpdlg.c
--- client/gui-gtk/helpdlg.c    15 Nov 2004 18:45:45 -0000      1.70
+++ client/gui-gtk/helpdlg.c    20 Nov 2004 08:48:22 -0000
@@ -756,7 +756,7 @@
       gtk_set_label(help_ulabel[4][1], advances[utype->tech_requirement].name);
     }
 /*    create_tech_tree(help_improvement_tree, 0, utype->tech_requirement, 3);*/
-    if(utype->obsoleted_by==-1) {
+    if (utype->obsoleted_by == U_NOT_OBSOLETED) {
       gtk_set_label(help_ulabel[4][4], _("None"));
     } else {
       gtk_set_label(help_ulabel[4][4], 
get_unit_type(utype->obsoleted_by)->name);
Index: client/gui-gtk-2.0/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/helpdlg.c,v
retrieving revision 1.39
diff -u -r1.39 helpdlg.c
--- client/gui-gtk-2.0/helpdlg.c        16 Nov 2004 04:08:30 -0000      1.39
+++ client/gui-gtk-2.0/helpdlg.c        20 Nov 2004 08:48:22 -0000
@@ -781,7 +781,7 @@
       gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]), 
advances[utype->tech_requirement].name);
     }
 /*    create_tech_tree(help_improvement_tree, 0, utype->tech_requirement, 3);*/
-    if(utype->obsoleted_by==-1) {
+    if (utype->obsoleted_by == U_NOT_OBSOLETED) {
       gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]), _("None"));
     } else {
       gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]), 
get_unit_type(utype->obsoleted_by)->name);
Index: client/gui-mui/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/helpdlg.c,v
retrieving revision 1.35
diff -u -r1.35 helpdlg.c
--- client/gui-mui/helpdlg.c    4 Sep 2004 21:11:47 -0000       1.35
+++ client/gui-mui/helpdlg.c    20 Nov 2004 08:48:23 -0000
@@ -688,7 +688,7 @@
 
     UpdateTechButton(help_unit_needs_button, utype->tech_requirement);
 
-    if (utype->obsoleted_by == -1)
+    if (utype->obsoleted_by == U_NOT_OBSOLETED)
       text = _("None");
     else
       text = get_unit_type(utype->obsoleted_by)->name;
Index: client/gui-sdl/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/helpdlg.c,v
retrieving revision 1.7
diff -u -r1.7 helpdlg.c
--- client/gui-sdl/helpdlg.c    4 Sep 2004 21:11:47 -0000       1.7
+++ client/gui-sdl/helpdlg.c    20 Nov 2004 08:48:23 -0000
@@ -773,7 +773,7 @@
   DownAdd(pBuf, pDock);
   pDock = pBuf;
   
-  if(pUnit->obsoleted_by==-1) {
+  if (pUnit->obsoleted_by == U_NOT_OBSOLETED) {
     pBuf = create_iconlabel_from_chars(NULL,
                    pWindow->dst, _("None"), 12, 0);
     pBuf->ID = ID_LABEL;  
Index: client/gui-win32/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/helpdlg.c,v
retrieving revision 1.22
diff -u -r1.22 helpdlg.c
--- client/gui-win32/helpdlg.c  14 Nov 2004 04:58:26 -0000      1.22
+++ client/gui-win32/helpdlg.c  20 Nov 2004 08:48:23 -0000
@@ -708,7 +708,7 @@
       SetWindowText(help_ulabel[4][1], advances[utype->tech_requirement].name);
     }
     /*    create_tech_tree(help_improvement_tree, 0, utype->tech_requirement, 
3);*/
-    if(utype->obsoleted_by==-1) {
+    if (utype->obsoleted_by == U_NOT_OBSOLETED) {
       SetWindowText(help_ulabel[4][4], _("None"));
     } else {
       SetWindowText(help_ulabel[4][4], 
get_unit_type(utype->obsoleted_by)->name);
Index: client/gui-xaw/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/helpdlg.c,v
retrieving revision 1.54
diff -u -r1.54 helpdlg.c
--- client/gui-xaw/helpdlg.c    17 Nov 2004 19:31:14 -0000      1.54
+++ client/gui-xaw/helpdlg.c    20 Nov 2004 08:48:23 -0000
@@ -845,7 +845,7 @@
                    advances[utype->tech_requirement].name);
     }
     create_tech_tree(help_tech_tree, 0, utype->tech_requirement, 3);
-    if(utype->obsoleted_by==-1) {
+    if (utype->obsoleted_by == U_NOT_OBSOLETED) {
       xaw_set_label(help_wonder_obsolete_data, _("None"));
     } else {
       xaw_set_label(help_wonder_obsolete_data,
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.255
diff -u -r1.255 city.c
--- common/city.c       17 Nov 2004 19:21:14 -0000      1.255
+++ common/city.c       20 Nov 2004 08:48:24 -0000
@@ -440,7 +440,7 @@
   if (!can_build_unit_direct(pcity, id)) {
     return FALSE;
   }
-  while ((id = unit_types[id].obsoleted_by) != -1) {
+  while ((id = unit_types[id].obsoleted_by) != U_NOT_OBSOLETED) {
     if (can_player_build_unit_direct(city_owner(pcity), id)) {
        return FALSE;
     }
Index: common/unittype.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.c,v
retrieving revision 1.41
diff -u -r1.41 unittype.c
--- common/unittype.c   17 Nov 2004 19:21:14 -0000      1.41
+++ common/unittype.c   20 Nov 2004 08:48:25 -0000
@@ -325,7 +325,7 @@
 
   if (!can_player_build_unit_direct(pplayer, id))
     return -1;
-  while ((id = unit_types[id].obsoleted_by) != -1) {
+  while ((id = unit_types[id].obsoleted_by) != U_NOT_OBSOLETED) {
     if (can_player_build_unit_direct(pplayer, id)) {
       best_upgrade = id;
     }
@@ -504,7 +504,7 @@
 {  
   if (!can_player_build_unit_direct(p, id))
     return FALSE;
-  while ((id = unit_types[id].obsoleted_by) != -1) {
+  while ((id = unit_types[id].obsoleted_by) != U_NOT_OBSOLETED) {
     if (can_player_build_unit_direct(p, id)) {
        return FALSE;
     }
@@ -523,7 +523,7 @@
   if (unit_type_flag(id, F_NOBUILD)) {
     return FALSE;
   }
-  while ((id = unit_types[id].obsoleted_by) != -1) {
+  while ((id = unit_types[id].obsoleted_by) != U_NOT_OBSOLETED) {
     if (can_player_build_unit_direct(p, id)) {
        return FALSE;
     }
Index: common/unittype.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.h,v
retrieving revision 1.33
diff -u -r1.33 unittype.h
--- common/unittype.h   17 Nov 2004 19:21:14 -0000      1.33
+++ common/unittype.h   20 Nov 2004 08:48:25 -0000
@@ -195,6 +195,7 @@
   int transport_capacity;
   int hp;
   int firepower;
+#define U_NOT_OBSOLETED ((Unit_Type_id)(-1))
   int obsoleted_by;
   int fuel;
 
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.273
diff -u -r1.273 cityturn.c
--- server/cityturn.c   17 Nov 2004 19:21:14 -0000      1.273
+++ server/cityturn.c   20 Nov 2004 08:48:25 -0000
@@ -796,7 +796,7 @@
   if (!can_build_unit_direct(pcity, check)) {
     return -1;
   }
-  while ((check = unit_types[check].obsoleted_by) != -1) {
+  while ((check = unit_types[check].obsoleted_by) != U_NOT_OBSOLETED) {
     if (can_build_unit_direct(pcity, check)) {
       latest_ok = check;
     }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9916) unit's obsoleted_by flag, Jason Short <=