Permalink
Browse files

workaround for bug #21797

at a certain point in playcampaign.cpp after the level has ended, wesnoth was
grabbing .child("end_level_data"), and writing carry_over sides.
this would cause "mandatory child missing" errors in the test case described.

we fix the error by checking if the child was not present and if so adding it.
however, it may indicate a more fundamental bug involving reloaded games.
  • Loading branch information...
1 parent 8e9fcd1 commit 7708d06a93b6b97923cafa162286f0739faa4a16 @cbeck88 cbeck88 committed Mar 18, 2014
Showing with 16 additions and 4 deletions.
  1. +1 −0 changelog
  2. +15 −4 src/playcampaign.cpp
View
@@ -34,6 +34,7 @@ Version 1.13.0-dev:
This issue is the source of some difficulties with mp campaigns which occur
when the campaign is reloaded from a non-host side, or after a player rejoins
from observer status. Hopefully, reloading campaigns is easier after this.
+ * Fix bug #21797: "Mandatory WML child missing" when leaving a reloaded game.
Version 1.11.11:
* Add-ons server:
View
@@ -271,8 +271,14 @@ static LEVEL_RESULT playsingle_scenario(const config& game_config,
LEVEL_RESULT res = playcontroller.play_scenario(story, skip_replay);
end_level = playcontroller.get_end_level_data_const();
- config& cfg_end_level = state_of_game.carryover_sides.child("end_level_data");
- end_level.write(cfg_end_level);
+
+ if (state_of_game.carryover_sides.has_child("end_level_data")) {
+ config& cfg_end_level = state_of_game.carryover_sides.child("end_level_data");
+ end_level.write(cfg_end_level);
+ } else {
+ config& cfg_end_level = state_of_game.carryover_sides.add_child("end_level_data");
+ end_level.write(cfg_end_level);
+ }
if (res == DEFEAT) {
if (resources::persist != NULL)
@@ -319,8 +325,13 @@ static LEVEL_RESULT playmp_scenario(const config& game_config,
LEVEL_RESULT res = playcontroller.play_scenario(story, skip_replay);
end_level = playcontroller.get_end_level_data_const();
- config& cfg_end_level = state_of_game.carryover_sides.child("end_level_data");
- end_level.write(cfg_end_level);
+ if (state_of_game.carryover_sides.has_child("end_level_data")) {
+ config& cfg_end_level = state_of_game.carryover_sides.child("end_level_data");
+ end_level.write(cfg_end_level);
+ } else {
+ config& cfg_end_level = state_of_game.carryover_sides.add_child("end_level_data");
+ end_level.write(cfg_end_level);
+ }
//Check if the player started as mp client and changed to host
if (io_type == IO_CLIENT && playcontroller.is_host())

0 comments on commit 7708d06

Please sign in to comment.