Town growth patch
Moderator: OpenTTD Developers
Town growth patch
After posting this: http://tt-forums.net/viewtopic.php?t=21257 I decided to take matters into my own hands. I have never really written anything in C (except from something simple, like Hello World), so this is my first real try on it.
After few hours of mostly reading and a little of coding I had this nice little patch that forces towns to build roads with at least 3 squares between them. Now, any experienced TTD player can see that this would only lead to a lot of unused tiles in the cities, so I also made it possible to build two rows of hoses on each side of a road.
Please comment on the patch, it is probably not very well written but keep in mind that it's my first real C programming.
[edit] Upgraded the diffs after learning to use the svn, this should work better.
After few hours of mostly reading and a little of coding I had this nice little patch that forces towns to build roads with at least 3 squares between them. Now, any experienced TTD player can see that this would only lead to a lot of unused tiles in the cities, so I also made it possible to build two rows of hoses on each side of a road.
Please comment on the patch, it is probably not very well written but keep in mind that it's my first real C programming.
[edit] Upgraded the diffs after learning to use the svn, this should work better.
- Attachments
-
- OTTD.tar.gz
- Linux build (r3073)
- (1.12 MiB) Downloaded 332 times
-
- How it looks
- screenshot.png (70.51 KiB) Viewed 10835 times
-
- town_growth.1.diff
- r3077
original version - (2.14 KiB) Downloaded 409 times
Last edited by scrooge on 23 Oct 2005 03:13, edited 1 time in total.
Great patch, this is a must for OTTD, altough I'd enchance the house building algorythm:
Your patch:
if tile distance from road <= 2
continue house building procedure on tile
My proposal:
if tile distance from road == 1
continue house building procedure on tile
if tile distance from road == 2
and 5 houses surround the tile //fix: was 4
continue house building procedure on tile
No C here, I want everyone to understand and comment this
This way, houses can be built in 3x3 or bigger blocks, butwill not happen
Your patch:
if tile distance from road <= 2
continue house building procedure on tile
My proposal:
if tile distance from road == 1
continue house building procedure on tile
if tile distance from road == 2
and 5 houses surround the tile //fix: was 4
continue house building procedure on tile
No C here, I want everyone to understand and comment this
This way, houses can be built in 3x3 or bigger blocks, but
Code: Select all
HHHHH H - House
HHHHH
RRRRR R - Road
Last edited by MeusH on 21 Oct 2005 19:44, edited 2 times in total.
Or bigger? How would a 4x4 block of houses get built? Or even just 3x4?MeusH wrote:This way, houses can be built in 3x3 or bigger blocks
I can get to
Code: Select all
RRRRR RRRRRR
RHHHR RHHHHR
RH HR and RH HR
RH HR RH HR
RHHHR RHHHHR
RRRRR RRRRRR
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
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
DaleStan wrote:Or bigger? How would a 4x4 block of houses get built? Or even just 3x4?MeusH wrote:This way, houses can be built in 3x3 or bigger blocks
I can get toBut after that, no more houses will be built, because there are no spaces where all 4 sides are by a house.Code: Select all
RRRRR RRRRRR RHHHR RHHHHR RH HR and RH HR RH HR RH HR RHHHR RHHHHR RRRRR RRRRRR
Code: Select all
RRRRR RRRRRR
RHHHR RHHHHR
RHTHR and RHTTHR
RHTHR RHTTHR
RHHHR RHHHHR
RRRRR RRRRRR
Is tile distance from road 2? Yes, it is
Are 5 houses surrounding the tile? Yes, even 7 //fix: 5 was 4
Houses can be built there.
Last edited by MeusH on 21 Oct 2005 19:45, edited 3 times in total.
Why do you think this shouldn't happen?MeusH wrote: This way, houses can be built in 3x3 or bigger blocks, butwill not happenCode: Select all
HHHHH H - House HHHHH RRRRR R - Road
It won't happen if just three houses are close to the tile. Five (fix: was "four") houses in the neighbourhood would allow next house to be built.
This would prevent two lines of houses be built near straight long piece of road
This would prevent two lines of houses be built near straight long piece of road
Last edited by MeusH on 21 Oct 2005 19:46, edited 1 time in total.
Take a look at the attached images:
Yellow tiles - possible house positions in (O)TTD
Blue tiles - possible house positions via this patch
Green tiles - possible house positions via 5 tile check I've proposed
In my method, each tile that is two squares away from the road will make a check whether at least five surrounding tiles are houses. You can see, there will be more houses in town, but there will be no double levels on a straight line. More realistic IMO
Yellow tiles - possible house positions in (O)TTD
Blue tiles - possible house positions via this patch
Green tiles - possible house positions via 5 tile check I've proposed
In my method, each tile that is two squares away from the road will make a check whether at least five surrounding tiles are houses. You can see, there will be more houses in town, but there will be no double levels on a straight line. More realistic IMO
- Attachments
-
- Green tiles - possible house positions via 5 tile check I've proposed
- Fivetiles_check.png (80.19 KiB) Viewed 1466 times
-
- Blue tiles - possible house positions via this patch
- Yourpatch.png (78.84 KiB) Viewed 1477 times
-
- Yellow tiles - possible house positions in (O)TTD
- TTD.png (83.46 KiB) Viewed 1471 times
Ah. You're counting the 8 surrounding tiles. I was as counting 4 out of 4.MeusH wrote:Are 5 houses surrounding the tile? Yes, even 7 //fix: 5 was 4
There's a slight difference there.
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
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Although I don't see very much use in having this restriction it took only few minutes to do, so why not...
But I would like to know why you think this is necessary. The odds of a town building a road in just one direction are very little, and I think that there will be more unbuilt tiles if you use this version (but that may also be because of something I have done in a wrong way).
[edit] Upgraded the diff, should now work with svn.
But I would like to know why you think this is necessary. The odds of a town building a road in just one direction are very little, and I think that there will be more unbuilt tiles if you use this version (but that may also be because of something I have done in a wrong way).
[edit] Upgraded the diff, should now work with svn.
- Attachments
-
- town_growth.2.diff
- r3077
MeusH's algorythm - (3.19 KiB) Downloaded 362 times
Last edited by scrooge on 23 Oct 2005 03:18, edited 1 time in total.
- nicfer
- Director
- Posts: 529
- Joined: 03 May 2005 20:50
- Location: Somewhere in a country called Argentina
I can't download the executable, I'm using FireFox and WinXpSp2
Sorry for my english I am argentinian
TTO don't crashes in Windows XP; XP crashes TTO
Formerly known as UnderBuilder.
MyMiniCity
TTO don't crashes in Windows XP; XP crashes TTO
Formerly known as UnderBuilder.
MyMiniCity
To download the .tar.gz file in Firefox you'll have to right click on it and chose "Save Link As", but although you would download it it would be pretty useless to you because it's a Linux build
But it would be great if someone would provide a windows version.
But it would be great if someone would provide a windows version.
Last edited by scrooge on 22 Oct 2005 18:14, edited 1 time in total.
- webfreakz.nl
- Director
- Posts: 627
- Joined: 11 Aug 2005 08:22
- Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
- Contact:
- nicfer
- Director
- Posts: 529
- Joined: 03 May 2005 20:50
- Location: Somewhere in a country called Argentina
Does this patch prevents towns from building lots of statues/fountains? It will be nice because I hate them because:
- 1. Decreases town population
2. Less passengers and mail will be atracted to my stations.
3. Sometimes, the statues and fountaines are builded above big buildings, that sometimes causes that my stations don't acept mail, goods, or even passengers.
Sorry for my english I am argentinian
TTO don't crashes in Windows XP; XP crashes TTO
Formerly known as UnderBuilder.
MyMiniCity
TTO don't crashes in Windows XP; XP crashes TTO
Formerly known as UnderBuilder.
MyMiniCity
@SLaY3r:
No, it doesn't reduce the number of statues and fountains. But this patch does partly cover your issues, because there will be less roads and more houses, and therefore higher density. It would be nice though to get rid of some of the statues and fountains.
@MeusH:
I used the 'diff' command in linux to produce the patch, is some other application prefered?
No, it doesn't reduce the number of statues and fountains. But this patch does partly cover your issues, because there will be less roads and more houses, and therefore higher density. It would be nice though to get rid of some of the statues and fountains.
@MeusH:
I used the 'diff' command in linux to produce the patch, is some other application prefered?
- webfreakz.nl
- Director
- Posts: 627
- Joined: 11 Aug 2005 08:22
- Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
- Contact:
yes, TortoiseSVN needs a line in the diff which contains something like "Index:". Yours doesn't have this. Therefore I cannot merge your patch with the sourcescrooge wrote: @MeusH:
I used the 'diff' command in linux to produce the patch, is some other application prefered?
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
Thank you for your response, it's nice to see you like it
But about this diff problem: I browsed the forum and google a little, and found out that most of the patches are made against svn. I would like to do that also, but I don't know a thing about svn, other that it is something fancy to get the latest version of a source code
I would appreciate it if some good sole would write a line or two about how I can use this svn, so I can be hip and cool like everybody else
[edit] Never mind, I figured it out right after posting this (how typical). I have also updated the diffs
But about this diff problem: I browsed the forum and google a little, and found out that most of the patches are made against svn. I would like to do that also, but I don't know a thing about svn, other that it is something fancy to get the latest version of a source code
I would appreciate it if some good sole would write a line or two about how I can use this svn, so I can be hip and cool like everybody else
[edit] Never mind, I figured it out right after posting this (how typical). I have also updated the diffs
Yes you can. Get cygwin and use patch ("cd $OTTD_SRC_DIR && patch < $PATCHFILE"). Works beautifully.webfreakz.nl wrote:Therefore I cannot merge your patch with the source
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
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Who is online
Users browsing this forum: Google [Bot] and 43 guests