Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] loading rulesets
Home

[Freeciv-Dev] loading rulesets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] loading rulesets
From: "Per I. Mathisen" <Per.Inge.Mathisen@xxxxxxxxxxx>
Date: Tue, 19 Feb 2002 00:29:39 +0100 (MET)

I am writing a patch to introduce pre-game alliances. That is, if pre-game
alliances are defined in nations.ruleset, all players are required to be
part of one of the available alliances before the game starts. Which
nations you can choose depends on your chosen alliance. I should probably
call it something other than alliances, since that is also what in-game
alliances are called, and players in a pre-game alliance are also in-game
allied; confusing but I couldn't find anything else to call it.

Anyway, the problem is that rulesets are only loaded immediately _after_
the game starts. So I don't have that information.

So what I would like to do is move the loading of ruleset information like
this:

--- freeciv/server/srv_main.c   Thu Feb 14 15:17:39 2002
+++ freeciv-phased/server/srv_main.c    Mon Feb 18 23:59:12 2002
@@ -1822,20 +1822,20 @@

   /* load a script file */
   if (srvarg.script_filename)
     read_init_script(NULL,srvarg.script_filename);

+  if(game.is_new_game) {
+    load_rulesets();
+    /* otherwise rulesets were loaded when savegame was loaded */
+  }
+
   freelog(LOG_NORMAL, _("Now accepting new client connections."));
   while(server_state==PRE_GAME_STATE)
     sniff_packets(); /* Accepting commands. */

   send_server_info_to_metaserver(TRUE, FALSE);
-
-  if(game.is_new_game) {
-    load_rulesets();
-    /* otherwise rulesets were loaded when savegame was loaded */
-  }

   nations_avail = fc_calloc(game.playable_nation_count, sizeof(int));
   nations_used = fc_calloc(game.playable_nation_count, sizeof(int));

Of course, this will create problems with setting rulesets from within the
server. My take on this is: Add another server option, "reload", which
reloads the rulesets. (Automatically reloading rulesets for each time a
ruleset setting is changed is not an option for obvious reasons.)

This will also be necessary for the edit-ruleset-stuff-from-clients patch.
For this reason I do not want a piece-meal solution which only loads
nations.ruleset, either. There may also be more features in the future
that can make use of ruleset info in the pre-game state, so I think this
generally is a right thing to do...

Useful ideas? Comments?

Yours,
Per

"What we anticipate seldom occurs: but what we least expect generally
happens." -- Benjamin Disraeli




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