Author: cazfi
Date: Sat Oct 29 13:04:18 2016
New Revision: 34288

URL: http://svn.gna.org/viewcvs/freeciv?rev=34288&view=rev
Log:
Store turn, not year, to plrtile last_updated.

See patch #7880

Modified:
    branches/S2_6/common/game.c
    branches/S2_6/common/game.h
    branches/S2_6/server/maphand.c
    branches/S2_6/server/savegame.c
    branches/S2_6/server/savegame2.c

Modified: branches/S2_6/common/game.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/game.c?rev=34288&r1=34287&r2=34288&view=diff
==============================================================================
--- branches/S2_6/common/game.c (original)
+++ branches/S2_6/common/game.c Sat Oct 29 13:04:18 2016
@@ -386,6 +386,7 @@
     game.server.event_cache.turns = GAME_DEFAULT_EVENT_CACHE_TURNS;
     game.server.foggedborders     = GAME_DEFAULT_FOGGEDBORDERS;
     game.server.fogofwar_old      = game.info.fogofwar;
+    game.server.last_updated_year = FALSE;
     game.server.freecost          = GAME_DEFAULT_FREECOST;
     game.server.homecaughtunits   = GAME_DEFAULT_HOMECAUGHTUNITS;
     game.server.kick_time         = GAME_DEFAULT_KICK_TIME;

Modified: branches/S2_6/common/game.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/game.h?rev=34288&r1=34287&r2=34288&view=diff
==============================================================================
--- branches/S2_6/common/game.h (original)
+++ branches/S2_6/common/game.h Sat Oct 29 13:04:18 2016
@@ -222,6 +222,8 @@
 
       bool fogofwar_old; /* as the fog_of_war bit get changed by setting
                           * the server we need to remember the old setting */
+      bool last_updated_year; /* last_updated is still counted as year in this
+                               * game. */
       char rulesetdir[MAX_LEN_NAME];
       char demography[MAX_LEN_DEMOGRAPHY];
       char allow_take[MAX_LEN_ALLOW_TAKE];

Modified: branches/S2_6/server/maphand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/maphand.c?rev=34288&r1=34287&r2=34288&view=diff
==============================================================================
--- branches/S2_6/server/maphand.c      (original)
+++ branches/S2_6/server/maphand.c      Sat Oct 29 13:04:18 2016
@@ -1184,7 +1184,11 @@
   plrtile->extras_owner = NULL;
   plrtile->site = NULL;
   BV_CLR_ALL(plrtile->extras);
-  plrtile->last_updated = game.info.year;
+  if (!game.server.last_updated_year) {
+    plrtile->last_updated = game.info.turn;
+  } else {
+    plrtile->last_updated = game.info.year;
+  }
 
   plrtile->seen_count[V_MAIN] = !game.server.fogofwar_old;
   plrtile->seen_count[V_INVIS] = 0;
@@ -1306,14 +1310,15 @@
 
 /***************************************************************
   Remember that tile was last seen this year.
-
-  FIXME: Should last_updated be turn rather than year? Turn is
-         guaranteed to go forward when game proceeds, but year
-         is not (it can remain same or even go backwards)
 ***************************************************************/
-void update_player_tile_last_seen(struct player *pplayer, struct tile *ptile)
-{
-  map_get_player_tile(ptile, pplayer)->last_updated = game.info.year;
+void update_player_tile_last_seen(struct player *pplayer,
+                                  struct tile *ptile)
+{
+  if (!game.server.last_updated_year) {
+    map_get_player_tile(ptile, pplayer)->last_updated = game.info.turn;
+  } else {
+    map_get_player_tile(ptile, pplayer)->last_updated = game.info.year;
+  }
 }
 
 /***************************************************************

Modified: branches/S2_6/server/savegame.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame.c?rev=34288&r1=34287&r2=34288&view=diff
==============================================================================
--- branches/S2_6/server/savegame.c     (original)
+++ branches/S2_6/server/savegame.c     Sat Oct 29 13:04:18 2016
@@ -3938,6 +3938,9 @@
     int loaded_players = 0;
     int players;
 
+    /* Update time has been saved as year in legacysave.c */
+    game.server.last_updated_year = TRUE;
+
     /* destroyed wonders: */
     string = secfile_lookup_str(file, "game.destroyed_wonders_new");
     if (!string) {

Modified: branches/S2_6/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame2.c?rev=34288&r1=34287&r2=34288&view=diff
==============================================================================
--- branches/S2_6/server/savegame2.c    (original)
+++ branches/S2_6/server/savegame2.c    Sat Oct 29 13:04:18 2016
@@ -1593,6 +1593,11 @@
   (void) secfile_entry_by_path(loading->file, "savefile.reason");
   (void) secfile_entry_by_path(loading->file, "savefile.revision");
 
+  /* In case of savegame2.c saves, missing entry means savegame older than 
support
+   * for saving last_updated by turn. So this must default to TRUE. */
+  game.server.last_updated_year = secfile_lookup_bool_default(loading->file, 
TRUE,
+                                                              
"savefile.last_updated_as_year");
+
   /* Load improvements. */
   loading->improvement.size
     = secfile_lookup_int_default(loading->file, 0,
@@ -1928,6 +1933,9 @@
      * This is never loaded, but exist in savegame file only for debugging 
purposes. */
     secfile_insert_str(saving->file, game.control.version, 
"savefile.rulesetversion");
   }
+
+  secfile_insert_bool(saving->file, game.server.last_updated_year,
+                      "savefile.last_updated_as_year");
 
   /* Save improvement order in savegame, so we are not dependent on ruleset
    * order. If the game isn't started improvements aren't loaded so we can


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

Reply via email to