From 395aa3f2b53550b9575dde1f5d2fb7494c21addf Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Thu, 5 Dec 2024 13:17:27 +0100 Subject: close #55 --- src/world.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/world.c') diff --git a/src/world.c b/src/world.c index bd04a52..a19e924 100644 --- a/src/world.c +++ b/src/world.c @@ -12,6 +12,7 @@ static void end_contract_with_employee(world* world, employee* emp); vec2f px_to_coords(platform_window* window, double x, double y); static bool world_check_location_accessibility(world_location* orig, world_location* source, int depth, double dist); static void world_update_location_scores(world* world); +static float get_worked_hours_per_week_for_employee(world* world, employee* emp, scheduled_job* excluding); float dotsize = 5; @@ -1010,6 +1011,24 @@ static float get_shiptime_factor(employee* emp) return shiptime_factor; } +employee* world_get_most_available_employee_for_location(world* world, world_location* loc) +{ + float best_match_hours = 99999.0f; + employee* best_match = 0; + for (s32 i = 0; i < loc->employees.length; i++) + { + employee* em = *(employee**)array_at(&loc->employees, i); + if (em->assigned_truck == 0) continue; + float hours_worked = get_worked_hours_per_week_for_employee(world, em, 0); + if (hours_worked < best_match_hours) { + best_match_hours = hours_worked; + best_match = em; + } + } + + return best_match; +} + static void world_start_scheduled_job(world* world, scheduled_job* scheduled_job, scheduled_job_time scheduled_time) { if (!scheduled_time.assignee) { -- cgit v1.2.3-70-g09d2