Improve cabin ladders and paths
This commit is contained in:
Binary file not shown.
@@ -1624,6 +1624,7 @@ static void build_cabin_rect(worldgen_ctx *ctx, const cabin_blueprint *bp, const
|
|||||||
if (story_floor >= CHUNK_HEIGHT - 4) break;
|
if (story_floor >= CHUNK_HEIGHT - 4) break;
|
||||||
for (int wz = z0 + 1; wz <= z1 - 1; ++wz) {
|
for (int wz = z0 + 1; wz <= z1 - 1; ++wz) {
|
||||||
for (int wx = x0 + 1; wx <= x1 - 1; ++wx) {
|
for (int wx = x0 + 1; wx <= x1 - 1; ++wx) {
|
||||||
|
if (story > 0 && wx == ladder_hole_x && wz == ladder_hole_z) continue;
|
||||||
int lx = wx - chunk_origin_x;
|
int lx = wx - chunk_origin_x;
|
||||||
int lz = wz - chunk_origin_z;
|
int lz = wz - chunk_origin_z;
|
||||||
if (lx < 0 || lx >= CHUNK_SIZE || lz < 0 || lz >= CHUNK_SIZE) continue;
|
if (lx < 0 || lx >= CHUNK_SIZE || lz < 0 || lz >= CHUNK_SIZE) continue;
|
||||||
@@ -1952,11 +1953,24 @@ static void connect_cabin_to_trail(worldgen_ctx *ctx, int chunk_x, int chunk_z,
|
|||||||
int step_z = (door_side == 0) ? -1 : (door_side == 1) ? 1 : 0;
|
int step_z = (door_side == 0) ? -1 : (door_side == 1) ? 1 : 0;
|
||||||
int start_x = door_x + step_x;
|
int start_x = door_x + step_x;
|
||||||
int start_z = door_z + step_z;
|
int start_z = door_z + step_z;
|
||||||
int spur_len = 6;
|
int spur_len = 12;
|
||||||
if (path_width < 2) path_width = 2;
|
if (path_width < 2) path_width = 2;
|
||||||
carve_cabin_path(ctx, chunk_x, chunk_z, chunk, columns, start_x, start_z, step_x, step_z, spur_len, path_width);
|
carve_cabin_path(ctx, chunk_x, chunk_z, chunk, columns, start_x, start_z, step_x, step_z, spur_len, path_width);
|
||||||
int target_x = 0, target_z = 0;
|
int target_x = 0, target_z = 0;
|
||||||
if (!find_nearest_trail_block(columns, chunk, chunk_x, chunk_z, start_x, start_z, 48, &target_x, &target_z)) {
|
if (!find_nearest_trail_block(columns, chunk, chunk_x, chunk_z, start_x, start_z, 48, &target_x, &target_z)) {
|
||||||
|
/* Fallback: extend a spur toward chunk edge */
|
||||||
|
int edge_len = 32;
|
||||||
|
int fallback_x = start_x + step_x * edge_len;
|
||||||
|
int fallback_z = start_z + step_z * edge_len;
|
||||||
|
int chunk_min_x = chunk_x * CHUNK_SIZE;
|
||||||
|
int chunk_max_x = chunk_min_x + CHUNK_SIZE - 1;
|
||||||
|
int chunk_min_z = chunk_z * CHUNK_SIZE;
|
||||||
|
int chunk_max_z = chunk_min_z + CHUNK_SIZE - 1;
|
||||||
|
if (fallback_x < chunk_min_x + 1) fallback_x = chunk_min_x + 1;
|
||||||
|
if (fallback_x > chunk_max_x - 1) fallback_x = chunk_max_x - 1;
|
||||||
|
if (fallback_z < chunk_min_z + 1) fallback_z = chunk_min_z + 1;
|
||||||
|
if (fallback_z > chunk_max_z - 1) fallback_z = chunk_max_z - 1;
|
||||||
|
carve_trail_span(ctx, chunk_x, chunk_z, chunk, columns, start_x, start_z, fallback_x, fallback_z, path_width);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
carve_trail_span(ctx, chunk_x, chunk_z, chunk, columns, start_x, start_z, target_x, target_z, path_width > 0 ? path_width : 2);
|
carve_trail_span(ctx, chunk_x, chunk_z, chunk, columns, start_x, start_z, target_x, target_z, path_width > 0 ? path_width : 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user