From 807b8d79d7be0277bf48555742e0baf20c9835df Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 22 Jul 2019 17:30:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=87=BB=E6=9D=80=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/human.cc | 6 +++--- server/gameserver/room.cc | 11 +++++++++++ server/gameserver/room.h | 7 +++++++ server/gameserver/types.h | 1 + server/tools/protobuild/cs_proto.proto | 15 +++++++++++++-- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index b033f74..02cc42a 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -463,7 +463,8 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) Entity* entity = room->GetEntityByUniId(killer_id); if (entity && entity->entity_type == kET_Player) { Human* killer = (Human*)entity; - killer->stats.dead_times++; + killer->stats.kills++; + killer->stats.last_kill_timeseq = ++room->last_kill_timeseq; } } ++stats.dead_times; @@ -1033,8 +1034,7 @@ void Human::DirectReload() void Human::SendUIUpdate() { cs::SMUiUpdate notifymsg; - notifymsg.set_alive_count(room->AliveCount()); - notifymsg.set_kill_count(stats.kills); + room->FillSMUiUpdate(notifymsg); SendNotifyMsg(notifymsg); } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index ba79d18..27050d0 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -484,6 +484,17 @@ bool Room::IsGameOver() return game_over; } +void Room::FillSMUiUpdate(cs::SMUiUpdate& msg) +{ + for (auto& pair : human_hash_) { + cs::MFPlayerBattlingStats* p = msg.add_player_stats(); + p->set_player_id(pair.second->entity_uniid); + p->set_name(pair.second->name); + p->set_kills(pair.second->stats.kills); + p->set_last_kill_timeseq(pair.second->stats.last_kill_timeseq); + } +} + Hero* Room::CreateHero(Human* hum) { a8::Vec2 pos = hum->pos; diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 7a3068d..c16154a 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -9,6 +9,11 @@ #include "mapservice.h" #include "metadata.h" +namespace cs +{ + class SMUiUpdate; +} + namespace MetaData { struct Map; @@ -46,6 +51,7 @@ public: MapService map_service; long long battle_start_frameno_ = 0; long long pending_request = 0; + int last_kill_timeseq = 0; ~Room(); void Init(); @@ -92,6 +98,7 @@ public: void OnPlayerOffline(Player* hum); Obstacle* CreateObstacle(int id, float x, float y); bool IsGameOver(); + void FillSMUiUpdate(cs::SMUiUpdate& msg); private: int AllocUniid(); diff --git a/server/gameserver/types.h b/server/gameserver/types.h index 4a2915b..0702a28 100755 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -85,6 +85,7 @@ struct Driver struct PlayerStats { int kills = 0; + int last_kill_timeseq = 0; int dead_times = 0; int damage_amount_in = 0; int damage_amount_out = 0; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index cca9c8b..da34fa5 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -540,6 +540,18 @@ message MFPlayerStats optional int32 dead_times = 6; //死亡次数 } +//玩家战斗中统计 +message MFPlayerBattlingStats +{ + optional int32 player_id = 1; //玩家id + optional string name = 2; //玩家名(可能为undefined) + optional int32 kills = 3; //击杀数 + /* + 最后击杀时间序号(用于客户端排序, 击杀数相同时越小的排前面, 如果timeseq也相同则player_id小的排前面 + */ + optional int32 last_kill_timeseq = 4; +} + //空投 message MFAirDrop { @@ -797,6 +809,5 @@ message SMWxVoip //ui界面更新,一些不需要实时更新的数据 message SMUiUpdate { - optional int32 alive_count = 1; //存活数量 - optional int32 kill_count = 2; //击杀数 + repeated MFPlayerBattlingStats player_stats = 1; //玩家战斗中统计信息 }