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

Function GetMapCenter

plugins/remotefortressreader/remotefortressreader.cpp:1902–1942  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1900}
1901
1902DFCoord GetMapCenter()
1903{
1904 DFCoord output;
1905//FIXME: Does this even still exist?
1906//#if DF_VERSION_INT > 34011
1907// auto embark = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
1908// if (embark)
1909// {
1910// df::embark_location location = embark->location;
1911// output.x = (location.region_pos.x * 16) + 8;
1912// output.y = (location.region_pos.y * 16) + 8;
1913// output.z = 100;
1914// df::world_data * data = df::global::world->world_data;
1915// if (data && data->region_map)
1916// {
1917// output.z = data->region_map[location.region_pos.x][location.region_pos.y].elevation;
1918// }
1919// }
1920// else
1921//#endif
1922 if (Maps::IsValid())
1923 {
1924 int x, y, z;
1925 Maps::getPosition(x, y, z);
1926 output = DFCoord(x, y, z);
1927 }
1928#if DF_VERSION_INT > 34011
1929 else
1930 for (size_t i = 0; i < df::global::world->armies.all.size(); i++)
1931 {
1932 df::army * thisArmy = df::global::world->armies.all[i];
1933 if (thisArmy->flags.is_set(df::enums::army_flags::player))
1934 {
1935 output.x = (thisArmy->pos.x / 3) - 1;
1936 output.y = (thisArmy->pos.y / 3) - 1;
1937 output.z = thisArmy->pos.z;
1938 }
1939 }
1940#endif
1941 return output;
1942}
1943
1944static command_result GetWorldMapCenter(color_ostream &stream, const EmptyMessage *in, WorldMap *out)
1945{

Callers 3

GetWorldMapCenterFunction · 0.85
GetWorldMapFunction · 0.85
GetWorldMapNewFunction · 0.85

Calls 2

is_setMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected