check is_replay on [set_global_variable] and [do_command]
adds a new method is_replay() to check whether we are in a replay. fixes http://gna.org/bugs/?21906 Also also we make [do_command]/run_in_synced_context_if_not_already more robust by checking is_replay
This commit is contained in:
parent
d71d39ec7a
commit
88de21a5ff
4 changed files with 13 additions and 3 deletions
|
@ -1139,7 +1139,7 @@ WML_HANDLER_FUNCTION(role, /*event_info*/, cfg)
|
|||
/// @todo Finish experimenting.
|
||||
WML_HANDLER_FUNCTION(set_global_variable,/**/,pcfg)
|
||||
{
|
||||
if (get_replay_source().at_end() || (network::nconnections() != 0))
|
||||
if (!resources::controller->is_replay())
|
||||
verify_and_set_global_variable(pcfg);
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ public:
|
|||
bool is_lingering() { return linger_; }
|
||||
|
||||
class hotkey_handler;
|
||||
|
||||
virtual bool is_replay() { return false; }
|
||||
protected:
|
||||
|
||||
game_display& get_display();
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef REPLAY_CONTROLLER_H_INCLUDED
|
||||
#define REPLAY_CONTROLLER_H_INCLUDED
|
||||
|
||||
#include "global.hpp"
|
||||
#include "game_end_exceptions.hpp"
|
||||
#include "saved_game.hpp"
|
||||
#include "play_controller.hpp"
|
||||
|
@ -54,7 +55,8 @@ public:
|
|||
bool recorder_at_end();
|
||||
|
||||
class hotkey_handler;
|
||||
|
||||
|
||||
virtual bool is_replay() OVERRIDE { return true; }
|
||||
protected:
|
||||
virtual void init_gui();
|
||||
|
||||
|
|
|
@ -103,10 +103,18 @@ bool synced_context::run_in_synced_context_if_not_already(const std::string& com
|
|||
switch(synced_context::get_synced_state())
|
||||
{
|
||||
case(synced_context::UNSYNCED):
|
||||
{
|
||||
if(resources::controller->is_replay())
|
||||
{
|
||||
ERR_REPLAY << "ignored attempt to invoke a synced command during replay\n";
|
||||
}
|
||||
return run_in_synced_context(commandname, data, use_undo, show, true, error_handler);
|
||||
}
|
||||
case(synced_context::LOCAL_CHOICE):
|
||||
ERR_REPLAY << "trying to execute action while being in a local_choice" << std::endl;
|
||||
//we reject it because such actions usually change the gamestate badly which is not intented during a local_choice.
|
||||
//Also we cannot invoke synced commands here, becasue multiple clients might run local choices
|
||||
//simultaniously so it could result in invoking different synced commands simultaniously.
|
||||
return false;
|
||||
case(synced_context::SYNCED):
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue