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() 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/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; 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); } 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; diff --git a/server/tools/scripts/ci/gameserver/boundle.sh b/server/tools/scripts/ci/gameserver/boundle.sh new file mode 100644 index 0000000..8f57cbc --- /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..7715216 --- /dev/null +++ b/server/tools/scripts/ci/gameserver/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): + 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, 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('gameserver %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/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..1b0ac91 --- /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$2_$1.out 2>&1 & diff --git a/server/tools/scripts/ci/masterserer/boundle.sh b/server/tools/scripts/ci/masterserer/boundle.sh new file mode 100644 index 0000000..376e1fc --- /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 -DGAME_ID=2001 . +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 &