-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
This commit is contained in:
giacomand@gmail.com
2012-07-17 16:23:47 +00:00
parent 01ab14455a
commit 7575c9a9cf
10 changed files with 81 additions and 26 deletions

View File

@@ -1202,7 +1202,7 @@
/obj/item/weapon/camera_bug/attack_self(mob/usr as mob) /obj/item/weapon/camera_bug/attack_self(mob/usr as mob)
var/list/cameras = new/list() 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) if (C.bugged && C.status)
cameras.Add(C) cameras.Add(C)
if (length(cameras) == 0) if (length(cameras) == 0)

View File

@@ -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 // Double clicking turfs to move to nearest camera
@@ -143,7 +153,7 @@
if (closestDist > 7 || closestDist == -1) if (closestDist > 7 || closestDist == -1)
//check other cameras //check other cameras
var/obj/machinery/camera/closest = C 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.network == src.network)
if (C2.z == target.z) if (C2.z == target.z)
zmatched = 1 zmatched = 1
@@ -191,10 +201,14 @@
if (stat == 2) if (stat == 2)
return return
// If they cancel then just put them back to their old camera
var/obj/machinery/camera/tempC = src.current
user.machine = src user.machine = src
src.current = null
switchCamera(null)
var/list/L = list() var/list/L = list()
for (var/obj/machinery/camera/C in world) for (var/obj/machinery/camera/C in Cameras)
L.Add(C) L.Add(C)
camera_sort(L) camera_sort(L)
@@ -208,11 +222,15 @@
var/t = input(user, "Which camera should you change to?") as null|anything in D var/t = input(user, "Which camera should you change to?") as null|anything in D
if (!t || t == "Cancel") if (!t || t == "Cancel")
switchCamera(null) if(tempC && tempC.status)
src.current = tempC
switchCamera(null)
else
src.current = null
switchCamera(null)
return 0 return 0
var/obj/machinery/camera/C = D[t] var/obj/machinery/camera/C = D[t]
switchCamera(C) switchCamera(C)
return return
@@ -383,6 +401,24 @@
O.reset_view(null) O.reset_view(null)
O << "The screen bursts into static." 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 //Return a working camera that can see a given mob
//or null if none //or null if none
/proc/seen_by_camera(var/mob/M) /proc/seen_by_camera(var/mob/M)

View File

@@ -33,7 +33,7 @@
user.machine = src user.machine = src
var/list/L = list() var/list/L = list()
for (var/obj/machinery/camera/C in world) for (var/obj/machinery/camera/C in Cameras)
L.Add(C) L.Add(C)
camera_sort(L) camera_sort(L)
@@ -57,6 +57,8 @@
if(C) if(C)
if ((get_dist(user, src) > 1 || user.machine != src || user.blinded || !( user.canmove ) || !( C.status )) && (!istype(user, /mob/living/silicon/ai))) 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 return 0
else else
src.current = C src.current = C

View File

@@ -152,15 +152,29 @@
if(istype(W, /obj/item/weapon/screwdriver)) if(istype(W, /obj/item/weapon/screwdriver))
playsound(src.loc, 'Screwdriver.ogg', 50, 1) playsound(src.loc, 'Screwdriver.ogg', 50, 1)
user << "\blue You connect the lense." user << "\blue You connect the lense."
var/B var/obj/machinery/camera/B = null
if(motion == 1) if(motion == 1)
B = new /obj/machinery/camera/motion( src.loc ) B = new /obj/machinery/camera/motion( src.loc )
else else
B = new /obj/machinery/camera( src.loc ) B = new /obj/machinery/camera( src.loc )
B:network = "SS13" // To prevent people exploiting the fact that it doesn't delete the assembly until the user is done
B:network = input(usr, "Which network would you like to connect this camera to?", "Set Network", "SS13") // entering the camera options.
direct = input(user, "Direction?", "Assembling Camera", null) in list( "NORTH", "EAST", "SOUTH", "WEST" ) src.loc = B
B:dir = text2dir(direct)
//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) del(src)
prime() prime()

View File

