From 453f149be586cfa204d44d53651bd082145fb9b6 Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Mon, 4 Jan 2016 00:02:28 -0600 Subject: [PATCH] Fix tgui states This led to a few in-game exploits it seems --- code/modules/tgui/states/contained.dm | 2 +- code/modules/tgui/states/deep_inventory.dm | 2 +- code/modules/tgui/states/notcontained.dm | 2 +- code/modules/tgui/tgui.dm | 11 +++++------ 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/code/modules/tgui/states/contained.dm b/code/modules/tgui/states/contained.dm index 20cda3241e0..78415023f44 100644 --- a/code/modules/tgui/states/contained.dm +++ b/code/modules/tgui/states/contained.dm @@ -7,6 +7,6 @@ /var/global/datum/ui_state/contained_state/contained_state = new() /datum/ui_state/contained_state/can_use_topic(atom/movable/src_object, mob/user) - if(!src_object.contains(user)) + if(!(user in src_object.contents)) return UI_CLOSE return user.shared_ui_interaction(src_object) diff --git a/code/modules/tgui/states/deep_inventory.dm b/code/modules/tgui/states/deep_inventory.dm index 4fef9ad5b3c..6e3fd17e292 100644 --- a/code/modules/tgui/states/deep_inventory.dm +++ b/code/modules/tgui/states/deep_inventory.dm @@ -7,6 +7,6 @@ /var/global/datum/ui_state/deep_inventory_state/deep_inventory_state = new() /datum/ui_state/deep_inventory_state/can_use_topic(atom/movable/src_object, mob/user) - if(!user.contains(src_object)) + if(!(src_object in user.contents)) return UI_CLOSE return user.shared_ui_interaction(src_object) diff --git a/code/modules/tgui/states/notcontained.dm b/code/modules/tgui/states/notcontained.dm index 8df75b57626..c6cd00b10e6 100644 --- a/code/modules/tgui/states/notcontained.dm +++ b/code/modules/tgui/states/notcontained.dm @@ -15,7 +15,7 @@ return UI_CLOSE /mob/living/notcontained_can_use_topic(atom/movable/src_object) - if(src_object.contains(src)) + if(src in src_object.contents) return UI_CLOSE // Close if we're inside it. return default_can_use_topic(src_object) diff --git a/code/modules/tgui/tgui.dm b/code/modules/tgui/tgui.dm index ef4fb47ae70..0c85209077e 100644 --- a/code/modules/tgui/tgui.dm +++ b/code/modules/tgui/tgui.dm @@ -95,7 +95,7 @@ update_status(push = 0) // Update the window status. if(status == UI_CLOSE) - return // Bail if we should close. + return // Bail if we're not supposed to open. if(!initial_data) if(!data) // If we don't have initial_data and data was not passed, get data from the src_object. @@ -333,14 +333,13 @@ * optional push bool Push an update to the UI (an update is always sent for UI_DISABLED). **/ /datum/tgui/proc/update_status(push = 0) - var/new_status = src_object.ui_state(user, state) + var/status = src_object.ui_state(user, state) if(master_ui) - new_status = min(new_status, master_ui.status) + status = min(status, master_ui.status) - if(new_status == UI_CLOSE) + set_status(status, push) + if(status == UI_CLOSE) close() - else - set_status(new_status, push) /** * private