From 1b9aa8c34ab5abbf0668525f2028163f6aa2cfbb Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 29 May 2020 20:20:39 +0800 Subject: [PATCH] 1 --- server/gameserver/room.cc | 138 +++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 68 deletions(-) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index d3d344d..dfd38cc 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -951,7 +951,7 @@ void Room::CombineTeam() hum->auto_fill = true; hum->team_uuid = a8::XValue(room_uuid_).GetString(); } - for (size_t i = 0; i < 4 - accountid_hash_.size(); ++i) { + for (size_t i = 0; i < MAX_TEAM_NUM - accountid_hash_.size(); ++i) { for (auto& pair : human_hash_) { Human* hum = pair.second; if (hum->IsAndroid() && @@ -1289,7 +1289,7 @@ void Room::RandRemoveAndroid() RemoveFromMoveableHash(hum); RemoveFromEntityHash(hum); RemoveFromHuamnHash(hum); - removed_robot_hash_[hum->entity_uniid] = hum; + AddToRemovedRobotHash(hum); --alive_count_; --App::Instance()->perf.alive_count; for (auto& pair : human_hash_) { @@ -1300,19 +1300,20 @@ void Room::RandRemoveAndroid() void Room::NotifyUiUpdate() { - xtimer.AddDeadLineTimerAndAttach(0, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Room* room = (Room*)param.sender.GetUserData(); - room->TouchPlayerList(a8::XParams(), - [] (Player * hum, a8::XParams & param) - { - hum->SendUIUpdate(); - }); - }, - &xtimer_attacher_.timer_list_); + xtimer.AddDeadLineTimerAndAttach + (0, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Room* room = (Room*)param.sender.GetUserData(); + room->TouchPlayerList(a8::XParams(), + [] (Player * hum, a8::XParams & param) + { + hum->SendUIUpdate(); + }); + }, + &xtimer_attacher_.timer_list_); } void Room::UpdateCarObject(int old_uniid, int new_uniid, a8::Vec2 pos) @@ -1375,19 +1376,20 @@ bool Room::HaveMyTeam(const std::string& team_uuid) void Room::NotifyWxVoip() { - xtimer.AddDeadLineTimerAndAttach(0, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Room* room = (Room*)param.sender.GetUserData(); - room->TouchPlayerList(a8::XParams(), - [] (Player * hum, a8::XParams & param) - { - hum->SendWxVoip(); - }); - }, - &xtimer_attacher_.timer_list_); + xtimer.AddDeadLineTimerAndAttach + (0, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Room* room = (Room*)param.sender.GetUserData(); + room->TouchPlayerList(a8::XParams(), + [] (Player * hum, a8::XParams & param) + { + hum->SendWxVoip(); + }); + }, + &xtimer_attacher_.timer_list_); } BornPoint* Room::AllocBornPoint(Human* hum) @@ -1418,7 +1420,8 @@ BornPoint* Room::AllocBornPoint(Human* hum) } } else { for (auto& pair : born_point_hash_) { - if (pair.second.player_num + pair.second.android_num < pair.second.thing_tpl->i->param1()) { + if (pair.second.player_num + pair.second.android_num < + pair.second.thing_tpl->i->param1()) { born_point = &pair.second; break; } @@ -1454,32 +1457,30 @@ void Room::CreateSpawnPoints() void Room::CreateLoots() { - if (loots_) { - for (auto& thing_tpl : *loots_) { - int thing_id = thing_tpl->RandThing(); - MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id); - if (equip_meta) { - int entity_uniid = CreateLoot( - equip_meta->i->id(), - a8::Vec2 - ( - thing_tpl->i->x(), - thing_tpl->i->y() - ), - 1, - 1 - ); - if (entity_uniid && equip_meta->i->equip_type() == EQUIP_TYPE_CAR) { - Entity* loot_entity = GetEntityByUniId(entity_uniid); - if (loot_entity && loot_entity->entity_type == ET_Loot) { - ((Loot*)loot_entity)->bullet_num = equip_meta->i->clip_volume(); - ((Loot*)loot_entity)->param1 = MetaMgr::Instance()->max_oil; - ((Loot*)loot_entity)->param2 = MetaMgr::Instance()->max_oil; - CarObject car; - car.car_id = equip_meta->i->id(); - car.pos = loot_entity->GetPos(); - car_hash_[loot_entity->entity_uniid] = car; - } + for (auto& thing_tpl : *loots_) { + int thing_id = thing_tpl->RandThing(); + MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id); + if (equip_meta) { + int entity_uniid = CreateLoot( + equip_meta->i->id(), + a8::Vec2 + ( + thing_tpl->i->x(), + thing_tpl->i->y() + ), + 1, + 1 + ); + if (entity_uniid && equip_meta->i->equip_type() == EQUIP_TYPE_CAR) { + Entity* loot_entity = GetEntityByUniId(entity_uniid); + if (loot_entity && loot_entity->entity_type == ET_Loot) { + ((Loot*)loot_entity)->bullet_num = equip_meta->i->clip_volume(); + ((Loot*)loot_entity)->param1 = MetaMgr::Instance()->max_oil; + ((Loot*)loot_entity)->param2 = MetaMgr::Instance()->max_oil; + CarObject car; + car.car_id = equip_meta->i->id(); + car.pos = loot_entity->GetPos(); + car_hash_[loot_entity->entity_uniid] = car; } } } @@ -1488,18 +1489,17 @@ void Room::CreateLoots() void Room::CreateDropObjs() { - if (buildings_) { - for (auto& building : *buildings_) { - for (auto& obj : building->meta->i->dropobj()) { - CreateLoot(obj.id(), - a8::Vec2( - building->GetX() + obj.x() - building->meta->i->tilewidth() / 2.0, - building->GetY() + obj.y() - building->meta->i->tileheight() / 2.0 - ), - 1, - 1 - ); - } + for (auto& building : *buildings_) { + for (auto& obj : building->meta->i->dropobj()) { + CreateLoot(obj.id(), + a8::Vec2 + ( + building->GetX() + obj.x() - building->meta->i->tilewidth() / 2.0, + building->GetY() + obj.y() - building->meta->i->tileheight() / 2.0 + ), + 1, + 1 + ); } } } @@ -1605,7 +1605,9 @@ void Room::SecondRandPoint() #endif for (auto& pair : accountid_hash_) { if (room_type_ == RT_MidBrid) { - pair.second->on_grid_chg = std::bind(&Room::OnHumanGridChg, this, std::placeholders::_1); + pair.second->on_grid_chg = std::bind(&Room::OnHumanGridChg, + this, + std::placeholders::_1); } } #ifdef DEBUG