Skip to content

Commit

Permalink
add "synced_context_id"
Browse files Browse the repository at this point in the history
the plan is to allow non-current-players to send require_random.
  • Loading branch information
gfgtdf committed Nov 25, 2014
1 parent 99678ef commit b75b733
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/play_controller.cpp
Expand Up @@ -141,7 +141,8 @@ play_controller::play_controller(const config& level, saved_game& state_of_game,
end_level_data_(),
victory_music_(),
defeat_music_(),
scope_()
scope_(),
synced_context_number_(0)
{
resources::controller = this;
resources::gameboard = &gamestate_.board_;
Expand Down
4 changes: 4 additions & 0 deletions src/play_controller.hpp
Expand Up @@ -182,6 +182,8 @@ class play_controller : public controller_base, public events::observer, public
boost::shared_ptr<wb::manager> get_whiteboard();
const mp_game_settings& get_mp_settings();
const game_classification & get_classification();
int get_synced_context_number() const { return synced_context_number_; }
void increase_synced_context_number() { ++synced_context_number_; }

static const std::string wml_menu_hotkey_prefix;
protected:
Expand Down Expand Up @@ -302,6 +304,8 @@ class play_controller : public controller_base, public events::observer, public
std::vector<std::string> defeat_music_;

hotkey::scope_changer scope_;
// used to sync with the mpserver, not persistent in savefiles.
int synced_context_number_;

};

Expand Down
5 changes: 3 additions & 2 deletions src/synced_context.cpp
Expand Up @@ -307,7 +307,8 @@ config synced_context::ask_server(const std::string &name, const mp_sync::user_c
if(is_local_side && !did_require)
{
config data;
data.add_child("require_random");
config& rr = data.add_child("require_random");
rr["context_id"] = resources::controller->get_synced_context_number();
network::send_data(data,0);
did_require = true;
}
Expand Down Expand Up @@ -375,7 +376,7 @@ set_scontext_synced::set_scontext_synced(int number)
*/
void set_scontext_synced::init()
{

resources::controller->increase_synced_context_number();
LOG_REPLAY << "set_scontext_synced::set_scontext_synced\n";
assert(synced_context::get_synced_state() == synced_context::UNSYNCED);

Expand Down

0 comments on commit b75b733

Please sign in to comment.