diff --git a/worldgen-c/bin/worldgen b/worldgen-c/bin/worldgen index 7b846df..6deca14 100755 Binary files a/worldgen-c/bin/worldgen and b/worldgen-c/bin/worldgen differ diff --git a/worldgen-c/src/worldgen.c b/worldgen-c/src/worldgen.c index a227e6e..39fca6e 100644 --- a/worldgen-c/src/worldgen.c +++ b/worldgen-c/src/worldgen.c @@ -133,6 +133,7 @@ static void generate_chunk_cabins(worldgen_ctx *ctx, int chunk_x, int chunk_z, c static void trail_node_position(worldgen_ctx *ctx, int node_x, int node_z, double spacing, double *out_x, double *out_z); static void carve_trail_pad(worldgen_ctx *ctx, int chunk_x, int chunk_z, chunk_data *out, column_data columns[CHUNK_SIZE][CHUNK_SIZE], int center_x, int center_z, int radius, int target_height); static void carve_trail_span(worldgen_ctx *ctx, int chunk_x, int chunk_z, chunk_data *out, column_data columns[CHUNK_SIZE][CHUNK_SIZE], int x0, int z0, int x1, int z1, int width); +static int build_trail_path(worldgen_ctx *ctx, double ax, double az, double bx, double bz, int **out_points, int *out_count); static double old_growth_plains_mask(worldgen_ctx *ctx, int x, int z); static double old_growth_grove_mask(worldgen_ctx *ctx, int x, int z); static uint16_t generate_normal_ores(worldgen_ctx *ctx, int x, int y, int z, const column_data *col); @@ -1957,13 +1958,27 @@ static void connect_cabin_to_trail(worldgen_ctx *ctx, int chunk_x, int chunk_z, 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); int target_x = 0, target_z = 0; - if (!find_nearest_trail_block(columns, chunk, chunk_x, chunk_z, start_x, start_z, 64, &target_x, &target_z)) { - int fallback_x = start_x + step_x * 48; - int fallback_z = start_z + step_z * 48; + if (!find_nearest_trail_block(columns, chunk, chunk_x, chunk_z, start_x, start_z, 96, &target_x, &target_z)) { + int fallback_x = start_x + step_x * 64; + int fallback_z = start_z + step_z * 64; carve_trail_span(ctx, chunk_x, chunk_z, chunk, columns, start_x, start_z, fallback_x, fallback_z, path_width); 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); + + int *pts = NULL; + int count = 0; + if (build_trail_path(ctx, (double)start_x, (double)start_z, (double)target_x, (double)target_z, &pts, &count) && pts && count >= 2) { + for (int i = 1; i < count; ++i) { + int x0 = pts[(i - 1) * 2]; + int z0 = pts[(i - 1) * 2 + 1]; + int x1 = pts[i * 2]; + int z1 = pts[i * 2 + 1]; + carve_trail_span(ctx, chunk_x, chunk_z, chunk, columns, x0, z0, x1, z1, path_width); + } + free(pts); + } else { + carve_trail_span(ctx, chunk_x, chunk_z, chunk, columns, start_x, start_z, target_x, target_z, path_width); + } } static uint16_t generate_normal_ores(worldgen_ctx *ctx, int x, int y, int z, const column_data *col) {