Author: cazfi Date: Mon May 2 18:43:33 2016 New Revision: 32543 URL: http://svn.gna.org/viewcvs/freeciv?rev=32543&view=rev Log: Moved resource_by_identifier() to savecompat.c
See patch #7167 Modified: trunk/common/terrain.c trunk/common/terrain.h trunk/data/alien/terrain.ruleset trunk/data/civ1/terrain.ruleset trunk/data/civ2/terrain.ruleset trunk/data/civ2civ3/terrain.ruleset trunk/data/classic/terrain.ruleset trunk/data/experimental/terrain.ruleset trunk/data/multiplayer/terrain.ruleset trunk/data/sandbox/terrain.ruleset trunk/data/stub/terrain.ruleset trunk/server/ruleset.c trunk/server/savecompat.c trunk/server/savecompat.h trunk/server/savegame3.c trunk/tools/ruledit/rulesave.c Modified: trunk/common/terrain.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/terrain.c?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/common/terrain.c (original) +++ trunk/common/terrain.c Mon May 2 18:43:33 2016 @@ -357,20 +357,6 @@ return NULL; } return civ_resources[type]; -} - -/**************************************************************************** - Return the resource type matching the identifier, or NULL when none matches. -****************************************************************************/ -struct resource_type *resource_by_identifier(const char identifier) -{ - resource_type_iterate(presource) { - if (presource->identifier == identifier) { - return presource; - } - } resource_type_iterate_end; - - return NULL; } /**************************************************************************** Modified: trunk/common/terrain.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/terrain.h?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/common/terrain.h (original) +++ trunk/common/terrain.h Mon May 2 18:43:33 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ struct resource_type { int item_number; - char identifier; /* Single-character identifier used in savegames. */ + char id_old_save; /* Single-character identifier used in old savegames. */ #define RESOURCE_NULL_IDENTIFIER '\0' #define RESOURCE_NONE_IDENTIFIER ' ' @@ -313,7 +313,6 @@ Resource_type_id resource_number(const struct resource_type *presource); struct resource_type *resource_by_number(const Resource_type_id id); -struct resource_type *resource_by_identifier(const char identifier); struct resource_type *resource_by_rule_name(const char *name); const char *resource_rule_name(const struct resource_type *presource); Modified: trunk/data/alien/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/terrain.ruleset?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/data/alien/terrain.ruleset (original) +++ trunk/data/alien/terrain.ruleset Mon May 2 18:43:33 2016 @@ -540,6 +540,8 @@ city can never be located on Boiling Ocean.\ ") +; /* <-- avoid gettext warnings +; ; The individual resource types, one per section. ; Roughly sorted by identifier. ; The actual tag used (the * in [resource_*]) must be unique for each resource, @@ -548,12 +550,14 @@ ; Notes: ; ; extra = name of the extra this resource section is part of -; identifier = single-character identifier used in savegames. This +; identifier = single-character identifier used in old savegames. This ; must be unique for each resource, and changing it will -; break savegame compatibility. +; break loading those old savegames. ; food = increased food production ; shield = increased shield production ; trade = increased trade production +; +; */ <-- avoid gettext warnings [resource_resources] extra = "Resources" Modified: trunk/data/civ1/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/terrain.ruleset?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/data/civ1/terrain.ruleset (original) +++ trunk/data/civ1/terrain.ruleset Mon May 2 18:43:33 2016 @@ -655,6 +655,8 @@ else.\ ") +; /* <-- avoid gettext warnings +; ; The individual resource types, one per section. ; Roughly sorted by identifier. ; The actual tag used (the * in [resource_*]) must be unique for each resource, @@ -663,12 +665,14 @@ ; Notes: ; ; extra = name of the extra this resource section is part of -; identifier = single-character identifier used in savegames. This +; identifier = single-character identifier used in old savegames. This ; must be unique for each resource, and changing it will -; break savegame compatibility. +; break loading those old savegames. ; food = increased food production ; shield = increased shield production ; trade = increased trade production +; +; */ <-- avoid gettext warnings [resource_gold] extra = "Gold" Modified: trunk/data/civ2/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/terrain.ruleset?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/data/civ2/terrain.ruleset (original) +++ trunk/data/civ2/terrain.ruleset Mon May 2 18:43:33 2016 @@ -650,6 +650,8 @@ else.\ ") +; /* <-- avoid gettext warnings +; ; The individual resource types, one per section. ; Roughly sorted by identifier. ; The actual tag used (the * in [resource_*]) must be unique for each resource, @@ -658,12 +660,14 @@ ; Notes: ; ; extra = name of the extra this resource section is part of -; identifier = single-character identifier used in savegames. This +; identifier = single-character identifier used in old savegames. This ; must be unique for each resource, and changing it will -; break savegame compatibility. +; break loading those old savegames. ; food = increased food production ; shield = increased shield production ; trade = increased trade production +; +; */ <-- avoid gettext warnings [resource_gold] extra = "Gold" Modified: trunk/data/civ2civ3/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/terrain.ruleset?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/data/civ2civ3/terrain.ruleset (original) +++ trunk/data/civ2civ3/terrain.ruleset Mon May 2 18:43:33 2016 @@ -840,6 +840,8 @@ else.\ ") +; /* <-- avoid gettext warnings +; ; The individual resource types, one per section. ; Roughly sorted by identifier. ; The actual tag used (the * in [resource_*]) must be unique for each resource, @@ -848,12 +850,14 @@ ; Notes: ; ; extra = name of the extra this resource section is part of -; identifier = single-character identifier used in savegames. This +; identifier = single-character identifier used in old savegames. This ; must be unique for each resource, and changing it will -; break savegame compatibility. +; break loading those old savegames. ; food = increased food production ; shield = increased shield production ; trade = increased trade production +; +; */ <-- avoid gettext warnings [resource_gold] extra = "Gold" Modified: trunk/data/classic/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/terrain.ruleset?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/data/classic/terrain.ruleset (original) +++ trunk/data/classic/terrain.ruleset Mon May 2 18:43:33 2016 @@ -830,6 +830,8 @@ else.\ ") +; /* <-- avoid gettext warnings +; ; The individual resource types, one per section. ; Roughly sorted by identifier. ; The actual tag used (the * in [resource_*]) must be unique for each resource, @@ -838,12 +840,14 @@ ; Notes: ; ; extra = name of the extra this resource section is part of -; identifier = single-character identifier used in savegames. This +; identifier = single-character identifier used in old savegames. This ; must be unique for each resource, and changing it will -; break savegame compatibility. +; break loading those old savegames. ; food = increased food production ; shield = increased shield production ; trade = increased trade production +; +; */ <-- avoid gettext warnings [resource_gold] extra = "Gold" Modified: trunk/data/experimental/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/terrain.ruleset?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/data/experimental/terrain.ruleset (original) +++ trunk/data/experimental/terrain.ruleset Mon May 2 18:43:33 2016 @@ -806,6 +806,8 @@ else.\ ") +; /* <-- avoid gettext warnings +; ; The individual resource types, one per section. ; Roughly sorted by identifier. ; The actual tag used (the * in [resource_*]) must be unique for each resource, @@ -814,12 +816,14 @@ ; Notes: ; ; extra = name of the extra this resource section is part of -; identifier = single-character identifier used in savegames. This +; identifier = single-character identifier used in old savegames. This ; must be unique for each resource, and changing it will -; break savegame compatibility. +; break loading those old savegames. ; food = increased food production ; shield = increased shield production ; trade = increased trade production +; +; */ <-- avoid gettext warnings [resource_gold] extra = "Gold" Modified: trunk/data/multiplayer/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/terrain.ruleset?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/data/multiplayer/terrain.ruleset (original) +++ trunk/data/multiplayer/terrain.ruleset Mon May 2 18:43:33 2016 @@ -804,6 +804,8 @@ else.\ ") +; /* <-- avoid gettext warnings +; ; The individual resource types, one per section. ; Roughly sorted by identifier. ; The actual tag used (the * in [resource_*]) must be unique for each resource, @@ -812,12 +814,14 @@ ; Notes: ; ; extra = name of the extra this resource section is part of -; identifier = single-character identifier used in savegames. This +; identifier = single-character identifier used in old savegames. This ; must be unique for each resource, and changing it will -; break savegame compatibility. +; break loading those old savegames. ; food = increased food production ; shield = increased shield production ; trade = increased trade production +; +; */ <-- avoid gettext warnings [resource_gold] extra = "Gold" Modified: trunk/data/sandbox/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/sandbox/terrain.ruleset?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/data/sandbox/terrain.ruleset (original) +++ trunk/data/sandbox/terrain.ruleset Mon May 2 18:43:33 2016 @@ -841,6 +841,8 @@ else.\ ") +; /* <-- avoid gettext warnings +; ; The individual resource types, one per section. ; Roughly sorted by identifier. ; The actual tag used (the * in [resource_*]) must be unique for each resource, @@ -849,12 +851,14 @@ ; Notes: ; ; extra = name of the extra this resource section is part of -; identifier = single-character identifier used in savegames. This +; identifier = single-character identifier used in old savegames. This ; must be unique for each resource, and changing it will -; break savegame compatibility. +; break loading those old savegames. ; food = increased food production ; shield = increased shield production ; trade = increased trade production +; +; */ <-- avoid gettext warnings [resource_gold] extra = "Gold" Modified: trunk/data/stub/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/terrain.ruleset?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/data/stub/terrain.ruleset (original) +++ trunk/data/stub/terrain.ruleset Mon May 2 18:43:33 2016 @@ -274,6 +274,8 @@ This is only possible oceanic terrain.\ ") +; /* <-- avoid gettext warnings +; ; The individual resource types, one per section. ; Roughly sorted by identifier. ; The actual tag used (the * in [resource_*]) must be unique for each resource, @@ -282,12 +284,14 @@ ; Notes: ; ; extra = name of the extra this resource section is part of -; identifier = single-character identifier used in savegames. This +; identifier = single-character identifier used in old savegames. This ; must be unique for each resource, and changing it will -; break savegame compatibility. +; break loading those old savegames. ; food = increased food production ; shield = increased shield production ; trade = increased trade production +; +; */ <-- avoid gettext warnings [resource_generic] extra = "Generic Resource" Modified: trunk/server/ruleset.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/server/ruleset.c (original) +++ trunk/server/ruleset.c Mon May 2 18:43:33 2016 @@ -2931,23 +2931,23 @@ sz_strlcpy(identifier, secfile_lookup_str(file,"%s.identifier", rsection)); - presource->identifier = identifier[0]; - if (RESOURCE_NULL_IDENTIFIER == presource->identifier) { + presource->id_old_save = identifier[0]; + if (RESOURCE_NULL_IDENTIFIER == presource->id_old_save) { ruleset_error(LOG_ERROR, "\"%s\" [%s] identifier missing value.", filename, rsection); ok = FALSE; break; } - if (RESOURCE_NONE_IDENTIFIER == presource->identifier) { + if (RESOURCE_NONE_IDENTIFIER == presource->id_old_save) { ruleset_error(LOG_ERROR, "\"%s\" [%s] cannot use '%c' as an identifier;" " it is reserved.", - filename, rsection, presource->identifier); + filename, rsection, presource->id_old_save); ok = FALSE; break; } for (j = 0; j < i; j++) { - if (presource->identifier == resource_by_number(j)->identifier) { + if (presource->id_old_save == resource_by_number(j)->id_old_save) { ruleset_error(LOG_ERROR, "\"%s\" [%s] has the same identifier as [%s].", filename, Modified: trunk/server/savecompat.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.c?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/server/savecompat.c (original) +++ trunk/server/savecompat.c Mon May 2 18:43:33 2016 @@ -245,6 +245,20 @@ if (spe < extra_type_list_size(elist)) { return extra_type_list_get(elist, spe); } + + return NULL; +} + +/**************************************************************************** + Return the resource type matching the identifier, or NULL when none matches. +****************************************************************************/ +struct resource_type *resource_by_identifier(const char identifier) +{ + resource_type_iterate(presource) { + if (presource->id_old_save == identifier) { + return presource; + } + } resource_type_iterate_end; return NULL; } Modified: trunk/server/savecompat.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.h?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/server/savecompat.h (original) +++ trunk/server/savecompat.h Mon May 2 18:43:33 2016 @@ -167,6 +167,8 @@ const char *special_rule_name(enum tile_special_type type); struct extra_type *special_extra_get(int spe); +struct resource_type *resource_by_identifier(const char identifier); + enum ai_level ai_level_convert(int old_level); enum barbarian_type barb_type_convert(int old_type); Modified: trunk/server/savegame3.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/server/savegame3.c (original) +++ trunk/server/savegame3.c Mon May 2 18:43:33 2016 @@ -1165,7 +1165,7 @@ ****************************************************************************/ static char resource2char(const struct resource_type *presource) { - return presource ? presource->identifier : RESOURCE_NONE_IDENTIFIER; + return presource ? presource->id_old_save : RESOURCE_NONE_IDENTIFIER; } /**************************************************************************** Modified: trunk/tools/ruledit/rulesave.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/rulesave.c?rev=32543&r1=32542&r2=32543&view=diff ============================================================================== --- trunk/tools/ruledit/rulesave.c (original) +++ trunk/tools/ruledit/rulesave.c Mon May 2 18:43:33 2016 @@ -1999,7 +1999,7 @@ } } output_type_iterate_end; - identifier[0] = pres->identifier; + identifier[0] = pres->id_old_save; identifier[1] = '\0'; secfile_insert_str(sfile, identifier, "%s.identifier", path); } resource_type_iterate_end; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits