1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Hopefully fixed #261, #263, #246.

This commit is contained in:
Michał W. Urbańczyk
2009-12-01 21:05:57 +00:00
parent 79592d6fbb
commit a3bfde9a41
4 changed files with 34 additions and 11 deletions

View File

@@ -2441,22 +2441,22 @@ bool CGameHandler::hireHero( ui32 tid, ui8 hid )
hr.tile = t->pos - int3(1,0,0);
sendAndApply(&hr);
std::map<ui32,CGHeroInstance *> pool = gs->hpool.heroesPool;
for ( std::map<ui8, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
for(std::vector<CGHeroInstance *>::iterator j = i->second.availableHeroes.begin(); j != i->second.availableHeroes.end(); j++)
if(*j)
pool.erase((**j).subID);
SetAvailableHeroes sah;
CGHeroInstance *h1 = gs->hpool.pickHeroFor(false,t->tempOwner,t->town, pool), //new hero
CGHeroInstance *h1 = gs->hpool.pickHeroFor(false,t->tempOwner,t->town, pool),
*h2 = gs->getPlayer(t->tempOwner)->availableHeroes[!hid];
(hid ? sah.hid2 : sah.hid1) = h1 ? h1->subID : -1;
(hid ? sah.hid1 : sah.hid2) = h2 ? h2->subID : -1;
sah.player = t->tempOwner;
//sah.flags = hid+1; //without army - why?
sah.flags = hid+1;
sendAndApply(&sah);
for ( std::map<ui8, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
for(std::vector<CGHeroInstance *>::iterator j = i->second.availableHeroes.begin(); j != i->second.availableHeroes.end(); j++)
if(*j)
pool.erase((**j).subID); //hero is removed from available lists
SetResource sr;
sr.player = t->tempOwner;
sr.resid = 6;