Skip to content

Commit

Permalink
improved logging
Browse files Browse the repository at this point in the history
removed unnecessary assignment logging, added more useful ones
  • Loading branch information
Doubleumc committed Aug 18, 2024
1 parent f6d74b9 commit f738869
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions code/game/jobs/role_authority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
unassigned_players = null
return

log_debug("ASSIGNMENT: Building player_weights list.")
var/list/player_weights = list()
for(var/mob/new_player/cycled_unassigned in unassigned_players)
var/debug_total_weight = 0
for(var/mob/new_player/cycled_unassigned as anything in unassigned_players)
var/base_weight = 1 //baseline weighting

var/new_bonus = 0
Expand All @@ -238,8 +238,14 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
var/streak_bonus = max(get_client_stat(cycled_unassigned.client, PLAYER_STAT_UNASSIGNED_ROUND_STREAK) - 2, 0) //+1 per missed round after 2

player_weights[cycled_unassigned] = base_weight + new_bonus + streak_bonus
debug_total_weight += player_weights[cycled_unassigned]
log_debug("ASSIGNMENT: player_weights generated with [length(player_weights)] players and [debug_total_weight] total weight.")

unassigned_players = shuffle_weight(player_weights)
var/list/debug_weight_order = list()
for(var/mob/new_player/cycled_unassigned as anything in unassigned_players)
debug_weight_order += player_weights[cycled_unassigned]
log_debug("ASSIGNMENT: unassigned_players by entry weight: ([debug_weight_order.Join(", ")])")

// How many positions do we open based on total pop
for(var/i in roles_by_name)
Expand Down Expand Up @@ -286,17 +292,13 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
break

if(!player_assigned_job)
log_debug("ASSIGNMENT: [cycled_unassigned] was unable to be assigned a job based on preferences and roles to assign. Attempting alternate options.")

switch(cycled_unassigned.client.prefs.alternate_option)
if(GET_RANDOM_JOB)
log_debug("ASSIGNMENT: [cycled_unassigned] has opted for random job alternate option. Finding random job.")
var/iterator = 0
while((cycled_unassigned in unassigned_players) || iterator >= 5)
iterator++
var/random_job_name = pick(roles_to_assign)
var/datum/job/random_job = roles_to_assign[random_job_name]
log_debug("ASSIGNMENT: [cycled_unassigned] is attempting to be assigned to [random_job_name].")

if(assign_role(cycled_unassigned, random_job))
log_debug("ASSIGNMENT: We have randomly assigned [random_job_name] to [cycled_unassigned]")
Expand All @@ -311,7 +313,6 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
log_debug("ASSIGNMENT: [cycled_unassigned] was unable to be randomly assigned a job. Something has gone wrong.")

if(BE_MARINE)
log_debug("ASSIGNMENT: [cycled_unassigned] has opted for marine alternate option. Checking if slot is available.")
var/datum/job/marine_job = GET_MAPPED_ROLE(JOB_SQUAD_MARINE)
if(assign_role(cycled_unassigned, marine_job))
log_debug("ASSIGNMENT: We have assigned [marine_job.title] to [cycled_unassigned] via alternate option.")
Expand All @@ -335,18 +336,15 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
return roles_to_assign

/datum/authority/branch/role/proc/assign_role_to_player_by_priority(mob/new_player/cycled_unassigned, list/roles_to_assign, list/unassigned_players, priority)
log_debug("ASSIGNMENT: We have started cycled through priority [priority] for [cycled_unassigned].")
var/wanted_jobs_by_name = shuffle(cycled_unassigned.client.prefs.get_jobs_by_priority(priority))
var/player_assigned_job = FALSE

for(var/job_name in wanted_jobs_by_name)
log_debug("ASSIGNMENT: We are cycling through wanted jobs and are at [job_name] for [cycled_unassigned].")
if(job_name in roles_to_assign)
log_debug("ASSIGNMENT: We have found [job_name] in roles to assign for [cycled_unassigned].")
var/datum/job/actual_job = roles_to_assign[job_name]

if(assign_role(cycled_unassigned, actual_job))
log_debug("ASSIGNMENT: We have assigned [job_name] to [cycled_unassigned].")
log_debug("ASSIGNMENT: We have assigned [job_name] to [cycled_unassigned] at priority [priority].")
cycled_unassigned.client.player_data?.adjust_stat(PLAYER_STAT_UNASSIGNED_ROUND_STREAK, STAT_CATEGORY_MISC, 0, TRUE)
unassigned_players -= cycled_unassigned

Expand All @@ -358,10 +356,8 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
break

if(player_assigned_job)
log_debug("ASSIGNMENT: [cycled_unassigned] has been assigned a job.")
return player_assigned_job

log_debug("ASSIGNMENT: [cycled_unassigned] did not get a job at priority [priority].")
return player_assigned_job

/**
Expand Down

0 comments on commit f738869

Please sign in to comment.