1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Partial garrison support, battles are played out and the object gets flagged.

This commit is contained in:
OnionKnight
2009-08-25 15:08:18 +00:00
parent a13d7fd595
commit 5f2d6b5e4c
2 changed files with 24 additions and 0 deletions

View File

@@ -3497,6 +3497,27 @@ void CGScholar::initObj()
} }
} }
void CGGarrison::onHeroVisit (const CGHeroInstance *h) const
{
if (h->tempOwner != tempOwner && army) {
//TODO: Find a way to apply magic garrison effects in battle.
cb->startBattleI(h, this, false, boost::bind(&CGGarrison::fightOver, this, h, _1));
return;
}
//New owner.
if (h->tempOwner != tempOwner)
cb->setOwner(id, h->tempOwner);
//TODO: Garrison visit screen.
}
void CGGarrison::fightOver (const CGHeroInstance *h, BattleResult *result) const
{
if (result->winner == 0)
onHeroVisit(h);
}
void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const
{ {
int sound = 0; int sound = 0;

View File

@@ -602,6 +602,9 @@ class DLL_EXPORT CGGarrison : public CArmedInstance
public: public:
ui8 removableUnits; ui8 removableUnits;
void onHeroVisit (const CGHeroInstance *h) const;
void fightOver (const CGHeroInstance *h, BattleResult *result) const;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & static_cast<CArmedInstance&>(*this); h & static_cast<CArmedInstance&>(*this);