[Freeciv-Dev] (PR#40758) Bug with SVN Trunk rev 15609- disappearing grasslands shield

2009-04-13 Thread guest

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.
-; 

[Freeciv-Dev] (PR#40758) Bug with SVN Trunk rev 15609- disappearing grasslands shield

2009-04-13 Thread Madeline Book

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

This ticket is now resolved; I have started a new ticket
to deal with the resource identifier cleanup (#40767).
Please continue the discussion there.


---
家の居間に入りましょう。

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40758) Bug with SVN Trunk rev 15609- disappearing grasslands shield

2009-04-11 Thread guest

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


Indeed, loading a civ1/2 game with the default ruleset is kind of weird.

Perhaps a dictionary (in terrain.ruleset) could look like this:

  [resourceids_dictionary]
  game_version = 2.2
  gold = $
  iron = /
  game = A
  ...

  [resourceids_dictionary]
  game_version = 2.1
  gold = H
  iron = /
  game = e
  ...

That would allow to load saved games from previous versions without
messing up the resources.
What do you think?

- Stéphane Messerli

--

 I am not sure if the whole update22 system should kept. It
 appears terribly hackish with the hard-coded version numbers
 and ruleset names (why should the default ruleset ever care
 about savegames in the civ1 or civ2 rulesets?). I am thinking
 that perhaps the resource identifiers should be changed back
 to remove the need for the update22* fields, or the entire
 identifier system replaced by something more robust (e.g. a
 dictionary mapping identifiers to resource names included in
 the ruleset definition).
 


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40758) Bug with SVN Trunk rev 15609- disappearing grasslands shield

2009-04-11 Thread guest

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


Indeed, loading a civ1/2 game with the default ruleset is kind of weird.

Perhaps a dictionary (in terrain.ruleset) could look like this:

  [resourceids_dictionary]
  game_version = 2.2
  gold = $
  iron = /
  game = A
  ...

  [resourceids_dictionary]
  game_version = 2.1
  gold = H
  iron = /
  game = e
  ...

That would allow to load saved games from previous versions without
messing up the resources.
What do you think?

- Stéphane Messerli

--

 I am not sure if the whole update22 system should kept. It
 appears terribly hackish with the hard-coded version numbers
 and ruleset names (why should the default ruleset ever care
 about savegames in the civ1 or civ2 rulesets?). I am thinking
 that perhaps the resource identifiers should be changed back
 to remove the need for the update22* fields, or the entire
 identifier system replaced by something more robust (e.g. a
 dictionary mapping identifiers to resource names included in
 the ruleset definition).
 


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40758) Bug with SVN Trunk rev 15609- disappearing grasslands shield

2009-04-11 Thread Madeline Book

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

 [guest - Sat Apr 11 15:20:17 2009]:
 
 
 Indeed, loading a civ1/2 game with the default ruleset is kind
 of weird.
 
 Perhaps a dictionary (in terrain.ruleset) could look like this:
 
   [resourceids_dictionary]
   game_version = 2.2
   gold = $
   iron = /
   game = A
   ...
 
   [resourceids_dictionary]
   game_version = 2.1
   gold = H
   iron = /
   game = e
   ...
 
 That would allow to load saved games from previous versions without
 messing up the resources.
 What do you think?

I think this would be an excellent way to keep the backwards-
conversion information distinct from the resources definitions.

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.


---
余計なもの出ていけ!

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40758) Bug with SVN Trunk rev 15609- disappearing grasslands shield

2009-04-10 Thread Christian Knoke
Madeline Book wrote on Apr 09, 20:50 (-0400):
 On 09/04/2009, Raahul Kumar raahul_da_...@yahoo.com wrote:
  Hi,
 
  I've experienced an extremely strange bug that I cannot track down the cause
  of. Any game that is started, find a grasslands shield resource. That shield
  resource will disappear if a savegame is loaded. I am not sure what this is
  a bug in. No other resources disappear, only grasslands shields. The square
  that previously claimed grassland(resource)2/1/0 will become just grassland
  2/0/0. The two grasslands squares near Tokyo are a good example, here today,
  gone tomorrow.

The diamonds in the jungle and the oil in the desert are also gone.

Christian

-- 
Christian Knoke* * *http://cknoke.de
* * * * * * * * *  Ceterum censeo Microsoft esse dividendum.

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40758) Bug with SVN Trunk rev 15609- disappearing grasslands shield

2009-04-10 Thread Madeline Book

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

I have confirmed the bug and after further testing I have
determined that all resources using the 'update22two' field
in the default terrain.ruleset file are affected.


 [guest - Fri Apr 10 20:27:31 2009]:
 
 The issue is caused by the server/savegame.c code
 considering the dev version 2.1.99 to be a 2.1 instead of
 a 2.2.

 Resource identifiers are then converted when loading a
 2.1.99 game, but they shouldn't be as they're already
 using 2.2 identifiers.

 I've attached a patch. I've quickly checked Tundra/Furs,
 and the resource now remains after loading a 2.1.99 game,
 while it disappeared without the patch.

 - Stéphane Messerli

Thank you for examining the problem and providing a patch.
I have tried your patch and it does appear to fix the issue,
so I will commit the changes soon.


I am not sure if the whole update22 system should kept. It
appears terribly hackish with the hard-coded version numbers
and ruleset names (why should the default ruleset ever care
about savegames in the civ1 or civ2 rulesets?). I am thinking
that perhaps the resource identifiers should be changed back
to remove the need for the update22* fields, or the entire
identifier system replaced by something more robust (e.g. a
dictionary mapping identifiers to resource names included in
the ruleset definition).


---
そんなものは本当に必要なのだろうか。

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40758) Bug with SVN Trunk rev 15609- disappearing grasslands shield

2009-04-10 Thread guest

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

Hi,

The issue is caused by the server/savegame.c code considering the dev
version 2.1.99 to be a 2.1 instead of a 2.2.

Resource identifiers are then converted when loading a 2.1.99 game, but
they shouldn't be as they're already using 2.2 identifiers.

I've attached a patch. I've quickly checked Tundra/Furs, and the
resource now remains after loading a 2.1.99 game, while it disappeared
without the patch.

- Stéphane Messerli

--

 [book - Jeu. Avr. 09 23:54:45 2009]:
 
 Hi,
 
 I've experienced an extremely strange bug that I cannot track down the 
 cause of. Any game that is started, find a grasslands shield resource. 
 That shield resource will disappear if a savegame is loaded. I am not 
 sure what this is a bug in. No other resources disappear, only 
 grasslands shields. The square that previously claimed grassland
 (resource)2/1/0 will become just grassland 2/0/0. The two grasslands 
 squares near Tokyo are a good example, here today, gone tomorrow.
 
 This only happens after reloading a game, if a game is just continually 
 played through, no grassland squares disappear. I suspect the problem 
 is in either saving or loading the game.
 I also cannot log in to RT with guest/viceerf, so I hope someone will 
 give me a RT login when they fix the website problems.
 
 
 Aloha,
 RK.
 



freeciv-2.1.99-patch-issue-40758.patch
Description: Binary data
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev