Author: pepeto Date: Thu Nov 13 21:17:52 2014 New Revision: 27040 URL: http://svn.gna.org/viewcvs/freeciv?rev=27040&view=rev Log: Save and load global advances in savegames. It might be the cause of disabled "survive" effects if the technology was lost before saving.
See gna bug #22909 Modified: branches/S2_5/server/savegame2.c Modified: branches/S2_5/server/savegame2.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/savegame2.c?rev=27040&r1=27039&r2=27040&view=diff ============================================================================== --- branches/S2_5/server/savegame2.c (original) +++ branches/S2_5/server/savegame2.c Thu Nov 13 21:17:52 2014 @@ -1970,6 +1970,7 @@ { int game_version; const char *string; + int i; /* Check status and return if not OK (sg_success != TRUE). */ sg_check_ret(); @@ -2081,6 +2082,29 @@ game.info.coolinglevel = secfile_lookup_int_default(loading->file, 0, "game.coolinglevel"); + /* Global advances. */ + string = secfile_lookup_str_default(loading->file, NULL, + "game.global_advances"); + if (string != NULL) { + sg_failure_ret(strlen(string) == loading->technology.size, + "Invalid length of 'game.global_advances' (%lu ~= %lu).", + (unsigned long) strlen(string), + (unsigned long) loading->technology.size); + for (i = 0; i < loading->technology.size; i++) { + sg_failure_ret(string[i] == '1' || string[i] == '0', + "Undefined value '%c' within 'game.global_advances'.", + string[i]); + if (string[i] == '1') { + struct advance *padvance = + advance_by_rule_name(loading->technology.order[i]); + + if (padvance != NULL) { + game.info.global_advances[advance_number(padvance)] = TRUE; + } + } + } + } + game.info.is_new_game = !secfile_lookup_bool_default(loading->file, TRUE, "game.save_players"); } @@ -2093,6 +2117,8 @@ int game_version; const char *user_message; enum server_states srv_state; + char global_advances[game.control.num_tech_types + 1]; + int i; /* Check status and return if not OK (sg_success != TRUE). */ sg_check_ret(); @@ -2164,6 +2190,13 @@ "game.cooling"); secfile_insert_int(saving->file, game.info.coolinglevel, "game.coolinglevel"); + + /* Global advances. */ + for (i = 0; i < game.control.num_tech_types; i++) { + global_advances[i] = game.info.global_advances[i] ? '1' : '0'; + } + global_advances[i] = '\0'; + secfile_insert_str(saving->file, global_advances, "game.global_advances"); if (!game_was_started()) { saving->save_players = FALSE; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits