SwapMaps

by Lummox JR
Load, save, and reuse temporary maps for unlimited worlds
ID:91627
 
This library is now available for download through access to digitalBYOND.

Suggestions are especially appreciated.

Version 1.5:
  • Fixed a bug in SwapMaps_CreateFromTemplate()
  • Added SwapMaps_GetSize() to query a map file for size
  • Added chunk load/save capability
Best library I know of for quickly and effectively managing dynamically generated maps.
One thing I've noticed is that it's faster to save or unload swapmaps if you delete the old swapmap file first:

if (fexists("map_[thisSwapmap.GetSwapmapID()].sav"))
fdel("map_[thisSwapmap.GetSwapmapID()].sav") // This is faster than having swapmaps do it.
In tests, it's about four or five times faster, depending on the map size.

I'm thinking the reason for this is probably because Swapmaps is performing some operation on the maps it unloads on if they already exist. If you watch the file while it does that, they deflate slowly before being rebuilt.

(Of course, even a cooler implementation than just flat out deleting the old swapmaps is to back them up first with fcopy() in case your game needs to revert to an earlier version to recover.)
Comments from a month ago? Awesome. I was just coming here to make sure this library was current/still functional. :)
Well... the code still works. Although I think Lummox JR has moved on to other things.
I'm not looking for updates... if it still works, I don't think it needs more than that.
I have trouble using this library, it always tells me it can't create objects from null even though there are no null turfs on the template I'm loading.
In response to Prazon
This means the template you're loading has turf types that no longer exist. There's actually an open bug report in BYOND (id:2521435) for this very behavior.