From 80ce11095022460dce22f3240c6f059e5b380589 Mon Sep 17 00:00:00 2001 From: azw Date: Fri, 10 Nov 2023 11:01:52 +0000 Subject: [PATCH] 1 --- server/masterserver/CMakeLists.txt | 8 ++++---- server/masterserver/app.cc | 7 ++++++- server/masterserver/app.h | 2 ++ server/masterserver/jsondatamgr.cc | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/server/masterserver/CMakeLists.txt b/server/masterserver/CMakeLists.txt index e4af8fb..7af27dd 100644 --- a/server/masterserver/CMakeLists.txt +++ b/server/masterserver/CMakeLists.txt @@ -84,7 +84,7 @@ set(EXECUTABLE_OUTPUT_PATH ) add_executable( - masterserver${GAME_ID} ${SRC_LIST} + masterserver ${SRC_LIST} ) add_custom_target(script_pb_protocol ALL) @@ -92,12 +92,12 @@ add_custom_command(TARGET script_pb_protocol PRE_BUILD COMMAND python ../../third_party/tools/scripts/construct/build_pb.py --cpp_out=. --pb_files=ss_proto,ss_msgid --nohooks 1 ) -add_dependencies(masterserver${GAME_ID} script_pb_protocol) +add_dependencies(masterserver script_pb_protocol) if (CMAKE_BUILD_TYPE STREQUAL "Debug") target_link_libraries( - masterserver${GAME_ID} + masterserver pthread mysqlclient protobuf @@ -115,7 +115,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") ) else() target_link_libraries( - masterserver${GAME_ID} + masterserver pthread mysqlclient protobuf diff --git a/server/masterserver/app.cc b/server/masterserver/app.cc index d4be168..74de620 100755 --- a/server/masterserver/app.cc +++ b/server/masterserver/app.cc @@ -28,7 +28,7 @@ static void SavePerfLog() const std::string App::GetPkgName() { - return a8::Format("game%d_masterserver", {GAME_ID}); + return a8::Format("game%d_masterserver", {App::Instance()->GetGameId()}); } void App::Init() @@ -106,3 +106,8 @@ void App::DispatchSocketMsg(f8::MsgHdr* hdr) } f8::App::Instance()->FreeSocketMsg(hdr); } + +int App::GetGameId() const +{ + return GAME_ID; +} diff --git a/server/masterserver/app.h b/server/masterserver/app.h index 1c9e907..60c3caa 100644 --- a/server/masterserver/app.h +++ b/server/masterserver/app.h @@ -25,6 +25,8 @@ public: virtual bool HasTask() override; virtual void DispatchSocketMsg(f8::MsgHdr* hdr) override; + int GetGameId() const; + private: void QuickExecute(); void SlowerExecute(); diff --git a/server/masterserver/jsondatamgr.cc b/server/masterserver/jsondatamgr.cc index f1e9977..9cccbe9 100644 --- a/server/masterserver/jsondatamgr.cc +++ b/server/masterserver/jsondatamgr.cc @@ -9,9 +9,9 @@ void JsonDataMgr::Init() { if (!f8::IsOnlineEnv()) { if (f8::IsTestEnv()) { - work_path_ = a8::Format("../%d_test_config", {GAME_ID}); + work_path_ = a8::Format("../%d_test_config", {App::Instance()->GetGameId()}); } else { - work_path_ = a8::Format("../%d_dev_config", {GAME_ID}); + work_path_ = a8::Format("../%d_dev_config", {App::Instance()->GetGameId()}); } }