Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] (PR#5252) Wishlist: Defined civil war nations
Home

[Freeciv-Dev] (PR#5252) Wishlist: Defined civil war nations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: morgan.jones@xxxxxxxxxxxxxxx
Cc: remi.bonnet@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#5252) Wishlist: Defined civil war nations
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Sep 2003 10:32:11 -0700
Reply-to: rt@xxxxxxxxxxxxxx

[remi - Sat Sep  6 08:01:19 2003]:

> > Great!  If you like, I'll update all the nation files once the patch
> > is done.
> > 
> >      -Morgan
> > 
> 
> Good idea, i'm really bad in all real history.
> 
> Here's the patch. Tested in some situations but civilwar doesn't occur
> enough often to test it fully.

Any reviewer care to look at this patch?

There are some problems I notice:

- The pref_nations_avail calculation is O(n^2) in the number of players.
 The algorithm could easily be made O(n).

- The civilwar_nations field is actually a Nation_Type_Id*, not an int*.
 The only exception is the -1 marker.  NO_NATION_SELECTED should be used
instead of -1.

- I think the fc_realloc call in ruleset.c is unnecessary.  This is an
error case anyway, and there's no reason to think reallocating will save
memory (since it causes additional fragmentation).  It's just not worth
the code.

- I think a new helper function should be written:

  Nation_Type_Id pick_available_nation(Nation_Type_Id *choices);

which picks a random available nation from the given list of choices. 
This separates the logic for that from the civil war code.

Otherwise it looks pretty good - even simpler than I had expected.

jason



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