From f1943cc35b08732825e2d7ec55243d585c6afc8c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 22 Mar 2019 14:35:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E6=AD=A5=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/metamgr.cc | 6 ++++++ server/gameserver/metamgr.h | 1 + server/gameserver/room.cc | 11 +++++++++++ server/gameserver/room.h | 1 + server/gameserver/roommgr.cc | 1 + server/tools/protobuild/cs_proto.proto | 2 ++ 6 files changed, 22 insertions(+) diff --git a/server/gameserver/metamgr.cc b/server/gameserver/metamgr.cc index 54bab2d..5728168 100755 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -137,6 +137,12 @@ MetaData::Map* MetaMgr::GetMap(int map_id) return itr != loader_->gamemap_hash.end() ? itr->second : nullptr; } +MetaData::MapThing* MetaMgr::GetMapThing(int mapthing_id) +{ + auto itr = loader_->mapthing_hash.find(mapthing_id); + return itr != loader_->mapthing_hash.end() ? itr->second : nullptr; +} + MetaData::Player* MetaMgr::GetPlayer(int id) { auto itr = loader_->player_hash.find(id); diff --git a/server/gameserver/metamgr.h b/server/gameserver/metamgr.h index 51e575d..83a76ca 100755 --- a/server/gameserver/metamgr.h +++ b/server/gameserver/metamgr.h @@ -18,6 +18,7 @@ class MetaMgr : public a8::Singleton std::string GetSysParam(const std::string& param_name); MetaData::Map* GetMap(int map_id); + MetaData::MapThing* GetMapThing(int mapthing_id); MetaData::Player* GetPlayer(int id); MetaData::Equip* GetEquip(int id); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 8949ae4..66fcf6a 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -9,6 +9,7 @@ #include "movement.h" #include "bullet.h" #include "collider.h" +#include "obstacle.h" const int ROOM_MAX_PLAYER_NUM = 50; const int ANDROID_NUM = 0; @@ -79,6 +80,8 @@ void Room::AddPlayer(Player* hum) accountid_hash_[hum->account_id] = hum; human_hash_[hum->entity_uniid] = hum; ++alive_count_; + hum->new_players.insert(hum); + hum->part_players.insert(hum); for (auto& pair : human_hash_) { if (pair.second != hum) { pair.second->new_players.insert(hum); @@ -133,6 +136,14 @@ void Room::ShuaAndroid() } } +void Room::ShuaObstacle(Human* hum) +{ + MetaData::MapThing* thing = MetaMgr::Instance()->GetMapThing(61001); + if (!thing) { + return; + } +} + bool Room::RandomPos(Human* hum, float distance, Vector2D& out_pos) { float angle = ((float)rand() / RAND_MAX) * 2.0f; diff --git a/server/gameserver/room.h b/server/gameserver/room.h index c89c1e1..834adcd 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -45,6 +45,7 @@ public: void AddBullet(Bullet* bullet); unsigned short AllocUniid(); void ShuaAndroid(); + void ShuaObstacle(Human* hum); bool RandomPos(Human* hum, float distance, Vector2D& out_pos); Human* FindEnemy(Human* hum); void CollisionDetection(Entity* sender, int detection_flags, std::vector objects); diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index db60f16..20f8b96 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -55,6 +55,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) { cs::SMJoinedNotify notifymsg; + notifymsg.set_error_code(0); room->FillSMJoinedNotify(hum, notifymsg); GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg); } diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 029b57c..37b4719 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -545,6 +545,8 @@ message SMJoinedNotify optional int32 map_type = 5; //目前没用到 optional bool elo_start = 6; //目前没用到 + + optional int32 error_code = 7; //错误 } //地图信息