Patch: prevent towns from building roads (patch option)

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

spoot
Engineer
Engineer
Posts: 6
Joined: 02 Apr 2006 17:23

Patch: prevent towns from building roads (patch option)

Post by spoot »

Hello,

this is my first attempt at a patch and I thought I'd start with something not too hard. Something frequently requested, which is an option to prevent towns from building roads. Well, here it is. I've tested it to some extent and I think it works as it should.

Suggestions or rants about my bad coding are quite welcome :)

23 April update
- changed name to "townscanbuildroads" to remove the double negative
- updated to work with r4549
- unrelated fix in ai/trolly/pathfinder (couldn't compile otherwise)
Attachments
openttd[win32]-townscanbuildroads.zip
Binary, win32
(454.04 KiB) Downloaded 567 times
townscanbuildroads.patch
build against r4549
(5.54 KiB) Downloaded 718 times
Last edited by spoot on 23 Apr 2006 18:43, edited 3 times in total.
spoot
Engineer
Engineer
Posts: 6
Joined: 02 Apr 2006 17:23

Post by spoot »

[screenie post]
Attachments
Screenshot showing the patch option, Economy menu, right under the "bribe" option.
Screenshot showing the patch option, Economy menu, right under the "bribe" option.
townscanbuildroads.png (55.25 KiB) Viewed 14105 times
Last edited by spoot on 23 Apr 2006 18:38, edited 2 times in total.
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

so you will get "Towns will not build roads: Off". I think a double negative like that is a bit confusing.

wouldn't it be better to make it "Towns will build roads: On/Off" with On being the default setting?
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

And how about "Forbit towns from building roads?"
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7597
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

I must agree, the way the patch setting itself is worded is confusing.

I had to not not read it a second time to get sense of it. :wink:
Image
spoot
Engineer
Engineer
Posts: 6
Joined: 02 Apr 2006 17:23

Post by spoot »

First, thanks for the feedback.

I named the topic after the request for this patch I saw somewhere, which literally used the name "townsbuildnoroads" which might be the way it is called in TTDPatch?

I think I'll rename the bool itself to "townscanbuildroads" and the string to "Towns can build roads". That removes the double negative, good point :) You think that name is clear enough?
ThunderAI
Transport Coordinator
Transport Coordinator
Posts: 306
Joined: 26 Nov 2003 09:15

Post by ThunderAI »

Would i tbe too hard to have a town build itself in a block 2x2 formation or 3x3 or 4x2. Since that is how i would build their roads anyway why not teach the city road expansion function to build roads like that.
spoot wrote:First, thanks for the feedback.

I named the topic after the request for this patch I saw somewhere, which literally used the name "townsbuildnoroads" which might be the way it is called in TTDPatch?

I think I'll rename the bool itself to "townscanbuildroads" and the string to "Towns can build roads". That removes the double negative, good point :) You think that name is clear enough?
User avatar
Aegir
Tycoon
Tycoon
Posts: 2884
Joined: 09 Feb 2004 10:02
Contact:

Post by Aegir »

It is indeed called townbuildnoroads in ttdpatch. Nice to see a usefull little, almost overlooked, feature make it's way into ottd.

Nice work.

Now, code townroadbranchprob :P.
TTDPatch Config file wrote:`townroadbranchprob' (no command line switch) changes the probability of a town building a road branch. 0 means almost no branches, 65535 means branch everywhere possible. TTD's default is 26214. Range 0..65535. Default 21845.
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
User avatar
MeTo
Traffic Manager
Traffic Manager
Posts: 129
Joined: 06 Apr 2003 14:02
Location: UnL; Czech Republic
Contact:

Post by MeTo »

Spoot : great work ! Would it be possible to add it to the mini integrated nightly ?
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

I hope this gets added into the core, it allows you to play a different kind of ttd game, where you just build pretty networks. About time someone coded it :)
spoot
Engineer
Engineer
Posts: 6
Joined: 02 Apr 2006 17:23

Post by spoot »

(update in first post)
ThunderAI wrote:Would i tbe too hard to have a town build itself in a block 2x2 formation or 3x3 or 4x2. Since that is how i would build their roads anyway why not teach the city road expansion function to build roads like that.
There is already a patch floating around here that does something like that, I'll see if I'm able to combine them. The setting might then become "Town roadbuilding behaviour: Off / 2x2 / 3x3 / 4x2" or whatever sounds reasonable.
Aegir wrote:It is indeed called townbuildnoroads in ttdpatch. Nice to see a usefull little, almost overlooked, feature make it's way into ottd.

Nice work.

Now, code townroadbranchprob :P.
TTDPatch Config file wrote:`townroadbranchprob' (no command line switch) changes the probability of a town building a road branch. 0 means almost no branches, 65535 means branch everywhere possible. TTD's default is 26214. Range 0..65535. Default 21845.
How does this work exactly? Does a value of 0 mean roads will never be branched, e.a. only existing roads will be extended?
User avatar
Aegir
Tycoon
Tycoon
Posts: 2884
Joined: 09 Feb 2004 10:02
Contact:

Post by Aegir »

spoot wrote:
Aegir wrote:It is indeed called townbuildnoroads in ttdpatch. Nice to see a usefull little, almost overlooked, feature make it's way into ottd.

Nice work.

Now, code townroadbranchprob :P.
TTDPatch Config file wrote:`townroadbranchprob' (no command line switch) changes the probability of a town building a road branch. 0 means almost no branches, 65535 means branch everywhere possible. TTD's default is 26214. Range 0..65535. Default 21845.
How does this work exactly? Does a value of 0 mean roads will never be branched, e.a. only existing roads will be extended?
That's my understanding of it. I could always check the source to confirm.
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

spoot wrote:How does this work exactly? Does a value of 0 mean roads will never be branched, e.a. only existing roads will be extended?
Yes.
AIUI, "townroadbranchprob 0" means that towns will never build a road with more than two of the four road pieces. It does not mean that the roads won't turn, though.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
jacke
Director
Director
Posts: 533
Joined: 19 May 2002 14:47
Location: Sweden

Post by jacke »

Nice work Spoot!
User avatar
MeTo
Traffic Manager
Traffic Manager
Posts: 129
Joined: 06 Apr 2003 14:02
Location: UnL; Czech Republic
Contact:

Post by MeTo »

Does there exist any progress with adding this great function into the latest nightly build ? I think it would be bad just to "forget" this and not to add it..... But I am sorry, I have really no idea how difficult it is to add it, so if it is the problem, so it is ok :)
User avatar
Rens2Sea
Engineer
Engineer
Posts: 109
Joined: 13 Sep 2004 10:22
Location: Holland
Contact:

Post by Rens2Sea »

MeTo wrote:Does there exist any progress with adding this great function into the latest nightly build ? I think it would be bad just to "forget" this and not to add it.....
Yeah what he said.
User avatar
Athorium
Traffic Manager
Traffic Manager
Posts: 218
Joined: 28 Mar 2006 10:19
Location: España

Post by Athorium »

Someone can say me how I install .path/diff files (windows version) I looked the post about it but I no understand anything :S
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

User avatar
Athorium
Traffic Manager
Traffic Manager
Posts: 218
Joined: 28 Mar 2006 10:19
Location: España

Post by Athorium »

Lol... I refering at this post that I no understand any thing of those codes posted... I'm a really noob... :(
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

Well if you don't then your only chance is that someone other compiles it for you. Dunno if it is in the MiniIN, but i think not. Applying an patch/diff file to an executable is not possible.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google [Bot] and 4 guests