From 92240a9d951a8e34e216b66833cad71e84250e78 Mon Sep 17 00:00:00 2001 From: Tkdrg Date: Fri, 18 Dec 2015 21:40:23 -0300 Subject: [PATCH] Fixes invisible mask exploits This code is awful and full of copy-paste and I can't be assed/can't manage to figure out how to fix it properly so I just got the hammer and made it always update everything whenever you toggle a helmet. Exploit's dead at least. Fixes #13486 --- code/modules/clothing/clothing.dm | 34 +++++++------------ code/modules/clothing/head/helmet.dm | 34 ++++++++----------- code/modules/clothing/spacesuits/hardsuit.dm | 3 ++ .../mob/living/carbon/human/inventory.dm | 10 +++--- code/modules/mob/living/carbon/inventory.dm | 4 +-- 5 files changed, 38 insertions(+), 47 deletions(-) diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 8ba8962b452..165bac65cbc 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -471,27 +471,19 @@ BLIND // can't see anything H.update_inv_w_uniform() /obj/item/clothing/proc/weldingvisortoggle() //Malk: proc to toggle welding visors on helmets, masks, goggles, etc. - if(can_use(usr)) - if(up) - up = !up - flags |= (visor_flags) - flags_inv |= (visor_flags_inv) - flags_cover = initial(flags_cover) - icon_state = initial(icon_state) - usr << "You pull \the [src] down." - flash_protect = initial(flash_protect) - tint = initial(tint) - else - up = !up - flags &= ~(visor_flags) - flags_inv &= ~(visor_flags_inv) - flags_cover &= 0 - icon_state = "[initial(icon_state)]up" - usr << "You push \the [src] up." - flash_protect = 0 - tint = 0 + if(!can_use(usr)) + return - if(istype(src, /obj/item/clothing/head)) //makes the mob-overlays update + up ^= 1 + flags ^= visor_flags + flags_inv ^= visor_flags_inv + flags_cover ^= initial(flags_cover) + icon_state = "[initial(icon_state)][up ? "up" : ""]" + usr << "You adjust \the [src] [up ? "up" : "down"]." + flash_protect ^= initial(flash_protect) + tint ^= initial(tint) + + if(istype(src, /obj/item/clothing/head)) //makes the mob-overlays update //this is awful usr.update_inv_head() if(istype(src, /obj/item/clothing/glasses)) usr.update_inv_glasses() @@ -499,7 +491,7 @@ BLIND // can't see anything usr.update_inv_wear_mask() if(istype(usr, /mob/living/carbon)) var/mob/living/carbon/C = usr - C.head_update(src) //updates based on the HIDE_ flags and fixes the sec hud + C.head_update(src, forced = 1) /obj/item/clothing/proc/can_use(mob/user) if(user && ismob(user)) diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm index 02b02d4317b..1fe7e79d754 100644 --- a/code/modules/clothing/head/helmet.dm +++ b/code/modules/clothing/head/helmet.dm @@ -52,26 +52,22 @@ if(usr.canmove && !usr.stat && !usr.restrained() && can_toggle) if(world.time > cooldown + toggle_cooldown) cooldown = world.time - up = !up - if(up) - flags &= ~(visor_flags) - flags_inv &= ~(visor_flags_inv) - flags_cover &= 0 - icon_state = "[initial(icon_state)]up" - usr << "[alt_toggle_message] \the [src]" - usr.update_inv_head() - if(active_sound) - while(up) - playsound(src.loc, "[active_sound]", 100, 0, 4) - sleep(15) - else - flags |= (visor_flags) - flags_inv |= (visor_flags_inv) - flags_cover = initial(flags_cover) - icon_state = initial(icon_state) - usr << "[toggle_message] \the [src]." - usr.update_inv_head() + up ^= 1 + flags ^= visor_flags + flags_inv ^= visor_flags_inv + flags_cover ^= initial(flags_cover) + icon_state = "[initial(icon_state)][up ? "up" : ""]" + usr << "[up ? alt_toggle_message : toggle_message] \the [src]" + usr.update_inv_head() + if(istype(usr, /mob/living/carbon)) + var/mob/living/carbon/C = usr + C.head_update(src, forced = 1) + + if(active_sound) + while(up) + playsound(src.loc, "[active_sound]", 100, 0, 4) + sleep(15) /obj/item/clothing/head/helmet/justice name = "helmet of justice" diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm index 28f958f647d..842b18479e7 100644 --- a/code/modules/clothing/spacesuits/hardsuit.dm +++ b/code/modules/clothing/spacesuits/hardsuit.dm @@ -215,6 +215,9 @@ playsound(src.loc, 'sound/mecha/mechmove03.ogg', 50, 1) toggle_hardsuit_mode(user) user.update_inv_head() + if(istype(user, /mob/living/carbon)) + var/mob/living/carbon/C = user + C.head_update(src, forced = 1) /obj/item/clothing/head/helmet/space/hardsuit/syndi/proc/toggle_hardsuit_mode(mob/user) //Helmet Toggles Suit Mode if(linkedsuit) diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index da953617dd0..5c866d142fb 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -193,12 +193,12 @@ sec_hud_set_security_status() ..() -/mob/living/carbon/human/head_update(obj/item/I) - if(I.flags & BLOCKHAIR) +/mob/living/carbon/human/head_update(obj/item/I, forced) + if(I.flags & BLOCKHAIR || forced) update_hair() - if(I.flags_inv & HIDEEYES) + if(I.flags_inv & HIDEEYES || forced) update_inv_glasses() - if(I.flags_inv & HIDEEARS) + if(I.flags_inv & HIDEEARS || forced) update_body() sec_hud_set_security_status() ..() @@ -300,4 +300,4 @@ if(!O) return 0 - return O.equip(src, visualsOnly) \ No newline at end of file + return O.equip(src, visualsOnly) diff --git a/code/modules/mob/living/carbon/inventory.dm b/code/modules/mob/living/carbon/inventory.dm index d397a7af712..d8294eaa567 100644 --- a/code/modules/mob/living/carbon/inventory.dm +++ b/code/modules/mob/living/carbon/inventory.dm @@ -92,7 +92,7 @@ update_inv_wear_mask() //handle stuff to update when a mob equips/unequips a headgear. -/mob/living/carbon/proc/head_update(obj/item/I) - if(I.flags_inv & HIDEMASK) +/mob/living/carbon/proc/head_update(obj/item/I, forced) + if(I.flags_inv & HIDEMASK || forced) update_inv_wear_mask() update_inv_head()