diff --git a/library/modules/Filesystem.cpp b/library/modules/Filesystem.cpp index 0731e9991..05d4e4fda 100644 --- a/library/modules/Filesystem.cpp +++ b/library/modules/Filesystem.cpp @@ -128,18 +128,19 @@ bool Filesystem::exists (std::string path) _filetype Filesystem::filetype (std::string path) { STAT_STRUCT info; - Filesystem::stat(path, info); + if (!Filesystem::stat(path, info)) + return FILETYPE_NONE; return mode2type(info.st_mode); } bool Filesystem::isfile (std::string path) { - return Filesystem::filetype(path) == FILETYPE_FILE; + return Filesystem::exists(path) && Filesystem::filetype(path) == FILETYPE_FILE; } bool Filesystem::isdir (std::string path) { - return Filesystem::filetype(path) == FILETYPE_DIRECTORY; + return Filesystem::exists(path) && Filesystem::filetype(path) == FILETYPE_DIRECTORY; } #define DEFINE_STAT_TIME_WRAPPER(attr) \ diff --git a/library/xml b/library/xml index 2a49a0761..32960d384 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 2a49a0761e4413603d9a72542077755cea2ad56d +Subproject commit 32960d38410e7caedf2b38cff7ef3f21c1785bbd diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index 1344bb694..51d78049d 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -302,6 +302,9 @@ message WorldMap repeated int32 salinity = 14; optional int32 map_x = 15; optional int32 map_y = 16; + optional int32 center_x = 17; + optional int32 center_y = 18; + optional int32 center_z = 19; } message RegionMaps @@ -336,3 +339,19 @@ message CreatureRawList { repeated CreatureRaw creature_raws = 1; } + +message Army +{ + optional int32 id = 1; + optional int32 pos_x = 2; + optional int32 pos_y = 3; + optional int32 pos_z = 4; + optional UnitDefinition leader = 5; + repeated UnitDefinition members = 6; + optional uint32 flags = 7; +} + +message ArmyList +{ + repeated Army armies = 1; +} diff --git a/plugins/remotefortressreader.cpp b/plugins/remotefortressreader.cpp index 857c70b07..ec1d6f636 100644 --- a/plugins/remotefortressreader.cpp +++ b/plugins/remotefortressreader.cpp @@ -42,6 +42,8 @@ #include "df/region_map_entry.h" #include "df/world_region_details.h" +#include "df/army.h" +#include "df/army_flags.h" #include "df/unit.h" #include "df/creature_raw.h" @@ -1256,6 +1258,23 @@ static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in, clouds->set_front((RemoteFortressReader::FrontType)map_entry->clouds.bits.front); clouds->set_stratus((RemoteFortressReader::StratusType)map_entry->clouds.bits.stratus); } + int32_t pos_x = 0, pos_y = 0, pos_z = 0; + if (Maps::IsValid()) + Maps::getPosition(pos_x, pos_y, pos_z); + else + for (int i = 0; i < df::global::world->armies.all.size(); i++) + { + df::army * thisArmy = df::global::world->armies.all[i]; + if (thisArmy->flags.is_set(df::enums::army_flags::player)) + { + pos_x = (thisArmy->pos.x / 3) - 1; + pos_y = (thisArmy->pos.y / 3) - 1; + pos_z = thisArmy->pos.z; + } + } + out->set_center_x(pos_x); + out->set_center_y(pos_y); + out->set_center_z(pos_z); return CR_OK; } diff --git a/scripts/gui/gm-editor.lua b/scripts/gui/gm-editor.lua index 2afca8f23..9526d396d 100644 --- a/scripts/gui/gm-editor.lua +++ b/scripts/gui/gm-editor.lua @@ -174,6 +174,7 @@ function GmEditorUi:getSelectedEnumType() local trg=self:currentTarget() local trg_key=trg.keys[self.subviews.list_main:getSelected()] if trg.target._field==nil then return nil end + if trg.target:_field(trg_key)==nil then return nil end local enum=trg.target:_field(trg_key)._type if enum._kind=="enum-type" then return enum