Skip to content

Commit

Permalink
Minor Code Maintenance Bundle (deletes, standards, runtimes) (#4756)
Browse files Browse the repository at this point in the history
# About the pull request

Just some bundled code maintenance bits:
 * annotations and variable names 
 * loc -> forceMove / New -> Initialize, GLOB variables, per standard
 * add some missing ref clearing in Destroy
 * dead code
 * fix minor runtimes 
 * runtime fix in gear presets spamming logs
 * fixes a typo in bottles making them use only 1 of the 4 sprites

<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

# Explain why it's good for the game
Standards, bugfixing


# Changelog
:cl:
fix: Spawned bottles now use all 4 of their sprites as intended rather
than always the same.
/:cl:
  • Loading branch information
fira authored Nov 7, 2023
1 parent a341a35 commit 2c9ef44
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 42 deletions.
15 changes: 7 additions & 8 deletions code/game/objects/effects/spawners/random.dm
Original file line number Diff line number Diff line change
Expand Up @@ -351,29 +351,28 @@

/obj/effect/spawner/random/gun/proc/spawn_weapon_on_floor(gunpath, ammopath, ammo_amount = 1)

var/atom/spawnloc = src
spawnloc = get_turf(spawnloc)
var/turf/spawnloc = get_turf(src)
var/obj/gun
var/obj/ammo

if(gunpath)
gun = new gunpath(spawnloc)
if(scatter)
var/direction = pick(alldirs)
var/turf/T = get_step(gun, direction)
if(!T || T.density)
var/turf/turf = get_step(gun, direction)
if(!turf || turf.density)
return
gun.loc = T
gun.forceMove(turf)
if(ammopath)
for(var/i in 0 to ammo_amount-1)
ammo = new ammopath(spawnloc)
if(scatter)
for(i=0, i<rand(1,3), i++)
var/direction = pick(alldirs)
var/turf/T = get_step(ammo, direction)
if(!T || T.density)
var/turf/turf = get_step(ammo, direction)
if(!turf || turf.density)
break
ammo.loc = T
ammo.forceMove(turf)

/*
// the actual spawners themselves
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/reagent_containers/glass/bottle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/obj/item/reagent_container/glass/bottle/Initialize()
. = ..()
if(!icon_state)
icon_state = "bottle-[rand(1.4)]"
icon_state = "bottle-[rand(1,4)]"

/obj/item/reagent_container/glass/bottle/update_icon()
overlays.Cut()
Expand Down
16 changes: 13 additions & 3 deletions code/game/objects/items/storage/backpack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,18 @@ GLOBAL_LIST_EMPTY_TYPED(radio_packs, /obj/item/storage/backpack/marine/satchel/r

/obj/item/storage/backpack/marine/satchel/rto/pickup(mob/user)
. = ..()
autoset_phone_id(user)

/obj/item/storage/backpack/marine/satchel/rto/equipped(mob/user, slot)
. = ..()
autoset_phone_id(user)

/// Automatically sets the phone_id based on the current or updated user
/obj/item/storage/backpack/marine/satchel/rto/proc/autoset_phone_id(mob/user)
if(!user)
internal_transmitter.phone_id = "[src]"
internal_transmitter.enabled = FALSE
return
if(ishuman(user))
var/mob/living/carbon/human/H = user
if(H.comm_title)
Expand All @@ -579,13 +591,11 @@ GLOBAL_LIST_EMPTY_TYPED(radio_packs, /obj/item/storage/backpack/marine/satchel/r
internal_transmitter.phone_id += " ([H.assigned_squad.name])"
else
internal_transmitter.phone_id = "[user]"

internal_transmitter.enabled = TRUE

/obj/item/storage/backpack/marine/satchel/rto/dropped(mob/user)
. = ..()
internal_transmitter.phone_id = "[src]"
internal_transmitter.enabled = FALSE
autoset_phone_id(null) // Disable phone when dropped

/obj/item/storage/backpack/marine/satchel/rto/proc/use_phone(mob/user)
internal_transmitter.attack_hand(user)
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/storage/boxes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
RegisterSignal(SSdcs, COMSIG_GLOB_MODE_PRESETUP, PROC_REF(handle_delete_clash_contents))

/obj/item/storage/box/flashbangs/proc/handle_delete_clash_contents()
SIGNAL_HANDLER
if(MODE_HAS_FLAG(MODE_FACTION_CLASH))
var/grenade_count = 0
var/grenades_desired = 4
Expand Down
21 changes: 11 additions & 10 deletions code/game/objects/items/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
var/atom/movable/screen/storage/storage_start = null //storage UI
var/atom/movable/screen/storage/storage_continue = null
var/atom/movable/screen/storage/storage_end = null
var/datum/item_storage_box/stored_ISB = null // This contains what previously was known as stored_start, stored_continue, and stored_end
var/datum/item_storage_box/stored_ISB //! This contains what previously was known as stored_start, stored_continue, and stored_end
var/atom/movable/screen/close/closer = null
var/foldable = null
var/use_sound = "rustle" //sound played when used. null for no sound.
Expand Down Expand Up @@ -212,16 +212,17 @@
if (storage_flags & STORAGE_SHOW_FULLNESS)
boxes.update_fullness(src)

var/list/global/item_storage_box_cache = list()
GLOBAL_LIST_EMPTY_TYPED(item_storage_box_cache, /datum/item_storage_box)

/datum/item_storage_box
var/atom/movable/screen/storage/start = null
var/atom/movable/screen/storage/continued = null
var/atom/movable/screen/storage/end = null
/// The index that indentifies me inside item_storage_box_cache
var/atom/movable/screen/storage/start
var/atom/movable/screen/storage/continued
var/atom/movable/screen/storage/end
/// The index that indentifies me inside GLOB.item_storage_box_cache
var/index

/datum/item_storage_box/New()
. = ..()
start = new()
start.icon_state = "stored_start"
continued = new()
Expand All @@ -233,7 +234,7 @@ var/list/global/item_storage_box_cache = list()
QDEL_NULL(start)
QDEL_NULL(continued)
QDEL_NULL(end)
item_storage_box_cache[index] = null // Or would it be better to -= src?
GLOB.item_storage_box_cache -= index
return ..()

/obj/item/storage/proc/space_orient_objs(list/obj/item/display_contents)
Expand Down Expand Up @@ -271,7 +272,7 @@ var/list/global/item_storage_box_cache = list()
click_border_start.Add(startpoint)
click_border_end.Add(endpoint)

if(!item_storage_box_cache[isb_index])
if(!GLOB.item_storage_box_cache[isb_index])
var/datum/item_storage_box/box = new()
var/matrix/M_start = matrix()
var/matrix/M_continue = matrix()
Expand All @@ -284,9 +285,9 @@ var/list/global/item_storage_box_cache = list()
box.continued.apply_transform(M_continue)
box.end.apply_transform(M_end)
box.index = isb_index
item_storage_box_cache[isb_index] = box
GLOB.item_storage_box_cache[isb_index] = box

var/datum/item_storage_box/ISB = item_storage_box_cache[isb_index]
var/datum/item_storage_box/ISB = GLOB.item_storage_box_cache[isb_index]
stored_ISB = ISB

storage_start.overlays += ISB.start
Expand Down
2 changes: 2 additions & 0 deletions code/game/objects/structures/flora.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ PLANT_CUT_MACHETE = 3 = Needs at least a machete to be cut down
addtimer(CALLBACK(src, PROC_REF(burn_up)), spread_time + 5 SECONDS)

/obj/structure/flora/proc/spread_fire()
SIGNAL_HANDLER
for(var/D in cardinal) //Spread fire
var/turf/T = get_step(src.loc, D)
if(T)
Expand All @@ -82,6 +83,7 @@ PLANT_CUT_MACHETE = 3 = Needs at least a machete to be cut down
new /obj/flamer_fire(T, create_cause_data("wildfire"))

/obj/structure/flora/proc/burn_up()
SIGNAL_HANDLER
new /obj/effect/decal/cleanable/dirt(loc)
if(center)
new /obj/effect/decal/cleanable/dirt(loc) //Produces more ash at the center
Expand Down
6 changes: 3 additions & 3 deletions code/modules/cm_marines/smartgun_mount.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@
var/rounds = 0 // How many rounds are in the weapon. This is useful if we break down our guns.
var/has_mount = FALSE // Indicates whether the M56D will come with its folding mount already attached

/obj/item/device/m56d_gun/New()
..()

/obj/item/device/m56d_gun/Initialize(mapload, ...)
. = ..()
update_icon()

/obj/item/device/m56d_gun/get_examine_text(mob/user) //Let us see how much ammo we got in this thing.
Expand Down Expand Up @@ -519,6 +518,7 @@
operator = null
QDEL_NULL(in_chamber)
STOP_PROCESSING(SSobj, src)
ammo = null
return ..()

/obj/structure/machinery/m56d_hmg/get_examine_text(mob/user) //Let us see how much ammo we got in this thing.
Expand Down
6 changes: 3 additions & 3 deletions code/modules/cm_tech/implements/railgun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ GLOBAL_DATUM(railgun_eye_location, /datum/coords)
RegisterSignal(eye, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(check_and_set_zlevel))
RegisterSignal(eye, COMSIG_PARENT_QDELETING, PROC_REF(remove_current_operator))

/obj/structure/machinery/computer/railgun/proc/check_and_set_zlevel(mob/hologram/railgun/H, turf/NewLoc, direction)
/obj/structure/machinery/computer/railgun/proc/check_and_set_zlevel(mob/hologram/railgun/hologram, turf/NewLoc, direction)
SIGNAL_HANDLER
if(!start_location)
start_location = GLOB.railgun_eye_location.get_turf_from_coord()

if(!NewLoc || (NewLoc.z != target_z && H.z != target_z))
H.loc = start_location
if(!NewLoc || (NewLoc.z != target_z && hologram.z != target_z))
hologram.forceMove(start_location)
return COMPONENT_OVERRIDE_MOVE

/obj/structure/machinery/computer/railgun/proc/can_fire(mob/living/carbon/human/H, turf/T)
Expand Down
2 changes: 0 additions & 2 deletions code/modules/gear_presets/cmb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,6 @@
new_human.equip_to_slot_or_del(new /obj/item/storage/pouch/construction/full, WEAR_R_STORE)
new_human.equip_to_slot_or_del(new /obj/item/storage/pouch/firstaid/ert, WEAR_L_STORE)

new_human.back.pickup()

//Anchorpoint Station Corpsman
/datum/equipment_preset/uscm/cmb/medic
name = "USCM Anchorpoint Station Corpsman"
Expand Down
2 changes: 0 additions & 2 deletions code/modules/gear_presets/uscm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,6 @@
new_human.equip_to_slot_or_del(new /obj/item/storage/pouch/general/large(new_human), WEAR_R_STORE)
new_human.equip_to_slot_or_del(new /obj/item/device/binoculars(new_human), WEAR_L_HAND)

new_human.back.pickup()

/datum/equipment_preset/uscm/tl_equipped/cryo
name = "USCM Cryo Fireteam Leader (Equipped)"
auto_squad_name = SQUAD_MARINE_CRYO
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,11 @@
if(observe_target_mob)
clean_observe_target()

/mob/dead/observer/Destroy()
/mob/dead/observer/Destroy(force)
GLOB.observer_list -= src
QDEL_NULL(orbit_menu)
QDEL_NULL(last_health_display)
GLOB.observer_list -= src
QDEL_NULL(minimap)
following = null
observe_target_mob = null
observe_target_client = null
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/xenomorph/Embryo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
victim.pain.apply_pain(PAIN_CHESTBURST_STRONG) //ow that really hurts larvie!
var/message = SPAN_HIGHDANGER( pick("IT'S IN YOUR INSIDES!", "IT'S GNAWING YOU!", "MAKE IT STOP!", "YOU ARE GOING TO DIE!", "IT'S TEARING YOU APART!"))
to_chat(victim, message)
addtimer(CALLBACK(src, PROC_REF(cause_unbearable_pain), victim), rand(1, 3) SECONDS, TIMER_UNIQUE)
addtimer(CALLBACK(src, PROC_REF(cause_unbearable_pain), victim), rand(1, 3) SECONDS, TIMER_UNIQUE|TIMER_NO_HASH_WAIT)

/mob/living/carbon/xenomorph/larva/proc/chest_burst(mob/living/carbon/victim)
set waitfor = 0
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/xenomorph/Xenomorph.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@
if(length(resin_build_order))
selected_resin = resin_build_order[1]

/mob/living/carbon/xenomorph/ghostize(can_reenter_corpse = TRUE)
/mob/living/carbon/xenomorph/ghostize(can_reenter_corpse = TRUE, aghosted = FALSE)
. = ..()
if(. && !can_reenter_corpse && stat != DEAD && !QDELETED(src) && !is_admin_level(z))
handle_ghost_message()
Expand Down
7 changes: 1 addition & 6 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,11 @@
/obj/item/weapon/gun/Destroy()
in_chamber = null
ammo = null
current_mag = null
QDEL_NULL(current_mag)
target = null
last_moved_mob = null
if(flags_gun_features & GUN_FLASHLIGHT_ON)//Handle flashlight.
flags_gun_features &= ~GUN_FLASHLIGHT_ON
if(ismob(loc))
for(var/slot in attachments)
var/obj/item/attachable/potential_attachment = attachments[slot]
if(!potential_attachment)
continue
attachments = null
attachable_overlays = null
QDEL_NULL(active_attachable)
Expand Down

0 comments on commit 2c9ef44

Please sign in to comment.