From 6c98b2048c815b35bd130394bdd4f1e4d752bdf8 Mon Sep 17 00:00:00 2001 From: Ren Erthilo Date: Tue, 1 May 2012 00:36:20 +0100 Subject: [PATCH] TG: Removes poo. XSI and co. weren't very fond of it, and the last thing I would do is make them uncomfortable and challenge their leadership by keeping poo in. An experimental lagfix, which removes a couple THOUSAND unnecessary machines from the machine processing list. Please report any unresponsive machinery (as result of this commit) as HIGH PRIORITY issues. I'm not quite sure how much lag this will kill, but I'm confident that it will be at least slightly noticeable. More work on step_triggers. The escape shuttle should no longer blast things forever and give them infinite momentum. Runtimes goin down for the count Lookin at the ground I think they a hater Revision: r3370 r3371 Author: vageyenaman quartz235 --- baystation12.dme | 1 + code/ATMOSPHERICS/atmospherics.dm | 1 - code/defines/obj/computer.dm | 9 -- code/defines/procs/helpers.dm | 41 +++++-- code/game/dna.dm | 5 +- code/game/machinery/atmo_control.dm | 89 --------------- code/game/machinery/atmoalter/zvent.dm | 1 - code/game/machinery/computer/atmos_alert.dm | 105 ++++++++++++++++++ .../embedded_controller_base.dm | 1 - code/game/machinery/machinery.dm | 11 +- code/game/machinery/magnet.dm | 2 - code/game/machinery/rechargestation.dm | 6 +- code/game/objects/devices/PDA/cart.dm | 16 +-- code/modules/mob/mob_cleanup.dm | 4 +- code/modules/mob/transform_procs.dm | 3 +- 15 files changed, 168 insertions(+), 127 deletions(-) create mode 100644 code/game/machinery/computer/atmos_alert.dm diff --git a/baystation12.dme b/baystation12.dme index 96b91193d41..c5b3ba17988 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -530,6 +530,7 @@ #include "code\game\machinery\computer\aifixer.dm" #include "code\game\machinery\computer\arcade.dm" #include "code\game\machinery\computer\atmos.dm" +#include "code\game\machinery\computer\atmos_alert.dm" #include "code\game\machinery\computer\buildandrepair.dm" #include "code\game\machinery\computer\camera_monitor.dm" #include "code\game\machinery\computer\cloning.dm" diff --git a/code/ATMOSPHERICS/atmospherics.dm b/code/ATMOSPHERICS/atmospherics.dm index 439ca6562c3..fca51ad7ce2 100644 --- a/code/ATMOSPHERICS/atmospherics.dm +++ b/code/ATMOSPHERICS/atmospherics.dm @@ -25,7 +25,6 @@ obj/machinery/atmospherics process() build_network() - ..() proc network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference) diff --git a/code/defines/obj/computer.dm b/code/defines/obj/computer.dm index edf201c9d5a..9e86cf158be 100644 --- a/code/defines/obj/computer.dm +++ b/code/defines/obj/computer.dm @@ -30,15 +30,6 @@ var/alarms = list("Fire"=list(), "Atmosphere"=list(), "Power"=list()) -/obj/machinery/computer/atmos_alert - name = "Atmospheric Alert Computer" - desc = "Used to access the station's atmospheric sensors." - icon_state = "alert:0" - var/list/priority_alarms = list() - var/list/minor_alarms = list() - var/receive_frequency = 1437 - - /obj/machinery/computer/atmosphere name = "atmos" desc = "A computer for Atmospherics." diff --git a/code/defines/procs/helpers.dm b/code/defines/procs/helpers.dm index 304645172f6..994d08745ec 100644 --- a/code/defines/procs/helpers.dm +++ b/code/defines/procs/helpers.dm @@ -266,7 +266,12 @@ var/list/textList = new() var/searchPosition = 1 var/findPosition = 1 + var/loops = 0 while(1) + if(loops >= 1000) + break + loops++ + findPosition = findtext(text, separator, searchPosition, 0) var/buggyText = copytext(text, searchPosition, findPosition) if(!withinList || (buggyText in withinList)) textList += "[buggyText]" @@ -654,7 +659,7 @@ Turf and target are seperate in case you want to teleport some distance from a t total = rand(1, total) for (item in L) - total -= L[item] + total -=L [item] if (total <= 0) return item @@ -819,9 +824,6 @@ Turf and target are seperate in case you want to teleport some distance from a t var/list/creatures = list() var/list/namecounts = list() for(var/mob/M in mobs) - /*if((!M.name || !M.real_name) && !istype(M, /mob/new_player)) - var/turf/T = get_turf(M) - message_admins("Alert! The mob with the key [M.key ? M.key : "NO KEY"] at ([T.x], [T.y], [T.z]) has no name!")*/ var/name = M.name if (name in names) namecounts[name]++ @@ -1008,8 +1010,8 @@ Turf and target are seperate in case you want to teleport some distance from a t output += A return output -// Returns the turf a movable atom (obj or mob) is on -/proc/get_turf_loc(var/atom/movable/M) +/proc/get_turf_loc(var/atom/movable/M) //gets the location of the turf that the atom is on, or what the atom is in is on, etc + //in case they're in a closet or sleeper or something var/atom/loc = M.loc while(!istype(loc, /turf/)) loc = loc.loc @@ -1020,6 +1022,8 @@ Turf and target are seperate in case you want to teleport some distance from a t /proc/get_edge_target_turf(var/atom/A, var/direction) var/turf/target = locate(A.x, A.y, A.z) + if(!A || !target) + return 0 //since NORTHEAST == NORTH & EAST, etc, doing it this way allows for diagonal mass drivers in the future //and isn't really any more complicated @@ -1306,13 +1310,16 @@ proc/listclearnulls(list/list) var/target_loc = target.loc var/holding = user.equipped() sleep(time) + if(!user || !target) return 0 if ( user.loc == user_loc && target.loc == target_loc && user.equipped() == holding && !( user.stat ) && ( !user.stunned && !user.weakened && !user.paralysis && !user.lying ) ) return 1 else return 0 - +/* /proc/do_after(mob/M as mob, time as num) - var/turf/T = get_turf(M) + if(!M) + return 0 + var/turf/T = M.loc var/holding = M.equipped() for(var/i=0, i 1) + string = copytext(input,1,((blocksize*blocknumber)-(blocksize-1))) return string else return null /proc/getrightblocks(input,blocknumber,blocksize) var/string - string = copytext(input,blocksize*blocknumber+1) if (blocknumber < (length(input)/blocksize)) + string = copytext(input,blocksize*blocknumber+1,length(input)+1) return string else return null diff --git a/code/game/machinery/atmo_control.dm b/code/game/machinery/atmo_control.dm index 864d6e451cd..e0274cf54dc 100644 --- a/code/game/machinery/atmo_control.dm +++ b/code/game/machinery/atmo_control.dm @@ -93,7 +93,6 @@ obj/machinery/computer/general_air_control process() ..() - src.updateDialog() attackby(I as obj, user as mob) @@ -442,94 +441,6 @@ Rate: [volume_rate] L/sec
"} radio_connection.post_signal(src, signal, filter = RADIO_ATMOSIA) -/obj/machinery/computer/atmos_alert - var/datum/radio_frequency/radio_connection -/obj/machinery/computer/atmos_alert/initialize() - set_frequency(receive_frequency) -/obj/machinery/computer/atmos_alert/receive_signal(datum/signal/signal) - if(!signal || signal.encryption) return - var/zone = signal.data["zone"] - var/severity = signal.data["alert"] - - if(!zone || !severity) return - - minor_alarms -= zone - priority_alarms -= zone - if(severity=="severe") - priority_alarms += zone - else if (severity=="minor") - minor_alarms += zone - /*else "clear"*/ - //do nothing - update_icon() - -/obj/machinery/computer/atmos_alert/proc/set_frequency(new_frequency) - radio_controller.remove_object(src, receive_frequency) - receive_frequency = new_frequency - radio_connection = radio_controller.add_object(src, receive_frequency, RADIO_ATMOSIA) - -/obj/machinery/computer/atmos_alert/attack_hand(mob/user) - user << browse(return_text(),"window=computer") - user.machine = src - onclose(user, "computer") - -/obj/machinery/computer/atmos_alert/process() - ..() - src.updateDialog() - -/obj/machinery/computer/atmos_alert/update_icon() - if(priority_alarms.len) - icon_state = "alert:2" - - else if(minor_alarms.len) - icon_state = "alert:1" - - else - icon_state = "alert:0" - -/obj/machinery/computer/atmos_alert/proc/return_text() - var/priority_text - var/minor_text - - if(priority_alarms.len) - for(var/zone in priority_alarms) - priority_text += "[zone] X
" - else - priority_text = "No priority alerts detected.
" - - if(minor_alarms.len) - for(var/zone in minor_alarms) - minor_text += "[zone] X
" - else - minor_text = "No minor alerts detected.
" - - var/output = {"[name]
-Priority Alerts:
-[priority_text] -
-
-Minor Alerts:
-[minor_text] -
"} - - return output - -/obj/machinery/computer/atmos_alert/Topic(href, href_list) - if(..()) - return - - if(href_list["priority_clear"]) - var/removing_zone = href_list["priority_clear"] - for(var/zone in priority_alarms) - if(ckey(zone) == removing_zone) - priority_alarms -= zone - - if(href_list["minor_clear"]) - var/removing_zone = href_list["minor_clear"] - for(var/zone in minor_alarms) - if(ckey(zone) == removing_zone) - minor_alarms -= zone - update_icon() \ No newline at end of file diff --git a/code/game/machinery/atmoalter/zvent.dm b/code/game/machinery/atmoalter/zvent.dm index 5831e9d6a85..0cf390d8795 100644 --- a/code/game/machinery/atmoalter/zvent.dm +++ b/code/game/machinery/atmoalter/zvent.dm @@ -10,7 +10,6 @@ var/volume_rate = 800 /obj/machinery/zvent/process() - ..() //all this object does, is make its turf share air with the ones above and below it, if they have a vent too. if (istype(loc,/turf/simulated)) //if we're not on a valid turf, forget it diff --git a/code/game/machinery/computer/atmos_alert.dm b/code/game/machinery/computer/atmos_alert.dm new file mode 100644 index 00000000000..659f98b9395 --- /dev/null +++ b/code/game/machinery/computer/atmos_alert.dm @@ -0,0 +1,105 @@ + +/obj/machinery/computer/atmos_alert + name = "Atmospheric Alert Computer" + desc = "Used to access the station's atmospheric sensors." + icon_state = "alert:0" + var + list/priority_alarms = list() + list/minor_alarms = list() + receive_frequency = 1437 + datum/radio_frequency/radio_connection + + + initialize() + set_frequency(receive_frequency) + + receive_signal(datum/signal/signal) + if(!signal || signal.encryption) return + + var/zone = signal.data["zone"] + var/severity = signal.data["alert"] + + if(!zone || !severity) return + + minor_alarms -= zone + priority_alarms -= zone + if(severity=="severe") + priority_alarms += zone + else if (severity=="minor") + minor_alarms += zone + update_icon() + return + + + proc/set_frequency(new_frequency) + radio_controller.remove_object(src, receive_frequency) + receive_frequency = new_frequency + radio_connection = radio_controller.add_object(src, receive_frequency, RADIO_ATMOSIA) + + + attack_hand(mob/user) + user << browse(return_text(),"window=computer") + user.machine = src + onclose(user, "computer") + + process() + ..() + src.updateDialog() + + update_icon() + if(priority_alarms.len) + icon_state = "alert:2" + + else if(minor_alarms.len) + icon_state = "alert:1" + + else + icon_state = "alert:0" + return + + + proc/return_text() + var/priority_text + var/minor_text + + if(priority_alarms.len) + for(var/zone in priority_alarms) + priority_text += "[zone] X
" + else + priority_text = "No priority alerts detected.
" + + if(minor_alarms.len) + for(var/zone in minor_alarms) + minor_text += "[zone] X
" + else + minor_text = "No minor alerts detected.
" + + var/output = {"[name]
+Priority Alerts:
+[priority_text] +
+
+Minor Alerts:
+[minor_text] +
"} + + return output + + + Topic(href, href_list) + if(..()) + return + + if(href_list["priority_clear"]) + var/removing_zone = href_list["priority_clear"] + for(var/zone in priority_alarms) + if(ckey(zone) == removing_zone) + priority_alarms -= zone + + if(href_list["minor_clear"]) + var/removing_zone = href_list["minor_clear"] + for(var/zone in minor_alarms) + if(ckey(zone) == removing_zone) + minor_alarms -= zone + update_icon() + return \ No newline at end of file diff --git a/code/game/machinery/embedded_controller/embedded_controller_base.dm b/code/game/machinery/embedded_controller/embedded_controller_base.dm index dae31678c80..5af17e377e9 100644 --- a/code/game/machinery/embedded_controller/embedded_controller_base.dm +++ b/code/game/machinery/embedded_controller/embedded_controller_base.dm @@ -62,7 +62,6 @@ obj/machinery/embedded_controller update_icon() src.updateDialog() - ..() radio var/frequency diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 49892a3331e..583c0f91e10 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -100,7 +100,16 @@ Class Procs: ..() /obj/machinery/process()//If you dont use process or power why are you here -// machines.Remove(src)Not going to do this till I test it a bit more + + /* + Big note: if do not call ..() in any machinery subtype process() call or it will + be removed from the list of machines to iterate. It is, however, okay to call ..() + if the machine has a parent process() call. For instance, machinery/atmosphereics has a + root process() call, so things like cryocells can call ..() and not worry about + it getting removed from machines. + */ + + machines.Remove(src) // uncommented by Doohl return /obj/machinery/emp_act(severity) diff --git a/code/game/machinery/magnet.dm b/code/game/machinery/magnet.dm index c874cb22734..46385e4686a 100644 --- a/code/game/machinery/magnet.dm +++ b/code/game/machinery/magnet.dm @@ -129,7 +129,6 @@ process() - ..() if(stat & NOPOWER) on = 0 @@ -238,7 +237,6 @@ process() - ..() if(magnets.len == 0 && autolink) for(var/obj/machinery/magnetic_module/M in world) if(M.freq == frequency && M.code == code) diff --git a/code/game/machinery/rechargestation.dm b/code/game/machinery/rechargestation.dm index 6c3924d25ec..ca7d1dbb66a 100644 --- a/code/game/machinery/rechargestation.dm +++ b/code/game/machinery/rechargestation.dm @@ -16,7 +16,6 @@ build_icon() process() - ..() if(!(NOPOWER|BROKEN)) return @@ -140,8 +139,9 @@ //Make sure they actually HAVE a cell, now that they can get in while powerless. --NEO return usr.pulling = null - usr.client.perspective = EYE_PERSPECTIVE - usr.client.eye = src + if(usr && usr.client) + usr.client.perspective = EYE_PERSPECTIVE + usr.client.eye = src usr.loc = src src.occupant = usr /*for(var/obj/O in src) diff --git a/code/game/objects/devices/PDA/cart.dm b/code/game/objects/devices/PDA/cart.dm index 9f8c9529d27..401b5ad03e8 100644 --- a/code/game/objects/devices/PDA/cart.dm +++ b/code/game/objects/devices/PDA/cart.dm @@ -519,7 +519,7 @@ Code: if (ml.z != cl.z) continue - ldat += "Mop - \[[ml.x],[ml.y]\] - [M.reagents.total_volume ? "Wet" : "Dry"]
" + ldat += "Mop - \[[ml.x],[ml.y]\] - [M.reagents.total_volume ? "Wet" : "Dry"]
" if (!ldat) menu += "None" @@ -532,10 +532,11 @@ Code: for (var/obj/structure/mopbucket/B in world) var/turf/bl = get_turf(B) - if (bl.z != cl.z) - continue + if(bl) + if (bl.z != cl.z) + continue - ldat += "Bucket - \[[bl.x],[bl.y]\] - Water level: [B.reagents.total_volume]/100
" + ldat += "Bucket - \[[bl.x],[bl.y]\] - Water level: [B.reagents.total_volume]/100
" if (!ldat) menu += "None" @@ -548,10 +549,11 @@ Code: for (var/obj/machinery/bot/cleanbot/B in world) var/turf/bl = get_turf(B) - if (bl.z != cl.z) - continue + if(bl) + if (bl.z != cl.z) + continue - ldat += "Cleanbot - \[[bl.x],[bl.y]\] - [B.on ? "Online" : "Offline"]
" + ldat += "Cleanbot - \[[bl.x],[bl.y]\] - [B.on ? "Online" : "Offline"]
" if (!ldat) menu += "None" diff --git a/code/modules/mob/mob_cleanup.dm b/code/modules/mob/mob_cleanup.dm index 0e167a6c5ef..766d6955974 100644 --- a/code/modules/mob/mob_cleanup.dm +++ b/code/modules/mob/mob_cleanup.dm @@ -93,7 +93,7 @@ Put (mob/proc)s here that are in dire need of a code cleanup. switch(target_zone) if(1) - if(isobj(H.head)) + if(isobj(H.head) && !istype(H.head, /obj/item/weapon/paper)) Cl = H.head passed = prob(Cl.permeability_coefficient*100*virus.permeability_mod) // world << "Head pass [passed]" @@ -191,4 +191,4 @@ Put (mob/proc)s here that are in dire need of a code cleanup. if(prob(5)) v.carrier = 1 return - return \ No newline at end of file + return diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm index 3d4ca7661d2..fdaa37fb570 100644 --- a/code/modules/mob/transform_procs.dm +++ b/code/modules/mob/transform_procs.dm @@ -190,7 +190,8 @@ O.invisibility = 0 O.name = "Cyborg" O.real_name = "Cyborg" - O.lastKnownIP = client.address ? client.address : null + if(client) + O.lastKnownIP = client.address ? client.address : null if (mind) mind.transfer_to(O) if (mind.assigned_role == "Cyborg")