From eb794369b79a6e66a59ee88e5be3876331b720be Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 1 Dec 2024 18:03:01 +0100 Subject: small fixes --- project-base/src/logging.h | 2 +- src/scenes/world_map.c | 1 + src/world.c | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/project-base/src/logging.h b/project-base/src/logging.h index a6ae594..4cd6983 100644 --- a/project-base/src/logging.h +++ b/project-base/src/logging.h @@ -22,7 +22,7 @@ { char __buf[500]; \ sprintf(__buf, "%s, Assertion failed at %s, line %d. In %s\n", _message, __FILENAME__, __LINE__, __func__); \ printf(__buf); \ - MessageBox(0, __buf, "Error", MB_OK); exit(0); } + MessageBox(0, __buf, "Error", MB_OK); abort(); } #define log_info(_message) { char _____buf[4000]; sprintf(_____buf, "INFO: %s, at %s, line %d. In %s\n", _message, __FILENAME__, __LINE__, __func__); printf(_____buf); OutputDebugStringA(_____buf); } #endif diff --git a/src/scenes/world_map.c b/src/scenes/world_map.c index 2d9c32b..f96ba0e 100644 --- a/src/scenes/world_map.c +++ b/src/scenes/world_map.c @@ -868,6 +868,7 @@ static void world_map_draw_purchase_location_panel(platform_window* window) _active_world->money -= world_location_get_price(scene_data.location_to_purchase); + world_update_location_scores(_active_world); scene_state = WORLD_SCENE_STATE_IDLE; } 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