diff --git a/code/game/objects/items/devices/multitool.dm b/code/game/objects/items/devices/multitool.dm index a059c062845..e11cebdf510 100644 --- a/code/game/objects/items/devices/multitool.dm +++ b/code/game/objects/items/devices/multitool.dm @@ -129,18 +129,18 @@ detect_state = PROXIMITY_ON_SCREEN break - if(!detect_state && GLOB.cameranet.chunkGenerated(our_turf.x, our_turf.y, our_turf.z)) - var/datum/camerachunk/chunk = GLOB.cameranet.getCameraChunk(our_turf.x, our_turf.y, our_turf.z) - if(chunk) - if(chunk.seenby.len) - for(var/mob/camera/aiEye/A in chunk.seenby) - var/turf/detect_turf = get_turf(A) - if(get_dist(our_turf, detect_turf) < rangealert) - detect_state = PROXIMITY_ON_SCREEN - break - if(get_dist(our_turf, detect_turf) < rangewarning) - detect_state = PROXIMITY_NEAR - break + if(detect_state) + return + var/datum/camerachunk/chunk = GLOB.cameranet.chunkGenerated(our_turf.x, our_turf.y, our_turf.z) + if(chunk && chunk.seenby.len) + for(var/mob/camera/aiEye/A in chunk.seenby) + var/turf/detect_turf = get_turf(A) + if(get_dist(our_turf, detect_turf) < rangealert) + detect_state = PROXIMITY_ON_SCREEN + break + if(get_dist(our_turf, detect_turf) < rangewarning) + detect_state = PROXIMITY_NEAR + break /obj/item/multitool/cyborg name = "multitool" diff --git a/code/modules/mob/living/silicon/ai/freelook/cameranet.dm b/code/modules/mob/living/silicon/ai/freelook/cameranet.dm index 5cc08ff1e0d..ed3742e1409 100644 --- a/code/modules/mob/living/silicon/ai/freelook/cameranet.dm +++ b/code/modules/mob/living/silicon/ai/freelook/cameranet.dm @@ -22,8 +22,7 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new) /datum/cameranet/proc/chunkGenerated(x, y, z) x &= ~(CHUNK_SIZE - 1) y &= ~(CHUNK_SIZE - 1) - var/key = "[x],[y],[z]" - return (chunks[key]) + return chunks["[x],[y],[z]"] // Returns the chunk in the x, y, z. // If there is no chunk, it creates a new chunk and returns that. @@ -31,10 +30,9 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new) x &= ~(CHUNK_SIZE - 1) y &= ~(CHUNK_SIZE - 1) var/key = "[x],[y],[z]" - if(!chunks[key]) - chunks[key] = new /datum/camerachunk(null, x, y, z) - - return chunks[key] + . = chunks[key] + if(!.) + chunks[key] = . = new /datum/camerachunk(x, y, z) // Updates what the aiEye can see. It is recommended you use this when the aiEye moves or it's location is set. @@ -53,7 +51,6 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new) var/mob/camera/aiEye/eye = V if(C) chunks_pre_seen |= eye.visibleCameraChunks - // 0xf = 15 var/static_range = eye.static_visibility_range var/x1 = max(0, eye.x - static_range) & ~(CHUNK_SIZE - 1) var/y1 = max(0, eye.y - static_range) & ~(CHUNK_SIZE - 1) @@ -105,10 +102,9 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new) majorChunkChange(A, 2) /datum/cameranet/proc/updateChunk(x, y, z) - // 0xf = 15 - if(!chunkGenerated(x, y, z)) + var/datum/camerachunk/chunk = chunkGenerated(x, y, z) + if (!chunk) return - var/datum/camerachunk/chunk = getCameraChunk(x, y, z) chunk.hasChanged() // Removes a camera from a chunk. @@ -135,7 +131,6 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new) // If you want to update the chunks around an object, without adding/removing a camera, use choice 2. /datum/cameranet/proc/majorChunkChange(atom/c, choice) - // 0xf = 15 if(!c) return @@ -147,8 +142,8 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new) var/y2 = min(world.maxy, T.y + (CHUNK_SIZE / 2)) & ~(CHUNK_SIZE - 1) for(var/x = x1; x <= x2; x += CHUNK_SIZE) for(var/y = y1; y <= y2; y += CHUNK_SIZE) - if(chunkGenerated(x, y, T.z)) - var/datum/camerachunk/chunk = getCameraChunk(x, y, T.z) + var/datum/camerachunk/chunk = chunkGenerated(x, y, T.z) + if(chunk) if(choice == 0) // Remove the camera. chunk.cameras -= c @@ -160,14 +155,12 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new) // Will check if a mob is on a viewable turf. Returns 1 if it is, otherwise returns 0. /datum/cameranet/proc/checkCameraVis(mob/living/target) - - // 0xf = 15 var/turf/position = get_turf(target) return checkTurfVis(position) /datum/cameranet/proc/checkTurfVis(turf/position) - var/datum/camerachunk/chunk = getCameraChunk(position.x, position.y, position.z) + var/datum/camerachunk/chunk = chunkGenerated(position.x, position.y, position.z) if(chunk) if(chunk.changed) chunk.hasChanged(1) // Update now, no matter if it's visible or not. diff --git a/code/modules/mob/living/silicon/ai/freelook/chunk.dm b/code/modules/mob/living/silicon/ai/freelook/chunk.dm index e03bba3067b..178883fbe11 100644 --- a/code/modules/mob/living/silicon/ai/freelook/chunk.dm +++ b/code/modules/mob/living/silicon/ai/freelook/chunk.dm @@ -126,9 +126,7 @@ // Create a new camera chunk, since the chunks are made as they are needed. -/datum/camerachunk/New(loc, x, y, z) - - // 0xf = 15 +/datum/camerachunk/New(x, y, z) x &= ~(CHUNK_SIZE - 1) y &= ~(CHUNK_SIZE - 1)