summaryrefslogtreecommitdiff
path: root/src/world.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c19
1 files changed, 19 insertions, 0 deletions
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) {