Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9831) rewrite handle_ruleset_terrain_control
Home

[Freeciv-Dev] (PR#9831) rewrite handle_ruleset_terrain_control

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9831) rewrite handle_ruleset_terrain_control
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 26 Aug 2004 21:40:44 -0700
Reply-to: rt@xxxxxxxxxxx

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

Because the ruleset_terrain_control packet structure is the same as the 
terrain_misc structure (via a #define in map.h) there is no need to copy 
field-by-field.  We can easily just copy the whole thing.  In the server 
this is already how it's done.

I can't decide whether this congruity is simple and elegant or ugly and 
hackish.  Should more structures be done this way?

jason

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.397
diff -u -r1.397 packhand.c
--- client/packhand.c   26 Aug 2004 18:37:51 -0000      1.397
+++ client/packhand.c   27 Aug 2004 04:39:11 -0000
@@ -2624,32 +2624,13 @@
 }
 
 /**************************************************************************
-...
+  Handle the terrain control ruleset packet sent by the server.
 **************************************************************************/
-void handle_ruleset_terrain_control(struct terrain_misc *p)
+void handle_ruleset_terrain_control(struct packet_ruleset_terrain_control *p)
 {
-  terrain_control.may_road = p->may_road;
-  terrain_control.may_irrigate = p->may_irrigate;
-  terrain_control.may_mine = p->may_mine;
-  terrain_control.may_transform = p->may_transform;
-  terrain_control.ocean_reclaim_requirement = p->ocean_reclaim_requirement;
-  terrain_control.land_channel_requirement = p->land_channel_requirement;
-  terrain_control.river_move_mode = p->river_move_mode;
-  terrain_control.river_defense_bonus = p->river_defense_bonus;
-  terrain_control.river_trade_incr = p->river_trade_incr;
-  sz_strlcpy(terrain_control.river_help_text, p->river_help_text);
-  terrain_control.fortress_defense_bonus = p->fortress_defense_bonus;
-  terrain_control.road_superhighway_trade_bonus = 
p->road_superhighway_trade_bonus;
-  terrain_control.rail_food_bonus = p->rail_food_bonus;
-  terrain_control.rail_shield_bonus = p->rail_shield_bonus;
-  terrain_control.rail_trade_bonus = p->rail_trade_bonus;
-  terrain_control.farmland_supermarket_food_bonus = 
p->farmland_supermarket_food_bonus;
-  terrain_control.pollution_food_penalty = p->pollution_food_penalty;
-  terrain_control.pollution_shield_penalty = p->pollution_shield_penalty;
-  terrain_control.pollution_trade_penalty = p->pollution_trade_penalty;
-  terrain_control.fallout_food_penalty = p->fallout_food_penalty;
-  terrain_control.fallout_shield_penalty = p->fallout_shield_penalty;
-  terrain_control.fallout_trade_penalty = p->fallout_trade_penalty;
+  /* Since terrain_control is the same as packet_ruleset_terrain_control
+   * we can just copy the data directly. */
+  terrain_control = *p;
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9831) rewrite handle_ruleset_terrain_control, Jason Short <=