RoomMgr 重构
This commit is contained in:
parent
5d72dbdae6
commit
70c630575d
@ -73,7 +73,7 @@ private:
|
||||
3: battleReport环境
|
||||
4: 打印性能日志
|
||||
5: 压力测试
|
||||
6: 删除over room
|
||||
6:
|
||||
7: 内存泄露测试
|
||||
*/
|
||||
std::set<int> flags;
|
||||
|
@ -393,37 +393,6 @@ void Room::CreateThings()
|
||||
}
|
||||
}
|
||||
|
||||
void Room::FillSMMapInfo(cs::SMMapInfo& map_info)
|
||||
{
|
||||
for (auto& pair :uniid_hash_) {
|
||||
switch (pair.second->entity_type) {
|
||||
case ET_Obstacle:
|
||||
{
|
||||
Obstacle* entity = (Obstacle*)pair.second;
|
||||
if (!entity->building) {
|
||||
cs::MFMapObject* p = map_info.add_objects();
|
||||
p->set_object_id(entity->meta->i->thing_id());
|
||||
entity->pos.ToPB(p->mutable_pos());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ET_Building:
|
||||
{
|
||||
Building* entity = (Building*)pair.second;
|
||||
cs::MFMapObject* p = map_info.add_objects();
|
||||
p->set_object_id(entity->building_id);
|
||||
entity->pos.ToPB(p->mutable_pos());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::DropItem(Vector2D pos, int item_id, int item_count, int item_lv)
|
||||
{
|
||||
#if 0
|
||||
|
@ -67,7 +67,6 @@ public:
|
||||
|
||||
void FetchBuilding(Human* hum);
|
||||
void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg);
|
||||
void FillSMMapInfo(cs::SMMapInfo& map_info);
|
||||
|
||||
void TouchPlayerList(a8::XParams param,
|
||||
std::function<void (Player*, a8::XParams&)> func);
|
||||
|
@ -63,76 +63,36 @@ void RoomMgr::Update(int delta_time)
|
||||
void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
{
|
||||
MetaData::Player* hum_meta = MetaMgr::Instance()->GetPlayer(40001);
|
||||
assert(hum_meta);
|
||||
if (!hum_meta) {
|
||||
abort();
|
||||
}
|
||||
if (App::Instance()->is_test_mode) {
|
||||
for (int i = 0; i < App::Instance()->test_param; ++i) {
|
||||
Room* room = GetJoinableRoom(msg.account_id());
|
||||
if (!room) {
|
||||
room = new Room();
|
||||
room->room_uuid = App::Instance()->NewUuid();
|
||||
assert(!GetRoomByUuid(room->room_uuid));
|
||||
if (GetRoomByUuid(room->room_uuid)) {
|
||||
abort();
|
||||
}
|
||||
room->map_meta = MetaMgr::Instance()->GetMap(1001);
|
||||
room->Init();
|
||||
inactive_room_hash_[room->room_uuid] = room;
|
||||
room_hash_[room->room_uuid] = room;
|
||||
}
|
||||
if (i == 0) {
|
||||
{
|
||||
Player* hum = PlayerMgr::Instance()->CreatePlayerByCMJoin(hdr.ip_saddr, hdr.socket_handle, msg);
|
||||
hum->meta = hum_meta;
|
||||
room->AddPlayer(hum);
|
||||
hum->ProcPrepareItems(msg.prepare_items());
|
||||
Room* room = GetJoinableRoom(msg.account_id());
|
||||
if (!room) {
|
||||
room = new Room();
|
||||
room->room_uuid = App::Instance()->NewUuid();
|
||||
if (GetRoomByUuid(room->room_uuid)) {
|
||||
abort();
|
||||
}
|
||||
room->map_meta = MetaMgr::Instance()->GetMap(1001);
|
||||
room->Init();
|
||||
inactive_room_hash_[room->room_uuid] = room;
|
||||
room_hash_[room->room_uuid] = room;
|
||||
}
|
||||
Player* hum = PlayerMgr::Instance()->CreatePlayerByCMJoin(hdr.ip_saddr, hdr.socket_handle, msg);
|
||||
hum->meta = hum_meta;
|
||||
room->AddPlayer(hum);
|
||||
hum->ProcPrepareItems(msg.prepare_items());
|
||||
|
||||
cs::SMJoinedNotify notifymsg;
|
||||
notifymsg.set_error_code(0);
|
||||
room->FillSMJoinedNotify(hum, notifymsg);
|
||||
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
|
||||
}
|
||||
{
|
||||
cs::SMMapInfo notifymsg;
|
||||
notifymsg.set_map_id(room->map_meta->i->map_id());
|
||||
room->FillSMMapInfo(notifymsg);
|
||||
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Room* room = GetJoinableRoom(msg.account_id());
|
||||
if (!room) {
|
||||
room = new Room();
|
||||
room->room_uuid = App::Instance()->NewUuid();
|
||||
assert(!GetRoomByUuid(room->room_uuid));
|
||||
if (GetRoomByUuid(room->room_uuid)) {
|
||||
abort();
|
||||
}
|
||||
room->map_meta = MetaMgr::Instance()->GetMap(1001);
|
||||
room->Init();
|
||||
inactive_room_hash_[room->room_uuid] = room;
|
||||
room_hash_[room->room_uuid] = room;
|
||||
}
|
||||
Player* hum = PlayerMgr::Instance()->CreatePlayerByCMJoin(hdr.ip_saddr, hdr.socket_handle, msg);
|
||||
hum->meta = hum_meta;
|
||||
room->AddPlayer(hum);
|
||||
hum->ProcPrepareItems(msg.prepare_items());
|
||||
|
||||
{
|
||||
cs::SMJoinedNotify notifymsg;
|
||||
notifymsg.set_error_code(0);
|
||||
room->FillSMJoinedNotify(hum, notifymsg);
|
||||
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
|
||||
}
|
||||
{
|
||||
cs::SMMapInfo notifymsg;
|
||||
notifymsg.set_map_id(room->map_meta->i->map_id());
|
||||
room->FillSMMapInfo(notifymsg);
|
||||
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
|
||||
}
|
||||
{
|
||||
cs::SMJoinedNotify notifymsg;
|
||||
notifymsg.set_error_code(0);
|
||||
room->FillSMJoinedNotify(hum, notifymsg);
|
||||
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
|
||||
}
|
||||
{
|
||||
cs::SMMapInfo notifymsg;
|
||||
notifymsg.set_map_id(room->map_meta->i->map_id());
|
||||
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,12 +210,10 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po
|
||||
|
||||
void RoomMgr::FreeOverRoom(long long room_uuid)
|
||||
{
|
||||
if (App::Instance()->HasFlag(6)) {
|
||||
auto itr = over_room_hash_.find(room_uuid);
|
||||
if (itr != over_room_hash_.end()) {
|
||||
itr->second->UnInit();
|
||||
delete itr->second;
|
||||
over_room_hash_.erase(itr);
|
||||
}
|
||||
auto itr = over_room_hash_.find(room_uuid);
|
||||
if (itr != over_room_hash_.end()) {
|
||||
itr->second->UnInit();
|
||||
delete itr->second;
|
||||
over_room_hash_.erase(itr);
|
||||
}
|
||||
}
|
||||
|
@ -684,7 +684,6 @@ message SMJoinedNotify
|
||||
optional int32 team_mode = 1; //队伍模式 0:单人 1:多人
|
||||
optional int32 player_id = 2; //玩家id(自己)
|
||||
optional bool started = 3; //游戏是否已开始
|
||||
//repeated MFPlayerInfo player_infos = 4; //玩家信息
|
||||
|
||||
optional int32 map_type = 5; //目前没用到
|
||||
optional bool elo_start = 6; //目前没用到
|
||||
@ -726,7 +725,6 @@ message SMUpdate
|
||||
repeated MFEmote emotes = 23; //表情
|
||||
optional MFAirDrop airdrop = 26; //空投
|
||||
optional MFPlane plane = 27; //飞机
|
||||
optional int32 ack = 24; //服务器最后处理的req id
|
||||
}
|
||||
|
||||
//滚动消息
|
||||
|
Loading…
x
Reference in New Issue
Block a user