From f1bfcfb2cff774508eb8449c19ce20ae87033a76 Mon Sep 17 00:00:00 2001 From: "sieve32@gmail.com" Date: Mon, 20 Aug 2012 05:59:46 +0000 Subject: [PATCH] -Worked on mech fabs a bit more, replaced the has_var() proc with just the BYOND proc, since that's all it did anyways. Tweaked another part that wasn't silently discarding junk correctly. This is probably due to the lack of type-casting now, but even when I crammed areas and null refs into the fabs, they didn't runtime, and operated as intended. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4502 316c924e-a436-60f5-8080-3fe189b3f50e --- code/defines/procs/helpers.dm | 4 ---- code/game/mecha/mech_fabricator.dm | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/code/defines/procs/helpers.dm b/code/defines/procs/helpers.dm index 6e64ee8bb16..021a82c97c4 100644 --- a/code/defines/procs/helpers.dm +++ b/code/defines/procs/helpers.dm @@ -762,10 +762,6 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl if(A.vars.Find(lowertext(varname))) return 1 else return 0 -/proc/has_var(var/atom/A, var/varname)//Object, non case-sensitive version - if(A.vars.Find(varname)) return 1 - else return 0 - //Takes: Area type as text string or as typepath OR an instance of the area. //Returns: A list of all areas of that type in the world. /proc/get_areas(var/areatype) diff --git a/code/game/mecha/mech_fabricator.dm b/code/game/mecha/mech_fabricator.dm index 284160755ba..43d3e764b32 100644 --- a/code/game/mecha/mech_fabricator.dm +++ b/code/game/mecha/mech_fabricator.dm @@ -313,8 +313,8 @@ /obj/machinery/mecha_part_fabricator/proc/output_part_cost(var/obj/item/part) var/i = 0 var/output - if(has_var(part,"construction_time") && has_var(part,"construction_cost"))//The most efficient way to go about this. Not all objects have these vars, but if they don't then they CANNOT be made by the mech fab. Doing it this way reduces a major amount of typecasting and switches, while cutting down maintenece for them as well -Sieve - for(var/c in part:construction_cost)//The has_var should ensure that anything without the var doesn't make it to this point + if(part.vars.Find("construction_time") && part.vars.Find("construction_cost"))//The most efficient way to go about this. Not all objects have these vars, but if they don't then they CANNOT be made by the mech fab. Doing it this way reduces a major amount of typecasting and switches, while cutting down maintenece for them as well -Sieve + for(var/c in part:construction_cost)//The check should ensure that anything without the var doesn't make it to this point if(c in resources) output += "[i?" | ":null][get_resource_cost_w_coeff(part,c)] [c]" i++ @@ -334,7 +334,7 @@ /obj/machinery/mecha_part_fabricator/proc/remove_resources(var/obj/item/part) //Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects - if(has_var(part,"construction_time") && has_var(part,"construction_cost")) + if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) for(var/resource in part:construction_cost) if(resource in src.resources) src.resources[resource] -= get_resource_cost_w_coeff(part,resource) @@ -344,7 +344,7 @@ /obj/machinery/mecha_part_fabricator/proc/check_resources(var/obj/item/part) // if(istype(part, /obj/item/robot_parts) || istype(part, /obj/item/mecha_parts) || istype(part,/obj/item/borg/upgrade)) //Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects - if(has_var(part,"construction_time") && has_var(part,"construction_cost")) + if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) for(var/resource in part:construction_cost) if(resource in src.resources) if(src.resources[resource] < get_resource_cost_w_coeff(part,resource)) @@ -398,8 +398,8 @@ return 1 /obj/machinery/mecha_part_fabricator/proc/process_queue() - var/part = listgetindex(src.queue, 1) - if(!(has_var(part,"construction_time")) || !(has_var(part,"construction_cost")))//If it shouldn't be printed + var/obj/item/part = listgetindex(src.queue, 1) + if(!(part.vars.Find("construction_time")) || !(part.vars.Find("construction_cost")))//If it shouldn't be printed remove_from_queue(1)//Take it out of the quene return process_queue()//Then reprocess it temp = null @@ -426,9 +426,9 @@ for(var/i=1;i<=queue.len;i++) var/obj/item/part = listgetindex(src.queue, i) if(istype(part)) - if(has_var(part,"construction_time") && has_var(part,"construction_cost"))//Prevents junk items from even appearing in the list, and they will be silently removed when the fab processes + if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) output += "[part.name] - [i>1?"":null] [i↓":null] Remove" - else + else//Prevents junk items from even appearing in the list, and they will be silently removed when the fab processes remove_from_queue(i)//Trash it return list_queue()//Rebuild it output += "" @@ -510,14 +510,14 @@ /obj/machinery/mecha_part_fabricator/proc/get_resource_cost_w_coeff(var/obj/item/part as obj,var/resource as text, var/roundto=1) //Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects - if(has_var(part,"construction_time") && has_var(part,"construction_cost")) + if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) return round(part:construction_cost[resource]*resource_coeff, roundto) else return 0 /obj/machinery/mecha_part_fabricator/proc/get_construction_time_w_coeff(var/obj/item/part as obj, var/roundto=1) //Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects - if(has_var(part,"construction_time") && has_var(part,"construction_cost")) + if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) return round(part:construction_time*time_coeff, roundto) else return 0