Page 6 of 7

Re: Freeform map edges (in trunk since 15190)

Posted: 21 Jan 2009 12:33
by Roujin
congratulations :)

Re: Freeform map edges (in trunk since 15190)

Posted: 21 Jan 2009 12:49
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

Re: Freeform map edges (in trunk since 15190)

Posted: 21 Jan 2009 15:12
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 6292 times

Re: Freeform map edges (in trunk since 15190)

Posted: 22 Jan 2009 02:46
by athanasios
Congratulations.
I was surprised it hit trunk so quickly, but it deserved it.
:D

Re: Freeform map edges (in trunk since 15190)

Posted: 22 Jan 2009 23:10
by mlw_1550
Awesome! Amazing work guys! :bow: :bow: :bow:

Re: Freeform map edges (in trunk since 15190)

Posted: 23 Jan 2009 17:51
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

Re: Freeform map edges (in trunk since 15190)

Posted: 23 Jan 2009 20:13
by Moriarty
It'll certainly help heightmaps - having spain surrounded by water on all sides is a little... unrealisitic.

Re: Freeform map edges (in trunk since 15190)

Posted: 01 Feb 2009 13:07
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! :)

Re: Freeform map edges (in trunk since 15190)

Posted: 09 Feb 2009 02:24
by Zhall
push through to 6.4! :D

Re: Freeform map edges (in trunk since 15190)

Posted: 09 Feb 2009 10:20
by Roujin
Sapphire united wrote:push through to 6.4! :D
uhm... huh?

What exactly do you want?

Re: Freeform map edges (in trunk since 15190)

Posted: 10 Feb 2009 03:35
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.

Re: Freeform map edges (in trunk since 15190)

Posted: 10 Mar 2009 19:57
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 955 times

Re: Freeform map edges (in trunk since 15190)

Posted: 10 Mar 2009 20:03
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.

Re: Freeform map edges (in trunk since 15190)

Posted: 11 Mar 2009 05:12
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.

Re: Freeform map edges (in trunk since 15190)

Posted: 11 Mar 2009 07:29
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.

User-defined background color?

Posted: 13 Feb 2018 00:47
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

Re: Freeform map edges (in trunk since 15190)

Posted: 13 Feb 2018 02:45
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.

Re: Freeform map edges (in trunk since 15190)

Posted: 25 Sep 2018 10:32
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.

Re: Freeform map edges (in trunk since 15190)

Posted: 25 Sep 2018 12:16
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)

Re: Freeform map edges (in trunk since 15190)

Posted: 25 Sep 2018 20:35
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.