Page 1 of 1
Export: OpenTTD maps to a text format?
Posted: 09 Nov 2009 05:44
by pekarna
Hi OpenTTD developers,
please, is there a convertor of OpenTTD map files to some text format?
No matter what - XML, plain text... the only necessity is to be parseable.
If not, could someone write it?
Yes, I could write it for myself... but you know the code right away and would code it much faster than I would.
I intend to use that for an opensource project - WebTTD (which you may join if you want

)
WebTTD
Thanks, Ondra Zizka
Re: Export: OpenTTD maps to a text format?
Posted: 09 Nov 2009 06:56
by Zuu
1. It is not an easy task.
2. How would someone else than you find value of spending their time on this for you? While it might be true that *someone* might do it faster than you, he or she still need to get something out of it. The person who do it must see a benefit of doing it.
Re: Export: OpenTTD maps to a text format?
Posted: 09 Nov 2009 09:00
by XeryusTC
pekarna wrote:No matter what - XML, plain text... the only necessity is to be parseable.
The current format is already parseable, it is just binary and quite hard to parse but OTTD is still able to read its own savegames so it is possible. Maybe you should take a look at all the save/load functions.
Re: Export: OpenTTD maps to a text format?
Posted: 09 Nov 2009 15:33
by Roujin
What exactly do you mean with "map"? Everything that's stored in a savegame?
In OpenTTD, savegames consist of two parts.
Part 1 being the map array, a big array (or arrays) where each element is associated with a tile, describing what is on the tile. See
docs/landscape.html
Part 2 is various variable-sized "pools" that store stuff that either is not associated with a certain tile on the map (e.g. company information, cargo packets...), or is too big to fit into the map array, so it's stored in the pool and to be able to access it in the map array is stored an index pointing to the corresponding item in the pool (e.g. stations).
So if you're gonna export that to xml or something similar, it's probably going to look something like this:
Code: Select all
<savegame>
<map_array>
<tile>
<x>0</x>
<y>0</y>
<type_height>xxxxxxxx</type_height>
<m1>xxxxxxxx</m1> // if you chose to write it in binary - it's 8 bits. x = either 0 or 1
<m2>xxxxxxxxxxxxxxxx</m2> // 16 bits
<m3>xxxxxxxx</m3>
<m4>xxxxxxxx</m4>
<m5>xxxxxxxx</m5>
<m6>xxxxxxxx</m6>
<m7>xxxxxxxx</m7>
</tile>
<tile>
...
</tile>
...
... // all the other tiles
...
</map_array>
<pools>
<company_pool>
<company>
<id>0</id>
<whateverstuffisstoredthere>...</whateverstuffisstoredthere>
</company>
...
</company_pool>
<cargopacket_pool>
<cargopacket>
<id>0</id>
<whateverstuffisstoredthere>...</whateverstuffisstoredthere>
</cargopacket>
</cargopacket_pool>
...
... // all the other pools
...
</pools>
</savegame>
(btw I'm not volunteering to code this for you, only helping. The others are probably right that you'll have to code it yourself.)
Disclaimer: This is only from what I remember and using the above mentioned landscape.html, so there may be mistakes. Don't rely on it too much and get a second opinion, if this is correct.
Re: Export: OpenTTD maps to a text format?
Posted: 09 Nov 2009 15:50
by pekarna
Thanks for info, Roujin and XeryusTC.
I would even suffice with some numbers and delimiters logged to a debug output.
The problem is not the code itself, but to get it compile, which I didn't manage to yet.
Zuu, the motivation for anyone to code this for the WebTTD project is the same as coding anything for any other free opensource project.
Imagine OpenTTD in the form of a MMO browser-based game. Don't you like this idea?
Re: Export: OpenTTD maps to a text format?
Posted: 09 Nov 2009 16:00
by Gremnon
I'd prefer to keep it offline, as it is myself.
That way, I don't have to be online to play, I get to choose what GRFs are active, and what the settings are. Online play is what the multiplayer function is for.
But that's just my view, don't let it discourage you.
Re: Export: OpenTTD maps to a text format?
Posted: 09 Nov 2009 17:32
by Roujin
There are instructions on the wiki that should help you getting OpenTTD compiled:
http://wiki.openttd.org/FAQ_development ... pile_it.3F
Re: Export: OpenTTD maps to a text format?
Posted: 09 Nov 2009 23:45
by maquinista
pekarna wrote:Hi OpenTTD developers,
please, is there a convertor of OpenTTD map files to some text format?
No matter what - XML, plain text... the only necessity is to be parseable.
If not, could someone write it?
Yes, I could write it for myself... but you know the code right away and would code it much faster than I would.
I intend to use that for an opensource project - WebTTD (which you may join if you want

)
WebTTD
Thanks, Ondra Zizka
It looks interesting.
I recomend You to use only OpenGFX images, because They have a free license.
Re: Export: OpenTTD maps to a text format?
Posted: 10 Nov 2009 07:02
by pekarna
I have managed to build OpenTTD using MinGW. Thanks for the wiki page link!
Re: Export: OpenTTD maps to a text format?
Posted: 26 Nov 2009 00:41
by pekarna
How can I enable logging to a file?
I've tried DEBUG, or printf, but that goes to a console (Windows XP, compiled using MinGW.
I've tried openttd -d 1 > foo.txt, but OpenTTD opens another console for stdout...
Thanks, Ondra
Re: Export: OpenTTD maps to a text format?
Posted: 26 Nov 2009 07:53
by Eddi
[to repeat the answer from the chat:]
you need to convert openttd.exe to a console application with
http://devs.openttd.org/~glx/convert.zip
Re: Export: OpenTTD maps to a text format?
Posted: 26 Nov 2009 14:57
by pekarna
Well, it didn't work on Windows, so I was hoping there is some logging implemented other than DEBUG(). If not, never mind, I'll use fprintf()

Thanks for help.