Index: obj/baum.h =================================================================== --- obj/baum.h (revision 9152) +++ obj/baum.h (working copy) @@ -50,8 +50,6 @@ static uint16 random_tree_for_climate_intern(climate cl); - static uint8 plant_tree_on_coordinate(koord pos, const uint8 maximum_count, const uint8 count); - public: /** * Only the load save constructor should be called outside @@ -119,6 +117,8 @@ static bool plant_tree_on_coordinate(koord pos, const tree_desc_t *desc, const bool check_climate, const bool random_age ); + static uint8 plant_tree_on_coordinate(koord pos, const uint8 maximum_count, const uint8 count); + static bool register_desc(tree_desc_t *desc); static bool successfully_loaded(); Index: simworld.cc =================================================================== --- simworld.cc (revision 9152) +++ simworld.cc (working copy) @@ -1187,8 +1187,12 @@ } +sint8 *humidity; + void karte_t::init(settings_t* const sets, sint8 const* const h_field) { + humidity = NULL; + clear_random_mode( 7 ); mute_sound(true); if (env_t::networkmode) { @@ -1273,9 +1277,39 @@ DBG_DEBUG("karte_t::init()","distributing trees"); if (!settings.get_no_trees()) { - baum_t::distribute_trees(3); + //baum_t::distribute_trees(3); + koord pos; + for( pos.y=0; pos.yget_top() == 0 && gr->get_typ() == grund_t::boden) { + if(humidity[pos.x+get_size().x*pos.y]>75) { + const uint32 tree_probability = (humidity[pos.x+get_size().x*pos.y] - 75)/5 + 38; + uint8 number_to_plant = 0; + uint8 const max_trees_here = min(get_settings().get_max_no_of_trees_on_square(), (tree_probability - 38 + 1) / 2); + for (uint8 c2 = 0 ; c275) { + // plant spare trees, (those with low preffered density) or in an entirely tree climate + uint16 cl = 1 << get_climate(pos); + settings_t const& s = get_settings(); + if ((cl & s.get_no_tree_climates()) == 0 && ((cl & s.get_tree_climates()) != 0 || simrand(s.get_forest_inverse_spare_tree_density() * /*dichte*/3) < 100)) { + baum_t::plant_tree_on_coordinate(pos, 1, 1); + } + } + } + } + } } + delete [] humidity; + DBG_DEBUG("karte_t::init()","built timeline"); private_car_t::build_timeline_list(this); pedestrian_t::build_timeline_list(this); @@ -5966,6 +6000,29 @@ // distributes climates in a rectangle void karte_t::calc_climate_map_region( sint16 xtop, sint16 ytop, sint16 xbottom, sint16 ybottom ) { + if(humidity == NULL) { + humidity = new sint8[get_size().x * get_size().y]; + } + + for( sint16 y = ytop; y < ybottom; y++ ) { + sint8 current_humidity = ( lookup_hgt_nocheck( 0, y ) < groundwater ) ? 50 : 50; + for( sint16 x = xtop; x < xbottom; x++ ) { + sint8 gradient = x>0 ? lookup_hgt_nocheck( x, y )-lookup_hgt_nocheck( x-1, y ) : 0; + + if( lookup_hgt_nocheck( x, y ) < groundwater ) { + current_humidity += 1; + } + else { + current_humidity += 1 + gradient * 10; + } + if( current_humidity > 100 ) current_humidity = 100; + if( current_humidity < 0 ) current_humidity = 0; + + humidity[x+y*get_size().x] = current_humidity; + + } + } + if( xtop == 0 && ytop == 0 ) { climate_map.clear(); } @@ -5981,11 +6038,119 @@ if( hgt < groundwater ) { climate_map.at( x, y ) = water_climate; } + else { + climate this_climate; + + sint8 temperature = 25 - (hgt-groundwater) - simrand(2); + sint8 this_humidity = humidity[x+y*get_size().x] + simrand(5); + + if( temperature >= 20 ) { + if( this_humidity > 75 ) { + this_climate = tropic_climate; + } + else if( this_humidity > 65 ) { + this_climate = mediterran_climate; + } + else { + this_climate = desert_climate; + } + } + else if( temperature >= 15 ) { + if( this_humidity > 65 ) { + this_climate = mediterran_climate; + } + else { + this_climate = desert_climate; + } + } + else if( temperature >= 8 ) { + if( this_humidity > 65 ) { + this_climate = temperate_climate; + } + else { + this_climate = mediterran_climate; + } + } + else if( temperature >= 0 ) { + if( this_humidity > 65 ) { + this_climate = tundra_climate; + } + else { + this_climate = temperate_climate; + } + } + else if( temperature >= -10 ) { + this_climate = rocky_climate; + } + else { + this_climate = arctic_climate; + } + + climate_map.at( x, y ) = this_climate; + } + } + } + +// smooth climates + const sint32 world_size = (get_size().x)*(sint32)(get_size().y); + climate *climate_smooth = new climate[world_size]; + climate *climate_smooth_cpy = new climate[world_size]; + + for(uint16 y=0; yget_map_roughness()*(simrand(8)); + climate_smooth[x+y*(get_size().x)]=(climate)((temp_climate)/16); + } + } + } + } + + for(uint16 y=0; y allowed( 8 ); +/* minivec_tpl allowed( 8 ); { // find the next climateless tile for( sint16 y = ytop; y < ybottom; y++ ) { @@ -6035,7 +6200,7 @@ } } } - } + }*/ assign_climate_map_region( xtop, ytop, xbottom, ybottom ); }