fix get_user_choice for other sides
as the comment in replay.cpp says we want "send data to others" so calling "pull_remote_user_input" is not really correct. Since plamp_controller::handle_generaic_command("ai_user_input") also invokes send_data we just don't call it with "sync_network" in this case. This solution is still not optmial but it has the smallest chance to break things since epecialy because this should go to 1.12 too. Conflicts: src/ai/manager.cpp
This commit is contained in:
parent
799e09d94a
commit
0e79ef919f
5 changed files with 11 additions and 7 deletions
|
@ -398,10 +398,10 @@ void manager::remove_turn_started_observer( events::observer* event_observer )
|
||||||
turn_started_.detach_handler(event_observer);
|
turn_started_.detach_handler(event_observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void manager::raise_user_interact() {
|
void manager::raise_user_interact(bool force_now) {
|
||||||
const int interact_time = 30;
|
const int interact_time = 30;
|
||||||
const int time_since_interact = SDL_GetTicks() - last_interact_;
|
const int time_since_interact = SDL_GetTicks() - last_interact_;
|
||||||
if(time_since_interact < interact_time) {
|
if(time_since_interact < interact_time && !force_now) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,8 +184,10 @@ public:
|
||||||
* with the interface. This function will make sure that interaction
|
* with the interface. This function will make sure that interaction
|
||||||
* doesn't occur too often, so there is no problem with calling it very
|
* doesn't occur too often, so there is no problem with calling it very
|
||||||
* regularly.
|
* regularly.
|
||||||
|
* @param force ignore if we already called this function recenlty,
|
||||||
|
* this is part of a hack related to mp_sync
|
||||||
*/
|
*/
|
||||||
static void raise_user_interact();
|
static void raise_user_interact(bool force= false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies all observers of 'ai_sync_network' event.
|
* Notifies all observers of 'ai_sync_network' event.
|
||||||
|
|
|
@ -1023,7 +1023,7 @@ static std::map<int, config> get_user_choice_internal(const std::string &name, c
|
||||||
//but if there wasn't any data sended during this turn, we don't want to bein wth that now.
|
//but if there wasn't any data sended during this turn, we don't want to bein wth that now.
|
||||||
if(synced_context::is_simultaneously() || current_side != local_side)
|
if(synced_context::is_simultaneously() || current_side != local_side)
|
||||||
{
|
{
|
||||||
synced_context::pull_remote_user_input();
|
synced_context::pull_remote_user_input(true);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ namespace
|
||||||
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(lua_network_error)
|
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(lua_network_error)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
void synced_context::pull_remote_user_input()
|
void synced_context::pull_remote_user_input(bool send_only)
|
||||||
{
|
{
|
||||||
//we sended data over the network.
|
//we sended data over the network.
|
||||||
is_simultaneously_ = true;
|
is_simultaneously_ = true;
|
||||||
|
@ -174,13 +174,15 @@ void synced_context::pull_remote_user_input()
|
||||||
//because that might result in crashs if someone clicks anywhere during screenlock.
|
//because that might result in crashs if someone clicks anywhere during screenlock.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ai::manager::raise_user_interact();
|
ai::manager::raise_user_interact(send_only);
|
||||||
}
|
}
|
||||||
catch(end_turn_exception&)
|
catch(end_turn_exception&)
|
||||||
{
|
{
|
||||||
//ignore, since it will be thwown throw again.
|
//ignore, since it will be thwown throw again.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(send_only)
|
||||||
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ai::manager::raise_sync_network();
|
ai::manager::raise_sync_network();
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
/*
|
/*
|
||||||
called from get_user_choice;
|
called from get_user_choice;
|
||||||
*/
|
*/
|
||||||
static void pull_remote_user_input();
|
static void pull_remote_user_input(bool send_only = false);
|
||||||
/*
|
/*
|
||||||
a function to be passed to run_in_synced_context to assert false on error (the default).
|
a function to be passed to run_in_synced_context to assert false on error (the default).
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue