1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
This commit is contained in:
ori.bar 2011-09-17 18:15:10 +00:00
parent 1e4a08529c
commit 74fafbedbf
3 changed files with 24 additions and 10 deletions

View File

@ -1186,7 +1186,10 @@ bool CPlayerInterface::altPressed() const
void CPlayerInterface::showGarrisonDialog( const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, boost::function<void()> &onEnd )
{
if(stillMoveHero.get() == DURING_MOVE && adventureInt->terrain.currentPath->nodes.size() > 1) //to ignore calls on passing through garrisons
{
onEnd();
return;
}
{
boost::unique_lock<boost::mutex> un(showingDialog->mx);

View File

@ -634,8 +634,9 @@ void CGameHandler::handleConnection(std::set<int> players, CConnection &c)
int packType = typeList.getTypeID(pack); //get the id of type
CBaseForGHApply *apply = applier->apps[packType]; //and appropriae applier object
if(packType != typeList.getTypeID<QueryReply>() && states[getCurrentPlayer()].queries.size())
if(packType != typeList.getTypeID<QueryReply>() &&
(packType != typeList.getTypeID<ArrangeStacks>() || !isAllowedArrangePack((ArrangeStacks*)pack)) && // for dialogs like garrison
states[getCurrentPlayer()].queries.size())
{
complain("Answer the query before attempting any further actions!");
PackageApplied applied;
@ -4003,18 +4004,26 @@ void CGameHandler::showThievesGuildWindow(int requestingObjId)
sendAndApply(&ow);
}
bool CGameHandler::isAllowedArrangePack(const ArrangeStacks *pack)
{
return isAllowedExchangeForQuery(pack->id1, pack->id2);
}
bool CGameHandler::isAllowedExchangeForQuery(int id1, int id2) {
boost::unique_lock<boost::recursive_mutex> lock(gsm);
for(std::map<ui32, std::pair<si32,si32> >::const_iterator i = allowedExchanges.begin(); i!=allowedExchanges.end(); i++)
if((id1 == i->second.first && id2 == i->second.second) ||
(id2 == i->second.first && id1 == i->second.second))
return true;
}
bool CGameHandler::isAllowedExchange( int id1, int id2 )
{
if(id1 == id2)
return true;
{
boost::unique_lock<boost::recursive_mutex> lock(gsm);
for(std::map<ui32, std::pair<si32,si32> >::const_iterator i = allowedExchanges.begin(); i!=allowedExchanges.end(); i++)
if((id1 == i->second.first && id2 == i->second.second) ||
(id2 == i->second.first && id1 == i->second.second))
return true;
}
if (isAllowedExchangeForQuery(id1, id2))
return true;
const CGObjectInstance *o1 = getObj(id1), *o2 = getObj(id2);

View File

@ -89,6 +89,7 @@ class CGameHandler : public IGameCallback
{
private:
void makeStackDoNothing(const CStack * next);
bool isAllowedExchangeForQuery(int id1, int id2);
public:
CVCMIServer *s;
std::map<int,CConnection*> connections; //player color -> connection to client with interface of that player
@ -103,6 +104,7 @@ public:
std::map<ui32, std::pair<si32,si32> > allowedExchanges;
bool isAllowedExchange(int id1, int id2);
bool isAllowedArrangePack(const ArrangeStacks *pack);
void giveSpells(const CGTownInstance *t, const CGHeroInstance *h);
int moveStack(int stack, THex dest); //returned value - travelled distance
void startBattle(const CArmedInstance *armies[2], int3 tile, const CGHeroInstance *heroes[2], bool creatureBank, boost::function<void(BattleResult*)> cb, const CGTownInstance *town = NULL); //use hero=NULL for no hero
@ -261,4 +263,4 @@ public:
#endif // __CGAMEHANDLER_H__
void makeStackDoNothing();
void makeStackDoNothing();