src/tgp.cpp
changeset 11091 6b5352725f43
parent 11088 3c315ff5f36a
child 11109 3a53e7dcff4c
equal deleted inserted replaced
11090:3ac220ac9a47 11091:6b5352725f43
   201 
   201 
   202 /** Noise amplitudes (multiplied by 1024)
   202 /** Noise amplitudes (multiplied by 1024)
   203  * - indexed by "smoothness setting" and log2(frequency) */
   203  * - indexed by "smoothness setting" and log2(frequency) */
   204 static const amplitude_t _amplitudes_by_smoothness_and_frequency[4][12] = {
   204 static const amplitude_t _amplitudes_by_smoothness_and_frequency[4][12] = {
   205 	/* Very smooth */
   205 	/* Very smooth */
   206 	{1000,  350,  123,   43,   15,    1,     1,    0,    0,    0,    0,    0},
   206 	{16000,  5600,  1968,   688,   240,    16,    16,    0,    0,    0,    0,    0},
   207 	/* Smooth */
   207 	/* Smooth */
   208 	{1000, 1000,  403,  200,   64,    8,     1,    0,    0,    0,    0,    0},
   208 	{16000, 16000,  6448,  3200,  1024,   128,    16,    0,    0,    0,    0,    0},
   209 	/* Rough */
   209 	/* Rough */
   210 	{1000, 1200,  800,  500,  200,   16,     4,    0,    0,    0,    0,    0},
   210 	{16000, 19200, 12800,  8000,  3200,   256,    64,    0,    0,    0,    0,    0},
   211 	/* Very Rough */
   211 	/* Very Rough */
   212 	{1500, 1000, 1200, 1000,  500,   32,    20,    0,    0,    0,    0,    0},
   212 	{24000, 16000, 19200, 16000,  8000,   512,   320,    0,    0,    0,    0,    0},
   213 };
   213 };
   214 
   214 
   215 /** Desired water percentage (100% == 1024) - indexed by _settings_game.difficulty.quantity_sea_lakes */
   215 /** Desired water percentage (100% == 1024) - indexed by _settings_game.difficulty.quantity_sea_lakes */
   216 static const amplitude_t _water_percent[4] = {20, 80, 250, 400};
   216 static const amplitude_t _water_percent[4] = {20, 80, 250, 400};
   217 
   217 
   265 /** RandomHeight() generator */
   265 /** RandomHeight() generator */
   266 static inline height_t RandomHeight(amplitude_t rMax)
   266 static inline height_t RandomHeight(amplitude_t rMax)
   267 {
   267 {
   268 	amplitude_t ra = (Random() << 16) | (Random() & 0x0000FFFF);
   268 	amplitude_t ra = (Random() << 16) | (Random() & 0x0000FFFF);
   269 	height_t rh;
   269 	height_t rh;
   270 	/* Scale the amplitude for better resolution */
       
   271 	rMax *= 16;
       
   272 	/* Spread height into range -rMax..+rMax */
   270 	/* Spread height into range -rMax..+rMax */
   273 	rh = A2H(ra % (2 * rMax + 1) - rMax);
   271 	rh = A2H(ra % (2 * rMax + 1) - rMax);
   274 	return rh;
   272 	return rh;
   275 }
   273 }
   276 
   274