mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +02:00
Fixed crash on visiting multi-creature dwellings (1874)
This commit is contained in:
parent
7e05945a6a
commit
69c6a3fa79
@ -34,13 +34,11 @@ void CGDwelling::initObj()
|
|||||||
|
|
||||||
if (getOwner() != PlayerColor::NEUTRAL)
|
if (getOwner() != PlayerColor::NEUTRAL)
|
||||||
cb->gameState()->players[getOwner()].dwellings.push_back (this);
|
cb->gameState()->players[getOwner()].dwellings.push_back (this);
|
||||||
}
|
|
||||||
//putStack(SlotID(0), new CStackInstance(CreatureID::GOLD_GOLEM, 9));
|
|
||||||
//putStack(SlotID(1), new CStackInstance(CreatureID::DIAMOND_GOLEM, 6));
|
|
||||||
|
|
||||||
//putStack(SlotID(0), new CStackInstance(CreatureID::EARTH_ELEMENTAL, 12));
|
assert(!creatures.empty());
|
||||||
|
assert(!creatures[0].second.empty());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Obj::REFUGEE_CAMP:
|
case Obj::REFUGEE_CAMP:
|
||||||
//is handled within newturn func
|
//is handled within newturn func
|
||||||
break;
|
break;
|
||||||
|
@ -158,7 +158,9 @@ void CDwellingInstanceConstructor::initTypeData(const JsonNode & input)
|
|||||||
availableCreatures[i][j] = VLC->creh->creatures[index];
|
availableCreatures[i][j] = VLC->creh->creatures[index];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
assert(!availableCreatures[i].empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
guards = input["guards"];
|
guards = input["guards"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,10 +187,11 @@ void CDwellingInstanceConstructor::configureObject(CGObjectInstance * object, CR
|
|||||||
CGDwelling * dwelling = dynamic_cast<CGDwelling*>(object);
|
CGDwelling * dwelling = dynamic_cast<CGDwelling*>(object);
|
||||||
|
|
||||||
dwelling->creatures.clear();
|
dwelling->creatures.clear();
|
||||||
dwelling->creatures.resize(availableCreatures.size());
|
dwelling->creatures.reserve(availableCreatures.size());
|
||||||
|
|
||||||
for (auto & entry : availableCreatures)
|
for (auto & entry : availableCreatures)
|
||||||
{
|
{
|
||||||
|
dwelling->creatures.resize(dwelling->creatures.size() + 1);
|
||||||
for (const CCreature * cre : entry)
|
for (const CCreature * cre : entry)
|
||||||
dwelling->creatures.back().second.push_back(cre->idNumber);
|
dwelling->creatures.back().second.push_back(cre->idNumber);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user