Author: sveinung Date: Fri Nov 20 14:38:46 2015 New Revision: 30704 URL: http://svn.gna.org/viewcvs/freeciv?rev=30704&view=rev Log: Store unseen action selection dialogs in saves
Make the unseen action selection dialog server state survive server restarts by storing it in save games. The new save game fields aren't mandatory. When missing it is assumed that the unit doesn't have an unseen action selection dialog. See patch #6609 Modified: branches/S2_6/server/savegame2.c Modified: branches/S2_6/server/savegame2.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame2.c?rev=30704&r1=30703&r2=30704&view=diff ============================================================================== --- branches/S2_6/server/savegame2.c (original) +++ branches/S2_6/server/savegame2.c Fri Nov 20 14:38:46 2015 @@ -5814,6 +5814,29 @@ punit->upkeep[o] = utype_upkeep_cost(unit_type_get(punit), plr, o); } output_type_iterate_end; + punit->action_decision_want + = secfile_lookup_enum_default(loading->file, + ACT_DEC_NOTHING, action_decision, + "%s.action_decision_want", unitstr); + + if (punit->action_decision_want != ACT_DEC_NOTHING) { + /* Load the tile to act against. */ + int adwt_x, adwt_y; + + if (secfile_lookup_int(loading->file, &adwt_x, + "%s.action_decision_tile_x", unitstr) + && secfile_lookup_int(loading->file, &adwt_y, + "%s.action_decision_tile_y", unitstr)) { + punit->action_decision_tile = native_pos_to_tile(adwt_x, adwt_y); + } else { + punit->action_decision_want = ACT_DEC_NOTHING; + punit->action_decision_tile = NULL; + log_sg("Bad action_decision_tile for unit %d", punit->id); + } + } else { + punit->action_decision_tile = NULL; + } + /* load the unit orders */ { int len = secfile_lookup_int_default(loading->file, 0, @@ -6096,6 +6119,26 @@ secfile_insert_int(saving->file, unit_transport_get(punit) ? unit_transport_get(punit)->id : -1, "%s.transported_by", buf); + + secfile_insert_enum(saving->file, punit->action_decision_want, + action_decision, "%s.action_decision_want", buf); + + /* Stored as tile rather than direction to make sure the target tile is + * sane. */ + if (punit->action_decision_tile) { + index_to_native_pos(&nat_x, &nat_y, + tile_index(punit->action_decision_tile)); + secfile_insert_int(saving->file, nat_x, + "%s.action_decision_tile_x", buf); + secfile_insert_int(saving->file, nat_y, + "%s.action_decision_tile_y", buf); + } else { + /* Dummy values to get tabular format. */ + secfile_insert_int(saving->file, -1, + "%s.action_decision_tile_x", buf); + secfile_insert_int(saving->file, -1, + "%s.action_decision_tile_y", buf); + } if (punit->has_orders) { int len = punit->orders.length, j; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits