1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Implemented flagged garrisons passableness ( #150 ). Full support for BorderGates.

This commit is contained in:
Michał W. Urbańczyk 2009-12-20 17:14:14 +00:00
parent 4780bcd1a6
commit 1c32679f93
9 changed files with 44 additions and 10 deletions

View File

@ -1418,6 +1418,9 @@ bool CPlayerInterface::shiftPressed() 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
return;
{
boost::unique_lock<boost::mutex> un(showingDialog->mx);
while(showingDialog->data)

View File

@ -317,7 +317,8 @@ int CClient::getSelectedHero()
void CClient::newGame( CConnection *con, StartInfo *si )
{
if (con == NULL) {
if (con == NULL)
{
timeHandler pomtime;
char portc[10];
SDL_itoa(conf.cc.port,portc,10);

View File

@ -439,6 +439,11 @@ void CGObjectInstance::onHeroVisit( const CGHeroInstance * h ) const
{
}
ui8 CGObjectInstance::getPassableness() const
{
return 0;
}
static int lowestSpeed(const CGHeroInstance * chi)
{
if(!chi->army.slots.size())
@ -3833,6 +3838,11 @@ void CGGarrison::fightOver (const CGHeroInstance *h, BattleResult *result) const
onHeroVisit(h);
}
ui8 CGGarrison::getPassableness() const
{
return 1<<tempOwner;
}
void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const
{
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
{
InfoWindow iw;
iw.player = h->getOwner();
if (!wasMyColorVisited (h->getOwner()) )
{
InfoWindow iw;
iw.player = h->getOwner();
iw.text << std::pair<ui8,ui32>(11,18);
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()
{
if (ID == 27)

View File

@ -142,6 +142,7 @@ public:
ui8 tempOwner;
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 int getSightRadious() const; //sight distance (should be used if player-owned structure)
void getSightTiles(std::set<int3> &tiles) const; //returns reference to the set
@ -633,6 +634,7 @@ class DLL_EXPORT CGGarrison : public CArmedInstance
public:
ui8 removableUnits;
ui8 getPassableness() const;
void onHeroVisit (const CGHeroInstance *h) const;
void fightOver (const CGHeroInstance *h, BattleResult *result) const;
@ -872,6 +874,7 @@ class DLL_EXPORT CGBorderGate : public CGBorderGuard //not fully imlemented, wai
{
public:
void onHeroVisit(const CGHeroInstance * h) const;
ui8 getPassableness() const;
};
class DLL_EXPORT CGBoat : public CGObjectInstance

View File

@ -2068,7 +2068,11 @@ void CGameState::calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int
for(size_t ii = 0; ii < tinfo->visitableObjects.size(); 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;
break;

View File

@ -277,7 +277,14 @@ struct CPathNode
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 land;
ui8 turns;

View File

@ -45,7 +45,7 @@
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="2"
WarningLevel="1"
DebugInformationFormat="4"
DisableSpecificWarnings="4251"
/>

View File

@ -646,8 +646,6 @@ void CGameHandler::handleConnection(std::set<int> players, CConnection &c)
HANDLE_EXCEPTION(end2 = true);
handleConEnd:
tlog1 << "Ended handling connection\n";
#undef SPELL_CAST_TEMPLATE_1
#undef SPELL_CAST_TEMPLATE_2
}
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
BOOST_FOREACH(CGObjectInstance *obj, t.visitableObjects)
{
if(obj != h && obj->blockVisit)
if(obj != h && obj->blockVisit && !(obj->getPassableness() & 1<<h->tempOwner))
{
blockvis = true;
break;

View File

@ -45,7 +45,7 @@
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="2"
WarningLevel="1"
DebugInformationFormat="4"
DisableSpecificWarnings="4251"
/>