From 5ce6fceaccf6ca797cde9f8a87aa4b85738a09b2 Mon Sep 17 00:00:00 2001 From: Japa Date: Wed, 16 Sep 2015 23:25:23 +0530 Subject: [PATCH 1/6] Send the center with the world map, based off current embark if available, otherwise adventurer position. --- plugins/remotefortressreader.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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; } From e49272854cf4c50fc2ee69c7718a6d1c4ef42ccb Mon Sep 17 00:00:00 2001 From: Japa Date: Wed, 16 Sep 2015 23:26:52 +0530 Subject: [PATCH 2/6] Add basic army info to RemoteFortressReader.proto --- plugins/proto/RemoteFortressReader.proto | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index c0d7104a7..ffcaea79f 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; +} \ No newline at end of file From 129218d5f8de7d2dd00196ec63812d1930c73092 Mon Sep 17 00:00:00 2001 From: Japa Date: Wed, 16 Sep 2015 23:29:21 +0530 Subject: [PATCH 3/6] fix whitespace. --- plugins/proto/RemoteFortressReader.proto | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index fef836929..51d78049d 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -302,9 +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; + optional int32 center_x = 17; + optional int32 center_y = 18; + optional int32 center_z = 19; } message RegionMaps @@ -342,16 +342,16 @@ message CreatureRawList 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; + 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; + repeated Army armies = 1; } From a56a427d1233b3538c0c85a13029aed798c2b985 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 19 Sep 2015 17:34:58 -0400 Subject: [PATCH 4/6] Make Filesystem::is* functions handle nonexistent paths properly If stat() failed, these functions could read from an uninitialized stat struct and return "true" for paths that didn't exist. --- library/modules/Filesystem.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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) \ From 051a1f9661c7732decbd6598bab698f0330ccc80 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 19 Sep 2015 18:00:59 -0400 Subject: [PATCH 5/6] Update xml --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 88d65b18a129b39e679ccc69e3128d022e4c4af4 Mon Sep 17 00:00:00 2001 From: warmist Date: Sun, 20 Sep 2015 18:10:19 +0300 Subject: [PATCH 6/6] Fix bug in gm-editor Fix a small bug that broken some flag editing. --- scripts/gui/gm-editor.lua | 1 + 1 file changed, 1 insertion(+) 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