• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Loading map by sectors

Dercas

Well-Known Member
Joined
Nov 15, 2008
Messages
241
Solutions
1
Reaction score
97
Hello,

As in the thread's title, has anyone seen tfs 1.x + with loading map by sectors? or maybe someone here managed to add loading map by sectors ?

Apart from PyOT I couldn't find anything at all (and PyOT isn't really helpful).


Thank you in advance,
 
Damn, there was this one server, pretty recent, that has something like this, basically it changed parts of the map, live in front of your eyes, I believe they changed seasons like that, looked pretty cool albeit a bit weird. You see the grass turn into snow etc.

Do you mean something like this?
 
Thank you both for your response.

Damn, there was this one server, pretty recent, that has something like this, basically it changed parts of the map, live in front of your eyes, I believe they changed seasons like that, looked pretty cool albeit a bit weird. You see the grass turn into snow etc.

Do you mean something like this?
What I meant is that we got as a standard one .otbm file which is loaded at the server startup. If i have a huge map - as I do -(20k x20k tiles, 2GB without details, for example) it require crazy amount of RAM to run it.
If we cut this huge map into the sectors (so, instead having 20k x 20k map we've got 175 sector files 128x128 tiles or 350 sectors 64x64 tiles) that are loaded whenever needed we could save lots of RAM.
Loading map in sectors also allows you (in theory) to make map changes live, even if server is running.
BUT! You gave me another idea with those seasons changes which will completely kill the performance of my server

Ezzz made a server to login and view the Cipsoft map. Might be experimental and not work for you, might work flawlessly, no idea:
Thank you! :D
I'll look into it:)

//edit
If I, somehow, manage to load map by sectors I will share the code and all the necessary info.
 
Damn, there was this one server, pretty recent, that has something like this, basically it changed parts of the map, live in front of your eyes, I believe they changed seasons like that, looked pretty cool albeit a bit weird. You see the grass turn into snow etc.

Do you mean something like this?
You mean they changed seasons (snow instead of grass etc.) while the server was online and live?
There is this, but not what OP is looking for.
 
BUMP
i tried, i failed.

Is anyone here who has tried adding loading map by sectors to TFS 1.x + and succed?
Or perhaps some good soul is capable of doing this and is keen to help? ^^
 
Is anyone here who has tried adding loading map by sectors to TFS 1.x + and succed?
Can you describe what do you try to fix by loading map by sectors?
What I meant is that we got as a standard one .otbm file which is loaded at the server startup. If i have a huge map - as I do -(20k x20k tiles, 2GB without details, for example) it require crazy amount of RAM to run it.
You can't save RAM by loading map parts 'when they are needed', how would you know, when they are needed?
If you already know when they are needed (ex. start of some event by globalevent timer/onThink), you can use Lua Function - Game.loadMapChunk(path, position, remove) (https://otland.net/threads/game-loadmapchunk-path-position-remove.266137/) to load .otbm with given map part.

If you try to load .otbm when server is online, it will freez all players in game. That's why nobody does it.

Real Tibia map is stored in multiple files not because it make it work faster/better, it's stored in multiple files to make it easy to track changes using Git/SVN and let multiple mappers work in same time (then merge their changes using Git).

GitHub - gesior/otclient_mapgen: Open Tibia map images generator [for LeafletJS]. Loads .otbm file and generate .png images 256x256 px (https://github.com/gesior/otclient_mapgen) has OTBM loader that can split .otbm map into parts and load them one after another. I made it this way, to make it possible to generate big .otbm PNG images on PC with 2 GB RAM, but it's unusable on server.
 
Can you describe what do you try to fix by loading map by sectors?
What I got is a huge map that require crazy amount of RAM to run it. I'd like to reduce the amount of RAM.
I believe there's two ways to achieve it. Either reduce the size of map (which is a 'no no' for me at the moment) or cut the map into sectors & load map sectors that are needed while leaving in peace sectors that are not needed

The alternative is to get a dedicated server with 256 gb of ram and pay over 9000 onion coins monthly which is also a 'no-no' :D


You can't save RAM by loading map parts 'when they are needed', how would you know, when they are needed?
I've been thinking to know which parts of the map are needed by the player pos, if player logins at X Y (Z is less important) then the server checks which file contains those coordinates and loads the map sectors.

There'd be either:
-list of sectors with their start/end coordinates
-the sector file names would include the starting X Y<&serv would know how many tiles each sector has so it calculate ending coordinates>
-file name would simply include starting/ending XY coordinates
and then load the needed sector (+2/3 surrounding sectors extra).

When player moves I'd like to avoid checking its pos every tile, so, i'd probably try loading further sectors when player cross the border of one sector to another.
I'd probably want the sectors to remain in RAM for a few minutes even if player leave them so that any people who walks on a sector border right/left back and forth won't cause the server loading new sectors back and forth.
The logging in time possibly would be a second or two longer but this is the price I was keen to pay.

those were just initial ideas that i had in my mind when thinking of the whole thing.


If you already know when they are needed (ex. start of some event by globalevent timer/onThink), you can use Lua Function - Game.loadMapChunk(path, position, remove) (https://otland.net/threads/game-loadmapchunk-path-position-remove.266137/) to load .otbm with given map part.
Someone already sent this link, I tried to use it but sadly I've encountered a number of issues and gave up.

If you try to load .otbm when server is online, it will freez all players in game. That's why nobody does it.
This is something I didn't think of. Obviously freezing server occasionally is not an option, even if we save some RAM. Just to double-check, wasn't the script that infernum shared work like that? it loads otbm when the server is running and there wasnt people complaining about freezes


Overall, I am very keen to add to my server any other solution that may help reduce the RAM used by the map.
The sector loading may work completely different than i described, as long, as it works and reduces the RAM usage & doesn't freeze the server, or, I could use something completely (I really don't know what else could help with RAM usage, loading map straight from the disc? o.o or perhaps some map compression? no idea)

Been trying to make it work for a while now and, to be perfectly honest with you, im quite desperate so any help will be really, really, much appreciated 😅
People here quite often say 'everything is possible' when it comes to coding/ programming/scripting so I'm sure something can be done here
 
This is something I didn't think of. Obviously freezing server occasionally is not an option, even if we save some RAM. Just to double-check, wasn't the script that infernum shared work like that? it loads otbm when the server is running and there wasnt people complaining about freezes
It uses game thread to load maps, if the map is big enough then it will take longer to load (also depends on server hardware). More chunks = less size = faster load.
 
it loads otbm when the server is running and there wasnt people complaining about freezes
It depends on size of map loaded.
IDK anyone who used Game.loadMapChunk(path, position, remove) on running server. People often use it in onStart globalevent to load quest/event related changes to map (ex. some boat appears with 20% chance each day).

No matter how efficient you will write it, it will still lag OTS.
When you unload part of map into HDD, you have to save current state of that sector. Some players could throw items there, when they come back, they expect these items to be there. There can be some decaying items (it should block unloading given sector, if there are decaying items).

The alternative is to get a dedicated server with 256 gb of ram and pay over 9000 onion coins monthly which is also a 'no-no'
Fast dedic with 128 GB ECC RAM costs ~90 EUR per month ( Dedicated Server Hosting (https://www.hetzner.com/dedicated-rootserver/ax42/configurator/#/) ).
192 GB ECC RAM with even faster CPU costs ~114 EUR per month ( Dedicated Server Hosting (https://www.hetzner.com/dedicated-rootserver/ax52/configurator/#/) )

canary 13+ RL map is 171 MB and it takes around 3 GB RAM. 2 GB .otbm should take around 40 GB RAM, so even 64 GB RAM server should be enough.

I can't imagine how map that takes 2 GB in .otbm looks like. Who mapped it? To make it with details like on RL tibia map it would take years.
 
with such a large map the ram needed is probably your simplest issue
I would think of scaling this server horizontally somehow for future scaling issues (i. e. switching to another server with part of the map when using a boat or something)
 
Unrelated question does anybody know how to modify actual map in tibia client 13? I mean map in game. ;) To like load my own? not possible I assume.
 
Back
Top