Patch: minimap

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Rolie
Engineer
Engineer
Posts: 5
Joined: 11 Apr 2009 22:48

Patch: minimap

Post by Rolie » 11 Apr 2009 23:36

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?
Attachments
screenshot#1.png
(52.63 KiB) Downloaded 430 times
minimap_r15912.patch
(3.91 KiB) Downloaded 223 times

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Patch: minimap

Post by HackaLittleBit » 12 Apr 2009 00:36

Nice Rolie.
will definitely have a look at it.

Regards HackaLittleBit

P. S. Happy Easter

User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Patch: minimap

Post by Bilbo » 12 Apr 2009 00:40

What about making "ordynary screenshot" of entire minimap? Like giant screenshot, just not of game, but of minimap.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)

Rolie
Engineer
Engineer
Posts: 5
Joined: 11 Apr 2009 22:48

Re: Patch: minimap

Post by Rolie » 12 Apr 2009 08:01

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!

User avatar
Dimme
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 30 Jul 2008 12:42
Location: Trondheim, Norway

Re: Patch: minimap

Post by Dimme » 12 Apr 2009 09:45

I'd really like to be able to zoom out on the smallmap. Then it could be used as bilbo suggested.
Try my modular airports minigame!

Image

Splatman
Engineer
Engineer
Posts: 31
Joined: 31 Jul 2005 16:08
Location: United Kingdom
Contact:

Re: Patch: minimap

Post by Splatman » 08 Aug 2009 20:04

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.
minimap.png
New map output
minimap.png (3.42 KiB) Viewed 5360 times
Attachments
minimap_r17108.patch
Patch against r17108
(3.95 KiB) Downloaded 123 times

Rolie
Engineer
Engineer
Posts: 5
Joined: 11 Apr 2009 22:48

Re: Patch: minimap

Post by Rolie » 08 Aug 2009 22:13

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 :)

Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: Patch: minimap

Post by Wasila » 09 Aug 2009 06:52

I'm not entirely sure what this is. So is it just a map of the network that's shown once every 100 years?

Splatman
Engineer
Engineer
Posts: 31
Joined: 31 Jul 2005 16:08
Location: United Kingdom
Contact:

Re: Patch: minimap

Post by Splatman » 09 Aug 2009 09:21

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

2007Alain2007
Chief Executive
Chief Executive
Posts: 658
Joined: 11 Nov 2007 12:06

Re: Patch: minimap

Post by 2007Alain2007 » 09 Sep 2009 10:12

what size is the out put picture?

Is it the same for all sized maps or dose it get biger/smaller
For Community Integrated Version http://code.google.com/p/civopenttd/

Rolie
Engineer
Engineer
Posts: 5
Joined: 11 Apr 2009 22:48

Re: Patch: minimap

Post by Rolie » 09 Sep 2009 10:14

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? :)

Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Patch: minimap

Post by Roujin » 09 Sep 2009 11:23

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.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage

Rolie
Engineer
Engineer
Posts: 5
Joined: 11 Apr 2009 22:48

Re: Patch: minimap

Post by Rolie » 09 Sep 2009 12:06

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:

User avatar
Vaulter
Traffic Manager
Traffic Manager
Posts: 185
Joined: 21 Dec 2004 05:35
Skype: andrey-zaharov
Location: St. Petersburg, Russia
Contact:

Re: Patch: minimap

Post by Vaulter » 12 Jan 2010 09:35

any progress?

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Patch: minimap

Post by petert » 13 Jan 2010 03:27

Vaulter wrote:any progress?
From what I can see, no.

User avatar
Vaulter
Traffic Manager
Traffic Manager
Posts: 185
Joined: 21 Dec 2004 05:35
Skype: andrey-zaharov
Location: St. Petersburg, Russia
Contact:

Re: Patch: minimap

Post by Vaulter » 14 Jan 2010 20:04

here updated patch for trunk and 0.7.5
Attachments
minimap_screenshot_r18799.patch
trunk
(3.98 KiB) Downloaded 117 times
minimap_screenshot_0.7.5.patch
0.7.5
(4 KiB) Downloaded 111 times
screenshot.png
sample from real server :)
screenshot.png (12.5 KiB) Viewed 4411 times

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 3 guests