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: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Cleaning up gotohand.c (PR#1068)
From: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Date: Tue, 4 Dec 2001 17:08:56 +0000 (GMT)

 --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> On Tue, Dec 04, 2001 at 04:00:05PM +0000, Gregory Berkolaiko wrote:
> > 
> > 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.

Hey, what do you mean by "separation"?

I thought you want to remove seacost field from warmap and do everything
on one map (well, I agree it's more unification than separation)...

> > 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.

I tried to do it once.  It dumps core

> 3) grep is your friend.

No I want runtime info.  You see warmap is generated once and then used
all over and then once again generated and many times used...  I want to
know which access corresponds to which generation.

> > 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?

generate_warmap tell you answer to the question
"where unit A can go from where it is now"?

if you want an answer to the question
"where unit A can go from city C which is over there"
you'd have to access _really_generate_warmap directly.

Example:
http://www.freeciv.org/lxr/source/server/settlers.c?v=cvs#L960

There punit wants to know where ferryboat can take him by sea from mycity
(ferryboat is somewhere far away).

Two lines below punit want to know where it can go by land:  another
place where land- and sea- warmaps must coexist.

G.
> 
> > 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 

________________________________________________________________
Nokia 5510 looks weird sounds great. 
Go to http://uk.promotions.yahoo.com/nokia/ discover and win it! 
The competition ends 16 th of December 2001.


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