From 7575c9a9cf2af32c0d361b0287d8cf9792e3d212 Mon Sep 17 00:00:00 2001 From: "giacomand@gmail.com" Date: Tue, 17 Jul 2012 16:23:47 +0000 Subject: [PATCH] -Added a new global list. Cameras will hold every camera created and is kept up to date by the Camera's New() and Del(). Much faster than having everything loop the world. AI camera movement seems faster too. -Fixed Issue 415 -Tweaked creating new cameras. When you create a camera from a camera assembly, it will now auto detect the direction it should be in. I also added a confirmation message which allows you to re choose the direction with up to 5 chances; to avoid infinite loops. -Made the New Player Options window a little bit slimmer. -Forgot to add a changelog for my last commit. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4096 316c924e-a436-60f5-8080-3fe189b3f50e --- code/defines/obj/weapon.dm | 2 +- code/game/machinery/camera.dm | 44 ++++++++++++++++++++-- code/game/machinery/computer/camera.dm | 4 +- code/game/objects/grenades/chem_grenade.dm | 24 +++++++++--- code/modules/admin/verbs/mapping.dm | 4 +- code/modules/mob/living/silicon/ai/ai.dm | 19 +++++----- code/modules/mob/living/silicon/ai/move.dm | 2 +- code/modules/mob/living/silicon/pai/pai.dm | 2 +- code/modules/mob/new_player/new_player.dm | 2 +- html/changelog.html | 4 ++ 10 files changed, 81 insertions(+), 26 deletions(-) diff --git a/code/defines/obj/weapon.dm b/code/defines/obj/weapon.dm index 81b93c6a84b..aae822ffa50 100644 --- a/code/defines/obj/weapon.dm +++ b/code/defines/obj/weapon.dm @@ -1202,7 +1202,7 @@ /obj/item/weapon/camera_bug/attack_self(mob/usr as mob) var/list/cameras = new/list() - for (var/obj/machinery/camera/C in world) + for (var/obj/machinery/camera/C in Cameras) if (C.bugged && C.status) cameras.Add(C) if (length(cameras) == 0) diff --git a/code/game/machinery/camera.dm b/code/game/machinery/camera.dm index 714b2a224aa..52ae99dfcc5 100644 --- a/code/game/machinery/camera.dm +++ b/code/game/machinery/camera.dm @@ -1,3 +1,13 @@ +var/global/list/obj/machinery/camera/Cameras = list() + +/obj/machinery/camera/New() + Cameras += src + ..() + +/obj/machinery/camera/Del() + Cameras -= src + ..() + // Double clicking turfs to move to nearest camera @@ -143,7 +153,7 @@ if (closestDist > 7 || closestDist == -1) //check other cameras var/obj/machinery/camera/closest = C - for(var/obj/machinery/camera/C2 in world) + for(var/obj/machinery/camera/C2 in Cameras) if (C2.network == src.network) if (C2.z == target.z) zmatched = 1 @@ -191,10 +201,14 @@ if (stat == 2) return + // If they cancel then just put them back to their old camera + var/obj/machinery/camera/tempC = src.current user.machine = src + src.current = null + switchCamera(null) var/list/L = list() - for (var/obj/machinery/camera/C in world) + for (var/obj/machinery/camera/C in Cameras) L.Add(C) camera_sort(L) @@ -208,11 +222,15 @@ var/t = input(user, "Which camera should you change to?") as null|anything in D if (!t || t == "Cancel") - switchCamera(null) + if(tempC && tempC.status) + src.current = tempC + switchCamera(null) + else + src.current = null + switchCamera(null) return 0 var/obj/machinery/camera/C = D[t] - switchCamera(C) return @@ -383,6 +401,24 @@ O.reset_view(null) O << "The screen bursts into static." +/atom/proc/auto_turn() + //Automatically turns based on nearby walls. + var/turf/simulated/wall/T = null + for(var/i = 1, i <= 8; i += i) + T = get_ranged_target_turf(src, i, 1) + if(!isnull(T) && istype(T)) + //If someone knows a better way to do this, let me know. -Giacom + switch(i) + if(NORTH) + src.dir = SOUTH + if(SOUTH) + src.dir = NORTH + if(WEST) + src.dir = EAST + if(EAST) + src.dir = WEST + break + //Return a working camera that can see a given mob //or null if none /proc/seen_by_camera(var/mob/M) diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index c95ad391534..ee93d254d76 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -33,7 +33,7 @@ user.machine = src var/list/L = list() - for (var/obj/machinery/camera/C in world) + for (var/obj/machinery/camera/C in Cameras) L.Add(C) camera_sort(L) @@ -57,6 +57,8 @@ if(C) if ((get_dist(user, src) > 1 || user.machine != src || user.blinded || !( user.canmove ) || !( C.status )) && (!istype(user, /mob/living/silicon/ai))) + if(!C.status) + src.current = null return 0 else src.current = C diff --git a/code/game/objects/grenades/chem_grenade.dm b/code/game/objects/grenades/chem_grenade.dm index 8624fbb4a53..c5c4069ac44 100644 --- a/code/game/objects/grenades/chem_grenade.dm +++ b/code/game/objects/grenades/chem_grenade.dm @@ -152,15 +152,29 @@ if(istype(W, /obj/item/weapon/screwdriver)) playsound(src.loc, 'Screwdriver.ogg', 50, 1) user << "\blue You connect the lense." - var/B + var/obj/machinery/camera/B = null if(motion == 1) B = new /obj/machinery/camera/motion( src.loc ) else B = new /obj/machinery/camera( src.loc ) - B:network = "SS13" - B:network = input(usr, "Which network would you like to connect this camera to?", "Set Network", "SS13") - direct = input(user, "Direction?", "Assembling Camera", null) in list( "NORTH", "EAST", "SOUTH", "WEST" ) - B:dir = text2dir(direct) + // To prevent people exploiting the fact that it doesn't delete the assembly until the user is done + // entering the camera options. + src.loc = B + + //Auto detect walls and turn camera based on wall locations. + B.auto_turn() + + B.network = "SS13" + B.network = input(usr, "Which network would you like to connect this camera to?", "Set Network", "SS13") + + for(var/i = 5; i >= 0; i -= 1) + direct = input(user, "Direction?", "Assembling Camera", null) in list("LEAVE IT", "NORTH", "EAST", "SOUTH", "WEST" ) + if(direct != "LEAVE IT") + B.dir = text2dir(direct) + if(i != 0) + var/confirm = alert(user, "Is this what you want? Chances Remaining: [i]", "Confirmation", "Yes", "No") + if(confirm == "Yes") + break del(src) prime() diff --git a/code/modules/admin/verbs/mapping.dm b/code/modules/admin/verbs/mapping.dm index f69b04b8c08..00028b6eb0b 100644 --- a/code/modules/admin/verbs/mapping.dm +++ b/code/modules/admin/verbs/mapping.dm @@ -57,7 +57,7 @@ var/intercom_range_display_status = 0 del(C) if(camera_range_display_status) - for(var/obj/machinery/camera/C in world) + for(var/obj/machinery/camera/C in Cameras) new/obj/effect/debugging/camera_range(C.loc) feedback_add_details("admin_verb","mCRD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! @@ -73,7 +73,7 @@ var/intercom_range_display_status = 0 var/list/obj/machinery/camera/CL = list() - for(var/obj/machinery/camera/C in world) + for(var/obj/machinery/camera/C in Cameras) CL += C var/output = {"CAMERA ANNOMALITIES REPORT
diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index c480bde39e8..fc9377c3533 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -269,12 +269,12 @@ var/mob/living/silicon/ai/A = locate(href_list["track2"]) if(A && target) - A:cameraFollow = target + A.cameraFollow = target A << text("Now tracking [] on camera.", target.name) if (usr.machine == null) usr.machine = usr - while (usr:cameraFollow == target) + while (src.cameraFollow == target) usr << "Target is not on or near any active cameras on the station. We'll check again in 5 seconds (unless you use the cancel-camera verb)." sleep(40) continue @@ -356,17 +356,16 @@ /mob/living/silicon/ai/proc/switchCamera(var/obj/machinery/camera/C) - usr:cameraFollow = null - if (!C) + + src.cameraFollow = null + if (!C || stat == 2 || !C.status || C.network != network) machine = null reset_view(null) return 0 - if (stat == 2 || !C.status || C.network != network) return 0 // ok, we're alive, camera is good and in our network... - machine = src - src:current = C + src.current = C reset_view(C) return 1 @@ -429,7 +428,7 @@ set name = "Cancel Camera View" reset_view(null) machine = null - src:cameraFollow = null + src.cameraFollow = null //Replaces /mob/living/silicon/ai/verb/change_network() in ai.dm & camera.dm //Adds in /mob/living/silicon/ai/proc/ai_network_change() instead @@ -439,14 +438,14 @@ set name = "Change Camera Network" reset_view(null) machine = null - src:cameraFollow = null + src.cameraFollow = null var/cameralist[0] if(usr.stat == 2) usr << "You can't change your camera network because you are dead!" return - for (var/obj/machinery/camera/C in world) + for (var/obj/machinery/camera/C in Cameras) if(!C.status) continue if(C.network == "AI Satellite") diff --git a/code/modules/mob/living/silicon/ai/move.dm b/code/modules/mob/living/silicon/ai/move.dm index fc5355d6478..9fb33a12d94 100644 --- a/code/modules/mob/living/silicon/ai/move.dm +++ b/code/modules/mob/living/silicon/ai/move.dm @@ -42,7 +42,7 @@ var/area/A = get_area(old) var/list/old_types = dd_text2list("[A.type]", "/") - for(var/obj/machinery/camera/current in world) + for(var/obj/machinery/camera/current in Cameras) if(user.network != current.network) continue if(!current.status) continue // ignore disabled cameras diff --git a/code/modules/mob/living/silicon/pai/pai.dm b/code/modules/mob/living/silicon/pai/pai.dm index 94967a4f8d2..324464e7e9d 100644 --- a/code/modules/mob/living/silicon/pai/pai.dm +++ b/code/modules/mob/living/silicon/pai/pai.dm @@ -195,7 +195,7 @@ usr << "You can't change your camera network because you are dead!" return - for (var/obj/machinery/camera/C in world) + for (var/obj/machinery/camera/C in Cameras) if(!C.status) continue else diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 40018881107..ddd15680763 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -56,7 +56,7 @@ output += "" - src << browse(output,"window=playersetup;size=250x240;can_close=0") + src << browse(output,"window=playersetup;size=210x240;can_close=0") return proc/Playmusic() diff --git a/html/changelog.html b/html/changelog.html index af4961cb528..21bdd639e14 100644 --- a/html/changelog.html +++ b/html/changelog.html @@ -54,6 +54,10 @@ should be listed in the changelog upon commit tho. Thanks. -->
  • Added Captain's Backpack and Satchel
  • Added three new hairstyles by Sly: Gelled, Flat Top, and Pigtails. Hair list has also been sorted by grouping similar styles.
  • +

    Giacom updated:

    +