1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Next set of fixes, mostly for deserialization.

This commit is contained in:
Michał W. Urbańczyk
2011-02-22 09:47:25 +00:00
parent 1458cf64c2
commit a46ad0b7ef
16 changed files with 144 additions and 78 deletions

View File

@ -26,6 +26,8 @@
#include <SDL_stdinc.h>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/algorithm/string/trim.hpp>
using namespace boost::assign;
/*
@ -1493,6 +1495,19 @@ void CGHeroInstance::deserializationFix()
attachTo(&speciality);
}
CBonusSystemNode * CGHeroInstance::whereShouldBeAttached(CGameState *gs)
{
if(visitedTown)
{
if(inTownGarrison)
return visitedTown;
else
return &visitedTown->townAndVis;
}
else
return CArmedInstance::whereShouldBeAttached(gs);
}
void CGDwelling::initObj()
{
switch(ID)
@ -2367,6 +2382,11 @@ bool CGTownInstance::armedGarrison() const
return stacksCount() || garrisonHero;
}
CBonusSystemNode * CGTownInstance::whatShouldBeAttached()
{
return &townAndVis;
}
void CGVisitableOPH::onHeroVisit( const CGHeroInstance * h ) const
{
if(visitors.find(h->id)==visitors.end())
@ -6586,6 +6606,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
b->val = 2-factions.size();
b->description = boost::str(boost::format(VLC->generaltexth->arraytxt[114]) % factions.size() % b->val); //Troops of %d alignments %d
}
boost::algorithm::trim(b->description);
//-1 modifier for any Necropolis unit in army
const ui8 UNDEAD_MODIFIER_ID = -2;
@ -6605,6 +6626,19 @@ void CArmedInstance::armyChanged()
updateMoraleBonusFromArmy();
}
CBonusSystemNode * CArmedInstance::whereShouldBeAttached(CGameState *gs)
{
if(tempOwner < PLAYER_LIMIT)
return gs->getPlayer(tempOwner);
else
return &gs->globalEffects;
}
CBonusSystemNode * CArmedInstance::whatShouldBeAttached()
{
return this;
}
bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const
{
switch(mode)