<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40758 >


I've created and tested a rollback patch, which removes all update22*
references/code and revert back resource identifiers to the 2.1.x default.

Should you need the dictionary approach, I could come up with a patch
for that too.

- Stéphane Messerli

> But I am still wondering if it would not just be simpler for
> the identifiers to be changed back to what they were before,
> i.e. the values they have in the update22* fields. I will
> check this and perhaps make a patch later if nobody can
> figure out a good reason why not to do this.

Index: server/ruleset.c
===================================================================
--- server/ruleset.c	(revision 15611)
+++ server/ruleset.c	(working copy)
@@ -69,10 +69,6 @@
 #define UNIT_CLASS_SECTION_PREFIX "unitclass_"
 #define UNIT_SECTION_PREFIX "unit_"
 
-/* savegame conversion: resource identifiers */
-char *update22one = NULL;
-char *update22two = NULL;
-
 static const char name_too_long[] = "Name \"%s\" too long; truncating.";
 #define check_name(name) (check_strlen(name, MAX_LEN_NAME, name_too_long))
 #define name_strlcpy(dst, src) \
@@ -1622,16 +1618,6 @@
   }
   game.control.resource_count = nval;
 
-  if (update22one) {
-    free(update22one);
-  }
-  update22one = fc_calloc(nval, sizeof(char));
-
-  if (update22two) {
-    free(update22two);
-  }
-  update22two = fc_calloc(nval, sizeof(char));
-
   /* avoid re-reading files */
   if (resource_sections) {
     free(resource_sections);
@@ -1932,33 +1918,6 @@
       }
     }
 
-    update22one[i]
-      = secfile_lookup_str_default(file, identifier,
-                                   "%s.update22one", rsection)[0];
-    if (RESOURCE_NULL_IDENTIFIER == update22one[i]) {
-      ruleset_error(LOG_ERROR, "\"%s\" [%s] update22one missing value.",
-                    filename, rsection);
-    }
-    if (RESOURCE_NONE_IDENTIFIER == update22one[i]) {
-      ruleset_error(LOG_ERROR,
-                    "\"%s\" [%s] cannot use '%c' as an identifier;"
-                    " it is reserved.",
-                    filename, rsection, update22one[i]);
-    }
-
-    update22two[i]
-      = secfile_lookup_str_default(file, identifier,
-                                   "%s.update22two", rsection)[0];
-    if (RESOURCE_NULL_IDENTIFIER == update22two[i]) {
-      ruleset_error(LOG_ERROR, "\"%s\" [%s] update22two missing value.",
-                    filename, rsection);
-    }
-    if (RESOURCE_NONE_IDENTIFIER == update22two[i]) {
-      ruleset_error(LOG_ERROR,
-                    "\"%s\" [%s] cannot use '%c' as an identifier;"
-                    " it is reserved.",
-                    filename, rsection, update22two[i]);
-    }
   } resource_type_iterate_end;
 
   /* base details */
Index: server/ruleset.h
===================================================================
--- server/ruleset.h	(revision 15611)
+++ server/ruleset.h	(working copy)
@@ -15,10 +15,6 @@
 
 struct conn_list;
 
-/* savegame conversion: resource identifiers */
-extern char *update22one;
-extern char *update22two;
-
 /* functions */
 void load_rulesets(void);
 void send_rulesets(struct conn_list *dest);
Index: server/savegame.c
===================================================================
--- server/savegame.c	(revision 15611)
+++ server/savegame.c	(working copy)
@@ -914,28 +914,6 @@
 }
 
 /****************************************************************************
-  Convert an older resource into the current value.
-****************************************************************************/
-static struct resource *update22_resource(char c)
-{
-  /* Different rulesets had different resources. */
-  if (strcmp(game.rulesetdir, "civ1") == 0) {
-    resource_type_iterate(presource) {
-      if (update22one[resource_index(presource)] == c) {
-        return presource;
-      }
-    } resource_type_iterate_end;
-  } else {
-    resource_type_iterate(presource) {
-      if (update22two[resource_index(presource)] == c) {
-        return presource;
-      }
-    } resource_type_iterate_end;
-  }
-  return NULL;
-}
-
-/****************************************************************************
   Return the resource for the given identifier.
 ****************************************************************************/
 static struct resource *identifier_to_resource(char c)
