Sphereserver / Source-X

Ultima Online server emulator
Apache License 2.0
58 stars 47 forks source link

Feature Request: Load Virtual Map dinamically #1129

Open DavideRei opened 1 year ago

DavideRei commented 1 year ago

Right now if you want to use Virtual maps (for example for dungeon instances) you have to declare the maps in sphere.ini and Sphere loads all the maps at launch. This is very resource consuming, a lot of RAM is needed to keep up a lot of virtual maps. It would be better to load maps dinamically on request, so you can load a map when you need to use it and then you can free the memory when you not need the map anymore.

xwerswoodx commented 1 year ago

Uhm, if these virtual maps be empty (I meant no item, npcs in it except statics) this could be possible, but if not, when npcs try to move, they probably keep giving an error because haven't find any path to move. Also it seems a bit cheesy when you think about save system. Probably can add some functions to check if their map instance is loaded but seems like a huge work to fix all possible scenarios about it. Also npcs can drop down the maps when the map unloaded because there will be no Z to keep them up. It's only my guess but probably nolok can have better idea about it.

DavideRei commented 1 year ago

I explain my current dungeon instance system.

On sphere.ini i load 50 copy of map 0 Map6=7168,4096,-1,0,0 Map7=7168,4096,-1,0,0 ... Map55=7168,4096,-1,0,0

On scripts i have declared all 50 virtual maps world like this

[AREADEF a_world_map_6] EVENTS=r_default,r_default_rock,r_default_water,r_default_tree,r_default_grass NAME=World GROUP=ALLMAP P=1323,1624,55,6 RECT=0,0,7168,4096,6

When a player enter a dungeon on map0:

When the dungeon is over (and players are out of it) i delete all chars and items from map n. I delete also the areadef file created for map n.

Now it would be nice to if i can load dinamically the virtual map when a player enter a dungeon on map0, create a file with the virtual map world areadef, delete the file and unload the virtual map when the dungeon is over. Like this i could load one virtual map at a time, and not 50. Right now is not possible to do that because sphere loads the maps only when you start it.

cbnolok commented 1 year ago

It's a reasonable request, but it will require a non-trivial rework. I'll put that on X2 milestone