mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-01 18:25:13 +01:00
7be78d4c50
## Description Fixed a bug where splitting a stack of two cartridges would delete one of them and cause a runtime. Both of these were caused in `/obj/item/ammo_pile/proc/check_ammo()`. In this case the proc is called after the second-to-last round has been removed. The *intention* is for the final bullet to be moved onto the floor, then the `/obj/item/ammo_pile` item is deleted, then the bullet is equipped into the user's hand in its place. In practice, the bullet is never actually removed from the pile's `ammo` list, so it gets deleted alongside it when the list is cleaned up in `/obj/item/ammo_pile/Destroy()`. https://github.com/Aurorastation/Aurora.3/blob/ea939d0aa2cae35dc14dc1f41c94773b87b40003/code/modules/projectiles/ammunition/ammo_pile.dm#L125-L135 The runtime happens on L135 when it continues on after that since there isn't a return. (`ammo` doesn't exist anymore). ## Media ### Before: https://github.com/user-attachments/assets/dadad09f-5291-4f90-ad5b-9989d5d11735 **Result after unloading and manually reloading a magazine:** <img width="315" height="82" alt="before 1" src="https://github.com/user-attachments/assets/69e4ae2b-dbb9-4c2e-a1b9-30c911b08463" /> ### After: https://github.com/user-attachments/assets/13a5f4c4-0711-4f64-b74c-3f2bc968a4d3 **Result after unloading and manually reloading a magazine:** <img width="315" height="81" alt="after 1" src="https://github.com/user-attachments/assets/911e25e0-84b1-4a98-9bb3-8bca9469349e" /> ## Changelog - ~~rscdel: Banished the ammo goblin, who fed upon loose cartridges.~~ - bugfix: Fixed the last round in an ammo pile (stack of cartridges) getting deleted after the second-to-last round was removed. - bugfix: Fixed 'runtime error: list index out of bounds' in `/obj/item/ammo_pile/proc/check_ammo()`. (Not player facing)