ID:283941
 
(See the best response by DarkCampainger.)
My PVP game works so that when 1 team wins, the round ends and everything is restored to default by world reboot. I want to be able to do that without using reboot so that resources dont need to be read again, and I found a way of doing this by having a proc check in all the objects and mobs that checks for a round end every 10 seconds. What I'm curious about is whether that itself will cause lag, due to all character selection icons and the world doing a proc check using spawn() and goto. would all those checks melded together cause lag and if so how much contribution?
Best response
A) Don't use goto when a while() or for() loop will do the trick

B) There are two types of lag: that caused by network latency, and that caused by intensive server CPU usage. The latter occurs when your game is trying to do so much in a short time frame, that it can't get everything done and the game "lurches" for clients. Depending on how many objects you have running their own loop and the power of the machine hosting the game, you may or may not experience "lag"

C) Don't "poll" for values in a loop to see if you should do something, instead just do it when the event occurs

D) Typically the most robust method for reloading the world is to just unload and reload the map, by using something like Map Instancing or SwapMaps.
Answer to C:

I would just do it when the event occurs. Problem is how would I call things such as turfs when using a world proc?
Loop through 'em with a for() loop.

for(var/turf/T in world)
world<<"turf '[T.name]' is located at [T.x],[T.y],[T.z]"
sleep(1)


You can also use block() to loop through a specific area.