ID:2016156
 
(See the best response by Ter13.)
Code:
area/daynight
layer=99
proc/Weather() while(1)
for(var/area/daynight/A) A.icon=pick(null,'Night.dmi') //and so on
sleep(3000)
world/New()
spawn(1) Weather()


Problem description:

If you're familiar with the typical method of a basic weathering system using area's and spamming it over each map instance, then please help me.

I wanted to know if there's some type of trick to keep the lag to a minimum while weathering effects are displaying, like day & night, and sunrise and fog- usually when the area's icons switch from null it provokes an annoying amount of lag but I noticed in some games they run alot smoother.

Any tricks?

Not really a response to what you're asking, but you are aware that all areas of a single type are really one object? If you set an instance of area/daynight/A's icon to 'Night'dmi, all instances of area/daynight/A have that icon. That's essentially how my weather system works, and I've never had any issues with lag or slowness. In my system, I simply have an icon that contains every possible weather, so I just add an overlay to the area. I also have the ability to add overlays with certain weather effects.

An alternative is to use screen objects, based on where the user is.
Best response
Couple of tricks here.

Never loop through world. I'm unsure if there's any optimization for looping through areas, I'm pretty sure there isn't, but I could be wrong.

list/areas = list()

area
New()
areas += src
Del()
areas -= src


Day/night can easily be handled with a global screen object.

var
obj/global_lighting/global_lighting = new() //add this bad boy to the screen when a client connects and you can animate() the object using color matrix to create dynamic day/night.

obj
global_lighting
plane = 1 //appear just above the map plane
screen_loc = "WEST,SOUTH to NORTH,EAST"
mouse_opacity = 0



Setting an /image object's location to an area is also a really great way to go about weather effects. Just make sure you show the image to all players connected to the world and remove it when necessary.

As for stuff like fog, that's usually best handled on the screen similar to the global lighting deal I showed.

Also, check out client.color while you are at it. It'll tint the client's viewport by a specific color or matrix. It's pretty cool.
In response to Ter13
Ter13 wrote:
Never loop through world. I'm unsure if there's any optimization for looping through areas, I'm pretty sure there isn't, but I could be wrong.

Yeah, it's not really optimized, although it was improved in recent releases. Looping through an area still has to check every turf in the world and then, if it matches the area, its contents.

The only optimization made here was that in older versions, looping through area was a nasty affair because each iteration of the loop had to start from scratch. I changed it so the loop would keep track properly.