1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Workaround for potential crash on opening town dwelling with no valid

creatures
This commit is contained in:
Ivan Savenko 2023-08-06 12:46:29 +03:00
parent a81f18765c
commit 0dca5c45bd

View File

@ -849,7 +849,13 @@ void CCastleBuildings::enterCastleGate()
void CCastleBuildings::enterDwelling(int level)
{
assert(level >= 0 && level < town->creatures.size());
if (level < 0 || level >= town->creatures.size() || town->creatures[level].second.empty())
{
assert(0);
logGlobal->error("Attempt to enter into invalid dwelling of level %d in town %s (%s)", level, town->getNameTranslated(), town->town->faction->getNameTranslated());
return;
}
auto recruitCb = [=](CreatureID id, int count)
{
LOCPLINT->cb->recruitCreatures(town, town->getUpperArmy(), id, count, level);