resurrection of diagonal level and clear patch

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

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: resurrection of diagonal level and clear patch

Post by petert »

Can you remind me what tieliter is?
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: resurrection of diagonal level and clear patch

Post 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.
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: resurrection of diagonal level and clear patch

Post 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
Attachments
OpenTTD_Crash.zip
(572.39 KiB) Downloaded 134 times
diaglvl_win32_r18577_CRASH.rar
(3.27 MiB) Downloaded 135 times
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: resurrection of diagonal level and clear patch

Post 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)
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: resurrection of diagonal level and clear patch

Post 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).
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: resurrection of diagonal level and clear patch

Post 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()
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: resurrection of diagonal level and clear patch

Post 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.
Attachments
cargodist_win32_r18625.rar
(3.37 MiB) Downloaded 131 times
cargodist_PDB_win32_r18625.rar
(2.79 MiB) Downloaded 133 times
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

I'm aware of the bug but I don't have a lot of time at the moment.
The guy on the picture is not me, it's Alonso.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: resurrection of diagonal level and clear patch

Post 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/
Last edited by Terkhen on 28 Dec 2009 23:54, edited 1 time in total.
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: resurrection of diagonal level and clear patch

Post by petert »

Do you have a clean hotfix so I can apply that over new patches?
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: resurrection of diagonal level and clear patch

Post 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.
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post 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.
The guy on the picture is not me, it's Alonso.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: resurrection of diagonal level and clear patch

Post 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.
Last edited by Terkhen on 02 Jan 2010 12:19, edited 1 time in total.
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post 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.
The guy on the picture is not me, it's Alonso.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: resurrection of diagonal level and clear patch

Post by Terkhen »

It seems that the cake is a lie... In that case the fixed version updated to trunk will do ;)
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: resurrection of diagonal level and clear patch

Post 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
Attachments
diaglvl_win32_r18683.rar
(3.24 MiB) Downloaded 128 times
diaglvl_PDB_win32_r18683.rar
(2.56 MiB) Downloaded 125 times
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post 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. ;)
The guy on the picture is not me, it's Alonso.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: resurrection of diagonal level and clear patch

Post 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);
			}
Attachments
diaglvl_r18730.diff
(27.63 KiB) Downloaded 138 times
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: resurrection of diagonal level and clear patch

Post 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
Attachments
diaglvl_win32_r18715.rar
(2.99 MiB) Downloaded 129 times
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: resurrection of diagonal level and clear patch

Post 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
Attachments
gf6ae587a-diaglvl_win32.rar
(2.99 MiB) Downloaded 126 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Amazon [Bot] and 17 guests