diff --git a/code/modules/projectiles/ammunition.dm b/code/modules/projectiles/ammunition.dm
index 75ba24579b11b..bbdfe62890bd6 100644
--- a/code/modules/projectiles/ammunition.dm
+++ b/code/modules/projectiles/ammunition.dm
@@ -17,19 +17,6 @@
var/fall_sounds = list('sound/weapons/guns/casingfall1.ogg','sound/weapons/guns/casingfall2.ogg','sound/weapons/guns/casingfall3.ogg')
-
-/obj/item/ammo_magazine/proc/create_initial_contents()
- if(contents_initialized || !initial_ammo || !ammo_type)
- return
- for(var/i in 1 to initial_ammo)
- stored_ammo += new ammo_type(src)
-
-/obj/item/ammo_magazine/proc/get_stored_ammo_count()
- . = length(stored_ammo)
- if(!contents_initialized)
- . += initial_ammo
-
-
/obj/item/ammo_casing/Initialize()
if(ispath(projectile_type))
BB = new projectile_type(src)
@@ -139,11 +126,6 @@
var/list/icon_keys = list() //keys
var/list/ammo_states = list() //values
- /// Determines whether or not we wait until the first time our contents are gotten to initialize contents. May lead to icon bugs if not handled delicately.
- var/lazyload_contents = TRUE
- /// Whether or not our contents have been initialized or not, used in lazyloaded contents.
- var/contents_initialized = FALSE
-
/obj/item/ammo_magazine/box
w_class = ITEM_SIZE_NORMAL
@@ -157,8 +139,9 @@
if(isnull(initial_ammo))
initial_ammo = max_ammo
- if(!lazyload_contents)
- create_initial_contents()
+ if(initial_ammo)
+ for(var/i in 1 to initial_ammo)
+ stored_ammo += new ammo_type(src)
if(caliber)
LAZYINSERT(labels, caliber, 1)
if(LAZYLEN(labels))
@@ -172,7 +155,7 @@
if(C.caliber != caliber)
to_chat(user, SPAN_WARNING("\The [C] does not fit into \the [src]."))
return TRUE
- if(get_stored_ammo_count() >= max_ammo)
+ if(length(stored_ammo) >= max_ammo)
to_chat(user, SPAN_WARNING("\The [src] is full!"))
return TRUE
if(!user.unEquip(C, src))
@@ -185,7 +168,6 @@
/obj/item/ammo_magazine/attack_self(mob/user)
- create_initial_contents()
if(!length(stored_ammo))
to_chat(user, SPAN_NOTICE("[src] is already empty!"))
return
@@ -199,7 +181,6 @@
/obj/item/ammo_magazine/attack_hand(mob/user)
if(user.get_inactive_hand() == src)
- create_initial_contents()
if(!length(stored_ammo))
to_chat(user, SPAN_NOTICE("[src] is already empty!"))
else
@@ -233,12 +214,11 @@
icon_state = initial(icon_state)
if(multiple_sprites)
- //find the lowest key greater than or equal to our ammo count
+ //find the lowest key greater than or equal to length(stored_ammo)
var/new_state = null
- var/self_ammo_count = get_stored_ammo_count()
for(var/idx in 1 to length(icon_keys))
- var/icon_ammo_count = icon_keys[idx]
- if (icon_ammo_count >= self_ammo_count)
+ var/ammo_count = icon_keys[idx]
+ if (ammo_count >= length(stored_ammo))
new_state = ammo_states[idx]
break
icon_state = (new_state)? new_state : initial(icon_state)
@@ -246,8 +226,7 @@
/obj/item/ammo_magazine/examine(mob/user)
. = ..()
- var/self_ammo_count = get_stored_ammo_count()
- to_chat(user, "There [(self_ammo_count == 1)? "is" : "are"] [self_ammo_count] round\s left!")
+ to_chat(user, "There [(length(stored_ammo) == 1)? "is" : "are"] [length(stored_ammo)] round\s left!")
//magazine icon state caching
diff --git a/code/modules/projectiles/ammunition/boxes.dm b/code/modules/projectiles/ammunition/boxes.dm
index 476a80b918514..8b99c3eca519b 100644
--- a/code/modules/projectiles/ammunition/boxes.dm
+++ b/code/modules/projectiles/ammunition/boxes.dm
@@ -80,7 +80,6 @@
/obj/item/ammo_magazine/shotholder/attack_hand(mob/user)
if((user.a_intent == I_HURT) && (length(stored_ammo)))
- create_initial_contents()
var/obj/item/ammo_casing/C = stored_ammo[length(stored_ammo)]
stored_ammo-=C
user.put_in_hands(C)
diff --git a/code/modules/projectiles/guns/projectile.dm b/code/modules/projectiles/guns/projectile.dm
index 358b84541b8b6..2321283af05ce 100644
--- a/code/modules/projectiles/guns/projectile.dm
+++ b/code/modules/projectiles/guns/projectile.dm
@@ -73,16 +73,10 @@
chambered = loaded[1] //load next casing.
if(handle_casings != HOLD_CASINGS)
loaded -= chambered
- else if(ammo_magazine)
- if(!ammo_magazine.contents_initialized && ammo_magazine.initial_ammo > 0)
- chambered = new ammo_magazine.ammo_type(src)
- if(handle_casings == HOLD_CASINGS)
- ammo_magazine.stored_ammo += chambered
- ammo_magazine.initial_ammo--
- else if(ammo_magazine && length(ammo_magazine.stored_ammo))
- chambered = ammo_magazine.stored_ammo[length(ammo_magazine.stored_ammo)]
- if(handle_casings != HOLD_CASINGS)
- ammo_magazine.stored_ammo -= chambered
+ else if(ammo_magazine && length(ammo_magazine.stored_ammo))
+ chambered = ammo_magazine.stored_ammo[length(ammo_magazine.stored_ammo)]
+ if(handle_casings != HOLD_CASINGS)
+ ammo_magazine.stored_ammo -= chambered
if (chambered)
return chambered.BB
@@ -321,7 +315,7 @@
/obj/item/gun/projectile/afterattack(atom/A, mob/living/user)
..()
- if(auto_eject && ammo_magazine && !ammo_magazine.get_stored_ammo_count())
+ if(auto_eject && ammo_magazine && ammo_magazine.stored_ammo && !length(ammo_magazine.stored_ammo))
ammo_magazine.dropInto(user.loc)
user.visible_message(
"[ammo_magazine] falls out and clatters on the floor!",
@@ -348,8 +342,8 @@
var/bullets = 0
if(loaded)
bullets += length(loaded)
- if(ammo_magazine)
- bullets += ammo_magazine.get_stored_ammo_count()
+ if(ammo_magazine && ammo_magazine.stored_ammo)
+ bullets += length(ammo_magazine.stored_ammo)
if(chambered)
bullets += 1
return bullets
diff --git a/code/modules/projectiles/guns/projectile/automatic.dm b/code/modules/projectiles/guns/projectile/automatic.dm
index 0764fb9f2cf6b..9d566499e507d 100644
--- a/code/modules/projectiles/guns/projectile/automatic.dm
+++ b/code/modules/projectiles/guns/projectile/automatic.dm
@@ -246,7 +246,7 @@
/obj/item/gun/projectile/automatic/bullpup_rifle/on_update_icon()
..()
if(ammo_magazine)
- if(length(ammo_magazine.get_stored_ammo_count()))
+ if(length(ammo_magazine.stored_ammo))
icon_state = "carbine-loaded"
else
icon_state = "carbine-empty"
@@ -351,7 +351,7 @@
/obj/item/gun/projectile/automatic/l6_saw/on_update_icon()
..()
if(istype(ammo_magazine, /obj/item/ammo_magazine/box))
- icon_state = "l6[cover_open ? "open" : "closed"][round(length(ammo_magazine.get_stored_ammo_count()), 10)]"
+ icon_state = "l6[cover_open ? "open" : "closed"][round(length(ammo_magazine.stored_ammo), 10)]"
item_state = "l6[cover_open ? "open" : "closed"]"
wielded_item_state = "l6[cover_open ? "open" : "closed"]-wielded"
else if(ammo_magazine)
diff --git a/code/modules/projectiles/guns/projectile/dartgun.dm b/code/modules/projectiles/guns/projectile/dartgun.dm
index dd80f273617f2..bb29b584eaba4 100644
--- a/code/modules/projectiles/guns/projectile/dartgun.dm
+++ b/code/modules/projectiles/guns/projectile/dartgun.dm
@@ -81,12 +81,12 @@
icon_state = "dartgun-empty"
return 1
- if(!ammo_magazine.get_stored_ammo_count() || length(ammo_magazine.get_stored_ammo_count()))
+ if(!ammo_magazine.stored_ammo || length(ammo_magazine.stored_ammo))
icon_state = "dartgun-0"
- else if(length(ammo_magazine.get_stored_ammo_count()) > 5)
+ else if(length(ammo_magazine.stored_ammo) > 5)
icon_state = "dartgun-5"
else
- icon_state = "dartgun-[length(ammo_magazine.get_stored_ammo_count())]"
+ icon_state = "dartgun-[length(ammo_magazine.stored_ammo)]"
return 1
/obj/item/gun/projectile/dartgun/consume_next_projectile()
@@ -166,8 +166,8 @@
dat += " \[Eject\]
"
if(ammo_magazine)
- if(ammo_magazine.stored_ammo && length(ammo_magazine.get_stored_ammo_count()))
- dat += "The dart cartridge has [length(ammo_magazine.get_stored_ammo_count())] shots remaining."
+ if(ammo_magazine.stored_ammo && length(ammo_magazine.stored_ammo))
+ dat += "The dart cartridge has [length(ammo_magazine.stored_ammo)] shots remaining."
else
dat += SPAN_COLOR("red", "The dart cartridge is empty!")
dat += " \[Eject\]
"