mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed #565. Creature components will not get description if they quantity is set to zero.
This commit is contained in:
parent
084a0148c7
commit
6c3ad7fcae
@ -86,6 +86,7 @@ public:
|
||||
void giveResource(int player, int which, int val){};
|
||||
void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet creatures) {};
|
||||
void takeCreatures (int objid, TSlots creatures){};
|
||||
void changeCreatureType (int objid, TSlot slot, TCreature creature){};
|
||||
void showCompInfo(ShowInInfobox * comp){};
|
||||
void heroVisitCastle(int obj, int heroID){};
|
||||
void stopHeroVisitCastle(int obj, int heroID){};
|
||||
|
@ -4619,13 +4619,11 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
if (creatures.slots.size())
|
||||
{
|
||||
messageID = 138;
|
||||
cb->takeCreatures(h->id, creatures.slots);
|
||||
for (std::map<TSlot, CStackInstance>::iterator i = creatures.slots.begin(); i != creatures.slots.end(); i++)
|
||||
{
|
||||
i->second.setType(11);
|
||||
}
|
||||
cb->giveCreatures(h->id, h, creatures); //suboptimal again, but creature sets are screwed in general
|
||||
iw.components.push_back(Component(Component::CREATURE,11,0,1));
|
||||
for (TSlots::const_iterator i = creatures.slots.begin(); i != creatures.slots.end(); ++i)
|
||||
{
|
||||
cb->changeCreatureType(h->id, i->first, 11);
|
||||
}
|
||||
}
|
||||
else
|
||||
messageID = 137;
|
||||
|
@ -87,6 +87,7 @@ public:
|
||||
virtual void giveResource(int player, int which, int val)=0;
|
||||
virtual void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet creatures) =0;
|
||||
virtual void takeCreatures (int objid, TSlots creatures) =0;
|
||||
virtual void changeCreatureType (int objid, TSlot slot, TCreature creature) =0;
|
||||
virtual void showCompInfo(ShowInInfobox * comp)=0;
|
||||
virtual void heroVisitCastle(int obj, int heroID)=0;
|
||||
virtual void stopHeroVisitCastle(int obj, int heroID)=0;
|
||||
|
@ -2875,6 +2875,20 @@ bool CGameHandler::upgradeCreature( ui32 objid, ui8 pos, ui32 upgID )
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGameHandler::changeCreatureType (int objid, TSlot slot, TCreature creature)
|
||||
{
|
||||
CArmedInstance *obj = static_cast<CArmedInstance*>(gs->map->objects[objid]);
|
||||
if (obj)
|
||||
{
|
||||
SetGarrisons sg;
|
||||
sg.garrs[objid] = obj->getArmy();
|
||||
sg.garrs[objid].slots[slot].setType(creature);
|
||||
sendAndApply(&sg);
|
||||
}
|
||||
else
|
||||
tlog2 <<"Illegal call of changeCreatureType for non-armed instance!\n";
|
||||
}
|
||||
|
||||
bool CGameHandler::garrisonSwap( si32 tid )
|
||||
{
|
||||
CGTownInstance *town = gs->getTown(tid);
|
||||
|
@ -135,6 +135,7 @@ public:
|
||||
void giveResource(int player, int which, int val);
|
||||
void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet creatures);
|
||||
void takeCreatures (int objid, TSlots creatures);
|
||||
void changeCreatureType (int objid, TSlot slot, TCreature creature);
|
||||
void showCompInfo(ShowInInfobox * comp);
|
||||
void heroVisitCastle(int obj, int heroID);
|
||||
void vistiCastleObjects (const CGTownInstance *t, const CGHeroInstance *h);
|
||||
|
Loading…
Reference in New Issue
Block a user