mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed desync due to uninitialized objects. Added some logging. RMG maps don't work yet, though.
This commit is contained in:
parent
3acbda75ef
commit
fe292dfa1d
@ -1849,7 +1849,10 @@ void CGameState::initMapObjects()
|
||||
for(CGObjectInstance *obj : map->objects)
|
||||
{
|
||||
if(obj)
|
||||
{
|
||||
logGlobal->traceStream() << boost::format ("Calling Init for object %d, %d") % obj->ID % obj->subID;
|
||||
obj->initObj();
|
||||
}
|
||||
}
|
||||
for(CGObjectInstance *obj : map->objects)
|
||||
{
|
||||
@ -3518,5 +3521,6 @@ CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance
|
||||
|
||||
CRandomGenerator & CGameState::getRandomGenerator()
|
||||
{
|
||||
logGlobal->traceStream() << "Fetching CGameState::rand with seed " << rand.nextInt();
|
||||
return rand;
|
||||
}
|
||||
|
@ -271,6 +271,8 @@ BankConfig CBankInstanceConstructor::generateConfig(const JsonNode & level, CRan
|
||||
|
||||
void CBankInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const
|
||||
{
|
||||
//logGlobal->debugStream() << "Seed used to configure bank is " << rng.nextInt();
|
||||
|
||||
auto bank = dynamic_cast<CBank*>(object);
|
||||
|
||||
bank->resetDuration = bankResetDuration;
|
||||
@ -282,6 +284,7 @@ void CBankInstanceConstructor::configureObject(CGObjectInstance * object, CRando
|
||||
assert(totalChance != 0);
|
||||
|
||||
si32 selectedChance = rng.nextInt(totalChance - 1);
|
||||
//logGlobal->debugStream() << "Selected chance for bank config is " << selectedChance;
|
||||
|
||||
for (auto & node : levels)
|
||||
{
|
||||
|
@ -632,6 +632,11 @@ std::string CGResource::getHoverText(PlayerColor player) const
|
||||
return VLC->generaltexth->restypes[subID];
|
||||
}
|
||||
|
||||
CGResource::CGResource()
|
||||
{
|
||||
amount = 0;
|
||||
}
|
||||
|
||||
void CGResource::initObj()
|
||||
{
|
||||
blockVisit = true;
|
||||
|
@ -182,6 +182,7 @@ public:
|
||||
ui32 amount; //0 if random
|
||||
std::string message;
|
||||
|
||||
CGResource();
|
||||
void onHeroVisit(const CGHeroInstance * h) const override;
|
||||
void initObj() override;
|
||||
void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
|
||||
|
@ -620,6 +620,7 @@ bool CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength,
|
||||
auto guard = new CGCreature();
|
||||
guard->ID = Obj::MONSTER;
|
||||
guard->subID = creId;
|
||||
guard->character = 1; //MUST be initialized or switch will diverge
|
||||
auto hlp = new CStackInstance(creId, amount);
|
||||
//will be set during initialization
|
||||
guard->putStack(SlotID(0), hlp);
|
||||
|
Loading…
Reference in New Issue
Block a user