[Freeciv-Dev] Re: Tech cost patch v15 (PR#1082)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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."
- [Freeciv-Dev] Tech cost patch v13 (PR#1082), Juha Litola, 2001/12/01
- [Freeciv-Dev] Re: Tech cost patch v13 (PR#1082), Per I. Mathisen, 2001/12/01
- [Freeciv-Dev] Re: Tech cost patch v13 (PR#1082), Juha Litola, 2001/12/05
- [Freeciv-Dev] Tech cost patch v14 (PR#1082), Juha Litola, 2001/12/08
- [Freeciv-Dev] Re: Tech cost patch v14 (PR#1082), Reinier Post, 2001/12/08
- [Freeciv-Dev] Re: Tech cost patch v14 (PR#1082), Juha Litola, 2001/12/09
- [Freeciv-Dev] Tech cost patch v15 (PR#1082), Juha Litola, 2001/12/09
- [Freeciv-Dev] Re: Tech cost patch v15 (PR#1082),
Raimar Falke <=
- [Freeciv-Dev] Tech cost patch v16 (PR#1082), Juha Litola, 2001/12/13
- [Freeciv-Dev] Re: Tech cost patch v16 (PR#1082), Reinier Post, 2001/12/13
- [Freeciv-Dev] Re: Tech cost patch v16 (PR#1082), Juha Litola, 2001/12/13
- [Freeciv-Dev] Re: Tech cost patch v16 (PR#1082), Reinier Post, 2001/12/14
- [Freeciv-Dev] Re: Tech cost patch v16 (PR#1082), Raimar Falke, 2001/12/13
- [Freeciv-Dev] Re: Tech cost patch v16 (PR#1082), Raimar Falke, 2001/12/16
- [Freeciv-Dev] Re: Tech cost patch v16 (PR#1082), Juha Litola, 2001/12/16
- [Freeciv-Dev] Re: Tech cost patch v14 (PR#1082), Reinier Post, 2001/12/09
- [Freeciv-Dev] Re: Tech cost patch v14 (PR#1082), Juha Litola, 2001/12/09
|
|