Freeform map edges (in trunk since 15190)

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

Post Reply
Yexo
Tycoon
Tycoon
Posts: 3653
Joined: 20 Dec 2007 12:49

Freeform map edges (in trunk since 15190)

Post by Yexo » 11 Dec 2008 20:38

The attached patch removes the need for the map edges to be water. You can raise the land / build on it what you want.

No known issues

If you have any suggestions / comments, please let me know.

Latest patch can be downloaded from http://bugs.openttd.org/task/2541

Edit: Fixed a lot of asserts that could happen when you let a train run towards a map edge. Also the map generator is updated so it generates landscapes with land at the borders now. Attached is a screenshot that show how it works and a windows binary.

Changes in r14668_v2:
- Incorporated SmatZ changes to fix the graphical glitch at the southern borders
- Fixed a bug where terragenesis could generate tiles with a height difference of 2 between two neighbouring corners.
- Added a gui option in the map generation window to choose what borders should be water and what borders should be land.
The binary is now v2, the zip still has the same name though.

Changes in r14675_v3:
- When loading a heightmap the border now depends on the heightmap instead of always water.
- Lighthouses are only build near water
- Stations can now be built at tile 0 without errors.
- Loading old (TTD) savegames was broken, now fixed again (thanks SmatZ)

Changes in r14677_v4:
- It was impossible to terraform south-border tiles in the scenario editor
- The white dot drawn when terraforming is now drawn at the correct height for the south-border tiles.

Changes in r14677_v5:
- Lots of bugfixes of bugs reported by Progman, see http://www.tt-forums.net/viewtopic.php?p=751289#p751289 for a complete list.
- Flat tiles at the map edge with height = 0 will get flooded (to prevent maps without any water at all).

Changes in r14577_v6:
- Removed a lot of IsValidTile checks and make GetTileType return MP_VOID for tiles > MapSize()

Changes in r14685_v7:
- Fixed segfault with fences on nw border.

Changes in r14772_v8:
- Tiles at the north edges will be MP_VOID when the patch is enabled.
- Removed lots of IsValidTile calls due to the previous change.
- New patch setting (under construction) to enable/disable terraforming the map edges.
- Known issue: small graphical glitch at the north edges.
- Removed the GetTileType hack introduced in v6.

Changes in r14840_v9:
- Enabling the setting in a running game would fail most of the time.

Changes in r14840_v10:
- Fix the graphical glitch at the north edges (SmatZ)
- A bit of cleanup (removing some unneeded IsValidTile checks)

See http://www.tt-forums.net/viewtopic.php?p=754862#p754862 for the latest patch (some fixes by SmatZ) and a windows/linux binary.
Changes:
- Fix an issue were you couldn't select tiles at the north border if they were raised more than a few height levels.
- Fix a crash if rails tiles went towards an edge of the map (introduced in v10).

Changes in v12:
- MP_VOID tiles could be seen as land for newgrf files (see r14415). (thanks SmatZ)

Changes in v13:
Update to r14905
minor cleanup
Last edited by Yexo on 21 Jan 2009 03:20, edited 24 times in total.

User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Freeform map edges

Post by CommanderZ » 11 Dec 2008 21:15

Oh, this is great! Going to try it once I have some time. Did you modify the map generator too?

Yexo
Tycoon
Tycoon
Posts: 3653
Joined: 20 Dec 2007 12:49

Re: Freeform map edges

Post by Yexo » 11 Dec 2008 21:24

I've not yet modified the map generator, but I'll definitely do that (if you don't do so first :p)

User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Freeform map edges

Post by CommanderZ » 12 Dec 2008 11:57

Yexo wrote:I've not yet modified the map generator, but I'll definitely do that (if you don't do so first :p)
If you want me to... :P

For TGen it is a little change in tgp.cpp...if I recall it well, all you have to do is commenting one or two function calls in terrain normalization function (it is called normalizeHeightmap or something like that).

Yexo
Tycoon
Tycoon
Posts: 3653
Joined: 20 Dec 2007 12:49

Re: Freeform map edges

Post by Yexo » 13 Dec 2008 00:59

Patch updated. I've modified to the map generator, see http://www.tt-forums.net/download/file.php?id=102995

I've attached a windows binary to the first post.

User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Freeform map edges

Post by CommanderZ » 13 Dec 2008 11:15

Beautiful. OTTD terrain posibilities are now really leaping forward.

What about adding a select box into the map generator taht would activate this?

User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13187
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: Freeform map edges

Post by Hyronymus » 13 Dec 2008 11:18

Very nice, someone finally did it :).

User avatar
Zephyris
Tycoon
Tycoon
Posts: 2826
Joined: 16 May 2007 16:59

Re: Freeform map edges

Post by Zephyris » 13 Dec 2008 11:38

How well bug tested is this? I thought some algorithms required a sea level edge square to prevent wraparound, or is there a special invisible square for this?

Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Freeform map edges

Post by Roujin » 13 Dec 2008 12:03

IIRC on the bottom left and bottom right edges, there's a row of invisible tiles, but not on the top left and top right edge.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage

User avatar
Zephyris
Tycoon
Tycoon
Posts: 2826
Joined: 16 May 2007 16:59

Re: Freeform map edges

Post by Zephyris » 13 Dec 2008 12:12

Ah cool, should be ok then...

Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Freeform map edges

Post by Terkhen » 13 Dec 2008 12:22

Yexo wrote:- You'll get graphical glitches if you raise any tiles at the south-east or south-west edge of the map. If there is anyone with an idea of how to solve this, be my guest. I don't know where to start :(
I have tried the patch with the water edges grf, and it seems that there's a not drawn slope between the map tiles and the usually invisible edge tiles. Here's a screenshot:
Attachments
Sin nombre, 1 Ene 1960.png
(167.75 KiB) Downloaded 546 times

User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Freeform map edges

Post by CommanderZ » 13 Dec 2008 12:29

I'm not really sure what the patch is supposed to do with the grf :)

SmatZ
OpenTTD Developer
OpenTTD Developer
Posts: 351
Joined: 03 Oct 2006 18:26
Location: Prague, Czech Republic
Contact:

Re: Freeform map edges

Post by SmatZ » 13 Dec 2008 12:30

Hello,

I like this patch :) Though it doesn't compile for me: (gcc 4.3.2, amd64)

Warnings:

Code: Select all

src/ai/default/default.cpp: In function 'void AiStateRemoveStation(Company*)':
src/ai/default/default.cpp:3677: warning: 'tile' may be used uninitialized in this function

src/terraform_cmd.cpp: In function 'CommandCost TerraformTileHeight(TerraformerState*, TileIndex, int)':
src/terraform_cmd.cpp:192: warning: comparison between signed and unsigned integer expressions
src/terraform_cmd.cpp:193: warning: comparison between signed and unsigned integer expressions
Errors:

Code: Select all

src/roadveh_cmd.cpp: In function 'Trackdir RoadFindPathToDest(Vehicle*, TileIndex, DiagDirection)':
src/roadveh_cmd.cpp:1196: error: jump to label 'found_best_track'
src/roadveh_cmd.cpp:1042: error:   from here
src/roadveh_cmd.cpp:1047: error:   crosses initialization of 'TrackdirBits trackdirs'
src/roadveh_cmd.cpp:1046: error:   crosses initialization of 'TrackdirBits red_signals'
src/roadveh_cmd.cpp:1045: error:   crosses initialization of 'TrackStatus ts'
edit: fixing that error is quite easy :)
Image

