Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] (PR#3757) multi support for muti citizens icons in server
Home

[Freeciv-Dev] (PR#3757) multi support for muti citizens icons in server

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3757) multi support for muti citizens icons in server side.
From: "Rafa³ Bursig" <bursig@xxxxxxxxx>
Date: Thu, 20 Mar 2003 19:22:47 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Hi All

This patch add :
- suppot for muti citizens icons to server code and network code. With 
this pice of code we can try implement rest in other clients and 
SDLClient can have some basic support for this.
- fix (IMHO) some problems with double load of explosions sprites.
- partial fix some problems with "die" comunitaces (with connection of 
SET_SPRITE(...) macro). This macro print error info from "buffer" 
variable and sometimes there are wrong infos.

Rafal

----------------------------------------------------------------------
WOJNA stala sie faktem! RELACJE jedynych polskich dziennikarzy w Iraku. 
>>> http://link.interia.pl/f16f7 



diff -u -r freeciv/client/packhand.c fc2/client/packhand.c
--- freeciv/client/packhand.c   Wed Mar 19 14:58:12 2003
+++ fc2/client/packhand.c       Fri Mar 21 02:11:20 2003
@@ -2315,6 +2315,8 @@
   sz_strlcpy(cs->name, packet->name);
   sz_strlcpy(cs->graphic, packet->graphic);
   sz_strlcpy(cs->graphic_alt, packet->graphic_alt);
+  sz_strlcpy(cs->citizens_graphic, packet->citizens_graphic);
+  sz_strlcpy(cs->citizens_graphic_alt, packet->citizens_graphic_alt);
 
   tilespec_setup_city_tiles(id);
 }
diff -u -r freeciv/client/tilespec.c fc2/client/tilespec.c
--- freeciv/client/tilespec.c   Wed Mar 19 14:58:12 2003
+++ fc2/client/tilespec.c       Fri Mar 21 00:53:04 2003
@@ -856,7 +856,7 @@
   do {
     my_snprintf(buffer, sizeof(buffer), "explode.unit_%d",
                num_tiles_explode_unit++);
-  } while (load_sprite(buffer));
+  } while (load_sprite(buffer)); /* first increment of reference count */
   num_tiles_explode_unit--;
     
   if (num_tiles_explode_unit==0) {
@@ -867,25 +867,29 @@
 
     for (i = 0; i < num_tiles_explode_unit; i++) {
       my_snprintf(buffer, sizeof(buffer), "explode.unit_%d", i);
+      /* secound increment of reference count */
       SET_SPRITE(explode.unit[i], buffer);
+      /* dec. reference count so we know when to free the sprite. */
+      ((struct small_sprite *)hash_lookup_data(sprite_hash, 
buffer))->ref_count--;
     }
   }
 
+  my_snprintf(buffer, sizeof(buffer), "unit.xxx");
   SET_SPRITE(unit.auto_attack,  "unit.auto_attack");
   SET_SPRITE(unit.auto_settler, "unit.auto_settler");
   SET_SPRITE(unit.auto_explore, "unit.auto_explore");
   SET_SPRITE(unit.fallout,     "unit.fallout");
-  SET_SPRITE(unit.fortified,   "unit.fortified");     
-  SET_SPRITE(unit.fortifying,  "unit.fortifying");     
+  SET_SPRITE(unit.fortified,   "unit.fortified");
+  SET_SPRITE(unit.fortifying,  "unit.fortifying");
   SET_SPRITE(unit.fortress,     "unit.fortress");
   SET_SPRITE(unit.airbase,      "unit.airbase");
-  SET_SPRITE(unit.go_to,       "unit.goto");     
+  SET_SPRITE(unit.go_to,       "unit.goto"); 
   SET_SPRITE(unit.irrigate,     "unit.irrigate");
   SET_SPRITE(unit.mine,                "unit.mine");
   SET_SPRITE(unit.pillage,     "unit.pillage");
   SET_SPRITE(unit.pollution,    "unit.pollution");
   SET_SPRITE(unit.road,                "unit.road");
-  SET_SPRITE(unit.sentry,      "unit.sentry");      
+  SET_SPRITE(unit.sentry,      "unit.sentry");
   SET_SPRITE(unit.stack,       "unit.stack");
   SET_SPRITE(unit.transform,    "unit.transform");
   SET_SPRITE(unit.connect,      "unit.connect");
@@ -896,6 +900,7 @@
     SET_SPRITE(unit.hp_bar[i], buffer);
   }
 
+  my_snprintf(buffer, sizeof(buffer), "city.disorder");
   SET_SPRITE(city.disorder, "city.disorder");
 
   for(i=0; i<NUM_TILES_DIGITS; i++) {
@@ -912,15 +917,18 @@
     my_snprintf(buffer, sizeof(buffer), "city.t_trade_%d", i);
     SET_SPRITE(city.tile_tradenum[i], buffer);
   }
