[NO GBP] Fixes some guns runtiming when attempting to reload (#87579)

## About The Pull Request

Closes #87567
Closes #87559

I have zero clue how this code worked during TMs or prior to my changes,
only sensible explanation I can come up with being that we had a
horrific hanging refs issue this entire time?

## Changelog
🆑
fix: Fixed some guns runtiming when attempting to reload
/🆑
This commit is contained in:
SmArtKar
2024-11-01 01:07:47 +01:00
committed by GitHub
parent b67b28ab5d
commit c0c1074bb0
3 changed files with 16 additions and 16 deletions

View File

@@ -81,6 +81,15 @@
return readout.Join("\n")
///list of every bullet in the box
///forces all bullets to lazyload
/obj/item/ammo_box/proc/ammo_list()
for (var/i in 1 to length(stored_ammo))
if (ispath(stored_ammo[i]))
var/casing_type = stored_ammo[i]
stored_ammo[i] = new casing_type(src)
return stored_ammo.Copy()
/**
* top_off is used to refill the magazine to max, in case you want to increase the size of a magazine with VV then refill it at once
*
@@ -159,7 +168,7 @@
if(istype(tool, /obj/item/ammo_box))
var/obj/item/ammo_box/other_box = tool
for(var/obj/item/ammo_casing/casing in other_box.stored_ammo)
for(var/obj/item/ammo_casing/casing in other_box.ammo_list())
var/did_load = give_round(casing, replace_spent)
if(did_load)
other_box.stored_ammo -= casing
@@ -249,15 +258,6 @@
boolets++
return boolets
///list of every bullet in the magazine
///forces all bullets to lazyload
/obj/item/ammo_box/magazine/proc/ammo_list()
for (var/i in 1 to length(stored_ammo))
if (ispath(stored_ammo[i]))
var/casing_type = stored_ammo[i]
stored_ammo[i] = new casing_type(src)
return stored_ammo.Copy()
///drops the entire contents of the magazine on the floor
/obj/item/ammo_box/magazine/proc/empty_magazine()
var/turf/turf_mag = get_turf(src)

View File

@@ -34,7 +34,7 @@
rotate()
/obj/item/ammo_box/magazine/internal/cylinder/ammo_list()
var/list/no_nulls_ammo = stored_ammo.Copy()
var/list/no_nulls_ammo = ..()
list_clear_nulls(no_nulls_ammo)
return no_nulls_ammo
@@ -44,7 +44,7 @@
for(var/i in 1 to stored_ammo.len)
var/obj/item/ammo_casing/bullet = stored_ammo[i]
if (!istype(bullet) || bullet.loaded_projectile)
if (istype(bullet) && bullet.loaded_projectile)
continue
// found a spent ammo
stored_ammo[i] = R

View File

@@ -547,13 +547,13 @@
return
if(bolt_type == BOLT_TYPE_NO_BOLT)
var/num_unloaded = 0
for(var/obj/item/ammo_casing/CB as anything in get_ammo_list(FALSE))
CB.forceMove(drop_location())
CB.bounce_away(FALSE, NONE)
for(var/obj/item/ammo_casing/casing as anything in get_ammo_list(FALSE))
casing.forceMove(drop_location())
casing.bounce_away(FALSE, NONE)
num_unloaded++
var/turf/T = get_turf(drop_location())
if(T && is_station_level(T.z))
SSblackbox.record_feedback("tally", "station_mess_created", 1, CB.name)
SSblackbox.record_feedback("tally", "station_mess_created", 1, casing.name)
if (num_unloaded)
balloon_alert(user, "[num_unloaded] [cartridge_wording]\s unloaded")
playsound(user, eject_sound, eject_sound_volume, eject_sound_vary)