1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Patch from Yupsi. Hero sleep/wake-up. Fixes #162 and #601.

This commit is contained in:
Frank Zago
2011-09-24 16:46:23 +00:00
parent 6dd9d416b4
commit 01566fcde1
5 changed files with 101 additions and 15 deletions

View File

@ -1094,6 +1094,23 @@ template <typename Handler> void CPlayerInterface::serializeTempl( Handler &h, c
h & playerID;
h & sysOpts;
h & spellbookSettings;
ui8 sleepingSize;
if(h.saving)
sleepingSize = sleepingHeroes.size();
h & sleepingSize;
for (int i = 0; i < sleepingSize; i++)
{
si32 hid;
if (h.saving)
hid = sleepingHeroes[i]->id;
h & hid;
if (!h.saving)
{
const CGHeroInstance *hero = cb->getHero(hid);
sleepingHeroes += hero;
}
}
}
void CPlayerInterface::serialize( COSer<CSaveFile> &h, const int version )
@ -1115,6 +1132,15 @@ bool CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path )
if (!h)
return false; //can't find hero
if (adventureInt && adventureInt->isHeroSleeping(h))
{
adventureInt->sleepWake.clickLeft(true, false);
adventureInt->sleepWake.clickLeft(false, true);
//could've just called
//adventureInt->fsleepWake();
//but no authentic button click/sound ;-)
}
//evil...
eventsM.unlock();
pim->unlock();