From 920d05c9e04f2df0898ae947fd746f5720c8644d Mon Sep 17 00:00:00 2001 From: D3athrow Date: Mon, 4 May 2015 20:38:51 -0500 Subject: [PATCH] Lots of runtime fixes --- code/ZAS/Turf.dm | 2 +- code/__HELPERS/experimental.dm | 2 ++ code/__HELPERS/lists.dm | 3 +++ code/_onclick/hud/hud.dm | 15 ++++++++++++--- code/_onclick/observer.dm | 13 +++++++++++++ code/datums/uplink_item.dm | 2 ++ code/game/atoms.dm | 2 +- code/game/machinery/portable_turret.dm | 6 ++++++ code/game/objects/items/devices/mat_synth.dm | 2 +- code/game/objects/items/weapons/gift_wrappaper.dm | 2 +- code/game/objects/items/weapons/handcuffs.dm | 1 + code/game/objects/items/weapons/tools.dm | 3 +-- code/game/objects/items/weapons/twohanded.dm | 9 +++++++++ code/game/smoothwall.dm | 6 ++++++ code/game/turfs/simulated/walls.dm | 1 + code/libs/Get Flat Icon/Get Flat Icon.dm | 13 +++++++------ code/modules/media/mediamanager.dm | 2 ++ code/modules/mob/dead/observer/say.dm | 13 +++++++------ code/modules/mob/emote.dm | 2 +- code/modules/mob/living/carbon/human/life.dm | 3 ++- code/modules/mob/living/living.dm | 7 +++++-- code/modules/nano/JSON Reader.dm | 2 +- code/modules/optics/mirrors/mirror.dm | 4 ++++ code/modules/optics/prism.dm | 5 +++++ 24 files changed, 94 insertions(+), 26 deletions(-) diff --git a/code/ZAS/Turf.dm b/code/ZAS/Turf.dm index cd82c7ecc0d..5878493c711 100644 --- a/code/ZAS/Turf.dm +++ b/code/ZAS/Turf.dm @@ -124,7 +124,7 @@ //This happens when windows move or are constructed. We need to rebuild. if((previously_open & d) && istype(unsim, /turf/simulated)) var/turf/simulated/sim = unsim - if(sim.zone == zone) + if(istype(zone) && sim.zone == zone) zone.rebuild() return diff --git a/code/__HELPERS/experimental.dm b/code/__HELPERS/experimental.dm index fda8232e730..401d6377efc 100644 --- a/code/__HELPERS/experimental.dm +++ b/code/__HELPERS/experimental.dm @@ -130,6 +130,8 @@ var/list/exclude = list("inhand_states", "loc", "locs", "parent_type", "vars", " vars[key] = initial(vars[key]) /proc/isInTypes(atom/Object, types) + if(!Object) + return 0 var/prototype = Object.type Object = null diff --git a/code/__HELPERS/lists.dm b/code/__HELPERS/lists.dm index 84f702306fa..0106a16a81c 100644 --- a/code/__HELPERS/lists.dm +++ b/code/__HELPERS/lists.dm @@ -165,6 +165,9 @@ i = L.len else i-- + if(i < L.len || i > L.len) + warning("[__FILE__]L[__LINE__]: [i] is outside of bounds for list, ([L.len])") + return return L[i] /* diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index c7dfe2c4e20..45e286213f8 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -169,9 +169,18 @@ datum/hud/New(mob/owner) if(!mymob.client) return 0 - var/ui_style = ui_style2icon(mymob.client.prefs.UI_style) - var/ui_color = mymob.client.prefs.UI_style_color - var/ui_alpha = mymob.client.prefs.UI_style_alpha + + var/ui_style + var/ui_color + var/ui_alpha + if(!mymob.client.prefs) + ui_sytle = ui_style2icon("Midnight") + ui_color = null + ui_alpha = 255 + else + ui_style = ui_style2icon(mymob.client.prefs.UI_style) + ui_color = mymob.client.prefs.UI_style_color + ui_alpha = mymob.client.prefs.UI_style_alpha if(ishuman(mymob)) human_hud(ui_style, ui_color, ui_alpha) // Pass the player the UI style chosen in preferences diff --git a/code/_onclick/observer.dm b/code/_onclick/observer.dm index 1ce6ac52e22..275a1e2cc07 100644 --- a/code/_onclick/observer.dm +++ b/code/_onclick/observer.dm @@ -15,6 +15,19 @@ else var/turf/targetloc = get_turf(A) var/area/targetarea = get_area(A) + if(!targetloc) + if(!targetarea) + return + var/list/turfs = list() + for(var/area/Ar in A.related) + for(var/turf/T in Ar) + if(T.density) + continue + turfs.Add(T) + + targetloc = pick_n_take(turfs) + if(!T) + return if(targetarea && targetarea.anti_ethereal && !isAdminGhost(usr)) usr << "A dark forcefield prevents you from entering the area." else diff --git a/code/datums/uplink_item.dm b/code/datums/uplink_item.dm index dbb5cc09a86..fb457b889c3 100644 --- a/code/datums/uplink_item.dm +++ b/code/datums/uplink_item.dm @@ -70,6 +70,8 @@ var/list/uplink_items = list() return 0 var/obj/I = spawn_item(get_turf(user), U, user) + if(!I) + return 0 var/icon/tempimage = icon(I.icon, I.icon_state) end_icons += tempimage var/tempstate = end_icons.len diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 7c8aa75e549..e4f996ca116 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -69,7 +69,7 @@ var/global/list/ghdel_profiling = list() var/mob/living/M = hit_atom M.hitby(src) - log_attack("[hit_atom] ([M.ckey]) was hit by [src] thrown by ([src.fingerprintslast])") + log_attack("[hit_atom] ([M ? M.ckey : "what"]) was hit by [src] thrown by ([src.fingerprintslast])") else if(isobj(hit_atom)) var/obj/O = hit_atom diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index ac4de9b83e7..ecfbf10b060 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -177,6 +177,12 @@ iconholder = 1 egun = 1 reqpower = 200 + if(!eprojectile || !projectile) + projectile = /obj/item/projectile/energy/electrode// if it hasn't been emagged, it uses normal taser shots + eprojectile = /obj/item/projectile/beam//If it has, going to kill mode + iconholder = 1 + egun = 1 + reqpower = 200 Destroy() // deletes its own cover with it diff --git a/code/game/objects/items/devices/mat_synth.dm b/code/game/objects/items/devices/mat_synth.dm index de2615cd90e..1a54a8b4d7f 100644 --- a/code/game/objects/items/devices/mat_synth.dm +++ b/code/game/objects/items/devices/mat_synth.dm @@ -51,7 +51,7 @@ if(isrobot(user)) var/mob/living/silicon/robot/R = user - if(material_type && R.cell.charge) + if(R && R.cell && material_type && R.cell.charge) var/modifier = MAT_COST_COMMON if(initial(active_material.perunit) < 3750) modifier = MAT_COST_MEDIUM diff --git a/code/game/objects/items/weapons/gift_wrappaper.dm b/code/game/objects/items/weapons/gift_wrappaper.dm index d56e6a55d5c..c6732f4374e 100644 --- a/code/game/objects/items/weapons/gift_wrappaper.dm +++ b/code/game/objects/items/weapons/gift_wrappaper.dm @@ -29,7 +29,7 @@ /obj/item/weapon/gift/New(var/W) ..() - w_class = W + w_class = W.w_class /obj/item/weapon/gift/attack_self(mob/user as mob) user.drop_item(src) diff --git a/code/game/objects/items/weapons/handcuffs.dm b/code/game/objects/items/weapons/handcuffs.dm index fdfbaaaf8b7..9a50d09e651 100644 --- a/code/game/objects/items/weapons/handcuffs.dm +++ b/code/game/objects/items/weapons/handcuffs.dm @@ -19,6 +19,7 @@ var/breakouttime = 1200 //Deciseconds = 120s = 2 minutes /obj/item/weapon/handcuffs/attack(mob/living/carbon/C as mob, mob/user as mob) + if(!istype(C)) return if(istype(src, /obj/item/weapon/handcuffs/cyborg) && isrobot(user)) if(!C.handcuffed) var/turf/p_loc = user.loc diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index 55b7d83334d..c42d5374f6a 100644 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -643,8 +643,7 @@ if(G.reagents.reagent_list.len>1) user << "The mixture is rejected by the tool." return - var/datum/reagent/R = G.reagents.reagent_list[1] - if(R.id != "sacid") + if(!has_reagent("sacid", 1)) user << "The tool is not compatible with that." return else diff --git a/code/game/objects/items/weapons/twohanded.dm b/code/game/objects/items/weapons/twohanded.dm index bb87ca6d072..f8f00a43bf8 100644 --- a/code/game/objects/items/weapons/twohanded.dm +++ b/code/game/objects/items/weapons/twohanded.dm @@ -17,10 +17,16 @@ var/obj/item/wielding = null /obj/item/offhand/dropped(user) + if(!wielding) + qdel(src) + return null return wielding.unwield(user) /obj/item/offhand/unwield(user) + if(!wielding) + qdel(src) + return null return wielding.unwield(user) /obj/item/offhand/preattack(atom/target, mob/user, proximity_flag, click_parameters) @@ -32,6 +38,9 @@ return 1 /obj/item/offhand/attack_self(mob/user) + if(!wielding) + qdel(src) + return null return wielding.unwield(user) /obj/item/offhand/proc/attach_to(var/obj/item/I) diff --git a/code/game/smoothwall.dm b/code/game/smoothwall.dm index 710305f80da..eed45f46702 100644 --- a/code/game/smoothwall.dm +++ b/code/game/smoothwall.dm @@ -23,9 +23,15 @@ return junction /atom/proc/isSmoothableNeighbor(atom/A) + if(!A) + WARNING("[__FILE__]L[__LINE__]: atom/isSmoothableNeighbor given bad atom") + return 0 return isInTypes(A, canSmoothWith) /turf/simulated/wall/isSmoothableNeighbor(atom/A) + if(!A) + WARNING("[__FILE__]L[__LINE__]: turf/isSmoothableNeighbor given bad atom") + return 0 if(isInTypes(A, canSmoothWith)) // COLON OPERATORS ARE TERRIBLE BUT I HAVE NO CHOICE if(src.mineral == A:mineral) diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm index 9910c2f4838..f01110168da 100644 --- a/code/game/turfs/simulated/walls.dm +++ b/code/game/turfs/simulated/walls.dm @@ -208,6 +208,7 @@ playsound(src, 'sound/items/Welder.ogg', 100, 1) if(do_after(user, 100)) + if(!istype(src)) return playsound(src, 'sound/items/Welder.ogg', 100, 1) user.visible_message("[user] slices through \the [src]'s outer plating.", \ "You slice through \the [src]'s outer plating.", \ diff --git a/code/libs/Get Flat Icon/Get Flat Icon.dm b/code/libs/Get Flat Icon/Get Flat Icon.dm index 76022cbb03f..3e4bf6d0bd8 100644 --- a/code/libs/Get Flat Icon/Get Flat Icon.dm +++ b/code/libs/Get Flat Icon/Get Flat Icon.dm @@ -146,12 +146,13 @@ proc/getFlatIcon(atom/A, dir, cache=1, exact=0) // 1 = use cache, 2 = override c if(I:name == "damage layer") var/mob/living/carbon/human/H = A - for(var/datum/organ/external/O in H.organs) - if(!(O.status & ORGAN_DESTROYED)) - if(O.damage_state == "00") continue - var/icon/DI - DI = H.get_damage_icon_part(O.damage_state, O.icon_name, (H.species.blood_color == "#A10808" ? "" : H.species.blood_color)) - add.Blend(DI,ICON_OVERLAY) + if(istype(H)) + for(var/datum/organ/external/O in H.organs) + if(!(O.status & ORGAN_DESTROYED)) + if(O.damage_state == "00") continue + var/icon/DI + DI = H.get_damage_icon_part(O.damage_state, O.icon_name, (H.species.blood_color == "#A10808" ? "" : H.species.blood_color)) + add.Blend(DI,ICON_OVERLAY) if(!exact && iscarbon(A)) var/mob/living/carbon/C = A diff --git a/code/modules/media/mediamanager.dm b/code/modules/media/mediamanager.dm index c39ecb4a2b0..f6ff358a6cd 100644 --- a/code/modules/media/mediamanager.dm +++ b/code/modules/media/mediamanager.dm @@ -161,6 +161,8 @@ function SetMusic(url, time, volume) { // Tell the player to play something via JS. proc/send_update() + if(!(!owner.prefs)) + return if(!(owner.prefs.toggles & SOUND_STREAMING) && url != "") return // Nope. MP_DEBUG("Sending update to VLC ([url])...") diff --git a/code/modules/mob/dead/observer/say.dm b/code/modules/mob/dead/observer/say.dm index 79fabeadbe8..73de53ca6e0 100644 --- a/code/modules/mob/dead/observer/say.dm +++ b/code/modules/mob/dead/observer/say.dm @@ -38,11 +38,12 @@ if (source_turf in view(src)) message = "[message]" else - if (isnull(radio_freq)) - if (!(client.prefs.toggles & CHAT_GHOSTEARS)) - return - else - if (!(client.prefs.toggles & CHAT_GHOSTRADIO)) - return + if(client && client.prefs) + if (isnull(radio_freq)) + if (!(client.prefs.toggles & CHAT_GHOSTEARS)) + return + else + if (!(client.prefs.toggles & CHAT_GHOSTRADIO)) + return src << "(Follow) [message]" diff --git a/code/modules/mob/emote.dm b/code/modules/mob/emote.dm index 2a8673976d0..413d84f64bd 100644 --- a/code/modules/mob/emote.dm +++ b/code/modules/mob/emote.dm @@ -32,7 +32,7 @@ continue if(findtext(message," snores.")) //Because we have so many sleeping people. break - if(M.stat == DEAD && (M.client.prefs.toggles & CHAT_GHOSTSIGHT) && !(M in viewers(src,null))) + if(M.stat == DEAD && M.client && M.client.prefs && (M.client.prefs.toggles & CHAT_GHOSTSIGHT) && !(M in viewers(src,null))) M.show_message(message) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 4fe1e72c959..f93b25afa46 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1626,7 +1626,8 @@ var/global/list/organ_damage_overlays = list( // Not on the station or mining? var/turf/temp_turf = get_turf(remoteview_target) - if((temp_turf.z != 1 && temp_turf.z != 5) || remoteview_target.stat!=CONSCIOUS) + + if(temp_turf && (temp_turf.z != 1 && temp_turf.z != 5) || remoteview_target.stat!=CONSCIOUS) src << "Your psy-connection grows too faint to maintain!" isRemoteObserve = 0 if(!isRemoteObserve && client && !client.adminobs && !iscamera(client.eye)) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 13089c54538..0688c4bfc35 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -550,15 +550,18 @@ stop_pulling() return + var/mob/living/M = pulling if (!restrained()) var/diag = get_dir(src, pulling) if ((diag - 1) & diag) else diag = null if ((get_dist(src, pulling) > 1 || diag)) - if(isturf(pulling.loc)) + if(!istype(pulling) || !pulling) + WARNING("Pulling disappeared! pulling = [pulling] old pulling = [M]") + else if(isturf(pulling.loc)) if (isliving(pulling)) - var/mob/living/M = pulling + M = pulling var/ok = 1 if (locate(/obj/item/weapon/grab, M.grabbed_by)) if (prob(75)) diff --git a/code/modules/nano/JSON Reader.dm b/code/modules/nano/JSON Reader.dm index 000bb87f0a4..b3b910270c2 100644 --- a/code/modules/nano/JSON Reader.dm +++ b/code/modules/nano/JSON Reader.dm @@ -217,4 +217,4 @@ json_reader die(json_token/T) if(!T) T = get_token() - CRASH("Unexpected token: [T.value].") \ No newline at end of file + CRASH("Unexpected token: [T.value] [json] index:[i] .") \ No newline at end of file diff --git a/code/modules/optics/mirrors/mirror.dm b/code/modules/optics/mirrors/mirror.dm index ac231613fc5..c4d30f60153 100644 --- a/code/modules/optics/mirrors/mirror.dm +++ b/code/modules/optics/mirrors/mirror.dm @@ -105,10 +105,12 @@ var/global/list/obj/machinery/mirror/mirror_list = list() /obj/machinery/mirror/proc/kill_all_beams() for(var/i=1;i<=4;i++) + if(i > emitted_beams.len) break var/obj/effect/beam/beam = emitted_beams[i] qdel(beam) emitted_beams[i]=null beam=null + emitted_beams.len = 4 /obj/machinery/mirror/proc/update_beams() overlays.len = 0 @@ -167,6 +169,8 @@ var/global/list/obj/machinery/mirror/mirror_list = list() // Emit beams. + if(emitted_beams.len < 4) + emitted_beams.len = 4 for(i=1;i<=4;i++) var/cdir = cardinal[i] var/list/dirdata = beam_dirs[i] diff --git a/code/modules/optics/prism.dm b/code/modules/optics/prism.dm index bf6c0ead056..8eb4102e122 100644 --- a/code/modules/optics/prism.dm +++ b/code/modules/optics/prism.dm @@ -97,6 +97,11 @@ var/list/obj/machinery/prism/prism_list = list() /obj/machinery/prism/proc/update_beams() overlays.len = 0 //testing("Beam count: [beams.len]") + if(!beams) + if(loc || !gcDestroyed) + beams = list() + else + return if(beams.len>0) var/newbeam=0 if(!beam)