Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] Small improvement at genlist and maphand
Home

[Freeciv-Dev] Re: [PATCH] Small improvement at genlist and maphand

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: Justin Moore <justin@xxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] Small improvement at genlist and maphand
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 22 Aug 2001 09:04:43 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Tue, Aug 21, 2001 at 07:56:29PM -0400, Ross W. Wetmore wrote:
> This may not be applicable to a lot of lists, but there will be subtle
> effects on game play and AI moves if for example it always processes
> its unit_list in a fixed order. Or always evaluates city actions in a
> NW to SE (i.e. 0,0 to map.xsize,map.ysize) direction.
> 
> It is actually better to have a stack or circular list for a lot of
> game objects where if one accesses them they get put back at the head
> or tail. If one needs to push/pop them for some reason, like filling 
> up a transport then having it be the next unit to move, one uses stack
> like operations, but if one is presumably done processing it, it goes 
> to the end. If one awakens a stack of caravnns to be sent to Wonderland
> in Tobruk, it is *very* irritating to not have moves stacked and have 
> the move selection bounce all around the map before it gets back to the
> next one (because the unit sort order was by home city or something).
> 
> This order has a play pattern, which may be appreciated by humans but it 
> is not a rigorous mechanical sort based on some obscure computer thingie
> and can be changed as units are awakened for out-of-list-order events.

Since a speclist insert() has no position argument it is unknown how
many callers really want the entry inserted at the head and how many
would be happy if the entry is just inserted somewhere. IMHO the
sorting should just be removed from the sortlist.

> I'd like to know exactly which lists are to be sorted and why before any 
> CVS code changes are made.

$ grep _sort */*.c */*/*.c|grep -v gtk_clist_sort|grep -v g_list_sort|grep -v 
gtk_clist_set
client/helpdata.c: for genlist_sort(); sort by topic via compare_strings()
client/helpdata.c:      genlist_sort(&category_nodes, help_item_compar);
common/genlist.c:void genlist_sort(struct genlist *pgenlist,
common/unit.c: Comparison function for genlist_sort, sorting by ord_map:
common/unit.c: Comparison function for genlist_sort, sorting by ord_city: see 
above.
common/unit.c:void unit_list_sort_ord_map(struct unit_list *This)
common/unit.c:    genlist_sort(&This->list, compar_unit_ord_map);
common/unit.c:void unit_list_sort_ord_city(struct unit_list *This)
common/unit.c:    genlist_sort(&This->list, compar_unit_ord_city);
server/savegame.c:      unit_list_sort_ord_city(&pcity->units_supported);
server/savegame.c:      unit_list_sort_ord_map(&map_get_tile(x,y)->units);
client/gui-mui/citydlg.c:static void city_list_sort(struct MinList *list)
client/gui-mui/citydlg.c:    city_list_sort(&list);

So no big deal here.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  (On the statement print "42 monkeys"+"1 snake"): BTW, both perl and Python
  get this wrong. Perl gives 43 and Python gives "42 monkeys1 snake", when 
  the answer is clearly "41 monkeys and 1 fat snake".  
    -- Jim Fulton, 10 Aug 1999


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