-
+  
+  my_snprintf(buffer, sizeof(buffer), "upkeep.xxx");
   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.shield, "upkeep.shield");
   
+  my_snprintf(buffer, sizeof(buffer), "user.attention");
   SET_SPRITE(user.attention, "user.attention");
 
+  my_snprintf(buffer, sizeof(buffer), "tx.xxx");
   SET_SPRITE(tx.fallout,    "tx.fallout");
   SET_SPRITE(tx.farmland,   "tx.farmland");
   SET_SPRITE(tx.irrigation, "tx.irrigation");
@@ -2490,7 +2498,7 @@
     ss->sprite =
        crop_sprite(ss->sf->big_sprite, ss->x, ss->y, ss->width, ss->height);
   }
-
+  
   /* Track the reference count so we know when to free the sprite. */
   ss->ref_count++;
 
diff -u -r freeciv/common/capstr.c fc2/common/capstr.c
--- freeciv/common/capstr.c     Mon Feb 17 23:59:58 2003
+++ fc2/common/capstr.c Fri Mar 21 02:16:41 2003
@@ -76,7 +76,7 @@
 
 #define CAPABILITY "+1.14.0 conn_info +occupied team tech_impr_gfx " \
                    "city_struct_minor_cleanup obsolete_last class_legend " \
-                   "+impr_req +waste +fastfocus +continent"
+                   "+impr_req +waste +fastfocus +continent citizens_style "
   
 /* "+1.14.0" is protocol for 1.14.0 release.
  *
@@ -108,7 +108,10 @@
  *
  * "fastfocus" removes the server from client unit focus.
  *
- * +continent": the server gives the client continent information
+ * "continent": the server gives the client continent information
+ *
+ * "citizens_style" is support for loading of ruleset-specified
+ * multi styles citizens city icons.
  */
 
 void init_our_capability(void)
diff -u -r freeciv/common/city.h fc2/common/city.h
--- freeciv/common/city.h       Wed Feb  5 17:41:34 2003
+++ fc2/common/city.h   Fri Mar 21 02:11:20 2003
@@ -299,6 +299,8 @@
   char name_orig[MAX_LEN_NAME];              /* untranslated */
   char graphic[MAX_LEN_NAME];
   char graphic_alt[MAX_LEN_NAME];
+  char citizens_graphic[MAX_LEN_NAME];
+  char citizens_graphic_alt[MAX_LEN_NAME];
   int techreq;                  /* tech required to use a style      */
   int replaced_by;              /* index to replacing style          */
                                 /* client side-only:                 */
diff -u -r freeciv/common/packets.c fc2/common/packets.c
--- freeciv/common/packets.c    Mon Feb 17 23:59:58 2003
+++ fc2/common/packets.c        Fri Mar 21 02:11:20 2003
@@ -2707,6 +2707,11 @@
   dio_put_string(&dout, packet->graphic);
   dio_put_string(&dout, packet->graphic_alt);
 
+  if (has_capability("citizens_style", pc->capability)) {
+    dio_put_string(&dout, packet->citizens_graphic);
+    dio_put_string(&dout, packet->citizens_graphic_alt);
+  }    
+  
   SEND_PACKET_END;
 }
 
@@ -2725,7 +2730,17 @@
   dio_get_string(&din, packet->name, MAX_LEN_NAME);
   dio_get_string(&din, packet->graphic, MAX_LEN_NAME);
   dio_get_string(&din, packet->graphic_alt, MAX_LEN_NAME);
-
+       
+  if (has_capability("citizens_style", pc->capability)) {
+    dio_get_string(&din, packet->citizens_graphic, MAX_LEN_NAME);
+    dio_get_string(&din, packet->citizens_graphic_alt, MAX_LEN_NAME);
+  } else {
+    /* Give a valid string (that will not refer to any sprite or
+       setup standart citizens icons -> "generic"). */
+    packet->citizens_graphic[0] = '\0';
+    my_snprintf(packet->citizens_graphic_alt, MAX_LEN_NAME, "generic");
+  }
+       
   RECEIVE_PACKET_END(packet);
 }
 
diff -u -r freeciv/common/packets.h fc2/common/packets.h
--- freeciv/common/packets.h    Mon Feb 17 23:59:59 2003
+++ fc2/common/packets.h        Fri Mar 21 02:11:20 2003
@@ -808,6 +808,8 @@
   char name[MAX_LEN_NAME];
   char graphic[MAX_LEN_NAME];
   char graphic_alt[MAX_LEN_NAME];
