Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2002:
[Freeciv-Dev] Re: How to make client code 22 lines shorter. (PR#1240)
Home

[Freeciv-Dev] Re: How to make client code 22 lines shorter. (PR#1240)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: How to make client code 22 lines shorter. (PR#1240)
From: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Date: Thu, 24 Jan 2002 12:19:51 +0000 (GMT)

 --- jdorje@xxxxxxxxxxxxxxxxxxxxx wrote: 
> Gregory Berkolaiko wrote:
> 
> > There is triplicated code in create_goto_map in client/goto.c
> > The lines 370-380, 404-414 and 429-439 are identical and can be
> > therefore put outside the switch statement.
> > 
> > Jason, you did exactly the same thing in gotohand.c once (only there
> > it was a bit more complicated), do you want to do it here too?
> 
> Seems simple enough...
> 
> It also seems possible to move the quick-check on the potential
> goodness of the route up above the switch statement.

well spotted!!

> The correctness of the patch should be fairly obvious:
> 
> - The code replaced is (AFAICT) entirely identical.
> - There are no extra or missing breaks within the switch statement.
> - All variables remain within scope.
> - Logically, it makes sense that the same algorithm is being used.

Does it compile?
I see absolutely no problem in the patch (cannot even find any nits to
satisfy Raimar ;) ) and naturally recommend its application asap.

> The trick, of course, would be to merge this with the server code 
> (moving it into common; they are, in theory, identical algorithms). 
> Unfortunately they use different backend structures (warmap versus 
> goto_map), so this is a larger task.

Only in theory though.  In reality server code doesn't care about enemies
at this stage, it leaves for find_the_shortest_path to weave between
them.
You can still separate it into a generic Dijkstra with cost-functions
supplied as arguments, something along the line of patch 1007, but it's a
lot of work and some significant overhead too.

In brief: take it as it comes.

Best,
G.

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


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