Skip to content

Commit

Permalink
Some more misc runtime fixes (#2491)
Browse files Browse the repository at this point in the history
* Fix two sources of color_cutoffs runtimes, then give it a better error (#75446)

50% of rounds.

`color_cutoffs` must always be a 3-item list. I couldn't find any more
cases where this assumption could be wrong.

```
[2023-05-05 04:04:21.144] runtime error: list index out of bounds
 - proc name: blend cutoff colors (/proc/blend_cutoff_colors)
 -   source file: colors.dm,91
 -   usr: Varuna Maddox (/mob/living/carbon/human)
 -   src: null
 -   usr.loc: the plating (122,145,2) (/turf/open/floor/plating)
 -   call stack:
 - blend cutoff colors(/list (/list), /list (/list))
 - Varuna Maddox (/mob/living/carbon/human): update sight()
 - the pressure-resistant enginee... (/obj/item/clothing/glasses/meson/engine): toggle mode(Varuna Maddox (/mob/living/carbon/human), 1)
 - the pressure-resistant enginee... (/obj/item/clothing/glasses/meson/engine): attack self(Varuna Maddox (/mob/living/carbon/human))
 - the pressure-resistant enginee... (/obj/item/clothing/glasses/meson/engine): ui action click(Varuna Maddox (/mob/living/carbon/human), Toggle Mode (/datum/action/item_action/toggle_mode))
 - Toggle Mode (/datum/action/item_action/toggle_mode): Trigger(null)
 - Toggle Mode (/atom/movable/screen/movable/action_button): Click(null, "mapwindow.map", "icon-x=10;icon-y=15;left=1;but...")
 - Toggle Mode (/atom/movable/screen/movable/action_button):  Click(null, "mapwindow.map", "icon-x=10;icon-y=15;left=1;but...")
 - /datum/callback/verb_callback (/datum/callback/verb_callback): Invoke()
 - world: push usr(Varuna Maddox (/mob/living/carbon/human), /datum/callback/verb_callback (/datum/callback/verb_callback))
 - /datum/callback/verb_callback (/datum/callback/verb_callback): InvokeAsync()
 - Input (/datum/controller/subsystem/verb_manager/input): run verb queue()
 - Input (/datum/controller/subsystem/verb_manager/input): fire(0)
 - Input (/datum/controller/subsystem/verb_manager/input): fire(0)
 - Input (/datum/controller/subsystem/verb_manager/input): fire(0)
 - Input (/datum/controller/subsystem/verb_manager/input): ignite(0)
 - Master (/datum/controller/master): RunQueue()
 - Master (/datum/controller/master): Loop(2)
 - Master (/datum/controller/master): StartProcessing(0)
```

* Don't re-add repackable to colony ore silos every silo_log

* Fix runtimes with experimental cloners

* Fixes chem master replace beaker runtime (#76062)

## About The Pull Request

I think it was rather silly to put this call in this proc, but I'm not
about to audit it

`new_beaker` can be `null` if this proc is being called to drop the
current beaker, so this needed a sanity check

## Why It's Good For The Game

Runtime

## Changelog

:cl: Melbert
fix: Runtime from ejecting beakers from a chem-master
/:cl:

---------

Co-authored-by: Mothblocks <[email protected]>
Co-authored-by: MrMelbert <[email protected]>
  • Loading branch information
3 people authored Jul 1, 2024
1 parent bdfe47f commit 087649b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
4 changes: 4 additions & 0 deletions code/__HELPERS/colors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
/// But paired down and modified to work for our color range
/// Accepts the color cutoffs as two 3 length list(0-100,...) arguments
/proc/blend_cutoff_colors(list/first_color, list/second_color)
// These runtimes usually mean that either the eye or the glasses have an incorrect color_cutoffs
ASSERT(first_color?.len == 3, "First color must be a 3 length list, received [json_encode(first_color)]")
ASSERT(second_color?.len == 3, "Second color must be a 3 length list, received [json_encode(second_color)]")

var/list/output = new /list(3)

// Invert the colors, multiply to "darken" (actually lights), then uninvert to get back to what we want
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/glasses/engine_goggles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

if(MODE_TRAY) //undoes the last mode, meson
vision_flags = NONE
color_cutoffs = list()
color_cutoffs = null
change_glass_color(user, /datum/client_colour/glass_colour/lightblue)

if(MODE_PIPE_CONNECTABLE)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/chemistry/machinery/chem_master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ GLOBAL_LIST_INIT(chem_master_containers, list(

/// Insert new beaker and/or eject the inserted one
/obj/machinery/chem_master/proc/replace_beaker(mob/living/user, obj/item/reagent_containers/new_beaker)
if(!user?.transferItemToLoc(new_beaker, src))
if(new_beaker && user && !user.transferItemToLoc(new_beaker, src))
return FALSE
if(beaker)
try_put_in_hand(beaker, user)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/surgery/organs/eyes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
color_cutoffs = high_light_cutoff.Copy()
light_level = NIGHTVISION_LIGHT_HIG
else
color_cutoffs = list()
color_cutoffs = null
light_level = NIGHTVISION_LIGHT_OFF
owner.update_sight()

Expand Down
10 changes: 4 additions & 6 deletions monkestation/code/game/machinery/cloning.dm
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,9 @@
icon_state = "pod_0"
return

if(!mob_occupant)
if(QDELETED(mob_occupant) || !exp_clone_check(mob_occupant))
return

exp_clone_check(mob_occupant)


current_insurance = null
REMOVE_TRAIT(mob_occupant, TRAIT_STABLEHEART, CLONING_POD_TRAIT)
REMOVE_TRAIT(mob_occupant, TRAIT_STABLELIVER, CLONING_POD_TRAIT)
Expand Down Expand Up @@ -415,9 +413,9 @@
unattached_flesh.Cut()

occupant = null

/obj/machinery/clonepod/proc/exp_clone_check(mob_occupant)
return
return TRUE

/obj/machinery/clonepod/proc/malfunction()
var/mob/living/mob_occupant = occupant
Expand Down
2 changes: 2 additions & 0 deletions monkestation/code/game/machinery/exp_cloner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
/obj/machinery/clonepod/experimental/exp_clone_check(mob/living/carbon/human/mob_occupant)
if(!mob_occupant?.mind) //When experimental cloner fails to get a ghost, it won't spit out a body, so we don't get an army of brainless rejects.
qdel(mob_occupant)
return FALSE
return TRUE

/obj/machinery/clonepod/experimental/proc/get_clone_preview(datum/dna/clone_dna)
RETURN_TYPE(/image)
Expand Down
5 changes: 4 additions & 1 deletion monkestation/code/modules/blueshift/machines/ore_silo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
/// What this packs into
var/packed_type = /obj/item/flatpacked_machine/ore_silo

/obj/machinery/ore_silo/colony_lathe/Initialize(mapload)
. = ..()
AddElement(/datum/element/repackable, packed_type, 10 SECONDS)

/obj/machinery/ore_silo/colony_lathe/silo_log(obj/machinery/machinery_in_question, action, amount, noun, list/mats)
. = ..()
playsound(src, 'sound/machines/beep.ogg', 30, TRUE)
AddElement(/datum/element/repackable, packed_type, 10 SECONDS)

/obj/machinery/ore_silo/colony_lathe/default_deconstruction_crowbar()
return
Expand Down

0 comments on commit 087649b

Please sign in to comment.