Merge pull request #798 from BenLubar/benlubar-civzone-num

set civzone number when constructing a civzone
develop
Lethosor 2016-01-18 15:55:17 -05:00
commit f61ff9147e
1 changed files with 20 additions and 0 deletions

@ -887,6 +887,21 @@ static int getMaxStockpileId()
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)
{
CHECK_NULL_POINTER(bld);
@ -903,6 +918,11 @@ bool Buildings::constructAbstract(df::building *bld)
stock->stockpile_number = getMaxStockpileId() + 1;
break;
case building_type::Civzone:
if (auto zone = strict_virtual_cast<df::building_civzonest>(bld))
zone->zone_num = getMaxCivzoneId() + 1;
break;
default:
break;
}