fix: all_melee_retreat 在使用迭代器遍历的同时删除元素导致SEGV

This commit is contained in:
Congcong Cai
2023-02-11 00:26:04 +08:00
parent c3703f6851
commit 913bf4892c

View File

@@ -3,6 +3,7 @@
#include "Utils/Ranges.hpp"
#include <chrono>
#include <future>
#include <vector>
#include "Utils/NoWarningCV.h"
@@ -596,13 +597,17 @@ std::optional<asst::battle::DeploymentOper> asst::RoguelikeBattleTaskPlugin::cal
void asst::RoguelikeBattleTaskPlugin::all_melee_retreat()
{
std::vector<Point const*> retreat_locs{};
for (const auto& loc : m_used_tiles | views::keys) {
auto& tile_info = m_normal_tile_info[loc];
auto& type = tile_info.buildable;
if (type == battle::LocationType::Melee || type == battle::LocationType::All) {
retreat_oper(loc);
retreat_locs.push_back(&loc);
}
}
for (const auto&loc: retreat_locs) {
retreat_oper(*loc);
}
}
void asst::RoguelikeBattleTaskPlugin::clear()