From dfe10dcaa815e3082b3ade0acb2f2a786ecded50 Mon Sep 17 00:00:00 2001 From: Artorp Date: Thu, 12 Feb 2015 20:58:41 +0100 Subject: [PATCH] Decals scalability, templ exploit prevention - Moved from multiple if() to for(), adding scalability to decals - added is_a_decal() to prevent possible template mod exploits --- code/game/machinery/atmoalter/canister.dm | 37 +++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/code/game/machinery/atmoalter/canister.dm b/code/game/machinery/atmoalter/canister.dm index 2d9a9924af4..9daadf47b51 100644 --- a/code/game/machinery/atmoalter/canister.dm +++ b/code/game/machinery/atmoalter/canister.dm @@ -211,6 +211,11 @@ update_flag return 1 return 0 +/obj/machinery/portable_atmospherics/canister/proc/is_a_decal(var/inputVar) + for(var/list/L in possibledecals) + if (L["icon"] == inputVar) + return 1 + return 0 /obj/machinery/portable_atmospherics/canister/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume) if(exposed_temperature > temperature_resistance) @@ -471,25 +476,19 @@ update_flag colorcontainer["quart"]["anycolor"] = 1 if (href_list["choice"] == "decals") - switch(href_list["icon"]) - if ("cold") - possibledecals[1]["active"] = (possibledecals[1]["active"] == 0) - if ("hot") - possibledecals[2]["active"] = (possibledecals[2]["active"] == 0) - if ("plasma") - possibledecals[3]["active"] = (possibledecals[3]["active"] == 0) - - decals = list() - if (possibledecals[1]["active"]) - if (!("cold" in decals)) - decals.Add("cold") - if (possibledecals[2]["active"]) - if (!("hot" in decals)) - decals.Add("hot") - if (possibledecals[3]["active"]) - if (!("plasma" in decals)) - decals.Add("plasma") - + if (is_a_decal(href_list["icon"])) + for (var/list/L in possibledecals) + if (L["icon"] == href_list["icon"]) + L["active"] = (L["active"] == 0) + break + + decals = list() + + for (var/list/L in possibledecals) + if (L["active"]) + if (!(L["icon"] in decals)) + decals.Add(L["icon"]) + src.add_fingerprint(usr) update_icon()