From eda56a2ca66ee0953d71882e0bf407f02ddb5fa2 Mon Sep 17 00:00:00 2001 From: azw Date: Sat, 11 Nov 2023 13:39:55 +0000 Subject: [PATCH] 1 --- server/wsproxy/CMakeLists.txt | 10 +++++----- server/wsproxy/app.cc | 13 ++++++++++++- server/wsproxy/app.h | 2 ++ server/wsproxy/jsondatamgr.cc | 4 ++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/server/wsproxy/CMakeLists.txt b/server/wsproxy/CMakeLists.txt index 7fdf533..fda5acc 100644 --- a/server/wsproxy/CMakeLists.txt +++ b/server/wsproxy/CMakeLists.txt @@ -78,7 +78,7 @@ set(EXECUTABLE_OUTPUT_PATH ) add_executable( - wsproxy${GAME_ID} ${SRC_LIST} + wsproxy ${SRC_LIST} ) add_custom_target(script_pb_protocol ALL) @@ -86,10 +86,10 @@ add_custom_command(TARGET script_pb_protocol PRE_BUILD COMMAND python ../tools/scripts/construct/build_pb.py ) -add_dependencies(wsproxy${GAME_ID} script_pb_protocol) +add_dependencies(wsproxy script_pb_protocol) target_link_libraries( - wsproxy${GAME_ID} + wsproxy pthread mysqlclient protobuf @@ -106,12 +106,12 @@ target_link_libraries( if (CMAKE_BUILD_TYPE STREQUAL "Debug") target_link_libraries( - wsproxy${GAME_ID} + wsproxy behaviac_gcc_debug ) else() target_link_libraries( - wsproxy${GAME_ID} + wsproxy tcmalloc behaviac_gcc_release ) diff --git a/server/wsproxy/app.cc b/server/wsproxy/app.cc index e00006b..a2c2761 100644 --- a/server/wsproxy/app.cc +++ b/server/wsproxy/app.cc @@ -84,7 +84,7 @@ static void SavePerfLog() const std::string App::GetPkgName() { - return a8::Format("game%d_wsproxy", {GAME_ID}); + return a8::Format("game%d_wsproxy", {App::Instance()->GetGameId()}); } void App::Init() @@ -496,3 +496,14 @@ void App::DispatchUdpMsg() udp_working_msgnode_size_ = 0; } } + +int App::GetGameId() const +{ +#ifdef DEBUG + std::string game_id = a8::XValue(getenv("_")).GetString(); + a8::ReplaceString(game_id, "./wsproxy", ""); + return a8::XValue(game_id); +#else + return GAME_ID; +#endif +} diff --git a/server/wsproxy/app.h b/server/wsproxy/app.h index 3cc27e3..7bd3c9c 100644 --- a/server/wsproxy/app.h +++ b/server/wsproxy/app.h @@ -40,6 +40,8 @@ public: int GetMsgNodeSize() { return msgnode_size_;} int GetUdpMsgNodeSize() { return udp_msgnode_size_;} + int GetGameId() const; + private: void QuickExecute(); void SlowerExecute(); diff --git a/server/wsproxy/jsondatamgr.cc b/server/wsproxy/jsondatamgr.cc index d7a0aae..8e109d0 100644 --- a/server/wsproxy/jsondatamgr.cc +++ b/server/wsproxy/jsondatamgr.cc @@ -12,9 +12,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()}); } }