Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: [Patch] turn_founded
Home

[Freeciv-Dev] Re: [Patch] turn_founded

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Patch] turn_founded
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 4 Mar 2002 17:25:14 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Mar 04, 2002 at 06:20:24AM -0500, Jason Short wrote:
> Raimar Falke wrote:
> >>-    pcity->did_buy=secfile_lookup_int(file,
> >>+    if (has_capability("turn_founded", savefile_options)) {
> >>+      pcity->turn_founded = secfile_lookup_int(file,
> >>+                                               "player%d.c%d.turn_founded",
> >>+                                               plrno, i);
> >>+      pcity->did_buy = secfile_lookup_int(file, "player%d.c%d.did_buy",
> >>+                                          plrno, i);
> >>+    } else {
> >>+      int did_buy = secfile_lookup_int(file,
> >>                                  "player%d.c%d.did_buy", plrno,i);
> >>+      if (did_buy >= 0) {
> >>
> > 
> >>+        pcity->turn_founded = game.turn - 1;
> >>
> > 
> > This may lead to a negative value.
> 
> Is that bad?  Didn't you use -2 as the default turn_founded?

I think it is bad if a value is normally >=0 and for some cities -1.

> But actually, I don't think it can give a negative value.  If a city is 
> founded on the first turn and then you save/reload on the first turn, 
> then did_buy would have been -1 anyway.

IMHO we should insert an assert:

+      if (did_buy >= 0) {
  assert(game.turn>0);
+        pcity->turn_founded = game.turn - 1;
+        pcity->did_buy = (did_buy != 0);
+      } else {

> Is there a secfile_insert_bool?  <checks>  I guess so.  Yes, that makes 
> it "prettier".  It should also be secfile_lookup_bool for did_buy up 
> above (only when we have the capability).

Yes.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "The BeOS takes the best features from the major operating systems. 
  It's got the power and flexibility of Unix, the interface and ease 
  of use of the MacOS, and Minesweeper from Windows."


[Prev in Thread] Current Thread [Next in Thread]