bug fix: whiteboard initialized before gamestate init'ed

the whiteboard needs for resources::teams.size() to have the
correct value, which only occurs after teambuilder phase, in
gamestate init.

this commit is an easy way to fix but it is pretty ugly, it will
be refactored soon.
This commit is contained in:
Chris Beck 2014-12-23 04:50:05 -05:00
parent b79df59e08
commit fbcfa99c81
6 changed files with 25 additions and 11 deletions

View File

@ -2,8 +2,12 @@
tab="--tab"
cmd0="bash -c './wesnothd --port 12345 --log-debug=server --log-warning=config';bash"
cmd1="bash -c './wesnoth --plugin=host.lua --server=localhost:12345 --username=host --nogui --mp-test';bash"
cmd2="bash -c './wesnoth --plugin=join.lua --server=localhost:12345 --username=join --nogui --mp-test';bash"
cmd1="bash -c '"
cmd1+='gdb -q -batch -return-child-result -ex "run" -ex "thread apply all bt" -ex "quit" --args ./wesnoth --plugin=host.lua --server=localhost:12345 --username=host --nogui --mp-test'
cmd1+="';bash"
cmd2="bash -c '"
cmd2+='gdb -q -batch -return-child-result -ex "run" -ex "thread apply all bt" -ex "quit" --args ./wesnoth --plugin=join.lua --server=localhost:12345 --username=join --nogui --mp-test'
cmd2+="';bash"
#cmd3="bash -c './client3';bash"
foo=""

View File

@ -126,7 +126,7 @@ void game_state::place_sides_in_preferred_locations()
}
}
void game_state::init(const int ticks, play_controller & pc)
wb::manager * game_state::init(const int ticks, play_controller & pc)
{
if (level_["modify_placing"].to_bool()) {
LOG_NG << "modifying placing..." << std::endl;
@ -177,8 +177,12 @@ void game_state::init(const int ticks, play_controller & pc)
pathfind_manager_.reset(new pathfind::manager(level_));
wb::manager * whiteboard = new wb::manager();
lua_kernel_.reset(new game_lua_kernel(level_, NULL, *this, pc, *reports_));
events_manager_.reset(new game_events::manager(level_, game_events::t_context(lua_kernel_.get(), this, NULL, &gamedata_, &board_.units_, boost::bind(&wb::manager::on_gamestate_change, pc.get_whiteboard().get()), boost::bind(&play_controller::current_side, &pc))));
events_manager_.reset(new game_events::manager(level_, game_events::t_context(lua_kernel_.get(), this, NULL, &gamedata_, &board_.units_, boost::bind(&wb::manager::on_gamestate_change, whiteboard), boost::bind(&play_controller::current_side, &pc))));
return whiteboard;
}
void game_state::set_game_display(game_display * gd)

View File

@ -33,6 +33,8 @@ namespace game_events { class manager; }
namespace pathfind { class manager; }
namespace wb { class manager; }
class game_state : public filter_context
{
public:
@ -53,7 +55,7 @@ public:
void place_sides_in_preferred_locations();
void init(int ticks, play_controller & );
wb::manager * init(int ticks, play_controller & );
void set_game_display(game_display *);

View File

@ -194,14 +194,16 @@ void play_controller::init(CVideo& video){
loadscreen::start_stage("load level");
recorder.set_skip(false);
LOG_NG << "initializing whiteboard..." << (SDL_GetTicks() - ticks_) << std::endl;
whiteboard_manager_.reset(new wb::manager()),
resources::whiteboard = whiteboard_manager_;
{
LOG_NG << "initializing game_state..." << (SDL_GetTicks() - ticks_) << std::endl;
gamestate_.init(ticks_, *this);
wb::manager * whiteboard = gamestate_.init(ticks_, *this);
resources::tunnels = gamestate_.pathfind_manager_.get();
LOG_NG << "initializing whiteboard..." << (SDL_GetTicks() - ticks_) << std::endl;
whiteboard_manager_.reset(whiteboard),
resources::whiteboard = whiteboard_manager_;
}
// mouse_handler expects at least one team for linger mode to work.
if (gamestate_.board_.teams().empty()) end_level_data_.transient.linger_mode = false;

View File

@ -188,7 +188,8 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
return PROCESS_CONTINUE;
}
const team & tm = resources::gameboard->teams()[index];
assert(resources::gameboard);
const team & tm = resources::gameboard->teams().at(index);
const std::string &player = change["player"];
const bool was_local = tm.is_local();

View File

@ -635,6 +635,7 @@ void manager::process_network_data(config const& cfg)
void manager::queue_net_cmd(size_t team_index, side_actions::net_cmd const& cmd)
{
assert(team_index < net_buffer_.size());
net_buffer_[team_index].add_child("net_cmd",cmd);
}