mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
Implemented flagged garrisons passableness ( #150 ). Full support for BorderGates.
This commit is contained in:
@ -1418,6 +1418,9 @@ bool CPlayerInterface::shiftPressed() 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
|
||||||
|
return;
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> un(showingDialog->mx);
|
boost::unique_lock<boost::mutex> un(showingDialog->mx);
|
||||||
while(showingDialog->data)
|
while(showingDialog->data)
|
||||||
|
@ -317,7 +317,8 @@ int CClient::getSelectedHero()
|
|||||||
|
|
||||||
void CClient::newGame( CConnection *con, StartInfo *si )
|
void CClient::newGame( CConnection *con, StartInfo *si )
|
||||||
{
|
{
|
||||||
if (con == NULL) {
|
if (con == NULL)
|
||||||
|
{
|
||||||
timeHandler pomtime;
|
timeHandler pomtime;
|
||||||
char portc[10];
|
char portc[10];
|
||||||
SDL_itoa(conf.cc.port,portc,10);
|
SDL_itoa(conf.cc.port,portc,10);
|
||||||
|
@ -439,6 +439,11 @@ void CGObjectInstance::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui8 CGObjectInstance::getPassableness() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int lowestSpeed(const CGHeroInstance * chi)
|
static int lowestSpeed(const CGHeroInstance * chi)
|
||||||
{
|
{
|
||||||
if(!chi->army.slots.size())
|
if(!chi->army.slots.size())
|
||||||
@ -3833,6 +3838,11 @@ void CGGarrison::fightOver (const CGHeroInstance *h, BattleResult *result) const
|
|||||||
onHeroVisit(h);
|
onHeroVisit(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui8 CGGarrison::getPassableness() const
|
||||||
|
{
|
||||||
|
return 1<<tempOwner;
|
||||||
|
}
|
||||||
|
|
||||||
void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const
|
void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const
|
||||||
{
|
{
|
||||||
int sound = 0;
|
int sound = 0;
|
||||||
@ -4505,15 +4515,23 @@ void CGBorderGuard::openGate(const CGHeroInstance *h, ui32 accept) const
|
|||||||
|
|
||||||
void CGBorderGate::onHeroVisit( const CGHeroInstance * h ) const //TODO: passability
|
void CGBorderGate::onHeroVisit( const CGHeroInstance * h ) const //TODO: passability
|
||||||
{
|
{
|
||||||
InfoWindow iw;
|
|
||||||
iw.player = h->getOwner();
|
|
||||||
if (!wasMyColorVisited (h->getOwner()) )
|
if (!wasMyColorVisited (h->getOwner()) )
|
||||||
{
|
{
|
||||||
|
InfoWindow iw;
|
||||||
|
iw.player = h->getOwner();
|
||||||
iw.text << std::pair<ui8,ui32>(11,18);
|
iw.text << std::pair<ui8,ui32>(11,18);
|
||||||
cb->showInfoDialog(&iw);
|
cb->showInfoDialog(&iw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui8 CGBorderGate::getPassableness() const
|
||||||
|
{
|
||||||
|
ui8 ret = 0;
|
||||||
|
for (int i = 0; i < PLAYER_LIMIT; i++)
|
||||||
|
ret |= wasMyColorVisited(i)<<i;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void CGMagi::initObj()
|
void CGMagi::initObj()
|
||||||
{
|
{
|
||||||
if (ID == 27)
|
if (ID == 27)
|
||||||
|
@ -142,6 +142,7 @@ public:
|
|||||||
ui8 tempOwner;
|
ui8 tempOwner;
|
||||||
ui8 blockVisit; //if non-zero then blocks the tile but is visitable from neighbouring tile
|
ui8 blockVisit; //if non-zero then blocks the tile but is visitable from neighbouring tile
|
||||||
|
|
||||||
|
virtual ui8 getPassableness() const; //bitmap - if the bit is set the corresponding player can pass through the visitable tiles of object, even if it's blockvis; if not set - default properties from definfo are used
|
||||||
virtual int3 getSightCenter() const; //"center" tile from which the sight distance is calculated
|
virtual int3 getSightCenter() const; //"center" tile from which the sight distance is calculated
|
||||||
virtual int getSightRadious() const; //sight distance (should be used if player-owned structure)
|
virtual int getSightRadious() const; //sight distance (should be used if player-owned structure)
|
||||||
void getSightTiles(std::set<int3> &tiles) const; //returns reference to the set
|
void getSightTiles(std::set<int3> &tiles) const; //returns reference to the set
|
||||||
@ -633,6 +634,7 @@ class DLL_EXPORT CGGarrison : public CArmedInstance
|
|||||||
public:
|
public:
|
||||||
ui8 removableUnits;
|
ui8 removableUnits;
|
||||||
|
|
||||||
|
ui8 getPassableness() const;
|
||||||
void onHeroVisit (const CGHeroInstance *h) const;
|
void onHeroVisit (const CGHeroInstance *h) const;
|
||||||
void fightOver (const CGHeroInstance *h, BattleResult *result) const;
|
void fightOver (const CGHeroInstance *h, BattleResult *result) const;
|
||||||
|
|
||||||
@ -872,6 +874,7 @@ class DLL_EXPORT CGBorderGate : public CGBorderGuard //not fully imlemented, wai
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void onHeroVisit(const CGHeroInstance * h) const;
|
void onHeroVisit(const CGHeroInstance * h) const;
|
||||||
|
ui8 getPassableness() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_EXPORT CGBoat : public CGObjectInstance
|
class DLL_EXPORT CGBoat : public CGObjectInstance
|
||||||
|
@ -2068,7 +2068,11 @@ void CGameState::calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int
|
|||||||
for(size_t ii = 0; ii < tinfo->visitableObjects.size(); ii++)
|
for(size_t ii = 0; ii < tinfo->visitableObjects.size(); ii++)
|
||||||
{
|
{
|
||||||
const CGObjectInstance * const obj = tinfo->visitableObjects[ii];
|
const CGObjectInstance * const obj = tinfo->visitableObjects[ii];
|
||||||
if(obj->blockVisit)
|
if(obj->getPassableness() & 1<<hero->tempOwner) //special object instance specific passableness flag - overwrites other accessibility flags
|
||||||
|
{
|
||||||
|
node.accessible = CGPathNode::ACCESSIBLE;
|
||||||
|
}
|
||||||
|
else if(obj->blockVisit)
|
||||||
{
|
{
|
||||||
node.accessible = CGPathNode::BLOCKVIS;
|
node.accessible = CGPathNode::BLOCKVIS;
|
||||||
break;
|
break;
|
||||||
|
@ -277,7 +277,14 @@ struct CPathNode
|
|||||||
|
|
||||||
struct CGPathNode
|
struct CGPathNode
|
||||||
{
|
{
|
||||||
enum {ACCESSIBLE=1, VISITABLE, BLOCKVIS, BLOCKED}; //BLOCKVIS - visitable from neighbouring tile but not passable
|
enum
|
||||||
|
{
|
||||||
|
ACCESSIBLE=1, //tile can be entered and passed
|
||||||
|
VISITABLE, //tile can be entered as the last tile in path
|
||||||
|
BLOCKVIS, //visitable from neighbouring tile but not passable
|
||||||
|
BLOCKED //tile can't be entered nor visited
|
||||||
|
};
|
||||||
|
|
||||||
ui8 accessible; //the enum above
|
ui8 accessible; //the enum above
|
||||||
ui8 land;
|
ui8 land;
|
||||||
ui8 turns;
|
ui8 turns;
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
MinimalRebuild="false"
|
MinimalRebuild="false"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
WarningLevel="2"
|
WarningLevel="1"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
DisableSpecificWarnings="4251"
|
DisableSpecificWarnings="4251"
|
||||||
/>
|
/>
|
||||||
|
@ -646,8 +646,6 @@ void CGameHandler::handleConnection(std::set<int> players, CConnection &c)
|
|||||||
HANDLE_EXCEPTION(end2 = true);
|
HANDLE_EXCEPTION(end2 = true);
|
||||||
handleConEnd:
|
handleConEnd:
|
||||||
tlog1 << "Ended handling connection\n";
|
tlog1 << "Ended handling connection\n";
|
||||||
#undef SPELL_CAST_TEMPLATE_1
|
|
||||||
#undef SPELL_CAST_TEMPLATE_2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CGameHandler::moveStack(int stack, int dest)
|
int CGameHandler::moveStack(int stack, int dest)
|
||||||
@ -1476,7 +1474,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
|
|||||||
tmh.movePoints = std::max(si32(0),h->movement-cost); //take move points
|
tmh.movePoints = std::max(si32(0),h->movement-cost); //take move points
|
||||||
BOOST_FOREACH(CGObjectInstance *obj, t.visitableObjects)
|
BOOST_FOREACH(CGObjectInstance *obj, t.visitableObjects)
|
||||||
{
|
{
|
||||||
if(obj != h && obj->blockVisit)
|
if(obj != h && obj->blockVisit && !(obj->getPassableness() & 1<<h->tempOwner))
|
||||||
{
|
{
|
||||||
blockvis = true;
|
blockvis = true;
|
||||||
break;
|
break;
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
MinimalRebuild="false"
|
MinimalRebuild="false"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
WarningLevel="2"
|
WarningLevel="1"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
DisableSpecificWarnings="4251"
|
DisableSpecificWarnings="4251"
|
||||||
/>
|
/>
|
||||||
|
Reference in New Issue
Block a user