Page 1 of 1

Patch: minimap

Posted: 11 Apr 2009 23:36
by Rolie
I'm running a OpenTTD-server permanently on a co-located server. I think it would be fun if all that work that goes into the game, every 100 years over and over again, would actually lead to something more permanently. I vision some web based statistics with possibly two goals:
  • Show history and statistics for finished games.
  • Possibly enable intra-game competition between players.
This patch might contribute to the above ideas. It makes a minimap (see attachment). All tiles are 1:1 mapped on pixels. Like the smallmap that can be viewed ingame, but only more compact and without isometric projection. A 1024x1024 map would lead to a 1024x1024 minimap. It is currently implemented using MakePNGImage. It now only encodes the "owners" of each tile. I tried to copy the colors that are used in the smallmap but did not succeed in that. It has nothing to do with the GUI, so can be run on a dedicated server. The function is triggered by a console command (minimap).

Todo
  • Fix colours.
  • Check for png.h.
  • Duplicate interesting smallmap functionalities.
  • Compile to run on server and periodically save image to create animation, disclosure on web, etc.
Known issues
  • Map is 180° rotated or mirrored. Either way, it doesn't follow the intuition that ingame west or north is the left-upper corner of the minimap.
I must say I'm kinda proud that I managed to do this. Hardly any experience with C++, so trial and error is my friend. Still not understand why I can't get the colors like in the smallmap. Finding out how to get pixeldata into the buf from the callback was very problematic too. For example, why can't I just cast the void pointer to a uint32 pointer, set it to the right 'location' and assign 0x00RRGGBB?

Re: Patch: minimap

Posted: 12 Apr 2009 00:36
by HackaLittleBit
Nice Rolie.
will definitely have a look at it.

Regards HackaLittleBit

P. S. Happy Easter

Re: Patch: minimap

Posted: 12 Apr 2009 00:40
by Bilbo
What about making "ordynary screenshot" of entire minimap? Like giant screenshot, just not of game, but of minimap.

Re: Patch: minimap

Posted: 12 Apr 2009 08:01
by Rolie
Bilbo, For 1024x1024 games, those would be too large to comfortably make animations, which is one of my goals :). But it shouldn't be too hard to do.

PS: Maybe I should call this patch "micromap" :)
PPS: Happy Easter!

Re: Patch: minimap

Posted: 12 Apr 2009 09:45
by Dimme
I'd really like to be able to zoom out on the smallmap. Then it could be used as bilbo suggested.

Re: Patch: minimap

Posted: 08 Aug 2009 20:04
by Splatman
Sorry for bumping an old thread, but I have made some fixes to this patch and updated to a newer trunk version (17108).

Fixed:
Colours now match the Maps owner view (including company colours)
Output map is now flipped so that the left point of the map in game becomes the top left corner in the output map

It now uses the OpenTTD palette system to get the colours, so _owner_colours is now a byte (as the minimap only needs 1 colour for each pixel, where as the smallmap seems to need 4) instead of a unit32.
New map output
New map output
minimap.png (3.42 KiB) Viewed 9163 times

Re: Patch: minimap

Posted: 08 Aug 2009 22:13
by Rolie
No need to be sorry for bumping an old thread if you ask me! Good work, will take a further look at it when I have my next OpenTTD period :)

Re: Patch: minimap

Posted: 09 Aug 2009 06:52
by Wasila
I'm not entirely sure what this is. So is it just a map of the network that's shown once every 100 years?

Re: Patch: minimap

Posted: 09 Aug 2009 09:21
by Splatman
It adds a console command that outputs a picture of the game map, there is a similar patch here http://www.tt-forums.net/viewtopic.php?f=33&t=44596 this one is different as it can be used by a dedicated server. I'm in the process of setting up a dedicated server as a sort of AI aquarium where I've used this patch with a quick bodge to get it to save a screenshot of the map every time the game autosaves (every month), which should give me a series of pngs which show the AIs progression.

Update:

AI Aquarium is up

Re: Patch: minimap

Posted: 09 Sep 2009 10:12
by 2007Alain2007
what size is the out put picture?

Is it the same for all sized maps or dose it get biger/smaller

Re: Patch: minimap

Posted: 09 Sep 2009 10:14
by Rolie
It maps 1 square on the map with 1 pixel of the minimap. A game with 1024x1024 squares would yield a minimap of 1024x1024. Simple, isn't it? :)

Re: Patch: minimap

Posted: 09 Sep 2009 11:23
by Roujin
Congratulations on your patch, I can see why it's more useful than mine.
However, I wonder why you created an entirely new way to draw the map.. sure, it's more compact than the existing map, but we're used the smallmap that's in the game. Maybe you could optionally allow to draw the map in the diamond shaped form? :) Just a suggestion.

Re: Patch: minimap

Posted: 09 Sep 2009 12:06
by Rolie
I just wanted a better information density or, as you already mentioned, compactness. I now also realize that the normal smallmap screenshots (your patch, right?) are still (a lot) larger than 1449x1449 for a 1024x1024 map, so rotating the minimap 45° would actually not be such a bad idea :) Would require anti-aliasing I believe though...

PS: Splatman: nice! Now you only need to make the images preload and browsable by a slider control or something :wink:

Re: Patch: minimap

Posted: 12 Jan 2010 09:35
by Vaulter
any progress?

Re: Patch: minimap

Posted: 13 Jan 2010 03:27
by petert
Vaulter wrote:any progress?
From what I can see, no.

Re: Patch: minimap

Posted: 14 Jan 2010 20:04
by Vaulter
here updated patch for trunk and 0.7.5