添加调试日志

This commit is contained in:
aozhiwei 2020-08-03 15:10:30 +08:00
parent 6fc0eeca8e
commit 68afdd8441
6 changed files with 52 additions and 14 deletions

View File

@ -2002,6 +2002,20 @@ void Human::WinExp(Human* sender, int exp)
race_ != kZombieRace) { race_ != kZombieRace) {
abort(); 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; exp_ += exp;
MetaData::Player* old_meta = meta; MetaData::Player* old_meta = meta;
int start_meta_id = race_ == kHumanRace ? HUMAN_RACE_META_START_ID : ZOMBIE_RACE_META_START_ID; 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); 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) bool Human::IsEnemy(Human* hum)

View File

@ -262,6 +262,7 @@ class Human : public MoveableEntity
void RecalcBuffAttr(); void RecalcBuffAttr();
void ProcBuffEffect(Human* caster, Buff* buff); void ProcBuffEffect(Human* caster, Buff* buff);
int GetLevel() {return level_;}; int GetLevel() {return level_;};
int GetExp() {return exp_;};
void OnAttack() {}; void OnAttack() {};
void OnHit() {}; void OnHit() {};
int GetItemNum(int item_id); int GetItemNum(int item_id);

View File

@ -572,6 +572,20 @@ void Room::RemoveObjectLater(RoomEntity* entity)
void Room::OnHumanDie(Human* hum) void Room::OnHumanDie(Human* hum)
{ {
if (GetRoomMode() == kZombieMode) { 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) { if (hum->GetRace() == kHumanRace) {
RemoveRescue(hum); RemoveRescue(hum);
hum->DeadDrop(); hum->DeadDrop();
@ -2892,9 +2906,15 @@ void Room::ZombieModeStart()
if (human_hash_.size() != GetRoomMaxPlayerNum()) { if (human_hash_.size() != GetRoomMaxPlayerNum()) {
abort(); abort();
} }
#ifdef DEBUG
debug_trace = true;
#endif
std::vector<Human*> human_list; std::vector<Human*> human_list;
for (auto& pair : human_hash_) { for (auto& pair : human_hash_) {
human_list.push_back(pair.second); 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()); std::random_shuffle(human_list.begin(), human_list.end());
for (size_t i = 0; i < 2; ++i) { for (size_t i = 0; i < 2; ++i) {

View File

@ -42,6 +42,7 @@ public:
a8::TimerAttacher timer_attacher; a8::TimerAttacher timer_attacher;
GridService* grid_service = nullptr; GridService* grid_service = nullptr;
MapService* map_service = nullptr; MapService* map_service = nullptr;
bool debug_trace = false;
~Room(); ~Room();
void InitData(RoomInitInfo& init_info); void InitData(RoomInitInfo& init_info);

View File

@ -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 gm_hash_.find(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;
} }

View File

@ -28,7 +28,7 @@ class RoomMgr : public a8::Singleton<RoomMgr>
int OverRoomNum(); int OverRoomNum();
Room* GetRoomByUuid(long long uuid); Room* GetRoomByUuid(long long uuid);
void AddOverRoom(long long room_uuid); void AddOverRoom(long long room_uuid);
bool IsGM(const cs::CMJoin& msg); bool IsGM(const std::string& account_id);
private: private:
void InstallReportStateTimer(); void InstallReportStateTimer();