Signal auto complete fix

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

Buhmann
Engineer
Engineer
Posts: 20
Joined: 20 Dec 2007 18:20

Signal auto complete fix

Post by Buhmann »

Please note that this is my very first patch and that I've never done anything like this before, so expect bad coding etc.

Nevertheless I think this is a small but usefull patch.

When you use the function to automatically build signals on a track with a choosen density, you end up having really large blocks around tunnels or bridges, because signals are simply left out.

With my patch, the code checks wether a signal would be placed in a tunnel or on a bridge. If that's the case, the code forces a signal to appear before the bridge/tunnel. The code also checks if a signal behind a tunnel/bridge would be useful and builds it if needed.

In other words, the code now uses signal blocks that are shorter than the choosen density to keep other signal blocks from becoming larger than they have to be.

Screenshot here
Attachments
signal.patch
Patch
(3.3 KiB) Downloaded 223 times
Lohrfeld Transport, 10. Jul 2002.png
Example
(158.66 KiB) Downloaded 646 times

Draakon
Director
Director
Posts: 542
Joined: 11 Mar 2007 16:50

Re: Signal auto complete fix

Post by Draakon »

theres already a feature like this in the trunk.

User avatar
Wolf01
Tycoon
Tycoon
Posts: 2013
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Re: Signal auto complete fix

Post by Wolf01 »

not so true
the trunk feature places signals every XX tiles, if it encounters a tunnel, that tile is skipped, so you end up with a larger gap between two signals with the tunnel in the middle (as Buhmann said)
his patch instead sees the tunnel, if the tunnel is smaller than the prefixed gap it does nothing but it places a signal at the tunnel entrances if needed, mainly because the tunnel is just in the tile where the signal should be
like

Code: Select all

the . are the signals, - the track and )( the tunnel

TRUNK
--.---)   (---.-----------.-----------
--.---------)   (---------.-----------
              ^
signal should be here

his PATCH
--.---)   (---.-----------.-----------
--.--------.)   (.-----------.-----------
and i think is a great feature, very useful also for bridges

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

Re: Signal auto complete fix

Post by Bilbo »

So basically a bigfix to the code already in trunk ... I hope this bugfix make it there too. Is it reported in bugtracker at bugs.openttd.org?
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)

Buhmann
Engineer
Engineer
Posts: 20
Joined: 20 Dec 2007 18:20

Re: Signal auto complete fix

Post by Buhmann »

@Wolf01 not exactly ;)
In your example, the signal right after the last tunnel is unnecessary, because the tunnel is shorter than the preferred distance between two signals.

Code: Select all

1. Placing signals before tunnels

TRUNK
--.---)   (---.-----------.-----------
--.---------)   (---------.-----------
   \_____________________/
       block too long


MY PATCH
--.---)   (---.-----------.-----------
--.--------.)   (------.-----------.--


2. Placing signals after tunnels

TRUNK
--.-----------.)   (------.-----------.--
--.-----------.)       (--.-----------.--
--.-----------.)           (----------.--
               \_____________________/
                    block too long
MY PATCH
--.-----------.)   (------.-----------.--
--.-----------.)       (--.-----------.--
--.-----------.)           (.-----------.

User avatar
Wolf01
Tycoon
Tycoon
Posts: 2013
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Re: Signal auto complete fix

Post by Wolf01 »

ah ok, it checks also the length of the tunnel, less signal entropy ;)

Psistorm
Traffic Manager
Traffic Manager
Posts: 173
Joined: 05 Jun 2004 12:22

Re: Signal auto complete fix

Post by Psistorm »

thats a great patch, I hope it makes it into trunk :) - thats pretty much the optimum behaviour for signal placement, so it sure has my vote, for what it is worth ;)

RMJ
Traffic Manager
Traffic Manager
Posts: 160
Joined: 24 Sep 2005 13:52
Location: Denmark
Contact:

Re: Signal auto complete fix

Post by RMJ »

very nice :) while you are at it, if you could also fix the signal placement behavior on / & \ kind of tracks, because the gaps on diagonal always becomes to big compared to straight tracks xD
Feel free to join my server on 90.185.50.242. its coop, meaning 1 company to dominate the whole map :) its more random and not as pro as the Openttd Coop guys.

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

Re: Signal auto complete fix

Post by Bilbo »

