ID:147606
 
Ok after about 5 minutes lately my game freezes up alot! I have no clue what it is I have changed coding and have not been able to locate the problem can someone help?
You probably have one or more infinite loops that don't sleep() correctly. What infinite loops do you have, and how are they structured?

Also, this would belong better in Code Problems or Newbie Central... I'm sure a moderator will be kind enough to move it. =)
In response to Crispy
I found what it was some Repop() ill post it
world/New()
..()
spawn
while(1)
sleep(300)
for(var/obj in world)
for(var/mob/M in world)
sleep(rand(32000,90000))
Repop()
In response to Darkfirewolf5
I'm very cursious where you got that snippet. I've seen this same atrocious code trip up many other people and I would love to see the source (the code, not the programmer) put out of everyone's misery.

Look carefully at what code is doing before you insert it into your project.


world/New()
When the world is created

..()
Do the default world new() stuff

spawn
start a new program thread

while(1)
loop as long as the program is running

sleep(300)
pause 30 seconds.

So far, so good. This is where the code turns to crap:

for(var/obj in world)
loop through every single thing in the world and store it in a var named obj. Then do nothing with it. This line basically says "create pointless server lag."

Doesn't it produce a warning message when you compile? No matter what others may have told you, warning messages are not ok. When you get a warning message, it means you've done something wrong and it needs fixed.

Sure the game will run, but not properly. It's like driving your car with the brake light on. It runs just fine until you need to execute that one little stopping function. Oops!

If you can't figure out a warning, post it and the relevant code in Code Problems and someone will help.

for(var/mob/M in world)
Now that we're done looping through everything, lets loop though it again and filter for mobs.

sleep(rand(32000,90000))
pause anywhere from 53 minutes to 2.5 hours

Repop()
repop the world

Those for loops don't belong in this snippet. Whoever placed them there did not understand Repop() or even for().
world/New()
..()
spawn()
while(1)
sleep(rand(32000,90000))
world.Repop()
In response to Shadowdarke
Thanks I didnt know how to do a repop() a long time ago so someone gave it to me thanks.!
Issue resolved: not a bug. Closed.