set civzone number when constructing a civzone

develop
Ben Lubar 2016-01-18 14:41:57 -06:00
parent 0b2ba377be
commit 675d173266
1 changed files with 20 additions and 0 deletions

@ -887,6 +887,21 @@ static int getMaxStockpileId()
return max_id; return max_id;
} }
static int getMaxCivzoneId()
{
auto &vec = world->buildings.other[buildings_other_id::ANY_ZONE];
int max_id = 0;
for (size_t i = 0; i < vec.size(); i++)
{
auto bld = strict_virtual_cast<df::building_civzonest>(vec[i]);
if (bld)
max_id = std::max(max_id, bld->zone_num);
}
return max_id;
}
bool Buildings::constructAbstract(df::building *bld) bool Buildings::constructAbstract(df::building *bld)
{ {
CHECK_NULL_POINTER(bld); CHECK_NULL_POINTER(bld);
@ -903,6 +918,11 @@ bool Buildings::constructAbstract(df::building *bld)
stock->stockpile_number = getMaxStockpileId() + 1; stock->stockpile_number = getMaxStockpileId() + 1;
break; break;
case building_type::Civzone:
if (auto zone = strict_virtual_cast<df::building_civzonest>(bld))
zone->zone_num = getMaxCivzoneId() + 1;
break;
default: default:
break; break;
} }