Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix prevent belt flare being filled by dump in action leaving no space for flare gun. #4110

Merged
merged 16 commits into from
Aug 20, 2023
15 changes: 15 additions & 0 deletions code/game/objects/items/storage/belt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
///TRUE Means that it closes a flap over its contents, and therefore update_icon should lift that flap when opened. If it doesn't have _half and _full iconstates, this doesn't matter either way.
var/flap = TRUE

/obj/item/storage/belt/gun/flaregun/dump_into(obj/item/storage/Main, mob/user)
Huffie56 marked this conversation as resolved.
Show resolved Hide resolved

if(length(holstered_guns) < 1 && length(contents) >= (storage_slots-1))

to_chat(user, SPAN_WARNING("[src] is full."))
return FALSE
return ..()

/obj/item/storage/belt/gun/flaregun/handle_item_insertion(obj/item/Warn, prevent_warning = 0, mob/user)
Huffie56 marked this conversation as resolved.
Show resolved Hide resolved

if(Warn.type == /obj/item/device/flashlight/flare && length(holstered_guns) < 1 && contents.len >= (storage_slots-1))
Huffie56 marked this conversation as resolved.
Show resolved Hide resolved
return FALSE
return ..()

/obj/item/storage/belt/equipped(mob/user, slot)
switch(slot)
if(WEAR_WAIST, WEAR_J_STORE, WEAR_BACK)
Expand Down Expand Up @@ -900,6 +914,7 @@
for(var/slot in holster_slots)
if(AM == holster_slots[slot]["gun"])
holster_slots[slot]["gun"] = null

update_gun_icon(slot)
return

Expand Down
28 changes: 14 additions & 14 deletions code/game/objects/items/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
var/storage_flags = STORAGE_FLAGS_DEFAULT
var/has_gamemode_skin = FALSE ///Whether to use map-variant skins.


/obj/item/storage/MouseDrop(obj/over_object as obj)
if(CAN_PICKUP(usr, src))
if(over_object == usr) // this must come before the screen objects only block
Expand Down Expand Up @@ -455,16 +454,16 @@ That's done by can_be_inserted(). Its checks are whether the item exists, is an
The stop_warning parameter will stop the insertion message from being displayed. It is intended for cases where you are inserting multiple
items at once, such as when picking up all the items on a tile with one click.
user can be null, it refers to the potential mob doing the insertion.**/
/obj/item/storage/proc/handle_item_insertion(obj/item/W, prevent_warning = 0, mob/user)
if(!istype(W))
/obj/item/storage/proc/handle_item_insertion(obj/item/Warn, prevent_warning = 0, mob/user)
Huffie56 marked this conversation as resolved.
Show resolved Hide resolved
if(!istype(Warn))
return FALSE
if(user && W.loc == user)
if(!user.drop_inv_item_to_loc(W, src))
if(user && Warn.loc == user)
if(!user.drop_inv_item_to_loc(Warn, src))
return FALSE
else
W.forceMove(src)
Warn.forceMove(src)

_item_insertion(W, prevent_warning, user)
_item_insertion(Warn, prevent_warning, user)
return TRUE

/**Inserts the item. Separate proc because handle_item_insertion isn't guaranteed to insert
Expand Down Expand Up @@ -721,24 +720,25 @@ W is always an item. stop_warning prevents messaging. user may be null.**/
to_chat(user, SPAN_WARNING("[ammo_dumping] is empty."))
return TRUE

Huffie56 marked this conversation as resolved.
Show resolved Hide resolved
/obj/item/storage/proc/dump_into(obj/item/storage/M, mob/user)
/obj/item/storage/proc/dump_into(obj/item/storage/Main, mob/user)
Huffie56 marked this conversation as resolved.
Show resolved Hide resolved

if(user.action_busy)
return

if(!M.contents.len)
to_chat(user, SPAN_WARNING("[M] is empty."))
if(!Main.contents.len)
to_chat(user, SPAN_WARNING("[Main] is empty."))
return
if(!has_room(M.contents[1])) //Does it have room for the first item to be inserted?
if(!has_room(Main.contents[1])) //Does it have room for the first item to be inserted?
to_chat(user, SPAN_WARNING("[src] is full."))
return

to_chat(user, SPAN_NOTICE("You start refilling [src] with [M]."))
to_chat(user, SPAN_NOTICE("You start refilling [src] with [Main]."))
if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC))
return
for(var/obj/item/I in M)
for(var/obj/item/I in Main)
Huffie56 marked this conversation as resolved.
Show resolved Hide resolved
if(!has_room(I))
Huffie56 marked this conversation as resolved.
Show resolved Hide resolved
break
M.remove_from_storage(I)
Main.remove_from_storage(I)
handle_item_insertion(I, TRUE, user) //quiet insertion

playsound(user.loc, "rustle", 15, TRUE, 6)
Expand Down