From 0f4712b43ff1ed323549f8ffadc372365b149d95 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 7 Apr 2022 14:30:08 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 2 ++ server/gameserver/typeconvert.cc | 16 ++++++++++++++++ server/gameserver/typeconvert.h | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index fe6fc608..e7e0e45d 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -818,6 +818,8 @@ void Human::FillSMGameOver(cs::SMGameOver& msg) p->add_values(pair.second); } } + stats.CalcReward(this, stats.rank, stats.kills); + TypeConvert::ToPb(stats.over_reward, msg.mutable_reward()); } void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) diff --git a/server/gameserver/typeconvert.cc b/server/gameserver/typeconvert.cc index e101ae58..036aa7e2 100644 --- a/server/gameserver/typeconvert.cc +++ b/server/gameserver/typeconvert.cc @@ -1,6 +1,8 @@ #include "precompile.h" +#include "typeconvert.h" #include "cs_proto.pb.h" +#include "human.h" namespace TypeConvert { @@ -16,4 +18,18 @@ namespace TypeConvert v.y = pb_obj->y(); } + void ToPb(const OverReward& v, cs::MFOverReward* pb_obj) + { + pb_obj->set_total(v.total); + pb_obj->mutable_hero()->set_obtain_gold(v.hero.obtain_gold); + pb_obj->mutable_hero()->set_gold_limit(v.hero.gold_limit); + + pb_obj->mutable_weapon1()->set_obtain_gold(v.weapon1.obtain_gold); + pb_obj->mutable_weapon1()->set_gold_limit(v.weapon1.gold_limit); + + pb_obj->mutable_weapon2()->set_obtain_gold(v.weapon2.obtain_gold); + pb_obj->mutable_weapon2()->set_gold_limit(v.weapon2.gold_limit); + + } + } diff --git a/server/gameserver/typeconvert.h b/server/gameserver/typeconvert.h index 71c50da9..5da5a4d8 100644 --- a/server/gameserver/typeconvert.h +++ b/server/gameserver/typeconvert.h @@ -3,10 +3,15 @@ namespace cs { class MFVec2; + class MFOverReward; } +struct OverReward; + namespace TypeConvert { void ToPb(const a8::Vec2& v, cs::MFVec2* pb_obj); void FromPb(a8::Vec2& v, const cs::MFVec2* pb_obj); + + void ToPb(const OverReward& v, cs::MFOverReward* pb_obj); }