• 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!

OpenTibia OTClient that unpack map.otbm to .png files - v2.0

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,966
Solutions
99
Reaction score
3,383
Location
Poland
GitHub
gesior
EDIT:
There is version 4.0 thread:

on GitHub is available version 5.1:

What is new in version 2.0?
- much faster generation
  • - - you can run PHP scripts on all CPU cores
  • - - much calculations moved to C++, it increased speed for around 400%
  • easier to use
  • split map to parts and load it one after another - you can run map generation with ~1GB ram, even if map uses few GB when you start server (works on 32bit systems!)


What is this?
It's automatic map image generator [for website view 'like GoogleMaps'].
It generates OTS map .png images (each 8x8 tiles).

-- BINARY (.EXE) ATTACHHED! YOU DO NOT HAVE TO COMPILE! --
To run binary you may need to install VS2015 Redist first (choose x86 version):
Download Microsoft Visual C++ 2015 Redistributable Update 3 from Official Microsoft Download Center


It contains configured JavaScript and HTML to view map on website like this:
leafexample.png


How to use?
1.
Download otclient_mapgen from GitHub:
GitHub - gesior/otclient_mapgen: Open Tibia map images generator [good for Leaflets]. Loads .otbm file and generate .png images 256x256 px

and compile it like normal OTClient:
Compiling on Windows · edubart/otclient Wiki · GitHub
Compiling on Linux · edubart/otclient Wiki · GitHub
Compiling on Mac OS X · edubart/otclient Wiki · GitHub
Compiling for Android · edubart/otclient Wiki · GitHub

OR DOWNLOAD BINARY (.EXE) ATTACHED

2. Copy your server client .spr and .dat files to OTClient folder: data/things/HERE_PROTOCOL_VERSION/

3.
Copy your server data/items/items.otb file to OTClient folder: data/things/HERE_PROTOCOL_VERSION/

4.
Copy your server data/world/MAP_NAME.otbm file to OTClient folder: data/map.otbm

5.
Run otclient.exe

6.
Type in client terminal command like:

