ID:195141
 
//Title: Dynamically-Generated Icon Pre-Caching
//Credit to: Jtgibson
//Contributed by: Jtgibson


/*
Dynamically-generated icons are one of BYOND's best new features,
but they are still considerably weaker than having direct access
to BYOND's screen buffer.

Perhaps the worst feature is that icons that are generated at
run time are transmitted to the clients only whenever they are
needed. Usually, this means that an icon will be transmitted
the first time the client sees that icon. In any game where time
is an issue, this is a very bad thing, because the client's
connection will temporarily burp while the server transmits the
new icon to the client. As soon as the new icon has been received,
the object suddenly appears.

Enter this snippet. This snippet allows you to transmit a resource
to the user's resource file even before encountering it, so it will
be available before the client needs it! This means no slowdown
when encountering an object with this "new" icon, which in turn
means no angry gamers complaining of lag.


Thanks to Lummox JR, and thanks in turn to Dantom themselves, who
revealed this function.
*/



mob/proc/cache_icon(icon)
if(src.client)
src.client.Export("##action=load_rsc",icon)