mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-29 21:56:54 +02:00
Fix game startup
This commit is contained in:
parent
cc30bdda04
commit
461c481ef3
@ -529,7 +529,7 @@ void CGameState::randomizeMapObjects()
|
||||
auto * hero = dynamic_cast<CGHeroInstance *>(object);
|
||||
auto * town = dynamic_cast<CGTownInstance *>(object);
|
||||
|
||||
if (hero)
|
||||
if (hero && hero->ID != Obj::PRISON)
|
||||
map->heroesOnMap.emplace_back(hero);
|
||||
|
||||
if (town)
|
||||
@ -579,7 +579,7 @@ void CGameState::placeStartingHero(const PlayerColor & playerColor, const HeroTy
|
||||
CGObjectInstance * hero = handler->create(handler->getTemplates().front());
|
||||
|
||||
hero->ID = Obj::HERO;
|
||||
hero->subID = VLC->heroh->objects[heroTypeId]->heroClass->getIndex();
|
||||
hero->subID = heroTypeId;
|
||||
hero->tempOwner = playerColor;
|
||||
|
||||
hero->pos = townPos;
|
||||
@ -1826,10 +1826,10 @@ void CGameState::buildBonusSystemTree()
|
||||
buildGlobalTeamPlayerTree();
|
||||
attachArmedObjects();
|
||||
|
||||
for(CGTownInstance *t : map->towns)
|
||||
{
|
||||
t->deserializationFix();
|
||||
}
|
||||
// for(CGTownInstance *t : map->towns)
|
||||
// {
|
||||
// t->deserializationFix();
|
||||
// }
|
||||
// CStackInstance <-> CCreature, CStackInstance <-> CArmedInstance, CArtifactInstance <-> CArtifact
|
||||
// are provided on initializing / deserializing
|
||||
|
||||
|
@ -189,6 +189,7 @@ void CGCreature::pickRandomObject(CRandomGenerator & rand)
|
||||
break;
|
||||
}
|
||||
ID = MapObjectID::MONSTER;
|
||||
setType(ID, subID);
|
||||
}
|
||||
|
||||
void CGCreature::initObj(CRandomGenerator & rand)
|
||||
|
@ -569,15 +569,17 @@ void CGHeroInstance::pickRandomObject(CRandomGenerator & rand)
|
||||
{
|
||||
ID = Obj::HERO;
|
||||
subID = cb->gameState()->pickNextHeroType(getOwner());
|
||||
type = VLC->heroh->objects[subID];
|
||||
randomizeArmy(type->heroClass->faction);
|
||||
}
|
||||
type = VLC->heroh->objects[subID];
|
||||
|
||||
// to find object handler we must use heroClass->id
|
||||
// after setType subID used to store unique hero identify id. Check issue 2277 for details
|
||||
setType(ID, type->heroClass->getIndex());
|
||||
if (ID != Obj::PRISON)
|
||||
{
|
||||
// to find object handler we must use heroClass->id
|
||||
// after setType subID used to store unique hero identify id. Check issue 2277 for details
|
||||
setType(ID, type->heroClass->getIndex());
|
||||
}
|
||||
this->subID = subID;
|
||||
|
||||
randomizeArmy(type->heroClass->faction);
|
||||
}
|
||||
|
||||
void CGHeroInstance::initObj(CRandomGenerator & rand)
|
||||
|
@ -122,7 +122,7 @@ std::set<int3> CGObjectInstance::getBlockedOffsets() const
|
||||
return appearance->getBlockedOffsets();
|
||||
}
|
||||
|
||||
void CGObjectInstance::setType(si32 newID, si32 newSubID)
|
||||
void CGObjectInstance::setType(MapObjectID newID, MapObjectSubID newSubID)
|
||||
{
|
||||
auto position = visitablePos();
|
||||
auto oldOffset = getVisitableOffset();
|
||||
|
@ -157,7 +157,7 @@ protected:
|
||||
virtual void setPropertyDer(ui8 what, ui32 val);
|
||||
|
||||
/// Called mostly during map randomization to turn random object into a regular one (e.g. "Random Monster" into "Pikeman")
|
||||
void setType(si32 ID, si32 subID);
|
||||
void setType(MapObjectID ID, MapObjectSubID subID);
|
||||
|
||||
/// Gives dummy bonus from this object to hero. Can be used to track visited state
|
||||
void giveDummyBonus(const ObjectInstanceID & heroID, BonusDuration::Type duration = BonusDuration::ONE_DAY) const;
|
||||
|
@ -255,6 +255,7 @@ void CGResource::pickRandomObject(CRandomGenerator & rand)
|
||||
{
|
||||
ID = Obj::RESOURCE;
|
||||
subID = rand.nextInt(EGameResID::WOOD, EGameResID::GOLD);
|
||||
setType(ID, subID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -735,6 +736,8 @@ void CGArtifact::pickRandomObject(CRandomGenerator & rand)
|
||||
|
||||
if (ID != Obj::SPELL_SCROLL)
|
||||
ID = MapObjectID::ARTIFACT;
|
||||
|
||||
setType(ID, subID);
|
||||
}
|
||||
|
||||
void CGArtifact::initObj(CRandomGenerator & rand)
|
||||
|
Loading…
x
Reference in New Issue
Block a user