more checks in [do_command]

also we fix run_in_synced_context_if_not_already it it supposed not to
execute the action if we are in a replay in an unsynced context.
This commit is contained in:
gfgtdf 2015-03-02 01:00:08 +01:00
parent d35e2a66a6
commit 9df349d646
2 changed files with 11 additions and 1 deletions

View file

@ -64,6 +64,7 @@
#include "unit_display.hpp"
#include "unit_filter.hpp"
#include "wml_exception.hpp"
#include "whiteboard/manager.hpp"
#include <boost/foreach.hpp>
#include <boost/assign/list_of.hpp>
@ -515,7 +516,15 @@ static void on_replay_error(const std::string& message, bool /*b*/)
// This allows to perform scripting in WML that will use the same code path as player actions, for example.
WML_HANDLER_FUNCTION(do_command, /*event_info*/, cfg)
{
//TODO: don't allow this if we are in a whiteboard applied context.
// Doing this in a whiteboard applied context will cause bugs
// Note that even though game_events::pump() will always apply the real unit map
// It is still possible get a wml commands to run in a whiteboard applied context
// With the theme_items lua callbacks
if(resources::whiteboard->has_planned_unit_map())
{
ERR_NG << "[do_command] called while whiteboard is applied, ignoring" << std::endl;
return;
}
static const std::set<std::string> allowed_tags = boost::assign::list_of("attack")("move")("recruit")("recall")("disband")("fire_event")("lua_ai");

View file

@ -110,6 +110,7 @@ bool synced_context::run_in_synced_context_if_not_already(const std::string& com
if(resources::controller->is_replay())
{
ERR_REPLAY << "ignored attempt to invoke a synced command during replay\n";
return false;
}
return run_in_synced_context(commandname, data, use_undo, show, true, error_handler);
}