+  char citizens_graphic[MAX_LEN_NAME];
+  char citizens_graphic_alt[MAX_LEN_NAME];
   int techreq;
   int replaced_by;
 };
diff -u -r freeciv/data/default/cities.ruleset fc2/data/default/cities.ruleset
--- freeciv/data/default/cities.ruleset Mon Nov 18 20:46:25 2002
+++ fc2/data/default/cities.ruleset     Fri Mar 21 02:11:20 2003
@@ -19,6 +19,8 @@
 ;
 ; graphic     = group of tiles to use, see cities spec for
 ;               more info on city tiles
+; citizens_graphic     = group of citizens tiles to use, see citizens/small
+;                        spec for more info on citizens tiles
 ; tech        = technology required for style to be used
 ; replaced_by = which style replaced this one
 
@@ -26,34 +28,53 @@
 name        = _("European")
 graphic     = "city.european"
 graphic_alt = "-"
+citizens_graphic     = "ancient"
+citizens_graphic_alt = "generic"
 tech        = "None"
-replaced_by = "Industrial"
+replaced_by = "Renaissance"
 
 [citystyle_classical]
 name        = _("Classical")
 graphic     = "city.classical"
 graphic_alt = "-"
+citizens_graphic     = "ancient"
+citizens_graphic_alt = "generic"
 tech        = "None"
-replaced_by = "Industrial"
+replaced_by = "Renaissance"
 
 [citystyle_tropical]
 name        = _("Tropical")
 graphic     = "city.tropical"
 graphic_alt = "city.european"
+citizens_graphic     = "ancient"
+citizens_graphic_alt = "generic"
 tech        = "None"
-replaced_by = "Industrial"
+replaced_by = "Renaissance"
 
 [citystyle_asian]
 name        = _("Asian")
 graphic     = "city.asian"
 graphic_alt = "city.classical"
+citizens_graphic     = "ancient"
+citizens_graphic_alt = "generic"
 tech        = "None"
+replaced_by = "Renaissance"
+
+[citystyle_renaissance]
+name        = _("Renaissance")
+graphic     = "city.industrial"
+graphic_alt = "-"
+citizens_graphic     = "renaissance"
+citizens_graphic_alt = "generic"
+tech        = "University"
 replaced_by = "Industrial"
 
 [citystyle_industrial]
 name        = _("Industrial")
 graphic     = "city.industrial"
 graphic_alt = "-"
+citizens_graphic     = "industrial"
+citizens_graphic_alt = "generic"
 tech        = "Railroad"
 replaced_by = "Modern"
 
@@ -61,6 +82,8 @@
 name        = _("Modern")
 graphic     = "city.modern"
 graphic_alt = "-"
+citizens_graphic     = "modern"
+citizens_graphic_alt = "generic"
 tech        = "Automobile"
 replaced_by = "PostModern"
 
@@ -68,5 +91,7 @@
 name        = _("PostModern")
 graphic     = "city.postmodern"
 graphic_alt = "-"
+citizens_graphic     = "postmodern"
+citizens_graphic_alt = "generic"
 tech        = "Superconductors"
 replaced_by = "-"
diff -u -r freeciv/server/ruleset.c fc2/server/ruleset.c
--- freeciv/server/ruleset.c    Thu Mar  6 00:59:21 2003
+++ fc2/server/ruleset.c        Fri Mar 21 02:34:34 2003
@@ -2288,6 +2288,12 @@
               secfile_lookup_str(file, "%s.graphic", styles[i]));
     sz_strlcpy(city_styles[i].graphic_alt, 
               secfile_lookup_str(file, "%s.graphic_alt", styles[i]));
+    sz_strlcpy(city_styles[i].citizens_graphic, 
+              secfile_lookup_str_default(file, "-", 
+                       "%s.citizens_graphic", styles[i]));
+    sz_strlcpy(city_styles[i].citizens_graphic_alt, 
+              secfile_lookup_str_default(file, "generic", 
+                       "%s.citizens_graphic_alt", styles[i]));
     city_styles[i].techreq = lookup_tech(file, styles[i], "tech", TRUE,
                                          filename, city_styles[i].name);
     
@@ -2742,6 +2748,8 @@
     sz_strlcpy(city_p.name, city_styles[k].name_orig);
     sz_strlcpy(city_p.graphic, city_styles[k].graphic);
     sz_strlcpy(city_p.graphic_alt, city_styles[k].graphic_alt);
+    sz_strlcpy(city_p.citizens_graphic, city_styles[k].citizens_graphic );
+    sz_strlcpy(city_p.citizens_graphic_alt, 
city_styles[k].citizens_graphic_alt );
 
     lsend_packet_ruleset_city(dest, &city_p);
   }

[Prev in Thread] Current Thread [Next in Thread]