Author: silene
Date: Tue May 26 21:22:32 2009
New Revision: 35900
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35900&view=rev
Log:
Enabled preloading of Lua events in multiplayer.
Modified:
trunk/src/playcampaign.cpp
Modified: trunk/src/playcampaign.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playcampaign.cpp?rev=35900&r1=35899&r2=35900&view=diff
==============================================================================
--- trunk/src/playcampaign.cpp (original)
+++ trunk/src/playcampaign.cpp Tue May 26 21:22:32 2009
@@ -183,6 +183,18 @@
return res;
}
+/** Marks all the toplevel [lua] tag as preload events. */
+static void preload_lua_tags(const config &game_config, config &target)
+{
+ foreach (const config &cfg, game_config.child_range("lua"))
+ {
+ config &ev = target.add_child("event");
+ ev["name"] = "preload";
+ ev["first_time_only"] = "no";
+ ev.add_child("lua", cfg);
+ }
+}
+
LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config&
game_config,
upload_log &log, io_type_t io_type, bool skip_replay)
{
@@ -206,6 +218,7 @@
// Otherwise this is the start of a campaign scenario.
if(gamestate.starting_pos["id"].empty() == false) {
LOG_G << "loading starting position...\n";
+ preload_lua_tags(game_config, gamestate.starting_pos);
starting_pos = gamestate.starting_pos;
scenario = &starting_pos;
} else {
@@ -213,15 +226,9 @@
scenario = &game_config.find_child(type, "id",
gamestate.scenario);
if (*scenario) {
starting_pos = *scenario;
+ preload_lua_tags(game_config, starting_pos);
+ gamestate.starting_pos.merge_with(starting_pos);
scenario = &starting_pos;
- foreach (const config &cfg,
game_config.child_range("lua")) {
- // Mark all the toplevel [lua] tag as
preload events.
- config &ev =
starting_pos.add_child("event");
- ev["name"] = "preload";
- ev["first_time_only"] = "no";
- ev.add_child("lua", cfg);
- }
- gamestate.starting_pos.merge_with(*scenario);
} else
scenario = NULL;
LOG_G << "scenario found: " << (scenario != NULL ?
"yes" : "no") << "\n";
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits