diff --git a/server/gameserver/incubator.cc b/server/gameserver/incubator.cc index 84d93a7c..c6509aab 100644 --- a/server/gameserver/incubator.cc +++ b/server/gameserver/incubator.cc @@ -671,52 +671,52 @@ void Incubator::StartNewBattleMode() if (!selected_player) { return; } - std::vector invisable_humans; - std::vector invisable_teammates; + auto invisable_humans = std::make_shared>(); + auto invisable_teammates = std::make_shared>(); room->xtimer.SetIntervalWpEx ( SERVER_FRAME_RATE * (3 + rand() % 2), - [this, selected_player, &invisable_humans, &invisable_teammates] (int event, const a8::Args* args) + [this, selected_player, invisable_humans, invisable_teammates] (int event, const a8::Args* args) { if (a8::TIMER_EXEC_EVENT == event) { if (room->IsGameOver()) { return; } - invisable_humans.clear(); - invisable_teammates.clear(); + invisable_humans->clear(); + invisable_teammates->clear(); room->TraverseAliveHumanList ( - [this, selected_player, &invisable_humans, &invisable_teammates] (Human* hum) -> bool + [this, selected_player, invisable_humans, invisable_teammates] (Human* hum) -> bool { if (hum == selected_player) { return true; } if (!CanSee(hum, selected_player)) { if (hum->GetTeam() == selected_player->GetTeam()) { - invisable_teammates.push_back(hum); + invisable_teammates->push_back(hum); } else { - invisable_humans.push_back(hum); + invisable_humans->push_back(hum); } } return true; }); - if (invisable_humans.size() > 0) { - std::shuffle(invisable_humans.begin(), - invisable_humans.end(), + if (invisable_humans->size() > 0) { + std::shuffle(invisable_humans->begin(), + invisable_humans->end(), std::default_random_engine(a8::XGetTickCount())); Human *killer = nullptr; - Human *target = invisable_humans.at(0); - for (size_t i = 0; i < invisable_humans.size(); ++i) { - if (invisable_humans.at(i)->GetTeam() != target->GetTeam()) { - killer = invisable_humans.at(i); + Human *target = invisable_humans->at(0); + for (size_t i = 0; i < invisable_humans->size(); ++i) { + if (invisable_humans->at(i)->GetTeam() != target->GetTeam()) { + killer = invisable_humans->at(i); break; } } - if (!killer && !invisable_teammates.empty()) { - std::shuffle(invisable_teammates.begin(), - invisable_teammates.end(), + if (!killer && !invisable_teammates->empty()) { + std::shuffle(invisable_teammates->begin(), + invisable_teammates->end(), std::default_random_engine(a8::XGetTickCount())); - killer = invisable_teammates.at(0); + killer = invisable_teammates->at(0); } if (killer) { target->BeKill(killer->GetUniId(),