I am not sure with that, but aren't trains placed diagonally also proportinally longer and move proportionally faster? Then the same spacing would be fine ...
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)

User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: Signal auto complete fix

Post by athanasios »

Small but clever patch. Thanks.
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.

User avatar
Shrekko
Engineer
Engineer
Posts: 29
Joined: 19 Feb 2007 10:49
Location: Hoogland, the Netherlands

Re: Signal auto complete fix

Post by Shrekko »

Good Job!!! I always had to place them by myself and that costs a lot of time...
OpenTTD is cool,
Thank you all developers.
I hope that I'm one day something like you.

User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Signal auto complete fix

Post by pavel1269 »

Code: Select all

TRUNK
--.-----------.)   (------.-----------.--
--.-----------.)       (--.-----------.--
--.-----------.)           (----------.--
               \_____________________/
                    block too long
PATCH
--.-----------.)   (------.-----------.--
--.-----------.)       (--.-----------.--
--.-----------.)           (.-----------.
i must say, i like the trunk version, since after tunnel

Code: Select all

--.--
--.--
--.--
and as i understand with your patch it will be

Code: Select all

--.--
--.--
---.-
this will be just another thing which will make building tracks for me harder :(

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

Re: Signal auto complete fix

Post by Bilbo »

So make this fix optional (toggleble in constructuion settings)? Since it seems there are people who like the old behaviour.
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)

Buhmann
Engineer
Engineer
Posts: 20
Joined: 20 Dec 2007 18:20

Re: Signal auto complete fix

Post by Buhmann »

@pavel

I've thought about that problem, but, if you want your track good looking, you would build tunnels for all tracks anyway, wouldn't you?

If I build tunnels on a two-way track, both tracks get their own tunnel.

And, furthermore, I have no idea how to add a toggle as Bilbo described :D. That way my first patch, and I'm far from understanding the ottd source code...
I'll try it, but I don't promise anything.

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

Re: Signal auto complete fix

Post by Bilbo »

Buhmann wrote:And, furthermore, I have no idea how to add a toggle as Bilbo described :D.
Add the variable to src/variables.h in the "struct Patches" - perhaps under the "bool enable_signal_gui" add line like "bool signal_autocomplete_mode" or alike with explanation of what the variable does

Look in src/settings.cpp and look for line "const SettingDesc _patch_settings[] = {" and the lines onward. These contain definition of patch settings, so add line there too for the patch settings, like:
SDT_BOOL(Patches, signal_autocomplete_mode, S, 0, false, STR_CONFIG_SIGNAL_AUTOCOMPLETE_MODE, NULL),

Next, open src/lang/english.txt and add english translation of the string used:

STR_CONFIG_SIGNAL_AUTOCOMPLETE_MODE :Use new mode of signal autocomplete

Now just add some checking like "if (_patches.signal_autocomplete_mode) new_behavior; else old_behavior;

and you're done :)
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)

Buhmann
Engineer
Engineer
Posts: 20
Joined: 20 Dec 2007 18:20

Re: Signal auto complete fix

Post by Buhmann »

You forgot the settings_gui.cpp ;)

Ok, here is the new version of the patch.
Attachments
signal.patch
New version of the signal patch, now with patch-option.
(6.34 KiB) Downloaded 218 times

User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7571
Joined: 10 Dec 2002 20:36
Skype: Bornacorn
Location: Wrexham, Wales
Contact:

Re: Signal auto complete fix

Post by Born Acorn »

Please don't inline images when they're so large, thanks.

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

Re: Signal auto complete fix

Post by Bilbo »

Buhmann wrote:You forgot the settings_gui.cpp ;)
Now I see .. you have to add line in one of the patch dialog tabs there too so it will appear in the dialog. I forgot that :)
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)

Buhmann
Engineer
Engineer
Posts: 20
Joined: 20 Dec 2007 18:20

Re: Signal auto complete fix

Post by Buhmann »

So - is there any chance that this patch will make it into trunk?

PhilSophus
Chairman
Chairman
Posts: 776
Joined: 20 Jan 2007 12:08
Location: Germany

Re: Signal auto complete fix

Post by PhilSophus »

Buhmann wrote:So - is there any chance that this patch will make it into trunk?
Did you post it to http://bugs.openttd.org? If not, do that and await the comments of the developers.
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 2 guests