Skip to content

Commit

Permalink
Fixes5 (#881)
Browse files Browse the repository at this point in the history
* fix welding goggles, and pushing buckled mobs

* PunPun can no longer eat cat ears off of people's heads

* fix codex runtime

* fixes my fixes

* fix brain issue

* fix slapcraft runtime

* fix runtimes with armor

* armor debugging

* crayon cleanable fix

* better fix

* inventory fix

* Fixes some runtimes in pathfinding (and bonus) (#80735)

## About The Pull Request

Found these while running a test server all night. I am not sure if the
second one really causes issues because `.` is being set to something
but it is is certainly polluting the runtime logs.

Also fixes an unrelated runtime with one of the admin verbs, where it
would runtime if you canceled out of the input prompt.

## Why It's Good For The Game

Less runtime spam.


![IklvTShHJB](https://github.com/tgstation/tgstation/assets/13398309/2441ad6b-67b7-4d65-83a3-eabba4516fe9)


![veGkt0Eyul](https://github.com/tgstation/tgstation/assets/13398309/e99eced9-89e6-4065-93d9-578795ddbd8d)

## Changelog

:cl:
fix: fixes some runtimes in pathfinding code, as well as one in the give
direct control admin verb
/:cl:

* fix division by zero in reagents

* fixes reagents stuffs

---------

Co-authored-by: Bloop <[email protected]>
  • Loading branch information
Kapu1178 and vinylspiders authored Mar 22, 2024
1 parent d7d0332 commit a311a56
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 78 deletions.
2 changes: 2 additions & 0 deletions code/__HELPERS/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
/proc/IsEdible(obj/item/thing)
if(!istype(thing))
return FALSE
if(thing.item_flags & ABSTRACT)
return FALSE
if(IS_EDIBLE(thing))
return TRUE
if(istype(thing, /obj/item/reagent_containers/food/drinks/drinkingglass))
Expand Down
4 changes: 3 additions & 1 deletion code/controllers/subsystem/codex.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ SUBSYSTEM_DEF(codex)

var/list/results = list()
var/list/priority_results = list()

if(entries_by_string[searching])
results = entries_by_string[searching]
results += entries_by_string[searching]
else
for(var/datum/codex_entry/entry as anything in all_entries)
if(findtext(entry.name, searching))
Expand All @@ -144,6 +145,7 @@ SUBSYSTEM_DEF(codex)

sortTim(priority_results, GLOBAL_PROC_REF(cmp_name_asc))
sortTim(results, GLOBAL_PROC_REF(cmp_name_asc))

priority_results += results
search_cache[searching] = priority_results
. = search_cache[searching]
Expand Down
7 changes: 6 additions & 1 deletion code/controllers/subsystem/movement/movement_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
controller.queue_loop(src)

/datum/move_loop/process()
if(isnull(controller))
qdel(src)
return

var/old_delay = delay //The signal can sometimes change delay

if(SEND_SIGNAL(src, COMSIG_MOVELOOP_PREPROCESS_CHECK) & MOVELOOP_SKIP_STEP) //Chance for the object to react
Expand Down Expand Up @@ -427,7 +431,8 @@
// this check if we're on exactly the next tile may be overly brittle for dense objects who may get bumped slightly
// to the side while moving but could maybe still follow their path without needing a whole new path
if(get_turf(moving) == next_step)
movement_path.Cut(1,2)
if(length(movement_path))
movement_path.Cut(1,2)
else
INVOKE_ASYNC(src, PROC_REF(recalculate_path))
return MOVELOOP_FAILURE
Expand Down
20 changes: 15 additions & 5 deletions code/datums/ai/generic/generic_behaviors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,16 @@
finish_action(controller, FALSE)

/datum/ai_behavior/find_and_set/proc/search_tactic(datum/ai_controller/controller, locate_path, search_range)
return locate(locate_path) in oview(search_range, controller.pawn)
for(var/atom/A as anything in oview(search_range, controller.pawn))
if(!istype(A, locate_path))
continue

if(isitem(A))
var/obj/item/I = A
if(I.item_flags & ABSTRACT)
continue

return A

/**
* Variant of find and set that fails if the living pawn doesn't hold something
Expand All @@ -227,11 +236,12 @@
continue
food_candidates += held_candidate

var/list/local_results = locate(locate_path) in oview(search_range, controller.pawn)
for(var/local_candidate in local_results)
if(!IsEdible(local_candidate))
for(var/obj/item/I in oview(search_range, controller.pawn))
if(!IsEdible(I))
continue
food_candidates += local_candidate

food_candidates += I

if(food_candidates.len)
return pick(food_candidates)

Expand Down
8 changes: 8 additions & 0 deletions code/datums/armor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
armor = getArmor(arglist(armor))
return armor

CRASH("Armor is not a datum or a list, what the fuck?")

///Setter for armor
/atom/proc/setArmor(datum/new_armor)
armor = new_armor
Expand Down Expand Up @@ -42,6 +44,12 @@
src.acid = acid
GenerateTag()

/datum/armor/Destroy(force, ...)
if(!force)
stack_trace("Some mf tried to delete an armor datum, KILL THIS MAN")
return QDEL_HINT_LETMELIVE
return ..()

/datum/armor/proc/modifyRating(blunt = 0, puncture = 0, slash = 0, laser = 0, energy = 0, bomb = 0, bio = 0, fire = 0, acid = 0)
return getArmor(
src.blunt + blunt,
Expand Down
2 changes: 0 additions & 2 deletions code/datums/components/crafting/crafting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@
if(RG.volume > amt)
RG.volume -= amt
data = RG.data
RC.reagents.conditional_update(RC)
RG = locate(RG.type) in Deletion
RG.volume = amt
RG.data += data
Expand All @@ -299,7 +298,6 @@
surroundings -= RC
amt -= RG.volume
RC.reagents.reagent_list -= RG
RC.reagents.conditional_update(RC)
RGNT = locate(RG.type) in Deletion
RGNT.volume += RG.volume
RGNT.data += RG.data
Expand Down
1 change: 0 additions & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
if(!reagents)
reagents = new()
reagents.reagent_list.Add(part)
reagents.conditional_update()
else if(ismovable(part))
var/atom/movable/object = part
if(isliving(object.loc))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/decals/cleanable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

if(blood_dna)
add_blood_DNA(blood_dna)
if(!length(blood_dna))
if(!islist(blood_dna) || !length(blood_dna))
stack_trace("Bad blood DNA sent")
else
var/datum/blood/path = blood_dna[blood_dna[1]]
Expand Down
5 changes: 3 additions & 2 deletions code/game/objects/effects/decals/crayon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GLOBAL_LIST(gang_tags)
var/rotation = 0
var/paint_colour = "#FFFFFF"

/obj/effect/decal/cleanable/crayon/Initialize(mapload, main, type, e_name, graf_rot, alt_icon = null)
/obj/effect/decal/cleanable/crayon/Initialize(mapload, list/datum/disease/diseases, list/blood_dna, main, type, e_name, graf_rot, alt_icon = null)
. = ..()
if(e_name)
name = e_name
Expand All @@ -30,6 +30,7 @@ GLOBAL_LIST(gang_tags)
if(main)
paint_colour = main
add_atom_colour(paint_colour, FIXED_COLOUR_PRIORITY)

/obj/effect/decal/cleanable/crayon/NeverShouldHaveComeHere(turf/T)
return isgroundlessturf(T)

Expand All @@ -40,7 +41,7 @@ GLOBAL_LIST(gang_tags)
layer = BELOW_MOB_LAYER
var/datum/team/gang/my_gang

/obj/effect/decal/cleanable/crayon/gang/Initialize(mapload, main, type, e_name, graf_rot, alt_icon = null)
/obj/effect/decal/cleanable/crayon/gang/Initialize(mapload, list/datum/disease/diseases, list/blood_dna, main, type, e_name, graf_rot, alt_icon = null)
. = ..()
LAZYADD(GLOB.gang_tags, src)

Expand Down
23 changes: 5 additions & 18 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -599,32 +599,19 @@ DEFINE_INTERACTABLE(/obj/item)
affecting?.receive_damage( 0, 5 ) // 5 burn damage
return

if(!(interaction_flags_item & INTERACT_ITEM_ATTACK_HAND_PICKUP)) //See if we're supposed to auto pickup.
if(!(interaction_flags_item & INTERACT_ITEM_ATTACK_HAND_PICKUP))
return

//Heavy gravity makes picking up things very slow.
var/grav = user.has_gravity()
if(grav > STANDARD_GRAVITY)
var/grav_power = min(3,grav - STANDARD_GRAVITY)
to_chat(user,span_notice("You start picking up [src]..."))
if(!do_after(user,src,30*grav_power))
var/grav_power = min(3, grav - STANDARD_GRAVITY)
to_chat(user, span_notice("You start picking up [src]..."))
if(!do_after(user, src, 30*grav_power))
return


//If the item is in a storage item, take it out
var/was_in_storage = loc.atom_storage?.attempt_remove(src, user.loc, silent = TRUE)
if(QDELETED(src)) //moving it out of the storage to the floor destroyed it.
return

if(throwing)
throwing.finalize(FALSE)
if(loc == user)
if(!allow_attack_hand_drop(user) || !user.temporarilyRemoveItemFromInventory(src))
return


// Return FALSE if the item is picked up.
return !user.pickup_item(src, ignore_anim = was_in_storage)
return !user.pickup_item(src)

/obj/item/proc/allow_attack_hand_drop(mob/user)
return TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/crayons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
else
switch(paint_mode)
if(PAINT_NORMAL)
C = new(target, paint_color, drawing, temp, graf_rot)
C = new(target, null, null, paint_color, drawing, temp, graf_rot)
C.pixel_x = clickx
C.pixel_y = clicky
affected_turfs += target
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
return span_warning("It's falling apart!")

/obj/structure/rust_heretic_act()
take_damage(500, BRUTE, "melee", 1)
take_damage(500, BRUTE, SLASH, 1)

/obj/structure/zap_act(power, zap_flags)
if(zap_flags & ZAP_OBJ_DAMAGE)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/admin/verbs/debug.dm
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@
if(tgui_alert(usr,"This mob is being controlled by [M.key]. Are you sure you wish to give someone else control of it? [M.key] will be made a ghost.",,list("Yes","No")) != "Yes")
return
var/client/newkey = input(src, "Pick the player to put in control.", "New player") as null|anything in sort_list(GLOB.clients)
if(isnull(newkey))
return
var/mob/oldmob = newkey.mob
var/delmob = FALSE
if((isobserver(oldmob) || tgui_alert(usr,"Do you want to delete [newkey]'s old mob?","Delete?",list("Yes","No")) != "No"))
Expand Down
1 change: 1 addition & 0 deletions code/modules/clothing/glasses/_glasses.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
user.update_sight()
if(iscarbon(user))
var/mob/living/carbon/carbon_user = user
carbon_user.update_tint()
carbon_user.update_slots_for_item(src, force_obscurity_update = TRUE)

//called when thermal glasses are emped.
Expand Down
16 changes: 14 additions & 2 deletions code/modules/mob/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,27 @@
return FALSE

/// A helper for picking up an item.
/mob/proc/pickup_item(obj/item/I, hand_index = active_hand_index, ignore_anim)
/mob/proc/pickup_item(obj/item/I, hand_index = active_hand_index, ignore_anim = FALSE)
if(QDELETED(I))
return

if(!can_put_in_hand(I, hand_index))
return

//If the item is in a storage item, take it out
var/was_in_storage = !!I.loc.atom_storage?.attempt_remove(I, src, silent = TRUE)
if(QDELETED(src)) //moving it out of the storage destroyed it.
return

if(I.throwing)
I.throwing.finalize(FALSE)

if(I.loc == src)
if(!I.allow_attack_hand_drop(src) || !temporarilyRemoveItemFromInventory(I))
return

I.pickup(src)
. = put_in_hand(I, hand_index, ignore_anim = ignore_anim)
. = put_in_hand(I, hand_index, ignore_anim = ignore_anim || was_in_storage)

if(!.)
stack_trace("Somehow, someway, pickup_item failed put_in_hand().")
Expand Down
13 changes: 11 additions & 2 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
(HAS_TRAIT(src, TRAIT_ARMS_RESTRAINED) || !combat_mode)
)
mob_swap = TRUE

if(mob_swap)
//switch our position with M
if(loc && !loc.MultiZAdjacent(M.loc))
Expand All @@ -189,15 +190,18 @@
//not if he's not CANPUSH of course
if(!(M.status_flags & CANPUSH))
return TRUE

if(isliving(M))
var/mob/living/L = M
if(HAS_TRAIT(L, TRAIT_PUSHIMMUNE))
return TRUE

//If they're a human, and they're not in help intent, block pushing
if(ishuman(M))
var/mob/living/carbon/human/human = M
if(human.combat_mode)
return TRUE

//if they are a cyborg, and they're alive and in combat mode, block pushing
if(iscyborg(M))
var/mob/living/silicon/robot/borg = M
Expand Down Expand Up @@ -255,9 +259,11 @@
if((AM.move_resist * MOVE_FORCE_CRUSH_RATIO) <= force)
if(move_crush(AM, move_force, dir_to_target))
push_anchored = TRUE

if((AM.move_resist * MOVE_FORCE_FORCEPUSH_RATIO) <= force) //trigger move_crush and/or force_push regardless of if we can push it normally
if(force_push(AM, move_force, dir_to_target, push_anchored))
push_anchored = TRUE

if(ismob(AM))
var/mob/mob_to_push = AM
var/atom/movable/mob_buckle = mob_to_push.buckled
Expand All @@ -266,9 +272,11 @@
if(mob_buckle && (mob_buckle.buckle_prevents_pull || (force < (mob_buckle.move_resist * MOVE_FORCE_PUSH_RATIO))))
now_pushing = FALSE
return

if((AM.anchored && !push_anchored) || (force < (AM.move_resist * MOVE_FORCE_PUSH_RATIO)))
now_pushing = FALSE
return

if(istype(AM, /obj/structure/window))
var/obj/structure/window/W = AM
if(W.fulltile)
Expand Down Expand Up @@ -771,8 +779,9 @@
if(lying_angle != 0)
lying_angle_on_movement(direct)
if (buckled && buckled.loc != newloc) //not updating position
if (!buckled.anchored)
return buckled.move_from_pull(newloc, buckled, glide_size)
if (buckled.anchored)
return FALSE
return buckled.move_from_pull(newloc, buckled, glide_size)

var/old_direction = dir
var/turf/T = loc
Expand Down
33 changes: 5 additions & 28 deletions code/modules/reagents/chemistry/holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,8 @@

current_list_element = rand(1, cached_reagents.len)

while(total_removed != amount)
if(total_removed >= amount)
break
while(total_removed < amount)
// There's nothing left in the container
if(total_volume <= 0 || !cached_reagents.len)
break

Expand All @@ -198,7 +197,9 @@

var/datum/reagent/R = cached_reagents[current_list_element]
var/remove_amt = min(amount-total_removed,round(amount/rand(2,initial_list_length),round(amount/10,0.01))) //double round to keep it at a somewhat even spread relative to amount without getting funky numbers.
//min ensures we don't go over amount.
// If the logic above means removing really tiny amounts (or even zero if it's a remove amount of 10) instead choose a sensible smallish number
// so this proc will actually finish instead of looping forever
remove_amt = max(CHEMICAL_VOLUME_ROUNDING, remove_amt)
remove_reagent(R.type, remove_amt)

current_list_element++
Expand Down Expand Up @@ -680,30 +681,6 @@
reagent.metabolizing = FALSE
reagent.on_mob_end_metabolize(C, metabolism_class)


/**
* Calls [/datum/reagent/proc/on_move] on every reagent in this holder
*
* Arguments:
* * atom/A - passed to on_move
* * Running - passed to on_move
*/
/datum/reagents/proc/conditional_update_move(atom/A, Running = 0)
for(var/datum/reagent/reagent as anything in reagent_list)
reagent.on_move(A, Running)
update_total()

/**
* Calls [/datum/reagent/proc/on_update] on every reagent in this holder
*
* Arguments:
* * atom/A - passed to on_update
*/
/datum/reagents/proc/conditional_update(atom/A)
for(var/datum/reagent/reagent as anything in reagent_list)
reagent.on_update(A)
update_total()

/// Handle any reactions possible in this holder
/// Also UPDATES the reaction list
/// High potential for infinite loopsa if you're editing this.
Expand Down
Loading

0 comments on commit a311a56

Please sign in to comment.