diff -uNrX freeciv/diff_ignore freeciv/common/government.c freeciv-autogen/common/government.c --- freeciv/common/government.c Thu Mar 21 05:17:21 2002 +++ freeciv-autogen/common/government.c Thu May 16 19:02:01 2002 @@ -267,3 +267,17 @@ sz_strlcpy(title->male_title, male); sz_strlcpy(title->female_title, female); } + +/*************************************************************** + ... +***************************************************************/ +void free_governments() { + int i; + + for (i=0; i < game.government_count; i++) { + free(governments[i].ruler_titles); + free(governments[i].helptext); + } + free(governments); + governments = NULL; +} diff -uNrX freeciv/diff_ignore freeciv/common/government.h freeciv-autogen/common/government.h --- freeciv/common/government.h Tue Feb 19 16:41:23 2002 +++ freeciv-autogen/common/government.h Thu May 16 18:12:44 2002 @@ -186,5 +186,6 @@ void set_ruler_title(struct government *gov, int nation, char *male, char *female); +void free_governments(); #endif /* FC__GOVERNMENT_H */ diff -uNrX freeciv/diff_ignore freeciv/common/nation.c freeciv-autogen/common/nation.c --- freeciv/common/nation.c Tue Apr 30 14:50:52 2002 +++ freeciv-autogen/common/nation.c Thu May 16 18:29:24 2002 @@ -177,7 +177,7 @@ if(!nations) return; for( i = 0; i < num; i++) { for( j = 0; j < nations[i].leader_count; j++) { - free( nations[i].leader_name[j] ); + free(nations[i].leader_name[j]); } if (nations[i].city_names) { /* Unfortunately, this monstrosity of a loop is necessary given the diff -uNrX freeciv/diff_ignore freeciv/common/tech.c freeciv-autogen/common/tech.c --- freeciv/common/tech.c Tue Mar 5 19:13:45 2002 +++ freeciv-autogen/common/tech.c Thu May 16 18:39:02 2002 @@ -557,3 +557,20 @@ || game.rgame.tech_cost_style == 2) && game.rgame.tech_leakage == 0); } + +/************************************************************************** + ... +**************************************************************************/ +void free_techs() +{ + int tech; + + for (tech = A_FIRST; tech < game.num_tech_types; tech++) { + free(advances[tech].helptext); + advances[tech].helptext = NULL; + if (advances[tech].bonus_message != NULL) { + free(advances[tech].bonus_message); + advances[tech].bonus_message = NULL; + } + } +} diff -uNrX freeciv/diff_ignore freeciv/common/tech.h freeciv-autogen/common/tech.h --- freeciv/common/tech.h Thu Feb 14 15:17:20 2002 +++ freeciv-autogen/common/tech.h Thu May 16 18:31:56 2002 @@ -114,6 +114,7 @@ const char *get_tech_name(struct player *pplayer, Tech_Type_id tech); void precalc_tech_data(void); +void free_techs(); extern struct advance advances[]; diff -uNrX freeciv/diff_ignore freeciv/common/unit.c freeciv-autogen/common/unit.c --- freeciv/common/unit.c Fri Apr 5 05:25:38 2002 +++ freeciv-autogen/common/unit.c Thu May 16 18:43:53 2002 @@ -1395,9 +1395,9 @@ return TRUE; } -/* - * Returns true if given activity is some kind of building/cleaning. - */ +/************************************************************************** + Returns true if given activity is some kind of building/cleaning. +**************************************************************************/ bool is_build_or_clean_activity(enum unit_activity activity) { switch (activity) { diff -uNrX freeciv/diff_ignore freeciv/common/unittype.c freeciv-autogen/common/unittype.c --- freeciv/common/unittype.c Mon Mar 18 01:49:40 2002 +++ freeciv-autogen/common/unittype.c Thu May 16 18:31:13 2002 @@ -561,3 +561,14 @@ } return U_LAST; } + +/************************************************************************** + ... +**************************************************************************/ +void free_unittypes() +{ + unit_type_iterate(j) { + free(unit_types[j].helptext); + unit_types[j].helptext = NULL; + } unit_type_iterate_end; +} diff -uNrX freeciv/diff_ignore freeciv/common/unittype.h freeciv-autogen/common/unittype.h --- freeciv/common/unittype.h Thu Apr 18 09:59:17 2002 +++ freeciv-autogen/common/unittype.h Thu May 16 18:31:42 2002 @@ -234,6 +234,7 @@ int num_role_units(int role); Unit_Type_id get_role_unit(int role, int index); Unit_Type_id best_role_unit(struct city *pcity, int role); +void free_unittypes(); #define unit_type_iterate(m_i) \ { \ diff -uNrX freeciv/diff_ignore freeciv/server/ruleset.c freeciv-autogen/server/ruleset.c --- freeciv/server/ruleset.c Thu May 16 03:01:03 2002 +++ freeciv-autogen/server/ruleset.c Thu May 16 18:50:53 2002 @@ -2798,5 +2798,11 @@ **************************************************************************/ void free_rulesets() { - /* placeholder function for now */ + int i; + + free_governments(); + free_nations(game.nation_count); + free_techs(); + free_unittypes(); + free(city_styles); } diff -uNrX freeciv/diff_ignore freeciv/server/srv_main.c freeciv-autogen/server/srv_main.c --- freeciv/server/srv_main.c Thu Apr 25 19:54:18 2002 +++ freeciv-autogen/server/srv_main.c Thu May 16 19:07:34 2002 @@ -1778,7 +1778,7 @@ /* load a saved game */ - if(srvarg.load_filename) { + if (srvarg.load_filename) { struct timer *loadtimer, *uloadtimer; struct section_file file; @@ -1796,6 +1796,9 @@ freelog(LOG_VERBOSE, "Load time: %g seconds (%g apparent)", read_timer_seconds_free(loadtimer), read_timer_seconds_free(uloadtimer)); + } else { + /* rulesets are called inside game_load for savegames */ + load_rulesets(); } /* init network */ @@ -1822,11 +1825,6 @@ sniff_packets(); /* Accepting commands. */ (void) 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)); diff -uNrX freeciv/diff_ignore freeciv/server/stdinhand.c freeciv-autogen/server/stdinhand.c --- freeciv/server/stdinhand.c Thu May 16 16:45:52 2002 +++ freeciv-autogen/server/stdinhand.c Thu May 16 18:51:45 2002 @@ -2826,6 +2826,8 @@ cmd_reply(CMD_RULESETDIR, caller, C_OK, _("Ruleset directory set to \"%s\""), str); sz_strlcpy(game.rulesetdir, str); + free_rulesets(); + load_rulesets(); } /**************************************************************************