Patch: Tree line height

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

loclahost
Engineer
Engineer
Posts: 46
Joined: 18 Dec 2008 07:39
Location: Sweden

Patch: Tree line height

Post by loclahost » 14 Jan 2010 16:03

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.
Unnamed, 1st Jan 1910.png
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 :)
Attachments
treelineheight_3.diff
Diff against 19135
(23.57 KiB) Downloaded 181 times
Last edited by loclahost on 15 Feb 2010 12:19, edited 9 times in total.

Paltala
Engineer
Engineer
Posts: 123
Joined: 09 Jan 2009 11:46

Re: Patch: Tree line height

Post by Paltala » 14 Jan 2010 16:59

Wow, that is a really simple but effective patch and could make it into trunk due to its simplicity and effectiveness
ImageImage
ImageImage

Tvel
Engineer
Engineer
Posts: 77
Joined: 29 Mar 2008 22:42
Skype: tvel___
Location: Bulgaria

Re: Patch: Tree line height

Post by Tvel » 14 Jan 2010 17:12

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.
Attachments
crash.log.zip
(1.31 KiB) Downloaded 133 times

User avatar
neob
Chief Executive
Chief Executive
Posts: 688
Joined: 29 Dec 2009 02:56

Re: Patch: Tree line height

Post by neob » 14 Jan 2010 17:30

Paltala wrote:Wow, that is a really simple but effective patch
Image

User avatar
Zephyris
Tycoon
Tycoon
Posts: 2826
Joined: 16 May 2007 16:59

Re: Patch: Tree line height

Post by Zephyris » 14 Jan 2010 22:43

I think the treeline should be defined totally separately from the snowline, it looks wierd having no trees at all above the snow line...

Tvel
Engineer
Engineer
Posts: 77
Joined: 29 Mar 2008 22:42
Skype: tvel___
Location: Bulgaria

Re: Patch: Tree line height

Post by Tvel » 14 Jan 2010 22:54

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 :)
Attachments
screenshot_004.png
screenshot_004.png (34.62 KiB) Viewed 7174 times

User avatar
Zephyris
Tycoon
Tycoon
Posts: 2826
Joined: 16 May 2007 16:59

Re: Patch: Tree line height

Post by Zephyris » 14 Jan 2010 23:06

Ah, fair enough, good work then!

User avatar
FooBar
Tycoon
Tycoon
Posts: 6559
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Patch: Tree line height

Post by FooBar » 14 Jan 2010 23:10

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.

loclahost
Engineer
Engineer
Posts: 46
Joined: 18 Dec 2008 07:39
Location: Sweden

Re: Patch: Tree line height

Post by loclahost » 15 Jan 2010 07:28

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.

Eddi
Tycoon
Tycoon
Posts: 7365
Joined: 17 Jan 2007 00:14

Re: Patch: Tree line height

Post by Eddi » 18 Jan 2010 15:19

just a remark: you might want to check whether this is compatible with moving snow line (implemented in some newgrfs)
You might not exactly be interested in Ferion, but if you are, have fun :)

loclahost
Engineer
Engineer
Posts: 46
Joined: 18 Dec 2008 07:39
Location: Sweden

Re: Patch: Tree line height

Post by loclahost » 19 Jan 2010 12:40

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

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

Re: Patch: Tree line height

Post by ChillCore » 19 Jan 2010 13:39

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 ... :(
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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.

loclahost
Engineer
Engineer
Posts: 46
Joined: 18 Dec 2008 07:39
Location: Sweden

Re: Patch: Tree line height

Post by loclahost » 19 Jan 2010 17:02

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.

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

Re: Patch: Tree line height

Post by ChillCore » 19 Jan 2010 17:46

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.
Attachments
treeline.png
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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.

loclahost
Engineer
Engineer
Posts: 46
Joined: 18 Dec 2008 07:39
Location: Sweden

Re: Patch: Tree line height

Post by loclahost » 20 Jan 2010 11:52

ChillCore wrote: EDIT: Screenshot with more heightlevels attached.
Sweet! Altough this really raises the need for a gradual tree line...

User avatar
SwissFan91
Tycoon
Tycoon
Posts: 2384
Joined: 08 Feb 2009 18:36
Location: Alberta, Canada

Re: Patch: Tree line height

Post by SwissFan91 » 03 Feb 2010 14:42

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.
Image
Total Alpine Replacement Set: Industry, Town, Objects
**ATTENTION**: If anyone would like me to help draw snow stages in any of their GRFs let me know. I genuinely enjoy drawing them.

loclahost
Engineer
Engineer
Posts: 46
Joined: 18 Dec 2008 07:39
Location: Sweden

Re: Patch: Tree line height

Post by loclahost » 08 Feb 2010 11:48

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.

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

Re: Patch: Tree line height

Post by CommanderZ » 08 Feb 2010 12:10

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?

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

Re: Patch: Tree line height

Post by ChillCore » 08 Feb 2010 12:16

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.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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.

loclahost
Engineer
Engineer
Posts: 46
Joined: 18 Dec 2008 07:39
Location: Sweden

Re: Patch: Tree line height

Post by loclahost » 08 Feb 2010 21:47

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.

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 6 guests