[prototype]Mark where trains frequently get stuck at signals

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
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

[prototype]Mark where trains frequently get stuck at signals

Post by Eddi »

This patch might help finding bottlenecks in the network by giving locations where trains wait for a long time.

This uses m7 for rail tiles [not road crossings or tunnel-/bridgeheads] as an 8-bit counter.

every 4 ticks that a train waits at a signal, the counter is increased by 1 [takes 1024 ticks to get to maximum of 255], every 256 ticks the counter is decreased by 25%. this emphasises trains that are currently waiting, and slowly phases out trains that have been waiting in the past months.

the values are then painted on the smallmap when you open the "routes" view.

Edit: updated to r19525
Attachments
Ravenswald Transport, 12th Oct 1987.png
stuck_trains3.diff
(3.23 KiB) Downloaded 375 times
Last edited by Eddi on 29 Mar 2010 22:23, edited 3 times in total.
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Ammler »

tested on current #openttdcoop PublicServer, but we use mostly block...
Eddi wrote: NOTE: currently seems to work only at path signals
... so I didn't find many red dots, but it has, also orange and green. :-)


Nice idea anyway. :-D

Greets
Ammler
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Eddi »

Well, i know where to put the check for the block signals, but the counting seems off then, maybe that code path is not run every tick, need to investigate that further.
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Re: [prototype]Mark where trains frequently get stuck at signals

Post by XeryusTC »

Very nice patch indeed, it helps you identify problem areas in a way that the traffic overview doesnt show. Too bad it currently only works with path signals though.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Eddi »

updated the patch, should now work with block signals, too.

the problem is, the block signals are handled in TrainController() which does not appear to be run every tick for stopped trains. initial tests have shown this to be every 5 ticks, but i can't be sure if that holds for all vehicles, so counting might be slightly off.
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2890
Joined: 16 May 2007 16:59

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Zephyris »

Nice :) Simple but effective.
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Ammler »

The patch does still apply to trunk, but somehow the gui is broken, how easy to fix?

-Ammler
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Eddi »

quick skim says in smallmap_gui.cpp:GetSmallMapRoutesPixels there was an "else if (t == MP_RAILWAY)" block added, this must be replaced by the stuck-counter block.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [prototype]Mark where trains frequently get stuck at signals

Post by ChillCore »

Thank you for the update Eddi.

While I was reading your patch ...
Would it not be better for codingstyle to have :

Code: Select all

/**
* Colour Coding for Stuck Counter
*/
...
delared after the violet aray?

I know it does not do anything to the way it works, it would just look better if your patch is to hit trunk. ;)

Needless to say I like this patch. It helps a lot to identify the troubled areas in my long lasting game.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Eddi »

ChillCore wrote:[...]after the violet aray?
that part was introduced after i wrote the patch, i didn't check whether it needs to be reordered...
if your patch is to hit trunk. ;)
honestly, i don't expect that to happen...

first, it doesn't record trains waiting on bridges or in stations. (this might be solved by using the counter at the signal tile, not at the tile the front engine waits, but that is difficult to determine, e.g. trains may be "waiting for path" while not at a signal at all)

second, it needs a better GUI representation, i just kinda hijacked the "routes" view...

... i don't think i'm going to do either of that ...
feel free to pick it up, though...
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [prototype]Mark where trains frequently get stuck at signals

Post by ChillCore »

Eddi wrote: that part was introduced after i wrote the patch, i didn't check whether it needs to be reordered...
Because I have been quite busy around that part of the code it kinda jumped out towards me. :)
honestly, i don't expect that to happen...
That would be a shame because it is very useful.
first, it doesn't record trains waiting on bridges or in stations. (this might be solved by using the counter at the signal tile, not at the tile the front engine waits, but that is difficult to determine, e.g. trains may be "waiting for path" while not at a signal at all)
I did not notice that. My bridges usually are enclosed by signals to minimize the gap and I still put signals in front of my stations eventhough they have a build in signal since some time now (I just think it looks better).
second, it needs a better GUI representation, i just kinda hijacked the "routes" view...

