[Freeciv-Dev] (PR#2787) Remove use of A_NONE
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[rfalke - Thu Jan 9 18:11:16 2003]:
>
> A_NONE is used to flag various different conditions:
> - no tech for research set
> - no tech goal set
> - researching a future tech
>
> The attached patch fixes this by replacing A_NONE with A_UNSET and
> A_FUTURE. This was listed as a FIXME in is_future_tech. In addition to
> the replacment the patch also adds some docu and adds a new function
> ai_wants_no_science. An autogame differs only in the expected way:
The savegame difference is a problem. Currently it means you can't
safely load any old savegames.
In fact, forwards-compatability with this is a problem too. Since
A_FUTURE and A_UNSET both depend on the value of A_LAST (which could
change in the future), we can't rely on them being the same in the savegame.
So the attached patch should fix the problem, but preserves the old
"hackish" way of special-casing.
jason
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.103
diff -u -r1.103 savegame.c
--- server/savegame.c 2003/01/05 23:24:52 1.103
+++ server/savegame.c 2003/01/14 04:54:14
@@ -598,6 +598,14 @@
plr->is_alive=secfile_lookup_bool(file, "player%d.is_alive", plrno);
plr->ai.control = secfile_lookup_bool(file, "player%d.ai.control", plrno);
plr->ai.tech_goal = secfile_lookup_int(file, "player%d.ai.tech_goal", plrno);
+ if (plr->ai.tech_goal == A_NONE
+ || !tech_exists(plr->ai.tech_goal)) {
+ /* The value of A_UNSET could change in the future, since it
+ * is not ruleset-dependent. And it used to be A_NONE, so we check for
+ * that as well. This is a hack since there's no way to distinguish
+ * from A_FUTURE (which shouldn't ever be here anyway). */
+ plr->ai.tech_goal = A_UNSET;
+ }
plr->ai.handicap = 0; /* set later */
plr->ai.fuzzy = 0; /* set later */
plr->ai.expand = 100; /* set later */
@@ -634,6 +642,14 @@
"player%d.researchpoints", plrno);
plr->research.researching=secfile_lookup_int(file,
"player%d.researching", plrno);
+ if (plr->research.researching == A_NONE
+ || !tech_exists(plr->research.researching)) {
+ /* The value of A_FUTURE could change in the future, since it
+ * is not ruleset-dependent. And it used to be A_NONE, so we check for
+ * that as well. This is a hack since there's no way to distinguish
+ * from A_UNSET (which shouldn't ever be here anyway). */
+ plr->research.researching = A_FUTURE;
+ }
p=secfile_lookup_str(file, "player%d.invs", plrno);
|
|