From 68afdd844114f215e1aa6730322d36fa1f2e71bf Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 3 Aug 2020 15:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B0=83=E8=AF=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/human.cc | 27 +++++++++++++++++++++++++++ server/gameserver/human.h | 1 + server/gameserver/room.cc | 20 ++++++++++++++++++++ server/gameserver/room.h | 1 + server/gameserver/roommgr.cc | 15 ++------------- server/gameserver/roommgr.h | 2 +- 6 files changed, 52 insertions(+), 14 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index b6ef131..65268c8 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -2002,6 +2002,20 @@ void Human::WinExp(Human* sender, int exp) race_ != kZombieRace) { abort(); } + if (room->debug_trace) { + a8::UdpLog::Instance()->Debug + ( + "WinExp before sender_id:%d uniid:%d race:%d level:%d exp:%d add_exp:%d ", + { + sender->GetEntityUniId(), + GetEntityUniId(), + GetRace(), + GetLevel(), + GetExp(), + exp + } + ); + } exp_ += exp; MetaData::Player* old_meta = meta; int start_meta_id = race_ == kHumanRace ? HUMAN_RACE_META_START_ID : ZOMBIE_RACE_META_START_ID; @@ -2026,6 +2040,19 @@ void Human::WinExp(Human* sender, int exp) room->OnZombieAppear(this); } } + if (room->debug_trace) { + a8::UdpLog::Instance()->Debug + ( + "WinExp after sender_id:%d uniid:%d race:%d level:%d exp:%d add_exp:%d ", + { + sender->GetEntityUniId(), + GetRace(), + GetLevel(), + GetExp(), + exp + } + ); + } } bool Human::IsEnemy(Human* hum) diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 695a3e3..9b1f085 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -262,6 +262,7 @@ class Human : public MoveableEntity void RecalcBuffAttr(); void ProcBuffEffect(Human* caster, Buff* buff); int GetLevel() {return level_;}; + int GetExp() {return exp_;}; void OnAttack() {}; void OnHit() {}; int GetItemNum(int item_id); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 9ea48f8..071d95c 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -572,6 +572,20 @@ void Room::RemoveObjectLater(RoomEntity* entity) void Room::OnHumanDie(Human* hum) { if (GetRoomMode() == kZombieMode) { + if (debug_trace) { + a8::UdpLog::Instance()->Debug + ( + "OnHumanDie uniid:%d name:%s race:%d level:%d exp:%d killer_id:%d ", + { + hum->GetEntityUniId(), + hum->name, + hum->GetRace(), + hum->GetLevel(), + hum->GetExp(), + hum->stats.killer_id + } + ); + } if (hum->GetRace() == kHumanRace) { RemoveRescue(hum); hum->DeadDrop(); @@ -2892,9 +2906,15 @@ void Room::ZombieModeStart() if (human_hash_.size() != GetRoomMaxPlayerNum()) { abort(); } + #ifdef DEBUG + debug_trace = true; + #endif std::vector human_list; for (auto& pair : human_hash_) { human_list.push_back(pair.second); + if (RoomMgr::Instance()->IsGM(pair.second->account_id)) { + debug_trace = true; + } } std::random_shuffle(human_list.begin(), human_list.end()); for (size_t i = 0; i < 2; ++i) { diff --git a/server/gameserver/room.h b/server/gameserver/room.h index ef5400a..a3c5093 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -42,6 +42,7 @@ public: a8::TimerAttacher timer_attacher; GridService* grid_service = nullptr; MapService* map_service = nullptr; + bool debug_trace = false; ~Room(); void InitData(RoomInitInfo& init_info); diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 3b6c57e..ba8214e 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -466,18 +466,7 @@ void RoomMgr::JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_ }); } -bool RoomMgr::IsGM(const cs::CMJoin& msg) +bool RoomMgr::IsGM(const std::string& account_id) { - if (gm_hash_.find(msg.account_id()) == gm_hash_.end()) { - return false; - } - for (int equip_id : msg.prepare_items()) { - MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(equip_id); - if (item_meta) { - if (item_meta->i->equip_type() == EQUIP_TYPE_CAR) { - return true; - } - } - } - return false; + return gm_hash_.find(account_id) != gm_hash_.end(); } diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 5c33fa0..a579cb3 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -28,7 +28,7 @@ class RoomMgr : public a8::Singleton int OverRoomNum(); Room* GetRoomByUuid(long long uuid); void AddOverRoom(long long room_uuid); - bool IsGM(const cs::CMJoin& msg); + bool IsGM(const std::string& account_id); private: void InstallReportStateTimer();