[prototype]Mark where trains frequently get stuck at signals
Moderator: OpenTTD Developers
[prototype]Mark where trains frequently get stuck at signals
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
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
-
- stuck_trains3.diff
- (3.23 KiB) Downloaded 731 times
Last edited by Eddi on 29 Mar 2010 22:23, edited 3 times in total.
Re: [prototype]Mark where trains frequently get stuck at signals
tested on current #openttdcoop PublicServer, but we use mostly block...

Nice idea anyway.
Greets
Ammler
... so I didn't find many red dots, but it has, also orange and green.Eddi wrote: NOTE: currently seems to work only at path signals

Nice idea anyway.

Greets
Ammler
Town Names:


Still work in progress: OpenGFX or/and OpenSFX - Please help!
Re: [prototype]Mark where trains frequently get stuck at signals
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.
Re: [prototype]Mark where trains frequently get stuck at signals
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)

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone







Re: [prototype]Mark where trains frequently get stuck at signals
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.
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.
Re: [prototype]Mark where trains frequently get stuck at signals
Nice
Simple but effective.

Re: [prototype]Mark where trains frequently get stuck at signals
The patch does still apply to trunk, but somehow the gui is broken, how easy to fix?
-Ammler
-Ammler
Town Names:


Still work in progress: OpenGFX or/and OpenSFX - Please help!
Re: [prototype]Mark where trains frequently get stuck at signals
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.
Re: [prototype]Mark where trains frequently get stuck at signals
Thank you for the update Eddi.
While I was reading your patch ...
Would it not be better for codingstyle to have :
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.
While I was reading your patch ...
Would it not be better for codingstyle to have :
Code: Select all
/**
* Colour Coding for Stuck Counter
*/
...
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.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
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.
Re: [prototype]Mark where trains frequently get stuck at signals
that part was introduced after i wrote the patch, i didn't check whether it needs to be reordered...ChillCore wrote:[...]after the violet aray?
honestly, i don't expect that to happen...if your patch is to hit trunk.
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...
Re: [prototype]Mark where trains frequently get stuck at signals
Because I have been quite busy around that part of the code it kinda jumped out towards me.Eddi wrote: that part was introduced after i wrote the patch, i didn't check whether it needs to be reordered...

That would be a shame because it is very useful.honestly, i don't expect that to happen...
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).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)
Would introducing a button for it and using for example "MP_WAITING_SIGNAL_TIME" be enough?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...
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.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
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.
Re: [prototype]Mark where trains frequently get stuck at signals
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.ChillCore wrote: My guess is that the rail colours would have to be preserved for trunk inclusion to be considered.
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 think I will start by including it in my patchpak to see how it behaves with other patches (Signals in tunnels and on bridges).
i did not modify bridges or stations or level crossings, so it's unlikely to conflict anywhere...
Re: [prototype]Mark where trains frequently get stuck at signals
Maybe having a seperate view will solve that.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.
Thanks for the info.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 tried using m8 for the grass growth but that does not seem to exist.

Hmm grass or signals ...i did not modify bridges or stations or level crossings, so it's unlikely to conflict anywhere...
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.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
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.
Re: [prototype]Mark where trains frequently get stuck at signals
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.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).
-- Michael Lutz
Re: [prototype]Mark where trains frequently get stuck at signals
Ah, OK. I assumed that they had like depots. Depots do have one built in them, don't they?Michi_cc wrote: They don't. What you see is simply the general don't-just-crash-my-trains protection.
...
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.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
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.
Re: [prototype]Mark where trains frequently get stuck at signals
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

-- Michael Lutz
-
- Engineer
- Posts: 36
- Joined: 06 Jan 2010 18:06
Re: [prototype]Mark where trains frequently get stuck at sig
Updated to current trunk
- Attachments
-
- stuck_trains_r22958.diff
- (3.39 KiB) Downloaded 622 times
-
- Engineer
- Posts: 36
- Joined: 06 Jan 2010 18:06
Re: [prototype]Mark where trains frequently get stuck at sig
Updated to current trunk
- Attachments
-
- stuck-trains-r25234.diff
- (3.43 KiB) Downloaded 541 times
Re: [prototype]Mark where trains frequently get stuck at sig
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)
- 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 542 times
![Pleased :]](./images/smilies/pleased.gif)
Who is online
Users browsing this forum: No registered users and 12 guests