SmatZ
OpenTTD Developer
OpenTTD Developer
Posts: 351
Joined: 03 Oct 2006 18:26
Location: Prague, Czech Republic
Contact:

Re: Freeform map edges

Post by SmatZ » 13 Dec 2008 12:43

Attached patch fixes compilation for me and probably makes those glitches disappear ;)

(maybe a hack, maybe not working. further issue may be not marking border tiles dirty, if this patch doesn't fix all cases )

edit: fixed one case
It doesn't look good when non-black void tiles are used... maybe SPR_SHADOW_CELL could be replaced by different sprite.
Attachments
edges_r14668_clean.diff
(57.08 KiB) Downloaded 134 times
Last edited by SmatZ on 13 Dec 2008 14:39, edited 1 time in total.
Image

Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Freeform map edges

Post by Terkhen » 13 Dec 2008 13:48

CommanderZ wrote:I'm not really sure what the patch is supposed to do with the grf :)
I meant that the invisible edge tiles are still at height 0. There's a "cliff" between real map tiles and invisible edge tiles. The space between tiles isn't drawn (even if it was meant to be black) and that's what creates the glitches. I used the grf just to see the height of the invisible tiles.

Yexo
Tycoon
Tycoon
Posts: 3653
Joined: 20 Dec 2007 12:49

Re: Freeform map edges

Post by Yexo » 13 Dec 2008 23:15

Updated the patch, see first post for new diff and changelog. Big thanks to SmatZ for fixing the graphical glitches.
Zephyris wrote:How well bug tested is this? I thought some algorithms required a sea level edge square to prevent wraparound, or is there a special invisible square for this?
As much as possible :) Only currently known bug is that building a station at tile 0 gives strange results.
Roujin wrote:IIRC on the bottom left and bottom right edges, there's a row of invisible tiles, but not on the top left and top right edge.
Correct.
Terkhen wrote:I have tried the patch with the water edges grf, and it seems that there's a not drawn slope between the map tiles and the usually invisible edge tiles. Here's a screenshot:
Where can I find said grf?

Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Freeform map edges

Post by Terkhen » 13 Dec 2008 23:26

Here.

I'm going to try the new version right now :D

Edit: I can't compile it with MinGW in windows vista.

Code: Select all

[SRC] Compiling ai/ai.cpp
make[1]: execvp: g++: Invalid argument
make[1]: *** [ai/ai.o] Error 127
I've never seen this error, and I can't find a solution. What can be causing it? :?

PhilSophus
Chairman
Chairman
Posts: 776
Joined: 20 Jan 2007 12:08
Location: Germany

Re: Freeform map edges

Post by PhilSophus » 14 Dec 2008 13:47

Terkhen wrote:

Code: Select all

[SRC] Compiling ai/ai.cpp
make[1]: execvp: g++: Invalid argument
make[1]: *** [ai/ai.o] Error 127
I've never seen this error, and I can't find a solution. What can be causing it? :?
That looks as if there is something wrong with your gcc installation rather than with the patch (did you try compiling clean trunk? Probably the same happens). execvp is a function replacing the currently running executable by another one (I'd guess in this case the gcc frontend calling the g++ backend).
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008

Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Freeform map edges

Post by Terkhen » 14 Dec 2008 15:31

Clean trunk compilation runs with no problems at all. The same is true for every other patch I use. I think the error happens with the first file that isn't at the src folder.

Yexo
Tycoon
Tycoon
Posts: 3653
Joined: 20 Dec 2007 12:49

Re: Freeform map edges

Post by Yexo » 14 Dec 2008 15:43

I have no idea what can be causing that error, but my patch doesn't change ai.cpp at all.

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 5 guests