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
PhilSophus
Chairman
Chairman
Posts: 776
Joined: 20 Jan 2007 12:08
Location: Germany

Re: More height levels

Post by PhilSophus »

ChillCore wrote: 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.
Assuming it is a local variable (I didn't look at the code), the best way would be to use AllocaM (which is a wrapper to alloca). It reserves memory from the stack until the end of the function (not the scope!) that uses the macro. So, it's similar, but not identical to what local variables do:

Code: Select all

int *top_row = AllocaM(int, right_column - left_column + 1);
And the same for bottom_row. The usage of top_row stays the same (i.e. top_row[3] would give the fourth element of the dynamic array).


Edit: For this to work, you have to include core/alloc_func.hpp if it not already is.
"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: 2658
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

Changes made in viewport.cpp as suggested by PhilSophus.

I left the old lines as comments to be removed later.

Because it already worked for me before,
there is no way for me to know if the changes fixed the problem.

I still have the few warnings as before on compiling.
Game runs.

ps:
Still against r14741.
I will try upating to a later revision when this thingy is fixed.
Attachments
moreheights-version4_01.patch
(105.2 KiB) Downloaded 122 times
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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 »

Wonderful, it works now. TY

EDIT: Awesome work, ic, the most glitches are really gone. Some remain though:
Attachments
Unnamed, 14th Jan 1950.png
(80.08 KiB) Downloaded 261 times

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

Re: More height levels

Post by ChillCore »

Good to hear that CommanderZ.
Thank you, Swallow and PhilSophus.

I managed to update the patch to r14827.
I had some manual merging to do, and some minor changes in command.cpp.
Let's hope i have not broken anything.
Dutch language file is also updated.

I didn't succeed updating to any later revision.
There have been some major changes to trunk since r14828,
some parts of the patch need relocating to the new saveload folder.
Maybe some other things need changing too.

Edit:

Updated to r14901.
Some changes but functionality should not have changed.

Attached is the new diff and i left the old one.
(It would be best if somebody reviewed my changes ?)

Edit 2:
I removed my version5 after reviewing my code three times.
Too many errors on my side. Sorry

@ the four persons who allready downloaded the r14827 patch:
No changes were made i only reposted.

@ the one person who downloaded the version5:
I have a new version5 against r14931.
Cleaner code. Less codechanges. Less misstakes. Same functionality.
But as you might have noticed game asserts on leveling land.
Attachments
moreheights-version4_04-r14827.patch
(108.47 KiB) Downloaded 66 times
Last edited by ChillCore on 09 Jan 2009 15:03, edited 4 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.

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

Re: More height levels

Post by ChillCore »

Bump.
Sorry for the double post.
I didn't Find the button.

Edit:

I did not want to edit the previous post too much...
So i continue here.

As i metioned above.
I'm having a little prob updating the patch to a newer revision.

When levelling land the game asserts:

asertion failed!
Expression: res.GetCost() == res2.GetCost() && CmdFailed(res) == CmdFailed(res2)

Corresponding code in command.cpp line 606-609:

/* If notest is on, it means the result of the test can be different than
* the real command.. so ignore the test */
if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
assert(res.GetCost() == res2.GetCost() && CmdFailed(res) == CmdFailed(res2)); // sanity check

/End code.

Im not too fond with posting buggy code but attached is the diff.
I have no clue(yet) on how to fix.

Ps: how do I edit and bump at the same time?
Attachments
moreheights-version5-r14931.patch
(109.09 KiB) Downloaded 70 times
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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
ChillCore
Tycoon
Tycoon
Posts: 2658
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

The above error was another misstake on my side in command.cpp.
Sorry.
Please find attached the fixed diff.

I had to fix another issue in terraform_cmd.cpp though.
I stumbled upon the same assert as CommanderZ had between version 1 and 2.
So i had to do a dirty hack again. I do not like the way i did what i did, but it works.

I noticed the game freezing a lot when terraforming.(best seen when leveling)
I do no know if that is a result of me messing around, some application running on my pc or simply a bug in trunk.
I will see what gives when updating to later a revision.

anyway it works again.

I am now going to mess it up again. lol.
Attachments
moreheights-version5-fixed-r14931.patch
(109.22 KiB) Downloaded 104 times
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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 »

Here's a version of the latest patch updated to (almost) current trunk.
moreheights-version5-fixed-r14993.patch
(109.55 KiB) Downloaded 102 times
The terraforming is way slower now than the last time I tried the patch, so it must be something ChillCore added. Also, I found this graphical glitch after zooming out:

PS: ChillCore: I would prefer that you detailed more what changes between versions. I'll do more tries later, but this is looking good.
Attachments
glitch.PNG
(25.11 KiB) Downloaded 156 times

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

Re: More height levels

Post by ChillCore »

I tried to make as little changes as possible.
So ic111 will not be too much lost when he comes back...

Version4 is only a merge from all patches.
Version4_01 is a compiler bugfix and was also the last "stable".
The next two posted patches are buggy.(4_04-r14827 and the first v5-r14931)

After getting tired of trying to get past r14827,see mess above,
I decided to give it one more manual go from the v4-01 to r14931 in one go.
(before trowing in the towel and crying for help.)

Version5 only indicates the adaption to the new saveload folder.
Nothing new was included, (except dutch translation)
no bugs were fixed.
I copypasted as much as possible.

As for the beauty of it all...

It is all the work of ic111.

I only updated and did what is mentioned below.

Changes moreheight version4_01(r14741) to version5-fixed-r14931:

1. command.cpp:
CommandTerraformLand to CommandTerraformLandOld (2x)
CommandLevelLand to CommandLevelLandOld (2x)
I needed to do so because compiler complained.

2. Included dutch translation.

3. saveload/map_sl.cpp:
Last part of misc.cpp went in here.

4. saveload/afterload.cpp:
Everything from openttd.cpp went in here.

5. 2x savebump:
setting.cpp and afterload.cpp(read below)

6. smallmap_gui.cpp:
Updated my comments (no need to re-read if you already did in version 4)

And finally my dirty hack:
7. terraform_cmd.cpp:
I added " * MAX_TILE_HEIGHT_OLD" to lines 30 and 36 to stop the game from crashing.
I tried with smaller values (* 3 and * 12) but then the games asserts sooner.
Maybe this is the cause of the freezes, maybe it is not.


To do:
Savebump settings.cpp to 106 (i missed that one)

@Terkhen:
Thank you for the update.
Sorry for not explaining my changes sooner but is hard to say i did this,
while (my)code is changing on a five minute base. (trial and error)

ps.:
I used turtoise to make this post. I pulled a diff between patches.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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
ChillCore
Tycoon
Tycoon
Posts: 2658
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: More height levels

Post by ChillCore »

Fixed the slow terraforming.
Adding ', const char *text' to :

'CommandCost CmdTerraformLand' and 'CommandCost CmdLevelLand' in terraform_cmd.cpp did the trick.

My changes in command.cpp are no longer needed(1 above).
They forced the game to use the old terraforming code. Hence the slowdown.
Now we use ic111 his terraformcode again.
The resulting needed hack(7) is no longer needed also.

To do is done.

Edit:
Update to 15040.
Time for a break for me and play a little bit ...
Testing the new ai ...

Edit 2:
Binaries removed, latest are available later in thread.
Last edited by ChillCore on 22 Mar 2009 09:04, 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.

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

Re: More height levels

Post by Terkhen »

No problem, everything is more clear now :D

I think the patch is now "playable". These are the missing features that come to my mind:

- Zooming out glitch

- Airplanes still fly "into" mountains, but they are drawed "over" them. I don't even know how to start with this (I never found the flying height in the code), but I think it can be very tricky.

- The map generator GUI needs to get more snow line levels than 15. I'm going to do some tests with this.

- The heightmap generator should ask for a "maximum height" before loading the heightmap, instead of the quick and dirty trick I did.

- ¿Changes to terragen?

- I found another glitch: when you build a power plant, the smoke appears correctly. But when you load a game with a power plant in it, the smoke is moved, see screenshot for details.
Attachments
glitch2.png
glitch2.png (19 KiB) Viewed 2689 times

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

Re: More height levels

Post by ChillCore »

- Terraforming is free ?
Not exactly free, but bank balance goes in the red figures instead of not being alowed.
- Airplanes still fly "into" mountains, but they are drawed "over" them. I don't even know how to start with this (I never found the flying height in the code), but I think it can be very tricky.
Have a looksie in aircraft_cmd.cpp: line 864+(with patch r15040 installed)

- other glitches: zoom out and smoke.
Please read last post that ic111 made in this thread (page 5, 4:19 pm).
It explains a lot and it still stands.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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 »

Terragen is Wip. it is far more complicated than I initially thought
, especially making it adapt to various map setting -
especially smoothness vs. map size. Map size should
make all map features (mountains, valleys etc.) larger
- in practice increasing the map size by two should
result in scaling the map by two along all three axes.
And smoothness should affect steepness of hills and
amout of small noise.

This all means balancing a lot of settings, I hope to
finish it once my exams are over. Just dont hurry on
me. :)

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

