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

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

Re: Freeform map edges (in trunk since 15190)

Post by Roujin »

congratulations :)
* @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
Hypolite
Engineer
Engineer
Posts: 126
Joined: 10 Jan 2009 07:20
Location: Paris, france

Re: Freeform map edges (in trunk since 15190)

Post by Hypolite »

A logical enhancement, appreciate it (though I won't be able to use it 'til the cargodest build hit r15190, I guess) :D
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Freeform map edges (in trunk since 15190)

Post by HackaLittleBit »

Very nice and congratulations.
See the photo of a game that I made in ttdPatch long time ago hope it gives you ideas.
See little water plane landing on top of the mountain. :wink:
Mountain with waterplane
Mountain with waterplane
mountainEdge.png (262.67 KiB) Viewed 6145 times
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: Freeform map edges (in trunk since 15190)

Post by athanasios »

Congratulations.
I was surprised it hit trunk so quickly, but it deserved it.
:D
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
mlw_1550
Engineer
Engineer
Posts: 98
Joined: 08 Mar 2004 00:39
Location: Good ol' Portugal

Re: Freeform map edges (in trunk since 15190)

Post by mlw_1550 »

Awesome! Amazing work guys! :bow: :bow: :bow:
That's CP 1564, a Montreal Locomotives Works built locomotive
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5656
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Freeform map edges (in trunk since 15190)

Post by andythenorth »

Great patch, thanks.

For those who are trying freeform map edges in the latest nightly, go to advanced settings, and then in the 'construction' menu node, 'Enable terraforming the tiles at the map borders'.

cheers,

Andy
Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Re: Freeform map edges (in trunk since 15190)

Post by Moriarty »

It'll certainly help heightmaps - having spain surrounded by water on all sides is a little... unrealisitic.
User avatar
Bob Smith
Engineer
Engineer
Posts: 111
Joined: 17 May 2005 23:25

Re: Freeform map edges (in trunk since 15190)

Post by Bob Smith »

While this works fine for me when generating a new map, it only works properly on two edges of the map when loading a heightmap (specifically the bottom two eges don't have any sea, but they still slope down to zero height). I'm running r15297. Note I can raise the edges back up manually, so I suppose it's a problem with the heightmap loading rather than the new feature itself.

Please don't shoot me if this is a known issue but I couldn't see anything form skimming the last couple of pages from this thread.

I very much like this new feature though! :)
User avatar
Zhall
Tycoon
Tycoon
Posts: 1237
Joined: 17 Jul 2007 01:36
Skype: moonray_zdo
Location: Teh matrix, duh.
Contact:

Re: Freeform map edges (in trunk since 15190)

Post by Zhall »

push through to 6.4! :D
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Freeform map edges (in trunk since 15190)

Post by Roujin »

Sapphire united wrote:push through to 6.4! :D
uhm... huh?

What exactly do you want?
* @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
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: Freeform map edges (in trunk since 15190)

Post by belugas »

Sapphire united wrote:push through to 6.4! :D
Poor you... You still fail to understand how it works :(

a) It would not be 6.4, it would be 0.6.4
b) if 0.6.4 would eventually come out, it will be bug fixes ONLY.
c) I can positively point out that there will be no 0.6.4, since there will be a 0.7.0. One day.
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Freeform map edges (in trunk since 15190)

Post by ic111 »

Hello,

I am just adjusting the more heightlevels patch to the freeform map edges patch. What makes me trouble are slopes at the map edges.

Example: Consider a 256x256 map. z(x,y) is the height at position (x,y). Let z(154,255)=22, z(155,255)=22, z(156,255)=21. So (155,255) has slope NE. If you scroll southeast, you have to paint the black area properly in order to avoid glitches resulting from areas of the map still being displayed where now black area has to be painted.

My idea to deal with this is assigning points outside the map a height as well, based on the heights at the map edges. Then, I can paint black tiles with the correct slope there. For example, for the tiles mentioned above (y now is any number > 255), z(154,y)=22, z(155,y)=22, z(156,y)=21. This way, any tile southeast of the map at y position 155 would be a Slope NE. Same for the areas northeast, northwest and southwest of the map. I wrote an alternative TileHeightOutsideMap function as follows:

Code: Select all

static inline uint TileHeightOutsideMap(int x, int y) 
{
  if (x < 1) {
	if (y < 1) {
	  return TileHeight(TileXY(1, 1));
	} else if (y < (int)MapMaxY()) {
	  return TileHeight(TileXY(1, y));
	} else {
	  return TileHeight(TileXY(1, (int)MapMaxY()));
	}
  } else if (x < (int)MapMaxX()) {
	if (y < 1) {
	  return TileHeight(TileXY(x, 1));
	} else if (y < (int)MapMaxY()) {
	  return TileHeight(TileXY(x, y));
	} else {
	  return TileHeight(TileXY(x, (int)MapMaxY()));
	}
  } else {
	if (y < 1) {
	  return TileHeight(TileXY((int)MapMaxX(), 1));
	} else if (y < (int)MapMaxY()) {
	  return TileHeight(TileXY((int)MapMaxX(), y));
	} else {
	  return TileHeight(TileXY((int)MapMaxX(), (int)MapMaxY()));
	}
  }
}
Based on this concept of heights outside map, I can rewrite the painting code in viewport.cpp for tiles outside map as follows:

Code: Select all

				} else {
					// We are outside the map => paint black
					tile_info.tile = 0;
					tile_info.tileh = GetTileSlopeOutsideMap(tile_info.x, tile_info.y, &tile_info.z);
					tile_type = MP_VOID;
				}
