Skip to content

Commit

Permalink
meta.json: added version and optional outside color
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWillard committed Oct 18, 2021
1 parent 350b4a9 commit 23d059b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,25 @@ else()
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH)

execute_process(
COMMAND git describe --tags --abbrev=0
OUTPUT_VARIABLE GIT_LAST_TAG
)

string(STRIP "${GIT_REV}" GIT_REV)
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
string(STRIP "${GIT_DIFF}" GIT_DIFF)
string(STRIP "${GIT_TAG}" GIT_TAG)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
string(STRIP "${GIT_LAST_TAG}" GIT_LAST_TAG)
endif()

set(VERSION "#include \"version.h\"
const std::string GRAD_MEH_GIT_REV = \"${GIT_REV}${GIT_DIFF}\";
const std::string GRAD_MEH_GIT_TAG = \"${GIT_TAG}\";
const std::string GRAD_MEH_GIT_BRANCH = \"${GIT_BRANCH}\";
const std::string GRAD_MEH_GIT_LAST_TAG = \"${GIT_LAST_TAG}\";
")

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp)
Expand Down
9 changes: 7 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ void writeMeta(const std::string& worldName, const int32_t& worldSize, fs::path&
client::invoker_lock threadLock;
auto mapConfig = sqf::config_entry(sqf::config_file()) >> "CfgWorlds" >> worldName;
nl::json meta;
meta["version"] = GRAD_MEH_FORMAT_VERSION;
meta["worldName"] = boost::algorithm::to_lower_copy(worldName);
meta["version"] = GRAD_MEH_GIT_LAST_TAG;
meta["worldName"] = ba::to_lower_copy(worldName);
meta["worldSize"] = worldSize;
meta["author"] = sqf::get_text(mapConfig >> "author");
meta["displayName"] = sqf::get_text(mapConfig >> "description");
Expand All @@ -74,6 +74,11 @@ void writeMeta(const std::string& worldName, const int32_t& worldSize, fs::path&
meta["gridOffsetX"] = sqf::get_number(mapConfig >> "Grid" >> "offsetX");
meta["gridOffsetY"] = sqf::get_number(mapConfig >> "Grid" >> "offsetY");

auto colorArray = sqf::get_array(mapConfig >> "OutsideTerrain" >> "colorOutside").to_array();
if (!colorArray.empty()) {
meta["colorOutside"] = std::vector<float_t>(colorArray.begin(), colorArray.end());
}

auto gridArray = nl::json::array();

for (auto& grid : sqf::config_classes("true", (mapConfig >> "Grid"))) {
Expand Down
1 change: 1 addition & 0 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
extern const std::string GRAD_MEH_GIT_REV;
extern const std::string GRAD_MEH_GIT_TAG;
extern const std::string GRAD_MEH_GIT_BRANCH;
extern const std::string GRAD_MEH_GIT_LAST_TAG;

0 comments on commit 23d059b

Please sign in to comment.