Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] (PR#2495) new setup citizens sprites procedure.
Home

[Freeciv-Dev] (PR#2495) new setup citizens sprites procedure.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2495) new setup citizens sprites procedure.
From: "Rafa³ Bursig via RT" <rt@xxxxxxxxxxxxxx>
Date: Thu, 5 Dec 2002 14:45:36 -0800
Reply-to: rt@xxxxxxxxxxxxxx

This patch add new setup procedure to citizens sprites that add support 
to citizens styles.
It is not finished, still lack "free sprites" part but I'm wait to 
Jason clean up in citizens code.

Problem is that some of my next patches depend of this change.

Rafal


--------------------------------------------------------------------------
Co o swietach mowia gwiazdy?
>>> http://choinka.interia.pl <<<
Sponsoruja Zaklady Tluszczowe Bielmar

diff -u -r fcc/client/packhand.c fc2/client/packhand.c
--- fcc/client/packhand.c       Wed Dec  4 15:27:36 2002
+++ fc2/client/packhand.c       Sat Nov 30 00:31:03 2002
@@ -1167,11 +1167,17 @@
 **************************************************************************/
 void handle_player_info(struct packet_player_info *pinfo)
 {
-  int i;
+  int i , style , old_style;
   bool poptechup;
   char msg[MAX_LEN_MSG];
   struct player *pplayer = &game.players[pinfo->playerno];
 
+  /* ugly fix to force first load citizens gfx */
+  if (pplayer == game.player_ptr &&
+         !strcmp("YourName", pplayer->name )) {
+    pplayer->city_style = -1;
+  }
+  
   sz_strlcpy(pplayer->name, pinfo->name);
 
   if (!pplayer->island_improv) {   /* initialise new player */
@@ -1189,6 +1195,7 @@
   pplayer->government=pinfo->government;
   pplayer->embassy=pinfo->embassy;
   pplayer->gives_shared_vision = pinfo->gives_shared_vision;
+  old_style = pplayer->city_style;
   pplayer->city_style=pinfo->city_style;
 
   for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) {
@@ -1260,6 +1267,14 @@
       && get_client_state() == CLIENT_GAME_RUNNING_STATE) {
     update_info_label();
   }
+  
+  style = get_player_city_style( pplayer );
+  if ((pplayer == game.player_ptr)&&(style != old_style))
+  {
+    tilespec_setup_citizens_tiles(style);
+  }
+  pplayer->city_style = style;
+  
 }
 
 /**************************************************************************
@@ -2187,6 +2202,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 fcc/client/tilespec.c fc2/client/tilespec.c
--- fcc/client/tilespec.c       Wed Dec  4 15:27:37 2002
+++ fc2/client/tilespec.c       Wed Dec  4 15:13:12 2002
@@ -343,6 +343,9 @@
     tilespec_setup_city_tiles(id);
   }
 
+  /* reload citizens gfx */
+  tilespec_setup_citizens_tiles( get_player_city_style(game.player_ptr) );
+  
   /* Step 4:  Draw.
    *
    * Do any necessary redraws.
@@ -622,19 +625,6 @@
     SET_SPRITE(coast_color, "t.coast_color");
   }
 
-  /* This uses internal code for citizens array/index: */
-  SET_SPRITE(citizen[0], "citizen.entertainer");
-  SET_SPRITE(citizen[1], "citizen.scientist");
-  SET_SPRITE(citizen[2], "citizen.tax_collector");
-  SET_SPRITE(citizen[3], "citizen.content_0");
-  SET_SPRITE(citizen[4], "citizen.content_1");
-  SET_SPRITE(citizen[5], "citizen.happy_0");
-  SET_SPRITE(citizen[6], "citizen.happy_1");
-  SET_SPRITE(citizen[7], "citizen.unhappy_0");
-  SET_SPRITE(citizen[8], "citizen.unhappy_1");
-  SET_SPRITE(citizen[9], "citizen.angry_0");
-  SET_SPRITE(citizen[10], "citizen.angry_1");
-
   SET_SPRITE(spaceship.solar_panels, "spaceship.solar_panels");
   SET_SPRITE(spaceship.life_support, "spaceship.life_support");
   SET_SPRITE(spaceship.habitation,   "spaceship.habitation");
@@ -1893,13 +1883,89 @@
 }
 
 /**********************************************************************
+  Set cititizens tiles sprite values; should only happen after
+  tilespec_load_tiles() and player city style is known.
+***********************************************************************/
+void tilespec_setup_citizens_tiles(int style)
+{
+  char tag[64];
+  char alt[64];
+  char alt_buf[32] = ".";
+  
+  if ( strcmp( "generic" , city_styles[style].citizens_graphic_alt ))
+  {
+    my_snprintf( alt_buf , sizeof(alt_buf) , ".%s_",
+                       city_styles[style].citizens_graphic_alt ); 
+  }
+  
+  /* This uses internal code for citizens array/index: */
+  
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_entertainer",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%sentertainer", alt_buf );
+  SET_SPRITE_ALT(citizen[0], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_scientist",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%sscientist", alt_buf );
+  SET_SPRITE_ALT(citizen[1], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_tax_collector",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%stax_collector", alt_buf);
+  SET_SPRITE_ALT(citizen[2], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_content_0",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%scontent_0", alt_buf);
+  SET_SPRITE_ALT(citizen[3], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_content_1",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%scontent_1", alt_buf);
+  SET_SPRITE_ALT(citizen[4], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_happy_0",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%shappy_0", alt_buf);
+  SET_SPRITE_ALT(citizen[5], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_happy_1",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%shappy_1", alt_buf);
+  SET_SPRITE_ALT(citizen[6], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_unhappy_0",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%sunhappy_0", alt_buf);
+  SET_SPRITE_ALT(citizen[7], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_unhappy_1",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%sunhappy_1", alt_buf);
+  SET_SPRITE_ALT(citizen[8], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_angry_0",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%sangry_0", alt_buf);
+  SET_SPRITE_ALT(citizen[9], tag, alt );
+
+  my_snprintf( tag , sizeof(tag) , "citizen.%s_angry_1",
+    city_styles[style].citizens_graphic );
+  my_snprintf( alt , sizeof(alt) , "citizen%sangry_1", alt_buf);
+  SET_SPRITE_ALT(citizen[10], tag, alt );
+  
+}
+
+
+/**********************************************************************
   Set city tiles sprite values; should only happen after
   tilespec_load_tiles().
 ***********************************************************************/
 void tilespec_setup_city_tiles(int style)
 {
   tilespec_setup_style_tile(style, city_styles[style].graphic);
-
+  
   if (city_styles[style].tiles_num == 0) {
     /* no tiles found, try alternate */
     freelog(LOG_NORMAL, "No tiles for %s style, trying alternate %s style",
@@ -1924,6 +1990,7 @@
     city_styles[style].tiles_num = 1;
     city_styles[style].tresh[0] = 0;
   }
+     
 }
 
 /**********************************************************************
diff -u -r fcc/client/tilespec.h fc2/client/tilespec.h
--- fcc/client/tilespec.h       Wed Dec  4 15:27:37 2002
+++ fc2/client/tilespec.h       Fri Nov 29 17:33:42 2002
@@ -43,6 +43,7 @@
 void tilespec_setup_government(int id);
 void tilespec_setup_nation_flag(int id);
 void tilespec_setup_city_tiles(int style);
+void tilespec_setup_citizens_tiles(int style);
 void tilespec_alloc_city_tiles(int count);
 void tilespec_free_city_tiles(int count);
 void tilespec_free_tech_gfx(void);
diff -u -r fcc/common/city.h fc2/common/city.h
--- fcc/common/city.h   Mon Nov 25 20:18:09 2002
+++ fc2/common/city.h   Thu Nov 28 22:23:07 2002
@@ -312,6 +312,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 fcc/common/packets.c fc2/common/packets.c
--- fcc/common/packets.c        Wed Dec  4 15:27:37 2002
+++ fc2/common/packets.c        Fri Nov 29 17:10:22 2002
@@ -2650,6 +2650,11 @@
   dio_put_string(&dout, packet->graphic);
   dio_put_string(&dout, packet->graphic_alt);
 
+  if (has_capability("delux", pc->capability)) {
+    dio_put_string(&dout, packet->citizens_graphic);
+    dio_put_string(&dout, packet->citizens_graphic_alt);
+  }    
+  
   SEND_PACKET_END;
 }
 
@@ -2668,7 +2673,16 @@
   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("delux", pc->capability)) {
+    dio_get_string(&din, packet->citizens_graphic, MAX_LEN_NAME);
+    dio_get_string(&din, packet->citizens_graphic_alt, MAX_LEN_NAME);
+  } else {
+    /* This is probably necessary */
+    packet->citizens_graphic[0] = '\0';
+    my_snprintf( packet->citizens_graphic_alt , MAX_LEN_NAME , "generic" );
+  }
+       
   RECEIVE_PACKET_END(packet);
 }
 
