check for connectedness in mapgen

This commit is contained in:
2025-02-22 21:11:24 -08:00
parent 0b7d447c5b
commit ec2e21c712

View File

@@ -168,7 +168,7 @@ export function generateMap(): LoadedNewMap {
if (e instanceof BadMapError) { if (e instanceof BadMapError) {
console.log(`Bad map generated: ${e.message}:`); console.log(`Bad map generated: ${e.message}:`);
showDebug(e.badMap); showDebug(e.badMap);
continue; // continue;
} }
throw e; throw e;
} }
@@ -604,6 +604,11 @@ function connectRegions(knife: Knife) {
connectors = connectors2; connectors = connectors2;
} }
knife.showDebug(merged); knife.showDebug(merged);
// The map should now be fully connected.
if (!knife.map.isConnected()) {
throw new BadMapError("unconnected", knife.map);
}
} }
function growMaze(knife: Knife, start: Point) { function growMaze(knife: Knife, start: Point) {