wb: don't remove invalid actions from other players
this would bring the whiteboard data of the differnt clients out of sync which could be a problem since the wb network protocoll identifies the actions to be removed ot replaced by index.
This commit is contained in:
parent
ee00b88427
commit
3a28c3a346
2 changed files with 15 additions and 13 deletions
|
@ -103,7 +103,7 @@ void mapbuilder::build_map()
|
|||
side_actions::iterator it = actions.turn_begin(turn), next = it, end = actions.turn_end(turn);
|
||||
while(it != end) {
|
||||
std::advance(next, 1);
|
||||
process(actions, it);
|
||||
process(actions, it, side.is_local());
|
||||
it = next;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ void mapbuilder::build_map()
|
|||
}
|
||||
}
|
||||
|
||||
void mapbuilder::process(side_actions &sa, side_actions::iterator action_it)
|
||||
void mapbuilder::process(side_actions &sa, side_actions::iterator action_it, bool is_local_side)
|
||||
{
|
||||
action_ptr action = *action_it;
|
||||
bool acted=false;
|
||||
|
@ -136,7 +136,7 @@ void mapbuilder::process(side_actions &sa, side_actions::iterator action_it)
|
|||
if(erval != action::OK) {
|
||||
// We do not delete obstructed moves, nor invalid actions caused by obstructed moves.
|
||||
if(has_invalid_actions_.find(unit.get()) == has_invalid_actions_.end()) {
|
||||
if(erval == action::TOO_FAR || (erval == action::LOCATION_OCCUPIED && std::dynamic_pointer_cast<move>(action))) {
|
||||
if(!is_local_side || erval == action::TOO_FAR || (erval == action::LOCATION_OCCUPIED && std::dynamic_pointer_cast<move>(action))) {
|
||||
has_invalid_actions_.insert(unit.get());
|
||||
invalid_actions_.push_back(action_it);
|
||||
} else {
|
||||
|
@ -150,17 +150,19 @@ void mapbuilder::process(side_actions &sa, side_actions::iterator action_it)
|
|||
}
|
||||
|
||||
// We do not keep invalid actions replaced by a valid one.
|
||||
std::set<class unit const*>::iterator invalid_it = has_invalid_actions_.find(unit.get());
|
||||
if(invalid_it != has_invalid_actions_.end()) {
|
||||
for(std::list<side_actions::iterator>::iterator it = invalid_actions_.begin(); it != invalid_actions_.end();) {
|
||||
if((**it)->get_unit().get() == unit.get()) {
|
||||
sa.remove_action(*it, false);
|
||||
it = invalid_actions_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
if(is_local_side) {
|
||||
std::set<class unit const*>::iterator invalid_it = has_invalid_actions_.find(unit.get());
|
||||
if(invalid_it != has_invalid_actions_.end()) {
|
||||
for(std::list<side_actions::iterator>::iterator it = invalid_actions_.begin(); it != invalid_actions_.end();) {
|
||||
if((**it)->get_unit().get() == unit.get()) {
|
||||
sa.remove_action(*it, false);
|
||||
it = invalid_actions_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
has_invalid_actions_.erase(invalid_it);
|
||||
}
|
||||
has_invalid_actions_.erase(invalid_it);
|
||||
}
|
||||
|
||||
if(acted || action->places_new_unit()) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
private:
|
||||
/** Function called on each action. */
|
||||
void process(side_actions &sa, side_actions::iterator action_it);
|
||||
void process(side_actions &sa, side_actions::iterator action_it, bool is_local_side);
|
||||
|
||||
/** Function called after visiting a team. */
|
||||
void post_visit_team(std::size_t turn);
|
||||
|
|
Loading…
Add table
Reference in a new issue