Page 4 of 5

Re: resurrection of diagonal level and clear patch

Posted: 20 Dec 2009 18:54
by petert
Can you remind me what tieliter is?

Re: resurrection of diagonal level and clear patch

Posted: 20 Dec 2009 19:01
by Gremnon
I'm not entierly sure. I just remember that reading the flyspray task for it, it said one had to be applied on top of the other in one of the comments further down.

If you search for 'diagonal' on Flyspray, you should find it, have a read. It's one of the last comments to the task.

Re: resurrection of diagonal level and clear patch

Posted: 20 Dec 2009 19:34
by petert
I get a crash when trying to use the diagonal level at the corner of the map.

Steps used to reproduce:
  1. Start OpenTTD
  2. Start a new game with following settings:
    Image
  3. Cheat yourself about $300,000,000
  4. Go to the very bottom of the map
  5. Lower some land so that the very bottom corner is sea
  6. Try to use Diagonal Level to go from the corner up
  7. Crash

Re: resurrection of diagonal level and clear patch

Posted: 20 Dec 2009 19:44
by Gremnon
Can I ask, does this happen only on the bottom corner, or does it affect all four? (Can't test. Accidentally killed computer. Am on the Internet channel on my Wii)

Re: resurrection of diagonal level and clear patch

Posted: 20 Dec 2009 19:47
by petert
Strangely enough, it happens on the most northern corner (top), most southern corner (bottom), and most eastern corner (right), but it has yet to happen on the most western corner (left).

Re: resurrection of diagonal level and clear patch

Posted: 20 Dec 2009 20:14
by Terkhen
I have tested this crash setting all edges to water. The crash is not related to map corners; trying any diagonal terraform at the upper left border or at the lower right border will trigger the following assertion:

Code: Select all

src/tile_map.h: tile < MapSize()

Re: resurrection of diagonal level and clear patch

Posted: 24 Dec 2009 20:20
by petert
I'm compiled with the latest patch and I still get the same crash, this time I've uploaded the PDB debugging file.

Re: resurrection of diagonal level and clear patch

Posted: 25 Dec 2009 09:49
by fonso
I'm aware of the bug but I don't have a lot of time at the moment.

Re: resurrection of diagonal level and clear patch

Posted: 28 Dec 2009 19:25
by Terkhen
I managed to solve the crash. At the SetSelectionTilesDirty() function (viewport.cpp), the following line was missing a check.

Code: Select all

-				MarkTileDirtyByTile(TileXY(x / TILE_SIZE, y / TILE_SIZE));
+				if (TileXY(x / TILE_SIZE, y / TILE_SIZE) < MapSize()) MarkTileDirtyByTile(TileXY(x / TILE_SIZE, y / TILE_SIZE));
Edit: Patch removed. An updated version can be found at http://fickzoo.com/fonsinchen/patches/against_trunk/

Re: resurrection of diagonal level and clear patch

Posted: 28 Dec 2009 22:26
by petert
Do you have a clean hotfix so I can apply that over new patches?

Re: resurrection of diagonal level and clear patch

Posted: 28 Dec 2009 22:39
by Terkhen
I don't. From what I know about how git works I think that it would be easy to create a diff against diagonal level and clear instead of against trunk, but learning git is still one of my pending subjects. I prefer to work with complete diff files anyways.

Re: resurrection of diagonal level and clear patch

Posted: 28 Dec 2009 23:47
by fonso
the problem is fixed in today's version. And I'll send some cookies to anyone who posts a useful patch preventing the first tiles outside the map on the lower borders to be marked as selected when demolishing diagonally.

Re: resurrection of diagonal level and clear patch

Posted: 29 Dec 2009 08:35
by Terkhen
I love cookies :D

At DrawTileSelection(const TileInfo *ti) in viewport.cpp, add the following line.

Code: Select all

 	if (_thd.diagonal) { // We're drawing a 45 degrees rotated (diagonal) rectangle
 		if (IsInsideRotatedRectangle((int)ti->x, (int)ti->y)) {
 			if (_thd.drawstyle & HT_RECT) { // highlighting a square (clear land)
+				if (TileX(ti->tile) == MapMaxX() || TileY(ti->tile) == MapMaxY()) return;
 				SpriteID image = SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh];
 				DrawSelectionSprite(image, _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE, ti, 7, FOUNDATION_PART_NORMAL);
 			} else { // highlighting a dot (level land)
Edit: Patch removed.

Re: resurrection of diagonal level and clear patch

Posted: 01 Jan 2010 17:27
by fonso
Terkhen wrote:I love cookies :D
Thanks for the patch and Congratulations! the cookies are yours. You may now choose between:

a, a fine selection of HTML cookies scraped from a bot-infested windows zombie
b, (fake space) cake
c, fake (space cake)
d, the christmas present I got from my grandmother

And you might want to tell me where to send them.

Re: resurrection of diagonal level and clear patch

Posted: 01 Jan 2010 19:01
by Terkhen
It seems that the cake is a lie... In that case the fixed version updated to trunk will do ;)

Re: resurrection of diagonal level and clear patch

Posted: 01 Jan 2010 22:53
by petert
Hello,
Here is an updated build using Terkhen's new patch. It was built with MSVC against r18683.

Disclaimer:
If diaglvl crashes, do not report it to the OpenTTD developers. Report it to this thread. When making your post about the crash, please upload the crash.dmp, crash.log, crash.sav, and crash.png (only available as of r18184, so if you are using a build older than that, don't bother). These files are vital to finding what happened during the crash. Also note that the PDB file attached is not needed when testing diaglvl, it is mainly for developers.

Peter

Re: resurrection of diagonal level and clear patch

Posted: 04 Jan 2010 02:19
by fonso
Terkhen wrote:It seems that the cake is a lie... In that case the fixed version updated to trunk will do ;)
The current version (and the previous one ...) contains the fix. And how can you tell if the cake is a lie? I'm fairly sure you don't know my grandmother. ;)

Re: resurrection of diagonal level and clear patch

Posted: 05 Jan 2010 12:48
by Terkhen
Sorry, I couldn't avoid the Portal reference :D

I have updated the patch to current trunk, solving a reject at terraform_cmd. There was also a change caused by r18702: when using diagonal raise / lower / level land, the points showing the selected terrain did not appear anymore. What was DrawGroundSpriteAt is now AddTileSpriteToDraw. At viewport.cpp:

Code: Select all

			} else { // highlighting a dot (level land)
				/* Figure out the Z coordinate for the single dot. */
				byte z = ti->z;
				if (ti->tileh & SLOPE_N) {
					z += TILE_HEIGHT;
					if (!(ti->tileh & SLOPE_S) && (ti->tileh & SLOPE_STEEP)) {
						z += TILE_HEIGHT;
					}
				}
-				DrawGroundSpriteAt(_cur_dpi->zoom != 2 ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z);
+				AddTileSpriteToDraw(_cur_dpi->zoom != 2 ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z);
			}

