"Improved" sub-tropic TGP landscape generator

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
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

"Improved" sub-tropic TGP landscape generator

Post by andythenorth »

In sub-tropic climate, TGP produces very boring flat maps. These are really dull to play (apologies to whoever wrote this in TGP) :)

I've 'improved' it by deleting the sub-tropic specific code, and using the same height rules as temperate climate. This makes for much more playable maps. Desert and rainforest generation work fine.

Code: Select all

diff --git a/src/tgp.cpp b/src/tgp.cpp
index 436870b..8db6cd3 100644
--- a/src/tgp.cpp
+++ b/src/tgp.cpp
@@ -489,24 +489,12 @@ static void HeightMapSineTransform(height_t h_min, height_t h_max)
 				break;

 			case LT_TROPIC:
-				{
-					/* Desert terrain needs special height distribution.
-					 * Half of tiles should be at lowest (0..25%) heights */
-					double sine_lower_limit = 0.5;
-					double linear_compression = 2;
-					if (fheight <= sine_lower_limit) {
-						/* Under the limit we do linear compression down */
-						fheight = fheight / linear_compression;
-					} else {
-						double m = sine_lower_limit / linear_compression;
-						/* Get sine_lower_limit..1 into -1..1 */
-						fheight = 2.0 * ((fheight - sine_lower_limit) / (1.0 - sine_lower_limit)) - 1.0;
-						/* Sine wave transform */
-						fheight = sin(fheight * M_PI_2);
-						/* Get -1..1 back to (sine_lower_limit / linear_compression)..1.0 */
-						fheight = 0.5 * ((1.0 - m) * fheight + (1.0 + m));
-					}
-				}
+				/* Move and scale 0..1 into -1..+1 */
+				fheight = 2 * fheight - 1;
+				/* Sine transform */
+				fheight = sin(fheight * M_PI_2);
+				/* Transform it back from -1..1 into 0..1 space */
+				fheight = 0.5 * (fheight + 1);
 				break;

 			default:

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: "Improved" sub-tropic TGP landscape generator

Post by HackaLittleBit »

It looks more like arizona now.
I like it
I used the command 'newgame 12343'
Attachments
arizona_org.png
arizona_org.png (85.22 KiB) Viewed 2945 times
arizona.png
arizona.png (84.02 KiB) Viewed 2945 times
User avatar
Pyoro
Tycoon
Tycoon
Posts: 2558
Joined: 17 Oct 2008 12:17
Location: Virgo Supercluster

Re: "Improved" sub-tropic TGP landscape generator

Post by Pyoro »

It'd be nice if the "jungle" was more coherent to a "region", like an entire mountain, instead of a blob of the mountain, but I really have no idea how that could be achieved.
Eddi
Tycoon
Tycoon
Posts: 8271
Joined: 17 Jan 2007 00:14

Re: "Improved" sub-tropic TGP landscape generator

Post by Eddi »

maybe with rivers you get better results?
User avatar
Sylf
President
President
Posts: 957
Joined: 23 Nov 2010 21:25
Location: ::1

Re: "Improved" sub-tropic TGP landscape generator

Post by Sylf »

Or maybe have bigger plateaus like arctic maps?
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 29 guests