[Freeciv-Dev] (PR#12716) Ruleset loading problem
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#12716) Ruleset loading problem |
From: |
"Per I. Mathisen" <per@xxxxxxxxxxx> |
Date: |
Mon, 4 Apr 2005 16:03:21 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12716 >
When rulesets are loaded, some checks are made on existing players to
ensure that they are valid, and fix them if not. This assumes that all
players are created prior to loading rulesets, which is not true for 'set
aifill' created players, for some reason.
The attached patch fixes the problem by moving the affected code later in
the game boot process.
- Per
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.240
diff -u -r1.240 srv_main.c
--- server/srv_main.c 27 Mar 2005 09:17:16 -0000 1.240
+++ server/srv_main.c 4 Apr 2005 22:59:11 -0000
@@ -53,6 +53,7 @@
#include "fciconv.h"
#include "fcintl.h"
#include "game.h"
+#include "government.h"
#include "log.h"
#include "map.h"
#include "mem.h"
@@ -1704,6 +1705,28 @@
/**************************************************************************
Server loop, run to set up one game.
**************************************************************************/
+static void final_ruleset_adjustments()
+{
+ int i;
+
+ for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) {
+ if (game.players[i].government == G_MAGIC) {
+ game.players[i].government = game.default_government;
+ }
+ }
+
+ if (game.default_government == game.government_when_anarchy) {
+ players_iterate(pplayer) {
+ /* If we do not do this, an assert will trigger. This enables us to
+ * select a valid government on game start. */
+ pplayer->revolution_finishes = 0;
+ } players_iterate_end;
+ }
+}
+
+/**************************************************************************
+ Server loop, run to set up one game.
+**************************************************************************/
static void srv_loop(void)
{
int i;
@@ -1818,6 +1841,7 @@
if (game.is_new_game) {
generate_ai_players();
}
+ final_ruleset_adjustments();
/* If we have a tile map, and map.generator==0, call map_fractal_generate
* anyway to make the specials, huts and continent numbers. */
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.240
diff -u -r1.240 ruleset.c
--- server/ruleset.c 29 Mar 2005 12:28:26 -0000 1.240
+++ server/ruleset.c 4 Apr 2005 22:59:12 -0000
@@ -1654,7 +1654,7 @@
**************************************************************************/
static void load_ruleset_governments(struct section_file *file)
{
- int i, j, nval;
+ int j, nval;
char **sec, **slist;
const char *filename = secfile_filename(file);
@@ -1668,24 +1668,6 @@
game.government_when_anarchy
= lookup_government(file, "governments.when_anarchy", filename);
- if (game.default_government == game.government_when_anarchy) {
- players_iterate(pplayer) {
- /* If we do not do this, the game will crash. It enables us to
- * select a valid government on game start. */
- pplayer->revolution_finishes = 0;
- } players_iterate_end;
- }
-
- /* Because player_init is called before rulesets are loaded we set
- * all players governments here, if they have not been previously
- * set (eg by loading game).
- */
- for(i=0; i<MAX_NUM_PLAYERS+MAX_NUM_BARBARIANS; i++) {
- if (game.players[i].government == G_MAGIC) {
- game.players[i].government = game.default_government;
- }
- }
-
/* easy ones: */
government_iterate(g) {
int i = g->index, j;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12716) Ruleset loading problem,
Per I. Mathisen <=
|
|