From 6e29c4464f4614b329eceaee9b72bdc4831dda11 Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Thu, 21 May 2015 02:21:25 -0700 Subject: [PATCH 1/4] Workaround for Out of resources byond bug --- code/__HELPERS/unsorted.dm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 49bbcb8d075..9426ec7edcf 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1074,7 +1074,13 @@ Turf and target are seperate in case you want to teleport some distance from a t //Gets the turf this atom inhabits /proc/get_turf(atom/movable/AM) if(istype(AM)) - return locate(/turf) in AM.locs + var/list/atom/moveable/checkedlocs = list() //prevent recursion from badmins being dumbasses + while (!isturf(AM)) + if (AM in checkedlocs || !AM.loc) + return + checkedlocs += AM + AM = AM.loc + return AM else if(isturf(AM)) return AM From b6451cce1bc421154e929c867b592866ede5d18e Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Thu, 21 May 2015 02:58:58 -0700 Subject: [PATCH 2/4] fixes compile error (hopefully) --- code/__HELPERS/unsorted.dm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 9426ec7edcf..ede4ecea97a 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1074,13 +1074,14 @@ Turf and target are seperate in case you want to teleport some distance from a t //Gets the turf this atom inhabits /proc/get_turf(atom/movable/AM) if(istype(AM)) - var/list/atom/moveable/checkedlocs = list() //prevent recursion from badmins being dumbasses - while (!isturf(AM)) - if (AM in checkedlocs || !AM.loc) + var/list/atom/checkedatoms = list() //prevent recursion from badmins being dumbasses + var/atom/A = AM + while (!isturf(A)) + if (A in checkedatoms || !A.loc) return - checkedlocs += AM - AM = AM.loc - return AM + checkedatoms += A + A = A.loc + return A else if(isturf(AM)) return AM From 8ac7f47caaf8cfdaff8053503c667ce37c3c12d0 Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Thu, 21 May 2015 23:39:04 -0700 Subject: [PATCH 3/4] Minor workaround for the runtime in get_turf on world new. Adding this second check for turf_candidate being null FOR SOME FUCKING REASON is needed. --- code/__HELPERS/unsorted.dm | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index ede4ecea97a..1e53709c227 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1072,18 +1072,30 @@ Turf and target are seperate in case you want to teleport some distance from a t //Gets the turf this atom inhabits -/proc/get_turf(atom/movable/AM) - if(istype(AM)) - var/list/atom/checkedatoms = list() //prevent recursion from badmins being dumbasses - var/atom/A = AM - while (!isturf(A)) - if (A in checkedatoms || !A.loc) - return - checkedatoms += A - A = A.loc + +/proc/get_turf(atom/A) + if (!istype(A)) + return + if (isturf(A)) return A - else if(isturf(AM)) - return AM + + var/list/atom/checked_turf_candidates = list() //prevent recursion from badmins being dumbasses + var/atom/turf_candidate = A.loc + + while (!isturf(turf_candidate)) + if (!turf_candidate || turf_candidate in checked_turf_candidates) + return + checked_turf_candidates += turf_candidate + + //SO I BET YOU MIGHT BE WONDERING WHY I'M CHECKING THIS AGAIN. + //I'LL FUCKING TELL YOU WAY, ITS BECAUSE FOR SOME GOD DAMN REASON, WHEN THIS IS CALLED + //IN AN OBJECT'S NEW() PROC, THE FIRST CHECK WILL FUCKING PASS, BUT FUCKING RUNTIME HERE + //BITCHING ABOUT HOW IT CAN'T READ NULL.LOC, SO FUCK IT, WE CHECK THIS TWICE. + if (!turf_candidate) + return + turf_candidate = turf_candidate.loc + return turf_candidate + //Gets the turf this atom's *ICON* appears to inhabit //Uses half the width/height respectively to work out From addb63adad72b0951a7c0c926abefd72f3f7f91b Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Thu, 21 May 2015 23:41:47 -0700 Subject: [PATCH 4/4] Utterly guts the use of .locs from the game. They This means that multi-tile things may not handle correctly, but the only thing that used it was atmos for double wide doors, and they are used in one location that is unlikely to have atmos changes see: http://www.byond.com/forum/?post=1852790 for justifcation. (tl;dr: accessing .locs causes memory leaks) --- code/LINDA/LINDA_system.dm | 4 ++-- code/_onclick/adjacent.dm | 8 +------- code/game/gamemodes/traitor/traitor.dm | 4 ++-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/code/LINDA/LINDA_system.dm b/code/LINDA/LINDA_system.dm index 0bf0a5ff5b3..2f8b6ac7eb8 100644 --- a/code/LINDA/LINDA_system.dm +++ b/code/LINDA/LINDA_system.dm @@ -82,8 +82,8 @@ turf/CanPass(atom/movable/mover, turf/target, height=1.5) /atom/movable/proc/air_update_turf(var/command = 0) if(!istype(loc,/turf) && command) return - for(var/turf/T in locs) // used by double wide doors and other nonexistant multitile structures - T.air_update_turf(command) + var/turf/T = loc + T.air_update_turf(command) /turf/proc/air_update_turf(var/command = 0) if(command) diff --git a/code/_onclick/adjacent.dm b/code/_onclick/adjacent.dm index 2ada5233a6f..20aeb967d29 100644 --- a/code/_onclick/adjacent.dm +++ b/code/_onclick/adjacent.dm @@ -62,17 +62,11 @@ /* Adjacency (to anything else): * Must be on a turf - * In the case of a multiple-tile object, all valid locations are checked for adjacency. - - Note: Multiple-tile objects are created when the bound_width and bound_height are creater than the tile size. - This is not used in stock /tg/station currently. */ /atom/movable/Adjacent(var/atom/neighbor) if(neighbor == loc) return 1 if(!isturf(loc)) return 0 - for(var/turf/T in locs) - if(isnull(T)) continue - if(T.Adjacent(neighbor,src)) return 1 + if(loc.Adjacent(neighbor,src)) return 1 return 0 // This is necessary for storage items not on your person. diff --git a/code/game/gamemodes/traitor/traitor.dm b/code/game/gamemodes/traitor/traitor.dm index 5a4040d9242..6c7b57edd47 100644 --- a/code/game/gamemodes/traitor/traitor.dm +++ b/code/game/gamemodes/traitor/traitor.dm @@ -348,9 +348,9 @@ var/obj/item/weapon/folder/syndicate/folder if(owner == exchange_red) - folder = new/obj/item/weapon/folder/syndicate/red(mob.locs) + folder = new/obj/item/weapon/folder/syndicate/red(mob.loc) else - folder = new/obj/item/weapon/folder/syndicate/blue(mob.locs) + folder = new/obj/item/weapon/folder/syndicate/blue(mob.loc) var/list/slots = list ( "backpack" = slot_in_backpack,