[Freeciv-Dev] (PR#4181) recursion in tech requirements
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[glip - Wed May 7 11:31:00 2003]:
> On Tue, 6 May 2003, Per I. Mathisen wrote:
>
> >
> > On Tue, 6 May 2003, Guest wrote:
> > > I am customizing my tech file and Freeciv-cvs as of April broke.
It says
> > > that it starts but then hangs my linux machine. I do not see any error
> > > mesages. It severly slows down my system and still does not display a
> > > map. why is that?
> >
> > It is because of this:
> >
> > [advance_mobile_warfare10]
> > name = _("Mobile Warfare10")
> > req1 = "Mobile Warfare10"
> > req2 = "None"
> > flags = ""
> >
> > You have this tech as its own requirement. Hence the tech tree code
(which
> > is recursive) loops until it runs out of stack, I guess.
> >
> > The attached patch will detect this condition and print the following
> > error message:
> >
> > 0: tech "Mobile Warfare10": requires itself (data/new/techs.ruleset)
>
> Well detected but a bad fix. You can still have a loop of length more
> than 1, eg
>
> Fusion requires Fission
> and
> Fission requires Fusion
>
> The proper fix, IMO, is to put
> if (advances[tech].req[0] == goal || advances[tech].req[1] == goal) {
> die("%s is an indirect prerequisite for itself", advances[goal].name);
> }
> just before two recursive calls to
> build_required_tech_helper in the function
> build_required_tech_helper (common/tech.c:92)
Indeed. How about this patch?
Note we should use LOG_FATAL+exit rather than die(), since this isn't a
code error...
jason
tech_loops.diff
Description: tech_loops.diff
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#4181) recursion in tech requirements,
Jason Short <=
|
|