More height levels (in trunk since r27010)

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
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: More height levels

Post by CommanderZ »

Thief^ wrote:I'd prefer for flatter slopes to be added.

You don't tend to get cliffs that are particularly tall in the real world, and you'd rarely get stuff built below them. They're not a big thing to be missing. But the only slope being 1/3 (if not steeper) is horribly wrong. Most trains couldn't go up a slope that steep at all.
It was already said - it might be true ando someone might address this issue in future, but it won't be now and in this patch.

ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: More height levels

Post by ic111 »

Thief^ wrote:I'd prefer for flatter slopes to be added.

You don't tend to get cliffs that are particularly tall in the real world, and you'd rarely get stuff built below them. They're not a big thing to be missing. But the only slope being 1/3 (if not steeper) is horribly wrong. Most trains couldn't go up a slope that steep at all.
Because of this fact, I always play with the rule to myself that after a railway ascends by one height level, there must be at least 5 flat tiles until it ascends for the next heightlevel. This way, your railways in mountainious areas look quite realistic.

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

Re: More height levels

Post by CommanderZ »

Interesting glitch: the building underlays seem to be drawn correctly, but the buildings themselves (including foundations) are drawn far higher than they should be. The bottom town is at height cca 40.
Attachments
Unnamed, 19th Jan 1950.png
(137.4 KiB) Downloaded 161 times

ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: More height levels

Post by ic111 »

Hello,

I have just had some look at the painting code, but I not yet found any place in code that might be responsible for those glitches appearing at heights about >= 31.

I started at MarkTileDirtyByTile, which is called during terraforming. The code always looks quite robust, we are working with ints, there are no fixed size arrays that might overflow or similar stuff. I also had some look at the video driver code, but also found nothing suspicious.

So I have some questions:
First, does anyone of you have some idea about what might cause those glitches? Maybe you know some place, where for reasons of performance some bit magic is performed, where things are placed in fixed sized array without proper handling of the case that the array overflows, or something similar?

Second, do you know where the actual painting of some tile is performed. E.g. I have grassland in editor, without trees, houses and similar stuff. It must be painted into some buffer at some point, maybe there something weird is done with the z coordinate?

And finally, is there anyone responsible for the painting code one could ask? Or if not responsible at least someone who actually knows that code?

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

Re: More height levels

Post by CommanderZ »

I guess some trouble might be caused by variable overflows - devs seem to use as small integers as possible, so where (u)int8 was sufficient on height 15, it might be too small for calculations with height 40.

EDIT: Additional infirmation to the glich with houses I presented in the previous post - the offset of their sprites over where they should be is 255 pixels, independently of the height. Affects all houses above level 31.

EDIT 2:

The map generator finally gets into shape.
512x512x64-very rough-mountainous-low water.png
512x512x64-very rough-mountainous-low water.png (424.22 KiB) Viewed 3028 times
A 512*512 map with maxheight 64 with Very rough smoothness and very low water level. As you can see, the map is dominated by two large mountains and two lowland areas.

Please ignore the graphical glitches and ugly outer shores.

Any ideas? Isn't it too craggy (but remember, this is Very rough, so it should be craggy)?

Sadly the maps are not yet playable due to graphical glitches which make gameplay pretty much impossible on levels 31+.
Last edited by CommanderZ on 20 Dec 2008 14:54, edited 1 time in total.

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2664
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

cool.

that narrows the glitches down to terrain_drawing.

when you look a my posted pyramide... you can see the tile shift.
i did not build three pyramids.
its just one, the backslope is one continuous slope.

when i investigate this glitch with the question button...
my cursor(read white_square_on_ground) dissappears.
when you build a pyramid with rail past the glitch, you can even see it better.

you can count missing levels:

for the left shift:
count on my pyramid

for the up shift:
when using the clear tool, continue dimolisching until the animation reappears.
put your finger on the screen where your mouse pointer is,
then querry the spot where your finger still is (is it?).
now querry the spot where it dissapears (on the actaul tile, no finger needed.)

it seems that some levels are not drawn.
which happens again higher up the slope.

now seeing your picture ...
the town_drawing is not affected.
the shadows are because they are drawn on the tile,
the houses are not, because they are drawn above tiles.

so that glitch is also the few (6? every so much?) lines not being drawn.

meaning townplacement "as drawn" is correct.(and everything above tiles)
terrain and everything on it is not.
in regards to drawing on screen

how to fix? ... . i am sorry.

i did some testing with long and small maps(64*1024)
some missing tops reappear at the sea level.(at bottom edges)
i will try and get a screenshot by next post.

working on arrays for smallmap_heightcolor for automatic_use_correct_array later

@ CommanderZ.
in regards to a few post above
yes i did overlook that *ahum* small detail.

edit:
seems like we cross posted.
very nice.
much better.
looking forward to diff (whenever you feel fit,please do not feel pusched)
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9415
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: More height levels

Post by planetmaker »

I applied the patch posted by ChillCore to current trunk (r14700) and it failed to compile:

Code: Select all

/Users/planetmaker/ottd/fixing/src/smallmap_gui.cpp:289: error: size of array '__ct_assert__' is negative
[SRC] Compiling spritecache.cpp
make[1]: *** [smallmap_gui.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2
Is it only supposed to work with the heightlevel patch?

ic111's patch works nicely.

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2664
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

must be that because it gives no errors here.
i only extended the array.
nothing else.
is somebody else having problems??
expect a new patch very soon.
did you aply the other patches too?
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

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

Re: More height levels

Post by CommanderZ »

I tried to study the glitches a bit more. Here is a shot:
Sondston Transport, 21st Mar 1950.png
(162.92 KiB) Downloaded 100 times
There is a parfectly straight piece of track with a pinky train on it. The transmitter on the right side of the shot is at level 31, the upper track is correct (it seamlessly continues to right down to the water level), the bottom one is just a glitch. It is shifted once again by 255 pixels.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9415
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: More height levels

Post by planetmaker »

ChillCore wrote:must be that because it gives no errors here.
i only extended the array.
nothing else.
is somebody else having problems??
expect a new patch very soon.
did you aply the other patches too?
The error happened when I applied it alone. It's fine, if applied on top. Sorry.

ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: More height levels

Post by ic111 »

CommanderZ wrote:I guess some trouble might be caused by variable overflows - devs seem to use as small integers as possible, so where (u)int8 was sufficient on height 15, it might be too small for calculations with height 40.

EDIT: Additional infirmation to the glich with houses I presented in the previous post - the offset of their sprites over where they should be is 255 pixels, independently of the height. Affects all houses above level 31.
Seems that you are right. Looking into viewport.cpp (struct TileSpriteToDraw) and sprite.h (DrawTileSeqStruct), z always is saved as a byte. Combined with the fact that TILE_HEIGHT is defined to be 8 pixels, this means that we get glitches when the height of a tile exceeds 255 / 8 = 31 (rounded down). And this is exactly what happens.

So I will try to find those places and replace the 8 byte datatypes by something bigger.

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

Re: More height levels

Post by CommanderZ »

The game crashes while generating a 2048*2048*256 map (see the attachment). Am I hitting some limitation?

I was just trying if determining the maxinum height for the generator could work as "smaller dimension divided by eight". It works for all maps until 2048. 2048*1024*128 works fine. Maybe I should cap the height to 128?

EDIT: Now it crashed on 1024*1024*128 too
Attachments
error.png
error.png (8.92 KiB) Viewed 3178 times

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2664
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

ah yes.
that one.

edit:
reply removed
read below
edit 2: added please in line below . i did not mean to be demanding. sorry.
/edit

in the meantime can someone please translate for me the following hex codes:

#99cccc
#9999cc
#cccc99
#cccccc

first one to blend with last greens.
last ones with the grays.
maybe extend the grays just a little
(instead of going beyond white)
or does somebody think... YUCK !
i wont be offended its just a suggestion.
please tell.

attached diff needs the mainpatch !
it does not work standalone.
it is intended to be merged with the rest of this patch when im done.
and for now i am not done...
enjoy.
Attachments
moreheight_better_smallmap_level63.patch
(9.73 KiB) Downloaded 86 times
Last edited by ChillCore on 21 Dec 2008 23:41, edited 2 times in total.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

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

Re: More height levels

Post by Terkhen »

I've been able to generate 8192 x 4096 x 128 maps using this patch and Bilbo's extra large maps patch, and I never had any problems... :|

ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: More height levels

Post by ic111 »

The reason for the crash reported above is that an assertion in the old terraforming code fails. However, at least in usual terraforming this code is no longer used as of version 2 of my patch.

So either the more heightlevels patch version 2 is not installed properly or the map generator still calls this code.

Can you give us a stacktrace of that crash?

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

Re: More height levels

Post by CommanderZ »

Ahh, sorry, I didn't realize it might be already fixed, I don't have the newest version of the patch. I will try it the updated version right now.

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2664
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

i was thinking you guys had to do it again...
well i was in the assumption CommanderZ had version 2 in...
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

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

Re: More height levels

Post by CommanderZ »

The updated version works correctly.

ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: More height levels

Post by ic111 »

Hello,

this is release 3 of my more heightlevels patch. My tests with some
city at heightlevel 53, with trains and busses and industries are
quite ok.

What's new?
The glitches are almost history. There where two main reasons for
them:

First, frequently the z coordinate was saved in a byte. Occasionally,
the old code even casted a int to a byte for one call of some helper
function and continued operating on ints afterwards. Hmm... I tried
to find all those places and replaced byte with int32.

If you encounter glitches where something located above height level
32 is painted too low, this is probably the reason.

Second, in the old code when painting the landscape, the heightlevel
was treated by (a) looking which tiles would be at sea level at the
edges of the to be painted area and (b) painting some fixed number of
tiles south of that area too. (if you have a look at the landscape,
by giving some tile height > 0, you shift the place where it must be
painted to the north).

I replaced this algorithm by a new one which also first determines
which tiles would be at the edges of the to be painted area assuming
sea level. But then, my algorithm has a look on the heights of the
tiles and by having this look, it determines which actually have to be
painted. For more information, have a look into the code.

Known bugs or things that still need to be done:
(1) The smoke of power plants e.g. at heightlevel 53 is painted too low.
(2) If you scroll across the map border in northwest, you will get
some glitches. Probably, under some circumstances the to be painted
area my algorithm determines is a bit too small. This can probably be
solved by applying an appropriate offset to some variable at a
to-be-searched place.
(3) I didn't touch airplanes. I think for their flying height, an
algorithm like "fly at the usual height if tile_height <= 15, else fly
at height tile_height + some_offset" would be appropriate.
(4) According to some forum entry above, there is a not-yet-finished
patch for the minimap. I didn't touch the minimap.
(5) I did not yet switch back to the old behaviour of levelling.
However, this is relatively simple - you just would have to call my
terraforming algorithm for each to-be-levelled tile individually and
ignore the errors for tiles where levelling is not possible.
(6) I had to make z_pos in struct Vehicle in vehicle_base.h an int32
(previously a byte). I don't know wether one has to write some
handling procedure for older safegames because of that.

Note that I will not be able to do anything with this patch during the
next few weeks. So if someone solves some of the problems above,
thanks, and feel free to publish version 4 / 5 / 6 / etc. of the
patch.

I think the patch is nearly finished now, except for some bugs and the
issues stated above, so it would be quite good if we could remove the
"nearly" in that sentence soon :-)
Attachments
moreheights-version3.patch
Version 3 of the more heightlevels patch
(91.49 KiB) Downloaded 132 times

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2664
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

thank you.

i will checkout your patch tonight.

as for my contribution...
i am sorry.
nature called and the little lady had a baby this week.
so its in and out of the hospital for now.
as for the rest of my free time i have been looking for that glitch bug...

you can ignore my colour question...
i found this neat colourcode list right where i should have started looking first,
in the docs folder ...
i feel silly...
but i have them now and i should find some time later this weekend.

once i have 128 colours
i will have a looksie on how to create dropdown boxes in the gui,
and have the game use the correct array when selecting desired height.

if somebody wants to jump in and give me a hand...
i would be delighted.
its not like im too lazy too learn...
i am afraid it will take me some time.
(reading and learning from other patches)

i need to learn how to create:

textfield in gui,
dropdowns, (choose height)
greyouts,(no 64 high on 64 square map, etc)
attach behaviour to all of this... (generate map with correct height and smallmapcolor)
and make it look correct.

maybe a bit to much in one go...

@ ic111:
(3) i agree. it would be nice to see planes change altitude
(4) in progress. i should finish my array127 by sunday.
then i start reading in order to create dropdown.

ps:
merry christmass to all.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 6 guests