Author: cazfi
Date: Mon Apr 20 23:13:00 2015
New Revision: 28831

URL: http://svn.gna.org/viewcvs/freeciv?rev=28831&view=rev
Log:
Added direction information about traderoutes.

See patch #6003

Modified:
    trunk/client/packhand.c
    trunk/common/city.h
    trunk/common/packets.def
    trunk/common/traderoutes.h
    trunk/fc_version
    trunk/server/citytools.c
    trunk/server/savegame.c
    trunk/server/savegame2.c
    trunk/server/savegame3.c

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=28831&r1=28830&r2=28831&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Mon Apr 20 23:13:00 2015
@@ -680,6 +680,7 @@
   for (i = 0; i < MAX_TRADE_ROUTES; i++) {
     pcity->trade[i] = packet->trade[i];
     pcity->trade_value[i] = packet->trade_value[i];
+    pcity->trade_direction[i] = packet->trade_direction[i];
   }
 
   if (pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE]

Modified: trunk/common/city.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/city.h?rev=28831&r1=28830&r2=28831&view=diff
==============================================================================
--- trunk/common/city.h (original)
+++ trunk/common/city.h Mon Apr 20 23:13:00 2015
@@ -25,6 +25,7 @@
 #include "fc_types.h"
 #include "name_translation.h"
 #include "improvement.h"
+#include "traderoutes.h"
 #include "unitlist.h"
 #include "vision.h"
 #include "workertask.h"
@@ -323,6 +324,7 @@
 
   /* trade routes */
   int trade[MAX_TRADE_ROUTES], trade_value[MAX_TRADE_ROUTES];
