From 6de09d12c66943638980660e25e90d6377a82264 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 28 Apr 2023 16:12:52 +0800 Subject: [PATCH] 1 --- server/gameserver/GGListener.cc | 2 +- server/gameserver/app.cc | 10 +++++----- server/gameserver/app.h | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index 18d8ecaa..3d30dae4 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -157,6 +157,6 @@ long long GGListener::GetSentBytesNum() void GGListener::OnListenError(int errorid) { a8::XPrintf("GGListeneron_error %d\n", {errorid}); - App::Instance()->terminated = true; + App::Instance()->Terminate(); exit(1); } diff --git a/server/gameserver/app.cc b/server/gameserver/app.cc index 0d1b1b7f..34f6a24f 100644 --- a/server/gameserver/app.cc +++ b/server/gameserver/app.cc @@ -123,8 +123,8 @@ static void SavePerfLog() bool App::Init(int argc, char* argv[]) { signal(SIGPIPE, SIG_IGN); - this->argc = argc; - this->argv = argv; + this->argc_ = argc; + this->argv_ = argv; if (!ParseOpt()) { if (node_id <= 0) { @@ -210,7 +210,7 @@ bool App::Init(int argc, char* argv[]) [] (int event, const a8::Args* args) { if (a8::TIMER_EXEC_EVENT == event) { - App::Instance()->terminated = true; + App::Instance()->terminated_ = true; } } ); @@ -258,7 +258,7 @@ int App::Run() f8::UdpLog::Instance()->Info("gameserver running", {}); last_run_tick_ = a8::XGetTickCount(); int delta_time = 0; - while (!terminated) { + while (!terminated_) { a8::tick_t begin_tick = a8::XGetTickCount(); Global::g_nowtime = time(nullptr); QuickExecute(delta_time); @@ -464,7 +464,7 @@ void App::UnInitLog() bool App::ParseOpt() { int ch = 0; - while ((ch = getopt(argc, argv, "i:t:r:f:n:")) != -1) { + while ((ch = getopt(argc_, argv_, "i:t:r:f:n:")) != -1) { switch (ch) { case 'n': { diff --git a/server/gameserver/app.h b/server/gameserver/app.h index 53839b4a..6dca01e0 100644 --- a/server/gameserver/app.h +++ b/server/gameserver/app.h @@ -38,6 +38,7 @@ public: void UnSetFlag(int flag); long long AllocTempHeroUniId(); long long AllocTempWeaponUniId(); + void Terminate() { terminated_ = true; } private: void QuickExecute(int delta_time); @@ -55,11 +56,6 @@ private: bool ParseOpt(); void FreeSocketMsgQueue(); -public: - int argc = 0; - char** argv = nullptr; - volatile bool terminated = false; - public: int instance_id = 0; int node_id = 0; @@ -81,6 +77,10 @@ private: std::set flags; private: + int argc_ = 0; + char** argv_ = nullptr; + volatile bool terminated_ = false; + a8::uuid::SnowFlake uuid_; long long last_run_tick_ = 0;