Address border wall issue reports

This commit is contained in:
chelsea
2026-05-02 21:54:12 -05:00
parent f93ebff0b9
commit d0f3c9a048
2 changed files with 46 additions and 18 deletions

Binary file not shown.

View File

@@ -181,6 +181,13 @@ static uint32_t hash_coords3(int x, int y, int z, uint32_t seed) {
return h ^ (h >> 16); return h ^ (h >> 16);
} }
static int floor_div_int(int value, int divisor) {
int q = value / divisor;
int r = value % divisor;
if (r != 0 && ((r < 0) != (divisor < 0))) q--;
return q;
}
static double land_value(worldgen_ctx *ctx, int x, int z) { static double land_value(worldgen_ctx *ctx, int x, int z) {
column_data col = get_column_data(ctx, x, z); column_data col = get_column_data(ctx, x, z);
double value = 0.0; double value = 0.0;
@@ -3611,14 +3618,8 @@ static void generate_chunk_border_wall(worldgen_ctx *ctx, int chunk_x, int chunk
if (ladder_offset < 0) ladder_offset = -ladder_offset; if (ladder_offset < 0) ladder_offset = -ladder_offset;
int near_corner = (dist_min_x < tower_depth || dist_max_x < tower_depth) && int near_corner = (dist_min_x < tower_depth || dist_max_x < tower_depth) &&
(dist_min_z < tower_depth || dist_max_z < tower_depth); (dist_min_z < tower_depth || dist_max_z < tower_depth);
int ladder_module = !near_corner && ladder_offset <= 1;
int ladder_face = !near_corner && ladder_offset == 0 && side_dist == wall_end + 1;
int ladder_trim = ladder_module && side_dist == wall_end + 1 && ladder_offset == 1;
int in_tower = side_dist >= tower_outer && side_dist <= tower_inner && int in_tower = side_dist >= tower_outer && side_dist <= tower_inner &&
(tower_offset <= tower_half_width || near_corner); (tower_offset <= tower_half_width || near_corner);
int in_wall = (side_dist >= wall_start && side_dist <= wall_end) || in_tower || ladder_face || ladder_trim;
int in_exterior_apron = side_dist < wall_start && !in_wall;
if (!in_wall && !in_exterior_apron) continue;
column_data data = get_column_data(ctx, world_x, world_z); column_data data = get_column_data(ctx, world_x, world_z);
int visible_base = data.height; int visible_base = data.height;
@@ -3627,6 +3628,14 @@ static void generate_chunk_border_wall(worldgen_ctx *ctx, int chunk_x, int chunk
} }
if (visible_base >= CHUNK_HEIGHT - 1) continue; if (visible_base >= CHUNK_HEIGHT - 1) continue;
int dry_ladder_site = !(data.has_water && data.height < data.water_surface);
int ladder_module = !near_corner && dry_ladder_site && ladder_offset <= 1;
int ladder_face = ladder_module && ladder_offset == 0 && side_dist == wall_end + 1;
int ladder_trim = ladder_module && side_dist == wall_end + 1 && ladder_offset == 1;
int in_wall = (side_dist >= wall_start && side_dist <= wall_end) || in_tower || ladder_face || ladder_trim;
int in_exterior_apron = side_dist < wall_start && !in_wall;
if (!in_wall && !in_exterior_apron) continue;
if (in_exterior_apron) { if (in_exterior_apron) {
for (int y = data.height + 1; y < CHUNK_HEIGHT; ++y) { for (int y = data.height + 1; y < CHUNK_HEIGHT; ++y) {
out->blocks[y][dx][dz] = BLOCK_AIR; out->blocks[y][dx][dz] = BLOCK_AIR;
@@ -3645,14 +3654,28 @@ static void generate_chunk_border_wall(worldgen_ctx *ctx, int chunk_x, int chunk
int center_x = world_x; int center_x = world_x;
int center_z = world_z; int center_z = world_z;
int base_along = (floor_div_int(along, tower_spacing) * tower_spacing) + tower_spacing / 2;
switch (side) { switch (side) {
case 0: center_x = ctx->wall_min_x + wall_center; break; case 0:
case 1: center_x = ctx->wall_max_x - wall_center; break; center_x = ctx->wall_min_x + wall_center;
case 2: center_z = ctx->wall_min_z + wall_center; break; center_z = base_along;
case 3: center_z = ctx->wall_max_z - wall_center; break; break;
case 1:
center_x = ctx->wall_max_x - wall_center;
center_z = base_along;
break;
case 2:
center_x = base_along;
center_z = ctx->wall_min_z + wall_center;
break;
case 3:
center_x = base_along;
center_z = ctx->wall_max_z - wall_center;
break;
} }
int smoothed_base = 0; int smoothed_base = 0;
int weight_sum = 0; int weight_sum = 0;
int highest_sample_base = 0;
const int sample_offsets[5] = {-32, -16, 0, 16, 32}; const int sample_offsets[5] = {-32, -16, 0, 16, 32};
const int sample_weights[5] = {1, 2, 4, 2, 1}; const int sample_weights[5] = {1, 2, 4, 2, 1};
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
@@ -3670,14 +3693,13 @@ static void generate_chunk_border_wall(worldgen_ctx *ctx, int chunk_x, int chunk
column_data sample = get_column_data(ctx, sx, sz); column_data sample = get_column_data(ctx, sx, sz);
int sample_base = sample.height; int sample_base = sample.height;
if (sample.has_water && sample.water_surface > sample_base) sample_base = sample.water_surface; if (sample.has_water && sample.water_surface > sample_base) sample_base = sample.water_surface;
if (i == 0 || sample_base > highest_sample_base) highest_sample_base = sample_base;
smoothed_base += sample_base * sample_weights[i]; smoothed_base += sample_base * sample_weights[i];
weight_sum += sample_weights[i]; weight_sum += sample_weights[i];
} }
smoothed_base /= weight_sum; smoothed_base /= weight_sum;
if (visible_base > smoothed_base + 8) { if (highest_sample_base > smoothed_base + 8) {
smoothed_base += (visible_base - smoothed_base - 8 + 3) / 4; smoothed_base += (highest_sample_base - smoothed_base - 8 + 1) / 2;
} else if (visible_base < smoothed_base - 16) {
smoothed_base -= (smoothed_base - visible_base - 16 + 4) / 5;
} }
if (smoothed_base < 1) smoothed_base = 1; if (smoothed_base < 1) smoothed_base = 1;
if (smoothed_base > CHUNK_HEIGHT - 2) smoothed_base = CHUNK_HEIGHT - 2; if (smoothed_base > CHUNK_HEIGHT - 2) smoothed_base = CHUNK_HEIGHT - 2;
@@ -3715,7 +3737,10 @@ static void generate_chunk_border_wall(worldgen_ctx *ctx, int chunk_x, int chunk
if (side_dist >= wall_center - 1 && side_dist <= wall_center + 1 && rel_y == height) { if (side_dist >= wall_center - 1 && side_dist <= wall_center + 1 && rel_y == height) {
block = BLOCK_STONE_BRICKS; block = BLOCK_STONE_BRICKS;
} }
if (ladder_face && rel_y >= 2 && rel_y <= height - 1) { if (ladder_face && rel_y >= 2 && rel_y <= height) {
if (rel_y == height) {
continue;
}
block = ladder_block; block = ladder_block;
} else if (ladder_trim && rel_y >= 2 && rel_y <= height - 1 && rel_y % 3 != 1) { } else if (ladder_trim && rel_y >= 2 && rel_y <= height - 1 && rel_y % 3 != 1) {
block = (rel_y % 6 == 0) ? BLOCK_BLACKSTONE : BLOCK_STONE_BRICKS; block = (rel_y % 6 == 0) ? BLOCK_BLACKSTONE : BLOCK_STONE_BRICKS;
@@ -3730,12 +3755,15 @@ static void generate_chunk_border_wall(worldgen_ctx *ctx, int chunk_x, int chunk
} }
set_block_with_height(out, dx, dz, y, block); set_block_with_height(out, dx, dz, y, block);
} }
if (top + 1 < CHUNK_HEIGHT && (side_dist == wall_start || side_dist == wall_end || in_tower) && if (top + 1 < CHUNK_HEIGHT) {
phase % 4 < 2) { if (!in_tower && (side_dist == wall_start || side_dist == wall_end)) {
set_block_with_height(out, dx, dz, top + 1, BLOCK_IRON_BARS);
} else if (in_tower && phase % 4 < 2) {
set_block_with_height(out, dx, dz, top + 1, BLOCK_STONE_BRICKS); set_block_with_height(out, dx, dz, top + 1, BLOCK_STONE_BRICKS);
} }
} }
} }
}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------