From 0a3ac6ef061de74cc635ae3068d954cbd72f1c33 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 1 Dec 2024 09:48:25 +0100 Subject: fix #11 again --- src/world.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/world.c b/src/world.c index e94e7c3..9eede87 100644 --- a/src/world.c +++ b/src/world.c @@ -721,6 +721,16 @@ static s32 world_get_max_depth_for_location(world_location* location) return location_depth; } +int compare( const void* a, const void* b) +{ + weekday int_a = * ( (int*) a ); + weekday int_b = * ( (int*) b ); + + if ( int_a == int_b ) return 0; + else if ( int_a < int_b ) return -1; + else return 1; +} + static void world_assign_new_job_offers(world* world, bool force) { for (s32 i = 0; i < world->locations.length; i++) @@ -754,6 +764,8 @@ static void world_assign_new_job_offers(world* world, bool force) s--; } } + // Sort for rendering order (because durations might overlap. see #11) + qsort(&new_offer.shipdays, amount_of_shipdays, sizeof(int), compare ); s32 max_depth = world_get_max_depth_for_location(location); s32 amount_of_connections = get_random_number(1, max_depth + 1) + 1; // +1 because we add original location to connection list. -- cgit v1.2.3-70-g09d2