Skip to content

Commit

Permalink
Fixes cases of players getting sent to lobby, preference runtimes, & …
Browse files Browse the repository at this point in the history
…cleans up split personality checks (#10536)

* knitting and knitting and knitting and

* check for clientless on login

* stuff I missed

* fix error

* comments
  • Loading branch information
Tsar-Salat authored Aug 4, 2024
1 parent 59c2a83 commit 8f8d306
Show file tree
Hide file tree
Showing 23 changed files with 118 additions and 50 deletions.
9 changes: 8 additions & 1 deletion code/datums/brain_damage/imaginary_friend.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
var/friend_initialized = FALSE

/datum/brain_trauma/special/imaginary_friend/on_gain()
var/mob/living/M = owner
// dead or clientless mobs dont get the brain trauma
if(M.stat == DEAD || !M.client)
qdel(src)
return
..()
make_friend()
get_ghost()
Expand Down Expand Up @@ -78,7 +83,9 @@
var/datum/action/innate/imaginary_hide/hide

/mob/camera/imaginary_friend/Login()
..()
. = ..()
if(!. || !client)
return FALSE
greet()
Show()

Expand Down
63 changes: 35 additions & 28 deletions code/datums/brain_damage/split_personality.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
var/mob/living/split_personality/owner_backseat

/datum/brain_trauma/severe/split_personality/on_gain()
var/mob/living/M = owner
//Dead and braindead people dont get a second voice
if(M.stat == DEAD || !M.client)
qdel(src)
return
..()
make_backseats()
get_ghost()
Expand All @@ -28,9 +33,6 @@

/datum/brain_trauma/severe/split_personality/proc/get_ghost()
set waitfor = FALSE
if(owner.stat == DEAD || !owner.mind)
qdel(src)
return
var/list/mob/dead/observer/candidates = poll_candidates_for_mob("Do you want to play as [owner]'s split personality?", ROLE_SPLIT_PERSONALITY, null, 7.5 SECONDS, stranger_backseat)
if(LAZYLEN(candidates))
var/mob/dead/observer/C = pick(candidates)
Expand All @@ -43,38 +45,35 @@
/datum/brain_trauma/severe/split_personality/on_life()
if(owner.stat == DEAD)
if(current_controller != OWNER)
switch_personalities()
switch_personalities(TRUE)
qdel(src)
else if(prob(3))
switch_personalities()
..()

/datum/brain_trauma/severe/split_personality/on_lose()
if(current_controller != OWNER) //it would be funny to cure a guy only to be left with the other personality, but it seems too cruel
switch_personalities()
switch_personalities(TRUE)
QDEL_NULL(stranger_backseat)
QDEL_NULL(owner_backseat)
..()

/datum/brain_trauma/severe/split_personality/Destroy()
if(stranger_backseat)
QDEL_NULL(stranger_backseat)
if(owner_backseat)
QDEL_NULL(owner_backseat)
return ..()

/datum/brain_trauma/severe/split_personality/proc/switch_personalities()
/datum/brain_trauma/severe/split_personality/proc/switch_personalities(reset_to_owner = FALSE)
if(QDELETED(owner) || owner.stat == DEAD || QDELETED(stranger_backseat) || QDELETED(owner_backseat))
return

var/mob/living/split_personality/current_backseat
var/mob/living/split_personality/free_backseat
if(current_controller == OWNER)
current_backseat = stranger_backseat
free_backseat = owner_backseat
else
var/mob/living/split_personality/new_backseat
if(current_controller == STRANGER || reset_to_owner)
current_backseat = owner_backseat
free_backseat = stranger_backseat
new_backseat = stranger_backseat
else
current_backseat = stranger_backseat
new_backseat = owner_backseat

if(!current_backseat.client) //Make sure we never switch to a logged off mob.
return

log_game("[key_name(current_backseat)] assumed control of [key_name(owner)] due to [src]. (Original owner: [current_controller == OWNER ? owner.key : current_backseat.key])")
to_chat(owner, "<span class='userdanger'>You feel your control being taken away... your other personality is in charge now!</span>")
Expand All @@ -87,18 +86,21 @@
owner.computer_id = null
owner.lastKnownIP = null

free_backseat.ckey = owner.ckey
new_backseat.ckey = owner.ckey

free_backseat.name = owner.name
new_backseat.name = owner.name

if(owner.mind)
free_backseat.mind = owner.mind
new_backseat.mind = owner.mind

if(!free_backseat.computer_id)
free_backseat.computer_id = h2b_id
if(!new_backseat.computer_id)
new_backseat.computer_id = h2b_id

if(!free_backseat.lastKnownIP)
free_backseat.lastKnownIP = h2b_ip
if(!new_backseat.lastKnownIP)
new_backseat.lastKnownIP = h2b_ip

if(reset_to_owner && new_backseat.mind)
new_backseat.ghostize(FALSE)

//Backseat to body

Expand Down Expand Up @@ -149,7 +151,9 @@
..()

/mob/living/split_personality/Login()
..()
. = ..()
if(!. || !client)
return FALSE
to_chat(src, "<span class='notice'>As a split personality, you cannot do anything but observe. However, you will eventually gain control of your body, switching places with the current personality.</span>")
to_chat(src, "<span class='warning'><b>Do not commit suicide or put the body in a deadly position. Behave like you care about it as much as the owner.</b></span>")

Expand Down Expand Up @@ -207,8 +211,9 @@
return //no random switching

/datum/brain_trauma/severe/split_personality/brainwashing/handle_hearing(datum/source, list/hearing_args)
if(HAS_TRAIT(owner, TRAIT_DEAF) || owner == hearing_args[HEARING_SPEAKER])
if(!owner.can_hear() || owner == hearing_args[HEARING_SPEAKER])
return

var/message = hearing_args[HEARING_RAW_MESSAGE]
if(findtext(message, codeword))
hearing_args[HEARING_RAW_MESSAGE] = replacetext(message, codeword, "<span class='warning'>[codeword]</span>")
Expand All @@ -225,7 +230,9 @@
var/codeword

/mob/living/split_personality/traitor/Login()
..()
. = ..()
if(!. || !client)
return FALSE
to_chat(src, "<span class='notice'>As a brainwashed personality, you cannot do anything yet but observe. However, you may gain control of your body if you hear the special codeword, switching places with the current personality.</span>")
to_chat(src, "<span class='notice'>Your activation codeword is: <b>[codeword]</b></span>")
if(objective)
Expand Down
4 changes: 3 additions & 1 deletion code/modules/antagonists/blob/overmind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ GLOBAL_LIST_EMPTY(blob_nodes)
return ..()

/mob/camera/blob/Login()
..()
. = ..()
if(!. || !client)
return FALSE
to_chat(src, "<span class='notice'>You are the overmind!</span>")
blob_help()
update_health_hud()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ GLOBAL_LIST_EMPTY(clockwork_marauders)

/mob/living/simple_animal/hostile/clockwork_marauder/Login()
. = ..()
if(!. || !client)
return FALSE
add_servant_of_ratvar(src)
to_chat(src, "<span class='brass'>You can block up to 4 attacks with your shield, however it requires a welder to be repaired.</span>")

Expand Down
2 changes: 2 additions & 0 deletions code/modules/antagonists/clock_cult/mobs/eminence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@

/mob/living/simple_animal/eminence/Login()
. = ..()
if(!. || !client)
return FALSE
var/datum/antagonist/servant_of_ratvar/S = add_servant_of_ratvar(src, silent=TRUE)
S.prefix = CLOCKCULT_PREFIX_EMINENCE
to_chat(src, "<span class='large_brass'>You are the Eminence!</span>")
Expand Down
4 changes: 3 additions & 1 deletion code/modules/antagonists/devil/true_devil/_true_devil.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
real_name = name

/mob/living/carbon/true_devil/Login()
..()
. = ..()
if(!. || !client)
return FALSE
var/datum/antagonist/devil/devilinfo = mind.has_antag_datum(/datum/antagonist/devil)
devilinfo.greet()
mind.announce_objectives()
Expand Down
4 changes: 3 additions & 1 deletion code/modules/antagonists/revenant/revenant.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@
name = built_name

/mob/living/simple_animal/revenant/Login()
..()
. = ..()
if(!. || !client)
return FALSE
to_chat(src, "<span class='deadsay'><span class='big bold'>You are a revenant.</span></span>")
to_chat(src, "<b>Your formerly mundane spirit has been infused with alien energies and empowered into a revenant.</b>")
to_chat(src, "<b>You are not dead, not alive, but somewhere in between. You are capable of limited interaction with both worlds.</b>")
Expand Down
2 changes: 2 additions & 0 deletions code/modules/holoparasite/_holoparasite.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ GLOBAL_LIST_EMPTY_TYPED(holoparasites, /mob/living/simple_animal/hostile/holopar
if(mind && key && key != mind.key) // Ooh, new player!
first_time_show_popup = mind.has_antag_datum(/datum/antagonist/holoparasite)
. = ..()
if(!. || !client)
return FALSE
if(mind)
mind.name = "[real_name]"
if(QDELETED(summoner?.current))
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/dead/dead.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ INITIALIZE_IMMEDIATE(/mob/dead)

/mob/dead/Login()
. = ..()
if(!. || !client)
return FALSE
var/turf/T = get_turf(src)
if (isturf(T))
update_z(T.z)
Expand Down
6 changes: 5 additions & 1 deletion code/modules/mob/dead/new_player/login.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/mob/dead/new_player/Login()
if(!client)
return
if(CONFIG_GET(flag/use_exp_tracking))
client.set_exp_from_db()
if(!client) // client null during sleep
Expand All @@ -11,7 +13,9 @@
mind.active = TRUE
mind.set_current(src)

..()
. = ..()
if(!. || !client)
return FALSE

var/motd = global.config.motd
if(motd)
Expand Down
4 changes: 3 additions & 1 deletion code/modules/mob/dead/observer/login.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/mob/dead/observer/Login()
..()
. = ..()
if(!. || !client)
return FALSE

ghost_accs = client.prefs.read_player_preference(/datum/preference/choiced/ghost_accessories)
ghost_others = client.prefs.read_player_preference(/datum/preference/choiced/ghost_others)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/living/carbon/alien/login.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/mob/living/carbon/alien/Login()
. = ..()
if(!. || !client)
return FALSE
AddInfectionImages()
5 changes: 4 additions & 1 deletion code/modules/mob/living/login.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/mob/living/Login()
..()
. = ..()
if(!. || !client)
return FALSE

//Mind updates
sync_mind()
mind.show_memory(src, 0)
Expand Down
4 changes: 3 additions & 1 deletion code/modules/mob/living/silicon/ai/login.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/mob/living/silicon/ai/Login()
..()
. = ..()
if(!. || !client)
return FALSE
if(stat != DEAD)
if(lacks_power() && apc_override) //Placing this in Login() in case the AI doesn't have this link for whatever reason.
to_chat(usr, "<span class='warning'>Main power is unavailable, backup power in use. Diagnostics scan complete.</span> <A HREF='?src=[REF(src)];emergencyAPC=[TRUE]'>Local APC ready for connection.</A>")
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/login.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var/datum/antagonist/rev/rev = mind.has_antag_datum(/datum/antagonist/rev)
if(rev)
rev.remove_revolutionary(TRUE)
..()
return ..()

/mob/living/silicon/auto_deadmin_on_login()
if(!client?.holder)
Expand Down
4 changes: 3 additions & 1 deletion code/modules/mob/living/silicon/pai/pai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@
return TRUE

/mob/living/silicon/pai/Login()
..()
. = ..()
if(!. || !client)
return FALSE
var/datum/asset/notes_assets = get_asset_datum(/datum/asset/simple/pAI)
mind.assigned_role = JOB_NAME_PAI
notes_assets.send(client)
Expand Down
4 changes: 3 additions & 1 deletion code/modules/mob/living/silicon/robot/login.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

/mob/living/silicon/robot/Login()
..()
. = ..()
if(!. || !client)
return FALSE
regenerate_icons()
show_laws(0)
2 changes: 2 additions & 0 deletions code/modules/mob/living/simple_animal/bot/bot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,8 @@ Pass a positive integer as an argument to override a bot's default speed.

/mob/living/simple_animal/bot/Login()
. = ..()
if(!. || !client)
return FALSE
access_card.access |= player_access
diag_hud_set_botmode()

Expand Down
4 changes: 3 additions & 1 deletion code/modules/mob/living/simple_animal/constructs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
return ..()

/mob/living/simple_animal/hostile/construct/Login()
..()
. = ..()
if(!. || !client)
return FALSE
to_chat(src, playstyle_string)

/mob/living/simple_animal/hostile/construct/examine(mob/user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@
return ..()

/mob/living/simple_animal/drone/Login()
..()
. = ..()
if(!. || !client)
return FALSE
check_laws()

if(flavortext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
hidden_uplink.telecrystals = 10

/mob/living/simple_animal/drone/syndrone/Login()
..()
. = ..()
if(!. || !client)
return FALSE
to_chat(src, "<span class='notice'>You can kill and eat other drones to increase your health!</span>" )

/mob/living/simple_animal/drone/syndrone/badass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
return ..()

/mob/living/simple_animal/hostile/poison/giant_spider/Login()
..()
. = ..()
if(!. || !client)
return FALSE
SSmove_manager.stop_looping(src) // Just in case the AI's doing anything when we give them the mind
GLOB.spidermobs[src] = TRUE

Expand Down
Loading

0 comments on commit 8f8d306

Please sign in to comment.