ID:2169715
 
(See the best response by Nadrew.)
Movementstuff is getting a ridiculous amount of calls even when there are no players or mobs calling movement loop. Movement loop has around 1800 calls and movementstuff has around 200k. How is this possible? How is movementstuff being called without movementloop being called is this a bug or something? This is also happening with another loop for stat regeneration and a whole bunch of other loops. Please help!
mob/proc/
MovementLoop()
set waitfor = 0
if(Moving)return;Moving=1
var/FirstStep=1

while(MN || ME || MW || MS || QueN || QueS || QueE || QueW)

if(FirstStep) {sleep(1);FirstStep=0}
sleep(GetMovementSpeed())
Movement_Stuff()
Moving=0
mob/proc/
Movement_Stuff()
if(MN || QueN)
if(ME || QueE) if(!step(src,NORTHEAST) && !step(src,NORTH)) step(src,EAST)
else if(MW || QueW) if(!step(src,NORTHWEST) && !step(src,NORTH)) step(src,WEST)
else step(src,NORTH)
else if(MS || QueS)
if(ME || QueE) if(!step(src,SOUTHEAST) && !step(src,SOUTH)) step(src,EAST)
else if(MW || QueW) if(!step(src,SOUTHWEST) && !step(src,SOUTH)) step(src,WEST)
else step(src,SOUTH)
else if(ME || QueE) step(src,EAST)
else if(MW || QueW) step(src,WEST)
QueN=0;QueS=0;QueE=0;QueW=0
You're certain you're not calling MovementLoop ANYWHERE?
In response to Nadrew
I'm certain and even so the number of calls for MovementLoop remains the same while Movement_Stuff keeps going up.
You probably don't need to do it in a second proc anyways (that's adding overhead needlessly), but you're definitely calling it somewhere, somehow. I'd search included files for it and usages of call() as well.
In response to Nadrew
Lol literally, Movement_Stuff is only called in the movement loop. I should also mention this only happens when the servers been up for a while but yea I guess this is a bug. This happens with other infinite loops like stat regen etc. Those loops keeping going even if the player logged out.
I doubt it's a bug, it's more than likely something in your code causing the problem. I also wasn't talking about Movement_Stuff(), I was talking about MovementLoop(). You might have things being called where they shouldn't be, or even references to mobs hanging around that you don't realize.

There's quite a few things it could be, and without knowing more about what you're doing there's no way to really say exactly what.
In response to Nadrew
But MovementLoop isn't even getting called. The # of calls for MovementLoop on the profiler stays the same while Movement_Stuff goes up every second. Anyway I'll just keep "troubleshooting" I guess.

This is called at login but even when a mob logs off it's still getting called. Another example.
mob/proc/get_rekt()
if(src&&client&&pk)
var/swag=client.inactivity/10
if(curstamina<=0&&!ko&&swag<=60)src:KO()

spawn(20)get_rekt()
Best response
Well, for one, you should be doing that as a loop. For two, there's nothing that prevents it from being called if there's nothing to call it from, you're not blocking the call with your if() because the spawn() stuff is outside of it.

You're also not setting your infinite loops up properly, you'd want something like "while(src)" which will terminate when the player is deleted.

You should also be using a bitflag system instead of individual variables for each movement direction.