+  enum route_direction trade_direction[MAX_TRADE_ROUTES];
 
   /* Tile output, regardless of if the tile is actually worked. It is used
    * as cache for the output of the tiles within the city map.

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=28831&r1=28830&r2=28831&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Mon Apr 20 23:13:00 2015
@@ -232,6 +232,7 @@
 type UTYF               = uint8(enum unit_type_flag_id)
 type CBONUS_TYPE        = uint8(enum combat_bonus_type)
 type TRI                = uint8(enum traderoute_illegal_cancelling)
+type RDIR               = uint8(enum route_direction)
 type MOVE_MODE          = uint8(enum road_move_mode)
 type GEN_ACTION         = uint8(enum gen_action)
 type REVOLENTYPE        = uint8(enum revolen_type)
@@ -617,6 +618,7 @@
 
   UINT16 trade[MAX_TRADE_ROUTES];
   UINT8 trade_value[MAX_TRADE_ROUTES];
+  RDIR trade_direction[MAX_TRADE_ROUTES];
 
   UINT16 pollution;
   UINT16 illness_trade;

Modified: trunk/common/traderoutes.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/traderoutes.h?rev=28831&r1=28830&r2=28831&view=diff
==============================================================================
--- trunk/common/traderoutes.h  (original)
+++ trunk/common/traderoutes.h  Mon Apr 20 23:13:00 2015
@@ -55,6 +55,15 @@
 #define SPECENUM_VALUE2NAME "Science"
 #define SPECENUM_VALUE3 TBONUS_BOTH
 #define SPECENUM_VALUE3NAME "Both"
+#include "specenum_gen.h"
+
+#define SPECENUM_NAME route_direction
+#define SPECENUM_VALUE0 RDIR_FROM
+#define SPECENUM_VALUE0NAME N_("?routedir:From")
+#define SPECENUM_VALUE1 RDIR_TO
+#define SPECENUM_VALUE1NAME N_("?routedir:To")
+#define SPECENUM_VALUE2 RDIR_BIDIRECTIONAL
+#define SPECENUM_VALUE2NAME N_("?routedir:Bidirectional")
 #include "specenum_gen.h"
 
 struct trade_route_settings {

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=28831&r1=28830&r2=28831&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Mon Apr 20 23:13:00 2015
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Apr.15"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Apr.20"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/citytools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.c?rev=28831&r1=28830&r2=28831&view=diff
==============================================================================
--- trunk/server/citytools.c    (original)
+++ trunk/server/citytools.c    Mon Apr 20 23:13:00 2015
@@ -2259,6 +2259,7 @@
   for (i = 0; i < MAX_TRADE_ROUTES; i++) {
     packet->trade[i] = pcity->trade[i];
     packet->trade_value[i] = pcity->trade_value[i];
+    packet->trade_direction[i] = pcity->trade_direction[i];
   }
 
   output_type_iterate(o) {
@@ -2530,6 +2531,7 @@
   for (i = 0; i < MAX_TRADE_ROUTES; i++) {
     if (pc1->trade[i] == 0) {
       pc1->trade[i] = pc2->id;
+      pc1->trade_direction[i] = RDIR_FROM;
       break;
     }
   }
@@ -2537,6 +2539,7 @@
   for (i = 0; i < MAX_TRADE_ROUTES; i++) {
     if (pc2->trade[i] == 0) {
       pc2->trade[i] = pc1->id;
+      pc2->trade_direction[i] = RDIR_TO;
       break;
     }
   }

Modified: trunk/server/savegame.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame.c?rev=28831&r1=28830&r2=28831&view=diff
==============================================================================
--- trunk/server/savegame.c     (original)
+++ trunk/server/savegame.c     Mon Apr 20 23:13:00 2015
@@ -2305,6 +2305,7 @@
       pcity->trade[j] = secfile_lookup_int_default(file, 0,
                                                    "player%d.c%d.traderoute%d",
                                                    plrno, i, j);
+      pcity->trade_direction[j] = RDIR_BIDIRECTIONAL;
     }
 
     fc_assert_exit_msg(secfile_lookup_int(file, &pcity->food_stock,

Modified: trunk/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=28831&r1=28830&r2=28831&view=diff
==============================================================================
--- trunk/server/savegame2.c    (original)
+++ trunk/server/savegame2.c    Mon Apr 20 23:13:00 2015
@@ -2954,6 +2954,7 @@
   for (i = 0; i < MAX_TRADE_ROUTES; i++) {
     pcity->trade[i] = secfile_lookup_int_default(loading->file, 0,
                                                  "%s.traderoute%d", citystr, 
i);
+    pcity->trade_direction[i] = RDIR_BIDIRECTIONAL;
   }
 
   sg_warn_ret_val(secfile_lookup_int(loading->file, &pcity->food_stock,

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=28831&r1=28830&r2=28831&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Mon Apr 20 23:13:00 2015
@@ -4239,8 +4239,16 @@
   }
 
   for (i = 0; i < MAX_TRADE_ROUTES; i++) {
+    const char *dir;
+
     pcity->trade[i] = secfile_lookup_int_default(loading->file, 0,
                                                  "%s.traderoute%d", citystr, 
i);
+    dir = secfile_lookup_str(loading->file, "%s.route_direction%d", citystr, 
i);
+    sg_warn_ret_val(dir != NULL, FALSE,
+                    "No traderoute direction found for %s", citystr);
+    pcity->trade_direction[i] = route_direction_by_name(dir, fc_strcasecmp);
+    sg_warn_ret_val(route_direction_is_valid(pcity->trade_direction[i]), FALSE,
+                    "Illegal route direction %s", dir);
   }
 
   sg_warn_ret_val(secfile_lookup_int(loading->file, &pcity->food_stock,
@@ -4589,6 +4597,8 @@
     for (j = 0; j < MAX_TRADE_ROUTES; j++) {
       secfile_insert_int(saving->file, pcity->trade[j], "%s.traderoute%d",
                          buf, j);
+      secfile_insert_str(saving->file, 
route_direction_name(pcity->trade_direction[i]),
+                         "%s.route_direction%d", buf, j);
     }
 
     secfile_insert_int(saving->file, pcity->food_stock, "%s.food_stock",


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to