From 81b0fdea10dd7d058daa67ddd0d21066933873c6 Mon Sep 17 00:00:00 2001 From: "n3ophyt3@gmail.com" Date: Thu, 30 Sep 2010 18:30:49 +0000 Subject: [PATCH] More runtime errors squashed. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@231 316c924e-a436-60f5-8080-3fe189b3f50e --- code/ATMOSPHERICS/components/valve.dm | 6 ++- code/WorkInProgress/Chemistry-Reagents.dm | 19 +++---- code/game/dna.dm | 9 ++-- code/game/gamemodes/intercept_report.dm | 3 +- code/game/gamemodes/objective.dm | 29 ++++++----- code/game/machinery/atmoalter/canister.dm | 1 - .../atmoalter/portable_atmospherics.dm | 39 +++++++------- code/game/machinery/gibber.dm | 6 +-- code/game/objects/explosion.dm | 4 +- code/game/objects/items/robot_parts.dm | 3 +- code/game/objects/items/weapons/tools.dm | 18 ++++--- code/game/objects/storage/crates.dm | 3 +- code/game/objects/weapons.dm | 14 ++--- code/modules/admin/verbs/randomverbs.dm | 6 ++- code/modules/mob/dead/observer/observer.dm | 9 ++-- code/modules/mob/living/carbon/human/human.dm | 11 ++-- code/modules/mob/living/carbon/monkey/life.dm | 2 + .../mob/living/carbon/monkey/monkey.dm | 4 +- code/modules/mob/login.dm | 7 +-- code/modules/mob/mob.dm | 51 ++++++++++--------- code/modules/mob/new_player/new_player.dm | 26 +++++----- 21 files changed, 148 insertions(+), 122 deletions(-) diff --git a/code/ATMOSPHERICS/components/valve.dm b/code/ATMOSPHERICS/components/valve.dm index 0e3c2def31a..f9fe2e5c648 100644 --- a/code/ATMOSPHERICS/components/valve.dm +++ b/code/ATMOSPHERICS/components/valve.dm @@ -48,9 +48,11 @@ obj/machinery/atmospherics/valve if(open) if(reference == node1) - return node2.network_expand(new_network, src) + if(node2) + return node2.network_expand(new_network, src) else if(reference == node2) - return node1.network_expand(new_network, src) + if(node1) + return node1.network_expand(new_network, src) return null diff --git a/code/WorkInProgress/Chemistry-Reagents.dm b/code/WorkInProgress/Chemistry-Reagents.dm index 58f1bf5fe74..ac0bd4453f7 100644 --- a/code/WorkInProgress/Chemistry-Reagents.dm +++ b/code/WorkInProgress/Chemistry-Reagents.dm @@ -120,16 +120,17 @@ datum reagent_state = LIQUID reaction_turf(var/turf/T, var/volume) - src = null - if(T:wet >= 2) return - T:wet = 2 - spawn(800) - T:wet = 0 - if(T:wet_overlay) - T:overlays -= T:wet_overlay - T:wet_overlay = null + if (!istype(T, /turf/space)) + src = null + if(T:wet >= 2) return + T:wet = 2 + spawn(800) + T:wet = 0 + if(T:wet_overlay) + T:overlays -= T:wet_overlay + T:wet_overlay = null - return + return bilk name = "Bilk" diff --git a/code/game/dna.dm b/code/game/dna.dm index c7e73ffed07..d7e1acceffd 100644 --- a/code/game/dna.dm +++ b/code/game/dna.dm @@ -830,10 +830,11 @@ //////////////////////////////////////////////////////// if (href_list["rejuv"]) var/mob/living/carbon/human/H = src.connected.occupant - if (H.reagents.get_reagent_amount("inaprovaline") < 60) - H.reagents.add_reagent("inaprovaline", 30) - usr << text("Occupant now has [] units of rejuvenation in his/her bloodstream.", H.reagents.get_reagent_amount("inaprovaline")) - src.delete = 0 + if(H) + if (H.reagents.get_reagent_amount("inaprovaline") < 60) + H.reagents.add_reagent("inaprovaline", 30) + usr << text("Occupant now has [] units of rejuvenation in his/her bloodstream.", H.reagents.get_reagent_amount("inaprovaline")) + src.delete = 0 //////////////////////////////////////////////////////// if (href_list["strucmenu"]) if(src.connected.occupant) diff --git a/code/game/gamemodes/intercept_report.dm b/code/game/gamemodes/intercept_report.dm index 6d9aafa0195..f598af6fce9 100644 --- a/code/game/gamemodes/intercept_report.dm +++ b/code/game/gamemodes/intercept_report.dm @@ -141,7 +141,8 @@ var/prob_right_dude = rand(prob_correct_person_lower, prob_correct_person_higher) var/prob_right_job = rand(prob_correct_job_lower, prob_correct_job_higher) if(prob(prob_right_job)) - changeling_job = correct_mob:assigned_role + if(correct_mob) + changeling_job = correct_mob:assigned_role else var/list/job_tmp = get_all_jobs() changeling_job = pick(job_tmp) diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index 6787480caa5..55e8b27e37d 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -132,22 +132,23 @@ datum check_completion() if(steal_target) - if(owner.current.check_contents_for(steal_target)) - if(target_name == "functional ai") -// world << "dude's after an AI, time to check for one." - for(var/obj/item/device/aicard/C in owner.current.contents) -// world << "Found an intelicard, checking it for an AI" - for(var/mob/living/silicon/ai/M in C) -// world << "Found an AI, checking if it's alive" - if(istype(M, /mob/living/silicon/ai) && M.stat != 2) -// world << "yay, you win!" - return 1 + if(owner.current) + if(owner.current.check_contents_for(steal_target)) + if(target_name == "functional ai") +// world << "dude's after an AI, time to check for one." + for(var/obj/item/device/aicard/C in owner.current.contents) +// world << "Found an intelicard, checking it for an AI" + for(var/mob/living/silicon/ai/M in C) +// world << "Found an AI, checking if it's alive" + if(istype(M, /mob/living/silicon/ai) && M.stat != 2) +// world << "yay, you win!" + return 1 // world << "didn't find a living AI on the card" - return 0 + return 0 + else + return 1 else - return 1 - else - return 0 + return 0 nuclear explanation_text = "Destroy the station with a nuclear device." diff --git a/code/game/machinery/atmoalter/canister.dm b/code/game/machinery/atmoalter/canister.dm index eb057a59a7c..083d43569f1 100644 --- a/code/game/machinery/atmoalter/canister.dm +++ b/code/game/machinery/atmoalter/canister.dm @@ -13,7 +13,6 @@ pressure_resistance = 7*ONE_ATMOSPHERE var/temperature_resistance = 1000 + T0C volume = 1000 - var/throwforce = 0 /obj/machinery/portable_atmospherics/canister/sleeping_agent name = "Canister: \[N2O\]" diff --git a/code/game/machinery/atmoalter/portable_atmospherics.dm b/code/game/machinery/atmoalter/portable_atmospherics.dm index a5979bea6bc..c7207123d65 100644 --- a/code/game/machinery/atmoalter/portable_atmospherics.dm +++ b/code/game/machinery/atmoalter/portable_atmospherics.dm @@ -7,6 +7,7 @@ var/volume = 0 var/destroyed = 0 + var/throwforce = 0 var/maximum_pressure = 90*ONE_ATMOSPHERE @@ -102,27 +103,29 @@ else if ((istype(W, /obj/item/device/analyzer) || (istype(W, /obj/item/device/pda))) && get_dist(user, src) <= 1) for (var/mob/O in viewers(user, null)) O << "\red [user] has used [W] on \icon[icon]" + if(air_contents) + var/pressure = air_contents.return_pressure() + var/total_moles = air_contents.total_moles() - var/pressure = air_contents.return_pressure() - var/total_moles = air_contents.total_moles() + user << "\blue Results of analysis of \icon[icon]" + if (total_moles>0) + var/o2_concentration = air_contents.oxygen/total_moles + var/n2_concentration = air_contents.nitrogen/total_moles + var/co2_concentration = air_contents.carbon_dioxide/total_moles + var/plasma_concentration = air_contents.toxins/total_moles - user << "\blue Results of analysis of \icon[icon]" - if (total_moles>0) - var/o2_concentration = air_contents.oxygen/total_moles - var/n2_concentration = air_contents.nitrogen/total_moles - var/co2_concentration = air_contents.carbon_dioxide/total_moles - var/plasma_concentration = air_contents.toxins/total_moles + var/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration) - var/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration) - - user << "\blue Pressure: [round(pressure,0.1)] kPa" - user << "\blue Nitrogen: [round(n2_concentration*100)]%" - user << "\blue Oxygen: [round(o2_concentration*100)]%" - user << "\blue CO2: [round(co2_concentration*100)]%" - user << "\blue Plasma: [round(plasma_concentration*100)]%" - if(unknown_concentration>0.01) - user << "\red Unknown: [round(unknown_concentration*100)]%" - user << "\blue Temperature: [round(air_contents.temperature-T0C)]°C" + user << "\blue Pressure: [round(pressure,0.1)] kPa" + user << "\blue Nitrogen: [round(n2_concentration*100)]%" + user << "\blue Oxygen: [round(o2_concentration*100)]%" + user << "\blue CO2: [round(co2_concentration*100)]%" + user << "\blue Plasma: [round(plasma_concentration*100)]%" + if(unknown_concentration>0.01) + user << "\red Unknown: [round(unknown_concentration*100)]%" + user << "\blue Temperature: [round(air_contents.temperature-T0C)]°C" + else + user << "\blue Tank is empty!" else user << "\blue Tank is empty!" return diff --git a/code/game/machinery/gibber.dm b/code/game/machinery/gibber.dm index 571238bbbc5..81eabed6b9d 100644 --- a/code/game/machinery/gibber.dm +++ b/code/game/machinery/gibber.dm @@ -22,12 +22,12 @@ if(src.occupant) user << "\red The gibber is full, empty it first!" return - if(G.affecting.abiotic()) - user << "\red Subject may not have abiotic items on." - return if (!( istype(G, /obj/item/weapon/grab)) || !(istype(G.affecting, /mob/living/carbon/human))) user << "\red This item is not suitable for the gibber!" return + if(G.affecting.abiotic()) + user << "\red Subject may not have abiotic items on." + return user.visible_message("\red [user] starts to put [G.affecting] into the gibber!") src.add_fingerprint(user) diff --git a/code/game/objects/explosion.dm b/code/game/objects/explosion.dm index b4e02b96520..e73da73c3b1 100644 --- a/code/game/objects/explosion.dm +++ b/code/game/objects/explosion.dm @@ -4,7 +4,9 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa message_admins("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ") defer_powernet_rebuild = 1 - + if (!istype(epicenter, /turf)) + epicenter = epicenter.loc + return explosion(epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range) playsound(epicenter.loc, 'explosionfar.ogg', 100, 1, round(devastation_range*2,1) ) playsound(epicenter.loc, "explosion", 100, 1, round(devastation_range,1) ) diff --git a/code/game/objects/items/robot_parts.dm b/code/game/objects/items/robot_parts.dm index 981fd9acdf3..98b7ef4a5a9 100644 --- a/code/game/objects/items/robot_parts.dm +++ b/code/game/objects/items/robot_parts.dm @@ -123,7 +123,8 @@ W.loc = src src.brain = W var/mob/living/silicon/robot/O = new /mob/living/silicon/robot(get_turf(src.loc)) - O.gender = src.brain.owner.gender + if (src.brain.owner) + O.gender = src.brain.owner.gender //O.start = 1 O.invisibility = 0 O.name = "Cyborg" diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index 0fd6e04e93a..61ba5b60e5f 100644 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -163,14 +163,16 @@ WELDINGTOOOL /obj/item/weapon/weldingtool/proc/eyecheck(mob/user as mob) //check eye protection var/safety = null - - if (istype(user:head, /obj/item/clothing/head/helmet/welding) || istype(user:head, /obj/item/clothing/head/helmet/space)) - safety = 2 - else if (istype(user:glasses, /obj/item/clothing/glasses/sunglasses)) - safety = 1 - else if (istype(user:glasses, /obj/item/clothing/glasses/thermal)) - safety = -1 - else + if (istype(user, /mob/living/carbon/human)) + if (istype(user:head, /obj/item/clothing/head/helmet/welding) || istype(user:head, /obj/item/clothing/head/helmet/space)) + safety = 2 + else if (istype(user:glasses, /obj/item/clothing/glasses/sunglasses)) + safety = 1 + else if (istype(user:glasses, /obj/item/clothing/glasses/thermal)) + safety = -1 + else + safety = 0 + else if(istype(user, /mob/living/carbon)) safety = 0 switch(safety) if(1) diff --git a/code/game/objects/storage/crates.dm b/code/game/objects/storage/crates.dm index 2e62e09621b..4d851379d7c 100644 --- a/code/game/objects/storage/crates.dm +++ b/code/game/objects/storage/crates.dm @@ -214,5 +214,6 @@ /obj/crate/attackby(obj/item/weapon/W as obj, mob/user as mob) if(opened) user.drop_item() - W.loc = src.loc + if(W) + W.loc = src.loc else return attack_hand(user) \ No newline at end of file diff --git a/code/game/objects/weapons.dm b/code/game/objects/weapons.dm index 89ce05f079b..3d6fd17aa21 100644 --- a/code/game/objects/weapons.dm +++ b/code/game/objects/weapons.dm @@ -115,12 +115,14 @@ var/turf/T = src.loc if (ismob(T)) T = T.loc - src.part1.loc = T - src.part2.loc = T - src.part1.master = null - src.part2.master = null - src.part1 = null - src.part2 = null + if (src.part1) + src.part1.loc = T + src.part1.master = null + src.part1 = null + if (src.part2) + src.part2.loc = T + src.part2.master = null + src.part2 = null del(src) return diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm index 555bd4f2491..86791f41a25 100644 --- a/code/modules/admin/verbs/randomverbs.dm +++ b/code/modules/admin/verbs/randomverbs.dm @@ -62,8 +62,10 @@ if (!msg) return - if (usr.client && usr.client.holder) - M << "\bold You hear a voice in your head... \italic [msg]" + if(usr) + if (usr.client) + if(usr.client.holder) + M << "\bold You hear a voice in your head... \italic [msg]" log_admin("SubtlePM: [key_name(usr)] -> [key_name(M)] : [msg]") message_admins("\blue \bold SubtleMessage: [key_name_admin(usr)] -> [key_name_admin(M)] : [msg]", 1) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index c2c7214fbb3..7a2117d107c 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -43,10 +43,11 @@ ..() statpanel("Status") if (src.client.statpanel == "Status") - if(emergency_shuttle.online && emergency_shuttle.location < 2) - var/timeleft = emergency_shuttle.timeleft() - if (timeleft) - stat(null, "ETA-[(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]") + if(emergency_shuttle) + if(emergency_shuttle.online && emergency_shuttle.location < 2) + var/timeleft = emergency_shuttle.timeleft() + if (timeleft) + stat(null, "ETA-[(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]") /mob/dead/observer/proc/reenter_corpse() set category = "Special Verbs" diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 7d96b291419..f37af9e880b 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -153,10 +153,11 @@ // if(ticker.mode.name == "AI malfunction") // if(ticker.mode:malf_mode_declared) // stat(null, "Time left: [ ticker.mode:AI_win_timeleft]") - if(emergency_shuttle.online && emergency_shuttle.location < 2) - var/timeleft = emergency_shuttle.timeleft() - if (timeleft) - stat(null, "ETA-[(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]") + if(emergency_shuttle) + if(emergency_shuttle.online && emergency_shuttle.location < 2) + var/timeleft = emergency_shuttle.timeleft() + if (timeleft) + stat(null, "ETA-[(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]") if (src.client.statpanel == "Status") if (src.internal) @@ -1088,7 +1089,7 @@ else stain_icon = icon('blood.dmi', "suitblood[!src.lying ? "" : "2"]") src.overlays += image("icon" = stain_icon, "layer" = MOB_LAYER) - src.wear_suit.screen_loc = ui_oclothing + src.wear_suit.screen_loc = ui_oclothing if (istype(src.wear_suit, /obj/item/clothing/suit/straight_jacket)) if (src.handcuffed) src.handcuffed.loc = src.loc diff --git a/code/modules/mob/living/carbon/monkey/life.dm b/code/modules/mob/living/carbon/monkey/life.dm index 16ced97fcf3..e6a1d7b7a32 100644 --- a/code/modules/mob/living/carbon/monkey/life.dm +++ b/code/modules/mob/living/carbon/monkey/life.dm @@ -250,6 +250,8 @@ if(O2_pp < safe_oxygen_min) // Too little oxygen if(prob(20)) spawn(0) emote("gasp") + if (O2_pp == 0) + O2_pp = 0.01 var/ratio = safe_oxygen_min/O2_pp oxyloss += min(5*ratio, 7) // Don't fuck them up too fast (space only does 7 after all!) oxygen_used = breath.oxygen*ratio/6 diff --git a/code/modules/mob/living/carbon/monkey/monkey.dm b/code/modules/mob/living/carbon/monkey/monkey.dm index 6db48342f9e..00f0c69700c 100644 --- a/code/modules/mob/living/carbon/monkey/monkey.dm +++ b/code/modules/mob/living/carbon/monkey/monkey.dm @@ -29,8 +29,8 @@ /mob/living/carbon/monkey/movement_delay() var/tally = 0 - - if(src.reagents.has_reagent("hyperzine")) return -1 + if(src.reagents) + if(src.reagents.has_reagent("hyperzine")) return -1 var/health_deficiency = (100 - src.health) if(health_deficiency >= 45) tally += (health_deficiency / 25) diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index 536b2fe0471..a14ebfe8bbb 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -38,7 +38,8 @@ if (!src.client.changes) src.changes() if(istype (src, /mob/living)) - if(ticker.mode.name == "revolution") - if ((src.mind in ticker.mode:revolutionaries) || (src.mind in ticker.mode:head_revolutionaries)) - ticker.mode:update_rev_icons_added(src.mind) + if(ticker) + if(ticker.mode.name == "revolution") + if ((src.mind in ticker.mode:revolutionaries) || (src.mind in ticker.mode:head_revolutionaries)) + ticker.mode:update_rev_icons_added(src.mind) ..() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 36241e276ed..90f87934389 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1438,8 +1438,9 @@ //we don't use message_admins here because the sender/receiver might get it too for (var/mob/K in world) - if(K && K.client && K.client.holder && K.key != usr.key && K.key != M.key) - K << "PM: [key_name(usr, K)]->[key_name(M, K)]: \blue [t]" + if(K) + if(K.client && K.client.holder && K.key != usr.key && K.key != M.key) + K << "PM: [key_name(usr, K)]->[key_name(M, K)]: \blue [t]" ..() return @@ -2024,26 +2025,28 @@ if(src.mob) var/mob/M = src.mob M.loc = null // HACK, but whatever, this works + var/obj/screen/boom = M.hud_used.station_explosion - M.client.screen += boom - if(ticker) - switch(ticker.mode.name) - if("nuclear emergency") - flick("start_nuke", boom) - if("AI malfunction") - flick("start_malf", boom) - else - boom.icon_state = "start" - sleep(40) - M << sound('explosionfar.ogg') - boom.icon_state = "end" - flick("explode", boom) - sleep(40) - if(ticker) - switch(ticker.mode.name) - if("nuclear emergency") - boom.icon_state = "loss_nuke" - if("AI malfunction") - boom.icon_state = "loss_malf" - else - boom.icon_state = "loss_general" + if (M.client) + M.client.screen += boom + if(ticker) + switch(ticker.mode.name) + if("nuclear emergency") + flick("start_nuke", boom) + if("AI malfunction") + flick("start_malf", boom) + else + boom.icon_state = "start" + sleep(40) + M << sound('explosionfar.ogg') + boom.icon_state = "end" + flick("explode", boom) + sleep(40) + if(ticker) + switch(ticker.mode.name) + if("nuclear emergency") + boom.icon_state = "loss_nuke" + if("AI malfunction") + boom.icon_state = "loss_malf" + else + boom.icon_state = "loss_general" diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index b315bf962df..cf8972dd546 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -222,24 +222,24 @@ mob/new_player proc/AttemptLateSpawn(rank, maxAllowed) if(IsJobAvailable(rank, maxAllowed)) var/mob/living/carbon/human/character = create_character() - - character.Equip_Rank(rank, joined_late=1) + if (character) + character.Equip_Rank(rank, joined_late=1) //add to manifest -- Commented out in favor of ManifestLateSpawn() -- TLE //for(var/datum/data/record/t in data_core.general) // if((t.fields["name"] == character.real_name) && (t.fields["rank"] == "Unassigned")) // t.fields["rank"] = rank - ManifestLateSpawn(character) + ManifestLateSpawn(character) + if(ticker) + if (ticker.current_state == GAME_STATE_PLAYING) + for (var/mob/living/silicon/ai/A in world) + if (!A.stat) + A.say("[character.real_name] has signed up as [rank].") - if (ticker.current_state == GAME_STATE_PLAYING) - for (var/mob/living/silicon/ai/A in world) - if (!A.stat) - A.say("[character.real_name] has signed up as [rank].") - - var/starting_loc = pick(latejoin) - character.loc = starting_loc - del(src) + var/starting_loc = pick(latejoin) + character.loc = starting_loc + del(src) else src << alert("[rank] is not available. Please try another.") @@ -371,8 +371,8 @@ mob/new_player preferences.copy_to(new_character) new_character.dna.ready_dna(new_character) - - mind.transfer_to(new_character) + if(mind) + mind.transfer_to(new_character) return new_character