mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
parent
1c0ccd2b02
commit
f19e41d38c
@ -27,7 +27,7 @@
|
||||
#include "mapping/CCampaignHandler.h" //for CCampaignState
|
||||
#include "rmg/CMapGenerator.h" // for CMapGenOptions
|
||||
|
||||
const ui32 version = 740;
|
||||
const ui32 version = 741;
|
||||
|
||||
class CConnection;
|
||||
class CGObjectInstance;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace GameConstants
|
||||
{
|
||||
const std::string VCMI_VERSION = "VCMI 0.92c";
|
||||
const std::string VCMI_VERSION = "VCMI 0.93";
|
||||
|
||||
const int BFIELD_WIDTH = 17;
|
||||
const int BFIELD_HEIGHT = 11;
|
||||
|
@ -942,6 +942,21 @@ struct RebalanceStacks : CGarrisonOperationPack //526
|
||||
|
||||
typedef boost::variant<ConstTransitivePtr<CGHeroInstance>, ConstTransitivePtr<CStackInstance> > TArtHolder;
|
||||
|
||||
|
||||
struct GetEngagedHeroIds : boost::static_visitor<boost::optional<ObjectInstanceID>>
|
||||
{
|
||||
boost::optional<ObjectInstanceID> operator()(const ConstTransitivePtr<CGHeroInstance> &h) const
|
||||
{
|
||||
return h->id;
|
||||
}
|
||||
boost::optional<ObjectInstanceID> operator()(const ConstTransitivePtr<CStackInstance> &s) const
|
||||
{
|
||||
if(s->armyObj && s->armyObj->ID == Obj::HERO)
|
||||
return s->armyObj->id;
|
||||
return boost::optional<ObjectInstanceID>();
|
||||
}
|
||||
};
|
||||
|
||||
//struct GetArtifactSet : boost::static_visitor<>
|
||||
//{
|
||||
// void operator()(const ConstTransitivePtr<CGHeroInstance> &h) const {}
|
||||
|
@ -258,14 +258,27 @@ CGarrisonDialogQuery::CGarrisonDialogQuery(const CArmedInstance *up, const CArme
|
||||
|
||||
bool CGarrisonDialogQuery::blocksPack(const CPack *pack) const
|
||||
{
|
||||
std::set<ObjectInstanceID> ourIds, idsAttempted;
|
||||
ourIds.insert(this->exchangingArmies[0]->id);
|
||||
ourIds.insert(this->exchangingArmies[1]->id);
|
||||
|
||||
|
||||
if(auto stacks = dynamic_cast<const ArrangeStacks*>(pack))
|
||||
{
|
||||
std::set<ObjectInstanceID> ourIds;
|
||||
ourIds.insert(this->exchangingArmies[0]->id);
|
||||
ourIds.insert(this->exchangingArmies[1]->id);
|
||||
|
||||
return !vstd::contains(ourIds, stacks->id1) || !vstd::contains(ourIds, stacks->id2);
|
||||
}
|
||||
else if(auto arts = dynamic_cast<const ExchangeArtifacts*>(pack))
|
||||
{
|
||||
if(auto id1 = boost::apply_visitor(GetEngagedHeroIds(), arts->src.artHolder))
|
||||
if(!vstd::contains(ourIds, *id1))
|
||||
return true;
|
||||
|
||||
if(auto id2 = boost::apply_visitor(GetEngagedHeroIds(), arts->dst.artHolder))
|
||||
if(!vstd::contains(ourIds, *id2))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return CDialogQuery::blocksPack(pack);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user