From ca8a4697d47a356f887c635c9ab1da201b6e4bf8 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 4 Aug 2023 17:06:04 +0200 Subject: [PATCH 01/16] fix the issue? maybe probably won't work. --- code/game/objects/items/storage/belt.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 290460da758f..12024e05a953 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -1476,7 +1476,9 @@ /obj/item/storage/belt/gun/flaregun/attackby(obj/item/W, mob/user) if(istype(W, /obj/item/storage/box/m94)) var/obj/item/storage/box/m94/M = W + storage_slots = 16 dump_into(M,user) + storage_slots = 17 else return ..() From 8aebcba2a90dc75df814af56d91dbb238ccf45a0 Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 6 Aug 2023 12:47:35 +0200 Subject: [PATCH 02/16] should make it way better --- code/game/objects/items/storage/belt.dm | 4 +- code/game/objects/items/storage/storage.dm | 43 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 12024e05a953..b6e76016746e 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -1476,9 +1476,7 @@ /obj/item/storage/belt/gun/flaregun/attackby(obj/item/W, mob/user) if(istype(W, /obj/item/storage/box/m94)) var/obj/item/storage/box/m94/M = W - storage_slots = 16 - dump_into(M,user) - storage_slots = 17 + dump_ammo_into_belt_holster(M,user) else return ..() diff --git a/code/game/objects/items/storage/storage.dm b/code/game/objects/items/storage/storage.dm index 36f946efdfdc..a7bee28852fe 100644 --- a/code/game/objects/items/storage/storage.dm +++ b/code/game/objects/items/storage/storage.dm @@ -30,7 +30,7 @@ var/list/content_watchers //list of mobs currently seeing the storage's contents var/storage_flags = STORAGE_FLAGS_DEFAULT var/has_gamemode_skin = FALSE ///Whether to use map-variant skins. - + /// TRUE mean this belt as an holster for a gun. this variable is used for the dump into action. /obj/item/storage/MouseDrop(obj/over_object as obj) if(CAN_PICKUP(usr, src)) @@ -697,7 +697,9 @@ W is always an item. stop_warning prevents messaging. user may be null.**/ if(ammo_dumping.flags_magazine & AMMUNITION_HANDFUL_BOX) var/handfuls = round(ammo_dumping.current_rounds / amount_to_dump, 1) //The number of handfuls, we round up because we still want the last one that isn't full if(ammo_dumping.current_rounds != 0) + if(contents.len < storage_slots) + to_chat(user, SPAN_NOTICE("You start refilling [src] with [ammo_dumping].")) if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) return for(var/i = 1 to handfuls) @@ -721,6 +723,45 @@ W is always an item. stop_warning prevents messaging. user may be null.**/ to_chat(user, SPAN_WARNING("[ammo_dumping] is empty.")) return TRUE +/obj/item/storage/proc/dump_ammo_into_belt_holster(obj/item/ammo_magazine/ammo_dumping, mob/user, amount_to_dump = 5) //amount_to_dump should never actually need to be used as default value + if(user.action_busy) + return + + if(ammo_dumping.flags_magazine & AMMUNITION_CANNOT_REMOVE_BULLETS) + to_chat(user, SPAN_WARNING("You can't remove ammo from \the [ammo_dumping]!")) + return + + if(ammo_dumping.flags_magazine & AMMUNITION_HANDFUL_BOX) + var/handfuls = round(ammo_dumping.current_rounds / amount_to_dump, 1) //The number of handfuls, we round up because we still want the last one that isn't full + if(ammo_dumping.current_rounds != 0) + + if(contents.len < (storage_slots - 1)) + + to_chat(user, SPAN_NOTICE("You start refilling [src] with [ammo_dumping].")) + if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) return + for(var/i = 1 to handfuls) + if(contents.len < (storage_slots - 1)) + //Hijacked from /obj/item/ammo_magazine/proc/create_handful because it had to be handled differently + //All this because shell types are instances and not their own objects :) + + var/obj/item/ammo_magazine/handful/new_handful = new /obj/item/ammo_magazine/handful + var/transferred_handfuls = min(ammo_dumping.current_rounds, amount_to_dump) + new_handful.generate_handful(ammo_dumping.default_ammo, ammo_dumping.caliber, amount_to_dump, transferred_handfuls, ammo_dumping.gun_type) + ammo_dumping.current_rounds -= transferred_handfuls + handle_item_insertion(new_handful, TRUE,user) + update_icon(-transferred_handfuls) + else + break + playsound(user.loc, "rustle", 15, TRUE, 6) + ammo_dumping.update_icon() + else + to_chat(user, SPAN_WARNING("[src] is full.")) + else + to_chat(user, SPAN_WARNING("[ammo_dumping] is empty.")) + return TRUE + + + /obj/item/storage/proc/dump_into(obj/item/storage/M, mob/user) if(user.action_busy) return From 56261a6f907c24fb6cffd76458e6b9dc34531aff Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 7 Aug 2023 16:48:14 +0200 Subject: [PATCH 03/16] fix the issue seem ok to me after test --- code/game/objects/items/storage/belt.dm | 3 +- code/game/objects/items/storage/storage.dm | 49 ++++------------------ 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index b6e76016746e..f5187417bded 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -1452,6 +1452,7 @@ name = "\improper M276 pattern M82F flare gun holster rig" desc = "The M276 is the standard load-bearing equipment of the USCM. It consists of a modular belt with various clips. This version is for the M82F flare gun." storage_slots = 17 + storage_holster = TRUE max_storage_space = 20 icon_state = "m82f_holster" item_state = "s_marinebelt" @@ -1476,7 +1477,7 @@ /obj/item/storage/belt/gun/flaregun/attackby(obj/item/W, mob/user) if(istype(W, /obj/item/storage/box/m94)) var/obj/item/storage/box/m94/M = W - dump_ammo_into_belt_holster(M,user) + dump_into(M,user) else return ..() diff --git a/code/game/objects/items/storage/storage.dm b/code/game/objects/items/storage/storage.dm index a7bee28852fe..01a25795ce7b 100644 --- a/code/game/objects/items/storage/storage.dm +++ b/code/game/objects/items/storage/storage.dm @@ -30,7 +30,7 @@ var/list/content_watchers //list of mobs currently seeing the storage's contents var/storage_flags = STORAGE_FLAGS_DEFAULT var/has_gamemode_skin = FALSE ///Whether to use map-variant skins. - /// TRUE mean this belt as an holster for a gun. this variable is used for the dump into action. + var/storage_holster = FALSE /obj/item/storage/MouseDrop(obj/over_object as obj) if(CAN_PICKUP(usr, src)) @@ -697,9 +697,7 @@ W is always an item. stop_warning prevents messaging. user may be null.**/ if(ammo_dumping.flags_magazine & AMMUNITION_HANDFUL_BOX) var/handfuls = round(ammo_dumping.current_rounds / amount_to_dump, 1) //The number of handfuls, we round up because we still want the last one that isn't full if(ammo_dumping.current_rounds != 0) - if(contents.len < storage_slots) - to_chat(user, SPAN_NOTICE("You start refilling [src] with [ammo_dumping].")) if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) return for(var/i = 1 to handfuls) @@ -723,46 +721,11 @@ W is always an item. stop_warning prevents messaging. user may be null.**/ to_chat(user, SPAN_WARNING("[ammo_dumping] is empty.")) return TRUE -/obj/item/storage/proc/dump_ammo_into_belt_holster(obj/item/ammo_magazine/ammo_dumping, mob/user, amount_to_dump = 5) //amount_to_dump should never actually need to be used as default value - if(user.action_busy) - return - - if(ammo_dumping.flags_magazine & AMMUNITION_CANNOT_REMOVE_BULLETS) - to_chat(user, SPAN_WARNING("You can't remove ammo from \the [ammo_dumping]!")) - return - - if(ammo_dumping.flags_magazine & AMMUNITION_HANDFUL_BOX) - var/handfuls = round(ammo_dumping.current_rounds / amount_to_dump, 1) //The number of handfuls, we round up because we still want the last one that isn't full - if(ammo_dumping.current_rounds != 0) - - if(contents.len < (storage_slots - 1)) - - to_chat(user, SPAN_NOTICE("You start refilling [src] with [ammo_dumping].")) - if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) return - for(var/i = 1 to handfuls) - if(contents.len < (storage_slots - 1)) - //Hijacked from /obj/item/ammo_magazine/proc/create_handful because it had to be handled differently - //All this because shell types are instances and not their own objects :) - - var/obj/item/ammo_magazine/handful/new_handful = new /obj/item/ammo_magazine/handful - var/transferred_handfuls = min(ammo_dumping.current_rounds, amount_to_dump) - new_handful.generate_handful(ammo_dumping.default_ammo, ammo_dumping.caliber, amount_to_dump, transferred_handfuls, ammo_dumping.gun_type) - ammo_dumping.current_rounds -= transferred_handfuls - handle_item_insertion(new_handful, TRUE,user) - update_icon(-transferred_handfuls) - else - break - playsound(user.loc, "rustle", 15, TRUE, 6) - ammo_dumping.update_icon() - else - to_chat(user, SPAN_WARNING("[src] is full.")) - else - to_chat(user, SPAN_WARNING("[ammo_dumping] is empty.")) - return TRUE - - - /obj/item/storage/proc/dump_into(obj/item/storage/M, mob/user) + if(storage_holster == TRUE && contents.len >= (storage_slots-1)) + to_chat(user, SPAN_WARNING("[src] is full.")) + return FALSE + if(user.action_busy) return @@ -777,6 +740,8 @@ W is always an item. stop_warning prevents messaging. user may be null.**/ if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) return for(var/obj/item/I in M) + if(storage_holster == TRUE && contents.len >= (storage_slots-1)) + break if(!has_room(I)) break M.remove_from_storage(I) From c924a957fab00b59b7ab7fe4f0267b79c1af66f7 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 9 Aug 2023 12:57:40 +0200 Subject: [PATCH 04/16] should make it way better --- code/game/objects/items/storage/belt.dm | 17 ++++++++++++++++- code/game/objects/items/storage/storage.dm | 6 ------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index f5187417bded..3d698d463fc7 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -15,6 +15,18 @@ cant_hold = list(/obj/item/weapon/throwing_knife) ///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 + var/holster_gun = FALSE + +/obj/item/storage/belt/proc/dump_into(obj/item/storage/M, mob/user) + if(holster_gun == FALSE && contents.len >= (storage_slots-1)) + to_chat(user, SPAN_WARNING("[src] is full.")) + return FALSE + ..() + +/obj/item/storage/belt/proc/handle_item_insertion(obj/item/W, prevent_warning = 0, mob/user) + if(holster_gun == FALSE && contents.len >= (storage_slots-1)) + return FALSE + ..() /obj/item/storage/belt/equipped(mob/user, slot) switch(slot) @@ -895,11 +907,14 @@ /obj/item/storage/belt/gun/on_stored_atom_del(atom/movable/AM) if(!isgun(AM)) + holster_gun = FALSE return holstered_guns -= AM + holster_gun = TRUE for(var/slot in holster_slots) if(AM == holster_slots[slot]["gun"]) holster_slots[slot]["gun"] = null + update_gun_icon(slot) return @@ -1452,7 +1467,7 @@ name = "\improper M276 pattern M82F flare gun holster rig" desc = "The M276 is the standard load-bearing equipment of the USCM. It consists of a modular belt with various clips. This version is for the M82F flare gun." storage_slots = 17 - storage_holster = TRUE + //storage_holster = TRUE max_storage_space = 20 icon_state = "m82f_holster" item_state = "s_marinebelt" diff --git a/code/game/objects/items/storage/storage.dm b/code/game/objects/items/storage/storage.dm index 01a25795ce7b..fc451a76e6d2 100644 --- a/code/game/objects/items/storage/storage.dm +++ b/code/game/objects/items/storage/storage.dm @@ -30,7 +30,6 @@ var/list/content_watchers //list of mobs currently seeing the storage's contents var/storage_flags = STORAGE_FLAGS_DEFAULT var/has_gamemode_skin = FALSE ///Whether to use map-variant skins. - var/storage_holster = FALSE /obj/item/storage/MouseDrop(obj/over_object as obj) if(CAN_PICKUP(usr, src)) @@ -722,9 +721,6 @@ W is always an item. stop_warning prevents messaging. user may be null.**/ return TRUE /obj/item/storage/proc/dump_into(obj/item/storage/M, mob/user) - if(storage_holster == TRUE && contents.len >= (storage_slots-1)) - to_chat(user, SPAN_WARNING("[src] is full.")) - return FALSE if(user.action_busy) return @@ -740,8 +736,6 @@ W is always an item. stop_warning prevents messaging. user may be null.**/ if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) return for(var/obj/item/I in M) - if(storage_holster == TRUE && contents.len >= (storage_slots-1)) - break if(!has_room(I)) break M.remove_from_storage(I) From e3fabcf5cef170a373b6ae80881348e29672a9c1 Mon Sep 17 00:00:00 2001 From: Julian56 <117036822+Huffie56@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:55:25 +0200 Subject: [PATCH 05/16] Update code/game/objects/items/storage/belt.dm Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com> --- code/game/objects/items/storage/belt.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 3d698d463fc7..2bee4bc804a7 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -17,13 +17,13 @@ var/flap = TRUE var/holster_gun = FALSE -/obj/item/storage/belt/proc/dump_into(obj/item/storage/M, mob/user) +/obj/item/storage/belt/gun/dump_into(obj/item/storage/M, mob/user) if(holster_gun == FALSE && contents.len >= (storage_slots-1)) to_chat(user, SPAN_WARNING("[src] is full.")) return FALSE ..() -/obj/item/storage/belt/proc/handle_item_insertion(obj/item/W, prevent_warning = 0, mob/user) +/obj/item/storage/belt/gun/handle_item_insertion(obj/item/W, prevent_warning = 0, mob/user) if(holster_gun == FALSE && contents.len >= (storage_slots-1)) return FALSE ..() From 5c4a55f1b579cda2d9ab24208692aff9d09746e2 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 10 Aug 2023 15:22:27 +0200 Subject: [PATCH 06/16] seem to work. maybe could be cleaner.... --- code/game/objects/items/storage/belt.dm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 2bee4bc804a7..3f610b3de564 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -18,13 +18,29 @@ var/holster_gun = FALSE /obj/item/storage/belt/gun/dump_into(obj/item/storage/M, mob/user) + for(var/slot in holster_slots) + if(!holster_slots[slot]["gun"]) //Open holster. + holster_gun = FALSE + break + if(holster_slots[slot]["gun"]) //Gun in holster. + holster_gun = TRUE + break + if(holster_gun == FALSE && contents.len >= (storage_slots-1)) to_chat(user, SPAN_WARNING("[src] is full.")) return FALSE ..() /obj/item/storage/belt/gun/handle_item_insertion(obj/item/W, prevent_warning = 0, mob/user) - if(holster_gun == FALSE && contents.len >= (storage_slots-1)) + for(var/slot in holster_slots) + if(!holster_slots[slot]["gun"]) //Open holster. + holster_gun = FALSE + break + if(holster_slots[slot]["gun"]) //gun in holster. + holster_gun = TRUE + break + + if(W.type == /obj/item/device/flashlight/flare && holster_gun == FALSE && contents.len >= (storage_slots-1)) return FALSE ..() @@ -907,10 +923,8 @@ /obj/item/storage/belt/gun/on_stored_atom_del(atom/movable/AM) if(!isgun(AM)) - holster_gun = FALSE return holstered_guns -= AM - holster_gun = TRUE for(var/slot in holster_slots) if(AM == holster_slots[slot]["gun"]) holster_slots[slot]["gun"] = null From f465e8d6758f38766ae9e4f86185da00b16a5e2d Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 10 Aug 2023 20:40:56 +0200 Subject: [PATCH 07/16] better code. single letter variable are great. --- code/game/objects/items/storage/belt.dm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 3f610b3de564..18929d5a9e54 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -15,9 +15,9 @@ cant_hold = list(/obj/item/weapon/throwing_knife) ///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 - var/holster_gun = FALSE /obj/item/storage/belt/gun/dump_into(obj/item/storage/M, mob/user) + var/holster_gun = FALSE for(var/slot in holster_slots) if(!holster_slots[slot]["gun"]) //Open holster. holster_gun = FALSE @@ -26,12 +26,14 @@ holster_gun = TRUE break - if(holster_gun == FALSE && contents.len >= (storage_slots-1)) + if(!holster_gun && length(contents) >= (storage_slots-1)) + to_chat(user, SPAN_WARNING("[src] is full.")) return FALSE - ..() + return ..() /obj/item/storage/belt/gun/handle_item_insertion(obj/item/W, prevent_warning = 0, mob/user) + var/holster_gun = FALSE for(var/slot in holster_slots) if(!holster_slots[slot]["gun"]) //Open holster. holster_gun = FALSE @@ -42,7 +44,7 @@ if(W.type == /obj/item/device/flashlight/flare && holster_gun == FALSE && contents.len >= (storage_slots-1)) return FALSE - ..() + return ..() /obj/item/storage/belt/equipped(mob/user, slot) switch(slot) @@ -1481,7 +1483,6 @@ name = "\improper M276 pattern M82F flare gun holster rig" desc = "The M276 is the standard load-bearing equipment of the USCM. It consists of a modular belt with various clips. This version is for the M82F flare gun." storage_slots = 17 - //storage_holster = TRUE max_storage_space = 20 icon_state = "m82f_holster" item_state = "s_marinebelt" From 8c12163c46bae12616104dc4a5c91122d3468a69 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 11 Aug 2023 09:34:00 +0200 Subject: [PATCH 08/16] fixgsdgq --- code/game/objects/items/storage/belt.dm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 18929d5a9e54..7cc6751d6fbb 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -17,7 +17,8 @@ var/flap = TRUE /obj/item/storage/belt/gun/dump_into(obj/item/storage/M, mob/user) - var/holster_gun = FALSE + //var/holster_gun = FALSE + /* for(var/slot in holster_slots) if(!holster_slots[slot]["gun"]) //Open holster. holster_gun = FALSE @@ -25,15 +26,16 @@ if(holster_slots[slot]["gun"]) //Gun in holster. holster_gun = TRUE break - - if(!holster_gun && length(contents) >= (storage_slots-1)) + */ + 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/handle_item_insertion(obj/item/W, prevent_warning = 0, mob/user) - var/holster_gun = FALSE + //var/holster_gun = FALSE + /* for(var/slot in holster_slots) if(!holster_slots[slot]["gun"]) //Open holster. holster_gun = FALSE @@ -41,8 +43,8 @@ if(holster_slots[slot]["gun"]) //gun in holster. holster_gun = TRUE break - - if(W.type == /obj/item/device/flashlight/flare && holster_gun == FALSE && contents.len >= (storage_slots-1)) + */ + if(W.type == /obj/item/device/flashlight/flare && length(holstered_guns) < 1 && contents.len >= (storage_slots-1)) return FALSE return ..() From b5b59349afc9355624d97a4bcefee7fe932942c0 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 11 Aug 2023 10:52:11 +0200 Subject: [PATCH 09/16] remove single letter variable. --- code/game/objects/items/storage/belt.dm | 28 ++++------------------ code/game/objects/items/storage/storage.dm | 26 ++++++++++---------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 7cc6751d6fbb..62550aa487d1 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -16,35 +16,17 @@ ///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/dump_into(obj/item/storage/M, mob/user) - //var/holster_gun = FALSE - /* - for(var/slot in holster_slots) - if(!holster_slots[slot]["gun"]) //Open holster. - holster_gun = FALSE - break - if(holster_slots[slot]["gun"]) //Gun in holster. - holster_gun = TRUE - break - */ +/obj/item/storage/belt/gun/dump_into(obj/item/storage/Main, mob/user) + 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/handle_item_insertion(obj/item/W, prevent_warning = 0, mob/user) - //var/holster_gun = FALSE - /* - for(var/slot in holster_slots) - if(!holster_slots[slot]["gun"]) //Open holster. - holster_gun = FALSE - break - if(holster_slots[slot]["gun"]) //gun in holster. - holster_gun = TRUE - break - */ - if(W.type == /obj/item/device/flashlight/flare && length(holstered_guns) < 1 && contents.len >= (storage_slots-1)) +/obj/item/storage/belt/gun/flaregun/handle_item_insertion(obj/item/Warn, prevent_warning = 0, mob/user) + + if(Warn.type == /obj/item/device/flashlight/flare && length(holstered_guns) < 1 && contents.len >= (storage_slots-1)) return FALSE return ..() diff --git a/code/game/objects/items/storage/storage.dm b/code/game/objects/items/storage/storage.dm index fc451a76e6d2..81e9de89ec25 100644 --- a/code/game/objects/items/storage/storage.dm +++ b/code/game/objects/items/storage/storage.dm @@ -454,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) + 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 @@ -720,25 +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 -/obj/item/storage/proc/dump_into(obj/item/storage/M, mob/user) +/obj/item/storage/proc/dump_into(obj/item/storage/Main, mob/user) 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) if(!has_room(I)) 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) From 1a8152a9f393b3c3b49c0e83d0600ed36b6f2ab9 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 11 Aug 2023 11:21:09 +0200 Subject: [PATCH 10/16] small adjustment --- code/game/objects/items/storage/belt.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 62550aa487d1..26ffcb2094bd 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -16,7 +16,7 @@ ///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/dump_into(obj/item/storage/Main, mob/user) +/obj/item/storage/belt/gun/flaregun/dump_into(obj/item/storage/Main, mob/user) if(length(holstered_guns) < 1 && length(contents) >= (storage_slots-1)) From f4719ded313f89c74f75ff4c1a80115256816b8e Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 18 Aug 2023 12:59:32 +0200 Subject: [PATCH 11/16] fix what Mr nice point out. thannks --- code/game/objects/items/storage/belt.dm | 10 +++---- code/game/objects/items/storage/storage.dm | 32 +++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 26ffcb2094bd..911b1f3f42a1 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -16,7 +16,7 @@ ///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) +/obj/item/storage/belt/gun/flaregun/dump_into(obj/item/storage/origin_storage, mob/user) if(length(holstered_guns) < 1 && length(contents) >= (storage_slots-1)) @@ -24,9 +24,9 @@ return FALSE return ..() -/obj/item/storage/belt/gun/flaregun/handle_item_insertion(obj/item/Warn, prevent_warning = 0, mob/user) +/obj/item/storage/belt/gun/flaregun/handle_item_insertion(obj/item/new_item, prevent_warning = FALSE, mob/user) - if(Warn.type == /obj/item/device/flashlight/flare && length(holstered_guns) < 1 && contents.len >= (storage_slots-1)) + if(istype(new_item, /obj/item/device/flashlight/flare) && length(holstered_guns) < 1 && length(contents) >= (storage_slots-1)) return FALSE return ..() @@ -767,7 +767,7 @@ for(var/i = 1 to storage_slots) new /obj/item/weapon/throwing_knife(src) -/obj/item/storage/belt/knifepouch/_item_insertion(obj/item/W, prevent_warning = 0) +/obj/item/storage/belt/knifepouch/_item_insertion(obj/item/W, prevent_warning = FALSE) ..() playsound(src, 'sound/weapons/gun_shotgun_shell_insert.ogg', 15, TRUE) @@ -990,7 +990,7 @@ to_chat(usr, SPAN_WARNING("[src] can't hold any more ammo.")) return FALSE -/obj/item/storage/belt/gun/_item_insertion(obj/item/W, prevent_warning = 0) +/obj/item/storage/belt/gun/_item_insertion(obj/item/W, prevent_warning = FALSE) if(isgun(W)) holstered_guns += W for(var/slot in holster_slots) diff --git a/code/game/objects/items/storage/storage.dm b/code/game/objects/items/storage/storage.dm index 81e9de89ec25..f2651023222e 100644 --- a/code/game/objects/items/storage/storage.dm +++ b/code/game/objects/items/storage/storage.dm @@ -454,23 +454,23 @@ 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/Warn, prevent_warning = 0, mob/user) - if(!istype(Warn)) +/obj/item/storage/proc/handle_item_insertion(obj/item/new_item, prevent_warning = FALSE, mob/user) + if(!istype(new_item)) return FALSE - if(user && Warn.loc == user) - if(!user.drop_inv_item_to_loc(Warn, src)) + if(user && new_item.loc == user) + if(!user.drop_inv_item_to_loc(new_item, src)) return FALSE else - Warn.forceMove(src) + new_item.forceMove(src) - _item_insertion(Warn, prevent_warning, user) + _item_insertion(new_item, prevent_warning, user) return TRUE /**Inserts the item. Separate proc because handle_item_insertion isn't guaranteed to insert and it therefore isn't safe to override it before calling parent. Updates icon when done. Can be called directly but only if the item was spawned inside src - handle_item_insertion is safer. W is always an item. stop_warning prevents messaging. user may be null.**/ -/obj/item/storage/proc/_item_insertion(obj/item/W, prevent_warning = 0, mob/user) +/obj/item/storage/proc/_item_insertion(obj/item/W, prevent_warning = FALSE, mob/user) W.on_enter_storage(src) if(user) if (user.client && user.s_active != src) @@ -720,26 +720,26 @@ W is always an item. stop_warning prevents messaging. user may be null.**/ to_chat(user, SPAN_WARNING("[ammo_dumping] is empty.")) return TRUE -/obj/item/storage/proc/dump_into(obj/item/storage/Main, mob/user) +/obj/item/storage/proc/dump_into(obj/item/storage/origin_storage, mob/user) if(user.action_busy) return - if(!Main.contents.len) - to_chat(user, SPAN_WARNING("[Main] is empty.")) + if(!origin_storage.contents.len) + to_chat(user, SPAN_WARNING("[origin_storage] is empty.")) return - if(!has_room(Main.contents[1])) //Does it have room for the first item to be inserted? + if(!has_room(origin_storage.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 [Main].")) + to_chat(user, SPAN_NOTICE("You start refilling [src] with [origin_storage].")) if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) return - for(var/obj/item/I in Main) - if(!has_room(I)) + for(var/obj/item/new_item in origin_storage) + if(!has_room(new_item)) break - Main.remove_from_storage(I) - handle_item_insertion(I, TRUE, user) //quiet insertion + origin_storage.remove_from_storage(new_item) + handle_item_insertion(new_item, TRUE, user) //quiet insertion playsound(user.loc, "rustle", 15, TRUE, 6) return TRUE From 1163870e54ab8ed5327bafe77231165ca5630720 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 18 Aug 2023 15:32:24 +0200 Subject: [PATCH 12/16] test probably bugged.... --- code/game/objects/items/storage/belt.dm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 911b1f3f42a1..66ad44b5acf7 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -30,6 +30,12 @@ return FALSE return ..() +/obj/item/storage/belt/gun/flaregun/has_room(obj/item/W as obj, W_class_override = null) + + if(istype(new_item, /obj/item/device/flashlight/flare) && length(holstered_guns) > 0 && length(contents) >= storage_slots) + return FALSE + return ..() + /obj/item/storage/belt/equipped(mob/user, slot) switch(slot) if(WEAR_WAIST, WEAR_J_STORE, WEAR_BACK) From c15ce691ee9fd652c0c8891cb09251c3775ada77 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 18 Aug 2023 16:48:04 +0200 Subject: [PATCH 13/16] fezfzg --- code/game/objects/items/storage/belt.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 66ad44b5acf7..01a71bbdebbe 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -32,8 +32,8 @@ /obj/item/storage/belt/gun/flaregun/has_room(obj/item/W as obj, W_class_override = null) - if(istype(new_item, /obj/item/device/flashlight/flare) && length(holstered_guns) > 0 && length(contents) >= storage_slots) - return FALSE + if(istype(new_item, /obj/item/device/flashlight/flare) && length(holstered_guns) < 1 && length(contents) >= (storage_slots-1)) + return FALSE //No slot open because gun in holster. return ..() /obj/item/storage/belt/equipped(mob/user, slot) From cfccaa8a774bddcf3937f78ff249a3e6d199a345 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 18 Aug 2023 17:01:00 +0200 Subject: [PATCH 14/16] sfqhqhdh --- code/game/objects/items/storage/belt.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 01a71bbdebbe..d562a3283818 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -32,7 +32,7 @@ /obj/item/storage/belt/gun/flaregun/has_room(obj/item/W as obj, W_class_override = null) - if(istype(new_item, /obj/item/device/flashlight/flare) && length(holstered_guns) < 1 && length(contents) >= (storage_slots-1)) + if(istype(W, /obj/item/device/flashlight/flare) && length(holstered_guns) < 1 && length(contents) >= (storage_slots-1)) return FALSE //No slot open because gun in holster. return ..() From b258d595b07db22b5daf288cfb0ed60ba559628b Mon Sep 17 00:00:00 2001 From: Julian56 <117036822+Huffie56@users.noreply.github.com> Date: Fri, 18 Aug 2023 20:41:07 +0200 Subject: [PATCH 15/16] Apply suggestions from code review apply drulikar modification Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com> --- code/game/objects/items/storage/belt.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index d562a3283818..2a43bd48524b 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -30,9 +30,9 @@ return FALSE return ..() -/obj/item/storage/belt/gun/flaregun/has_room(obj/item/W as obj, W_class_override = null) +/obj/item/storage/belt/gun/flaregun/has_room(obj/item/new_item, W_class_override = null) - if(istype(W, /obj/item/device/flashlight/flare) && length(holstered_guns) < 1 && length(contents) >= (storage_slots-1)) + if(istype(new_item, /obj/item/device/flashlight/flare) && length(holstered_guns) < 1 && length(contents) >= (storage_slots-1)) return FALSE //No slot open because gun in holster. return ..() @@ -773,7 +773,7 @@ for(var/i = 1 to storage_slots) new /obj/item/weapon/throwing_knife(src) -/obj/item/storage/belt/knifepouch/_item_insertion(obj/item/W, prevent_warning = FALSE) +/obj/item/storage/belt/knifepouch/_item_insertion(obj/item/new_item, prevent_warning = FALSE) ..() playsound(src, 'sound/weapons/gun_shotgun_shell_insert.ogg', 15, TRUE) From 5ef12615a323ae8c60c79b77637f58c7b668c96e Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 18 Aug 2023 21:00:38 +0200 Subject: [PATCH 16/16] small fix --- code/game/objects/items/storage/storage.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/storage/storage.dm b/code/game/objects/items/storage/storage.dm index f2651023222e..5a6b7d2b9b05 100644 --- a/code/game/objects/items/storage/storage.dm +++ b/code/game/objects/items/storage/storage.dm @@ -377,12 +377,12 @@ var/list/global/item_storage_box_cache = list() return ///Returns TRUE if there is room for the given item. W_class_override allows checking for just a generic W_class, meant for checking shotgun handfuls without having to spawn and delete one just to check. -/obj/item/storage/proc/has_room(obj/item/W as obj, W_class_override = null) +/obj/item/storage/proc/has_room(obj/item/new_item, W_class_override = null) if(storage_slots != null && contents.len < storage_slots) return TRUE //At least one open slot. //calculate storage space only for containers that don't have slots if (storage_slots == null) - var/sum_storage_cost = W_class_override ? W_class_override : W.get_storage_cost() //Takes the override if there is one, the given item otherwise. + var/sum_storage_cost = W_class_override ? W_class_override : new_item.get_storage_cost() //Takes the override if there is one, the given item otherwise. for(var/obj/item/I in contents) sum_storage_cost += I.get_storage_cost() //Adds up the combined storage costs which will be in the storage item if the item is added to it.