mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
Workaround for potential crash on opening town dwelling with no valid
creatures
This commit is contained in:
@ -849,7 +849,13 @@ void CCastleBuildings::enterCastleGate()
|
|||||||
|
|
||||||
void CCastleBuildings::enterDwelling(int level)
|
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)
|
auto recruitCb = [=](CreatureID id, int count)
|
||||||
{
|
{
|
||||||
LOCPLINT->cb->recruitCreatures(town, town->getUpperArmy(), id, count, level);
|
LOCPLINT->cb->recruitCreatures(town, town->getUpperArmy(), id, count, level);
|
||||||
|
Reference in New Issue
Block a user