Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Apr 24, 2017 5:05 pm

All times are UTC




Post new topic  Reply to topic  [ 107 posts ]  Go to page 1 2 3 4 5 6 Next
Author Message
PostPosted: Sat Mar 12, 2011 7:15 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
Hello all,

I was playing on a 2048*2048 map and felt the need of the feature presented in this *very first* patch: an extension of zooming out capability of the main viewport (relying only on the smallmap was not convenient enough for me).

This patch has been initially done on top of the 1.1 branch of OpenTTD. I tried to reuse a maximum of already existing code. As I like very much how the smallmap presents things, I borrowed its "owners" (with heightmap activated) rendering method. It is obviously far from perfect but it runs quite smoothly on my computer and should help big map players.

I hope this kind of feature will find its way into trunk one day :)

    1/ Zoom out any viewport up to 128X
To get an overview, no need to switch to the smallmap constantly: just use your mousewheel (works with main viewport and extraviewports too).
Attachment:
maps.png
maps.png [ 92.06 KiB | Viewed 6185 times ]
NB: Bridges and tunnels support is glitchy.

    2/ Locate a viewport
When you move a viewport (not in map mode), the other viewports (in map mode) will show its location.
Image
Note that blending option is enabled only for 32bpp blitter!

    3/ Industry tooltips
If you are tired of the "click on industry, read info then close window" routine, this is for you!
Image

    4/ Plans
To ease cooperative games, this is a tool to draw lines on viewports.
By default, a plan is visible only by its owning company but you can advertise the plan and make it public (public appears in blue).
Image
Double click on a plan in the list expand its lines.
The selected line or plan is drawn in red.
The Delete button affects the selected item in the list.

    5/ Vehicle route
Understanding where a vehicle goes is very important.
On a big map, there are too many towns to get quickly the relation between name and location.
So to make things easier, the route steps are pointed out.
And if you want more, it can show the path and conditional branching.
Image
(there is an expert setting to chose dashed or plain lines)

    6/ Settings
All options are found in "Display options" and its "Viewport Map" subpage.
Also, don't forget to increase the maximum zoom out level!
Attachment:
advanced-settings.png
advanced-settings.png [ 8.54 KiB | Viewed 3321 times ]


    7/ Patch
Attachment:
enhanced-viewport_r53_for_r27127.zip [205.35 KiB]
Downloaded 129 times

r53:
- adapted to the "more height levels" feature (+ full heightlevel colour dithering)
- replaced dark/light heightlevels by darken/lighten lookup tables

r52:
- adapted to codechange r26623 (SettingsPage)
- sanity check for binary data length (server recv)
- fix a crash with tooltip buffer

r51:
- add ability to draw straight plan lines (in 2 clicks)
- fix plans GUI with custom fonts
- scrolling a viewport does not give it focus
- add advanced setting to specify the dash level of a vehicle's route

r50:
- fix crash when oilrig is not shown on map
- fix smallmap notification to viewports
- fix horizontal alignment of route step labels

r49:
- extend focus system to prevent useless redraw and on/off/on effect (when using dropdowns) with route steps and path (and fix marking dirty when passing from a vehicle A window to a vehicle B window)

r48:
- dynamically adjust the disabled state of the buttons of the plans window
- set plan initial visibility to true if the player works for the plan's owner
- cancel current drawing if the associated plan is remotely deleted
- fix public plans handling and some focus related things

r47:
- fix the selected item handling in plan window (possible crash after a plan gets remotely deleted)

r46:
- fix SetLine32() anim value (blinking owners are definitely not good)
- templatize map rendering with show_slope
- reworked slope colours in vegetation map mode

r45:
- the vegetation map style takes into account the transparency settings of trees
- route steps are aware of font height
- fix toggle private/public plan crash

r44:
- updated filter mark dirty (no farmfield changes in map mode)
- configurable maintoolbar hotkey "plan_list" to open the plans window
- fix plans error strings
- add tooltip to plans window buttons
- change the advertise (plan) button into Make public/Make private

r43:
- new route step graphics
- fix plans destructor (possible crash when returning to menu)

r42:
- plans feature: draw things with the mouse to ease explanations in coop games (there are 2 levels of plan visibility : local company only or public)
- changed line style of vehicle route path

r41:
- "vegetation" mode adapts itself to baseset/NewGRF
- force realtime rendering of the map
- deduplicate code in industry tooltips
- route steps use grf resource instead of uint8 _ugly_array[]
- route steps support multiple stops at the same place (ex: "A -> B -> C -> B -> A" means 2 lines for B)

r40:
- added a gcc friendly PREFETCH_NTA macro (only 01_iterator-prefetch-tile.patch is affected)

