Page 1 of 2

Patch: Tree line height

Posted: 14 Jan 2010 16:03
by loclahost
When playing arctic maps, I have often been irritated on the fact that trees get everywhere, even where there is snow. Snow -> minus degrees -> no growth, right?

Anyway, I decided to go for it and therefor present my first patch! :D
It allows the user to set a tree line height, that is, a height at which no trees grow above, at the begining of a game.

Enjoy not having your alps covered in trees.
No trees where there's been snow for a hundred years...
No trees where there's been snow for a hundred years...
New in current version: The patch applied itself to all climates (instead of just arctic). Solved now though :)

Re: Patch: Tree line height

Posted: 14 Jan 2010 16:59
by Paltala
Wow, that is a really simple but effective patch and could make it into trunk due to its simplicity and effectiveness

Re: Patch: Tree line height

Posted: 14 Jan 2010 17:12
by Tvel
Cool. Nice patch.

2 problems however.
I got a crash when i tried to plant trees on the open snow.

And also i looks kinda strange with forest industries in the open with no trees, only snow.

EDIT: crash log added.

Re: Patch: Tree line height

Posted: 14 Jan 2010 17:30
by neob
Paltala wrote:Wow, that is a really simple but effective patch

Re: Patch: Tree line height

Posted: 14 Jan 2010 22:43
by Zephyris
I think the treeline should be defined totally separately from the snowline, it looks wierd having no trees at all above the snow line...

Re: Patch: Tree line height

Posted: 14 Jan 2010 22:54
by Tvel
Zephyris wrote:I think the treeline should be defined totally separately from the snowline, it looks wierd having no trees at all above the snow line...
It is defined separately. Just the crash needs to be fixed :)

Re: Patch: Tree line height

Posted: 14 Jan 2010 23:06
by Zephyris
Ah, fair enough, good work then!

Re: Patch: Tree line height

Posted: 14 Jan 2010 23:10
by FooBar
Very well done indeed, I like this idea.

One suggestion: allow a transition of let's say 2 height levels where only small trees grow. That way trees don't just stop all of a sudden, but actually show that they have a hard time growing at greater height.

Re: Patch: Tree line height

Posted: 15 Jan 2010 07:28
by loclahost
Thanks a lot for all the positive comments guys. As you can see in the first post I've updated it against todays trunk and fixed the assert.
FooBar wrote: One suggestion: allow a transition of let's say 2 height levels where only small trees grow. That way trees don't just stop all of a sudden, but actually show that they have a hard time growing at greater height.
Well, that depends on the type of mountain really. Old and compartivly flat mountains, like the swedish "fjällen" usually have a height intervall where trees get smaller and more far between.
On the other hand there's new mountains, like the alps, which are rather steep. On such mountains, the effect of thinning out the trees is almost nonexistent. You can go from compact forest to only grass in just a couple of hundred meters (been there, done that :wink:).
But thanks for the idea anyway, I'll look into it.

Re: Patch: Tree line height

Posted: 18 Jan 2010 15:19
by Eddi
just a remark: you might want to check whether this is compatible with moving snow line (implemented in some newgrfs)

Re: Patch: Tree line height

Posted: 19 Jan 2010 12:40
by loclahost
Since trees don't move with the snowline, that should not be a problem. My code only introduces another condition as to whether trees can be planted on a tile. This condition has nothing to do with the snowline, except for sharing its maximum and minimum limits (which, I guess, is only used before the game starts).

Updated the diff against the current trunk: 18866

Re: Patch: Tree line height

Posted: 19 Jan 2010 13:39
by ChillCore
Nice patch. I think I will include it in the moreheightlevels patch when you are done. :)

Like Eddi said, I would not let the max tree height value depend on the max snowline height value.
For them todo's, have a looksie at tile_type.h.
Also, table/settings.h and settings_type.h could use a little coding style.

