1
This commit is contained in:
parent
6a30ba3375
commit
568e7449b4
@ -50,6 +50,7 @@ void HandlerMgr::RegisterNetMsgHandlers()
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMVoice);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMGameOver);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMWatchWar);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMLeave);
|
||||
}
|
||||
|
||||
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
||||
|
@ -434,7 +434,9 @@ void Human::FillSMGameOver(cs::SMGameOver& msg)
|
||||
room->TouchHumanList(a8::XParams(),
|
||||
[&human_list] (Human* hum, a8::XParams& param) -> bool
|
||||
{
|
||||
human_list.push_back(hum);
|
||||
if (hum->leave_frameno_ == 0 || hum->leave_frameno_ > hum->room->battle_start_frameno_) {
|
||||
human_list.push_back(hum);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
std::sort(human_list.begin(), human_list.end(),
|
||||
@ -529,13 +531,13 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!HasLiveTeammate()) {
|
||||
if (!HasLiveTeammate() && !leave_) {
|
||||
if (team_members) {
|
||||
for (auto& member : *team_members) {
|
||||
member->SendGameOver();
|
||||
}
|
||||
} else {
|
||||
SendGameOver();
|
||||
SendGameOver();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,6 +186,8 @@ protected:
|
||||
long long reflect_damage_frameno_ = 0;
|
||||
long long summon_hero_frameno_ = 0;
|
||||
a8::XTimerAttacher skill_xtimer_attacher_;
|
||||
bool leave_ = false;
|
||||
long long leave_frameno_ = 0;
|
||||
|
||||
std::array<int, IS_END - 1> inventory_ = {};
|
||||
std::array<int, IS_END> volume_ = {};
|
||||
|
@ -993,3 +993,17 @@ void Player::_CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg)
|
||||
SendNotifyMsg(respmsg);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_CMLeave(f8::MsgHdr& hdr, const cs::CMLeave& msg)
|
||||
{
|
||||
if (!leave_) {
|
||||
if (room->BattleStarted()) {
|
||||
//如果战斗已经开始算自杀
|
||||
BeKill(entity_uniid, name, VW_Spectate);
|
||||
}
|
||||
leave_ = true;
|
||||
leave_frameno_ = room->frame_no;
|
||||
}
|
||||
cs::SMLeave respmsg;
|
||||
SendNotifyMsg(respmsg);
|
||||
}
|
||||
|
@ -90,5 +90,6 @@ class Player : public Human
|
||||
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
|
||||
void _CMGameOver(f8::MsgHdr& hdr, const cs::CMGameOver& msg);
|
||||
void _CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg);
|
||||
void _CMLeave(f8::MsgHdr& hdr, const cs::CMLeave& msg);
|
||||
|
||||
};
|
||||
|
@ -614,6 +614,11 @@ Human* Room::GetWatchWarTarget(Human* hum)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Room::BattleStarted()
|
||||
{
|
||||
return battle_start_frameno_ != 0;
|
||||
}
|
||||
|
||||
int Room::NewTeam()
|
||||
{
|
||||
++current_teamid;
|
||||
@ -757,6 +762,7 @@ void Room::UpdateGas()
|
||||
}
|
||||
gas_data.rad_old = gas_data.old_area_meta->i->rad();
|
||||
gas_data.rad_new = gas_data.new_area_meta->i->rad();
|
||||
battle_start_frameno_ = frame_no;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
a8::XTimer xtimer;
|
||||
Plane plane;
|
||||
GridService grid_service;
|
||||
long long battle_start_frameno_ = 0;
|
||||
|
||||
~Room();
|
||||
void Init();
|
||||
@ -83,6 +84,7 @@ public:
|
||||
void OnHumanDie(Human* hum);
|
||||
bool OverBorder(const Vector2D pos, float radius);
|
||||
Human* GetWatchWarTarget(Human* hum);
|
||||
bool BattleStarted();
|
||||
|
||||
private:
|
||||
unsigned short AllocUniid();
|
||||
|
@ -11,6 +11,7 @@ enum CMMessageId_e
|
||||
_CMVoice = 206;
|
||||
_CMGameOver = 207;
|
||||
_CMWatchWar = 208;
|
||||
_CMLeave = 209;
|
||||
}
|
||||
|
||||
enum SMMessageId_e
|
||||
@ -19,6 +20,7 @@ enum SMMessageId_e
|
||||
_SMRpcError = 102;
|
||||
|
||||
_SMWatchWar = 208;
|
||||
_SMLeave = 209;
|
||||
|
||||
_SMJoinedNotify = 103;
|
||||
_SMMapInfo = 1002;
|
||||
|
@ -657,6 +657,12 @@ message CMWatchWar
|
||||
|
||||
}
|
||||
|
||||
//离开 在飞机起飞前视为:逃跑 起飞后视为自杀
|
||||
message CMLeave
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//endcmmsg
|
||||
|
||||
//观战error_code == 0 时关闭结算界面,回到战斗界面
|
||||
@ -741,6 +747,11 @@ message SMGameOver
|
||||
repeated MFPlayerStats player_stats = 6; //玩家信息统计
|
||||
}
|
||||
|
||||
//离开
|
||||
message SMLeave
|
||||
{
|
||||
}
|
||||
|
||||
//断线通知
|
||||
message SMDisconnectNotify
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user