Patch: new town grids (r15096)

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

User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Patch: new town grids (r15096)

Post by Gremnon »

New version based against r15096! Go to this post to get it.

What the new version does:
Pre-Set grids are a thing of the past! You can now choose the X and Y values yourself, anywhere from 1 to 10.
1, of course, isn't very useful. I'll remove that in the next version.

Also, the minor problem of towns sometimes building where the grid's road should go has been fixed... mostly. Once in a while, especially when two towns are close by, they'll still build in the way, but that's not often.

Finally, a note to anyone who looks at the patch's code.... yes, there's a line in the english strings file that says not to remove the two lines underneath - if you don't beleve me that it's needed, take them out, and compile - the other languages throw up a load of warnings. I could fix that, but I don't speak any other language to translate the three new strings, so anyone who wants to help with that is welcome to PM me the translations for the other languages.

===========
Original Post:
At last, my first patch!
Ahem.

Small patch at the moment, what this does is add into the economy tab's settings the option to have towns in grids of 4x4 and 5x5. Both have a few small issues still, such as sometimes a 2x2 or larger building will block one of the roads, and on 5x5, there's often empty space in the middle of the grid.

Both have been tested in the editor and in game, though so far not with the town funding patch, although I doubt there will be any issues there.

It shouldn't be too much of a problem to add any more new grid sizes in, and I think it's possible to do something like 3X5, though I'm still looking into that.

Attached is the diff against r14667 and a prepatched windows binary.
Attachments
newtowngrid_r14667.diff
diff against trunk r14667
(3.06 KiB) Downloaded 367 times
newgrids_r14667.zip
windows binary
(3.42 MiB) Downloaded 413 times
Last edited by Gremnon on 15 Jan 2009 21:36, edited 3 times in total.
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: new town grids (r14667)

Post by Gremnon »

And just to show off a bit, a screenshot of each.
Attachments
The 4x4 grid
The 4x4 grid
4x4.png (88.77 KiB) Viewed 1883 times
The 5x5 grid
The 5x5 grid
5x5.png (146.1 KiB) Viewed 2026 times
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: Patch: new town grids (r14667)

Post by athanasios »

Now we need more 2x2 buildings. :wink:
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.
User avatar
robo
Route Supervisor
Route Supervisor
Posts: 398
Joined: 14 Jan 2007 12:14

Re: Patch: new town grids (r14667)

Post by robo »

Is it possible to make a more realistic grid like the New York grid (240m x 60m)?
PhilSophus
Chairman
Chairman
Posts: 776
Joined: 20 Jan 2007 12:08
Location: Germany

Re: Patch: new town grids (r14667)

Post by PhilSophus »

athanasios wrote:Now we need more 2x2 buildings. :wink:
Now we need even larger buildings (doing some advertising for FS#1983) :wink:

I dream of a Mars scenario, having 4x4 domes as town buildings.
robo wrote:Is it possible to make a more realistic grid like the New York grid (240m x 60m)?
Indeed something like, 2x3, 2x4 and 3x4 (and maybe 3x5) would be nice.
Gremnon wrote:and I think it's possible to do something like 3X5, though I'm still looking into that.
Ahh, you are already considering that :D
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: new town grids (r14667)

Post by Gremnon »

Yes, already working on it. I've sucessfully added in a 4x8 one, but it doesn't appear to like creating a patch.
What I'm going to attempt to work on (when I have a little more free time) is a slight change to the way the patch setting works, and split into three parts.

The first will act the same as it does currently, choosing random, better roads, etc. Instead of 3X3 or other grids in there, it'll show Geometric Grid.
When that's on, the other two patch settings get read, one defining the X for the grid, the other the Y.

IF I can get it to work, it'll mean people can customise how many in each direction.
PhilSophus
Chairman
Chairman
Posts: 776
Joined: 20 Jan 2007 12:08
Location: Germany

Re: Patch: new town grids (r14667)

Post by PhilSophus »

Gremnon wrote:[separate patch settings]
Yes, this sounds reasonable.
Gremnon wrote:(when I have a little more free time)
No need to hurry :wink:
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
Teeg
Engineer
Engineer
Posts: 55
Joined: 31 Jul 2007 23:57

Re: Patch: new town grids (r14667)

Post by Teeg »

What would be really neat is if you could have the grid expand as a town develops. It would mean you had to work with specific (and wonky) numbers, but it'd be super-nifty.

What I mean by that:
- Suburbs are built at 2x2
- Inner city is 5x2
- Downtown is 5x5

The major problem (aside from the fact that it might be impossible to code) is its possible effect on bus service. (Tram service doesn't run on roads, so if you only demolish the road, the tram will continue uninterrupted. Busses, to use a bad metaphor, aren't quite in the same boat.)
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: new town grids (r14667)

Post by Gremnon »

It's an interesting idea, but at the moment it's enough trouble adding nonuniform grids such as 2x5 or similar without breaking something else... I did manage to get a 4x8 one, which unfortunatly stopped the 5x5 grid working.

Maybe if/when I can figure out how to make the code support that.
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Patch: new town grids (r14667)

Post by DJ Nekkid »

what _also_ would be cool, is haveing different "randoms". one city is 2x2, one is 4x4 etc... :)
Member of the
ImageImage
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: new town grids (r14667)