@@ -945,9 +923,6 @@
    || c == RESOURCE_NONE_IDENTIFIER) {
     return NULL;
   }
-  if (20199 > game.version) {
-    return update22_resource(c);
-  }
   return find_resource_by_identifier(c);
 }
 
Index: data/default/terrain.ruleset
===================================================================
--- data/default/terrain.ruleset	(revision 15611)
+++ data/default/terrain.ruleset	(working copy)
@@ -674,8 +674,6 @@
 ; identifier           = single-character identifier used in savegames.  This
 ;                        must be unique for each resource, and changing it will
 ;                        break savegame compatibility.
-; update22one          = single-character identifier in < 2.2 civ1 savegames.
-; update22two          = single-character identifier in < 2.2 civ2 savegames.
 ; food                 = increased food production
 ; shield               = increased shield production
 ; trade                = increased trade production
@@ -685,7 +683,6 @@
 graphic     = "ts.gold"
 graphic_alt = "-"
 identifier  = "$"
-update22one = "H"
 trade       = 6
 # glacier, hills, mountains.
 
@@ -701,8 +698,7 @@
 name        = _("?animals:Game")
 graphic     = "ts.tundra_game"
 graphic_alt = "-"
-identifier  = "A"
-update22two = "e"
+identifier  = "e"
 food        = 2
 shield      = 1
 # tundra.
@@ -711,8 +707,7 @@
 name        = _("Furs")
 graphic     = "ts.furs"
 graphic_alt = "-"
-identifier  = "b"
-update22two = "u"
+identifier  = "u"
 food        = 1
 trade       = 3
 # tundra-only (beaver pelts).
@@ -721,8 +716,7 @@
 name        = _("Coal")
 graphic     = "ts.coal"
 graphic_alt = "-"
-identifier  = "C"
-update22two = "c"
+identifier  = "c"
 shield      = 2
 # hills.
 
@@ -730,8 +724,7 @@
 name        = _("Fish")
 graphic     = "ts.fish"
 graphic_alt = "-"
-identifier  = "F"
-update22two = "y"
+identifier  = "y"
 food        = 2
 # ocean.
 
@@ -748,23 +741,17 @@
 name        = _("Gems")
 graphic     = "ts.gems"
 graphic_alt = "-"
-identifier  = "G"
-update22two = "g"
+identifier  = "g"
 trade       = 4
 # jungle.
 
 ; "h" reserved for strategic horses
 
-; "H" formerly for update22one gold
-
-; "i" reserved for incense
-
 [resource_buffalo]
 name        = _("Buffalo")
 graphic     = "ts.buffalo"
 graphic_alt = "-"
-identifier  = "I"
-update22two = "b"
+identifier  = "b"
 shield      = 2
 # plains (horses => buffalo => cattle).
 
@@ -786,8 +773,7 @@
 name        = _("Oasis")
 graphic     = "ts.oasis"
 graphic_alt = "-"
-identifier  = "O"
-update22two = "o"
+identifier  = "o"
 food        = 3
 # desert.
 
@@ -795,8 +781,7 @@
 name        = _("Peat")
 graphic     = "ts.peat"
 graphic_alt = "-"
-identifier  = "P"
-update22two = "a"
+identifier  = "a"
 shield      = 4
 # swamp (petroleum => peat => petroleum).
 
@@ -814,8 +799,7 @@
 name        = _("Resources")
 graphic     = "ts.grassland_resources"
 graphic_alt = "-"
-identifier  = "R"
-update22two = "r"
+identifier  = "r"
 shield      = 1
 # grassland.
 
@@ -823,8 +807,7 @@
 name        = _("Ivory")
 graphic     = "ts.arctic_ivory"
 graphic_alt = "-"
-identifier  = "S"
-update22two = "i"
+identifier  = "i"
 food        = 1
 shield      = 1
 trade       = 4
@@ -879,7 +862,6 @@
 graphic     = "ts.oil"
 graphic_alt = "-"
 identifier  = "X"
-update22two = "P"
 shield      = 3
 # desert-only, special processing, see savegame map_load().
 
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to