From 3ab308aa0f8f3be657fce5fe1eb0dbb588292aa4 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Wed, 22 Feb 2017 09:55:50 -0500 Subject: [PATCH] Makes game start smoother (#23552) * Makes game start smoother * Hide the sausage making * Fix the shit * Fixes AI's losing their name prefs --- code/__HELPERS/unsorted.dm | 8 ++-- code/controllers/subsystem/jobs.dm | 22 +++++++---- code/controllers/subsystem/ticker.dm | 48 +++++++++++++++++------ code/datums/datacore.dm | 1 + code/modules/jobs/job_types/job.dm | 3 +- code/modules/jobs/job_types/security.dm | 6 +-- code/modules/mob/new_player/new_player.dm | 27 ++++++++----- code/modules/mob/transform_procs.dm | 18 ++++++--- 8 files changed, 91 insertions(+), 42 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 9dd1fd5ac5f..cd9a136003b 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -186,15 +186,17 @@ Turf and target are seperate in case you want to teleport some distance from a t return 1 //Generalised helper proc for letting mobs rename themselves. Used to be clname() and ainame() -/mob/proc/rename_self(role) +/mob/proc/rename_self(role, client/C) + if(!C) + C = client var/oldname = real_name var/newname var/loop = 1 var/safety = 0 while(loop && safety < 5) - if(client && client.prefs.custom_names[role] && !safety) - newname = client.prefs.custom_names[role] + if(C && C.prefs.custom_names[role] && !safety) + newname = C.prefs.custom_names[role] else switch(role) if("clown") diff --git a/code/controllers/subsystem/jobs.dm b/code/controllers/subsystem/jobs.dm index 5c706e62e66..596e86b48b4 100644 --- a/code/controllers/subsystem/jobs.dm +++ b/code/controllers/subsystem/jobs.dm @@ -357,7 +357,15 @@ var/datum/subsystem/job/SSjob return 1 //Gives the player the stuff he should have with his rank -/datum/subsystem/job/proc/EquipRank(mob/living/H, rank, joined_late=0) +/datum/subsystem/job/proc/EquipRank(mob/M, rank, joined_late=0) + var/mob/new_player/N + var/mob/living/H + if(!joined_late) + N = M + H = N.new_character + else + H = M + var/datum/job/job = GetJob(rank) H.job = rank @@ -399,16 +407,16 @@ var/datum/subsystem/job/SSjob if(ismob(new_mob)) H = new_mob - H << "You are the [rank]." - H << "As the [rank] you answer directly to [job.supervisors]. Special circumstances may change this." - H << "To speak on your departments radio, use the :h button. To see others, look closely at your headset." + M << "You are the [rank]." + M << "As the [rank] you answer directly to [job.supervisors]. Special circumstances may change this." + M << "To speak on your departments radio, use the :h button. To see others, look closely at your headset." if(job.req_admin_notify) - H << "You are playing a job that is important for Game Progression. If you have to disconnect, please notify the admins via adminhelp." + M << "You are playing a job that is important for Game Progression. If you have to disconnect, please notify the admins via adminhelp." if(config.minimal_access_threshold) - H << "As this station was initially staffed with a [config.jobs_have_minimal_access ? "full crew, only your job's necessities" : "skeleton crew, additional access may"] have been added to your ID card." + M << "As this station was initially staffed with a [config.jobs_have_minimal_access ? "full crew, only your job's necessities" : "skeleton crew, additional access may"] have been added to your ID card." if(job && H) - job.after_spawn(H) + job.after_spawn(H, M) return H diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 92244a45f0a..50ef8311de1 100644 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -127,6 +127,8 @@ var/datum/subsystem/ticker/ticker declare_completion(force_ending) /datum/subsystem/ticker/proc/setup() + world << "Starting game..." + var/init_start = world.timeofday //Create and announce mode var/list/datum/game_mode/runnable_modes if(master_mode == "random" || master_mode == "secret") @@ -156,10 +158,13 @@ var/datum/subsystem/ticker/ticker SSjob.ResetOccupations() return 0 + CHECK_TICK //Configure mode and assign player to special mode stuff var/can_continue = 0 can_continue = src.mode.pre_setup() //Choose antagonists + CHECK_TICK SSjob.DivideOccupations() //Distribute jobs + CHECK_TICK if(!Debug2) if(!can_continue) @@ -171,6 +176,7 @@ var/datum/subsystem/ticker/ticker else message_admins("DEBUG: Bypassing prestart checks...") + CHECK_TICK if(hide_mode) var/list/modes = new for (var/datum/game_mode/M in runnable_modes) @@ -181,18 +187,28 @@ var/datum/subsystem/ticker/ticker else mode.announce() + CHECK_TICK current_state = GAME_STATE_PLAYING if(!config.ooc_during_round) toggle_ooc(0) // Turn it off round_start_time = world.time + CHECK_TICK start_landmarks_list = shuffle(start_landmarks_list) //Shuffle the order of spawn points so they dont always predictably spawn bottom-up and right-to-left - create_characters() //Create player characters and transfer them + create_characters() //Create player characters + CHECK_TICK collect_minds() + CHECK_TICK equip_characters() + CHECK_TICK data_core.manifest() + CHECK_TICK - Master.RoundStart() + transfer_characters() //transfer keys to the new mobs + + Master.RoundStart() //let the party begin... + + log_world("Game start took [(world.timeofday - init_start)/10]s") world << "Welcome to [station_name()], enjoy your stay!" world << sound('sound/AI/welcome.ogg') @@ -357,34 +373,42 @@ var/datum/subsystem/ticker/ticker joined_player_list += player.ckey if(player.mind.assigned_role=="AI") player.close_spawn_windows() - player.AIize() + player.AIize(FALSE) else - player.create_character() - qdel(player) + player.create_character(FALSE) else player.new_player_panel() + CHECK_TICK /datum/subsystem/ticker/proc/collect_minds() for(var/mob/living/player in player_list) if(player.mind) ticker.minds += player.mind + CHECK_TICK /datum/subsystem/ticker/proc/equip_characters() var/captainless=1 - for(var/mob/living/carbon/human/player in player_list) - if(player && player.mind && player.mind.assigned_role) + for(var/mob/new_player/N in player_list) + var/mob/living/carbon/human/player = N.new_character + if(istype(player) && player.mind && player.mind.assigned_role && player.mind.assigned_role != "AI") if(player.mind.assigned_role == "Captain") captainless=0 if(player.mind.assigned_role != player.mind.special_role) - SSjob.EquipRank(player, player.mind.assigned_role, 0) + SSjob.EquipRank(N, player.mind.assigned_role, 0) + CHECK_TICK if(captainless) - for(var/mob/M in player_list) - if(!isnewplayer(M)) - M << "Captainship not forced on anyone." - + for(var/mob/new_player/N in player_list) + if(N.new_character) + N << "Captainship not forced on anyone." + CHECK_TICK +/datum/subsystem/ticker/proc/transfer_characters() + for(var/mob/new_player/player in player_list) + if(player.transfer_character()) + qdel(player) + /datum/subsystem/ticker/proc/declare_completion() set waitfor = FALSE diff --git a/code/datums/datacore.dm b/code/datums/datacore.dm index f10a33b75e5..9e2f25e3c31 100644 --- a/code/datums/datacore.dm +++ b/code/datums/datacore.dm @@ -68,6 +68,7 @@ /datum/datacore/proc/manifest() for(var/mob/living/carbon/human/H in player_list) manifest_inject(H) + CHECK_TICK /datum/datacore/proc/manifest_modify(name, assignment) var/datum/data/record/foundrecord = find_record("name", name, data_core.general) diff --git a/code/modules/jobs/job_types/job.dm b/code/modules/jobs/job_types/job.dm index e83c93e82ee..a3d6287cf5c 100644 --- a/code/modules/jobs/job_types/job.dm +++ b/code/modules/jobs/job_types/job.dm @@ -44,7 +44,8 @@ var/outfit = null //Only override this proc -/datum/job/proc/after_spawn(mob/living/carbon/human/H) +/datum/job/proc/after_spawn(mob/living/carbon/human/H, mob/M) + //do actions on H but send messages to M as the key may not have been transferred_yet /datum/job/proc/announce(mob/living/carbon/human/H) diff --git a/code/modules/jobs/job_types/security.dm b/code/modules/jobs/job_types/security.dm index cae08cd353f..f436d8544c9 100644 --- a/code/modules/jobs/job_types/security.dm +++ b/code/modules/jobs/job_types/security.dm @@ -183,7 +183,7 @@ Security Officer var/list/available_depts = list(SEC_DEPT_ENGINEERING, SEC_DEPT_MEDICAL, SEC_DEPT_SCIENCE, SEC_DEPT_SUPPLY) -/datum/job/officer/after_spawn(mob/living/carbon/human/H) +/datum/job/officer/after_spawn(mob/living/carbon/human/H, mob/M) // Assign department security var/department if(H && H.client && H.client.prefs) @@ -255,9 +255,9 @@ var/list/available_depts = list(SEC_DEPT_ENGINEERING, SEC_DEPT_MEDICAL, SEC_DEPT else break if(department) - H << "You have been assigned to [department]!" + M << "You have been assigned to [department]!" else - H << "You have not been assigned to any department. Patrol the halls and help where needed." + M << "You have not been assigned to any department. Patrol the halls and help where needed." diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index e03ad3649e3..91387880d00 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -13,6 +13,7 @@ canmove = 0 anchored = 1 // don't get pushed around + var/mob/living/new_character //for instant transfer once the round is set up /mob/new_player/New() tag = "mob_[next_mob_id++]" @@ -301,7 +302,7 @@ SSjob.AssignRole(src, rank, 1) - var/mob/living/character = create_character() //creates the human and transfers vars and mind + var/mob/living/character = create_character(TRUE) //creates the human and transfers vars and mind var/equip = SSjob.EquipRank(character, rank, 1) if(iscyborg(equip)) //Borgs get borged in the equip, so we need to make sure we handle the new mob. character = equip @@ -422,27 +423,33 @@ popup.open(0) // 0 is passed to open so that it doesn't use the onclose() proc -/mob/new_player/proc/create_character() +/mob/new_player/proc/create_character(transfer_after) spawning = 1 close_spawn_windows() - var/mob/living/carbon/human/new_character = new(loc) + var/mob/living/carbon/human/H = new(loc) if(config.force_random_names || jobban_isbanned(src, "appearance")) client.prefs.random_character() client.prefs.real_name = client.prefs.pref_species.random_name(gender,1) - client.prefs.copy_to(new_character) - new_character.dna.update_dna_identity() + client.prefs.copy_to(H) + H.dna.update_dna_identity() if(mind) mind.active = 0 //we wish to transfer the key manually - mind.transfer_to(new_character) //won't transfer key since the mind is not active + mind.transfer_to(H) //won't transfer key since the mind is not active - new_character.name = real_name + H.name = real_name - new_character.key = key //Manually transfer the key to log them in - new_character.stopLobbySound() + . = H + new_character = . + if(transfer_after) + transfer_character() - return new_character +/mob/new_player/proc/transfer_character() + . = new_character + if(.) + new_character.key = key //Manually transfer the key to log them in + new_character.stopLobbySound() /mob/new_player/proc/ViewManifest() var/dat = "" diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm index 02f0821bd54..5bd86bbc4c9 100644 --- a/code/modules/mob/transform_procs.dm +++ b/code/modules/mob/transform_procs.dm @@ -287,9 +287,12 @@ qdel(src) -/mob/new_player/AIize() +/mob/new_player/AIize(transfer_after) spawning = 1 - return ..() + . = ..() + new_character = . + if(!transfer_after) //name can't be set in AI/New without the client + new_character.rename_self("ai", client) /mob/living/carbon/human/AIize() if (notransform) @@ -311,7 +314,7 @@ invisibility = INVISIBILITY_MAXIMUM return ..() -/mob/proc/AIize() +/mob/proc/AIize(transfer_after = TRUE) if(client) stopLobbySound() @@ -334,10 +337,13 @@ if (sloc.name == "AI") loc_landmark = sloc.loc - . = new /mob/living/silicon/ai(loc_landmark, null, src) - qdel(src) - return + if(!transfer_after) + mind.active = FALSE + . = new /mob/living/silicon/ai(loc_landmark, null, src) + + if(transfer_after) + qdel(src) //human -> robot /mob/living/carbon/human/proc/Robotize(delete_items = 0)