Patch: Minimum Town Distance

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

2007Alain2007
Chief Executive
Chief Executive
Posts: 658
Joined: 11 Nov 2007 12:06
Contact:

Re: Patch: Minimum Town Distance

Post by 2007Alain2007 »

look down for update of this patch
Last edited by 2007Alain2007 on 30 Mar 2009 21:31, edited 3 times in total.
For Community Integrated Version http://code.google.com/p/civopenttd/
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Patch: Minimum Town Distance

Post by Yexo »

2007Alain2007 wrote:updated it a bit but now got C:/msys/1.0/home/Alainspc/ottdsrc/trunk/src/town.h:379: warning: 'bool IsCloseToTown(TileIndex, uint)' defined but not used
Then you clearly updated it wrong.
2007Alain2007
Chief Executive
Chief Executive
Posts: 658
Joined: 11 Nov 2007 12:06
Contact:

Re: Patch: Minimum Town Distance

Post by 2007Alain2007 »

but it seemed to work so were did i go wrong
For Community Integrated Version http://code.google.com/p/civopenttd/
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Patch: Minimum Town Distance

Post by Yexo »

2007Alain2007 wrote:were did i go wrong
By trying to build a patchpack before learning to program a bit. You don't have to be an expert, but being able to write a simple program yourself is certainly necesary.
User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Patch: Minimum Town Distance

Post by pavel1269 »

proper update .... they just merget that ;) if you will just "ignore" that one fail, it works :-)
Attachments
min_town-ind_r15895.patch
(9.06 KiB) Downloaded 136 times
User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Patch: Minimum Town Distance

Post by pavel1269 »

Update :-)
Attachments
min_town-ind_r18517.patch
(9.04 KiB) Downloaded 133 times
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Patch: Minimum Town Distance

Post by petert »

Do you need a binary for this one?
User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Patch: Minimum Town Distance

Post by pavel1269 »

I dont need any binary. Usually, those patches I update just fit to some patchpatck, here on forums or just personal ones ;-)
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Patch: Minimum Town Distance

Post by Terkhen »

If anyone is interested: here is a custom version of the patch that only implements minimum distance between towns. Industry generation is left unchanged.
Attachments
minimum_ONLY_town_distance_r18656.diff
(4.34 KiB) Downloaded 206 times
Haskey
Engineer
Engineer
Posts: 12
Joined: 01 Jan 2011 19:44

Re: Patch: Minimum Town Distance

Post by Haskey »

can anybody make this patch in grf format for usual users like me?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Patch: Minimum Town Distance

Post by planetmaker »

Haskey wrote:can anybody make this patch in grf format for usual users like me?
No. It's technically not possible.
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: Patch: Minimum Town Distance

Post by Creat »

Has anyone used this patch recently? I would've applies and uploaded an updated version (in particular for the "minimum town distance" variant) but I have no idea how to adapt to the new settings.ini (replacing the settings.h from older versions). This was the old entry used by the patch:

Code: Select all

SDT_CONDVAR(GameSettings, economy.minimum_distance_town,       SLE_UINT16,200, SL_MAX_VERSION, 0, 0,    20,    10,     500,10, STR_CONFIG_SETTING_TOWN_MIN_DISTANCE,      NULL),
if someone could tell me how that translates to an entry for the new settings.ini I'd be happy to upload a patch for a current revision.
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Patch: Minimum Town Distance

Post by Eddi »

that's easy, at the beginning of settings.ini there's a line like

Code: Select all

SDT_VAR    =    SDT_VAR($base, $var, $type, $flags, $guiflags, $def,       $min, $max, $interval, $str, $strval, $proc, $from, $to),
so you just match them: (the order might have been changed)

Code: Select all

[SDT_VAR]
base = GameSettings
var = economy.minimum_distance_town
etc.
you can leave out values that are default. and make sure you add it at the same position as previously.
Last edited by Eddi on 04 Jan 2012 20:00, edited 1 time in total.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Patch: Minimum Town Distance

Post by ChillCore »

There you go ... minus the coding style. ;)

Code: Select all

[SDT_VAR]
base = GameSettings
var = economy.minimum_distance_town
type = SLE_UINT16
from = 200
def = 20
min = 10
max = 500
interval = 10
str = STR_CONFIG_SETTING_TOWN_MIN_DISTANCE
Have a looksie near line 80 of the settings.ini file ... if a value matches the defaults you can leave it out.
Also you must drop the "COND" part out of STD_CONDVAR



edit : Eddi was faster :)
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: Patch: Minimum Town Distance

Post by Creat »

First of all, thank you both for the rather quick reply! Didn't expect such a swift answer so I only just saw it.

The main thing that confused me (or at least made me ask) was the fact that the old syntax apparently had STD_CONDVAR and STD_VAR, which seems to no longer be the case.

It's quite a simple patch obviously since it mostly comes into play with generating a new map (and maybe when founding a town, if allowed in game, which I've never done), which is why I don't understand why the SAVEGAME_VERSION is bumped. I checked the load functions and there doesn't seem to be any verification upon loading if the towns are allowed to be placed where they are. So I would conclude it's safe to leave out the version bump, at least for the town-distance-only variant?

Anyway, the patch (town distance ONLY) for r23754 is attached. If the savegame version needs to be bumped because I missed something, let me know and I'll update it accordingly.
EDIT: Updated the patch to include savegame version bump
Attachments
minimum_ONLY_town_distance_r23754.patch
updated patch for current trunk revision, now including savegame version bump again
(4.44 KiB) Downloaded 146 times
Last edited by Creat on 15 Jan 2012 15:07, edited 2 times in total.
wleader
Engineer
Engineer
Posts: 123
Joined: 18 May 2007 09:04

Re: Patch: Minimum Town Distance

Post by wleader »

The reason for the save game version bump is that the industry generation code runs when a new industry spawns during game, so that value must be part of the save game. When you have both industry distance and town distance, there is a change to the save game data.

In older versions you couldn't fund a town, but in recent version you can. So the town distance check could now also run during the game. Therefore with the current code, both of these settings should be connected to the save game, and the save game version should bump.

Personally I think it is awesome that this patch still lives.
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: Patch: Minimum Town Distance

Post by Creat »

Thanks for the clarification, I've updated the patch (above) accordingly, just to be on the safe side.

It's worth mentioning that it shouldn't ever matter for single player if you load a game saved without this patch (so feel free to omit the patch to saveload.cpp). If you load it once with and without the patch, and you use the "Fund Town" the result MIGHT be different, but apart from that nothing should change.

Of course for a network game this value needs to be synchronized (which it is) or you might get desyncs upon funding a town (but only then).
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: Patch: Minimum Town Distance

Post by R2dical »

Update to latest nightly.

Edit: To clarify, this only affects towns, industries have the default behaviour (of min 20 tiles from a town centre).
Attachments
Minimum_Town_Distance_r25754.patch
(3.94 KiB) Downloaded 176 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 28 guests