r39:
- "Scan surroundings" now relies on an inlined iterator whom prefetches tiles (ViewportMapGetMostSignificantTileType() is 2 times faster than it was)

r38:
- fix compilation with gcc

r37:
- fix wrong stopover in case of an explicit order "go to nearest depot"

r36:
- adapted to codechanges r25262, r25263 & r25264 (linkgraph)

r35:
- adapted to codechanges r25018 & r25020

r34:
- fix scrolling viewport blending (GetBytesPerPixel != GetScreenDepth)

r33:
- adapted to codechange r24206

r32:
- add "scan surroundings" (replica of the idea behind SmallMapWindow::GetTileColours())
- better bridges & tunnels support at high zoom out levels (thanks to "scan surroundings")
- fix invalid order crash (related to stopovers and path)

r31:
- vehicle refit window is now handled for stopovers and path
- transfer focus to vehicle view when closing a window like orders or timetable
- prevent news from getting focused

r30:
- fix depot stopover (was not shown)
- show a vehicle's path

r29:
- show on map the steps of a vehicle's route (only when the focused window is related to a specific vehicle)
- cleanup 2 magic constants for extraviewport tooltips (nvp->pos_x/y)

r28:
- fix coordinates of scrolling viewport box on map
- fix keynames for hotkeys.cfg
- do not show hidden players' bridges and tunnels
- show where train stations are in map owner mode
- finally enable the use of owner's colour for bridges and tunnels

r27:
- add 2 global hotkeys equivalent of ctrl+mousewheel ("previous_map_mode"/PAGEUP and "next_map_mode"/PAGEDOWN) ; it affects the first window matching criteria (a viewport at map zoomlevel): first it checks the focused window then it falls back on the main viewport

r26:
- show where the scrolling viewport is on maps (the right-clicked and dragged one)

r25:
- all advanced settings are now in Interface->Display options->Viewport Map
- doubleclick on map: depending on adv. settings, it goes directly to zoom1X or it opens an extra viewport
- line buffer is dynamically adjusted to width

r24:
- ensure that sprites are not encoded for map zoomlevels

r23:
- fix the flickering in realtime rendering mode (related to colour_index_base)

r22:
- code cleanup
- fix minor graphic bug with slopes
- fix viewport refresh when showing/hiding stuff from smallmap controls
- adapted to feature r23670

r21:
- fix freeform graphic glitch
- added 2 Advanced Settings to show/hide bridges and tunnels

r20:
- slopes influence players' colour in owner mode
- bridges and tunnels are rendered (known bug: at least one end of the bridge/tunnel must be in the redrawn block)

r19:
- town names are shown up to 32X

r18:
- split patch in 3 parts
- in map mode, town names are shown in a tooltip
- fix extraviewport tooltips (feature r23316 related)

r17:
- adapted to feature r23316 ("Add ability to zoom in to 2x and 4x level")

r16:
- adapted to codechange r23091
- reworked and simplified filter for marking tile dirty