Re: More height levels

Post by Terkhen »

No problem CommanderZ, i was just listing what parts are missing. I never wanted to rush you or ChillCore :)

I have been working with the snowline: the attached new version allows to raise the snow line up to 65533! I hope to not have created some nasty bug with this; I had to touch a lot of parts of the code. Due to changes in settings.cpp,the savegame version was increased. It still should be compatible with old savegames and saved games from trunk.

When I have time I'll try to remove to the height of flat land in the scenario editor. It should be easier than snow, I think.
Attachments
moreheights-version5_02-r15077.patch
(118.38 KiB) Downloaded 64 times

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

Re: More height levels

Post by CommanderZ »

When I have time I'll try to remove to the height of flat land in the scenario editor. It should be easier than snow, I think.
I don't get it. What is the "height of flat land"?

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

Re: More height levels

Post by Terkhen »

I have noticed that map generation asserts when the patch is not active. I've been doing a few tests with no success, but I'll give it another look later.

CommanderZ, I meant this:
Attachments
screenshot#2.png
screenshot#2.png (13.8 KiB) Viewed 2331 times

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

Re: More height levels

Post by CommanderZ »

Ah, good feature.

Im quite sure the crash is on my side, ignore it.

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

Re: More height levels

Post by Terkhen »

Done!. Now you can generate flat maps of any height.

