From 924ae0c500120f8f23714ceb92bc64ac8682a93c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 18 Jun 2023 14:26:30 +0800 Subject: [PATCH] 1 --- server/gameserver/app.cc | 12 +++++++++--- server/gameserver/app.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server/gameserver/app.cc b/server/gameserver/app.cc index 83a3e649..bd19dfc4 100644 --- a/server/gameserver/app.cc +++ b/server/gameserver/app.cc @@ -464,8 +464,13 @@ 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, "z:i:t:r:f:n:")) != -1) { switch (ch) { + case 'z': + { + zone_id = a8::XValue(optarg); + } + break; case 'n': { node_id = a8::XValue(optarg); @@ -493,12 +498,13 @@ bool App::ParseOpt() break; } } - return instance_id > 0 && node_id > 0; + return zone_id > 0 && instance_id > 0 && node_id > 0; } std::string App::NewUuid() { - return a8::XValue(uuid.Generate()).GetString(); + std::string id = a8::Format("%d%d", {zone_id, uuid.Generate()}); + return id; } bool App::HasFlag(int flag) diff --git a/server/gameserver/app.h b/server/gameserver/app.h index 4163af3a..6f8b80e5 100644 --- a/server/gameserver/app.h +++ b/server/gameserver/app.h @@ -62,6 +62,7 @@ public: a8::uuid::SnowFlake uuid; public: + int zone_id = 0; int instance_id = 0; int node_id = 0; bool is_test_mode = false;