Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2001:
[Freeciv-Dev] Re: Tech cost patch v6
Home

[Freeciv-Dev] Re: Tech cost patch v6

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Juha Litola <slave@xxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Tech cost patch v6
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 Nov 2001 14:11:34 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Nov 29, 2001 at 02:39:08PM +0200, Juha Litola wrote:
> On Thu, Nov 29, 2001 at 02:36:32PM +0200, Juha Litola wrote:
> > Added preset_cost and num_reqs, got rid of cost. Also changed 
> > tech_cost_rec to num_tech_reqs. You were right, it's much
> > cleaner this way.
> And patch.

From
+  int value = 1;
+  if (tech == A_NONE)
+    return 0;
+  if (advances[tech].num_reqs != 0)    /* Precalculated value */
+    return advances[tech].num_reqs;
+
+  value += num_req_techs(advances[tech].req[0]);
+  value += num_req_techs(advances[tech].req[1]);
+  advances[tech].num_reqs = value;
+  return value;

to

+  if (tech == A_NONE)
+    return 0;
+  if (advances[tech].num_reqs != 0)    /* Precalculated value */
+    return advances[tech].num_reqs;
+
+  advances[tech].num_reqs = 1 + num_req_techs(advances[tech].req[0]) + 
num_req_techs(advances[tech].req[1]);
+  return advances[tech].num_reqs

Problem: where is num_reqs set to 0 (initialized)?
Suggestion: at the correct places (one for the server and one for the client) 
do:
  for each tech:
     tech.num_reqs=0;
  for each tech:
     num_req_techs(tech)
and later doesn't use num_req_techs() anymore.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "At the beginning of the week, we sealed ten BSD programmers
  into a computer room with a single distribution of BSD Unix.
  Upon opening the room after seven days, we found all ten programmers 
  dead, clutching each other's throats, and thirteen new flavors of BSD."


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