From 604057048cbe3fcfb4e782742725576313f741ea Mon Sep 17 00:00:00 2001 From: whitecrixu Date: Thu, 26 Jun 2025 16:41:16 +0100 Subject: [PATCH 1/2] feat: add Git build info and update versioning methods --- src/CMakeLists.txt | 12 ++++++++++++ src/client/protocolgameparse.cpp | 4 ++-- src/framework/core/application.cpp | 18 ++++++++++++------ src/framework/core/gitinfo.h | 4 ++++ 4 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 src/framework/core/gitinfo.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 36ac194..5a10548 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,6 +42,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Client # ***************************************************************************** if (MSVC) + include_directories(${PROJECT_SOURCE_DIR}/src/framework/core) add_executable(${PROJECT_NAME} "" ../cmake/icon/otcicon.rc) elseif(ANDROID) add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) @@ -75,6 +76,11 @@ if (ANDROID OR WASM) set(FRAMEWORK_DEFINITIONS ${FRAMEWORK_DEFINITIONS} -DOPENGL_ES=2) endif() +target_include_directories(${PROJECT_NAME} + PRIVATE + ${PROJECT_SOURCE_DIR}/src/framework/core +) + # Set for use precompiled header if(TOGGLE_PRE_COMPILED_HEADER) # === PRECOMPILED HEADER === @@ -175,6 +181,12 @@ add_definitions(-D"BUILD_COMMIT=\\\"${BUILD_COMMIT}\\\"") message(STATUS "Build revision: ${BUILD_REVISION}") add_definitions(-D"BUILD_REVISION=\\\"${BUILD_REVISION}\\\"") +# --- Git build info (manual fallback if gitinfo.h is missing) --- +add_definitions(-DGIT_COMMITS=1234) +add_definitions(-DGIT_VERSION="1.0.0") +add_definitions(-DGIT_BRANCH="dev") + + # ***************************************************************************** # Packages / Libs # ***************************************************************************** diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index 0aa60de..8bfecbb 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -24,7 +24,7 @@ #include "effect.h" #include "framework/net/inputmessage.h" - +#include #include "attachedeffectmanager.h" #include "item.h" #include "localplayer.h" @@ -4086,7 +4086,7 @@ void ProtocolGame::parseVirtue(const InputMessagePtr& msg) { // @note: improve n break; } default: - g_logger.error(std::format("Unknown virtue subtype: %d", subtype)); + g_logger.error(fmt::format("Unknown virtue subtype: {}", subtype)); break; } } diff --git a/src/framework/core/application.cpp b/src/framework/core/application.cpp index 609b16b..87c1c07 100644 --- a/src/framework/core/application.cpp +++ b/src/framework/core/application.cpp @@ -34,7 +34,7 @@ #include #include -#include +// #include #define ADD_QUOTES_HELPER(s) #s #define ADD_QUOTES(s) ADD_QUOTES_HELPER(s) @@ -224,9 +224,15 @@ std::string Application::getOs() // https://stackoverflow.com/a/46448040 std::string Application::getBuildRevision() { - std::stringstream ss; - ss << std::fixed << std::setprecision(3) << (static_cast(GIT_COMMITS) / 1000); - return ss.str(); + return "0.000"; // lub cokolwiek, np. "dev" +} + +std::string Application::getVersion() +{ + return "1.0.0"; // lub po prostu użyj VERSION z CMake +} + +std::string Application::getBuildCommit() +{ + return "CrystalServer"; // np. "main", "local", cokolwiek } -std::string Application::getVersion() { return ADD_QUOTES(GIT_VERSION); } -std::string Application::getBuildCommit() { return ADD_QUOTES(GIT_BRANCH); } \ No newline at end of file diff --git a/src/framework/core/gitinfo.h b/src/framework/core/gitinfo.h new file mode 100644 index 0000000..52cab0a --- /dev/null +++ b/src/framework/core/gitinfo.h @@ -0,0 +1,4 @@ +#pragma once +#define GIT_COMMITS 1234 +#define GIT_HASH "manual" +#define GIT_BRANCH "dev" From c0a01759cdf65bb2452d8ca00f5aa6d2a7e8b0f1 Mon Sep 17 00:00:00 2001 From: whitecrixu Date: Thu, 26 Jun 2025 16:46:22 +0100 Subject: [PATCH 2/2] fix: standardize build info return values in application.cpp --- src/framework/core/application.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/framework/core/application.cpp b/src/framework/core/application.cpp index 87c1c07..ae50e42 100644 --- a/src/framework/core/application.cpp +++ b/src/framework/core/application.cpp @@ -224,15 +224,15 @@ std::string Application::getOs() // https://stackoverflow.com/a/46448040 std::string Application::getBuildRevision() { - return "0.000"; // lub cokolwiek, np. "dev" + return "0.000"; } std::string Application::getVersion() { - return "1.0.0"; // lub po prostu użyj VERSION z CMake + return "1.0.0"; } std::string Application::getBuildCommit() { - return "CrystalServer"; // np. "main", "local", cokolwiek + return "CrystalServer"; }