完成gm工具逻辑
This commit is contained in:
parent
cf87b127d4
commit
3ad1dda451
5
server/bin/gmtool.sh
Executable file
5
server/bin/gmtool.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd ../tools/robot/virtualclient
|
||||
python robot3.py ws://192.168.100.21:7101 hao1069 hao1069 $1
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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/";
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
{
|
||||
|
@ -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; //地图对象
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user