MCPcopy Create free account
hub / github.com/DFHack/dfhack / SetRegionTile

Function SetRegionTile

plugins/remotefortressreader/remotefortressreader.cpp:2052–2111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2050}
2051
2052static void SetRegionTile(RegionTile * out, df::region_map_entry * e1)
2053{
2054 df::world_region * region = df::world_region::find(e1->region_id);
2055 df::world_geo_biome * geoBiome = df::world_geo_biome::find(e1->geo_index);
2056 out->set_rainfall(e1->rainfall);
2057 out->set_vegetation(e1->vegetation);
2058 out->set_temperature(e1->temperature);
2059 out->set_evilness(e1->evilness);
2060 out->set_drainage(e1->drainage);
2061 out->set_volcanism(e1->volcanism);
2062 out->set_savagery(e1->savagery);
2063 out->set_salinity(e1->salinity);
2064 if (region->type == world_region_type::Lake)
2065 out->set_water_elevation(region->lake_surface);
2066 else
2067 out->set_water_elevation(99);
2068
2069 int topLayer = 0;
2070 for (size_t i = 0; i < geoBiome->layers.size(); i++)
2071 {
2072 auto layer = geoBiome->layers[i];
2073 if (layer->top_height == 0)
2074 {
2075 topLayer = layer->mat_index;
2076 }
2077 if (layer->type != geo_layer_type::SOIL
2078 && layer->type != geo_layer_type::SOIL_OCEAN
2079 && layer->type != geo_layer_type::SOIL_SAND)
2080 {
2081 auto mat = out->add_stone_materials();
2082 mat->set_mat_index(layer->mat_index);
2083 mat->set_mat_type(0);
2084 }
2085 }
2086 auto surfaceMat = out->mutable_surface_material();
2087 surfaceMat->set_mat_index(topLayer);
2088 surfaceMat->set_mat_type(0);
2089
2090 for (size_t i = 0; i < region->population.size(); i++)
2091 {
2092 auto pop = region->population[i];
2093 if (pop->type == world_population_type::Grass)
2094 {
2095 auto plantMat = out->add_plant_materials();
2096
2097 plantMat->set_mat_index(pop->plant);
2098 plantMat->set_mat_type(419);
2099 }
2100 else if (pop->type == world_population_type::Tree)
2101 {
2102 auto plantMat = out->add_tree_materials();
2103
2104 plantMat->set_mat_index(pop->plant);
2105 plantMat->set_mat_type(419);
2106 }
2107 }
2108#if DF_VERSION_INT >= 43005
2109 out->set_snow(e1->snowfall);

Callers 2

GetWorldMapNewFunction · 0.85
AddRegionTilesFunction · 0.85

Calls 2

findFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected