From ec9b1dc98f420ff24ec662e93235d2d4435dcec4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 25 Jul 2019 15:53:40 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 5 +++-- server/gameserver/room.cc | 2 +- server/gameserver/room.h | 2 +- server/gameserver/roommgr.cc | 6 +++--- server/gameserver/roommgr.h | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 5d2e49c..4fff4e6 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -863,7 +863,8 @@ void Human::RecoverHp(int inc_hp) { if (!dead) { ability.hp += inc_hp; - ability.hp = std::max(GetHP(), GetMaxHP()); + ability.hp = std::min(GetHP(), GetMaxHP()); + ability.hp = std::max(GetHP(), 1.0f); SyncAroundPlayers(); } } @@ -1657,7 +1658,7 @@ float Human::BuffAttrRate(int buff_effect_id) float Human::GetFireRate() { if (curr_weapon) { - return curr_weapon->meta->i->fire_rate() + ability.fire_rate; + return std::max(curr_weapon->meta->i->fire_rate() - ability.fire_rate, 1.0f); } else { return ability.fire_rate; } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index b51675e..4e61047 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -749,7 +749,7 @@ int Room::GetAliveTeamNum() return num; } -bool Room::CanJoin(const std::string& accountid) +bool Room::CanJoin(const std::string& accountid, const std::string& team_uuid) { if (gas_data.gas_mode != kGasInactive) { return false; diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 9e82b24..589a83f 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -95,7 +95,7 @@ public: bool BattleStarted(); int GetAliveTeamNum(); std::set* GetAliveTeam(); - bool CanJoin(const std::string& accountid); + bool CanJoin(const std::string& accountid, const std::string& team_uuid); void OnPlayerOffline(Player* hum); Obstacle* CreateObstacle(int id, float x, float y); bool IsGameOver(); diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 3de0648..38abfe9 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -46,7 +46,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) if (!hum_meta) { abort(); } - Room* room = GetJoinableRoom(msg.account_id()); + Room* room = GetJoinableRoom(msg.account_id(), msg.team_uuid()); if (!room) { room = new Room(); room->room_uuid = App::Instance()->NewUuid(); @@ -99,10 +99,10 @@ int RoomMgr::OverRoomNum() return over_room_hash_.size(); } -Room* RoomMgr::GetJoinableRoom(const std::string& account_id) +Room* RoomMgr::GetJoinableRoom(const std::string& account_id, const std::string& team_uuid) { for (auto& pair : inactive_room_hash_) { - if (pair.second->CanJoin(account_id)) { + if (pair.second->CanJoin(account_id, team_uuid)) { return pair.second; } } diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 88e262d..cb93dc1 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -31,7 +31,7 @@ class RoomMgr : public a8::Singleton void InstallReportStateTimer(); private: - Room* GetJoinableRoom(const std::string& account_id); + Room* GetJoinableRoom(const std::string& account_id, const std::string& team_uuid); void ReportServerState(int instance_id, const std::string& host, int port); void FreeOverRoom(long long room_uuid);