prepareClient(1076, '/things/1076/items.otb', '/map.otbm', 8, 5)

  • with you client protocol version,
  • valid paths to items.otb and map.otbm,
  • number of threads to run (in example it's 8),
  • number of map parts (OTC will split map to parts to reduce maximum RAM usage)

[Paths are relational, so start path with '/' to start in folder 'data', access to other folders in computer is blocked]

7. OTClient will show in 10-50 seconds (it will freez client, do not close it, just wait) something like:
Now just type (lower levels shadow 30%)
ALL PARTS OF MAP:
generateMap('all', 30)
ONLY PARTS 2 AND 3 OF MAP:
generateMap({2, 3}, 30)

8. Type in client terminal command:

generateMap('all', 30)

OTClient will report progress in terminal.

9. Your map images will appear in your system 'user' directory

%HOMEPATH%/otclient - Windows, open it in folder explorer
$({HOME}/.otclient - Linux, 'cd' to it, this folder is invisible, but you can navigate to it

10. Copy folder map from folder metioned in previous step to folder website_and_php_files of otclient_mapgen.

--- NEXT STEPS REQUIRE PHP INSTALLED IN SYSTEM ---

--- LINUX: FOR GENERATION TIME, SET FOLDER website_and_php_files RIGHTS TO 777 ---


11.
Execute (in system terminal):
Code:
php 1_pre_tile_generator.php

12. Execute (command parameter is map 'floor'):
  • You can execute these commands in any order.
  • You can open few terminals and run few commands at once to generate it faster (use all CPU cores).

Code:
php 2_tile_generator.php 0
php 2_tile_generator.php 1
php 2_tile_generator.php 2
php 2_tile_generator.php 3
php 2_tile_generator.php 4
php 2_tile_generator.php 5
php 2_tile_generator.php 6
php 2_tile_generator.php 7
php 2_tile_generator.php 8
php 2_tile_generator.php 9
php 2_tile_generator.php 10
php 2_tile_generator.php 11
php 2_tile_generator.php 12
php 2_tile_generator.php 13
php 2_tile_generator.php 14
php 2_tile_generator.php 15
php 2_tile_generator.php 16

13. Execute:
Code:
php 3_pre_compress.php

14. Execute (command parameter is map 'floor'):
  • You can set compression quality in file 4_compress.php (line: $quality = 80;)
  • You can execute these commands in any order.
  • You can open few terminals and run few commands at once to generate it faster (use all CPU cores).

Code:
php 4_compress.php 0
php 4_compress.php 1
php 4_compress.php 2
php 4_compress.php 3
php 4_compress.php 4
php 4_compress.php 5
php 4_compress.php 6
php 4_compress.php 7
php 4_compress.php 8
php 4_compress.php 9
php 4_compress.php 10
php 4_compress.php 11
php 4_compress.php 12
php 4_compress.php 13
php 4_compress.php 14
php 4_compress.php 15
php 4_compress.php 16

15. Move folder website_and_php_files/map_viewer to your webserver - it contains all images and website scripts to view them (Leaflet Map).

16. Configure map_viewer. Config is at start of map.js file:
- You can keep images on other webserver. Set imagesUrl to URL of this server like: 'http://myserver.com/map_images/'

Code:
imagesUrl: 'map/', // URL to folder with 'zoom levels' (folders with names 0-16)
imagesExtension: '.jpg',
mapName: 'RL MAP?',
startPosition: {x: 1000, y: 1000, z: 7},
startZoom: 14,
minZoom: 4,
maxZoom: 18, // maximum zoom with full quality is 16

Added item/outfit generator to sources (you can use binary file v3 to unpack outfits/items):
Feature - Unpack items/outfits from any client to PNG with OTClient!

and merged newest edubart/otclient (just to keep it up to date, there is no new features):
GitHub - gesior/otclient_mapgen: Open Tibia map images generator [good for Leaflets]. Loads .otbm file and generate .png images 256x256 px
 

Attachments

  • otclient_mapgen_v2_binary.zip
    6.3 MB · Views: 70 · VirusTotal
  • otclient_mapgen_v3_binary.zip
    6.4 MB · Views: 267 · VirusTotal
Last edited:
Just compiled this on ubnutu and looks like it didnt create the otclient file? huh? hahaha

Cant edit my post for some reason??? heres error at end of the compile.


Code:
[100%] Linking CXX executable otclient
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libphysfs.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
CMakeFiles/otclient.dir/build.make:3857: recipe for target 'otclient' failed
make[2]: *** [otclient] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/otclient.dir/all' failed
make[1]: *** [CMakeFiles/otclient.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
 
Last edited by a moderator:
Just compiled this on ubnutu and looks like it didnt create the otclient file? huh? hahaha

Cant edit my post for some reason??? heres error at end of the compile.


Code:
[100%] Linking CXX executable otclient
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libphysfs.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
CMakeFiles/otclient.dir/build.make:3857: recipe for target 'otclient' failed
make[2]: *** [otclient] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/otclient.dir/all' failed
make[1]: *** [CMakeFiles/otclient.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
It's not related to my modified version and I got no idea how to help you :(
Someone reported similar problem before with Ubuntu 15 and libphysfs.a:
Error Compiling in Ubuntu 15.04

Maybe one of answers from that thread will help you.

------------
@Don Daniello
Can you add otclient_mapgen_v3_binary.zip from my post above to first post or put in first post link to that post with information that it contains 'item and outfit image generator' included?
 
It's not related to my modified version and I got no idea how to help you :(
Someone reported similar problem before with Ubuntu 15 and libphysfs.a:
Error Compiling in Ubuntu 15.04

Maybe one of answers from that thread will help you.

------------
@Don Daniello
Can you add otclient_mapgen_v3_binary.zip from my post above to first post or put in first post link to that post with information that it contains 'item and outfit image generator' included?
Oh sorry i forgot i posted here.. was indeed that lib. for some reason mine wasnt replacing the old one so i had to manually overwrite it. thanks for the reply!
 
Anyone knows how to launch otclient under linux without GUI? With just console and use those commands? Is possible?
 
Anyone knows how to launch otclient under linux without GUI? With just console and use those commands? Is possible?
You can use mobaXterm and ssh into your Linux server which will
Allot you to open otclient with its GUI.
 
@slawkens ordered 'show monster and NPC' script for 30 euro and he said I can release it :)

Added NPC and Monsters viewer and fast spawn search (to master, only JS and PHP changes):
GitHub - gesior/otclient_mapgen: Open Tibia map images generator [good for Leaflets]. Loads .otbm file and generate .png images 256x256 px

List of spawns, monsters and NPCs is based on OTS files. You don't have to write/configure anything except path to OTS data. Data is cached in 'creaturesData.cache.json' file, remove that file to refresh cache.

Screenshot with monsters, NPCs and 'Search monster and NPC' feature (it groups near monsters into 'spawns', you can search for few monsters in same time):
map_search.png



Also added OTClient version that compiles on Linux with new OpenSSL 1.1 (use 'cmake -DUSE_GMP=1 ..' to compile with GMP in place of OpenSSL):
GitHub - gesior/otclient_mapgen at gmp_rsa

-----------------------------

I did some tests of OTClient mapgen on PC at work. 112MB .otbm generated and compressed to .jpg in 72 minutes on i7-8700k (6 cores @5.0GHz), Samsung 950 EVO (NVMe disc).
 
Map with monsters and NPCs example (xavato.eu custom ots):
Xavato.eu map

-------------------------------------------------------------------------------
I've added new feature to otclient_mapgen:
Generate houses images!

Now you can generate images of all houses with 2 commands :)
PHP:
prepareClient(860, 'items.otb', 'map.otbm', 1, 1)
860 - version

items.otb - path to items file in 'data' folder
map.otbm - path to map file in 'data' folder
1 - number of threads, houses generator uses only 1 thread, so it does not matter
1 - number of map parts, set it to 3-8 to reduce 'maximum RAM useage' (it will slow down generator a bit)

and then:
PHP:
generateHouses(30, false)
30 - shadow percent for tiles 'around house'
false ('partial loading')- do not load map by parts, load all at once, if you set it true OTClient will relaod map for every house (will load only part with house).. veery slow, but reduces amount of RAM required


I've added this feature to branches 'master' and 'gmp_rsa':
GitHub - gesior/otclient_mapgen: Open Tibia map images generator [good for Leaflets]. Loads .otbm file and generate .png images 256x256 px
GitHub - gesior/otclient_mapgen at gmp_rsa


- No matter of house size, all images are rectangles (easy to style on website)
- It generates image for every house floor

If client crashes while houses generation, it means that you got bugged house - with some tile far away from real house location.
Client tries to generate big image (like 30000x30000 px) to render house and crashes, because of RAM limit.

Run OTClient by console (./otclient, not by clicking .exe) to view house generation progress, there are messages like:
PHP:
...
Generate house ID: 2126, size: 17
Generated house image: 2126
Generate house ID: 70, size: 15
Generated house image: 70
Generate house ID: 2127, size: 18
Generated house image: 2127
Generate house ID: 149, size: 2060
ERROR: Application crashed
Opss.. some house (ID 149) has width or height over 2000 tiles (image size 2060*32 px)!

Examples:
- house 61
file 61_7.png
61_7.png


- house 111
file 111_6.png

111_6.png


file 111_7.png
111_7.png
 
I don't know what compiler you are using but this won't compile in visual studios 2015 or 2017. I can compile otclient just fine but this throws errors.
These are the errors and I have not made any changes to the source
Code:
Severity    Code    Description    Project    File    Line    Suppression State
Error    C2976    'std::set': too few template arguments    otclient    C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp    297
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2079   'floors' uses undefined class 'std::set'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   297   
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2228   left of '.insert' must have class/struct/union   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   301   
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2589   '(': illegal token on right side of '::'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   316   
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2062   type 'unknown-type' unexpected   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   316   
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2059   syntax error: ')'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   316   
Severity   Code   Description   Project   File   Line   Suppression State
Error   C3312   no callable 'begin' function found for type 'int'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   321   
Severity   Code   Description   Project   File   Line   Suppression State
Error   C3312   no callable 'end' function found for type 'int'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   321   
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2679   binary '<<': no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion)   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   323   
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2664   'void Map::drawMap(std::string,int,int,short,int,uint32)': cannot convert argument 4 from 'overloaded-function' to 'short'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   324   
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2668   'push_luavalue': ambiguous call to overloaded function (compiling source file ..\src\client\luafunctions.cpp)   otclient   c:\users\user\downloads\otclient_mapgen-master\src\framework\luaengine\luainterface.h   359
It's really not that important I just wanted to make you aware of this.
 
Got the map working fine. Took about 3 hours with an SSD and 6600k for a 80mb map.

I tryed with the creatures/npcs but I can't make that one to work. The map will say "Waiting for server stream..".

Im not sure how to configure this in creaturesdata.php

Code:
// path to folder with monster, npc and spawns data
$dataPath = '/home/jskalski/p/prv/mapview_monsters_npc/';
$monstersDir = 'monster/';
$npcDir = 'npc/';
$spawnsFile = 'world/world-spawn.xml';
 
I don't know what compiler you are using but this won't compile in visual studios 2015 or 2017. I can compile otclient just fine but this throws errors.
These are the errors and I have not made any changes to the source
Code:
Severity    Code    Description    Project    File    Line    Suppression State
Error    C2976    'std::set': too few template arguments    otclient    C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp    297
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2079   'floors' uses undefined class 'std::set'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   297  
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2228   left of '.insert' must have class/struct/union   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   301  
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2589   '(': illegal token on right side of '::'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   316  
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2062   type 'unknown-type' unexpected   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   316  
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2059   syntax error: ')'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   316  
Severity   Code   Description   Project   File   Line   Suppression State
Error   C3312   no callable 'begin' function found for type 'int'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   321  
Severity   Code   Description   Project   File   Line   Suppression State
Error   C3312   no callable 'end' function found for type 'int'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   321  
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2679   binary '<<': no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion)   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   323  
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2664   'void Map::drawMap(std::string,int,int,short,int,uint32)': cannot convert argument 4 from 'overloaded-function' to 'short'   otclient   C:\Users\User\Downloads\otclient_mapgen-master\src\client\mapio.cpp   324  
Severity   Code   Description   Project   File   Line   Suppression State
Error   C2668   'push_luavalue': ambiguous call to overloaded function (compiling source file ..\src\client\luafunctions.cpp)   otclient   c:\users\user\downloads\otclient_mapgen-master\src\framework\luaengine\luainterface.h   359
It's really not that important I just wanted to make you aware of this.
I did not compile it on Windows for few months. I will test it next weekend with VS/Codeblocks.
Did you compile 'master' branch or 'gmp'?
Got the map working fine. Took about 3 hours with an SSD and 6600k for a 80mb map.

