diff --git a/src/decblupi.cxx b/src/decblupi.cxx index 41e7419..a52ca68 100644 --- a/src/decblupi.cxx +++ b/src/decblupi.cxx @@ -2430,6 +2430,32 @@ bool CDecor::BlupiNextAction (Sint32 rank) if (!m_blupi[rank].bExist) return false; + /* Check if a Blupi is already doing a conflicting action at the same place. + * It happens for example when a blupi wants to carry an object from a + * direction and a second from the other direction. Without this check, the + * object is duplicated. + */ + for (int i = 0; i < MAXBLUPI; ++i) + { + if (rank == i || !m_blupi[i].bExist) + continue; + + if ( + (m_blupi[rank].goalAction == EV_ACTION_CARRY || + m_blupi[rank].goalAction == EV_ACTION_EAT || + m_blupi[rank].goalAction == EV_ACTION_DRINK) && + (m_blupi[i].goalAction == EV_ACTION_CARRY2 || + m_blupi[i].goalAction == EV_ACTION_EAT2 || + m_blupi[i].goalAction == EV_ACTION_DRINK2) && + m_blupi[rank].goalHili.x == m_blupi[i].goalHili.x && + m_blupi[rank].goalHili.y == m_blupi[i].goalHili.y) + { + BlupiInitAction (i, ACTION_STOP); + GoalStop (i, true); + return false; + } + } + if (m_blupi[rank].clicDelay > 0) m_blupi[rank].clicDelay--; if (m_blupi[rank].clicDelay == 0)