Page 1 of 2

Patch: new town grids (r15096)

Posted: 12 Dec 2008 13:34
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.

Re: Patch: new town grids (r14667)

Posted: 12 Dec 2008 13:36
by Gremnon
And just to show off a bit, a screenshot of each.

Re: Patch: new town grids (r14667)

Posted: 13 Dec 2008 02:37
by athanasios
Now we need more 2x2 buildings. :wink:

Re: Patch: new town grids (r14667)

Posted: 13 Dec 2008 10:52
by robo
Is it possible to make a more realistic grid like the New York grid (240m x 60m)?

Re: Patch: new town grids (r14667)

Posted: 13 Dec 2008 13:22
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

Re: Patch: new town grids (r14667)

Posted: 13 Dec 2008 14:36
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.

Re: Patch: new town grids (r14667)

Posted: 13 Dec 2008 14:43
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:

Re: Patch: new town grids (r14667)

Posted: 15 Dec 2008 03:47
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.)

Re: Patch: new town grids (r14667)

Posted: 15 Dec 2008 11:45
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.

Re: Patch: new town grids (r14667)

Posted: 15 Dec 2008 13:00
by DJ Nekkid
what _also_ would be cool, is haveing different "randoms". one city is 2x2, one is 4x4 etc... :)

Re: Patch: new town grids (r14667)

Posted: 15 Dec 2008 13:03
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.

Re: Patch: new town grids (r14667)

Posted: 15 Dec 2008 16:46
by DJ Nekkid
but doesnt that also include "old" and "improved" ? :)

Re: Patch: new town grids (r14667)

Posted: 15 Dec 2008 17:02
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.

Re: Patch: new town grids (r14667)

Posted: 15 Dec 2008 23:52
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.

Re: Patch: new town grids (r14667)

Posted: 16 Dec 2008 00:02
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

Re: Patch: new town grids (r14667)

Posted: 16 Dec 2008 14:46
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)

Re: Patch: new town grids (r14667)

Posted: 16 Dec 2008 16:38
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. ;-)

Re: Patch: new town grids (r14667)

Posted: 16 Dec 2008 18:30
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).

Re: Patch: new town grids (r14667)

Posted: 16 Dec 2008 21:31
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)

Re: Patch: new town grids (r14667)

Posted: 15 Jan 2009 21:35
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.