I tryed with the creatures/npcs but I can't make that one to work. The map will say "Waiting for server stream..".

Im not sure how to configure this in creaturesdata.php

Code:
// path to folder with monster, npc and spawns data
$dataPath = '/home/jskalski/p/prv/mapview_monsters_npc/';
$monstersDir = 'monster/';
$npcDir = 'npc/';
$spawnsFile = 'world/world-spawn.xml';
$dataPath is your OTS 'data' folder (changed example to more readable format)
3 next lines are paths to monsters (default), npcs (default), spawns file (there you need to set your map spawns file name)
Code:
// path to folder with monster, npc and spawns data
$dataPath = '/home/myuser/ots-files/data/';
$monstersDir = 'monster/';
$npcDir = 'npc/';
$spawnsFile = 'world/world-spawn.xml';

map.js config,
this part is about streaming players from game live (with LUA script and special table in MySQL),
when you turn it on and it can't load stream, it shows message 'waiting for stream...':
PHP:
streamPlayers: false, // stream on/off
streamUpdateURL: 'update.php',
streamUpdateOutfitsURL: 'update_outfits.php',
disableClusteringAtZoom: 14, // disable grouping when zoomed in
streamAnimationFramesPerSecond: 25, // smoother animation requires fast PC for high number of players online
streamOutfit: false,
streamHideOutfitOnZoom: 14, // show icons, not outfits when zoomed out
itemGeneratorURL: 'http://item-images.ots.me/1092/',
outfitGeneratorURL: 'http://outfit-images.ots.me/outfit.php?',
outfitAnimatedGeneratorURL: 'http://outfit-images.ots.me/animatedOutfits1090/animoutfit.php?',

map.js config (there was one '-' by mistake, removed from github: otclient_mapgen/map.js at master · gesior/otclient_mapgen · GitHub )
this part is about showing NPCs and Monsters (it's not streamed, it loads everything when page loads):
PHP:
// NPC & Monsters
creaturesDataURL: false, // set 'false' to disable, set 'creaturesData.php' to make it load data
drawMonstersMinimumZoom: 14,
drawNpcsMinimumZoom: 13,
 
It all looks really cool. :drool:
 
Still can't make monsters/npc to work. After your last update map loads and creaturesData.cache.json is created (empty) but no matter what I try can't make the monsters/npc to load.
 
Hi, im getting this erro when generating house img:

> generateHouses(30, false)
ERROR: command failed: :1: attempt to call global 'generateHouses' (a nil value)
 
Someone can give me some answer? Why i can't include this to gesior acc maker? i'm try but it doesn't working.
 
Someone can give me some answer? Why i can't include this to gesior acc maker? i'm try but it doesn't working.

Basically, you need to require/include the index.htm file from this script (map viewer) into your page (into pages/example.php)

This is the file that is responsible for displaying the map: gesior/otclient_mapgen
 
Back
Top