This commit is contained in:
aozhiwei 2019-07-25 15:53:40 +08:00
parent 840c786964
commit ec9b1dc98f
5 changed files with 9 additions and 8 deletions

View File

@ -863,7 +863,8 @@ void Human::RecoverHp(int inc_hp)
{ {
if (!dead) { if (!dead) {
ability.hp += inc_hp; ability.hp += inc_hp;
ability.hp = std::max(GetHP(), GetMaxHP()); ability.hp = std::min(GetHP(), GetMaxHP());
ability.hp = std::max(GetHP(), 1.0f);
SyncAroundPlayers(); SyncAroundPlayers();
} }
} }
@ -1657,7 +1658,7 @@ float Human::BuffAttrRate(int buff_effect_id)
float Human::GetFireRate() float Human::GetFireRate()
{ {
if (curr_weapon) { 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 { } else {
return ability.fire_rate; return ability.fire_rate;
} }

View File

@ -749,7 +749,7 @@ int Room::GetAliveTeamNum()
return num; 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) { if (gas_data.gas_mode != kGasInactive) {
return false; return false;

View File

@ -95,7 +95,7 @@ public:
bool BattleStarted(); bool BattleStarted();
int GetAliveTeamNum(); int GetAliveTeamNum();
std::set<Human*>* GetAliveTeam(); std::set<Human*>* GetAliveTeam();
bool CanJoin(const std::string& accountid); bool CanJoin(const std::string& accountid, const std::string& team_uuid);
void OnPlayerOffline(Player* hum); void OnPlayerOffline(Player* hum);
Obstacle* CreateObstacle(int id, float x, float y); Obstacle* CreateObstacle(int id, float x, float y);
bool IsGameOver(); bool IsGameOver();

View File

@ -46,7 +46,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
if (!hum_meta) { if (!hum_meta) {
abort(); abort();
} }
Room* room = GetJoinableRoom(msg.account_id()); Room* room = GetJoinableRoom(msg.account_id(), msg.team_uuid());
if (!room) { if (!room) {
room = new Room(); room = new Room();
room->room_uuid = App::Instance()->NewUuid(); room->room_uuid = App::Instance()->NewUuid();
@ -99,10 +99,10 @@ int RoomMgr::OverRoomNum()
return over_room_hash_.size(); 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_) { for (auto& pair : inactive_room_hash_) {
if (pair.second->CanJoin(account_id)) { if (pair.second->CanJoin(account_id, team_uuid)) {
return pair.second; return pair.second;
} }
} }

View File

@ -31,7 +31,7 @@ class RoomMgr : public a8::Singleton<RoomMgr>
void InstallReportStateTimer(); void InstallReportStateTimer();
private: 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 ReportServerState(int instance_id, const std::string& host, int port);
void FreeOverRoom(long long room_uuid); void FreeOverRoom(long long room_uuid);