Adds caching to dummy objects, seems to work great.

This commit is contained in:
SkyMarshal
2012-07-26 17:14:31 -07:00
parent 54ce48fb9d
commit 62dcb7be1b
4 changed files with 43 additions and 30 deletions
+18 -4
View File
@@ -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)
+16 -7
View File
@@ -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