From f1997b657aaedfbe9dff11d1fbd6df0433b3d600 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 28 Feb 2020 15:48:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=09=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/room.cc | 35 ++++++++++++++++++++++++++ server/gameserver/room.h | 2 ++ server/tools/protobuild/cs_msgid.proto | 1 + server/tools/protobuild/cs_proto.proto | 7 +++++- 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index fda1e17..9f936a7 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -982,6 +982,8 @@ void Room::UpdateGasInactive() NotifyUiUpdate(); } CombineTeam(); + NotifyGameStart(); + SecondRandPoint(); #else gas_data.gas_mode = GasJump; gas_data.gas_start_frameno = frame_no; @@ -1505,6 +1507,15 @@ void Room::NotifyWxVoip() BornPoint* Room::AllocBornPoint(Human* hum) { + if (hum->born_point) { + std::vector point_list; + for (auto& pair : born_point_hash_) { + if (&pair.second != hum->born_point) { + point_list.push_back(&pair.second); + } + } + return !point_list.empty() ? point_list[rand() % point_list.size()] : nullptr; + } BornPoint* born_point = nullptr; for (auto& pair : born_point_hash_) { if (pair.second.player_num + pair.second.android_num < pair.second.thing_tpl->i->param1()) { @@ -1576,3 +1587,27 @@ void Room::CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl) born_point.thing_tpl = &thing_tpl; born_point_hash_[AllocUniid()] = born_point; } + +void Room::SecondRandPoint() +{ + for (auto& pair : accountid_hash_) { + Human* hum = pair.second; + hum->born_point = AllocBornPoint(hum); + if (!hum->born_point) { + hum->pos.x = DEFAULT_BORN_POINT_X + rand() % 100; + hum->pos.y = DEFAULT_BORN_POINT_Y + rand() % 200; + } else { + hum->pos = hum->born_point->RandPoint(); + } + hum->FindLocation(); + hum->RefreshView(); + } +} + +void Room::NotifyGameStart() +{ + cs::SMGameStart msg; + for (auto& pair : accountid_hash_) { + pair.second->SendNotifyMsg(msg); + } +} diff --git a/server/gameserver/room.h b/server/gameserver/room.h index ae3390d..535fa72 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -130,6 +130,8 @@ private: BornPoint* AllocBornPoint(Human* hum); void CreateMapObject(MetaData::MapTplThing& thing_tpl); void CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl); + void SecondRandPoint(); + void NotifyGameStart(); private: int elapsed_time_ = 0; diff --git a/server/tools/protobuild/cs_msgid.proto b/server/tools/protobuild/cs_msgid.proto index 7421f83..d583841 100644 --- a/server/tools/protobuild/cs_msgid.proto +++ b/server/tools/protobuild/cs_msgid.proto @@ -36,4 +36,5 @@ enum SMMessageId_e _SMDebugMsg = 1010; _SMWxVoip = 1011; _SMUiUpdate = 1012; + _SMGameStart = 1013; } diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index a0ba428..7ed1183 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -869,4 +869,9 @@ message SMUiUpdate optional int32 alive_count = 1; //存活数量 optional int32 kill_count = 2; //击杀数 repeated MFCar car_list = 3; //载具列表 -} \ No newline at end of file +} + +//游戏开始 +message SMGameStart +{ +}