Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: Tech cost patch v15 (PR#1082)
Home

[Freeciv-Dev] Re: Tech cost patch v15 (PR#1082)

[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 v15 (PR#1082)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Dec 2001 16:17:34 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sun, Dec 09, 2001 at 01:40:42PM +0200, Juha Litola wrote:
> On Sun, Dec 09, 2001 at 01:19:04PM +0200, Juha Litola wrote:
> > On Sat, Dec 08, 2001 at 07:12:51PM +0100, Reinier Post wrote:
> > 
> > > +  if(req[tech]++ || get_invention(pplayer, tech) == TECH_KNOWN)
> > > +    return 0;
> > Mark this technology as requirement in requirement array. If this
> > was marked as requirement before in recursive search, assign no
> > extra requirement. Also if technology is already known, it shouldn't
> > be added as requirement.
> This line indeed had a bug. Increment should happen later so it should
> read:
> +  if(req[tech] || get_invention(pplayer, tech) == TECH_KNOWN)
> +    return 0;
> +
> +  req[tech]++;
> 
> I misread the code in aitech.c find_prerequisites, this is how
> it does checking. This bug had no effect on gameplay, but this 
> is correct way.
> 
> v15 included.

Before I start to edit it by myself:

>    game.rgame.granary_food_inc = packet->granary_food_inc;
> +  if(has_capability("turn", aconnection.capability)) {
> +    game.rgame.tech_cost_style = packet->tech_cost_style;

This "turn" looks odd.

In find_unknown_req_techs:
> +
> +  req[tech]++;
> +

Is this equvialant to "req[tech]=1"?

find_unknown_req_techs and num_req_techs_rec perform the same
task. Can you unify them to:

> +static int foobar(Tech_Type_id tech, int *counted,struct player *pplayer) {
> +  if (tech == A_NONE)
> +    return 0;
> +
> +  if(counted[tech])
> +    return 0;
> +
     if(pplayer && get_invention(pplayer, tech) == TECH_KNOWN) return 0?

> +  counted[tech] = 1;
> +
> +  return 1 + num_req_techs_rec(advances[tech].req[0], counted)
> +    + num_req_techs_rec(advances[tech].req[1], counted);
> +}

?

> +  case 0:
...
> +  default:
> +    return goal_tech_cost_rec(pplayer, goal);

It is more robust to do
case 0:
...
case 1:
case 2:
  return goal_tech_cost_rec(pplayer, goal);
default:
  assert(0);
  exit(1);

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Despite all the medical advances of the 20th century, the mortality 
  rate remains unchanged at 1 death per person."


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