diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/common/game.c freeciv-phased/common/game.c --- freeciv/common/game.c Mon Mar 11 20:36:37 2002 +++ freeciv-phased/common/game.c Thu Mar 14 22:11:52 2002 @@ -708,14 +708,6 @@ game.watchtower_vision=GAME_DEFAULT_WATCHTOWER_VISION; game.watchtower_extra_vision=GAME_DEFAULT_WATCHTOWER_EXTRA_VISION, - sz_strlcpy(game.ruleset.techs, GAME_DEFAULT_RULESET); - sz_strlcpy(game.ruleset.units, GAME_DEFAULT_RULESET); - sz_strlcpy(game.ruleset.buildings, GAME_DEFAULT_RULESET); - sz_strlcpy(game.ruleset.terrain, GAME_DEFAULT_RULESET); - sz_strlcpy(game.ruleset.governments, GAME_DEFAULT_RULESET); - sz_strlcpy(game.ruleset.nations, GAME_DEFAULT_RULESET); - sz_strlcpy(game.ruleset.cities, GAME_DEFAULT_RULESET); - sz_strlcpy(game.ruleset.game, GAME_DEFAULT_RULESET); game.firepower_factor = 1; game.num_unit_types = 0; game.num_impr_types = 0; diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/common/game.h freeciv-phased/common/game.h --- freeciv/common/game.h Mon Mar 11 20:36:37 2002 +++ freeciv-phased/common/game.h Thu Mar 14 22:11:52 2002 @@ -148,16 +148,7 @@ int watchtower_extra_vision; int watchtower_vision; - struct { - char techs[MAX_LEN_NAME]; - char units[MAX_LEN_NAME]; - char buildings[MAX_LEN_NAME]; - char terrain[MAX_LEN_NAME]; - char governments[MAX_LEN_NAME]; - char nations[MAX_LEN_NAME]; - char cities[MAX_LEN_NAME]; - char game[MAX_LEN_NAME]; - } ruleset; + char rulesetdir[MAX_LEN_NAME]; int firepower_factor; /* See README.rulesets */ struct { int cathedral_plus; /* eg Theology */ @@ -420,8 +411,9 @@ #define GAME_MIN_OCCUPYCHANCE 0 #define GAME_MAX_OCCUPYCHANCE 100 +#define GAME_DEFAULT_RULESETDIR "default" + #define GAME_DEFAULT_SAVE_NAME "civgame" -#define GAME_DEFAULT_RULESET "default" #define GAME_DEFAULT_SKILL_LEVEL 3 /* easy */ #define GAME_OLD_DEFAULT_SKILL_LEVEL 5 /* normal; for old save games */ diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/common/government.c freeciv-phased/common/government.c --- freeciv/common/government.c Tue Feb 26 17:13:35 2002 +++ freeciv-phased/common/government.c Thu Mar 14 22:11:52 2002 @@ -53,7 +53,7 @@ * basics). */ -struct government *governments; +struct government *governments = NULL; struct ai_gov_tech_hint ai_gov_tech_hints[MAX_NUM_TECH_LIST]; diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/common/shared.c freeciv-phased/common/shared.c --- freeciv/common/shared.c Thu Mar 7 13:17:30 2002 +++ freeciv-phased/common/shared.c Thu Mar 14 22:11:52 2002 @@ -735,11 +735,8 @@ } } - freelog(LOG_ERROR, _("Could not find readable file \"%s\" in data path."), + freelog(LOG_VERBOSE, _("Could not find readable file \"%s\" in data path."), filename); - freelog(LOG_ERROR, _("The data path may be set via" - " the environment variable FREECIV_PATH.")); - freelog(LOG_ERROR, _("Current data path is: \"%s\""), datafilename(NULL)); return NULL; } @@ -758,6 +755,9 @@ if (dname) { return dname; } else { + freelog(LOG_ERROR, _("The data path may be set via" + " the environment variable FREECIV_PATH.")); + freelog(LOG_ERROR, _("Current data path is: \"%s\""), datafilename(NULL)); freelog(LOG_FATAL, _("The \"%s\" file is required ... aborting!"), filename); exit(EXIT_FAILURE); diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/data/Makefile.am freeciv-phased/data/Makefile.am --- freeciv/data/Makefile.am Tue Mar 12 13:42:38 2002 +++ freeciv-phased/data/Makefile.am Thu Mar 14 22:11:52 2002 @@ -14,4 +14,4 @@ EXTRA_DIST = $(pkgdata_DATA) -SUBDIRS = misc trident engels default classic civ1 civ2 scenario nation hires +SUBDIRS = misc trident engels default civ1 civ2 scenario nation hires diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/data/civ1.serv freeciv-phased/data/civ1.serv --- freeciv/data/civ1.serv Sun Jul 9 20:35:53 2000 +++ freeciv-phased/data/civ1.serv Thu Mar 14 23:59:04 2002 @@ -5,17 +5,10 @@ # Civ1 start: set settlers 1 set explorer 0 +rulesetdir civ1 # # Minor civ1 rules: set civstyle 1 -# -# Rulesets: -set terrain civ1 -set techs civ1 -set governments civ1 -set units civ1 -set buildings civ1 -set game civ1 # # Optional: #set nations civ1 diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/data/civ2.serv freeciv-phased/data/civ2.serv --- freeciv/data/civ2.serv Sun Jul 9 20:35:53 2000 +++ freeciv-phased/data/civ2.serv Thu Mar 14 23:59:12 2002 @@ -5,14 +5,7 @@ # Civ2 start: set settlers 2 set explorer 0 +rulesetdir civ2 # # Minor civ2 rules: set civstyle 2 -# -# Rulesets: -set terrain civ2 -set techs civ2 -set governments civ2 -set units civ2 -set buildings civ2 -set game civ2 diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/server/civserver.c freeciv-phased/server/civserver.c --- freeciv/server/civserver.c Thu Mar 7 13:17:35 2002 +++ freeciv-phased/server/civserver.c Thu Mar 14 22:11:52 2002 @@ -55,6 +55,7 @@ /* initialize server */ srv_init(); + sz_strlcpy(game.rulesetdir, GAME_DEFAULT_RULESETDIR); /* disallow running as root -- too dangerous */ dont_run_as_root(argv[0], "freeciv_server"); diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/server/ruleset.c freeciv-phased/server/ruleset.c --- freeciv/server/ruleset.c Thu Mar 7 13:17:35 2002 +++ freeciv-phased/server/ruleset.c Thu Mar 14 22:21:48 2002 @@ -44,7 +44,7 @@ #define name_strlcpy(dst, src) ((void) sz_loud_strlcpy(dst, src, name_too_long)) static void openload_ruleset_file(struct section_file *file, - char *subdir, char *whichset); + char *whichset); static char *check_ruleset_capabilities(struct section_file *file, char *us_capstr, const char *filename); @@ -84,7 +84,7 @@ static void load_ruleset_cities(struct section_file *file); static void load_ruleset_nations(struct section_file *file); -static void load_ruleset_game(char *ruleset_subdir); +static void load_ruleset_game(); static void send_ruleset_techs(struct conn_list *dest); static void send_ruleset_units(struct conn_list *dest); @@ -101,18 +101,24 @@ **************************************************************************/ char *valid_ruleset_filename(char *subdir, char *whichset) { - char filename1[512], filename2[512], *dfilename; + char filename1[512], *dfilename; + + assert(subdir && whichset); my_snprintf(filename1, sizeof(filename1), "%s/%s.ruleset", subdir, whichset); dfilename = datafilename(filename1); if (dfilename) return dfilename; - freelog(LOG_ERROR, _("Trying alternative ruleset filename syntax.")); - - my_snprintf(filename2, sizeof(filename2), "%s_%s.ruleset", subdir, whichset); - dfilename = datafilename(filename2); + freelog(LOG_VERBOSE, _("Trying to load file from default ruleset directory instead.")); + my_snprintf(filename1, sizeof(filename1), "default/%s.ruleset", whichset); + dfilename = datafilename(filename1); + if (dfilename) + return dfilename; + freelog(LOG_ERROR, _("Trying alternative ruleset filename syntax.")); + my_snprintf(filename1, sizeof(filename1), "%s_%s.ruleset", subdir, whichset); + dfilename = datafilename(filename1); if (dfilename) return dfilename; @@ -121,18 +127,13 @@ /************************************************************************** Do initial section_file_load on a ruleset file. - "subdir" = "default", "civ1", "custom", ... "whichset" = "techs", "units", "buildings", "terrain", ... Calls exit(EXIT_FAILURE) on failure. - This no longer returns the full filename opened; used secfile_filename() - if you want it. **************************************************************************/ - -static void openload_ruleset_file(struct section_file *file, - char *subdir, char *whichset) +static void openload_ruleset_file(struct section_file *file, char *whichset) { char sfilename[512]; - char *dfilename = valid_ruleset_filename(subdir, whichset); + char *dfilename = valid_ruleset_filename(game.rulesetdir, whichset); if (!dfilename) { freelog(LOG_FATAL, @@ -2174,16 +2175,16 @@ } /************************************************************************** -Load game.ruleset file +Load ruleset file **************************************************************************/ -static void load_ruleset_game(char *ruleset_subdir) +static void load_ruleset_game() { struct section_file file; char *datafile_options; char *sval; const char *filename; - openload_ruleset_file(&file, ruleset_subdir, "game"); + openload_ruleset_file(&file, "game"); filename = secfile_filename(&file); datafile_options = check_ruleset_capabilities(&file, "+1.11.1", filename); (void) section_file_lookup(&file, "datafile.description"); /* unused */ @@ -2628,28 +2629,38 @@ { struct section_file techfile, unitfile, buildfile, govfile, terrfile; struct section_file cityfile, nationfile; + char filename1[512], *dfilename; + + /* preserve sanity and report wrong directory */ + my_snprintf(filename1, sizeof(filename1), "%s/game.ruleset", game.rulesetdir); + dfilename = datafilename(filename1); + if (!dfilename) { + freelog(LOG_FATAL, _("The required file %s/game.ruleset not found"), + game.rulesetdir); + exit(EXIT_FAILURE); + } freelog(LOG_NORMAL, _("Loading rulesets")); - openload_ruleset_file(&techfile, game.ruleset.techs, "techs"); + openload_ruleset_file(&techfile, "techs"); load_tech_names(&techfile); - openload_ruleset_file(&buildfile, game.ruleset.buildings, "buildings"); + openload_ruleset_file(&buildfile, "buildings"); load_building_names(&buildfile); - openload_ruleset_file(&govfile, game.ruleset.governments, "governments"); + openload_ruleset_file(&govfile, "governments"); load_government_names(&govfile); - openload_ruleset_file(&unitfile, game.ruleset.units, "units"); + openload_ruleset_file(&unitfile, "units"); load_unit_names(&unitfile); - openload_ruleset_file(&terrfile, game.ruleset.terrain, "terrain"); + openload_ruleset_file(&terrfile, "terrain"); load_terrain_names(&terrfile); - openload_ruleset_file(&cityfile, game.ruleset.cities, "cities"); + openload_ruleset_file(&cityfile, "cities"); load_citystyle_names(&cityfile); - openload_ruleset_file(&nationfile, game.ruleset.nations, "nations"); + openload_ruleset_file(&nationfile, "nations"); load_nation_names(&nationfile); load_ruleset_techs(&techfile); @@ -2659,7 +2670,7 @@ load_ruleset_terrain(&terrfile); /* terrain must precede nations */ load_ruleset_buildings(&buildfile); load_ruleset_nations(&nationfile); - load_ruleset_game(game.ruleset.game); + load_ruleset_game(); translate_data_names(); } @@ -2681,4 +2692,13 @@ send_ruleset_cities(dest); conn_list_do_unbuffer(dest); +} + +/************************************************************************** + Deallocate and clean up. For use when freeciv quits, or in case we + later want to be able to reload rulesets. +**************************************************************************/ +void free_rulesets() +{ + /* placeholder function for now */ } diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/server/ruleset.h freeciv-phased/server/ruleset.h --- freeciv/server/ruleset.h Mon Aug 13 15:13:36 2001 +++ freeciv-phased/server/ruleset.h Thu Mar 14 22:11:52 2002 @@ -16,6 +16,7 @@ struct conn_list; void load_rulesets(void); +void free_rulesets(void); void send_rulesets(struct conn_list *dest); char *valid_ruleset_filename(char *subdir, char *whichset); diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/server/savegame.c freeciv-phased/server/savegame.c --- freeciv/server/savegame.c Mon Mar 11 20:36:40 2002 +++ freeciv-phased/server/savegame.c Thu Mar 14 23:45:48 2002 @@ -139,13 +139,12 @@ } \ } -/* Following does not include "unirandom", used previously; add it if - * appropriate. (Code no longer looks at "unirandom", but should still - * include it when appropriate for maximum savegame compatibility.) - */ -#define SAVEFILE_OPTIONS "1.7 startoptions spacerace2 rulesets" \ +/* The following should be removed when compatibility with + pre-1.13.0 savegames is broken: startoptions, spacerace2 + and rulesets */ +#define SAVEFILE_OPTIONS "startoptions spacerace2 rulesets" \ " diplchance_percent worklists2 map_editor known32fix turn " \ -"attributes watchtower" +"attributes watchtower rulesetdir" static const char hex_chars[] = "0123456789abcdef"; static const char terrain_chars[] = "adfghjm prstu"; @@ -255,24 +254,6 @@ } /*************************************************************** - Note -- as of v1.6.4 you should use savefile_options (instead of - game.version) to determine which variables you can expect to - find in a savegame file. Or even better (IMO --dwp) is to use - section_file_lookup(), secfile_lookup_int_default(), - secfile_lookup_str_default(), etc. -***************************************************************/ -static char *get_savefile_options(struct section_file *file) -{ - if ((game.version == 10604 && section_file_lookup(file,"savefile.options")) - || (game.version > 10604)) { - return secfile_lookup_str(file,"savefile.options"); - } else { - /* else leave savefile_options empty */ - return " "; - } -} - -/*************************************************************** load starting positions for the players from a savegame file Now we don't know how many start positions there are nor how many should be because rulesets are loaded later. So try to load as @@ -348,7 +329,7 @@ ***************************************************************/ static void map_load(struct section_file *file) { - char *savefile_options = get_savefile_options(file); + char *savefile_options = secfile_lookup_str(file,"savefile.options"); /* map_init(); * This is already called in game_init(), and calling it @@ -572,7 +553,7 @@ { int i, j, x, y, nunits, ncities; char *p; - char *savefile_options = get_savefile_options(file); + char *savefile_options = secfile_lookup_str(file,"savefile.options"); server_player_init(plr, TRUE); @@ -671,33 +652,7 @@ plrno, i); } - if (has_capability("spacerace", savefile_options)) { - struct player_spaceship *ship = &plr->spaceship; - char prefix[32]; - int arrival_year; - - my_snprintf(prefix, sizeof(prefix), "player%d.spaceship", plrno); - spaceship_init(ship); - arrival_year = secfile_lookup_int(file, "%s.arrival_year", prefix); - ship->structurals = secfile_lookup_int(file, "%s.structurals", prefix); - ship->components = secfile_lookup_int(file, "%s.components", prefix); - ship->modules = secfile_lookup_int(file, "%s.modules", prefix); - ship->state = secfile_lookup_int(file, "%s.state", prefix); - if (ship->state >= SSHIP_LAUNCHED) { - ship->launch_year = (arrival_year - 15); - } - /* auto-assign to individual parts: */ - ship->habitation = (ship->modules + 2)/3; - ship->life_support = (ship->modules + 1)/3; - ship->solar_panels = ship->modules/3; - ship->fuel = (ship->components + 1)/2; - ship->propulsion = ship->components/2; - for(i=0; istructurals; i++) { - ship->structure[i] = TRUE; - } - spaceship_calc_derived(ship); - } - else if(has_capability("spacerace2", savefile_options)) { + { /* spacerace */ struct player_spaceship *ship = &plr->spaceship; char prefix[32]; char *st; @@ -1726,8 +1681,13 @@ tmp_server_state = (enum server_states) secfile_lookup_int_default(file, RUN_GAME_STATE, "game.server_state"); - /* This one uses game.version! */ - savefile_options = get_savefile_options(file); + savefile_options = secfile_lookup_str(file,"savefile.options"); + + /* we require at least version 1.9.0 */ + if (10900 > game.version) { + freelog(LOG_FATAL, "Savegame too old, at least version 1.9.0 required."); + exit(EXIT_FAILURE); + } if (game.load_options.load_settings) { sz_strlcpy(srvarg.metaserver_info_line, @@ -1852,33 +1812,31 @@ game.randseed = secfile_lookup_int_default(file, game.randseed, "game.randseed"); - sz_strlcpy(game.ruleset.techs, - secfile_lookup_str_default(file, "default", "game.ruleset.techs")); - sz_strlcpy(game.ruleset.units, - secfile_lookup_str_default(file, "default", "game.ruleset.units")); - sz_strlcpy(game.ruleset.buildings, - secfile_lookup_str_default(file, "default", - "game.ruleset.buildings")); - sz_strlcpy(game.ruleset.terrain, - secfile_lookup_str_default(file, "classic", - "game.ruleset.terrain")); - sz_strlcpy(game.ruleset.governments, - secfile_lookup_str_default(file, "default", - "game.ruleset.governments")); - sz_strlcpy(game.ruleset.nations, - secfile_lookup_str_default(file, "default", - "game.ruleset.nations")); - sz_strlcpy(game.ruleset.cities, - secfile_lookup_str_default(file, "default", "game.ruleset.cities")); if(game.civstyle == 1) { string = "civ1"; } else { string = "default"; game.civstyle = GAME_DEFAULT_CIVSTYLE; } - sz_strlcpy(game.ruleset.game, + + if (!has_capability("rulesetdir", savefile_options)) { + /* touch to prevent warnings */ + section_file_lookup(file, "game.ruleset.techs"); + section_file_lookup(file, "game.ruleset.units"); + section_file_lookup(file, "game.ruleset.buildings"); + section_file_lookup(file, "game.ruleset.terrain"); + section_file_lookup(file, "game.ruleset.governments"); + section_file_lookup(file, "game.ruleset.nations"); + section_file_lookup(file, "game.ruleset.cities"); + + sz_strlcpy(game.rulesetdir, secfile_lookup_str_default(file, string, "game.ruleset.game")); + } else { + sz_strlcpy(game.rulesetdir, + secfile_lookup_str_default(file, string, + "game.rulesetdir")); + } sz_strlcpy(game.demography, secfile_lookup_str_default(file, GAME_DEFAULT_DEMOGRAPHY, @@ -1896,8 +1854,7 @@ load_rulesets(); } - if(tmp_server_state==PRE_GAME_STATE - || has_capability("startoptions", savefile_options)) { + { if (game.version >= 10300) { if (game.load_options.load_settings) { game.settlers = secfile_lookup_int(file, "game.settlers"); @@ -2115,9 +2072,6 @@ secfile_insert_str(file, meta_addr_port(), "game.metaserver"); sz_strlcpy(options, SAVEFILE_OPTIONS); - if (myrand_is_init()) { - sz_strlcat(options, " unirandom"); /* backward compat */ - } if (game.is_new_game) { if (map.num_start_positions>0) { sz_strlcat(options, " startpos"); @@ -2176,14 +2130,6 @@ secfile_insert_int(file, game.barbarianrate, "game.barbarians"); secfile_insert_int(file, game.onsetbarbarian, "game.onsetbarbs"); secfile_insert_int(file, game.occupychance, "game.occupychance"); - secfile_insert_str(file, game.ruleset.techs, "game.ruleset.techs"); - secfile_insert_str(file, game.ruleset.units, "game.ruleset.units"); - secfile_insert_str(file, game.ruleset.buildings, "game.ruleset.buildings"); - secfile_insert_str(file, game.ruleset.terrain, "game.ruleset.terrain"); - secfile_insert_str(file, game.ruleset.governments, "game.ruleset.governments"); - secfile_insert_str(file, game.ruleset.nations, "game.ruleset.nations"); - secfile_insert_str(file, game.ruleset.cities, "game.ruleset.cities"); - secfile_insert_str(file, game.ruleset.game, "game.ruleset.game"); secfile_insert_str(file, game.demography, "game.demography"); secfile_insert_int(file, game.watchtower_vision, "game.watchtower_vision"); secfile_insert_int(file, game.watchtower_extra_vision, "game.watchtower_extra_vision"); @@ -2235,6 +2181,8 @@ } else { secfile_insert_int(file, 0, "game.save_random"); } + + secfile_insert_str(file, game.rulesetdir, "game.rulesetdir"); if (!map_is_empty()) map_save(file); diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/server/srv_main.c freeciv-phased/server/srv_main.c --- freeciv/server/srv_main.c Thu Mar 14 18:58:06 2002 +++ freeciv-phased/server/srv_main.c Thu Mar 14 22:11:52 2002 @@ -1986,4 +1986,5 @@ } close_connections_and_socket(); + free_rulesets(); } diff -u3NrX /home/perrin/freeciv/diff_ignore freeciv/server/stdinhand.c freeciv-phased/server/stdinhand.c --- freeciv/server/stdinhand.c Mon Mar 11 20:36:40 2002 +++ freeciv-phased/server/stdinhand.c Thu Mar 14 22:54:16 2002 @@ -135,50 +135,13 @@ size_t sz_svalue; /* max size we can write into svalue */ }; -/******************************************************************** -Triggers used in settings_s. valid_ruleset() is clumsy because of -the fixed number of arguments and the reject_message - change? - rp -*********************************************************************/ - +/* + * Triggers used in settings_s. + */ static bool valid_notradesize(int value, char **reject_message); static bool valid_fulltradesize(int value, char **reject_message); static bool autotoggle(int value, char **reject_message); -static bool valid_ruleset(char *whichset, char *subdir, char **reject_message) -{ - static char buffer[MAX_LEN_CONSOLE_LINE]; - - assert(subdir != NULL); - - *reject_message = buffer; - - if (!valid_ruleset_filename(subdir,whichset)) { - my_snprintf(buffer, sizeof(buffer), - _("Invalid ruleset subdirectory, keeping old value.")); - return FALSE; - } - - buffer[0] = '\0'; - - return TRUE; -} - -static bool valid_techs_ruleset(char *v, char **r_m) - { return valid_ruleset("techs",v,r_m); } -static bool valid_governments_ruleset(char *v, char **r_m) - { return valid_ruleset("governments",v,r_m); } -static bool valid_units_ruleset(char *v, char **r_m) - { return valid_ruleset("units",v,r_m); } -static bool valid_buildings_ruleset(char *v, char **r_m) - { return valid_ruleset("buildings",v,r_m); } -static bool valid_terrain_ruleset(char *v, char **r_m) - { return valid_ruleset("terrain",v,r_m); } -static bool valid_nations_ruleset(char *v, char **r_m) - { return valid_ruleset("nations",v,r_m); } -static bool valid_cities_ruleset(char *v, char **r_m) - { return valid_ruleset("cities",v,r_m); } -static bool valid_game_ruleset(char *v, char **r_m) - { return valid_ruleset("game",v,r_m); } static bool valid_max_players(int v, char **r_m) { static char buffer[MAX_LEN_CONSOLE_LINE]; @@ -372,101 +335,6 @@ GAME_MIN_TECHLEVEL, GAME_MAX_TECHLEVEL, GAME_DEFAULT_TECHLEVEL, N_("Number of initial advances per player"), "", NULL, NULL, 0 }, -/* Various rules: these cannot be changed once the game has started. */ - { "techs", NULL, NULL, valid_techs_ruleset, - SSET_RULES, SSET_TO_CLIENT, - 0, 0, 0, - N_("Data subdir containing techs.ruleset"), - N_("This should specify a subdirectory of the data directory, " - "containing a file called \"techs.ruleset\". " - "The advances (technologies) present in the game will be " - "initialized from this file. " - "See also README.rulesets."), - game.ruleset.techs, GAME_DEFAULT_RULESET, - sizeof(game.ruleset.techs) }, - - { "governments", NULL, NULL, valid_governments_ruleset, - SSET_RULES, SSET_TO_CLIENT, - 0, 0, 0, - N_("Data subdir containing governments.ruleset"), - N_("This should specify a subdirectory of the data directory, " - "containing a file called \"governments.ruleset\". " - "The government types available in the game will be " - "initialized from this file. " - "See also README.rulesets."), - game.ruleset.governments, GAME_DEFAULT_RULESET, - sizeof(game.ruleset.governments) }, - - { "units", NULL, NULL, valid_units_ruleset, - SSET_RULES, SSET_TO_CLIENT, - 0, 0, 0, - N_("Data subdir containing units.ruleset"), - N_("This should specify a subdirectory of the data directory, " - "containing a file called \"units.ruleset\". " - "The unit types present in the game will be " - "initialized from this file. " - "See also README.rulesets."), - game.ruleset.units, GAME_DEFAULT_RULESET, - sizeof(game.ruleset.units) }, - - { "buildings", NULL, NULL, valid_buildings_ruleset, - SSET_RULES, SSET_TO_CLIENT, - 0, 0, 0, - N_("Data subdir containing buildings.ruleset"), - N_("This should specify a subdirectory of the data directory, " - "containing a file called \"buildings.ruleset\". " - "The building types (City Improvements and Wonders) " - "in the game will be initialized from this file. " - "See also README.rulesets."), - game.ruleset.buildings, GAME_DEFAULT_RULESET, - sizeof(game.ruleset.buildings) }, - - { "terrain", NULL, NULL, valid_terrain_ruleset, - SSET_RULES, SSET_TO_CLIENT, - 0, 0, 0, - N_("Data subdir containing terrain.ruleset"), - N_("This should specify a subdirectory of the data directory, " - "containing a file called \"terrain.ruleset\". " - "The terrain types present in the game will be " - "initialized from this file. " - "See also README.rulesets."), - game.ruleset.terrain, GAME_DEFAULT_RULESET, - sizeof(game.ruleset.terrain) }, - - { "nations", NULL, NULL, valid_nations_ruleset, - SSET_RULES, SSET_TO_CLIENT, - 0, 0, 0, - N_("Data subdir containing nations.ruleset"), - N_("This should specify a subdirectory of the data directory, " - "containing a file called \"nations.ruleset\". " - "The nations present in the game will be " - "initialized from this file. " - "See also README.rulesets."), - game.ruleset.nations, GAME_DEFAULT_RULESET, - sizeof(game.ruleset.nations) }, - - { "cities", NULL, NULL, valid_cities_ruleset, - SSET_RULES, SSET_TO_CLIENT, - 0, 0, 0, - N_("Data subdir containing cities.ruleset"), - N_("This should specify a subdirectory of the data directory, " - "containing a file called \"cities.ruleset\". " - "The file is used to initialize city data (such as city style). " - "See also README.rulesets."), - game.ruleset.cities, GAME_DEFAULT_RULESET, - sizeof(game.ruleset.cities) }, - - { "game", NULL, NULL, valid_game_ruleset, - SSET_RULES, SSET_TO_CLIENT, - 0, 0, 0, - N_("Data subdir containing game.ruleset"), - N_("This should specify a subdirectory of the data directory, " - "containing a file called \"game.ruleset\". " - "The file is used to initialize some miscellanous game rules. " - "See also README.rulesets."), - game.ruleset.game, GAME_DEFAULT_RULESET, - sizeof(game.ruleset.game) }, - { "researchcost", &game.researchcost, NULL, NULL, SSET_RULES, SSET_TO_CLIENT, GAME_MIN_RESEARCHCOST, GAME_MAX_RESEARCHCOST, GAME_DEFAULT_RESEARCHCOST, @@ -1000,6 +868,7 @@ /* mostly non-harmful: */ CMD_SET, + CMD_RULESETDIR, CMD_RENAME, CMD_METAINFO, CMD_METACONN, @@ -1121,6 +990,10 @@ N_("set "), N_("Set server options."), NULL }, + {"rulesetdir", ALLOW_CTRL, + N_("rulesetdir "), + N_("Choose new ruleset directory or modpack."), NULL + }, {"rename", ALLOW_CTRL, NULL, N_("This command is not currently implemented."), NULL @@ -2779,6 +2652,27 @@ } /************************************************************************** + ... +**************************************************************************/ +static void set_rulesetdir(struct connection *caller, char *str) +{ + char filename1[512], *dfilename; + if ((str == NULL) || (strlen(str)==0)) { + cmd_reply(CMD_RULESETDIR, caller, C_SYNTAX, + _("Undefined argument. Usage: rulesetdir .")); + return; + } + my_snprintf(filename1, sizeof(filename1), "%s/game.ruleset", str); + dfilename = datafilename(filename1); + if (!dfilename) { + cmd_reply(CMD_RULESETDIR, caller, C_SYNTAX, + _("Required ruleset game.ruleset not found in %s"), str); + return; + } + sz_strlcpy(game.rulesetdir, str); +} + +/************************************************************************** Cutting away a trailing comment by putting a '\0' on the '#'. The method handles # in single or double quotes. It also takes care of "\#". @@ -2944,6 +2838,9 @@ break; case CMD_SET: set_command(caller,arg); + break; + case CMD_RULESETDIR: + set_rulesetdir(caller, arg); break; case CMD_SCORE: if(server_state==RUN_GAME_STATE) {