ps:
May I suggest using some form of versioning with patches you post.
It gets a bit confusing if you have different versions in different folders.
There is always the solution of opening the file and looking but ... :(

Re: Patch: Tree line height

Posted: 19 Jan 2010 17:02
by loclahost
ChillCore wrote:Nice patch. I think I will include it in the moreheightlevels patch when you are done. :)
Splendid! It's always boring to make something noone will ever use. Looking forward to your height level patch by the way, with or without this as an addition. I miss mountains...
ChillCore wrote: Like Eddi said, I would not let the max tree height value depend on the max snowline height value.
For them todo's, have a looksie at tile_type.h.
Also, table/settings.h and settings_type.h could use a little coding style.
Ah, it's always easier to do the todo's when you know how to do. Or at least where :wink: . Many thanks
ChillCore wrote: ps:
May I suggest using some form of versioning with patches you post.
It gets a bit confusing if you have different versions in different folders.
There is always the solution of opening the file and looking but ... :(
Now I'm confused too. Versioning with patches? Are there more options than the "attach file" present here in the post editor? Or are you refering to some kind of template? Currently I'm posting the patch in the first post with the revision I built it against in the file comment. Please describe your favoured way further or point me at a page describing it.

Re: Patch: Tree line height

Posted: 19 Jan 2010 17:46
by ChillCore
loclahost wrote:
ChillCore wrote: ps:
May I suggest using some form of versioning with patches you post.
It gets a bit confusing if you have different versions in different folders.
There is always the solution of opening the file and looking but ... :(
Now I'm confused too. Versioning with patches? Are there more options than the "attach file" present here in the post editor? Or are you refering to some kind of template? Currently I'm posting the patch in the first post with the revision I built it against in the file comment. Please describe your favoured way further or point me at a page describing it.
Lol. I mean something like treelineheight_01.diff, treelineheight_02.diff, ..., nothing complicated.

You see when i first tested i applied your patch in my "test" folder.
Next version was against "a" moreheightlevels folder,
and the latest version(modified) against my "official" moreheightlevels patch folder.
If it were not for the little typo in the last version I would have to open all tree versions to see which is the newest.

Good luck getting it in trunk.

EDIT: Screenshot with more heightlevels attached.

Re: Patch: Tree line height

Posted: 20 Jan 2010 11:52
by loclahost
ChillCore wrote: EDIT: Screenshot with more heightlevels attached.
Sweet! Altough this really raises the need for a gradual tree line...

Re: Patch: Tree line height

Posted: 03 Feb 2010 14:42
by SwissFan91
Sorry to bump this, but is there any likelihood of this being put into trunk any time soon? IMHO it is one of the most useful patches made in recent months.

Re: Patch: Tree line height

Posted: 08 Feb 2010 11:48
by loclahost
And it still builds, there hasn't been any conflicts since I last updated it. I have also played it ever since (one game to "the end") and there has been no side effects, at least that I have been aware of. If there's anything preventing it from hitting trunk, please tell me and I'll fix it.

Re: Patch: Tree line height

Posted: 08 Feb 2010 12:10
by CommanderZ
loclahost wrote:And it still builds, there hasn't been any conflicts since I last updated it. I have also played it ever since (one game to "the end") and there has been no side effects, at least that I have been aware of. If there's anything preventing it from hitting trunk, please tell me and I'll fix it.
Did you consider implementing the gradual tree line?

Re: Patch: Tree line height

Posted: 08 Feb 2010 12:16
by ChillCore
Hello loclahost,
loclahost wrote: And it still builds, there hasn't been any conflicts since I last updated it.
Are you sure savegame has not bumped in the meantime?
loclahost wrote: If there's anything preventing it from hitting trunk, please tell me and I'll fix it.
settings.gui and table/settings.h: Still depend on snowline.
tile_type.h : Coding style.

Re: Patch: Tree line height

Posted: 08 Feb 2010 21:47
by loclahost
ChillCore wrote:Hello loclahost,
loclahost wrote: And it still builds, there hasn't been any conflicts since I last updated it.
Are you sure savegame has not bumped in the meantime?
Oops, it had. I just couldn't see it in-game since I don't play without may patch. Bumped it again.
ChillCore wrote:
loclahost wrote: If there's anything preventing it from hitting trunk, please tell me and I'll fix it.
settings.gui and table/settings.h: Still depend on snowline.
tile_type.h : Coding style.
I haven't made any changes to settings_gui, so I guess you mean genworld_gui . Anyway; fixed all three of them and updated the diff in the first post. I had forgotten how space-happy the coding style is (myself being more of a tab person :wink: ).
Thank you ChillCore for pointing out my silly misstakes. I bow in your general direction :bow:. Hopefully I remember to read my own diff file next time.

CommanderZ:
Not yet. I'm lacking in IDE (and linux skills) so my traversal of the code is quite slow. But if that is something you want, I'll increase my efforts in finding where to make it work. Maybe I'll have some more time this weekend than the ten minutes I had today. Stay tuned.