Re: resurrection of diagonal level and clear patch

Posted: 07 Jan 2010 00:41
by petert
Here's another build, r18715, MSVC. Sorry Terkhen, I used fonso's patch from his repo. I will use yours when he implements it into the git repo.

Disclaimer:
If diaglvl crashes, do not report it to the OpenTTD developers. Report it to this thread. When making your post about the crash, please upload the crash.dmp, crash.log, crash.sav, and crash.png (only available as of r18184, so if you are using a build older than that, don't bother). These files are vital to finding what happened during the crash. For developers, you can find the PDB file and other files at this site: http://users.tt-forums.net/petert/dev/

Peter

Re: resurrection of diagonal level and clear patch

Posted: 11 Jan 2010 00:59
by petert
Hey again,
I've done another compile, but this time with git. I'm not sure if I did this correctly, because I used the following commands:

Code: Select all

git clone http://fickzoo.com/fonsinchen/openttd.git/
git checkout origin/diaglvl
git checkout -b diaglvl
Disclaimer:
If diaglvl crashes, do not report it to the OpenTTD developers. Report it to this thread. When making your post about the crash, please upload the crash.dmp, crash.log, crash.sav, and crash.png (only available as of r18184, so if you are using a build older than that, don't bother). These files are vital to finding what happened during the crash. For developers, you can find the PDB file and other files at this site: http://users.tt-forums.net/petert/dev/

Peter