Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Thu Apr 25, 2019 3:00 pm

All times are UTC




Post new topic  Reply to topic  [ 24 posts ]  Go to page 1 2 Next
Author Message
 Post subject: Signal auto complete fix
PostPosted: Sun Dec 23, 2007 3:37 pm 
Offline
Engineer
Engineer

Joined: Thu Dec 20, 2007 6:20 pm
Posts: 20
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:
File comment: Patch
signal.patch [3.3 KiB]
Downloaded 162 times
File comment: Example
Lohrfeld Transport, 10. Jul 2002.png [158.66 KiB]
Downloaded 646 times
Top
   
PostPosted: Sun Dec 23, 2007 3:51 pm 
Offline
Director
Director

Joined: Sun Mar 11, 2007 4:50 pm
Posts: 542
theres already a feature like this in the trunk.


Top
   
PostPosted: Sun Dec 23, 2007 4:30 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Apr 24, 2004 10:43 am
Posts: 2008
Location: Venezia - Italia
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:
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

_________________
ImageImage
ImageImage
ImageImage
newgrf tests, see: newgrf test topic, my patches: Wolf01's Hire Point
Italian TTD Forum
Wiki Page


Top
   
PostPosted: Sun Dec 23, 2007 4:37 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
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)


Top
   
PostPosted: Sun Dec 23, 2007 4:45 pm 
Offline
Engineer
Engineer

Joined: Thu Dec 20, 2007 6:20 pm
Posts: 20
@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:
1. Placing signals before tunnels

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


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


2. Placing signals after tunnels

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


Top
   
PostPosted: Sun Dec 23, 2007 4:48 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Apr 24, 2004 10:43 am
Posts: 2008
Location: Venezia - Italia
ah ok, it checks also the length of the tunnel, less signal entropy ;)

_________________
ImageImage
ImageImage
ImageImage
newgrf tests, see: newgrf test topic, my patches: Wolf01's Hire Point
Italian TTD Forum
Wiki Page


Top
   
PostPosted: Sun Dec 23, 2007 4:51 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Sat Jun 05, 2004 12:22 pm
Posts: 173
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 ;)


Top
   
PostPosted: Mon Dec 24, 2007 12:14 am 
Offline
Traffic Manager
Traffic Manager

Joined: Sat Sep 24, 2005 1:52 pm
Posts: 160
Location: Denmark
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.


Top
   
PostPosted: Mon Dec 24, 2007 12:25 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
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)


Top
   
PostPosted: Mon Dec 24, 2007 2:24 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 23, 2005 12:09 am
Posts: 3138
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.


Top
   
PostPosted: Mon Dec 24, 2007 8:21 am 
Offline
Engineer
Engineer
User avatar

Joined: Mon Feb 19, 2007 10:49 am
Posts: 29
Location: Hoogland, the Netherlands
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.


Top
   
PostPosted: Mon Dec 24, 2007 9:32 am 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Sun Dec 03, 2006 1:22 pm
Posts: 473
Location: Czech Republic
Code:
TRUNK
--.-----------.)   (------.-----------.--
--.-----------.)       (--.-----------.--
--.-----------.)           (----------.--
               \_____________________/
                    block too long
PATCH
--.-----------.)   (------.-----------.--
--.-----------.)       (--.-----------.--
--.-----------.)           (.-----------.


i must say, i like the trunk version, since after tunnel
Code:
--.--
--.--
--.--


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


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

_________________
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)


Top
   
PostPosted: Mon Dec 24, 2007 10:18 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
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)


Top
   
PostPosted: Mon Dec 24, 2007 11:53 am 
Offline
Engineer
Engineer

Joined: Thu Dec 20, 2007 6:20 pm
Posts: 20
@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.


Top
   
PostPosted: Mon Dec 24, 2007 12:32 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
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)


Top
   
PostPosted: Mon Dec 24, 2007 2:30 pm 
Offline
Engineer
Engineer

Joined: Thu Dec 20, 2007 6:20 pm
Posts: 20
You forgot the settings_gui.cpp ;)

Ok, here is the new version of the patch.


Attachments:
File comment: New version of the signal patch, now with patch-option.
signal.patch [6.34 KiB]
Downloaded 170 times
Top
   
PostPosted: Mon Dec 24, 2007 7:23 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Dec 10, 2002 8:36 pm
Posts: 7571
Skype: Bornacorn
Location: Wrexham, Wales
Please don't inline images when they're so large, thanks.

_________________
Image
FacebookFlickr PhotosBlogTwitterHosting


Top
   
PostPosted: Wed Dec 26, 2007 1:50 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
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)


Top
   
PostPosted: Sun Feb 10, 2008 3:51 pm 
Offline
Engineer
Engineer

Joined: Thu Dec 20, 2007 6:20 pm
Posts: 20
So - is there any chance that this patch will make it into trunk?


Top
   
PostPosted: Sun Feb 10, 2008 5:01 pm 
Offline
Chairman
Chairman

Joined: Sat Jan 20, 2007 12:08 pm
Posts: 776
Location: Germany
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 24 posts ]  Go to page 1 2 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


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-2019 phpBB Limited

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