Author: suokko
Date: Mon Jun 30 12:42:58 2008
New Revision: 27609

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27609&view=rev
Log:
* Fixed manager to initialize before gamestate in playcontroller (bug: 11935)

Modified:
    trunk/changelog
    trunk/src/game_events.cpp
    trunk/src/play_controller.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=27609&r1=27608&r2=27609&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Mon Jun 30 12:42:58 2008
@@ -25,6 +25,7 @@
  * miscellaneous and bug fixes:
    * Fixed droiding not to make wesnoth think player is observer (bug: #9675)
    * Fixed statitics not add turn data from previus scenarios (bug: #11719)
+   * Fixed manager to initialize before gamestate in playcontroller (bug: 
11935)
    * Removed persistance from team configuration (bug: #10916)
    * Made automaticaly generated macro reference easier to naviagate and link 
to
         (patch: #1076)

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=27609&r1=27608&r2=27609&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Mon Jun 30 12:42:58 2008
@@ -66,6 +66,7 @@
 
 namespace {
 
+       bool manager_running = false;
        game_display* screen = NULL;
        soundsource::manager* soundsources = NULL;
        gamemap* game_map = NULL;
@@ -3293,6 +3294,7 @@
                                game_state& state_of_game_, gamestatus& status) 
:
                        variable_manager(&state_of_game_)
                {
+                       assert(!manager_running);
                        const config::child_list& events_list = 
cfg.get_children("event");
                        for(config::child_list::const_iterator i = 
events_list.begin();
                                        i != events_list.end(); ++i) {
@@ -3306,6 +3308,7 @@
                        }
                        std::vector<std::string> unit_ids = 
utils::split(cfg["unit_wml_ids"]);
                        for(std::vector<std::string>::const_iterator id_it = 
unit_ids.begin(); id_it != unit_ids.end(); ++id_it) {
+                               std::cerr << *id_it << "\n";
                                unit_wml_ids.insert(*id_it);
                        }
 
@@ -3316,6 +3319,7 @@
                        units = &units_;
                        state_of_game = &state_of_game_;
                        status_ptr = &status;
+                       manager_running = true;
 
                        used_items.clear();
 
@@ -3348,6 +3352,7 @@
 
                void write_events(config& cfg)
                {
+                       assert(manager_running);
                        
for(std::multimap<std::string,game_events::event_handler>::const_iterator i = 
events_map.begin(); i != events_map.end(); ++i) {
                                if(!i->second.disabled() && 
!i->second.is_menu_item()) {
                                        i->second.write(cfg.add_child("event"));
@@ -3379,6 +3384,8 @@
                }
 
                manager::~manager() {
+                       assert(manager_running);
+                       manager_running = false;
                        events_queue.clear();
                        events_map.clear();
                        screen = NULL;
@@ -3398,6 +3405,7 @@
                                const entity_location& loc2,
                                const config& data)
                {
+                       assert(manager_running);
                        if(!events_init())
                                return;
 
@@ -3409,13 +3417,16 @@
                                const entity_location& loc2,
                                const config& data)
                {
+                       assert(manager_running);
                        raise(event,loc1,loc2,data);
                        return pump();
                }
 
                void add_events(const config::child_list& cfgs,const 
std::string& id)
                {
+                       assert(manager_running);
                        
if(std::find(unit_wml_ids.begin(),unit_wml_ids.end(),id) == unit_wml_ids.end()) 
{
+                               std::cerr << id << "\n";
                                unit_wml_ids.insert(id);
                                for(config::child_list::const_iterator new_ev = 
cfgs.begin(); new_ev != cfgs.end(); ++ new_ev) {
                                        unit_wml_configs.push_back(new 
config(**new_ev));
@@ -3432,6 +3443,7 @@
 
                bool pump()
                {
+                       assert(manager_running);
                        if(!events_init())
                                return false;
 

Modified: trunk/src/play_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=27609&r1=27608&r2=27609&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Mon Jun 30 12:42:58 2008
@@ -95,23 +95,7 @@
                place_sides_in_preferred_locations(map_,unit_cfg);
        }
 
-       loadscreen::global_loadscreen->set_progress(70, _("Initializing 
teams"));
-
-       LOG_NG << "initializing teams..." << unit_cfg.size() << "\n";;
-       LOG_NG << (SDL_GetTicks() - ticks_) << "\n";
-
-       std::set<std::string> seen_save_ids;
-
-       for(config::child_list::const_iterator ui = unit_cfg.begin(); ui != 
unit_cfg.end(); ++ui) {
-               std::string save_id = get_unique_saveid(**ui, seen_save_ids);
-               seen_save_ids.insert(save_id);
-               if (first_human_team_ == -1){
-                       first_human_team_ = get_first_human_team(ui, unit_cfg);
-               }
-               get_player_info(**ui, gamestate_, save_id, teams_, level_, 
map_, units_, status_, snapshot, is_replay );
-       }
-
-       loadscreen::global_loadscreen->set_progress(80, _("Initializing 
display"));
+       loadscreen::global_loadscreen->set_progress(70, _("Initializing 
display"));
 
        preferences::encounter_recruitable_units(teams_);
        preferences::encounter_start_units(units_);
@@ -126,12 +110,14 @@
                gui_ = new 
game_display(units_,video,map_,status_,teams_,*theme_cfg, game_config_, level_);
        else
                gui_ = new 
game_display(units_,video,map_,status_,teams_,config(), game_config_, level_);
-       loadscreen::global_loadscreen->set_progress(90, _("Initializing 
display"));
+       loadscreen::global_loadscreen->set_progress(80, _("Initializing 
display"));
        mouse_handler_.set_gui(gui_);
        menu_handler_.set_gui(gui_);
        theme::set_known_themes(&game_config_);
 
        LOG_NG << "done initializing display... " << (SDL_GetTicks() - ticks_) 
<< "\n";
+
+       loadscreen::global_loadscreen->set_progress(90, _("Initializing 
teams"));
 
        if(first_human_team_ != -1) {
                gui_->set_team(first_human_team_);
@@ -152,6 +138,22 @@
        }
 
        init_managers();
+       
+
+       LOG_NG << "initializing teams..." << unit_cfg.size() << "\n";;
+       LOG_NG << (SDL_GetTicks() - ticks_) << "\n";
+
+       std::set<std::string> seen_save_ids;
+
+       for(config::child_list::const_iterator ui = unit_cfg.begin(); ui != 
unit_cfg.end(); ++ui) {
+               std::string save_id = get_unique_saveid(**ui, seen_save_ids);
+               seen_save_ids.insert(save_id);
+               if (first_human_team_ == -1){
+                       first_human_team_ = get_first_human_team(ui, unit_cfg);
+               }
+               get_player_info(**ui, gamestate_, save_id, teams_, level_, 
map_, units_, status_, snapshot, is_replay );
+       }
+
        loadscreen::global_loadscreen->set_progress(100, _("Starting game"));
        loadscreen_manager->reset();
 }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to