I have been looking at the code, and I think a max height limit of 255 would be easier to mantain, and would consume less resources. I don't think levels higher than 255 will be reached in normal gameplay. Also, the highest level you can possibly reach is having a pyramid sized scenario at a 8192 x 8192 scenario, and it's 4095 (I think).

What do you think?. Should the highest level be reduced to 255?.
Attachments
screenshot.png
screenshot.png (22.09 KiB) Viewed 2249 times
moreheights-v5_3-r15089.diff
(119.23 KiB) Downloaded 66 times

User avatar
Thief^
Route Supervisor
Route Supervisor
Posts: 468
Joined: 10 Oct 2004 00:11

Re: More height levels

Post by Thief^ »

Yes. It sounds like it would reduce memory usage quite a lot, especially on larger maps.
Melt with the Shadows,
Embrace your destiny...

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

Re: More height levels

Post by CommanderZ »

Terkhen wrote:scenario at a 8192 x 8192 scenario, and it's 4095 (I think).

What do you think?. Should the highest level be reduced to 255?.

Not necessarily. From what I have seen in the Freeform edges thread, devs seem to be interested in that patch, which means possible inclusion in trunk in not so distant future. It would make a height of 8192 possible on the map of same size. In any case, I wouldn't reduce the length of the height data to less then 2 bytes (max 65000 or so), 255 is still reachable with reasonable terrain on 2048 map.

User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: More height levels

Post by DJ Nekkid »

that saied, i think 255 levels should be sufficient, unless "unlimited" is just as easy to implement. However, i think it should be possible to set a max height in the terran generator.
Member of the
ImageImage

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google Adsense [Bot] and 3 guests