@@ -57,7 +57,7 @@ var/intercom_range_display_status = 0
del(C) del(C)
if(camera_range_display_status) 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) 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! 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() 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 CL += C
var/output = {"<B>CAMERA ANNOMALITIES REPORT</B><HR> var/output = {"<B>CAMERA ANNOMALITIES REPORT</B><HR>

View File

@@ -269,12 +269,12 @@
var/mob/living/silicon/ai/A = locate(href_list["track2"]) var/mob/living/silicon/ai/A = locate(href_list["track2"])
if(A && target) if(A && target)
A:cameraFollow = target A.cameraFollow = target
A << text("Now tracking [] on camera.", target.name) A << text("Now tracking [] on camera.", target.name)
if (usr.machine == null) if (usr.machine == null)
usr.machine = usr 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)." 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) sleep(40)
continue continue
@@ -356,17 +356,16 @@
/mob/living/silicon/ai/proc/switchCamera(var/obj/machinery/camera/C) /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 machine = null
reset_view(null) reset_view(null)
return 0 return 0
if (stat == 2 || !C.status || C.network != network) return 0
// ok, we're alive, camera is good and in our network... // ok, we're alive, camera is good and in our network...
machine = src machine = src
src:current = C src.current = C
reset_view(C) reset_view(C)
return 1 return 1
@@ -429,7 +428,7 @@
set name = "Cancel Camera View" set name = "Cancel Camera View"
reset_view(null) reset_view(null)
machine = null machine = null
src:cameraFollow = null src.cameraFollow = null
//Replaces /mob/living/silicon/ai/verb/change_network() in ai.dm & camera.dm //Replaces /mob/living/silicon/ai/verb/change_network() in ai.dm & camera.dm
//Adds in /mob/living/silicon/ai/proc/ai_network_change() instead //Adds in /mob/living/silicon/ai/proc/ai_network_change() instead
@@ -439,14 +438,14 @@
set name = "Change Camera Network" set name = "Change Camera Network"
reset_view(null) reset_view(null)
machine = null machine = null
src:cameraFollow = null src.cameraFollow = null
var/cameralist[0] var/cameralist[0]
if(usr.stat == 2) if(usr.stat == 2)
usr << "You can't change your camera network because you are dead!" usr << "You can't change your camera network because you are dead!"
return return
for (var/obj/machinery/camera/C in world) for (var/obj/machinery/camera/C in Cameras)
if(!C.status) if(!C.status)
continue continue
if(C.network == "AI Satellite") if(C.network == "AI Satellite")

View File

@@ -42,7 +42,7 @@
var/area/A = get_area(old) var/area/A = get_area(old)
var/list/old_types = dd_text2list("[A.type]", "/") 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(user.network != current.network) continue
if(!current.status) continue // ignore disabled cameras if(!current.status) continue // ignore disabled cameras

View File

@@ -195,7 +195,7 @@
usr << "You can't change your camera network because you are dead!" usr << "You can't change your camera network because you are dead!"
return return
for (var/obj/machinery/camera/C in world) for (var/obj/machinery/camera/C in Cameras)
if(!C.status) if(!C.status)
continue continue
else else

View File

@@ -56,7 +56,7 @@
output += "</div>" output += "</div>"
src << browse(output,"window=playersetup;size=250x240;can_close=0") src << browse(output,"window=playersetup;size=210x240;can_close=0")
return return
proc/Playmusic() proc/Playmusic()

View File

@@ -54,6 +54,10 @@ should be listed in the changelog upon commit tho. Thanks. -->
<li class="imageadd">Added Captain's Backpack and Satchel</li> <li class="imageadd">Added Captain's Backpack and Satchel</li>
<li class="imageadd">Added three new hairstyles by Sly: Gelled, Flat Top, and Pigtails. Hair list has also been sorted by grouping similar styles.</li> <li class="imageadd">Added three new hairstyles by Sly: Gelled, Flat Top, and Pigtails. Hair list has also been sorted by grouping similar styles.</li>
</ul> </ul>
<h3 class="author">Giacom updated:</h3>
<ul class="changes bgimages16">
<li class="tweak">Added a new wire for Cyborgs. See if you can figure out what it does.</li>
</ul>
</div> </div>
<div class="commit sansserif"> <div class="commit sansserif">