Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: Cleaning up gotohand.c (PR#1068)
Home

[Freeciv-Dev] Re: Cleaning up gotohand.c (PR#1068)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Cleaning up gotohand.c (PR#1068)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 4 Dec 2001 17:38:32 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Tue, Dec 04, 2001 at 04:00:05PM +0000, Gregory Berkolaiko wrote:
>  --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> > On Mon, Dec 03, 2001 at 04:54:08PM +0000, Gregory Berkolaiko wrote:
> > > So you propose:
> > > 1. Generate city land warmap, evaluate all land enemy units
> > > 2. Generate city sea warmap, evaluate all marine enemy units
> > > ?
> > 
> > Yes.
> > 
> > > This will take exactly the same amount of time.
> > 
> > Good.
> > 
> > > There will be problems like "what if this howitzer over there takes
> > > a boat?", but it is not fatal.
> > 
> > Does the current code handle this case right?
> 
> It tries.
> 
> > > But the amount of work needed to make such separation and the
> > > resultant patch would be huge.
> > 
> > But this is a real cleanup. Or how would you call it?
> 
> I would call it much ado about nothing, since it doesn't facilitate the
> use of warmap and doesn't speed anything up.  And it is MUCH work to
> trace calls to warmap throughout the code and understand which warmap
> they are actually refering to.

But the separation of parts which can be seperated _is_ a long term
for me. And the goto code is a good example for a separable part of
code. It is IMHO a misdesign that the references of warmap are
sprinkled all over the code.

> BTW, can it be done automatically, I mean whenever warmap.cost is used,
> print a log message with the file:line info?

1) A good interface with query functions/macros would avoid such
question in the first place.

2) gdb has AFAIK a feature to catch access of a memory region.

3) grep is your friend.

> There is one step on the road to tightening interface, that I think is
> worth taking.  There are 2 functions, really_generate_warmap and
> generate_warmap (which is a wrapper for really_generate_warmap, doing
> some initialisations).  Unfortunately, due to objective reasons (see
> below), really_generate_warmap is also called directly from the code,
> making it difficult to understand which initialisation should go where. 
> One should probably unify it.
> 
> The "exceptional" warmap are generated when AI wants to know 

> "where unit A will be able to go when it comes to city X?"

Can you rephrase this?

> that is it needs a warmap with initial coordinates in X but with
> move_type of A.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Only one human captain has ever survived battle with the Minbari
  fleet. He is behind me. You are in front of me. If you value your 
  lives, be somewhere else."
    -- Ambassador Delenn, "Severed Dreams," Babylon 5


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