mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fix #807
This commit is contained in:
parent
1e4a08529c
commit
74fafbedbf
@ -1186,7 +1186,10 @@ bool CPlayerInterface::altPressed() const
|
|||||||
void CPlayerInterface::showGarrisonDialog( const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, boost::function<void()> &onEnd )
|
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
|
if(stillMoveHero.get() == DURING_MOVE && adventureInt->terrain.currentPath->nodes.size() > 1) //to ignore calls on passing through garrisons
|
||||||
|
{
|
||||||
|
onEnd();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> un(showingDialog->mx);
|
boost::unique_lock<boost::mutex> un(showingDialog->mx);
|
||||||
|
@ -634,8 +634,9 @@ void CGameHandler::handleConnection(std::set<int> players, CConnection &c)
|
|||||||
|
|
||||||
int packType = typeList.getTypeID(pack); //get the id of type
|
int packType = typeList.getTypeID(pack); //get the id of type
|
||||||
CBaseForGHApply *apply = applier->apps[packType]; //and appropriae applier object
|
CBaseForGHApply *apply = applier->apps[packType]; //and appropriae applier object
|
||||||
|
if(packType != typeList.getTypeID<QueryReply>() &&
|
||||||
if(packType != typeList.getTypeID<QueryReply>() && states[getCurrentPlayer()].queries.size())
|
(packType != typeList.getTypeID<ArrangeStacks>() || !isAllowedArrangePack((ArrangeStacks*)pack)) && // for dialogs like garrison
|
||||||
|
states[getCurrentPlayer()].queries.size())
|
||||||
{
|
{
|
||||||
complain("Answer the query before attempting any further actions!");
|
complain("Answer the query before attempting any further actions!");
|
||||||
PackageApplied applied;
|
PackageApplied applied;
|
||||||
@ -4003,18 +4004,26 @@ void CGameHandler::showThievesGuildWindow(int requestingObjId)
|
|||||||
sendAndApply(&ow);
|
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 )
|
bool CGameHandler::isAllowedExchange( int id1, int id2 )
|
||||||
{
|
{
|
||||||
if(id1 == id2)
|
if(id1 == id2)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
{
|
if (isAllowedExchangeForQuery(id1, id2))
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(gsm);
|
return true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CGObjectInstance *o1 = getObj(id1), *o2 = getObj(id2);
|
const CGObjectInstance *o1 = getObj(id1), *o2 = getObj(id2);
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ class CGameHandler : public IGameCallback
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
void makeStackDoNothing(const CStack * next);
|
void makeStackDoNothing(const CStack * next);
|
||||||
|
bool isAllowedExchangeForQuery(int id1, int id2);
|
||||||
public:
|
public:
|
||||||
CVCMIServer *s;
|
CVCMIServer *s;
|
||||||
std::map<int,CConnection*> connections; //player color -> connection to client with interface of that player
|
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;
|
std::map<ui32, std::pair<si32,si32> > allowedExchanges;
|
||||||
|
|
||||||
bool isAllowedExchange(int id1, int id2);
|
bool isAllowedExchange(int id1, int id2);
|
||||||
|
bool isAllowedArrangePack(const ArrangeStacks *pack);
|
||||||
void giveSpells(const CGTownInstance *t, const CGHeroInstance *h);
|
void giveSpells(const CGTownInstance *t, const CGHeroInstance *h);
|
||||||
int moveStack(int stack, THex dest); //returned value - travelled distance
|
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
|
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__
|
#endif // __CGAMEHANDLER_H__
|
||||||
|
|
||||||
void makeStackDoNothing();
|
void makeStackDoNothing();
|
||||||
|
Loading…
Reference in New Issue
Block a user