diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index f15733c..493ae74 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -83,6 +83,31 @@ void Human::FillMFObjectFull(cs::MFObjectFull* full_data) p->set_sdmg(sdmg); } +void Human::FillMFPlayerStats(cs::MFPlayerStats* stats_pb) +{ + stats_pb->set_player_id(entity_uniid); + stats_pb->set_player_avatar_url(avatar_url); + + stats_pb->set_time_alive(dead_frameno * 1000.0f / SERVER_FRAME_RATE); + stats_pb->set_kills(stats.kills); + stats_pb->set_damage_amount(stats.damage_amount); + stats_pb->set_heal_amount(stats.heal_amount); + + stats_pb->set_history_time_alive(stats.history_time_alive); + stats_pb->set_history_kills(stats.history_kills); + stats_pb->set_history_damage_amount(stats.history_damage_amount); + stats_pb->set_history_heal_amount(stats.history_heal_amount); + + stats_pb->set_gold(stats.gold); + stats_pb->set_score(stats.score); + + stats_pb->set_dead(dead); + stats_pb->set_killer_id(stats.killer_id); + stats_pb->set_killer_name(stats.killer_name); + + stats_pb->set_account_id(account_id); +} + void Human::Shot(Vector2D& target_dir) { if (!curr_weapon->meta) { diff --git a/server/gameserver/human.h b/server/gameserver/human.h index f788427..48baa00 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -13,12 +13,32 @@ struct HumanFrameData { }; +struct PlayerStats +{ + int kills = 0; + int damage_amount = 0; + int heal_amount = 0; + + int history_time_alive = 0; + int history_kills = 0; + int history_damage_amount = 0; + int history_heal_amount = 0; + + int gold = 0; + int score = 0; + + int killer_id = 0; + std::string killer_name; + +}; + class CircleCollider; class Obstacle; class Human : public Entity { public: int team_id = 0; + std::string account_id; std::string team_uniid; MetaData::Player* meta = nullptr; MetaData::Equip* helmet_meta = nullptr; @@ -28,6 +48,7 @@ class Human : public Entity Vector2D attack_dir; std::string name; + std::string avatar_url; float health = 0.0; bool dead = false; bool downed = false; @@ -61,6 +82,7 @@ class Human : public Entity bool need_sync_active_player = false; HumanFrameData frame_data; + PlayerStats stats; std::set new_objects; std::set part_objects; @@ -71,6 +93,7 @@ class Human : public Entity virtual float GetSpeed() override; virtual void FillMFObjectPart(cs::MFObjectPart* part_data) override; virtual void FillMFObjectFull(cs::MFObjectFull* full_data) override; + virtual void FillMFPlayerStats(cs::MFPlayerStats* stats); void Shot(Vector2D& target_dir); void RecalcSelfCollider(); bool IsCollision(); diff --git a/server/gameserver/player.h b/server/gameserver/player.h index 25c58ba..f9623fe 100644 --- a/server/gameserver/player.h +++ b/server/gameserver/player.h @@ -23,12 +23,10 @@ class Player : public Human public: int socket_handle = 0; - std::string account_id; int team_mode = 0; int player_count = 0; bool auto_fill = false; bool use_touch = false; - std::string avatar_url; int last_seq_id = 0; bool moving = false; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 0d15a34..253eb5e 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -478,12 +478,12 @@ message MFPlayerStats optional string player_avatar_url = 2; //玩家头像 //本次成绩 - optional int32 time_alive = 3; //存活时间 + optional int32 time_alive = 3; //存活时间(毫秒) optional int32 kills = 4; //击杀敌人数 optional int32 damage_amount = 8; //伤害总量 optional int32 heal_amount = 20; //治疗总量 //历史最佳成绩 - optional int32 history_time_alive = 30; //存活时间 + optional int32 history_time_alive = 30; //存活时间(毫秒) optional int32 history_kills = 31; //击杀敌人数 optional int32 history_damage_amount = 32; //伤害总量 optional int32 history_heal_amount = 33; //治疗总量 @@ -491,8 +491,9 @@ message MFPlayerStats optional int32 gold = 10; //金币 optional int32 score = 11; //积分 - optional int32 dead = 5; //是否已死亡 + optional bool dead = 5; //是否已死亡 optional int32 killer_id = 7; //杀手id(自杀时为自己) + optional string killer_name = 40; //杀手名称 optional string account_id = 21; //账号id }