From eb794369b79a6e66a59ee88e5be3876331b720be Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 1 Dec 2024 18:03:01 +0100 Subject: small fixes --- src/world.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/world.c') diff --git a/src/world.c b/src/world.c index 7ff0e19..e9401b4 100644 --- a/src/world.c +++ b/src/world.c @@ -119,6 +119,7 @@ static void connect_locations(world* world, char* str1, char* str2) world_location* loc2 = world_get_location_by_name(world, str2); array_push(&loc1->connections, &loc2); + array_push(&loc2->connections, &loc1); } static void world_create_manual_connections(world* world) @@ -559,7 +560,7 @@ world* world_create_new() world* new_world = mem_alloc(sizeof(world)); new_world->simulation_time = time(NULL); new_world->start_year = gmtime(&new_world->simulation_time)->tm_year; - new_world->money = 10000000.0f; + new_world->money = 100000.0f; new_world->next_id = 1; new_world->active_jobs = array_create(sizeof(active_job)); new_world->investments = (company_investments){0}; @@ -1225,9 +1226,9 @@ static world_location* get_random_owned_location(world* world) { world_location* location = array_at(&world->locations, i); if (!location->is_owned) continue; - count++; if (count == rand_nr) return location; + count++; } return 0; } @@ -1268,6 +1269,7 @@ static float get_fine_multiplier(world* world) static void give_random_fine(world* world) { world_location* location = get_random_owned_location(world); + if (location->employees.length == 0) return; employee* emp = *(employee**)array_at(&location->employees, get_random_number(0, location->employees.length)); s32 fine = get_random_number(world->money / 20, world->money / 10) * get_fine_multiplier(world); // fine is between 5% and 10% of current money. minimum 2k. @@ -1289,6 +1291,7 @@ static void brake_down_random_truck(world* world) { retry:; world_location* location = get_random_owned_location(world); + if (location->employees.length == 0) return; employee* emp = *(employee**)array_at(&location->employees, get_random_number(0, location->employees.length)); if (emp->assigned_truck == 0) goto retry; @@ -1542,10 +1545,10 @@ void world_update(platform_window* window, world* world) { static float delta = 0; delta += frame_delta; - //if (delta >= (1/60.0f)) { // tick runs at 60 ticks per second regardless of fps. + if (delta >= (1/60.0f)) { // tick runs at 60 ticks per second regardless of fps. world_run_simulation_tick(world); delta = 0; - //} + } } static vec2f get_world_location_for_job(platform_window* window, world* world, active_job* job) -- cgit v1.2.3-70-g09d2