From b0babbb1f7da1cb952ef2d32fe4cf0eb2e62837b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 30 May 2019 16:32:48 +0800 Subject: [PATCH 01/10] 1 --- server/bin/monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/bin/monitor.py b/server/bin/monitor.py index a455261..77a08d3 100644 --- a/server/bin/monitor.py +++ b/server/bin/monitor.py @@ -24,7 +24,7 @@ def monitor_gs(): pids = getRuningProgramPids('gameserver2001') if len(pids) <= 0: print('zzzz') - os.popen('nohup ./gameserver2001 -i1 >> gameserver2001.out 2>&1 &') + os.popen('nohup ./gameserver2001 -n1 -i1 >> gameserver2001.out 2>&1 &') time.sleep(2) monitor_gs() From cdc6f0ffd029086b9708b3937b0879bbd9dd9e19 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 30 May 2019 16:39:51 +0800 Subject: [PATCH 02/10] 1 --- server/gameserver/human.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index bad5a31..03c200a 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1671,7 +1671,9 @@ void Human::SendUIUpdate() void Human::SendWxVoip() { cs::SMWxVoip notifymsg; - notifymsg.set_group_id(a8::XValue(room->room_uuid).GetString()); + if (!team_uuid.empty()) { + notifymsg.set_group_id(a8::XValue(room->room_uuid).GetString() + team_uuid); + } SendNotifyMsg(notifymsg); } From 58ecc1d7760c06135beaec5891633fca17aee248 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 30 May 2019 19:54:46 +0800 Subject: [PATCH 03/10] 1 --- server/tools/scripts/ci/gameserver/boundle.sh | 14 ++++ server/tools/scripts/ci/gameserver/manage.py | 74 +++++++++++++++++++ server/tools/scripts/ci/gameserver/reload.sh | 0 server/tools/scripts/ci/gameserver/restart.sh | 5 ++ .../scripts/ci/gameserver/start_instance.sh | 4 + 5 files changed, 97 insertions(+) create mode 100644 server/tools/scripts/ci/gameserver/boundle.sh create mode 100755 server/tools/scripts/ci/gameserver/manage.py create mode 100644 server/tools/scripts/ci/gameserver/reload.sh create mode 100755 server/tools/scripts/ci/gameserver/restart.sh create mode 100755 server/tools/scripts/ci/gameserver/start_instance.sh diff --git a/server/tools/scripts/ci/gameserver/boundle.sh b/server/tools/scripts/ci/gameserver/boundle.sh new file mode 100644 index 0000000..3c15b6b --- /dev/null +++ b/server/tools/scripts/ci/gameserver/boundle.sh @@ -0,0 +1,14 @@ +cd third_party/game2001/server/gameserver +python ../tools/scripts/construct/build_pb.py --nohooks 1 +cmake $1 . +make clean +make +cp ../bin/gameserver ../../../../bin/ + +cd ../../../../ + +tag_name=`git status |grep '# On branch '|sed 's/# On branch //g'` +dir_name=`basename $PWD` +package_name=${dir_name}.tar.gz + +tar --exclude=*.git -chzf target/${package_name} bin reload.sh restart.sh start_instance.sh manage.py config res diff --git a/server/tools/scripts/ci/gameserver/manage.py b/server/tools/scripts/ci/gameserver/manage.py new file mode 100755 index 0000000..421c0f8 --- /dev/null +++ b/server/tools/scripts/ci/gameserver/manage.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +#coding utf8 + +import os +import sys +import time + +def getRuningProgramPids(progname): + pids = [] + lines = os.popen('ps -ef | grep %s' % progname).readlines() + for l in lines: + line = '' + oldc = '' + for c in l.strip(): + if c in [' ', '\t'] and c == oldc: + continue + oldc = c + line += c + line = line.split(' ') + + if line[7] == './%s' % progname: + pids.append(line[1]) + return pids + +def getExePath(pid): + return os.popen('ls -l /proc/%d | grep "exe ->" | cut -d " " -f 7-' % int(pid)).read() + +def getExeCmdLine(pid): + return os.popen('cat /proc/%d/cmdline' % int(pid)).read() + +def stop(instance_id, node_id): + gameserver_ids = getRuningProgramPids('gameserver') + pids = gameserver_ids + for pid in pids: + exepath = getExePath(pid) + cmdline = getExeCmdLine(pid) + if cmdline == ("./gameserver\0-i\0%d\0-i\0%d\0" % (instance_id, node_id)): + os.popen('kill -9 %d' % int(pid)) + +def listserver(): + gameserver_ids = getRuningProgramPids('gameserver') + pids = gameserver_ids + for pid in pids: + exepath = getExePath(pid) + cmdline = getExeCmdLine(pid) + print(pid, exepath, cmdline) + +def restartServer(str_instance_ids, node_id): + instance_ids = str_instance_ids.split(',') + for instance_id in instance_ids: + instance_id = int(instance_id) + stop(instance_id) + time.sleep(0.5) + print('gameserver %d starting......' % instance_id) + cmd = 'sh start_instance.sh %d' % (instance_id) + os.popen(cmd) + time.sleep(0.5) + +def printHelp(): + print('usuage: [restart]') + +def main(argv): + if len(argv) == 1: + printHelp() + else: + if argv[1] == 'restart': + restartServer(argv[2], argv[3]) + elif argv[1] == 'stop': + stop(argv[2], argv[3]) + elif argv[1] == 'list': + listserver() + +if __name__ == '__main__': + main(sys.argv) diff --git a/server/tools/scripts/ci/gameserver/reload.sh b/server/tools/scripts/ci/gameserver/reload.sh new file mode 100644 index 0000000..e69de29 diff --git a/server/tools/scripts/ci/gameserver/restart.sh b/server/tools/scripts/ci/gameserver/restart.sh new file mode 100755 index 0000000..7d3ed21 --- /dev/null +++ b/server/tools/scripts/ci/gameserver/restart.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +python manage.py restart $1 $2 + +echo 'success' diff --git a/server/tools/scripts/ci/gameserver/start_instance.sh b/server/tools/scripts/ci/gameserver/start_instance.sh new file mode 100755 index 0000000..88e8a21 --- /dev/null +++ b/server/tools/scripts/ci/gameserver/start_instance.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd bin +nohup ./gameserver -i $1 -n $2>> gameserver$1_$2.out 2>&1 & From dceb8060e76cf14fdde60b5101cb11f7a2c37a5b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 30 May 2019 20:23:23 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=88=B7=E9=A3=9E=E6=9C=BA=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E5=8F=91=E7=94=9F=E5=BE=AE=E4=BF=A1=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/room.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index b5bf3e4..0c930f6 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -785,6 +785,7 @@ void Room::UpdateGas() gas_data.gas_mode = GasJump; gas_data.gas_start_frameno = frame_no; ShuaPlane(); + NotifyWxVoip(); RoomMgr::Instance()->ActiveRoom(room_uuid); int auto_jump_interval = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_interval"); auto_jump_timer_ = xtimer.AddRepeatTimerAndAttach(SERVER_FRAME_RATE * auto_jump_interval, @@ -849,7 +850,6 @@ void Room::UpdateGas() battle_start_frameno_ = frame_no; xtimer.DeleteTimer(auto_jump_timer_); auto_jump_timer_ = nullptr; - NotifyWxVoip(); } } break; From 171592ad7769e9956747189ab433eb21dadc9124 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 30 May 2019 20:55:20 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=89=93=E9=98=9F?= =?UTF-8?q?=E5=8F=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/bullet.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/gameserver/bullet.cc b/server/gameserver/bullet.cc index cf6434c..3d07681 100644 --- a/server/gameserver/bullet.cc +++ b/server/gameserver/bullet.cc @@ -40,10 +40,10 @@ void Bullet::Update(int delta_time) std::set objects; for (auto& grid : grid_list) { for (Human* hum: grid->human_list) { -#if 1 +#if 0 if (hum != player && !hum->dead) { #else - if (hum != player && + if (hum != player && !hum->dead && (hum->team_id == 0 || player->team_id != hum->team_id)) { #endif if (TestCollision(hum)) { @@ -112,7 +112,8 @@ void Bullet::OnHit(std::set& objects) #if 1 if (!hum->dead) { #else - if (!hum->dead && (hum->team_id == 0 || hum->team_id != player->team_id)) { + if (hum != player && !hum->dead && + (hum->team_id == 0 || player->team_id != hum->team_id)) { #endif float dmg = gun_meta->i->atk() * (1 + player->buff.damage_add); float def = hum->def + hum->buff.def_add; From 30f3a37b5aa334e963a9c6e30532b459f9abe51a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 31 May 2019 09:10:21 +0800 Subject: [PATCH 06/10] ok --- server/tools/scripts/ci/gameserver/manage.py | 11 ++++++----- server/tools/scripts/ci/gameserver/start_instance.sh | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server/tools/scripts/ci/gameserver/manage.py b/server/tools/scripts/ci/gameserver/manage.py index 421c0f8..7715216 100755 --- a/server/tools/scripts/ci/gameserver/manage.py +++ b/server/tools/scripts/ci/gameserver/manage.py @@ -37,7 +37,7 @@ def stop(instance_id, node_id): if cmdline == ("./gameserver\0-i\0%d\0-i\0%d\0" % (instance_id, node_id)): os.popen('kill -9 %d' % int(pid)) -def listserver(): +def listServer(): gameserver_ids = getRuningProgramPids('gameserver') pids = gameserver_ids for pid in pids: @@ -45,14 +45,15 @@ def listserver(): cmdline = getExeCmdLine(pid) print(pid, exepath, cmdline) -def restartServer(str_instance_ids, node_id): +def restartServer(str_instance_ids, str_node_id): instance_ids = str_instance_ids.split(',') + node_id = int(str_node_id) for instance_id in instance_ids: instance_id = int(instance_id) - stop(instance_id) + stop(instance_id, node_id) time.sleep(0.5) print('gameserver %d starting......' % instance_id) - cmd = 'sh start_instance.sh %d' % (instance_id) + cmd = 'sh start_instance.sh %d %d' % (instance_id, node_id) os.popen(cmd) time.sleep(0.5) @@ -68,7 +69,7 @@ def main(argv): elif argv[1] == 'stop': stop(argv[2], argv[3]) elif argv[1] == 'list': - listserver() + listServer() if __name__ == '__main__': main(sys.argv) diff --git a/server/tools/scripts/ci/gameserver/start_instance.sh b/server/tools/scripts/ci/gameserver/start_instance.sh index 88e8a21..1b0ac91 100755 --- a/server/tools/scripts/ci/gameserver/start_instance.sh +++ b/server/tools/scripts/ci/gameserver/start_instance.sh @@ -1,4 +1,4 @@ #!/bin/bash cd bin -nohup ./gameserver -i $1 -n $2>> gameserver$1_$2.out 2>&1 & +nohup ./gameserver -i $1 -n $2>> gameserver$2_$1.out 2>&1 & From d26da80c4ba46343aeedfb3980a6065b1ab9fc30 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 31 May 2019 09:13:41 +0800 Subject: [PATCH 07/10] masterserver ci script ok --- .../tools/scripts/ci/masterserer/boundle.sh | 14 ++++ server/tools/scripts/ci/masterserer/manage.py | 75 +++++++++++++++++++ server/tools/scripts/ci/masterserer/reload.sh | 0 .../tools/scripts/ci/masterserer/restart.sh | 5 ++ .../scripts/ci/masterserer/start_instance.sh | 4 + 5 files changed, 98 insertions(+) create mode 100644 server/tools/scripts/ci/masterserer/boundle.sh create mode 100755 server/tools/scripts/ci/masterserer/manage.py create mode 100644 server/tools/scripts/ci/masterserer/reload.sh create mode 100755 server/tools/scripts/ci/masterserer/restart.sh create mode 100755 server/tools/scripts/ci/masterserer/start_instance.sh diff --git a/server/tools/scripts/ci/masterserer/boundle.sh b/server/tools/scripts/ci/masterserer/boundle.sh new file mode 100644 index 0000000..12c368d --- /dev/null +++ b/server/tools/scripts/ci/masterserer/boundle.sh @@ -0,0 +1,14 @@ +cd third_party/game2001/server/masterserver +python ../tools/scripts/construct/build_pb.py --nohooks 1 +cmake $1 . +make clean +make +cp ../bin/masterserver ../../../../bin/ + +cd ../../../../ + +tag_name=`git status |grep '# On branch '|sed 's/# On branch //g'` +dir_name=`basename $PWD` +package_name=${dir_name}.tar.gz + +tar --exclude=*.git -chzf target/${package_name} bin reload.sh restart.sh start_instance.sh manage.py config diff --git a/server/tools/scripts/ci/masterserer/manage.py b/server/tools/scripts/ci/masterserer/manage.py new file mode 100755 index 0000000..9442517 --- /dev/null +++ b/server/tools/scripts/ci/masterserer/manage.py @@ -0,0 +1,75 @@ +#!/usr/bin/python +#coding utf8 + +import os +import sys +import time + +def getRuningProgramPids(progname): + pids = [] + lines = os.popen('ps -ef | grep %s' % progname).readlines() + for l in lines: + line = '' + oldc = '' + for c in l.strip(): + if c in [' ', '\t'] and c == oldc: + continue + oldc = c + line += c + line = line.split(' ') + + if line[7] == './%s' % progname: + pids.append(line[1]) + return pids + +def getExePath(pid): + return os.popen('ls -l /proc/%d | grep "exe ->" | cut -d " " -f 7-' % int(pid)).read() + +def getExeCmdLine(pid): + return os.popen('cat /proc/%d/cmdline' % int(pid)).read() + +def stop(instance_id, node_id): + masterserver_ids = getRuningProgramPids('masterserver') + pids = masterserver_ids + for pid in pids: + exepath = getExePath(pid) + cmdline = getExeCmdLine(pid) + if cmdline == ("./masterserver\0-i\0%d\0-i\0%d\0" % (instance_id, node_id)): + os.popen('kill -9 %d' % int(pid)) + +def listServer(): + masterserver_ids = getRuningProgramPids('masterserver') + pids = masterserver_ids + for pid in pids: + exepath = getExePath(pid) + cmdline = getExeCmdLine(pid) + print(pid, exepath, cmdline) + +def restartServer(str_instance_ids, str_node_id): + instance_ids = str_instance_ids.split(',') + node_id = int(str_node_id) + for instance_id in instance_ids: + instance_id = int(instance_id) + stop(instance_id, node_id) + time.sleep(0.5) + print('masterserver %d starting......' % instance_id) + cmd = 'sh start_instance.sh %d %d' % (instance_id, node_id) + os.popen(cmd) + time.sleep(0.5) + +def printHelp(): + print('usuage: [restart]') + +def main(argv): + if len(argv) == 1: + printHelp() + else: + if argv[1] == 'restart': + restartServer(argv[2], argv[3]) + elif argv[1] == 'stop': + stop(argv[2], argv[3]) + elif argv[1] == 'list': + listServer() + +if __name__ == '__main__': + main(sys.argv) diff --git a/server/tools/scripts/ci/masterserer/reload.sh b/server/tools/scripts/ci/masterserer/reload.sh new file mode 100644 index 0000000..e69de29 diff --git a/server/tools/scripts/ci/masterserer/restart.sh b/server/tools/scripts/ci/masterserer/restart.sh new file mode 100755 index 0000000..7d3ed21 --- /dev/null +++ b/server/tools/scripts/ci/masterserer/restart.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +python manage.py restart $1 $2 + +echo 'success' diff --git a/server/tools/scripts/ci/masterserer/start_instance.sh b/server/tools/scripts/ci/masterserer/start_instance.sh new file mode 100755 index 0000000..7537a25 --- /dev/null +++ b/server/tools/scripts/ci/masterserer/start_instance.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd bin +nohup ./masterserver -i $1 -n $2>> masterserver$2_$1.out 2>&1 & From 3f4e713ce8e1d2af40cc5fe470d9fdf077cd55c5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 31 May 2019 10:25:43 +0800 Subject: [PATCH 08/10] 1 --- server/gameserver/CMakeLists.txt | 12 ++++++++++++ server/masterserver/CMakeLists.txt | 6 ++++++ third_party/tools | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/server/gameserver/CMakeLists.txt b/server/gameserver/CMakeLists.txt index 9e57f2d..3612bfa 100644 --- a/server/gameserver/CMakeLists.txt +++ b/server/gameserver/CMakeLists.txt @@ -40,6 +40,18 @@ aux_source_directory(../../third_party/framework/cpp SRC_LIST ) +execute_process( + COMMAND touch -a cs_proto.pb.h + COMMAND touch -a cs_proto.pb.cc + COMMAND touch -a cs_msgid.pb.h + COMMAND touch -a cs_msgid.pb.cc + COMMAND touch -a ss_proto.pb.h + COMMAND touch -a ss_proto.pb.cc + COMMAND touch -a ss_msgid.pb.h + COMMAND touch -a ss_msgid.pb.cc + COMMAND touch -a metatable.pb.h + COMMAND touch -a metatable.pb.cc + ) aux_source_directory(. SRC_LIST ) diff --git a/server/masterserver/CMakeLists.txt b/server/masterserver/CMakeLists.txt index 8c97cfe..e27615a 100644 --- a/server/masterserver/CMakeLists.txt +++ b/server/masterserver/CMakeLists.txt @@ -37,6 +37,12 @@ aux_source_directory(../../third_party/framework/cpp SRC_LIST ) +execute_process( + COMMAND touch -a ss_proto.pb.h + COMMAND touch -a ss_proto.pb.cc + COMMAND touch -a ss_msgid.pb.h + COMMAND touch -a ss_msgid.pb.cc + ) aux_source_directory(. SRC_LIST ) diff --git a/third_party/tools b/third_party/tools index 3196cd6..d8cde2a 160000 --- a/third_party/tools +++ b/third_party/tools @@ -1 +1 @@ -Subproject commit 3196cd6696239a11b60f9730af0bad1f73ab0e5d +Subproject commit d8cde2addd3987c980b6b53d3ce0e08dff145b1d From 7eac337db4aaf1637d38fb6d65b64272544188f0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 31 May 2019 11:42:59 +0800 Subject: [PATCH 09/10] 1 --- server/masterserver/CMakeLists.txt | 6 ------ server/masterserver/app.cc | 21 +++++++++++++++---- server/masterserver/app.h | 1 + server/masterserver/constant.h | 3 +++ server/masterserver/gsmgr.cc | 5 ++++- server/masterserver/gsmgr.h | 3 +++ server/masterserver/jsondatamgr.cc | 17 +++++++++++---- .../tools/scripts/ci/masterserer/boundle.sh | 2 +- 8 files changed, 42 insertions(+), 16 deletions(-) diff --git a/server/masterserver/CMakeLists.txt b/server/masterserver/CMakeLists.txt index e27615a..8c97cfe 100644 --- a/server/masterserver/CMakeLists.txt +++ b/server/masterserver/CMakeLists.txt @@ -37,12 +37,6 @@ aux_source_directory(../../third_party/framework/cpp SRC_LIST ) -execute_process( - COMMAND touch -a ss_proto.pb.h - COMMAND touch -a ss_proto.pb.cc - COMMAND touch -a ss_msgid.pb.h - COMMAND touch -a ss_msgid.pb.cc - ) aux_source_directory(. SRC_LIST ) diff --git a/server/masterserver/app.cc b/server/masterserver/app.cc index 50fc456..38ea27a 100755 --- a/server/masterserver/app.cc +++ b/server/masterserver/app.cc @@ -73,7 +73,15 @@ void App::Init(int argc, char* argv[]) if (!ParseOpt()) { terminated = true; - a8::XPrintf("masterserver启动失败,缺少-i参数\n", {}); + if (node_id <= 0) { + a8::XPrintf("gameserver启动失败,缺少-n参数\n", {}); + } else if (node_id > MAX_NODE_ID) { + a8::XPrintf("gameserver启动失败,-n参数不能大于%d\n", {MAX_NODE_ID}); + } else if (instance_id <= 0) { + a8::XPrintf("gameserver启动失败,缺少-i参数\n", {}); + } else if (instance_id > MAX_INSTANCE_ID) { + a8::XPrintf("gameserver启动失败,-i参数不能大于%d\n", {MAX_INSTANCE_ID}); + } return; } a8::XPrintf("masterserver starting instance_id:%d pid:%d game_id:%d\n", {instance_id, getpid(), GAME_ID}); @@ -91,7 +99,7 @@ void App::Init(int argc, char* argv[]) f8::TGLog::Instance()->Init(a8::Format(PROJ_NAME_FMT, {GAME_ID}), false); f8::HttpClientPool::Instance()->Init(10); JsonDataMgr::Instance()->Init(); - uuid.SetMachineId(instance_id); + uuid.SetMachineId((node_id - 1) * MAX_NODE_ID + instance_id); GGListener::Instance()->Init(); a8::UdpLog::Instance()->Info("masterserver starting instance_id:%d pid:%d", {instance_id, getpid()}); @@ -413,8 +421,13 @@ void App::UnInitLog() bool App::ParseOpt() { int ch = 0; - while ((ch = getopt(argc, argv, "i:t:r:f:")) != -1) { + while ((ch = getopt(argc, argv, "n:i:t:r:f:")) != -1) { switch (ch) { + case 'n': + { + node_id = a8::XValue(optarg); + } + break; case 'i': { instance_id = a8::XValue(optarg); @@ -437,7 +450,7 @@ bool App::ParseOpt() break; } } - return instance_id > 0; + return instance_id > 0 && node_id > 0; } long long App::NewUuid() diff --git a/server/masterserver/app.h b/server/masterserver/app.h index 815c1d3..a145067 100644 --- a/server/masterserver/app.h +++ b/server/masterserver/app.h @@ -57,6 +57,7 @@ public: a8::uuid::SnowFlake uuid; public: + int node_id = 0; int instance_id = 0; bool is_test_mode = false; int test_param = 0; diff --git a/server/masterserver/constant.h b/server/masterserver/constant.h index 9fb76aa..f1dcd20 100755 --- a/server/masterserver/constant.h +++ b/server/masterserver/constant.h @@ -144,3 +144,6 @@ const int MAP_WIDTH = 8192; const int MAP_CELL_WIDTH = 64 * 8; const int DOOR_THING_ID = 61701; + +const int MAX_NODE_ID = 8; +const int MAX_INSTANCE_ID = 500; diff --git a/server/masterserver/gsmgr.cc b/server/masterserver/gsmgr.cc index c383600..bdb85af 100644 --- a/server/masterserver/gsmgr.cc +++ b/server/masterserver/gsmgr.cc @@ -41,6 +41,8 @@ void GSMgr::___GSReport(f8::JsonHttpRequest* request) int port = request->request.Get("port"); int online_num = request->request.Get("online_num"); int room_num = request->request.Get("room_num"); + int instance_id = request->request.Get("instance_id"); + int node_id = request->request.Get("node_id"); std::string key = ip + a8::XValue(port).GetString(); auto itr = node_key_hash_.find(key); @@ -49,7 +51,8 @@ void GSMgr::___GSReport(f8::JsonHttpRequest* request) itr->second.room_num = room_num; } else { GSNode gs; - gs.key = key; + gs.node_id = node_id; + gs.instance_id = instance_id; gs.online_num = online_num; gs.room_num = room_num; gs.ip = ip; diff --git a/server/masterserver/gsmgr.h b/server/masterserver/gsmgr.h index 2af62bb..3cc0908 100644 --- a/server/masterserver/gsmgr.h +++ b/server/masterserver/gsmgr.h @@ -6,10 +6,13 @@ struct GSNode { std::string key; unsigned short node_idx = 0; + int node_id = 0; + int instance_id = 0; int room_num = 0; int online_num = 0; std::string ip; int port = 0; + bool servicing = false; }; class GSMgr : public a8::Singleton diff --git a/server/masterserver/jsondatamgr.cc b/server/masterserver/jsondatamgr.cc index 6451fd5..55deb8d 100644 --- a/server/masterserver/jsondatamgr.cc +++ b/server/masterserver/jsondatamgr.cc @@ -10,21 +10,30 @@ void JsonDataMgr::Init() std::string masterserver_cluster_json_file; if (!f8::IsOnlineEnv()) { if (App::Instance()->flags.find(2) != App::Instance()->flags.end()) { - masterserver_cluster_json_file = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver/" + masterserver_cluster_json_file = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver/node%d/" "game%d.masterserver.cluster.json", { GAME_ID, App::Instance()->instance_id, GAME_ID, + App::Instance()->node_id, GAME_ID }); } else { - masterserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/masterserver/" + masterserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/masterserver/node%d/" "game%d.masterserver.cluster.json", - {GAME_ID, GAME_ID}); + { + GAME_ID, + App::Instance()->node_id, + GAME_ID + }); } } else { - masterserver_cluster_json_file = a8::Format("../config/game%d.masterserver.cluster.json", {GAME_ID}); + masterserver_cluster_json_file = a8::Format("../config/node%d/game%d.masterserver.cluster.json", + { + App::Instance()->node_id, + GAME_ID + }); } masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file); } diff --git a/server/tools/scripts/ci/masterserer/boundle.sh b/server/tools/scripts/ci/masterserer/boundle.sh index 12c368d..781cf05 100644 --- a/server/tools/scripts/ci/masterserer/boundle.sh +++ b/server/tools/scripts/ci/masterserer/boundle.sh @@ -1,6 +1,6 @@ cd third_party/game2001/server/masterserver python ../tools/scripts/construct/build_pb.py --nohooks 1 -cmake $1 . +cmake -DGAME_ID=2001 . make clean make cp ../bin/masterserver ../../../../bin/ From c087df8fcc398e2ac456f7a7e2024e227a26a0d5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 31 May 2019 11:52:45 +0800 Subject: [PATCH 10/10] 1 --- server/tools/scripts/ci/gameserver/boundle.sh | 2 +- server/tools/scripts/ci/masterserer/boundle.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/tools/scripts/ci/gameserver/boundle.sh b/server/tools/scripts/ci/gameserver/boundle.sh index 3c15b6b..8f57cbc 100644 --- a/server/tools/scripts/ci/gameserver/boundle.sh +++ b/server/tools/scripts/ci/gameserver/boundle.sh @@ -1,5 +1,5 @@ cd third_party/game2001/server/gameserver -python ../tools/scripts/construct/build_pb.py --nohooks 1 +#python ../tools/scripts/construct/build_pb.py --nohooks 1 cmake $1 . make clean make diff --git a/server/tools/scripts/ci/masterserer/boundle.sh b/server/tools/scripts/ci/masterserer/boundle.sh index 781cf05..376e1fc 100644 --- a/server/tools/scripts/ci/masterserer/boundle.sh +++ b/server/tools/scripts/ci/masterserer/boundle.sh @@ -1,5 +1,5 @@ cd third_party/game2001/server/masterserver -python ../tools/scripts/construct/build_pb.py --nohooks 1 +#python ../tools/scripts/construct/build_pb.py --nohooks 1 cmake -DGAME_ID=2001 . make clean make