From d99ae5c05b10409d04afd8c8840124ef2621dc63 Mon Sep 17 00:00:00 2001 From: Emil Kosz Date: Wed, 24 Sep 2025 19:17:48 +0200 Subject: [PATCH] Better map uploading algorithm --- src/client/gfx_context.h | 1 + src/common/world.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client/gfx_context.h b/src/client/gfx_context.h index aea0259..413bc94 100644 --- a/src/client/gfx_context.h +++ b/src/client/gfx_context.h @@ -45,3 +45,4 @@ void GfxContext_render (GfxContext *self); void GfxContext_free (GfxContext * self); void GfxContext_cache_World (GfxContext * self, World * world); +void GfxContext_update_Players (GfxContext *self, World * world); diff --git a/src/common/world.c b/src/common/world.c index a825584..aebad54 100644 --- a/src/common/world.c +++ b/src/common/world.c @@ -65,21 +65,24 @@ World_load_from_file (const char *path) /* NULL is a palette, only used in indexed images. */ SDL_GetRGBA (pixel, details, NULL, &r, &g, &b, &a); - /* The ranges here can be tweaked to work better or - worse. */ - if (b > 196 && r < 50 && g < 50) + /* Improved color ranges (handles light blue water better) */ + if (b > 120 && (b > g || b > r)) { + /* Water: medium-to-light blues */ mt->terrain_type = TERRAIN_WATER; } - else if (g > 200) + else if (g > 140 && g >= r && g >= b) { + /* Green-dominant = flat/grassland */ mt->terrain_type = TERRAIN_FLAT; } else { + /* Otherwise: hills/mountains */ mt->terrain_type = TERRAIN_HILL; } - + /* Thanks, ChatGPT! */ + g_array_append_val (self->tiles, mt); } }