I am pretty sure that this works, except for one problem. The drawing procedure for the black tile called some lines later unfortunately ignores the slope and paints the tile like if it is flat. See attached screenshot for what I mean.

I think, what we would need here, are just black images for the slopes NE, SW, NW, SE (and/or make the painting code paint them :D ). What I unfortunately not know is how to implement them. If I get it right, the solution originally implemented in the freeform map edges patch for the problem I described above is the following code:

Code: Select all

			} else {
				if (!_settings_game.construction.freeform_edges || (TileX(tile) != 0 && TileY(tile) != 0)) {
					if (x_cur == ((int)MapMaxX() - 1) * TILE_SIZE || y_cur == ((int)MapMaxY() - 1) * TILE_SIZE) {
						uint maxh = max<uint>(TileHeight(tile), 1);
						for (uint h = 0; h < maxh; h++) {
							DrawGroundSpriteAt(SPR_SHADOW_CELL, PAL_NONE, ti.x, ti.y, h * TILE_HEIGHT);
						}
					}

					ti.tile = tile;
					ti.tileh = GetTileSlope(tile, &ti.z);
					tt = GetTileType(tile);
				}
 			}
So you simply paint: For each tile in the black area, one black tile per height level of that tile. I don't think that painting that many images is resonable with more height levels.

So: Can anyone help solving the problem I described above?
Glitches at the map edge.
Glitches at the map edge.
Unbenannt, 16. Nov 1962.png (78.3 KiB) Viewed 808 times
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Freeform map edges (in trunk since 15190)

Post by Yexo »

ic111 wrote:So you simply paint: For each tile in the black area, one black tile per height level of that tile. I don't think that painting that many images is resonable with more height levels.
Have you already tried if this works? It would by far be the simplest solution.
So: Can anyone help solving the problem I described above?
Unfortunatly I don't think I can, the code to fix this in the freeform map edges patch was written by SmatZ.
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Freeform map edges (in trunk since 15190)

Post by ic111 »

First thanks for your answer, although you couldn't give me the informations I need.

Well, I mainly meant resonable in terms of efficiency. If I get it right, the freeform edges algorithm would paint <heightlevel> images for each black tile?

And as I already have implemented an adapted algorithm (more things had to be changed for the more heightlevels patch, e.g. the selection of the to-be-updated tiles), I think providing / painting images for sloped tiles (they are basically what I am missing so far) would be easier and better.

I will have a closer look on how I can do this soon.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Freeform map edges (in trunk since 15190)

Post by Yexo »

ic111 wrote:First thanks for your answer, although you couldn't give me the informations I need.

Well, I mainly meant resonable in terms of efficiency. If I get it right, the freeform edges algorithm would paint <heightlevel> images for each black tile?
I thought it only does that for the tiles at the south edge, so only for tiles with coordinates (MaxX, ?) and (?, MaxY). If that's true, it isn't a problem at all to do that for some more heightlevels.
GojkoG
Engineer
Engineer
Posts: 14
Joined: 06 Dec 2017 18:45

User-defined background color?

Post by GojkoG »

Hi everyone!
I’m building a new map to play on, and the first time I use the feature to build to the edges. But one thing bothers me: the black background. I really get depressed when I’m in the edge areas. Could there be a feature to select another background color like in my screenshot? I find it much more friendly there. (There was a NewGRF which made everything to water, but it’s not working anymore.)
Regards. GojkoG
Attachments
Background-Color.png
(335.57 KiB) Not downloaded yet
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Freeform map edges (in trunk since 15190)

Post by Eddi »

the way the edge is drawn was changed when more heightlevels was introduced, so the existing newgrfs don't work anymore. it is not anymore a special black sprite drawn as a tile, but the grass/dirt sprite with an all-black recolour map

but it should be possible to make a newgrf again, which just replaces this recolour map.
GojkoG
Engineer
Engineer
Posts: 14
Joined: 06 Dec 2017 18:45

Re: Freeform map edges (in trunk since 15190)

Post by GojkoG »

Thanks for the hint, Eddi.
Since I figured out how NewGRFs work, I might find a way. I now understand that the sprites 3924 to 39.. are paited beyond the edge depending on the edge tile. Now I have to find how to apply a palette on these over-the-edge tiles.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Freeform map edges (in trunk since 15190)

Post by Eddi »

the palette used for the map border is: action 5 type 18 (https://newgrf-specs.tt-wiki.net/wiki/Action5https://github.com/OpenTTD/OpenTTD/blob ... alette.nfo), or if you use NML, you need a "replacenew" block with type "OTTD_RECOLOUR" (https://newgrf-specs.tt-wiki.net/wiki/N ... ew_sprites)
GojkoG
Engineer
Engineer
Posts: 14
Joined: 06 Dec 2017 18:45

Re: Freeform map edges (in trunk since 15190)

Post by GojkoG »

Thank you again, Eddi. But I don’t get it to work in my NFO file. So I guess I do something wrong.

Am I right that I have an Action 5 type 18 line followed by a recolor sprite (https://newgrf-specs.tt-wiki.net/wiki/RecolorSprites)?
I want to change every color index to color 99 from the Windows palette (light blue). (https://newgrf-specs.tt-wiki.net/wiki/P ... s#Palettes)

What do I do wrong here? GRFcodec doesn’t complain.

Code: Select all

10 * 3     05 18 01
11 * 257   00 99 99 99 99 99 . . . 99  (256 times "99")
Unfortunately the wiki doesn’t explain type 18.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 9 guests