From 62dcb7be1bf481322f986d4a4569f07a75bdaa1b Mon Sep 17 00:00:00 2001 From: SkyMarshal Date: Thu, 26 Jul 2012 17:14:31 -0700 Subject: [PATCH] Adds caching to dummy objects, seems to work great. --- code/game/atom_procs.dm | 22 ++++++++++++++---- code/game/throwing.dm | 23 +++++++++++++------ .../mob/living/carbon/metroid/metroid.dm | 12 +++++++--- code/modules/recycling/disposal.dm | 16 ------------- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/code/game/atom_procs.dm b/code/game/atom_procs.dm index 5215a6b3321..dc59b9962fe 100644 --- a/code/game/atom_procs.dm +++ b/code/game/atom_procs.dm @@ -1005,9 +1005,20 @@ var/using_new_click_proc = 0 //TODO ERRORAGE (This is temporary, while the DblCl usr.next_move = world.time + 6 return +//////////////////////////////////////// +///IMPORTANT: CACHE FOR DUMMY OBJECTS/// +//Used to cut down on stupid deletions// +//////////////////////////////////////// +var/list/DummyCache = list() /proc/CanReachThrough(turf/srcturf, turf/targetturf, atom/target) - var/obj/item/weapon/dummy/D = new /obj/item/weapon/dummy( srcturf ) + + var/obj/item/weapon/dummy/D = locate() in DummyCache + if(!D) + D = new /obj/item/weapon/dummy( srcturf ) + else + DummyCache.Remove(D) + D.loc = srcturf if(targetturf.density && targetturf != get_turf(target)) return 0 @@ -1016,17 +1027,20 @@ var/using_new_click_proc = 0 //TODO ERRORAGE (This is temporary, while the DblCl for(var/obj/border_obstacle in srcturf) if(border_obstacle.flags & ON_BORDER) if(!border_obstacle.CheckExit(D, targetturf)) - del D + D.loc = null + DummyCache.Add(D) return 0 //Next, check objects to block entry that are on the border for(var/obj/border_obstacle in targetturf) if((border_obstacle.flags & ON_BORDER) && (target != border_obstacle)) if(!border_obstacle.CanPass(D, srcturf, 1, 0)) - del D + D.loc = null + DummyCache.Add(D) return 0 - del D + D.loc = null + DummyCache.Add(D) return 1 /atom/proc/CtrlClick(var/mob/M as mob) diff --git a/code/game/throwing.dm b/code/game/throwing.dm index 8340f98d753..8dec7f7a55c 100644 --- a/code/game/throwing.dm +++ b/code/game/throwing.dm @@ -99,12 +99,11 @@ if(istype(A,/mob/living)) if(A:lying) continue src.throw_impact(A) - if(src.throwing == 1) - src.throwing = 0 + throwing = 0 if(isobj(A)) if(A.density && !A.CanPass(src,target)) src.throw_impact(A) - src.throwing = 0 + throwing = 0 /atom/proc/throw_impact(atom/hit_atom) if(istype(hit_atom,/mob/living)) @@ -133,10 +132,20 @@ message_admins("ATTACK: [hit_atom] ([M.ckey]) was hit by [src] thrown by ([src.fingerprintslast])") else if(isobj(hit_atom)) - var/obj/O = hit_atom - if(!O.anchored) - step(O, src.dir) - O.hitby(src) + if (istype(hit_atom,/obj/machinery/disposal) && istype(src, /obj/item)) + var/obj/item/I = src + if(prob(75)) + I.loc = hit_atom + for(var/mob/M in viewers(hit_atom)) + M.show_message("\The [I] lands in \the [hit_atom].", 3) + else + for(var/mob/M in viewers(hit_atom)) + M.show_message("\The [I] bounces off of \the [hit_atom]'s rim!", 3) + else + var/obj/O = hit_atom + if(!O.anchored) + step(O, src.dir) + O.hitby(src) else if(isturf(hit_atom)) var/turf/T = hit_atom diff --git a/code/modules/mob/living/carbon/metroid/metroid.dm b/code/modules/mob/living/carbon/metroid/metroid.dm index a74a7c6a6e2..84a3a3c2a32 100644 --- a/code/modules/mob/living/carbon/metroid/metroid.dm +++ b/code/modules/mob/living/carbon/metroid/metroid.dm @@ -700,10 +700,15 @@ mob/living/carbon/metroid/var/temperature_resistance = T0C+75 health = 150 stat = 0 - /mob/living/carbon/metroid/proc/get_obstacle_ok(atom/A) var/direct = get_dir(src, A) - var/obj/item/weapon/dummy/D = new /obj/item/weapon/dummy( src.loc ) + var/obj/item/weapon/dummy/D = locate() in DummyCache //See atom_procs.dm + if(!D) + D = new /obj/item/weapon/dummy( src.loc ) + else + D.loc = src.loc + DummyCache.Remove(D) + var/ok = 0 if ( (direct - 1) & direct) @@ -781,7 +786,8 @@ mob/living/carbon/metroid/var/temperature_resistance = T0C+75 if(!border_obstacle.CanPass(D, D.loc, 1, 0)) ok = 0 - del(D) + D.loc = null + DummyCache.Add(D) if (!( ok )) return 0 diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index 3ded32fecf0..13b2a67967e 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -502,22 +502,6 @@ H.vent_gas(loc) del(H) - CanPass(atom/movable/mover, turf/target, height=0, air_group=0) - if (istype(mover,/obj/item) && mover.throwing) - var/obj/item/I = mover - if(istype(I, /obj/item/weapon/dummy) || istype(I, /obj/item/projectile)) - return - if(prob(75)) - I.loc = src - for(var/mob/M in viewers(src)) - M.show_message("\the [I] lands in \the [src].", 3) - else - for(var/mob/M in viewers(src)) - M.show_message("\the [I] bounces off of \the [src]'s rim!", 3) - return 0 - else - return ..() - // virtual disposal object // travels through pipes in lieu of actual items // contents will be items flushed by the disposal