Merge branch 'master' into dev

This commit is contained in:
aozhiwei 2019-05-22 16:05:01 +08:00
commit fb924eb0a2
23 changed files with 72 additions and 364 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash
cd ../tools/robot/virtualclient
python robot3.py ws://192.168.100.21:7101 hao1069 hao1069 $1
python robot.py ws://192.168.100.21:7101 hao1069 hao1069 $1

View File

@ -102,6 +102,7 @@ void AndroidAI::DoMove()
}
break;
}
hum->room->grid_service.MoveHuman(hum);
}
}
}

View File

@ -715,7 +715,7 @@ bool Human::HasNoDownedTeammate()
{
if (team_members) {
for (auto& hum : *team_members) {
if (hum != this && (!hum->dead || !hum->downed)) {
if (hum != this && !hum->dead && !hum->downed) {
return true;
}
}

View File

@ -209,7 +209,6 @@ private:
}
{
int building_id = 0;
for (auto& meta : building_meta_list) {
MetaData::Building& item = a8::FastAppend(building_list);
item.i = &meta;

View File

@ -89,7 +89,7 @@ void Obstacle::FillMFObjectFull(cs::MFObjectFull* full_data)
p->set_obstacle_id(meta->i->thing_id());
p->set_health(health);
p->set_dead(dead);
p->set_dead_at_thisframe(dead ? dead_frameno < room->frame_no : false);
p->set_dead_at_thisframe(dead ? dead_frameno <= room->frame_no : false);
p->set_is_door(is_door);
if (is_door) {

View File

@ -53,6 +53,9 @@ void Player::Update(int delta_time)
if (shot_start || shot_hold) {
UpdateShot();
}
if (drop_weapon) {
UpdateDropWeapon();
}
if (interaction_objids.size() > 0) {
ProcInteraction();
}
@ -62,9 +65,6 @@ void Player::Update(int delta_time)
if (select_weapon) {
UpdateSelectWeapon();
}
if (drop_weapon) {
UpdateDropWeapon();
}
if (use_scope) {
UpdateUseScope();
}

View File

@ -497,17 +497,17 @@ void Room::CreateLoot(int equip_id, Vector2D pos, int count, int equip_lv)
entity->pos = pos;
#if 1
{
if (entity->pos.x > MAP_WIDTH) {
entity->pos.x = MAP_WIDTH;
if (entity->pos.x >= MAP_WIDTH) {
entity->pos.x = MAP_WIDTH - 1;
}
if (entity->pos.x <= 0.001f) {
entity->pos.x = 0.0f;
if (entity->pos.x < 1.0f) {
entity->pos.x = 1.0f;
}
if (entity->pos.y > MAP_HEIGHT) {
entity->pos.y = MAP_HEIGHT;
if (entity->pos.y >= MAP_HEIGHT) {
entity->pos.y = MAP_HEIGHT - 1;
}
if (entity->pos.y < 0.0001f) {
entity->pos.y = 0.0f;
if (entity->pos.y < 1.0f) {
entity->pos.y = 1.0f;
}
}
#endif

View File

@ -1,2 +0,0 @@
cd ..
start python robot.py ws://118.31.73.76:82 test0001 123456

View File

@ -1,2 +0,0 @@
cd ..
start python robot.py ws://192.144.140.87:8999 test0002 123456

View File

@ -1,110 +0,0 @@
import websocket
import sys
import time
import vs_proto_pb2
import vs_msgid_pb2
try:
import thread
except ImportError:
import _thread as thread
import time
def on_open (ws):
print 'on open'
class Client:
def __init__(self, accountid, user_profile, remote_ip, remote_port):
self._recv_buf = bytearray()
self._accountid = accountid
self._sessionid = ''
self._user_profile = user_profile
self._ws = websocket.WebSocketApp ("ws://127.0.0.1:" + sys.argv[1],
on_message = self.onMessage,
on_error = self.onError,
on_close = self.onClose)
# self._ws.on_open = on_open
self._ws.on_open = self.onOpen
def sendMsg(self, msgid, msg):
PACK_SIGN = 0xAABBCCAA
enmsg = bytearray(msg.SerializeToString())
pktlen_str = chr(len(enmsg) & 0xFF) + chr(len(enmsg) >> 8 & 0xFF)
msgid_str = chr(msgid & 0xFF) + chr(msgid >> 8 & 0xFF)
sign_str = chr(PACK_SIGN & 0xFF) + chr(PACK_SIGN >> 8 & 0xFF) + \
chr(PACK_SIGN >> 16 & 0xFF) + chr(PACK_SIGN >> 24 & 0xFF)
buff = pktlen_str + msgid_str + sign_str + enmsg
self._ws.send (buff, 2)
def parsePacket(self):
while len(self._recv_buf) >= 8:
pktlen = self._recv_buf[0] + (self._recv_buf[1] << 8)
msgid = self._recv_buf[2] + (self._recv_buf[3] << 8)
magiccode = self._recv_buf[4] + \
(self._recv_buf[5] << 8) + \
(self._recv_buf[6] << 16) + \
(self._recv_buf[7] << 24)
print 'pkglen:', pktlen, ' msgid:', msgid, ' magiccode:', magiccode
if len(self._recv_buf) >= 8 + pktlen:
msgbody = self._recv_buf[8 : 8 + pktlen]
self.onUserPacket(msgid, msgbody)
self._recv_buf = self._recv_buf[8 + pktlen:]
def onUserPacket(self):
try:
msgid_class_hash = {
vs_msgid_pb2._SMLogin: vs_proto_pb2.SMLogin,
vs_msgid_pb2._SMCreateRoom: vs_proto_pb2.SMCreateRoom
}
if not msgid_class_hash.has_key(msgid):
print 'not found msgclass:', msgid
return
msg = msgid_class_hash[msgid]()
ret = msg.ParseFromString(str(msgbody))
print str(msg)
except Exception, e:
print 'on_user_packet', e
def onMessage(self, message):
data = bytearray(message)
self._recv_buf += data
print 'on_message ', len(recv_buf)
self._ws.parsePacket();
def onError(self, error):
print error
def onClose(self):
print 'onclose'
def onOpen(self):
print 'ok'
def run (*args):
msg = vs_proto_pb2.CMLogin()
msg.account_id = '1234567'
msg.session_id = 'dsjfkasjkfljfsklfd'
print msg
sendmsg(ws, vs_msgid_pb2._CMLogin, msg)
testCMCreateRoom(ws)
while True:
testSendRoomEvent(ws)
time.sleep(10)
time.sleep(500)
ws.close ()
print ("thread terminating...")
thread.start_new_thread (run, ())
def runForever(self):
self._ws.run_forever()
if __name__ == "__main__":
client = Client(
'123456',
'',
'127.0.0.1',
82
)
client.runForever()

View File

@ -21,7 +21,7 @@ def main():
help = "account info")
(options, args) = parser.parse_args()
ws_url = args if args else 'ws://127.0.0.1:83/websocket'
ws_url = args if args else 'ws://192.168.100.21:7101/websocket'
for account in options.accounts.split(','):
ioloop.IOLoop.current().spawn_callback(createVirtualClient, account, ws_url)

View File

@ -1,9 +0,0 @@
protoc.exe --proto_path=../../protobuild --python_out=. ../../protobuild/kingsomevs.proto
protoc.exe --proto_path=../../protobuild --python_out=. ../../protobuild/messages.proto
rename kingsomevs_pb2.py vs_proto_pb2.py
rename messages_pb2.py vs_msgid_pb2.py
start python robot.py ws://118.31.73.76:82 test0001 123456
start python robot.py ws://118.31.73.76:82 test0002 123456
start python robot.py ws://118.31.73.76:82 test0003 123456
start python robot.py ws://118.31.73.76:82 test0004 123456

View File

@ -2,7 +2,9 @@
import websocket
import sys
import ssl
import json
import datetime
import urllib.request
import cs_proto_pb2
import cs_msgid_pb2
@ -16,8 +18,22 @@ except ImportError:
import _thread as thread
import time
def getSession(account_id):
url = 'https://login-test.kingsome.cn/webapp/index.php?c=Login&a=auth&'
params = {
'openid': sys.argv[2],
'token': sys.argv[2],
'gameid': 1008,
'channel': '6000'
}
real_url = url + urllib.parse.urlencode(params)
print(real_url)
req = urllib.request.Request(real_url)
data = urllib.request.urlopen(req).read()
return json.loads(data.decode('utf-8'))['session_id']
def inputCommand(ws):
cmdline= raw_input('')
cmdline= input('')
idx = cmdline.find(' ')
if idx <= 0:
cmdline += '()'
@ -41,36 +57,38 @@ def getSMMsg(sm_msgid):
#g_remote_ip = "ws://127.0.0.1:" + sys.argv[1]
g_remote_ip = sys.argv[1]
g_account_id = sys.argv[2]
g_account_id = '6000_1008_' + sys.argv[2]
g_session_id = sys.argv[3]
g_server_id = sys.argv[4]
g_seqid = 1000
recv_buf = bytearray()
def sendMsg(ws, msg):
print datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
global g_seqid
++g_seqid
msgid = eval('cs_msgid_pb2._' + msg.DESCRIPTOR.name)
PACK_SIGN = 'KS'
enmsg = bytearray(msg.SerializeToString())
pktlen_str = chr(len(enmsg) & 0xFF) + chr(len(enmsg) >> 8 & 0xFF)
msgid_str = chr(msgid & 0xFF) + chr(msgid >> 8 & 0xFF)
seqid_str = chr(g_seqid & 0xFF) + chr(g_seqid >> 8 & 0xFF) + \
chr(g_seqid >> 16 & 0xFF) + chr(g_seqid >> 24 & 0xFF)
sign_str = PACK_SIGN
reserved_str = chr(0) + chr(0)
enmsg = msg.SerializeToString()
pktlen_str = bytes([(len(enmsg) & 0xFF) , (len(enmsg) >> 8 & 0xFF)])
msgid_str = bytes([(msgid & 0xFF) , (msgid >> 8 & 0xFF)])
seqid_str = bytes([(g_seqid & 0xFF) , (g_seqid >> 8 & 0xFF) , \
(g_seqid >> 16 & 0xFF) , (g_seqid >> 24 & 0xFF)])
sign_str = bytes([ord('K'), ord('S')])
reserved_str = bytes([0, 0])
buff = pktlen_str + msgid_str + seqid_str + sign_str + reserved_str + enmsg
ws.send (buff, 2)
print time.time(), time.strftime('[%H:%M:%S]'), msg.DESCRIPTOR.name + '{'
print str(msg),
print '}'
print ''
print(time.time(), time.strftime('[%H:%M:%S]'), msg.DESCRIPTOR.name + '{')
print(str(msg),)
print('}')
print('')
def onMessage(ws, message):
global recv_buf
print 'onMessage', len(message)
print('onMessage', len(message))
data = bytearray(message)
recv_buf += data
parserPacket(ws)
@ -93,18 +111,16 @@ def parserPacket(ws):
def onUserPacket(ws, msgid, msgbody):
try:
print datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
msg = getSMMsg(msgid)
ret = msg.ParseFromString(str(msgbody))
print len(msgbody)
print time.time(), time.strftime('[%H:%M:%S]'), msg.DESCRIPTOR.name + '{'
print str(msg),
print '}'
print ''
if msgid == cs_msgid_pb2._SMTestAward:
print msg.default_123456
except Exception, e:
print 'onUserPacket', e
ret = msg.ParseFromString(msgbody)
print(len(msgbody))
print(time.time(), time.strftime('[%H:%M:%S]'), msg.DESCRIPTOR.name + '{')
print(str(msg),)
print('}')
print('')
except Exception as e:
print('onUserPacket', e)
def onError (ws, error):
print (error)
@ -113,17 +129,17 @@ def onClose (ws):
print ("### closed ###")
def opOpen (ws):
print 'opOpen', time.time()
print('opOpen', time.time())
def run (*args):
global g_remote_ip
global g_account_id
global g_session_id
msg = cs_proto_pb2.CMLogin()
msg.server_id = 1
global g_server_id
msg = cs_proto_pb2.CMJoin()
msg.server_id = int(g_server_id)
msg.account_id = g_account_id
msg.session_id = g_session_id
msg.device_id = '123456'
print msg.DESCRIPTOR.name, 'zzzzz'
msg.name = "测试"
print(msg.DESCRIPTOR.name, 'zzzzz')
sendMsg(ws, msg)
while True:
inputCommand(ws)
@ -132,8 +148,8 @@ def opOpen (ws):
print ("thread terminating...")
thread.start_new_thread (run, ())
print time.time()
print g_remote_ip
print(time.time())
print(g_remote_ip)
if __name__ == "__main__":
websocket.enableTrace(True)

View File

@ -1,3 +0,0 @@
#!/bin/bash
python robot.py ws://127.0.0.1:8999 test0001 123456

View File

@ -1,9 +0,0 @@
protoc.exe --proto_path=../../protobuild --python_out=. ../../protobuild/kingsomevs.proto
protoc.exe --proto_path=../../protobuild --python_out=. ../../protobuild/messages.proto
rename kingsomevs_pb2.py vs_proto_pb2.py
rename messages_pb2.py vs_msgid_pb2.py
rem start python robot.py wss://matchvs-test.kingsome.cn/websocket test00010 123456
start python robot.py wss://matchvs-test.kingsome.cn/websocket test0001 123456
start python robot.py wss://matchvs-test.kingsome.cn/websocket test0003 123456
start python robot.py wss://matchvs-test.kingsome.cn/websocket test0004 123456

View File

@ -1,3 +0,0 @@
#!/bin/bash
python robot.py ws://127.0.0.1:8999 test0002 123456

View File

@ -1,162 +0,0 @@
# -*- coding: utf-8 -*-
import websocket
import sys
import ssl
import json
import datetime
import urllib.request
import cs_proto_pb2
import cs_msgid_pb2
#from google.protobuf import json_format
import pprint
try:
import thread
except ImportError:
import _thread as thread
import time
def getSession(account_id):
url = 'https://login-test.kingsome.cn/webapp/index.php?c=Login&a=auth&'
params = {
'openid': sys.argv[2],
'token': sys.argv[2],
'gameid': 1008,
'channel': '6000'
}
real_url = url + urllib.parse.urlencode(params)
print(real_url)
req = urllib.request.Request(real_url)
data = urllib.request.urlopen(req).read()
return json.loads(data.decode('utf-8'))['session_id']
def inputCommand(ws):
cmdline= input('')
idx = cmdline.find(' ')
if idx <= 0:
cmdline += '()'
else:
cmdline = cmdline[:idx] + '(' + cmdline[idx + 1:] + ')'
msg = eval('cs_proto_pb2.' + cmdline)
sendMsg(ws, msg)
inputCommand(ws)
def getSMMsgEnum(sm_msgid):
sm_e = cs_msgid_pb2._SMMESSAGEID_E
for e in sm_e.values:
if e.number == sm_msgid:
return e
return None
def getSMMsg(sm_msgid):
sm_e = getSMMsgEnum(sm_msgid)
msg = eval('cs_proto_pb2.' + sm_e.name[1:] + '()')
return msg
#g_remote_ip = "ws://127.0.0.1:" + sys.argv[1]
g_remote_ip = sys.argv[1]
g_account_id = '6000_1008_' + sys.argv[2]
g_session_id = sys.argv[3]
g_server_id = sys.argv[4]
g_seqid = 1000
recv_buf = bytearray()
def sendMsg(ws, msg):
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
global g_seqid
++g_seqid
msgid = eval('cs_msgid_pb2._' + msg.DESCRIPTOR.name)
enmsg = msg.SerializeToString()
pktlen_str = bytes([(len(enmsg) & 0xFF) , (len(enmsg) >> 8 & 0xFF)])
msgid_str = bytes([(msgid & 0xFF) , (msgid >> 8 & 0xFF)])
seqid_str = bytes([(g_seqid & 0xFF) , (g_seqid >> 8 & 0xFF) , \
(g_seqid >> 16 & 0xFF) , (g_seqid >> 24 & 0xFF)])
sign_str = bytes([ord('K'), ord('S')])
reserved_str = bytes([0, 0])
buff = pktlen_str + msgid_str + seqid_str + sign_str + reserved_str + enmsg
ws.send (buff, 2)
print(time.time(), time.strftime('[%H:%M:%S]'), msg.DESCRIPTOR.name + '{')
print(str(msg),)
print('}')
print('')
def onMessage(ws, message):
global recv_buf
print('onMessage', len(message))
data = bytearray(message)
recv_buf += data
parserPacket(ws)
def parserPacket(ws):
global recv_buf
while len(recv_buf) >= 8:
pktlen = recv_buf[0] + (recv_buf[1] << 8)
msgid = recv_buf[2] + (recv_buf[3] << 8)
seqid = recv_buf[4] + \
(recv_buf[5] << 8) + \
(recv_buf[6] << 16) + \
(recv_buf[7] << 24)
sign = recv_buf[8] + (recv_buf[9] << 8)
resv = recv_buf[10] + (recv_buf[11] << 8)
if len(recv_buf) >= 12 + pktlen:
msgbody = recv_buf[12 : 12 + pktlen]
onUserPacket(ws, msgid, msgbody)
recv_buf = recv_buf[12 + pktlen:]
def onUserPacket(ws, msgid, msgbody):
try:
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
msg = getSMMsg(msgid)
ret = msg.ParseFromString(msgbody)
print(len(msgbody))
print(time.time(), time.strftime('[%H:%M:%S]'), msg.DESCRIPTOR.name + '{')
print(str(msg),)
print('}')
print('')
except Exception as e:
print('onUserPacket', e)
def onError (ws, error):
print (error)
def onClose (ws):
print ("### closed ###")
def opOpen (ws):
print('opOpen', time.time())
def run (*args):
global g_remote_ip
global g_account_id
global g_session_id
global g_server_id
msg = cs_proto_pb2.CMJoin()
msg.server_id = int(g_server_id)
msg.account_id = g_account_id
msg.name = "测试"
print(msg.DESCRIPTOR.name, 'zzzzz')
sendMsg(ws, msg)
while True:
inputCommand(ws)
time.sleep(500)
ws.close ()
print ("thread terminating...")
thread.start_new_thread (run, ())
print(time.time())
print(g_remote_ip)
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp (g_remote_ip,
on_message = onMessage,
on_error = onError,
on_close = onClose
)
ws.on_open = opOpen
ws.run_forever ()

View File

@ -1,3 +0,0 @@
#!/bin/bash
python robot.py ws://127.0.0.1:8999 test0003 123456

View File

@ -1,3 +0,0 @@
#!/bin/bash
python robot.py ws://127.0.0.1:8999 test0004 123456

View File

@ -57,11 +57,9 @@ class VirtualClient(object):
print('')
def sendLogin(self, conn):
msg = cs_proto_pb2.CMLogin()
msg.server_id = 1
msg = cs_proto_pb2.CMJoin()
msg.server_id = 2
msg.account_id = self.account
msg.session_id = '12342'
msg.device_id = '123456'
self.sendMsg(conn, msg)
def parsePacket(self, conn, recv_buf):

@ -1 +1 @@
Subproject commit fc99a3615db9aabc1a77489e069a4e6af26d50d5
Subproject commit ff8c00652d5367595c4adee8f95306ae1a46236b

@ -1 +1 @@
Subproject commit 4e612f46cedb1723496662ddeb32c174944041b4
Subproject commit fd72ea56059dc8545920e33d436dad5a1d3700fb

2
third_party/tools vendored

@ -1 +1 @@
Subproject commit 23026cb4e2ec630f6d421f742b65de6752a57b9d
Subproject commit 3196cd6696239a11b60f9730af0bad1f73ab0e5d