Fixes infinite loop in bitrunning (#79194)

## About The Pull Request
Clears up some functionality in netpod disconnect cases that lead to an
infinite loop

Also fixes an errant message from #78959
## Why It's Good For The Game
Fixes #79190

## Changelog
🆑
fix: Entering a virtual domain should no longer give you a message that
it doesn't forbid items
/🆑

---------

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
Jeremiah
2023-10-23 23:22:25 +01:00
committed by GitHub
co-authored by Mothblocks
parent ec8e8f193a
commit 83e6cc517b
5 changed files with 90 additions and 111 deletions
+63 -79
View File
@@ -35,15 +35,10 @@
disconnect_damage = BASE_DISCONNECT_DAMAGE
find_server()
RegisterSignals(src, list(
COMSIG_QDELETING,
COMSIG_MACHINERY_BROKEN,
COMSIG_MACHINERY_POWER_LOST,
),
PROC_REF(on_broken),
)
RegisterSignal(src, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
RegisterSignal(src, COMSIG_ATOM_TAKE_DAMAGE, PROC_REF(on_take_damage))
RegisterSignal(src, COMSIG_ATOM_TAKE_DAMAGE, PROC_REF(on_damage_taken))
RegisterSignal(src, COMSIG_MACHINERY_POWER_LOST, PROC_REF(on_power_loss))
RegisterSignals(src, list(COMSIG_QDELETING, COMSIG_MACHINERY_BROKEN),PROC_REF(on_broken))
register_context()
update_appearance()
@@ -89,7 +84,7 @@
if(!iscarbon(player))
return
if((HAS_TRAIT(player, TRAIT_UI_BLOCKED) && !player.resting) || !Adjacent(player) || !player.Adjacent(target) || !ISADVANCEDTOOLUSER(player) || !is_operational)
if((HAS_TRAIT(player, TRAIT_UI_BLOCKED) && !player.resting) || !Adjacent(player) || !ISADVANCEDTOOLUSER(player) || !is_operational)
return
close_machine(target)
@@ -142,9 +137,10 @@
open_machine()
/obj/machinery/netpod/open_machine(drop = TRUE, density_to_set = FALSE)
unprotect_and_signal()
playsound(src, 'sound/machines/tramopen.ogg', 60, TRUE, frequency = 65000)
flick("[base_icon_state]_opening", src)
SEND_SIGNAL(src, COMSIG_BITRUNNER_NETPOD_OPENED)
update_use_power(IDLE_POWER_USE)
return ..()
@@ -156,10 +152,6 @@
flick("[base_icon_state]_closing", src)
..()
if(!iscarbon(occupant))
open_machine()
return
enter_matrix()
/obj/machinery/netpod/default_pry_open(obj/item/crowbar, mob/living/pryer)
@@ -184,6 +176,7 @@
if(do_after(pryer, 15 SECONDS, src))
if(!state_open)
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
open_machine()
return TRUE
@@ -232,17 +225,22 @@
if(isnull(our_target) || !our_observer.orbit(our_target))
return ..()
/// Puts the occupant in netpod stasis, basically short-circuiting environmental conditions
/obj/machinery/netpod/proc/add_healing(mob/living/target)
if(target != occupant)
return
target.AddComponent(/datum/component/netpod_healing, pod = src)
target.playsound_local(src, 'sound/effects/submerge.ogg', 20, vary = TRUE)
target.extinguish_mob()
update_use_power(ACTIVE_POWER_USE)
/// Disconnects the occupant after a certain time so they aren't just hibernating in netpod stasis. A balance change
/obj/machinery/netpod/proc/auto_disconnect()
if(isnull(occupant) || state_open || connected)
return
if(!iscarbon(occupant))
open_machine()
return
var/mob/living/carbon/player = occupant
var/mob/player = occupant
player.playsound_local(src, 'sound/effects/splash.ogg', 60, TRUE)
to_chat(player, span_notice("The machine disconnects itself and begins to drain."))
open_machine()
@@ -252,7 +250,7 @@
connected = FALSE
var/mob/living/mob_occupant = occupant
if(isnull(occupant) || !isliving(occupant) || mob_occupant.stat == DEAD)
if(isnull(occupant) || mob_occupant.stat == DEAD)
open_machine()
return
@@ -261,6 +259,10 @@
mob_occupant.set_temp_blindness(1 SECONDS)
mob_occupant.Paralyze(2 SECONDS)
if(!is_operational)
open_machine()
return
var/heal_time = 1
if(mob_occupant.health < mob_occupant.maxHealth)
heal_time = (mob_occupant.stat + 2) * 5
@@ -299,9 +301,8 @@
return
var/mob/living/carbon/current_avatar = avatar_ref?.resolve()
var/obj/structure/hololadder/wayout
if(isnull(current_avatar) || current_avatar.stat != CONSCIOUS) // We need a viable avatar
wayout = server.generate_hololadder()
var/obj/structure/hololadder/wayout = server.generate_hololadder()
if(isnull(wayout))
balloon_alert(neo, "out of bandwidth!")
return
@@ -310,7 +311,7 @@
server.stock_gear(current_avatar, neo, generated_domain)
neo.set_static_vision(3 SECONDS)
protect_occupant(occupant)
add_healing(occupant)
if(!do_after(neo, 2 SECONDS, src))
return
@@ -372,20 +373,33 @@
/obj/machinery/netpod/proc/on_broken(datum/source)
SIGNAL_HANDLER
if(!state_open)
open_machine()
if(isnull(occupant) || !connected)
return
if(occupant)
unprotect_and_signal()
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
/// Checks the integrity, alerts occupants
/obj/machinery/netpod/proc/on_damage_taken(datum/source, damage_amount)
SIGNAL_HANDLER
if(isnull(occupant) || !connected)
return
var/total = max_integrity - damage_amount
var/integrity = (atom_integrity / total) * 100
if(integrity > 50)
return
SEND_SIGNAL(src, COMSIG_BITRUNNER_NETPOD_INTEGRITY)
/// Puts points on the current occupant's card account
/obj/machinery/netpod/proc/on_domain_complete(datum/source, atom/movable/crate, reward_points)
SIGNAL_HANDLER
if(isnull(occupant) || !connected || !iscarbon(occupant))
if(isnull(occupant) || !connected)
return
var/mob/living/carbon/player = occupant
var/mob/living/player = occupant
var/datum/bank_account/account = player.get_bank_account()
if(isnull(account))
@@ -393,6 +407,16 @@
account.bitrunning_points += reward_points * 100
/// The domain has been fully purged, so we should double check our avatar is deleted
/obj/machinery/netpod/proc/on_domain_scrubbed(datum/source)
SIGNAL_HANDLER
var/mob/avatar = avatar_ref?.resolve()
if(isnull(avatar))
return
QDEL_NULL(avatar)
/// User inspects the machine
/obj/machinery/netpod/proc/on_examine(datum/source, mob/examiner, list/examine_text)
SIGNAL_HANDLER
@@ -408,15 +432,19 @@
examine_text += span_notice("It is currently occupied by [occupant].")
examine_text += span_notice("It can be pried open with a crowbar, but its safety mechanisms will alert the occupant.")
/// The domain has been fully purged, so we should double check our avatar is deleted
/obj/machinery/netpod/proc/on_domain_scrubbed(datum/source)
/// Boots out anyone in the machine && opens it
/obj/machinery/netpod/proc/on_power_loss(datum/source)
SIGNAL_HANDLER
var/mob/living/current_avatar = avatar_ref?.resolve()
if(isnull(current_avatar))
if(state_open)
return
QDEL_NULL(current_avatar)
if(isnull(occupant) || !connected)
connected = FALSE
open_machine()
return
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
/// When the server is upgraded, drops brain damage a little
/obj/machinery/netpod/proc/on_server_upgraded(datum/source, servo_rating)
@@ -424,50 +452,6 @@
disconnect_damage = BASE_DISCONNECT_DAMAGE * (1 - servo_rating)
/// Checks the integrity, alerts occupants
/obj/machinery/netpod/proc/on_take_damage(datum/source, damage_amount)
SIGNAL_HANDLER
if(isnull(occupant))
return
var/total = max_integrity - damage_amount
var/integrity = (atom_integrity / total) * 100
if(integrity > 50)
return
SEND_SIGNAL(src, COMSIG_BITRUNNER_NETPOD_INTEGRITY)
/// Puts the occupant in netpod stasis, basically short-circuiting environmental conditions
/obj/machinery/netpod/proc/protect_occupant(mob/living/target)
if(target != occupant)
return
target.AddComponent(/datum/component/netpod_healing, \
brute_heal = 4, \
burn_heal = 4, \
toxin_heal = 4, \
clone_heal = 4, \
blood_heal = 4, \
)
target.playsound_local(src, 'sound/effects/submerge.ogg', 20, TRUE)
target.extinguish_mob()
update_use_power(ACTIVE_POWER_USE)
/// On unbuckle or break, make sure the occupant ref is null
/obj/machinery/netpod/proc/unprotect_and_signal()
unprotect_occupant(occupant)
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
/// Removes the occupant from netpod stasis
/obj/machinery/netpod/proc/unprotect_occupant(mob/living/target)
var/datum/component/netpod_healing/healing_eff = target?.GetComponent(/datum/component/netpod_healing)
if(healing_eff)
qdel(healing_eff)
update_use_power(IDLE_POWER_USE)
/// Resolves a path to an outfit.
/obj/machinery/netpod/proc/resolve_outfit(text)
var/path = text2path(text)