Signal auto complete fix
Moderator: OpenTTD Developers
Signal auto complete fix
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
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 327 times
-
- Lohrfeld Transport, 10. Jul 2002.png
- Example
- (158.66 KiB) Downloaded 646 times
Re: Signal auto complete fix
theres already a feature like this in the trunk.
Re: Signal auto complete fix
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
and i think is a great feature, very useful also for bridges
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
--.---) (---.-----------.-----------
--.--------.) (.-----------.-----------
Re: Signal auto complete fix
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)
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)
Re: Signal auto complete fix
@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.
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
--.-----------.) (------.-----------.--
--.-----------.) (--.-----------.--
--.-----------.) (.-----------.
Re: Signal auto complete fix
ah ok, it checks also the length of the tunnel, less signal entropy
Re: Signal auto complete fix
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
Re: Signal auto complete fix
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.
Re: Signal auto complete fix
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)
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)
- athanasios
- Tycoon
- Posts: 3138
- Joined: 23 Jun 2005 00:09
- Contact:
Re: Signal auto complete fix
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.
"If no one is a fool I am also a fool." -The TTD maniac.
I prefer to be contacted through PMs. Thanks.
Re: Signal auto complete fix
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.
Thank you all developers.
I hope that I'm one day something like you.
Re: Signal auto complete fix
Code: Select all
TRUNK
--.-----------.) (------.-----------.--
--.-----------.) (--.-----------.--
--.-----------.) (----------.--
\_____________________/
block too long
PATCH
--.-----------.) (------.-----------.--
--.-----------.) (--.-----------.--
--.-----------.) (.-----------.
Code: Select all
--.--
--.--
--.--
Code: Select all
--.--
--.--
---.-
My patches: Day length (new concept), Conditional loading, Auto separation, Unload all adds Leave empty, Better statue placement (in trunk)
My abandoned patches: Speed limits for RVs, Day length (old concept)
My abandoned patches: Speed limits for RVs, Day length (old concept)
Re: Signal auto complete fix
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)
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)
Re: Signal auto complete fix
@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 . 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.
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 . 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.
Re: Signal auto complete fix
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 doesBuhmann wrote:And, furthermore, I have no idea how to add a toggle as Bilbo described :D.
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)
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)
Re: Signal auto complete fix
You forgot the settings_gui.cpp
Ok, here is the new version of the patch.
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 294 times
- Born Acorn
- Tycoon
- Posts: 7595
- Joined: 10 Dec 2002 20:36
- Skype: bornacorn
- Location: Wrexham, Wales
- Contact:
Re: Signal auto complete fix
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 :)Buhmann wrote:You forgot the settings_gui.cpp ;)
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)
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)
Re: Signal auto complete fix
So - is there any chance that this patch will make it into trunk?
-
- Chairman
- Posts: 776
- Joined: 20 Jan 2007 12:08
- Location: Germany
Re: Signal auto complete fix
Did you post it to http://bugs.openttd.org? If not, do that and await the comments of the developers.Buhmann wrote:So - is there any chance that this patch will make it into trunk?
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
Who is online
Users browsing this forum: No registered users and 3 guests