ID:264457
 

mob
Move()
if(src.frozen||src.moving||src.npc)
return
if(src.client)
if(src.inshikai||src.inbankai)
if(src.stype == "Rukia")
var/K = new/obj/rukiadust(src.loc)
K:dir = src.dir
if(src.bankai == 1)
if(src.stype == "Fire")
if(src.inshikai == 1)
var/F = new/obj/bountofiretrail(src.loc)
F:dir = src.dir
src.moving = 1
if(usr.race == "Inoue")
for(var/obj/inoueshield/S in world)
if(S.owner == src)
S.density = 0
..()
if(usr.race == "Inoue")
for(var/obj/inoueshield/S in world)
if(S.owner == src)
S.loc=locate(src.x,src.y,src.z)
S.density = 0
step(S,src.dir)
S.density = 1
sleep(src.rundelay)
src.moving = 0


Problem description:I have be getting lag on my Dream Seeker, I tracked the problem to this. Anyone see anything that will cause lag?

I dunno if that would really cause a lot of lag, but you're certainly doing a few things you shouldn't be doing there, using some bad practices and I'd say that code generally isn't made well, neither is the game designed right (not a surprise, since it looks like a ripped source and those are known for their low quality). Fixing everything that's not right there will involve more than just changing that snippet.
Define what precisely is 'lag', what are you experiencing and how have you tracked it down to this Move() override? Maybe the bottleneck is actually something stuck in an infinite loop (or similar) that keeps calling Move(), etc?
In response to Kaioken
Well, I would use Run to test my update, and I would lag on the game. The movement would be slow and the computer would start heating up. I used the the Profile thing in Dream Seeker, and tried to figure out what was causing it. There were over a million calls on the ()Move thing. I'm still not sure if thats it.

In response to Bankai Naruto
Well, seems like what I've said is pretty accurate. The main problem is that Move() is called a lot and too much by some of your code (isn't necessarily in your Move() code itself), most likely in some sort of [infinite] loop.
Note that Move() can of course be called indirectly through other functions as well, including but not limited to step(), walk(), etc.
Probably the whole looping through every object in the world under certain circumstances. If you're trying to make some object that is only dense to some players, and follows a player's movement, you would do something like this:

atom
movable
proc
//analogous to Enter()
StepOn(atom/movable/A)
//always allow an object to step on itself
if(A == src) return 1
//do not allow two dense objects in the same turf
else return !(density & A.density)

turf
Enter(atom/movable/A)
//don't allow dense movables onto dense turfs
if((density | loc.density) & A.density) return 0
else
//check contents of this turf for something else that will block A
for(var/atom/movable/M in src)
if(M != A)
if(!M.StepOn(A))
return 0

return 1

obj/tagalong
var/mob/owner
density = 0
//don't let any mobs besides our owner step on us
StepOn(atom/movable/A)
if(ismob(A) && A != owner)
return 0
else
return ..()

mob
var/list/tagalongs
Move(newloc)
var/direction = get_dir(src, newloc)
.=..()
if(. && tagalongs && direction)
for(var/atom/movable/v in tagalongs)
step(v, direction)

verb/test()
var/obj/tagalong/T = new(get_step(src,NORTH))
T.owner = src
tagalongs = list(T)


Also: do you think you can tell me why the hell you're using - in the same proc - locate(src.x, src.y, src.z) and ALSO just using src.loc? The second one is correct, the first is stupid, and I'm wondering where people are learning it.