diff -u -r fcc/common/packets.h fc2/common/packets.h
--- fcc/common/packets.h        Wed Dec  4 15:27:37 2002
+++ fc2/common/packets.h        Thu Nov 28 22:30:12 2002
@@ -799,6 +799,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 fcc/common/tech.h fc2/common/tech.h
--- fcc/common/tech.h   Wed Dec  4 15:27:37 2002
+++ fc2/common/tech.h   Tue Nov 26 23:44:17 2002
@@ -65,7 +65,7 @@
 
 struct advance {
   char name[MAX_LEN_NAME];
-  char name_orig[MAX_LEN_NAME];        /* untranslated */
+  char name_orig[MAX_LEN_NAME];        /* untranslated */
   char graphic_str[MAX_LEN_NAME];      /* icon of tech. */
   char graphic_alt[MAX_LEN_NAME];      /* icon of tech. */
   int req[2];
diff -u -r fcc/data/default/cities.ruleset fc2/data/default/cities.ruleset
--- fcc/data/default/cities.ruleset     Mon Nov 18 20:46:25 2002
+++ fc2/data/default/cities.ruleset     Fri Nov 29 01:06:05 2002
@@ -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 fcc/server/ruleset.c fc2/server/ruleset.c
--- fcc/server/ruleset.c        Wed Dec  4 15:27:37 2002
+++ fc2/server/ruleset.c        Wed Dec  4 15:32:40 2002
@@ -2242,6 +2242,10 @@
               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(file, "%s.citizens_graphic", styles[i]));
+    sz_strlcpy(city_styles[i].citizens_graphic_alt, 
+              secfile_lookup_str(file, "%s.citizens_graphic_alt", styles[i]));
     city_styles[i].techreq = lookup_tech(file, styles[i], "tech", TRUE,
                                          filename, city_styles[i].name);
     
@@ -2685,6 +2689,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]