This commit is contained in:
aozhiwei 2020-05-29 20:20:39 +08:00
parent 675d17f1bb
commit 1b9aa8c34a

View File

@ -951,7 +951,7 @@ void Room::CombineTeam()
hum->auto_fill = true; hum->auto_fill = true;
hum->team_uuid = a8::XValue(room_uuid_).GetString(); 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_) { for (auto& pair : human_hash_) {
Human* hum = pair.second; Human* hum = pair.second;
if (hum->IsAndroid() && if (hum->IsAndroid() &&
@ -1289,7 +1289,7 @@ void Room::RandRemoveAndroid()
RemoveFromMoveableHash(hum); RemoveFromMoveableHash(hum);
RemoveFromEntityHash(hum); RemoveFromEntityHash(hum);
RemoveFromHuamnHash(hum); RemoveFromHuamnHash(hum);
removed_robot_hash_[hum->entity_uniid] = hum; AddToRemovedRobotHash(hum);
--alive_count_; --alive_count_;
--App::Instance()->perf.alive_count; --App::Instance()->perf.alive_count;
for (auto& pair : human_hash_) { for (auto& pair : human_hash_) {
@ -1300,19 +1300,20 @@ void Room::RandRemoveAndroid()
void Room::NotifyUiUpdate() void Room::NotifyUiUpdate()
{ {
xtimer.AddDeadLineTimerAndAttach(0, xtimer.AddDeadLineTimerAndAttach
a8::XParams() (0,
.SetSender(this), a8::XParams()
[] (const a8::XParams& param) .SetSender(this),
{ [] (const a8::XParams& param)
Room* room = (Room*)param.sender.GetUserData(); {
room->TouchPlayerList(a8::XParams(), Room* room = (Room*)param.sender.GetUserData();
[] (Player * hum, a8::XParams & param) room->TouchPlayerList(a8::XParams(),
{ [] (Player * hum, a8::XParams & param)
hum->SendUIUpdate(); {
}); hum->SendUIUpdate();
}, });
&xtimer_attacher_.timer_list_); },
&xtimer_attacher_.timer_list_);
} }
void Room::UpdateCarObject(int old_uniid, int new_uniid, a8::Vec2 pos) 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() void Room::NotifyWxVoip()
{ {
xtimer.AddDeadLineTimerAndAttach(0, xtimer.AddDeadLineTimerAndAttach
a8::XParams() (0,
.SetSender(this), a8::XParams()
[] (const a8::XParams& param) .SetSender(this),
{ [] (const a8::XParams& param)
Room* room = (Room*)param.sender.GetUserData(); {
room->TouchPlayerList(a8::XParams(), Room* room = (Room*)param.sender.GetUserData();
[] (Player * hum, a8::XParams & param) room->TouchPlayerList(a8::XParams(),
{ [] (Player * hum, a8::XParams & param)
hum->SendWxVoip(); {
}); hum->SendWxVoip();
}, });
&xtimer_attacher_.timer_list_); },
&xtimer_attacher_.timer_list_);
} }
BornPoint* Room::AllocBornPoint(Human* hum) BornPoint* Room::AllocBornPoint(Human* hum)
@ -1418,7 +1420,8 @@ BornPoint* Room::AllocBornPoint(Human* hum)
} }
} else { } else {
for (auto& pair : born_point_hash_) { 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; born_point = &pair.second;
break; break;
} }
@ -1454,32 +1457,30 @@ void Room::CreateSpawnPoints()
void Room::CreateLoots() void Room::CreateLoots()
{ {
if (loots_) { for (auto& thing_tpl : *loots_) {
for (auto& thing_tpl : *loots_) { int thing_id = thing_tpl->RandThing();
int thing_id = thing_tpl->RandThing(); MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id);
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id); if (equip_meta) {
if (equip_meta) { int entity_uniid = CreateLoot(
int entity_uniid = CreateLoot( equip_meta->i->id(),
equip_meta->i->id(), a8::Vec2
a8::Vec2 (
( thing_tpl->i->x(),
thing_tpl->i->x(), thing_tpl->i->y()
thing_tpl->i->y() ),
), 1,
1, 1
1 );
); if (entity_uniid && equip_meta->i->equip_type() == EQUIP_TYPE_CAR) {
if (entity_uniid && equip_meta->i->equip_type() == EQUIP_TYPE_CAR) { Entity* loot_entity = GetEntityByUniId(entity_uniid);
Entity* loot_entity = GetEntityByUniId(entity_uniid); if (loot_entity && loot_entity->entity_type == ET_Loot) {
if (loot_entity && loot_entity->entity_type == ET_Loot) { ((Loot*)loot_entity)->bullet_num = equip_meta->i->clip_volume();
((Loot*)loot_entity)->bullet_num = equip_meta->i->clip_volume(); ((Loot*)loot_entity)->param1 = MetaMgr::Instance()->max_oil;
((Loot*)loot_entity)->param1 = MetaMgr::Instance()->max_oil; ((Loot*)loot_entity)->param2 = MetaMgr::Instance()->max_oil;
((Loot*)loot_entity)->param2 = MetaMgr::Instance()->max_oil; CarObject car;
CarObject car; car.car_id = equip_meta->i->id();
car.car_id = equip_meta->i->id(); car.pos = loot_entity->GetPos();
car.pos = loot_entity->GetPos(); car_hash_[loot_entity->entity_uniid] = car;
car_hash_[loot_entity->entity_uniid] = car;
}
} }
} }
} }
@ -1488,18 +1489,17 @@ void Room::CreateLoots()
void Room::CreateDropObjs() void Room::CreateDropObjs()
{ {
if (buildings_) { for (auto& building : *buildings_) {
for (auto& building : *buildings_) { for (auto& obj : building->meta->i->dropobj()) {
for (auto& obj : building->meta->i->dropobj()) { CreateLoot(obj.id(),
CreateLoot(obj.id(), a8::Vec2
a8::Vec2( (
building->GetX() + obj.x() - building->meta->i->tilewidth() / 2.0, building->GetX() + obj.x() - building->meta->i->tilewidth() / 2.0,
building->GetY() + obj.y() - building->meta->i->tileheight() / 2.0 building->GetY() + obj.y() - building->meta->i->tileheight() / 2.0
), ),
1, 1,
1 1
); );
}
} }
} }
} }
@ -1605,7 +1605,9 @@ void Room::SecondRandPoint()
#endif #endif
for (auto& pair : accountid_hash_) { for (auto& pair : accountid_hash_) {
if (room_type_ == RT_MidBrid) { 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 #ifdef DEBUG