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

Function GetWorldMap

plugins/remotefortressreader/remotefortressreader.cpp:1968–2050  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1966}
1967
1968static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in, WorldMap *out)
1969{
1970 if (!df::global::world->world_data)
1971 {
1972 out->set_world_width(0);
1973 out->set_world_height(0);
1974 return CR_FAILURE;
1975 }
1976 df::world_data * data = df::global::world->world_data;
1977 if (!data->region_map)
1978 {
1979 out->set_world_width(0);
1980 out->set_world_height(0);
1981 return CR_FAILURE;
1982 }
1983 int width = data->world_width;
1984 int height = data->world_height;
1985 out->set_world_width(width);
1986 out->set_world_height(height);
1987 out->set_name(DF2UTF(Translation::translateName(&(data->name), false)));
1988 out->set_name_english(DF2UTF(Translation::translateName(&(data->name), true)));
1989 auto poles = data->flip_latitude;
1990 switch (poles)
1991 {
1992 case df::pole_type::None:
1993 out->set_world_poles(WorldPoles::NO_POLES);
1994 break;
1995 case df::pole_type::North:
1996 out->set_world_poles(WorldPoles::NORTH_POLE);
1997 break;
1998 case df::pole_type::South:
1999 out->set_world_poles(WorldPoles::SOUTH_POLE);
2000 break;
2001 case df::pole_type::Both:
2002 out->set_world_poles(WorldPoles::BOTH_POLES);
2003 break;
2004 default:
2005 break;
2006 }
2007 for (int yy = 0; yy < height; yy++)
2008 for (int xx = 0; xx < width; xx++)
2009 {
2010 df::region_map_entry * map_entry = &data->region_map[xx][yy];
2011 df::world_region * region = data->regions[map_entry->region_id];
2012 out->add_elevation(map_entry->elevation);
2013 out->add_rainfall(map_entry->rainfall);
2014 out->add_vegetation(map_entry->vegetation);
2015 out->add_temperature(map_entry->temperature);
2016 out->add_evilness(map_entry->evilness);
2017 out->add_drainage(map_entry->drainage);
2018 out->add_volcanism(map_entry->volcanism);
2019 out->add_savagery(map_entry->savagery);
2020 out->add_salinity(map_entry->salinity);
2021 auto clouds = out->add_clouds();
2022#if DF_VERSION_INT > 34011
2023 clouds->set_cirrus(map_entry->clouds.bits.cirrus);
2024 clouds->set_cumulus((RemoteFortressReader::CumulusType)map_entry->clouds.bits.cumulus);
2025 clouds->set_fog((RemoteFortressReader::FogType)map_entry->clouds.bits.fog);

Callers

nothing calls this directly

Calls 3

DF2UTFFunction · 0.85
GetMapCenterFunction · 0.85
set_nameMethod · 0.45

Tested by

no test coverage detected