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
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: More height levels

Post by Zuu »

ChillCore wrote:i need to learn how to create:

textfield in gui,
The text box widget type is called WWT_TEXTBOX if I recall correctly from memory. To use it you need to make the window class inherit from a special Query window class, instead of from the usual Window class. This is how the text-buffer that is used to store the string that users edit gets added to the window. As you probably see this is one of the reasons for the current limitation of only one text edit box per window.

In the constructor/destructor you will need to add code to lock the arrow keys from being used to pan the map. As you might know if a window with text box is open, all keyboard input is directed to the text box, and arrow keys need to be locked from being used to pan the map, instead users should be able to move the cursor in the text box.

Probably easiest is to read the code of an existing window that has a text box in it. Which you should do, as I have not checked it to make sure my statements are correct. I've been working with text edit boxes quite some the last half year with my filter sign list patch and later the widget focus patch. But I don't have every and all details in memory.
ChillCore wrote:ps:
merry christmass to all.
Merry christmass you too :)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: More height levels

Post by Terkhen »

Well, this is getting better and better! :D

I did a quick test at height 125 and every graphical glitch (except those mentioned by ic111 in his post) seems to be fixed (I'll test it more deeply later). But I found a big bug that seems to be in the raise/lower land new algorithm... You can raise all the land you want: you will never get a "Not enough cash" error.
Attachments
bug.png
bug.png (25.54 KiB) Viewed 4380 times
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: More height levels

Post by ic111 »

Terkhen wrote:Well, this is getting better and better! :D

I did a quick test at height 125 and every graphical glitch (except those mentioned by ic111 in his post) seems to be fixed (I'll test it more deeply later). But I found a big bug that seems to be in the raise/lower land new algorithm... You can raise all the land you want: you will never get a "Not enough cash" error.
Oh, seems that I tested too much in the editor instead of in the game. Probably a check in terraform() is needed, before terraforming is actually performed according to the information collected before.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

as requested by ic111 here is version 4.

what is in this version 4?
- version 3 by ic111.
- version3 includes moreheights-withheightmaps by Terkhen.
- tgp adaptor by CommanderZ.
- height_color array 15, 31, 63 and 127 for smallmap (not coded yet)
array 127 is currently used. please read comments in smallmap_gui.cpp for more info.

what have i changed:

- version 3-> no changes.
- heightmaps ->now set to load heightmaps at level 128.
- tgp adaptor-> no changes: WIP (as stated before by CommanderZ)
- smallmap colour array:
-> extended to 127 colours.
-> new feature: flooding_danger_flash at level 0. (again read comments in smallmap_gui.cpp please)

sorry for short post but i am a bit tired.

@ Zuu:
thank you for your pointers.
they will come in handy.

edit 1:
hmm. posting when tired is not good.
i forgot to credit someone, if not more than 1 person.
/me re-reads thread from page 1...take notes... then comes back to edit some more
edit2:
sorry Terkhen.
post updated.
Attachments
moreheights-version4.patch
(104.85 KiB) Downloaded 175 times
Last edited by ChillCore on 29 Dec 2008 10:24, edited 1 time 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.
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 will post new version of the tgp patch once it
can generate all map sizes correctly, for now it
works only for sizes <= 512, maps 1024 and larger
do unpretty things.

Btw does the patch keep track of what current highest
height is? then you could make the minimap adapt to the
current map height - it would show level 0 as green and
the highest level as yellow (or what color it is), the rest
would be calculated between these two.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

Quote: CommanderZ said:
Btw does the patch keep track of what current highest
height is? then you could make the minimap adapt to the
current map height - it would show level 0 as green and
the highest level as yellow (or what color it is), the rest
would be calculated between these two.
/Quote.

@CommanderZ :
actually the patch does keep track of highest height.
twice, independant of one another:
that is, in regards to generation of terrain.

first time in tgp.cpp : MAX_TGEN_HEIGHT = value
second in heightmap.cpp. : line 354 (see comment at end of line)

in both cases you can still build higher if you want to do so.
(imo: the player should decide if he does that or not. no limits.)
for both cases i/we/somebody could attach a different array_to_use.
to clarify:
the version 4 i posted:
loads heightmaps at 128 (127 ?) (defined in heightmap.cpp)
but still generates a map at 63 (defined in tgp.cpp)
----
the calculating colours bit has crossed my mind ...
but: (why is there always a but?)
- on my quest exploring colors i have encounterd some (gr)action_colours.
can an algorithm cope with those?
or do you know somebody who can filter them out with an algorithm ?
also the brown-, blue-, red shades (and everything in between) ?
-also note that sometimes: "the next value" != "the next/desired shade".
/@CommanderZ

i have been thinking a bit about how to handle correct array use.

case 1: landgeneration
--------------------------
solution a and b.

a. extend selection box (both on new game and in scenario editor)
-verry flat
-flat
-hilly
-mountanious
-32
-64
-128
- ...
and attach colour_array_to_use here.

b. make MAX_TGEN_HEIGHT variable and selectable in advanced settings
as explained for loading heightmaps.(see case 2)
and have flat,hilly etc. calculated against this value (the way it is now)

both solutions are possible.
b would be my preffered way.

case 2: loading heightmaps:
---------------------------
there is already a button in advanced settings gui.
on is allow higher than 16 levels
off is do not allow higher levels.
dependant on this setting the correct height is generated (16 or other).
attached to this button is the loading heightmap_at_level_other behaviour in heightmap.cpp,
with an if else statement.
this if else statement decides the value of other.

maybe this statement can be extended and selectable in advanced settings gui.
this would need a select heightmap_height button to be created as proposed below

the same can be aplied for case_1_solution_b above.
(add an if else to MAX_TGEN_HEIGHT in tgp.cpp ?)

proposed advanced setting gui:
[textfield][setting/value/dropdown?]
-----------------------------------------
- [allow more than 16 levels] [on/off] (is there allready)
- [load Heightmap_height] [original/32/64/128/...](auto-select original if above setting is off)
- [MAX_TGEN_HEIGHT] [original/32/64/128/...](auto-select original if first setting is off)

- attach behaviour to decide what color array to use to the two new options(invisible to user)

so far my proposal for now.

as for array 255:
it will be very hard to find more shades.
there is already:

- white for rails.
- red and black for towns and industries.
- blue for rivers and sea.
- i tested some browns and YUK...(at least not where i had put them)

all these colours(except brown) have to show up at the same time.
and still have to have enough contrast to see what is located where.
also, as you can see when testing,
the pale-greens are kinda hard to distinguish.
so instead of adding shades there i should delete some ...
i still have room for expansion, only i do not know how much.

how would you people feel to use array 127 for level 128 and also for level 256?
(1 colour two levels)
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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 »

actually the patch does keep track of highest height.
twice, independant of one another:
that is, in regards to generation of terrain.

first time in tgp.cpp : MAX_TGEN_HEIGHT = value
second in heightmap.cpp. : line 354 (see comment at end of line)

in both cases you can still build higher if you want to do so.
(imo: the player should decide if he does that or not. no limits.)
for both cases i/we/somebody could attach a different array_to_use.
to clarify:
the version 4 i posted:
loads heightmaps at 128 (127 ?) (defined in heightmap.cpp)
but still generates a map at 63 (defined in tgp.cpp)
This wasn't exactly what I meant. I meant if it stores the highest height really used, so the minimap would adapt to the changes of the heigh field during game too - for example - player would generate quite flat map with heights 0-10. The minimap would show height 1 as green and height 10 as yellow. But then the player goes mad and makes a 200 tiles high pyramid of dirt. The scale would shift and 10 would be still quite green and yellowish colors would start apearing at height 120 or so.

This is to make the minimap useful as flatmaps too. I guess played classical ttd map with 16 heights and the minimap would be optimized for 127, all the minimap would be flat green.

The array could be used for 8bpp blitter, but for the 32bpp you should use some smooth color gradient algorithm.
proposed advanced setting gui:
[textfield][setting/value/dropdown?]
-----------------------------------------
- [allow more than 16 levels] [on/off] (is there allready)
- [load Heightmap_height] [original/32/64/128/...](auto-select original if above setting is off)
- [MAX_TGEN_HEIGHT] [original/32/64/128/...](auto-select original if first setting is off)
The height scale for heightmap generation should be in the heightmap import window imo.

For the tgen setting, it would be better to use multiplier, because the base height bounds will be calculated from the size of the map (one eighth of the smaller map dimension currently). the multiplier could have these values: 1/16, 1/8, 1/4, 1/2, 1, 2, 4, 8. I need it to stay in powers of two for now. I think this settig should be in the map generation window (as all the settings affecting map generation are there).

PS: Please use the Quote tag (and other formatting) where necessary, it makes the posts much more pleasant to read.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

indeed playing 16 high witch 127 array looks like ****.
the other way round is even worse.

hmm auto-scaling heightmap_colours...
sounds great, but is out of my league.
if somebody can do that... i would like that very much.
that way we would only need 1 array and we keep code compacter.

as for the what to put where...
i am learning.
there is so much...
but i am not complaining.

i will not change stuff just like that ...
i watch and learn ...
it will be obvious for you what to do when the time comes, i guess...
feel free to adapt my arrays, even delete15, 31, 63, if no longer needed.
even if none used anymore i will not cry because i have learned something new.

Edit:
I am sorry.
I keep JavaScript and ActiveX disabled.
Bassicly all other security settings are off too.
So no quotes for me.
Even smilies do not work for me.
As a pleasant side effect.(for me). Byebye google ads.
I will try harder to keep my posts more pleasant to read.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: More height levels

Post by Eddi »

ChillCore wrote: I am sorry.
I keep JavaScript and ActiveX disabled.
Bassicly all other security settings are off too.
So no quotes for me.
Even smilies do not work for me.
As a pleasant side effect.(for me). Byebye google ads.
I will try harder to keep my posts more pleasant to read.
you can insert
tags by hand

syntax is (without spaces):
[ quote = "name" ]
blah
[ / quote ]
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: More height levels

Post by CommanderZ »

Just tried to update to version 4. I fails with a bunch of unpretty errors for me (MSVS 2008 Pro + Win XP):

Code: Select all

c:\documents and settings\**** *****\plocha\moreheight\src\viewport.cpp(1248) : error C2057: expected constant expression
c:\documents and settings\**** *****\plocha\moreheight\src\viewport.cpp(1248) : error C2466: cannot allocate an array of constant size 0
c:\documents and settings\**** *****\plocha\moreheight\src\viewport.cpp(1248) : error C2133: 'top_row' : unknown size
c:\documents and settings\**** *****\plocha\moreheight\src\viewport.cpp(1249) : error C2057: expected constant expression
c:\documents and settings\**** *****\plocha\moreheight\src\viewport.cpp(1249) : error C2466: cannot allocate an array of constant size 0
c:\documents and settings\**** *****\plocha\moreheight\src\viewport.cpp(1249) : error C2133: 'bottom_row' : unknown size
OT:
syntax is (without spaces):
[ quote = "name" ]
blah
[ / quote ]
The ="name" part is not obligatory. Also, you an see a "quote" button under each post on the thread page, it should work without javascript (I guess).
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

CommanderZ wrote: Just tried to update to version 4. I fails with a bunch of unpretty errors for me (MSVS 2008 Pro + Win XP):
Strange.
I use: Win XP, turtoise for patching. MinGW-MSYS for compiling.

I did a clean merge against clean r14741. No conflicts.
A few warnings on compiling but not in viewport.cpp
The game runs.

Edit:
I just downloaded the patch myself.
Same result.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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 version 3, it throws the same errors. Both applied to their respective SVN revisions. I was so anxious to try the game without these annoying rendering glitches :(
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

Here is my bin.
No changes made since i posted the patch a few posts back

Note: not checked for virusses.

Hope this works for you.

edit:
Binaries removed.
Newer version available further in the thread.
Last edited by ChillCore on 17 Jan 2009 13:07, edited 1 time 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.
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: More height levels

Post by CommanderZ »

Binary is useless for me, I want to keep improving my tgen patch :P

Thanks for the effort, anyways.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

I can send you my source if you want.
I have a backup, only including version 4.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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 tihink it is a bug somewhere in the code which some compilers ignore, but MSVS fails because of it. I tried to apply the patch three times on a clean SVN source and the patching process was successful, but the compilation fails.
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: More height levels

Post by Hirundo »

The lines that cause the problems are these:

Code: Select all

	int top_row[right_column - left_column + 1];
	int bottom_row[right_column - left_column + 1];
C/C++ arrays require their size to be known at compile time, which is not the case here as right/left_column are determined at runtime.
Create your own NewGRF? Check out this tutorial!
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: More height levels

Post by CommanderZ »

Swallow wrote:The lines that cause the problems are these:

Code: Select all

	int top_row[right_column - left_column + 1];
	int bottom_row[right_column - left_column + 1];
C/C++ arrays require their size to be known at compile time, which is not the case here as right/left_column are determined at runtime.
I know, but I don't understand why it works for ChillCore. And I'm not exactly in the mysterius-bu-fixing mood :)
PhilSophus
Chairman
Chairman
Posts: 776
Joined: 20 Jan 2007 12:08
Location: Germany

Re: More height levels

Post by PhilSophus »

CommanderZ wrote:
Swallow wrote:T
C/C++ arrays require their size to be known at compile time, which is not the case here as right/left_column are determined at runtime.
I know, but I don't understand why it works for ChillCore. And I'm not exactly in the mysterius-bu-fixing mood :)
Because gcc has an extension supporting the size of local arrays to be determined at run-time and because it is not given options that enforce ISO standard conformance. For maximum portability, one should check compiling with "-std=c++98 -pedantic".
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

Swallow wrote: C/C++ arrays require their size to be known at compile time, which is not the case here as right/left_column are determined at runtime.
CommanderZ wrote: I know, but I don't understand why it works for ChillCore. And I'm not exactly in the mysterius-bu-fixing mood
PhilSophus wrote: Because gcc has an extension supporting the size of local arrays to be determined at run-time and because it is not given options that enforce ISO standard conformance. For maximum portability, one should check compiling with "-std=c++98 -pedantic".
Can i fix this, with my limited knowledge?
If so, how?
I would be happy to provide a fixed patch.
If only i knew what to change where.

Do i remove patch_v4 and wait for a new version 3 ?
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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 11 guests