diff --git a/code/apps/server/source/world.c b/code/apps/server/source/world.c index 0cd7e00..e316967 100644 --- a/code/apps/server/source/world.c +++ b/code/apps/server/source/world.c @@ -2,23 +2,27 @@ #include "zpl.h" static uint8_t *world = NULL; +static uint32_t world_seed = 0; static uint32_t world_size = 0; static uint32_t world_width = 0; static uint32_t world_height = 0; +int32_t world_gen(); + int32_t world_init(int32_t seed, uint8_t width, uint8_t height) { if (world) { world_destroy(); } - world_size = width*height; + world_seed = seed; world_width = width; world_height = height; + world_size = width*height; world = zpl_malloc(sizeof(uint8_t)*world_size); if (!world) { return WORLD_ERROR_OUTOFMEM; } - return world_gen(world, world_size, world_width, world_height, seed); + return world_gen(); } int32_t world_destroy(void) { diff --git a/code/apps/server/source/world_gen.c b/code/apps/server/source/world_gen.c index da910c7..2385cd5 100644 --- a/code/apps/server/source/world_gen.c +++ b/code/apps/server/source/world_gen.c @@ -1,5 +1,6 @@ #include "world.h" #include "blocks.h" +#include "perlin.h" #include "zpl.h" #include @@ -7,6 +8,9 @@ #define WORLD_BLOCK_OBSERVER(name) uint32_t name(uint32_t id, uint32_t block_idx) typedef WORLD_BLOCK_OBSERVER(world_block_observer_proc); +#define WORLD_PERLIN_FREQ 1.0 +#define WORLD_PERLIN_OCTAVES 1 + static void world_fill_rect(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, world_block_observer_proc *proc) { for (uint32_t cy=y; cy