Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12330) gen-output for the city overlays
Home

[Freeciv-Dev] (PR#12330) gen-output for the city overlays

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12330) gen-output for the city overlays
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Feb 2005 14:16:17 -0800
Reply-to: bugs@xxxxxxxxxxx

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

The so-called city overlays (the upkeep of units shown in the citydlg) 
can be simplified a bit using gen-output.  This would make future 
extensions easier (to larger amounts or different types of upkeep).

-jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.193
diff -u -r1.193 mapview_common.c
--- client/mapview_common.c     19 Feb 2005 17:15:13 -0000      1.193
+++ client/mapview_common.c     22 Feb 2005 22:14:43 -0000
@@ -1047,27 +1047,22 @@
                            struct canvas *pcanvas,
                            int canvas_x, int canvas_y)
 {
-  int upkeep_food = CLIP(0, punit->upkeep[O_FOOD], 2);
-  int upkeep_gold = CLIP(0, punit->upkeep[O_GOLD], 2);
   int unhappy = CLIP(0, punit->unhappiness, 2);
 
   /* draw overlay pixmaps */
-  if (punit->upkeep[O_SHIELD] > 0) {
-    canvas_put_sprite_full(pcanvas, canvas_x, canvas_y,
-                          sprites.upkeep.shield);
-  }
-  if (upkeep_food > 0) {
-    canvas_put_sprite_full(pcanvas, canvas_x, canvas_y,
-                          sprites.upkeep.food[upkeep_food - 1]);
-  }
-  if (upkeep_gold > 0) {
-    canvas_put_sprite_full(pcanvas, canvas_x, canvas_y,
-                          sprites.upkeep.gold[upkeep_gold - 1]);
-  }
   if (unhappy > 0) {
     canvas_put_sprite_full(pcanvas, canvas_x, canvas_y,
                           sprites.upkeep.unhappy[unhappy - 1]);
   }
+
+  output_type_iterate(o) {
+    int upkeep = CLIP(0, punit->upkeep[o], 2);
+
+    if (upkeep > 0 && sprites.upkeep.output[o][upkeep - 1]) {
+      canvas_put_sprite_full(pcanvas, canvas_x, canvas_y,
+                            sprites.upkeep.output[o][upkeep - 1]);
+    }
+  } output_type_iterate_end;
 }
 
 /*
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.237
diff -u -r1.237 tilespec.c
--- client/tilespec.c   17 Feb 2005 22:11:37 -0000      1.237
+++ client/tilespec.c   22 Feb 2005 22:14:44 -0000
@@ -1445,13 +1445,16 @@
     SET_SPRITE(city.tile_tradenum[i], buffer);
   }
 
-  SET_SPRITE(upkeep.food[0], "upkeep.food");
-  SET_SPRITE(upkeep.food[1], "upkeep.food2");
   SET_SPRITE(upkeep.unhappy[0], "upkeep.unhappy");
   SET_SPRITE(upkeep.unhappy[1], "upkeep.unhappy2");
-  SET_SPRITE(upkeep.gold[0], "upkeep.gold");
-  SET_SPRITE(upkeep.gold[1], "upkeep.gold2");
-  SET_SPRITE(upkeep.shield, "upkeep.shield");
+  output_type_iterate(o) {
+    my_snprintf(buffer, sizeof(buffer),
+               "upkeep.%s", get_output_identifier(o));
+    sprites.upkeep.output[o][0] = load_sprite(buffer);
+    my_snprintf(buffer, sizeof(buffer),
+               "upkeep.%s2", get_output_identifier(o));
+    sprites.upkeep.output[o][1] = load_sprite(buffer);
+  } output_type_iterate_end;
   
   SET_SPRITE(user.attention, "user.attention");
 
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.104
diff -u -r1.104 tilespec.h
--- client/tilespec.h   17 Feb 2005 22:11:37 -0000      1.104
+++ client/tilespec.h   22 Feb 2005 22:14:44 -0000
@@ -278,10 +278,8 @@
   } unit;
   struct {
     struct Sprite
-      *food[2],
-      *unhappy[2],
-      *gold[2],
-      *shield;
+      *output[O_MAX][2],
+      *unhappy[2];
   } upkeep;
   struct {
     struct Sprite

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12330) gen-output for the city overlays, Jason Short <=