From d10ae63aa7b9334ef17b71c3480f3bf2e6e0b223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 11 Jan 2021 22:50:14 +0100 Subject: [PATCH] Fix worldgen dims bug --- code/apps/server/header/blocks_info.h | 1 + code/apps/server/header/world.h | 2 +- code/apps/server/source/blocks_list.c | 1 + code/apps/server/source/world.c | 2 +- code/apps/server/source/world_gen.c | 14 ++++++++------ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/code/apps/server/header/blocks_info.h b/code/apps/server/header/blocks_info.h index de479c1..34a9aae 100644 --- a/code/apps/server/header/blocks_info.h +++ b/code/apps/server/header/blocks_info.h @@ -6,6 +6,7 @@ typedef enum { BLOCK_KIND_WATER, BLOCK_KIND_WALL, BLOCK_KIND_HILL, + BLOCK_KIND_HILL_SNOW, BLOCK_KIND_HOLE, } block_kind; diff --git a/code/apps/server/header/world.h b/code/apps/server/header/world.h index 2a305a2..01f6f9f 100644 --- a/code/apps/server/header/world.h +++ b/code/apps/server/header/world.h @@ -7,7 +7,7 @@ #define WORLD_ERROR_INVALID_DIMENSIONS -0x0003 #define WORLD_ERROR_INVALID_BUFFER -0x0004 -int32_t world_init(int32_t seed, uint8_t width, uint8_t height); +int32_t world_init(int32_t seed, uint32_t width, uint32_t height); int32_t world_destroy(void); uint32_t world_buf(uint8_t const **ptr, uint32_t *width); diff --git a/code/apps/server/source/blocks_list.c b/code/apps/server/source/blocks_list.c index 45d93c3..30c8d00 100644 --- a/code/apps/server/source/blocks_list.c +++ b/code/apps/server/source/blocks_list.c @@ -5,5 +5,6 @@ static block blocks[] = { {.tex_id = ATLAS_XY(0, 0), .name = "base-ground", .flags = 0, .kind = BLOCK_KIND_GROUND, .biome = 0, .symbol = '.'}, {.tex_id = ATLAS_XY(1, 0), .name = "base-wall", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_WALL, .biome = 0, .symbol = '#'}, {.tex_id = ATLAS_XY(2, 0), .name = "base-hill", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_HILL, .biome = 0, .symbol = '^'}, + {.tex_id = ATLAS_XY(3, 0), .name = "base-hill-snow", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_HILL_SNOW, .biome = 0, .symbol = '*'}, {.tex_id = ATLAS_XY(0, 1), .name = "base-water", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_WATER, .biome = 0, .symbol = '~'}, }; diff --git a/code/apps/server/source/world.c b/code/apps/server/source/world.c index e316967..822725b 100644 --- a/code/apps/server/source/world.c +++ b/code/apps/server/source/world.c @@ -9,7 +9,7 @@ static uint32_t world_height = 0; int32_t world_gen(); -int32_t world_init(int32_t seed, uint8_t width, uint8_t height) { +int32_t world_init(int32_t seed, uint32_t width, uint32_t height) { if (world) { world_destroy(); } diff --git a/code/apps/server/source/world_gen.c b/code/apps/server/source/world_gen.c index 441bef0..ed993d2 100644 --- a/code/apps/server/source/world_gen.c +++ b/code/apps/server/source/world_gen.c @@ -47,6 +47,9 @@ static WORLD_BLOCK_OBSERVER(shaper) { if (kind == BLOCK_KIND_WALL && kind == old_kind) { return blocks_find(biome, BLOCK_KIND_HILL); } + if (kind == BLOCK_KIND_HILL && kind == old_kind) { + return blocks_find(biome, BLOCK_KIND_HILL_SNOW); + } } return id; @@ -89,16 +92,15 @@ int32_t world_gen() { world_fill_rect(grnd_id, 1, 1, world_width-2, world_height-2, NULL); // water - for (int i=0; i