Post by Gremnon »

That I think is handled in existing 'random' option, though having never used that, I can't say for sure.
If it does, and it uses the new ones as well as the old...
hm.... now you've got me curious, time I did some more to this patch.

Edit: As I thought, setting the town road layout to 'random' before starting a new game will do what you're thinking of.
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Patch: new town grids (r14667)

Post by DJ Nekkid »

but doesnt that also include "old" and "improved" ? :)
Member of the
ImageImage
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: new town grids (r14667)

Post by Gremnon »

Unfortunatly so... I'm looking into that too, just random grids would be nice, but at the moment I'm having a little trouble understanding some of the code... C++ isn't something I've actually learned properly, I'm sort of picking it up as I go along.
So it's a bit of a surprise to find not only my first patch works, but works first time... let alone adding all the extra things that could improve it. But I'm working on it.
phil88
Transport Coordinator
Transport Coordinator
Posts: 267
Joined: 25 Jan 2007 23:26

Re: Patch: new town grids (r14667)

Post by phil88 »

It'd be nice if all towns' roads were on the same grid, so that when they grow into each other, their roads line up and they're not all botched.
- Phil
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: new town grids (r14667)

Post by Gremnon »

There was a patch some time ago, on Flyspray IIRC, that did that. If that patch still works, I don't know, and how it worked is beyond me at the moment too, but if anyone feels like finding that old patch out and updating it, I'll see if I can resolve and conflicts between it, and my patch
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Patch: new town grids (r14667)

Post by Zuu »

One method:
Given you have the x and y coordinate of a tile.

if x%3 == 0 or y%3 == 0
=> build road

Where x%3 gives the remainder from dividing x with 3. So if x is 8 then the reminder becomes 2. (2*3 => 6; 8-6 => 2)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: Patch: new town grids (r14667)

Post by SirkoZ »

Great patch idea, Gremnon!

It would be really nice if you can implement Teeg's ideas for different patterns under 1 setting (perhaps named New York layout).

I wish you lots of success coding it. ;-)
User avatar
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Re: Patch: new town grids (r14667)

Post by cirdan »

phil88 wrote:It'd be nice if all towns' roads were on the same grid, so that when they grow into each other, their roads line up and they're not all botched.
Coincidentally, I recently submitted a patch to flyspray that does exactly that, by only placing towns during map generation at the right places.
Gremnon wrote:There was a patch some time ago, on Flyspray IIRC, that did that.
I also seem to remember a previous patch to this effect, but I was unable to find it (so I coded a new one).
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: new town grids (r14667)

Post by Gremnon »

Ah, that's useful... I'll take a glance into it when I finally get some free time (read: sometime in the new year)
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: new town grids (r14667)

Post by Gremnon »

New version against r15096

The details (Also at the top of the first post, for those who decide to read there first)

What the new version does:
Pre-Set grids are a thing of the past! You can now choose the X and Y values yourself, anywhere from 1 to 10.
1, of course, isn't very useful. I'll remove that in the next version.

Also, the minor problem of towns sometimes building where the grid's road should go has been fixed... mostly. Once in a while, especially when two towns are close by, they'll still build in the way, but that's not often.

Finally, a note to anyone who looks at the patch's code.... yes, there's a line in the english strings file that says not to remove the two lines underneath - if you don't beleve me that it's needed, take them out, and compile - the other languages throw up a load of warnings. I could fix that, but I don't speak any other language to translate the three new strings, so anyone who wants to help with that is welcome to PM me the translations for the other languages.

And now, what you've been waiting for (maybe)... the download.
Attachments
newtowngrids_r15096.patch
The patch, against r15096
(9.03 KiB) Downloaded 278 times
Post Reply

Return to “OpenTTD Development”

Who is online

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