Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,6 @@ Makefile

deploy/
config.json

# build
build/
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ project(GimuServer)

set(CMAKE_CXX_STANDARD 17)

if (NOT DEFINED GIMUSRV_FRONTEND)
set(GIMUSRV_FRONTEND "STANDALONE")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make a new CMake preset for your target platform (which uses the VCPKG_ROOT env variable) rather than allowing the build to work without a specific frontend preset.

endif()

if ("${GIMUSRV_FRONTEND}" STREQUAL "STANDALONE")
set(STANDALONE TRUE)
elseif ("${GIMUSRV_FRONTEND}" STREQUAL "PROXYAPPX")
Expand Down
13 changes: 11 additions & 2 deletions gimuserver/core/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ std::string Utils::RandomAccountID()
return r;
}

void GetLocalTime(struct tm& timeinfo, time_t& rawtime)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use localtime_r and then #define for localtime_s (or make this function constexpr if possible)

{
#ifdef _WIN32
localtime_s(&timeinfo, &rawtime);
#else
localtime_r(&rawtime, &timeinfo);
#endif
}

void Utils::AppendJsonReqToFile(const Json::Value& v, const std::string& group)
{
if (!System::Instance().LogConfig().Enable)
Expand All @@ -73,7 +82,7 @@ void Utils::AppendJsonReqToFile(const Json::Value& v, const std::string& group)
time_t rawtime;
time(&rawtime);
struct tm timeinfo;
localtime_s(&timeinfo, &rawtime);
GetLocalTime(timeinfo, rawtime);
auto ct = std::ctime(&rawtime);

p += std::filesystem::path::preferred_separator;
Expand Down Expand Up @@ -101,7 +110,7 @@ void Utils::AppendJsonResToFile(const Json::Value& v, const std::string& group)
time_t rawtime;
time(&rawtime);
struct tm timeinfo;
localtime_s(&timeinfo, &rawtime);
GetLocalTime(timeinfo, rawtime);
auto ct = std::ctime(&rawtime);

p += std::filesystem::path::preferred_separator;
Expand Down
2 changes: 1 addition & 1 deletion gimuserver/db/MigrationManager_Register.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "MigrationManager.hpp"
#include "migrations/CreateDefaultTables.hpp"

#define ADD(x) m_migs.push_back(std::make_shared<Migrations::##x>());
#define ADD(x) m_migs.push_back(std::make_shared<Migrations::x>());

void MigrationManager::Register()
{
Expand Down
2 changes: 1 addition & 1 deletion gimuserver/gme/GmeController_Handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "handlers/DeckEditHandler.hpp"
#include "handlers/MissionStartHandler.hpp"

#define REGISTER(name) InitializeHandler(std::make_shared<Handler::##name##Handler>())
#define REGISTER(name) InitializeHandler(std::make_shared<Handler::name##Handler>())

void GmeController::InitializeHandlers()
{
Expand Down
2 changes: 1 addition & 1 deletion gimuserver/gme/handlers/InitializeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void Handler::InitializeHandler::OnUserInfoSuccess(const drogon::orm::Result& re
if (result.size() > 0)
{
int col = 0;
auto& sql = result[0];
const auto& sql = result[0];
user.info.accountID = sql[col++].as<std::string>();
user.info.handleName = sql[col++].as<std::string>();
user.info.debugMode = sql[col++].as<bool>() ? 1 : 0;
Expand Down
2 changes: 1 addition & 1 deletion gimuserver/gme/handlers/UserInfoHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void Handler::UserInfoHandler::Handle(UserInfo& user, DrogonCallback cb, const J
if (result.size() > 0)
{
int col = 0;
auto& sql = result[0];
const auto& sql = result[0];
user.teamInfo.UserID = user.info.userID;
user.teamInfo.Level = sql[col++].as<uint32_t>();
user.teamInfo.Exp = sql[col++].as<int64_t>();
Expand Down