From d3812d7ed7602ca82da6d3b70e2c3b4bfbd307d8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 23 May 2023 19:56:49 +0800 Subject: [PATCH] 1 --- server/gameserver/killmgr.cc | 16 +++++++++++++--- server/gameserver/killmgr.h | 9 +++++++-- server/gameserver/pbutils.cc | 9 +++++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/server/gameserver/killmgr.cc b/server/gameserver/killmgr.cc index 0d560988..c2a640eb 100644 --- a/server/gameserver/killmgr.cc +++ b/server/gameserver/killmgr.cc @@ -4,11 +4,13 @@ #include "human.h" #include "room.h" #include "player.h" + #include "mt/Param.h" #include "mt/Text.h" #include "mt/Equip.h" +#include "mt/Hero.h" -bool RollMsgHintInfo::Replace(int idx, std::string& text) +bool RollMsgHintInfo::Replace(Room* room, int idx, std::string& text) { switch (idx) { case kFieldIdxMasterName: @@ -23,7 +25,10 @@ bool RollMsgHintInfo::Replace(int idx, std::string& text) break; case kFieldIdxKillerHeroId: { - text = killer_name; + Human* hum = room->GetHumanByUniId(killer_id); + if (hum) { + text = a8::XValue(hum->meta->id()).GetString(); + } } break; case kFieldIdxDeadName: @@ -33,7 +38,10 @@ bool RollMsgHintInfo::Replace(int idx, std::string& text) break; case kFieldIdxDeadHeroId: { - text = dead_name; + Human* hum = room->GetHumanByUniId(dead_id); + if (hum) { + text = a8::XValue(hum->meta->id()).GetString(); + } } break; case kFieldIdxWeaponTextIcon: @@ -109,6 +117,8 @@ void KillMgr::FillHintInfo(Human* dead_hum, KillInfo* info, RollMsgHintInfo& hin if (equip_meta) { hint_info.weapon_text_icon = equip_meta->text_icon(); } + hint_info.dead_id = dead_hum->GetUniId(); + hint_info.killer_id = info->killer_id; hint_info.killer_name = killer->GetName(); if (info->killer_id == dead_hum->GetUniId()) { //${dead.name} 自杀 diff --git a/server/gameserver/killmgr.h b/server/gameserver/killmgr.h index 9f9fbfbd..ba50900c 100644 --- a/server/gameserver/killmgr.h +++ b/server/gameserver/killmgr.h @@ -7,6 +7,8 @@ namespace cs class SMRollMsg; } +class Room; + struct KillInfo { int root_master_id = 0; @@ -19,13 +21,15 @@ struct KillInfo struct RollMsgHintInfo { + int killer_id = 0; + int dead_id = 0; std::string master_name; std::string killer_name; std::string dead_name; std::string weapon_text_icon; std::vector>* hint_template = nullptr; - bool Replace(int idx, std::string& text); + bool Replace(Room* room, int idx, std::string& text); }; class Human; @@ -44,7 +48,8 @@ class KillMgr : public a8::Singleton private: void FillHintInfo(Human* dead_hum, KillInfo* info, RollMsgHintInfo& hint_info); - void PreprocessRollMsg(std::shared_ptr pb_msg, + void PreprocessRollMsg(Human* dead_hum, + std::shared_ptr pb_msg, RollMsgHintInfo& hint_info); void BoradcastRollMsg(Human* dead_hum, KillInfo* info, diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 5555aaf0..16e5d159 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -178,12 +178,13 @@ void KillMgr::OnHumanDead(Human* dead_hum, KillInfo* info) RollMsgHintInfo hint_info; std::shared_ptr pb_msg = std::make_shared(); FillHintInfo(dead_hum, info, hint_info); - PreprocessRollMsg(pb_msg, hint_info); + PreprocessRollMsg(dead_hum, pb_msg, hint_info); BoradcastRollMsg(dead_hum, info, 0, pb_msg); } -void KillMgr::PreprocessRollMsg(std::shared_ptr pb_msg, - RollMsgHintInfo& hint_info) +void KillMgr::PreprocessRollMsg(Human* dead_hum, + std::shared_ptr pb_msg, + RollMsgHintInfo& hint_info) { if (hint_info.hint_template) { for (auto& tuple : *hint_info.hint_template) { @@ -214,7 +215,7 @@ void KillMgr::PreprocessRollMsg(std::shared_ptr pb_msg, default: { std::string text; - if (hint_info.Replace(el_type, text)) { + if (hint_info.Replace(dead_hum->room, el_type, text)) { if (el_type == kFieldIdxWeaponTextIcon) { auto e = pb_msg->add_elements(); e->set_element_type(kImageElement);