-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* step 1 * E * Update jamming.dm * t * d * Containerization Stuff * inventory management improvements and signal management imrprovement * it works , it all works * fix this! * e * Update jamming.dmi * D * eeee * it is done * a * Update devices and tools.dm * 1 * e * Update device.dmi * fix + multi Z support yeaah!! * Update code/game/objects/items.dm Co-authored-by: Pink-Chink <[email protected]> * fix descs * t * Update cev_eris.dme * Update cev_eris.dme * d * Update jamming.dm * Revert "Update jamming.dm" This reverts commit 424ae3f. * Revert "d" This reverts commit dcd82b9. * Revert "Update cev_eris.dme" This reverts commit 13dfa02. * Revert "Update cev_eris.dme" This reverts commit 573ba02. * Revert "t" This reverts commit 8a420c6. * Revert "Revert "t"" This reverts commit 9737982. * Revert "Revert "Update cev_eris.dme"" This reverts commit fce0546. * Revert "Revert "Update cev_eris.dme"" This reverts commit b9e26b9. * Revert "Revert "d"" This reverts commit d1f74f0. * Revert "Revert "Update jamming.dm"" This reverts commit 574cea3. * Revert "Update jamming.dm" This reverts commit 424ae3f. * Revert "Revert "Update jamming.dm"" This reverts commit 069f3be. * it works * Functioning prototype for mobs * fix chunk hashing + fix humans not getting registered * Update chunks.dm * how many linter errors can we fit in one line * Update jamming.dm * f * Fix double-chunk additions and stuff not using forcemOve * optimizations * almost done with hearers * better * it all works * remove all debug messages and fix hearers * Update chunks.dm * adjust * fix runtimes at roundstart * fix * fix runtime + more performance imrpovements on visiblem essages * fix the funny * Update chunks.dm * Update chunks.dm * le z suport * z-levels support 2 * Update chunks.dm * Update chunks.dm * Fix cases of null/non-existing mobs being checked. * Fix roaches attacking from inside lockers * Update _inventory.dm * Update _inventory.dm * Update jamming.dm * Update jamming.dm * switch to a define whose FUCKING TARGET WON'T DISSAPEAR MID EXECUTION * zz * Update chunks.dm * fix item bug * Remove debug procs and functions --------- Co-authored-by: Pink-Chink <[email protected]>
- Loading branch information
1 parent
372408b
commit 41ab997
Showing
46 changed files
with
482 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
#define CHUNK_SIZE 8 | ||
//#define CHUNKID(x,y,size) round((((x - x%size) + (y - y%size) * world.maxx) / size ** 2)) | ||
#define CHUNKID(x,y) max(1,round(x/CHUNK_SIZE)+round(y/CHUNK_SIZE)*round(world.maxx / CHUNK_SIZE)) | ||
#define CHUNKSPERLEVEL(x,y) round(world.maxx * world.maxy) / (CHUNK_SIZE ** 2) + round(world.maxx / CHUNK_SIZE) | ||
#define CHUNKCOORDCHECK(x,y) (x > world.maxx || y > world.maxy || x <= 0 || y <= 0) | ||
/// This subsystem is meant for anything that should not be employing byond view() and is generally very constraining to keep track of | ||
/// For now it only has mobs and hearers, but it should also include sanity , signal receivers , and anything that is very frequently | ||
// searched | ||
|
||
/datum/chunk | ||
var/list/mob/mobs = list() | ||
//var/list/sanity_damagers = list() | ||
var/list/obj/hearers = list() | ||
//var/list/signal_receivers = list() | ||
|
||
SUBSYSTEM_DEF(chunks) | ||
name = "Chunks" | ||
init_order = INIT_ORDER_CHUNKS | ||
flags = SS_NO_FIRE | ||
var/list/datum/chunk/chunk_list_by_zlevel | ||
|
||
/datum/controller/subsystem/chunks/Initialize(timeofday) | ||
chunk_list_by_zlevel = new/list(world.maxz) | ||
for(var/i = 1, i <= world.maxz,i++) | ||
chunk_list_by_zlevel[i] = new/list(CHUNKSPERLEVEL(world.maxx, world.maxy)) | ||
for(var/j = 1, j <= CHUNKSPERLEVEL(world.maxx, world.maxy), j++) | ||
chunk_list_by_zlevel[i][j] = new /datum/chunk(src) | ||
RegisterSignal(SSdcs, COMSIG_MOB_INITIALIZED, PROC_REF(onMobNew)) | ||
RegisterSignal(SSdcs, COMSIG_WORLD_MAXZ_INCREMENTING, PROC_REF(beforeLevelIncrement)) | ||
return ..() | ||
|
||
/datum/controller/subsystem/chunks/proc/beforeLevelIncrement(datum/source) | ||
SIGNAL_HANDLER | ||
var/temp_list = new/list(world.maxz + 1) | ||
for(var/i = 1; i <= world.maxz; i++) | ||
temp_list[i] = chunk_list_by_zlevel[i] | ||
|
||
temp_list[world.maxz + 1] = new/list(CHUNKSPERLEVEL(world.maxx, world.maxy)) | ||
for(var/j = 1, j <= CHUNKSPERLEVEL(world.maxx, world.maxy), j++) | ||
temp_list[world.maxz + 1][j] = new /datum/chunk(src) | ||
chunk_list_by_zlevel = temp_list | ||
|
||
|
||
/datum/controller/subsystem/chunks/proc/onMobNew(atom/signalSource, mob/source) | ||
SIGNAL_HANDLER | ||
source.InitiateChunkTracking() | ||
|
||
// Get mobs in range using chunks | ||
/proc/getMobsInRangeChunked(atom/source, range, aliveonly = FALSE, canseeonly = FALSE) | ||
if(!source || !range) | ||
return | ||
var/atom/container = source.getContainingAtom() | ||
var/list/returnValue = list() | ||
if(container.z == 0) | ||
return returnValue | ||
var/coordinates = list(container.x - range - CHUNK_SIZE, container.y - range - CHUNK_SIZE, container.x + range + CHUNK_SIZE, container.y + range + CHUNK_SIZE) | ||
if(coordinates[1] == 0) | ||
coordinates[1] = 1 | ||
if(coordinates[2] == 0) | ||
coordinates[2] = 1 | ||
if(coordinates[3] > world.maxx) | ||
coordinates[3] = world.maxx | ||
if(coordinates[4] > world.maxy) | ||
coordinates[4] = world.maxy | ||
var/datum/chunk/chunkReference | ||
var/turf/containerTurf = get_turf(container) | ||
if(containerTurf == null) | ||
return returnValue | ||
for(var/chunkX = coordinates[1], chunkX <= coordinates[3], chunkX += CHUNK_SIZE) | ||
for(var/chunkY = coordinates[2], chunkY <= coordinates[4], chunkY += CHUNK_SIZE) | ||
chunkReference = SSchunks.chunk_list_by_zlevel[container.z][CHUNKID(chunkX, chunkY)] | ||
for(var/mob/mobToCheck as anything in chunkReference.mobs) | ||
var/turf/mobTurf = get_turf(mobToCheck) | ||
if(!mobTurf) | ||
continue | ||
if(DIST_EUCLIDIAN(containerTurf.x, containerTurf.y, mobTurf.x, mobTurf.y) < range) | ||
if(aliveonly && mobToCheck.stat == DEAD) | ||
continue | ||
if(canseeonly && !can_see(containerTurf, get_turf(mobToCheck), range * 2)) | ||
continue | ||
returnValue += mobToCheck | ||
return returnValue | ||
|
||
/proc/getHearersInRangeChunked(atom/source, range) | ||
if(!source || !range) | ||
return | ||
var/atom/container = source.getContainingAtom(source) | ||
var/list/returnValue = list() | ||
if(container.z == 0) | ||
return returnValue | ||
// IF THE RANGE IS SMALLER THAN CHUNK_SIZE , theres a risk of not checking all relevant chunks (If anyone can figure the true underlying cause to this, then feel free to remove this) | ||
// as it'd basically just improve performance (not like its not improved enough already tho) | ||
var/coordinates = list(container.x - range - CHUNK_SIZE, container.y - range - CHUNK_SIZE, container.x + range + CHUNK_SIZE, container.y + range + CHUNK_SIZE) | ||
if(coordinates[1] == 0) | ||
coordinates[1] = 1 | ||
if(coordinates[2] == 0) | ||
coordinates[2] = 1 | ||
if(coordinates[3] > world.maxx) | ||
coordinates[3] = world.maxx | ||
if(coordinates[4] > world.maxy) | ||
coordinates[4] = world.maxy | ||
var/datum/chunk/chunkReference | ||
var/turf/containerTurf = get_turf(container) | ||
if(containerTurf == null) | ||
return returnValue | ||
for(var/chunkX = coordinates[1], chunkX <= coordinates[3], chunkX += CHUNK_SIZE) | ||
for(var/chunkY = coordinates[2], chunkY <= coordinates[4], chunkY += CHUNK_SIZE) | ||
chunkReference = SSchunks.chunk_list_by_zlevel[container.z][CHUNKID(chunkX, chunkY)] | ||
for(var/obj/hearerToCheck as anything in chunkReference.hearers) | ||
var/turf/hearerTurf = get_turf(hearerToCheck) | ||
if(!hearerTurf) | ||
continue | ||
if(DIST_EUCLIDIAN(containerTurf.x, containerTurf.y, hearerTurf.x, hearerTurf.y) < range) | ||
if(!can_see(source, get_turf(hearerToCheck), range * 2)) | ||
continue | ||
returnValue += hearerToCheck | ||
return returnValue | ||
|
||
/// Mob tracking and handling | ||
/mob/proc/chunkOnMove(atom/source, atom/oldLocation, atom/newLocation) | ||
SIGNAL_HANDLER | ||
var/datum/chunk/chunk_reference | ||
if(oldLocation?.z && newLocation?.z) | ||
if(CHUNKID(oldLocation.x, oldLocation.y) == CHUNKID(newLocation.x, newLocation.y) && oldLocation.z == newLocation.z) | ||
return | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[oldLocation.z][CHUNKID(oldLocation.x, oldLocation.y)] | ||
chunk_reference.mobs -= src | ||
//if(ishuman(src)) | ||
// message_admins("[src] removed from chunkID : [CHUNKID(oldLocation.x, oldLocation.y)]") | ||
if(CHUNKCOORDCHECK(newLocation.x, newLocation.y)) | ||
return | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[newLocation.z][CHUNKID(newLocation.x, newLocation.y)] | ||
chunk_reference.mobs += src | ||
//if(ishuman(src)) | ||
// message_admins("[src] added to chunkID : [CHUNKID(newLocation.x, newLocation.y)]") | ||
else if(newLocation?.z) | ||
if(CHUNKCOORDCHECK(newLocation.x, newLocation.y)) | ||
return | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[newLocation.z][CHUNKID(newLocation.x, newLocation.y)] | ||
chunk_reference.mobs += src | ||
//if(ishuman(src)) | ||
// message_admins("[src] added to chunkID : [CHUNKID(newLocation.x, newLocation.y)]") | ||
else if(oldLocation?.z) | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[oldLocation.z][CHUNKID(oldLocation.x, oldLocation.y)] | ||
chunk_reference.mobs -= src | ||
//if(ishuman(src)) | ||
// message_admins("[src] removed from chunkID : [CHUNKID(oldLocation.x, oldLocation.y)]") | ||
|
||
/mob/proc/chunkOnContainerization(atom/source, atom/newContainer , atom/oldContainer) | ||
SIGNAL_HANDLER | ||
//message_admins("[src] switched container from [oldContainer] to [newContainer]") | ||
UnregisterSignal(oldContainer , COMSIG_MOVABLE_MOVED) | ||
RegisterSignal(newContainer, COMSIG_MOVABLE_MOVED, PROC_REF(chunkOnMove)) | ||
|
||
|
||
/mob/proc/chunkClearSelf(atom/source) | ||
SIGNAL_HANDLER | ||
var/atom/container = getContainingAtom() | ||
// in this case we never registered | ||
if(container.z != 0) | ||
var/datum/chunk/chunk_reference = SSchunks.chunk_list_by_zlevel[container.z][CHUNKID(container.x, container.y)] | ||
chunk_reference.mobs -= src | ||
|
||
/// Hearer tracking and handling | ||
/obj/proc/chunkHearerOnMove(atom/source, atom/oldLocation , atom/newLocation) | ||
SIGNAL_HANDLER | ||
var/datum/chunk/chunk_reference | ||
if(oldLocation?.z && newLocation?.z) | ||
if(CHUNKID(oldLocation.x, oldLocation.y) == CHUNKID(newLocation.x, newLocation.y) && oldLocation.z == newLocation.z) | ||
return | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[oldLocation.z][CHUNKID(oldLocation.x, oldLocation.y)] | ||
chunk_reference.hearers -= src | ||
//if(ishuman(src)) | ||
// message_admins("[src] removed from chunkID : [CHUNKID(oldLocation.x, oldLocation.y)]") | ||
if(CHUNKCOORDCHECK(newLocation.x, newLocation.y)) | ||
return | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[newLocation.z][CHUNKID(newLocation.x, newLocation.y)] | ||
chunk_reference.hearers += src | ||
//if(ishuman(src)) | ||
// message_admins("[src] added to chunkID : [CHUNKID(newLocation.x, newLocation.y)]") | ||
else if(newLocation?.z) | ||
if(CHUNKCOORDCHECK(newLocation.x, newLocation.y)) | ||
return | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[newLocation.z][CHUNKID(newLocation.x, newLocation.y)] | ||
chunk_reference.hearers += src | ||
//if(ishuman(src)) | ||
// message_admins("[src] added to chunkID : [CHUNKID(newLocation.x, newLocation.y)]") | ||
else if(oldLocation?.z) | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[oldLocation.z][CHUNKID(oldLocation.x, oldLocation.y)] | ||
chunk_reference.hearers -= src | ||
//if(ishuman(src)) | ||
// message_admins("[src] removed from chunkID : [CHUNKID(oldLocation.x, oldLocation.y)]") | ||
/* | ||
var/datum/chunk/chunk_reference | ||
if(oldLocation && oldLocation.z != 0) | ||
if(newLocation) | ||
if(CHUNKID(oldLocation.x, oldLocation.y) == CHUNKID(newLocation.x, newLocation.y)) | ||
return | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[oldLocation.z][CHUNKID(oldLocation.x, oldLocation.y)] | ||
chunk_reference.hearers -= src | ||
//if(ishuman(src)) | ||
// message_admins("[src] removed from chunkID : [CHUNKID(oldLocation.x, oldLocation.y)]") | ||
// The new location has invalid coordinates , so lets get rid of them from the old chunk and not update to another one | ||
if(newLocation && newLocation.z != 0) | ||
if(CHUNKCOORDCHECK(newLocation.x, newLocation.y)) | ||
return | ||
chunk_reference = SSchunks.chunk_list_by_zlevel[newLocation.z][CHUNKID(newLocation.x, newLocation.y)] | ||
chunk_reference.hearers += src | ||
//if(ishuman(src)) | ||
// message_admins("[src] added to chunkID : [CHUNKID(newLocation.x, newLocation.y)]") | ||
*/ | ||
|
||
/obj/proc/chunkHearerOnContainerization(atom/source, atom/newContainer, atom/oldContainer) | ||
SIGNAL_HANDLER | ||
//message_admins("[src] switched container from [oldContainer] to [newContainer]") | ||
UnregisterSignal(oldContainer , COMSIG_MOVABLE_MOVED) | ||
RegisterSignal(newContainer, COMSIG_MOVABLE_MOVED, PROC_REF(chunkHearerOnMove)) | ||
|
||
/obj/proc/chunkHearerClearSelf(datum/source) | ||
var/atom/container = getContainingAtom() | ||
UnregisterSignal(container, COMSIG_MOVABLE_MOVED) | ||
UnregisterSignal(src, list(COMSIG_ATOM_CONTAINERED, COMSIG_PARENT_QDELETING)) | ||
// in this case we never registered | ||
if(container.z != 0) | ||
var/datum/chunk/chunk_reference = SSchunks.chunk_list_by_zlevel[container.z][CHUNKID(container.x, container.y)] | ||
chunk_reference.hearers -= src | ||
SIGNAL_HANDLER | ||
|
||
|
||
// This is done by the mob itself because keeping track of them with reference solving is trash and unefficient | ||
// Especially resolving references between container > contained mob to update X mob's chunk | ||
// TGMC Minimaps are a good example (old ones they fixed their stuff) | ||
/mob/proc/InitiateChunkTracking() | ||
SIGNAL_HANDLER | ||
// No to this!! | ||
if(isnewplayer(src)) | ||
return | ||
var/atom/highestContainer = getContainingAtom() | ||
RegisterSignal(highestContainer, COMSIG_MOVABLE_MOVED, PROC_REF(chunkOnMove)) | ||
RegisterSignal(src, COMSIG_ATOM_CONTAINERED, PROC_REF(chunkOnContainerization)) | ||
RegisterSignal(src, COMSIG_PARENT_QDELETING, PROC_REF(chunkClearSelf)) | ||
if(highestContainer.z != 0) | ||
var/datum/chunk/chunk_reference = SSchunks.chunk_list_by_zlevel[highestContainer.z][CHUNKID(highestContainer.x, highestContainer.y)] | ||
chunk_reference.mobs += src | ||
|
||
/obj/proc/InitiateHearerTracking() | ||
var/atom/highestContainer = getContainingAtom() | ||
RegisterSignal(highestContainer, COMSIG_MOVABLE_MOVED, PROC_REF(chunkHearerOnMove)) | ||
RegisterSignal(src, COMSIG_ATOM_CONTAINERED, PROC_REF(chunkHearerOnContainerization)) | ||
RegisterSignal(src, COMSIG_PARENT_QDELETING, PROC_REF(chunkHearerClearSelf)) | ||
if(highestContainer.z != 0) | ||
var/datum/chunk/chunk_reference = SSchunks.chunk_list_by_zlevel[highestContainer.z][CHUNKID(highestContainer.x, highestContainer.y)] | ||
chunk_reference.hearers += src | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.