mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
parent
79592d6fbb
commit
a3bfde9a41
@ -1276,9 +1276,9 @@ void CGDwelling::setProperty(ui8 what, ui32 val)
|
||||
if (val != NEUTRAL_PLAYER) //can new owner be neutral?
|
||||
cb->gameState()->players[val].dwellings.push_back (this);
|
||||
}
|
||||
tempOwner = val;
|
||||
break;
|
||||
}
|
||||
CGObjectInstance::setProperty(what,val);
|
||||
}
|
||||
void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
|
@ -429,7 +429,11 @@ public:
|
||||
{
|
||||
h & static_cast<CGDwelling&>(*this);
|
||||
h & name & builded & destroyed & identifier & alignment & forbiddenBuildings & builtBuildings
|
||||
& possibleSpells & obligatorySpells & spells & /*strInfo & */events;
|
||||
& possibleSpells & obligatorySpells & spells & /*strInfo & */events & bonusingBuildings;
|
||||
|
||||
for (std::vector<CGTownBuilding*>::iterator i = bonusingBuildings.begin(); i!=bonusingBuildings.end(); i++)
|
||||
(*i)->town = this;
|
||||
|
||||
|
||||
ui8 standardType = (&VLC->townh->towns[subID] == town);
|
||||
h & standardType;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef __CGAMESTATE_H__
|
||||
#define __CGAMESTATE_H__
|
||||
#include "../global.h"
|
||||
#include <cassert>
|
||||
#ifndef _MSC_VER
|
||||
#include "../hch/CCreatureHandler.h"
|
||||
#include "VCMI_Lib.h"
|
||||
@ -81,7 +82,17 @@ public:
|
||||
size = availableHeroes.size();
|
||||
h & size;
|
||||
for(size_t i=0; i < size; i++)
|
||||
h & availableHeroes[i]->subID;
|
||||
{
|
||||
if(availableHeroes[i])
|
||||
{
|
||||
h & availableHeroes[i]->subID;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui32 none = 0xffffffff;
|
||||
h & none;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -390,7 +401,15 @@ public:
|
||||
{
|
||||
ui32 hlp = i->second.availableHeroes[j]->subID;
|
||||
delete i->second.availableHeroes[j];
|
||||
i->second.availableHeroes[j] = hpool.heroesPool[hlp];
|
||||
if(hlp != 0xffffffff)
|
||||
{
|
||||
assert(vstd::contains(hpool.heroesPool, hlp));
|
||||
i->second.availableHeroes[j] = hpool.heroesPool[hlp];
|
||||
}
|
||||
else
|
||||
{
|
||||
i->second.availableHeroes[j] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user