merge master

This commit is contained in:
aozhiwei 2019-06-02 15:03:34 +08:00
commit 3776467e61
15 changed files with 217 additions and 6 deletions

View File

@ -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()

View File

@ -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
)

View File

@ -40,10 +40,10 @@ void Bullet::Update(int delta_time)
std::set<Entity*> 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<Entity*>& 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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -0,0 +1,5 @@
#!/bin/bash
python manage.py restart $1 $2
echo 'success'

View File

@ -0,0 +1,4 @@
#!/bin/bash
cd bin
nohup ./gameserver -i $1 -n $2>> gameserver$2_$1.out 2>&1 &

View File

@ -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

View File

@ -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)

View File

@ -0,0 +1,5 @@
#!/bin/bash
python manage.py restart $1 $2
echo 'success'

View File

@ -0,0 +1,4 @@
#!/bin/bash
cd bin
nohup ./masterserver -i $1 -n $2>> masterserver$2_$1.out 2>&1 &