From ce5dcf7ea7358729ea23253a83b8d11ddf1fb4ac Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 5 Jul 2019 13:25:55 +0800 Subject: [PATCH] 1 --- server/gameserver/framemaker.cc | 11 +++++++++++ server/gameserver/human.cc | 6 ++++-- server/gameserver/human.h | 2 +- server/gameserver/room.cc | 10 +++++++++- server/gameserver/room.h | 1 + server/tools/protobuild/cs_proto.proto | 9 +-------- 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/server/gameserver/framemaker.cc b/server/gameserver/framemaker.cc index 1079d32..e270ab3 100644 --- a/server/gameserver/framemaker.cc +++ b/server/gameserver/framemaker.cc @@ -4,6 +4,7 @@ #include "human.h" #include "room.h" #include "typeconvert.h" +#include "metamgr.h" cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum) { @@ -73,6 +74,16 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum) if (room->frame_event.airdrops_.size() > 0) { *msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0); } + { + if (room->BattleStarted()) { + int game_left_time = MetaMgr::Instance()->game_duration * 1000 - + (room->frame_no - room->battle_start_frameno_) * FRAME_RATE_MS; + game_left_time = std::max(0, game_left_time); + msg->set_game_left_time(game_left_time); + } else { + msg->set_game_left_time(MetaMgr::Instance()->game_duration * 1000); + } + } } return msg; } diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 14c594c..f32f3dd 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -515,11 +515,12 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) [] (const a8::XParams& param) { Human* hum = (Human*)param.sender.GetUserData(); - hum->Relive(); + hum->Revive(); }, &xtimer_attacher.timer_list_ ); room->frame_event.AddDead(this); + room->OnHumanDie(this); SyncAroundPlayers(); } } @@ -1703,10 +1704,11 @@ void Human::DeadDrop() } } -void Human::Relive() +void Human::Revive() { dead = false; health = GetMaxHP(); room->frame_event.AddRevive(this); + room->OnHumanRevive(this); SyncAroundPlayers(); } diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 7ac385c..a012254 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -197,7 +197,7 @@ private: void ClearFrameData(); void GenBattleReportData(a8::MutableXObject* params); void DeadDrop(); - void Relive(); + void Revive(); protected: long long last_shot_frameno_ = 0; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index d2ed457..ee6d50f 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -40,7 +40,7 @@ void Room::Init() { xtimer.Init(RoomXGetTickCount, this, 100, 100); xtimer_attacher.xtimer = &xtimer; - grid_service.Init(MAP_WIDTH, MAP_HEIGHT, MAP_CELL_WIDTH); + grid_service.Init(MAP_WIDTH, MAP_HEIGHT, MAP_CELL_WIDTH * 8); map_service.Init(MAP_WIDTH / MAP_GRID_WIDTH, MAP_HEIGHT / MAP_GRID_WIDTH, MAP_GRID_WIDTH); CreateThings(); @@ -603,6 +603,7 @@ void Room::FetchBuilding(Human* hum) void Room::OnHumanDie(Human* hum) { + #if 0 if (hum->skill_meta && hum->skill_meta->i->type() == ST_SelfDetonate) { for (auto& pair : human_hash_) { if (pair.second != hum && (pair.second->team_id == 0 || pair.second->team_id != hum->team_id)) { @@ -617,10 +618,17 @@ void Room::OnHumanDie(Human* hum) } frame_event.AddExplosionEx(hum, 0, hum->pos, 1); } + #endif --alive_count_; NotifyUiUpdate(); } +void Room::OnHumanRevive(Human* hum) +{ + ++alive_count_; + NotifyUiUpdate(); +} + bool Room::OverBorder(const a8::Vec2 pos, float radius) { //检查x轴 diff --git a/server/gameserver/room.h b/server/gameserver/room.h index ce1b664..d05081a 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -78,6 +78,7 @@ public: a8::Vec2 pos, a8::Vec2 dir, float fly_distance); void OnHumanDie(Human* hum); + void OnHumanRevive(Human* hum); bool OverBorder(const a8::Vec2 pos, float radius); Human* GetWatchWarTarget(Human* hum); bool BattleStarted(); diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index cd5e88c..091d6bc 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -551,13 +551,6 @@ message MFBuff optional float lasting_time = 3; //持续时间(总时间毫秒) } -//飞机 -message MFPlane -{ - optional MFVector2D start_point = 1; //飞机起点 - optional MFVector2D end_point = 2; //飞机终点 -} - //end mfmsg //加入 @@ -699,7 +692,7 @@ message SMUpdate repeated MFObjectPart part_objects = 4; //对象-部分(用于插值更新) optional int32 active_player_id = 5; //当前活跃玩家id(如果玩家死亡后是观战对象的id) optional MFActivePlayerData active_player_data = 6; //活跃玩家数据(如果玩家死亡后是观战对象的数据) - optional int32 alive_count = 15; //存活数量 + optional int32 game_left_time = 15; //游戏剩余时间(毫秒, 战斗开始后字段才有意义) optional int32 gas_progress = 16; //毒圈进度,表示缩进的像素数(只有当gas_data.mode == moving时才会发进度) optional MFVector2D gas_pos_old = 30; //毒圈当前圆心坐标 optional MFGasData gas_data = 17; //毒圈数据