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)
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?
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?
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 .
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.
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
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 .
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?
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 .
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.
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.
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
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.....
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.