... i don't think i'm going to do either of that ...
feel free to pick it up, though...
Would introducing a button for it and using for example "MP_WAITING_SIGNAL_TIME" be enough?
If so I might give it a try ...
My guess is that the rail colours would have to be preserved for trunk inclusion to be considered.
I think I will start by including it in my patchpak to see how it behaves with other patches (Signals in tunnels and on bridges).
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Eddi »

ChillCore wrote: My guess is that the rail colours would have to be preserved for trunk inclusion to be considered.
i tried, but the rail colour is very bright, it's difficult to make out the coloured spots in there, which is why i made it black. the original colouring also includes two pixels of the terrain, leaving only two pixels for the rail colour. i made it use the whole 4 pixels.
I think I will start by including it in my patchpak to see how it behaves with other patches (Signals in tunnels and on bridges).
that should be easy to determine: if they use m7 for rail tiles, it's not going to work (the grass growth patch is the only one i know that does that)

i did not modify bridges or stations or level crossings, so it's unlikely to conflict anywhere...
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [prototype]Mark where trains frequently get stuck at signals

Post by ChillCore »

Eddi wrote: i tried, but the rail colour is very bright, it's difficult to make out the coloured spots in there, which is why i made it black. the original colouring also includes two pixels of the terrain, leaving only two pixels for the rail colour. i made it use the whole 4 pixels.
Maybe having a seperate view will solve that.
that should be easy to determine: if they use m7 for rail tiles, it's not going to work (the grass growth patch is the only one i know that does that)
Thanks for the info.
I tried using m8 for the grass growth but that does not seem to exist. :(
i did not modify bridges or stations or level crossings, so it's unlikely to conflict anywhere...
Hmm grass or signals ...
Signals seem less cpu intensive. (Less places to check)
But this is off-topic here.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Michi_cc »

ChillCore wrote:and I still put signals in front of my stations eventhough they have a build in signal since some time now (I just think it looks better).
They don't. What you see is simply the general don't-just-crash-my-trains protection. Just compare the position of the two waiting trains in http://www.tt-ms.de/forum/attachment.php?aid=1014.

-- Michael Lutz
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [prototype]Mark where trains frequently get stuck at signals

Post by ChillCore »

Michi_cc wrote: They don't. What you see is simply the general don't-just-crash-my-trains protection.
...
Ah, OK. I assumed that they had like depots. Depots do have one built in them, don't they?
If not I have some more reading to do. :)

/me should stop assuming ...
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: [prototype]Mark where trains frequently get stuck at signals

Post by Michi_cc »

Depots have signals built in. But as a train inside a depot has no real position anyway, it wouldn't make a difference where the train waits for a free path :)

-- Michael Lutz
xmirakulix
Engineer
Engineer
Posts: 36
Joined: 06 Jan 2010 18:06

Re: [prototype]Mark where trains frequently get stuck at sig

Post by xmirakulix »

Updated to current trunk
Attachments
stuck_trains_r22958.diff
(3.39 KiB) Downloaded 305 times
xmirakulix
Engineer
Engineer
Posts: 36
Joined: 06 Jan 2010 18:06

Re: [prototype]Mark where trains frequently get stuck at sig

Post by xmirakulix »

Updated to current trunk
Attachments
stuck-trains-r25234.diff
(3.43 KiB) Downloaded 291 times
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [prototype]Mark where trains frequently get stuck at sig

Post by adf88 »

I refreshed the patch:
- change: stuck counter now decreases to 0 so a highlight will disappear after certain period of time (previously once highlighted signal was staying highlighted for eternity)
- removed magic constants
- fixed coding style (whitespace)
- moved new functions in rail_map.h higher (to keep MakeXXX functions on the bottom as usually)
Attachments
stuck_trains_r26405.diff
(3.35 KiB) Downloaded 228 times
:] don't worry, be happy and checkout my patches
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 10 guests