r15:
- interactions with smallmap's legend immediately affect viewports
- the "Industry chain -> Link to smallmap" button refresh all viewports in industry mode too
- industry tooltip is now enabled for all zoom levels (I just can't play without it anymore :) )
- fix text of Advanced Option "default_viewport_map_mode"

r14:
- fix tooltip (yes, again: r12 fix broke partially the "Length: x" tooltip)

r13:
- crashfix: I forgot some basic range checking

r12:
- crashfix: a tooltip keeps StringID but not the associated params (meaning with r11: one overlap, one redraw... one crash :S)

r11:
- added a tooltip to industry mode (production info)

r10:
- patch now following trunk (r22277)
- better sync between vehicles and ground

r9:
- fix vehicle trail
- slightly better performance

r8:
- enhanced rendering (with slopes)
- better handling of owned roads color
- partially fix vehicle trail (problem occuring in realtime mode only)
- realtime option moved from "Interaction" to "Display options"
- Advanced Option to enable/disable slopes
- Advanced Option to select default map mode

r7:
- replace the full refresh every n ticks by realtime
- filtering applied on the dirty tile setting system (reduce cpu usage)
- bugfix with 32bpp-anim (forgotten ::SetLine() in v6)
- option added in Advanced Settings -> Interaction -> Render viewport map in realtime (if not: 1:n ticks)

r6:
- code clean-up
- really fix the graphic glitch (colidx init related)

r5:
- minor graphic glitch corrected (vertical lines with wrong color)
- introduce "ctrl + mousewheel" to cycle through 3 map types:
1/ owner+contour
2/ industry
3/ vegetation

r4:
- secondary viewport draws what it should
- ground heightmap looks like what smallmap does
- vehicles are rendered


Last edited by MJP on Thu Jan 29, 2015 10:59 pm, edited 80 times in total.

Top
   
PostPosted: Sat Mar 12, 2011 7:35 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Tue Oct 03, 2006 6:26 pm
Posts: 351
Location: Prague, Czech Republic
Hello,

when compiling this patch applied, I get link error:

/home/smatz/openttd/anon3/src/smallmap_gui.h:19:17: warning: inline function ‘TileType GetEffectiveTileType(TileIndex)’ used but never defined

[SRC] Linking openttd
viewport.o: In function `ViewportDoDraw(ViewPort const*, int, int, int, int)':
/home/smatz/openttd/anon3/src/viewport.cpp:1448: undefined reference to `GetEffectiveTileType(unsigned int)'

_________________
Image


Top
   
PostPosted: Sat Mar 12, 2011 7:49 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
Thank you for testing.
I used MSVC and it linked well but I suppose I should have removed the inline attribute of GetEffectiveTileType().
I have updated the patch accordingly.


Top
   
PostPosted: Fri Mar 18, 2011 12:30 am 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
By the way, would anyone know how to manage all these refresh messages caused apparently by window overlapping?

Put a secondary viewport above a high traffic junction and you'll see that the window gets redrawn a lot more than the minimum of 1 time every n ticks stated by ontick().
I tried to doublebuffer the window to prevent cpu stress but with no success: the result being clearly worse (by absolutely killing the scrolling smoothness).


Top
   
PostPosted: Fri Mar 18, 2011 3:02 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4336
Location: home
MJP wrote:
By the way, would anyone know how to manage all these refresh messages caused apparently by window overlapping?
Extend Window::SetDirty() with code that detects that (part of) the dirtying is not visible, and thus can be skipped.
There are however also refreshes that should not be blocked (at least the full-screen refreshes, and possibly others as well).


Top
   
PostPosted: Sat Mar 19, 2011 10:08 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
Alberth wrote:
Extend Window::SetDirty() with code that detects that (part of) the dirtying is not visible, and thus can be skipped.


I followed your advice and modified SetDirtyBlocks() so a window can't mark a block dirty it that block is under another window. It seems to work but in the end, I'm not sure if this is really needed.


Attachments:
zoom64_v6_with_modified_gfx.cpp-SetDirtyBlocks.patch [26.36 KiB]
Downloaded 181 times
Top
   
PostPosted: Mon Mar 21, 2011 10:35 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
Well, of all the changes the v7 brings, I wonder what you (all openttd devs) think of the extension of MarkAllViewportsDirty() and if you see a better way to achieve that result?

(on a side note, I did the DirtyTileInfo flags really quickly and there are surely tons of errors in what I put on all the callers of MarkAllViewportsDirty(), it's draft quality :) )


Top
   
PostPosted: Tue Mar 22, 2011 2:10 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2759
Could I suggest changing the appearence of the terrain in the smallmap-style views? The sudden switch from shaded to gradient shaded (i.e. the normal tile graphics) to the contour shading (i.e. the smallmap-style display) is a bit ugly. Could you change the contour shading to a more normal-tile like one? (if that makes sense at all!)

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
PostPosted: Tue Mar 22, 2011 6:25 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4336
Location: home
MJP wrote:
what you (all openttd devs) think of the extension of MarkAllViewportsDirty() and if you see a better way to achieve that result?
26KB is too much to figure out quickly, especially since zoom and redraw reduction are not related.

It is much better to keep separate things separately.


Top
   
PostPosted: Tue Mar 22, 2011 11:13 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
Zephyris> Do you mean showing slope orientation rather than altitude?

Alberth> Thank you for paying attention to my patch. I will try to make a separate one (I'm new to SVN and versioning in general).

At the moment I'm working on eliminating the trail behind vehicles and regarding that, I have another question. Here is what I did.

In the v7-ViewportDrawVehiclesOnMap(), z-pos of a vehicle is ignored so when redraw occurs with z-aware dpi coordinates, some vehicle's old white pixels are out and stay. To fix that: RemapCoords() get its z-pos instead of 0 and problem is gone.

But... z-aware vehicles on a flat map... well, not good ;) So in order to "resync" the ground with vehicles, I used a cheap approximation of z in VpGetSmallMapColor() (the correct method found in TranslateXYToTileCoord() takes way too much time).

At that point, I thought it was all fixed: no rogue white pixel on my 512*512 test map. Just to be sure, I check with another savegame on a 2048*2048 map and... Surprise ! Unwanted evil white pixels.

Attachment:
bug.png
bug.png [ 1013 Bytes | Viewed 12147 times ]


It happens only with vehicles going up (NE or NW gives the same). The 8px intervals shows the block below does not cross the dpi to redraw. This is something I fail to understand.


Attachments:
zoom64_v8T.patch [63.41 KiB]
Downloaded 186 times
Top
   
PostPosted: Wed Mar 23, 2011 1:12 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2759
Quote:
Zephyris> Do you mean showing slope orientation rather than altitude?
Yup, that's exactly what I mean, sorry I didn't explain it very clearly!

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
PostPosted: Wed Mar 23, 2011 6:53 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4336
Location: home
Quote:
Alberth> Thank you for paying attention to my patch. I will try to make a separate one (I'm new to SVN and versioning in general).
Reducing redraws may be useful to have a look at, although screen/window redraw is not significant for non-viewports, I think.

For version control, SVN is quite useless unless you have commit access. It is much more useful to use hg or git for your patches. It not only gives you commit access so you can actually do versioning, but they also have patch queues which is very useful for developing a sequence of patches stacked on top of each other.
(At least, I know hg has it, I am guessing git has it too.)


Top
   
PostPosted: Wed Mar 23, 2011 10:47 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
Alberth> I've just installed TortoiseHg. It looks nice, I will get into it after the completion of my patch v8.

Zephyris> I tried to implement what you suggested. Tell me what you think of the following results:

1/ "old" heightmap:
Attachment:
heightmap.png
heightmap.png [ 23.23 KiB | Viewed 12048 times ]


2/ slopes:
Attachment:
slopes.png
slopes.png [ 31.92 KiB | Viewed 12048 times ]


3/ heightmap combined with slopes:
Attachment:
heightmap-and-slopes.png
heightmap-and-slopes.png [ 32.72 KiB | Viewed 12048 times ]


Personally, I find #3 to be very easy to read in 16X and 32X but it becomes a little messy in 64X.


Top
   
PostPosted: Wed Mar 23, 2011 10:53 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2759
MJP wrote:
Zephyris> I tried to implement what you suggested. Tell me what you think of the following results:

Very very nice! I think the third one looks best, but as you say I can see it would get hard to read in the 64x zoom out. The second one is probably the clearest and would fit best into the zooming out sequence.

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
PostPosted: Thu Mar 24, 2011 12:24 am 
Offline
Chairman
Chairman
User avatar

Joined: Sun Feb 21, 2010 12:15 am
Posts: 861
Location: Fitzroy North - 96
Wonderful solution to the graphic issues!


Top
   
PostPosted: Thu Mar 24, 2011 7:23 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
Zephyris> The vegetation mode fits almost nicely in the zooming out sequence. But for my settings, I find the owner mode more useful and I keep it as a default (though it is an option now).

supermop> Thank you! I'm glad you like what's done here! :)


Top
   
PostPosted: Thu Apr 14, 2011 4:08 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
Added in r11, a useful tooltip for industry:

Attachment:
industry_tooltip.png
industry_tooltip.png [ 7.99 KiB | Viewed 11793 times ]

Note that in MouseOver() of extra-viewport (line 2084 of the patch r11), I had to use x-2 and y-16 to compensate for the window. Is there a proper way to replace those hardcoded values?


Attachments:
industry_tooltip.png
industry_tooltip.png [ 65.5 KiB | Viewed 9892 times ]


Last edited by MJP on Sun Jan 22, 2012 9:56 pm, edited 1 time in total.
Top
   
PostPosted: Fri Apr 15, 2011 7:35 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Wed Mar 30, 2005 9:43 am
Posts: 1505
This crashes with freeform edges enabled; it tries to read an out-of-bounds tile.

_________________
He's like, some kind of OpenTTD developer.


Top
   
PostPosted: Fri Apr 15, 2011 12:39 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
Thank you for testing.
Indeed it crashes. And fast. Basic range checking failure. There is one only thing to say: shame on me.
This will teach me what happens when I test only with --disable-assert.
It should be fixed in r13.


Top
   
PostPosted: Sun Nov 27, 2011 5:40 pm 
Offline
Engineer
Engineer

Joined: Sat Mar 12, 2011 7:01 pm
Posts: 115
To use the extra zoom out levels, you need to change the new game setting "Maximum zoom out level" to 64x.


Attachments:
max_zoom_out_level.png
max_zoom_out_level.png [ 2.55 KiB | Viewed 9892 times ]


Last edited by MJP on Sun Jan 22, 2012 9:53 pm, edited 1 time in total.
Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 107 posts ]  Go to page 1 2 3 4 5 6 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.