From 630b620c18e0cc7abd97482aba4c310fe1552b3e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 27 Oct 2022 19:14:21 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 19 +++++++++++++++++-- server/gameserver/player.cc | 22 +++++++++++----------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 092a14ee..3d166b57 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -621,11 +621,17 @@ void Human::FillMFPlayerStats(cs::MFPlayerStats* stats_pb) stats_pb->set_team_id(team_id); stats_pb->set_nickname(name); + int alive_time = room->GetFrameNo() * FRAME_RATE_MS; if (!dead) { - stats_pb->set_time_alive(room->GetFrameNo() * 1000.0f / SERVER_FRAME_RATE); + stats_pb->set_time_alive(alive_time); } else { - stats_pb->set_time_alive(dead_frameno * 1000.0f / SERVER_FRAME_RATE); + alive_time = (dead_frameno - room->GetBattleStartFrameNo()) * FRAME_RATE_MS; + if (room->GetBattleStartFrameNo() <= 0) { + alive_time = 0; + } + stats_pb->set_time_alive(alive_time); } + stats_pb->set_kills(stats.kills); stats_pb->set_damage_amount(stats.damage_amount_out); stats_pb->set_heal_amount(stats.heal_amount); @@ -1111,6 +1117,12 @@ void Human::FillSMGameOver(cs::SMGameOver& msg) } } } +#if 1 + if (room->GetBattleStartFrameNo() <= 0) { + msg.set_team_rank(0); + msg.set_personal_rank(0); + } +#endif } void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) @@ -2164,6 +2176,9 @@ void Human::GenBattleReportData(a8::MutableXObject* params) params->SetVal("alive_time", alive_time); } else { alive_time = (dead_frameno - room->GetBattleStartFrameNo()) * FRAME_RATE_MS; + if (room->GetBattleStartFrameNo() <= 0) { + alive_time = 0; + } params->SetVal("alive_time", alive_time); } params->SetVal("weapon_uuid1", spec_weapons.size() > 0 ? spec_weapons[0].weapon_uniid : 0); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index e52b6ed3..98a80b09 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -801,12 +801,12 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg) } } } else { -#ifdef DEBUG +#ifdef DEBUG1 a8::XPrintf("attack_dir 0,0\n", {}); #endif } } else { -#ifdef DEBUG +#ifdef DEBUG1 a8::XPrintf("moving:%d times:%d\n", {moving ? 1 : 0, GetDisableAttackDirTimes()}); #endif if (moving && GetDisableAttackDirTimes() <= 0) { @@ -1103,15 +1103,15 @@ void Player::_CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg) void Player::_CMGameOver(f8::MsgHdr& hdr, const cs::CMGameOver& msg) { - CancelRevive(); - if (!dead) { - BeKill(GetUniId(), name, 0); - } if (room->GetGasData().GetGasMode() == GasInactive || HasBuffEffect(kBET_Fly) || HasBuffEffect(kBET_Jump)) { stats.is_run_away = true; } + CancelRevive(); + if (!dead) { + BeKill(GetUniId(), name, 0); + } SendGameOver(); } @@ -1122,6 +1122,11 @@ void Player::_CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg) void Player::_CMLeave(f8::MsgHdr& hdr, const cs::CMLeave& msg) { + if (room->GetGasData().GetGasMode() == GasInactive || + HasBuffEffect(kBET_Fly) || + HasBuffEffect(kBET_Jump)) { + stats.is_run_away = true; + } if (!leave_) { if (room->BattleStarted()) { //如果战斗已经开始算自杀 @@ -1130,11 +1135,6 @@ void Player::_CMLeave(f8::MsgHdr& hdr, const cs::CMLeave& msg) leave_ = true; leave_frameno_ = room->GetFrameNo(); } - if (room->GetGasData().GetGasMode() == GasInactive || - HasBuffEffect(kBET_Fly) || - HasBuffEffect(kBET_Jump)) { - stats.is_run_away = true; - } cs::SMLeave respmsg; SendNotifyMsg(respmsg); }