Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#14182) Unusual nations in scenarious
Home

[Freeciv-Dev] (PR#14182) Unusual nations in scenarious

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#14182) Unusual nations in scenarious
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Tue, 11 Oct 2005 01:38:11 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14182 >

Changes:
1)
is_available boolean is read from the nation file(as Jason suggested)

2)
Unavailable nations can be created by civil war (in some scenarios civil
war was completely impossible by now).
--
mateusz
Index: common/nation.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/nation.h,v
retrieving revision 1.58
diff -u -r1.58 nation.h
--- common/nation.h     3 Oct 2005 02:50:44 -0000       1.58
+++ common/nation.h     11 Oct 2005 08:35:40 -0000
@@ -104,7 +104,7 @@
   int num_conflicts;
   struct nation_type **conflicts_with;
 
-  /* Unavailable nations aren't allowed in the scenario. */
+  /* Unavailable nations aren't allowed to be chosen in the scenario. */
   bool is_available;
 
   struct player *player; /* Who's using the nation, or NULL. */
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.426
diff -u -r1.426 plrhand.c
--- server/plrhand.c    3 Oct 2005 02:50:47 -0000       1.426
+++ server/plrhand.c    11 Oct 2005 08:35:41 -0000
@@ -1339,9 +1339,11 @@
   file were found, return a random nation. If no nations are available, die.
 
   choices may be NULL; if so it's ignored.
+  If only_available is set choose only nations that have is_available bit set.
 ****************************************************************************/
-struct nation_type *pick_available_nation(struct nation_type **choices,
-                                          bool ignore_conflicts)
+struct nation_type *pick_a_nation(struct nation_type **choices,
+                                  bool ignore_conflicts,
+                                 bool only_available)
 {
   enum {
     UNAVAILABLE, AVAILABLE, PREFERRED, UNWANTED
@@ -1358,7 +1360,7 @@
   nations_iterate(pnation) {
     if (!is_nation_playable(pnation)
        || pnation->player
-       || !pnation->is_available) {
+       || (only_available && !pnation->is_available)) {
       /* Nation is unplayable or already used: don't consider it. */
       nations_used[pnation->index] = UNAVAILABLE;
       match[pnation->index] = 0;
@@ -1459,7 +1461,7 @@
 
   /* select a new name and nation for the copied player. */
   /* Rebel will always be an AI player */
-  cplayer->nation = pick_available_nation(civilwar_nations, TRUE);
+  cplayer->nation = pick_a_nation(civilwar_nations, TRUE, FALSE);
   pick_random_player_name(cplayer->nation, cplayer->name);
 
   sz_strlcpy(cplayer->username, ANON_USER_NAME);
Index: server/plrhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.h,v
retrieving revision 1.88
diff -u -r1.88 plrhand.h
--- server/plrhand.h    3 Oct 2005 02:50:47 -0000       1.88
+++ server/plrhand.h    11 Oct 2005 08:35:41 -0000
@@ -36,8 +36,9 @@
 void kill_dying_players(void);
 void update_revolution(struct player *pplayer);
 
-struct nation_type *pick_available_nation(struct nation_type **choices,
-                                          bool ignore_conflicts);
+struct nation_type *pick_a_nation(struct nation_type **choices,
+                                  bool ignore_conflicts,
+                                 bool only_available);
 
 void check_player_government_rates(struct player *pplayer);
 void make_contact(struct player *pplayer1, struct player *pplayer2,
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.287
diff -u -r1.287 ruleset.c
--- server/ruleset.c    6 Oct 2005 16:11:26 -0000       1.287
+++ server/ruleset.c    11 Oct 2005 08:35:42 -0000
@@ -2134,6 +2134,9 @@
       }
     }
     free(leaders);
+    
+    pl->is_available = secfile_lookup_bool_default(file, TRUE,
+                                                   "%s.is_available", sec[i]);
 
     pl->is_playable = secfile_lookup_bool_default(file, TRUE,
                                                  "%s.is_playable", sec[i]);
@@ -2251,7 +2254,6 @@
       pl->legend[MAX_LEN_MSG - 1] = '\0';
     }
 
-    pl->is_available = TRUE;
     pl->player = NULL;
   }
 
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.295
diff -u -r1.295 srv_main.c
--- server/srv_main.c   3 Oct 2005 02:50:47 -0000       1.295
+++ server/srv_main.c   11 Oct 2005 08:35:42 -0000
@@ -1432,7 +1432,7 @@
       continue;
     }
 
-    player_set_nation(pplayer, pick_available_nation(NULL, FALSE));
+    player_set_nation(pplayer, pick_a_nation(NULL, FALSE, TRUE));
     assert(pplayer->nation != NO_NATION_SELECTED);
 
     pplayer->city_style = get_nation_city_style(pplayer->nation);

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