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

[MIRROR] Indestructible items are properly rejected by material containers #2008

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions code/datums/components/material/material_container.dm
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,9 @@
var/inserted = 0
//All messages to be displayed to chat
var/list/chat_msgs = list()

//differs from held_item when using TK
var/active_held = user.get_active_held_item()

//storage items to retrive items from
var/static/list/storage_items
if(isnull(storage_items))
storage_items = list(
Expand All @@ -288,7 +287,7 @@
)

//1st iteration consumes all items that do not have contents inside
//2nd iteration consumes items who do have contents inside(but they were consumed in the 1st iteration si its empty now)
//2nd iteration consumes items who do have contents inside(but they were consumed in the 1st iteration so its empty now)
for(var/i in 1 to 2)
//no point inserting more items
if(inserted == MATERIAL_INSERT_ITEM_NO_SPACE)
Expand All @@ -311,22 +310,22 @@
//can't allow abstract, hologram items
if((target_item.item_flags & ABSTRACT) || (target_item.flags_1 & HOLOGRAM_1))
continue
//untouchable, move it out the way, code copied from recycler
if(target_item.resistance_flags & INDESTRUCTIBLE)
target_item.forceMove(get_turf(parent))
continue
//user defined conditions
if(SEND_SIGNAL(src, COMSIG_MATCONTAINER_PRE_USER_INSERT, target_item, user) & MATCONTAINER_BLOCK_INSERT)
continue
//item is either not allowed for redemption, not in the allowed types
if((target_item.item_flags & NO_MAT_REDEMPTION) || (allowed_item_typecache && !is_type_in_typecache(target_item, allowed_item_typecache)))
//item is either indestructible, not allowed for redemption or not in the allowed types
if((target_item.resistance_flags & INDESTRUCTIBLE) || (target_item.item_flags & NO_MAT_REDEMPTION) || (allowed_item_typecache && !is_type_in_typecache(target_item, allowed_item_typecache)))
if(!(mat_container_flags & MATCONTAINER_SILENT) && i == 1) //count only child items the 1st time around
var/list/status_data = chat_msgs["[MATERIAL_INSERT_ITEM_FAILURE]"] || list()
var/list/item_data = status_data[target_item.name] || list()
item_data["count"] += 1
status_data[target_item.name] = item_data
chat_msgs["[MATERIAL_INSERT_ITEM_FAILURE]"] = status_data

if(target_item.resistance_flags & INDESTRUCTIBLE)
if(i == 1 && target_item != active_held) //move it out of any storage medium its in so it doesn't get consumed with its parent, but only if that storage medium is not our hand
target_item.forceMove(get_turf(context))
continue
//storage items usually come here but we make the exception only on the 1st iteration
//this is so players can insert items from their bags into machines for convinience
if(!is_type_in_list(target_item, storage_items))
Expand Down
Loading