完成gm工具逻辑

This commit is contained in:
aozhiwei 2019-03-20 15:00:29 +08:00
parent cf87b127d4
commit 3ad1dda451
11 changed files with 36 additions and 14 deletions

5
server/bin/gmtool.sh Executable file
View File

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

View File

@ -94,6 +94,7 @@ void App::Init(int argc, char* argv[])
uuid.SetMachineId(instance_id);
PlayerMgr::Instance()->Init();
RoomMgr::Instance()->Init();
GGListener::Instance()->Init();
a8::UdpLog::Instance()->Info("gameserver starting instance_id:%d pid:%d", {instance_id, getpid()});
{
@ -115,6 +116,7 @@ void App::UnInit()
if (terminated) {
return;
}
GGListener::Instance()->Init();
RoomMgr::Instance()->UnInit();
PlayerMgr::Instance()->UnInit();
MetaMgr::Instance()->UnInit();
@ -350,6 +352,9 @@ void App::ProcessGameGateMsg(f8::MsgHdr& hdr)
ProcessNetMsg(handler, PlayerMgr::Instance(), hdr);
#endif
break;
case HID_RoomMgr:
ProcessNetMsg(handler, RoomMgr::Instance(), hdr);
break;
case HID_Player:
{
#if 0

View File

@ -26,6 +26,7 @@ class Human : public Entity
MetaData::Equip* chest_meta = nullptr;
MetaData::Equip* weapon_meta = nullptr;
std::string name;
float health = 0.0;
bool dead = false;
bool downed = false;

View File

@ -34,7 +34,7 @@ public:
{
std::string res_path;
if (!f8::IsOnlineEnv()) {
res_path = a8::Format("/var/data/conf_test/game%d/res/", {GAME_ID});
res_path = a8::Format("/var/data/conf_test/game%d/gameserver/res/", {GAME_ID});
} else {
res_path = "../res/";
}

View File

@ -30,6 +30,7 @@ Player* PlayerMgr::CreatePlayerByCMJoin(unsigned short obj_uniid, const cs::CMJo
Player* hum = new Player();
hum->entity_uniid = obj_uniid;
hum->account_id = msg.account_id();
hum->name = msg.name();
hum->health = 100;
hum->team_uniid = msg.team_uuid();
hum->team_mode = msg.team_mode();

View File

@ -69,7 +69,7 @@ void Room::AddPlayer(Player* hum)
unsigned short Room::AllocUniid()
{
while (GetEntityByUniId(++current_uniid)) {}
while (GetEntityByUniId(++current_uniid) || current_uniid == 0) {}
return current_uniid;
}
@ -82,6 +82,7 @@ void Room::ShuaAndroid()
}
for (int i = 0; i < 30; ++i) {
Android* hum = new Android();
hum->name = a8::Format("机器人%d", {i+1});
hum->meta = hum_meta;
hum->entity_uniid = AllocUniid();
hum->pos.x = 100 + rand() % 400;
@ -165,3 +166,19 @@ void Room::AddDeletedObject(unsigned short obj_uniid)
{
frame_data.deleted_objects.insert(obj_uniid);
}
void Room::FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg)
{
msg.set_team_mode(msg.team_mode());
msg.set_player_id(self_hum->entity_uniid);
msg.set_started(false);
for (auto& pair : uniid_hash_) {
if (pair.second->entity_type == ET_Player) {
Human* hum = (Human*)pair.second;
cs::MFPlayerInfo* info = msg.add_player_infos();
info->set_player_id(hum->entity_uniid);
info->set_team_id(hum->team_id);
info->set_name(hum->name);
}
}
}

View File

@ -47,6 +47,7 @@ public:
Human* FindEnemy(Human* hum);
void CollisionDetection(Entity* sender, int detection_flags, std::vector<Entity*> objects);
void AddDeletedObject(unsigned short obj_uniid);
void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg);
private:
unsigned short current_uniid = 0;

View File

@ -38,7 +38,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
if (!room) {
room = new Room();
room->room_uuid = App::Instance()->NewUuid();
assert(GetRoomByUuid(room->room_uuid));
assert(!GetRoomByUuid(room->room_uuid));
if (GetRoomByUuid(room->room_uuid)) {
abort();
}
@ -55,9 +55,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
{
cs::SMJoinedNotify notifymsg;
notifymsg.set_team_mode(msg.team_mode());
notifymsg.set_player_id(hum->entity_uniid);
notifymsg.set_started(false);
room->FillSMJoinedNotify(hum, notifymsg);
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
}
{

View File

@ -553,7 +553,6 @@ message SMMapInfo
optional int32 map_id = 1; //id
optional int32 width = 2; //
optional int32 height = 3; //
optional int32 seed = 4; //
repeated MFMapObject objects = 6; //
}

View File

@ -27,8 +27,6 @@ message Item
{
optional int32 id = 1; //id
optional int32 type = 2; //
optional int32 reward = 3; //使
optional int32 price = 4; //
}
message Equip

View File

@ -119,8 +119,6 @@ def onUserPacket(ws, msgid, msgbody):
print(str(msg),)
print('}')
print('')
if msgid == cs_msgid_pb2._SMTestAward:
print(msg.default_123456)
except Exception as e:
print('onUserPacket', e)
@ -137,11 +135,10 @@ def opOpen (ws):
global g_account_id
global g_session_id
global g_server_id
msg = cs_proto_pb2.CMLogin()
msg = cs_proto_pb2.CMJoin()
msg.server_id = int(g_server_id)
msg.account_id = g_account_id
msg.session_id = getSession(g_account_id)
msg.device_id = '123456'
msg.name = "测试"
print(msg.DESCRIPTOR.name, 'zzzzz')
sendMsg(ws, msg)
while True: