int originZ = platmap.originZ;
// clean up the platmap of singletons and odd road structures
for (int x = 0; x < PlatMap.Width; x++) {
for (int z = 0; z < PlatMap.Width; z++) {
PlatLot current = platmap.getLot(x, z);
// something here?
if (current == null) {
// but there aren't neighbors
if (!platmap.isEmptyLot(x - 1, z) && !platmap.isEmptyLot(x + 1, z) &&
!platmap.isEmptyLot(x, z - 1) && !platmap.isEmptyLot(x, z + 1))
platmap.recycleLot(x, z);
}
// look for singleton nature and roundabouts
else {
// if a single natural thing is here but surrounded by four "things"
if (current.style == LotStyle.NATURE &&
platmap.isEmptyLot(x - 1, z) && platmap.isEmptyLot(x + 1, z) &&
platmap.isEmptyLot(x, z - 1) && platmap.isEmptyLot(x, z + 1))
platmap.emptyLot(x, z);
// get rid of roundabouts
else if (current.style == LotStyle.ROUNDABOUT) {
platmap.paveLot(x, z, false);
platmap.emptyLot(x - 1, z - 1);
platmap.emptyLot(x - 1, z + 1);
platmap.emptyLot(x + 1, z - 1);
platmap.emptyLot(x + 1, z + 1);
}
}
}
}
// let the user add their stuff first
getSchematics(generator).populate(generator, platmap);
// backfill with farms and a single house
for (int x = 0; x < PlatMap.Width; x++) {
for (int z = 0; z < PlatMap.Width; z++) {
PlatLot current = platmap.getLot(x, z);
if (current == null) {
//TODO Barns and Wells
// farm house here?
if (!housePlaced && platmapOdds.playOdds(oddsOfFarmHouse) && generator.settings.includeHouses) {
housePlaced = platmap.setLot(x, z, getHouseLot(generator, platmap, platmapOdds, originX + lastX, originZ + lastZ));
// place the farm
} else {
// place the farm
current = getFarmLot(generator, platmap, platmapOdds, originX + x, originZ + z);
// see if the previous chunk is the same type
PlatLot previous = null;
if (x > 0 && current.isConnectable(platmap.getLot(x - 1, z))) {
previous = platmap.getLot(x - 1, z);
} else if (z > 0 && current.isConnectable(platmap.getLot(x, z - 1))) {
previous = platmap.getLot(x, z - 1);
}