Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] Re: (PR#3930) increase MAX_NUM_NATIONS
Home

[Freeciv-Dev] Re: (PR#3930) increase MAX_NUM_NATIONS

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#3930) increase MAX_NUM_NATIONS
From: "Raimar Falke" <rf13@xxxxxxxxxxxxxxxxx>
Date: Sat, 5 Apr 2003 07:48:31 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Fri, Apr 04, 2003 at 03:09:22PM -0800, Jason Short wrote:
> Mike Kaufman wrote:
> > On Fri, Apr 04, 2003 at 12:27:10PM -0800, Jason Short wrote:
> > 
> >>The attached patch increases MAX_NUM_NATIONS to 90, which requires a new 
> >>manditory capability.  This is a portion of the original PR#3589 (which 
> >>was never updated with a capability).
> 
> >>Ideally, MAX_NUM_NATIONS should be removed so that the server and client 
> >>do not need to have identical values for it.  This would also mean less 
> >>wasted space in most cases.  Unfortunately it's not trivial to do this - 
> >>but any patches to help toward that goal would be welcome.
> 
> 
> > hell yes it should be removed. In fact, looking at the code, there seems to
> > be no reason whatsoever for MAX_NUM_NATIONS to exist at all. Any place
> > where should be used should use game.nation_count and dynamically allocate
> > the arrays. MAX_NUM_NATIONS seems to be left over from Raimar's 64k purge a
> > while back. My only qualm is the possibility of having to send a couple
> > thousand nations to the client :)
> 
> Yes, exactly.  The only problem is that it may take some work to get 
> there - the code is pretty spread out and embedded in various parts of 
> thee code, and it's not trivial (for me) to tell where the allocations 
> need to go.

It isn't _this_ hard. Lets see:

./client/packhand.c:2262:  if(p->id < 0 || p->id >= game.nation_count || p->id 
>= MAX_NUM_NATIONS) {
./server/ruleset.c:1831:  } else if (game.playable_nation_count >= 
MAX_NUM_NATIONS) {
./server/ruleset.c:1834:            MAX_NUM_NATIONS - 1, 
game.playable_nation_count);
./server/ruleset.c:1835:    game.playable_nation_count = MAX_NUM_NATIONS - 1;

Safeguards. Can be removed.

./client/gui-gtk-2.0/plrdlg.c:57:static GdkPixbuf *flags[MAX_NUM_NATIONS];

game.nation_count

./server/srv_main.c:1113:    if (pplayer->nation == MAX_NUM_NATIONS) {

Should be NO_NATION_SELECTED.

./common/map.h:182:  struct map_position start_positions[MAX_NUM_NATIONS];

This is only non-trival one. Alloc space for game.nplayers in
create_start_positions and also alloc space in map_startpos_load. Not
this hard.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Life is too short for reboots."




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