mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
perf: 移除SSReopen中掉落物品集的指针
This commit is contained in:
@@ -177,11 +177,12 @@ bool asst::SideStoryReopenTask::fight(bool use_medicine, bool use_stone)
|
||||
.set_times_limit("StageQueue@StartButton2", 1);
|
||||
|
||||
auto plugin = fight_task.register_plugin<StageQueueMissionCompletedPlugin>();
|
||||
plugin->set_drop_stats(&m_drop_stats);
|
||||
plugin->set_drop_stats(std::move(m_drop_stats));
|
||||
plugin->set_enable_penguid(m_enable_penguid);
|
||||
plugin->set_server(m_server);
|
||||
plugin->set_penguin_id(m_penguin_id);
|
||||
auto result = fight_task.run();
|
||||
m_drop_stats = plugin->get_drop_stats();
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,9 +25,14 @@ bool asst::StageQueueMissionCompletedPlugin::verify(AsstMsg msg, const json::val
|
||||
}
|
||||
}
|
||||
|
||||
void asst::StageQueueMissionCompletedPlugin::set_drop_stats(std::unordered_map<std::string, int>* drop_stats)
|
||||
void asst::StageQueueMissionCompletedPlugin::set_drop_stats(std::unordered_map<std::string, int> drop_stats)
|
||||
{
|
||||
m_drop_stats = drop_stats;
|
||||
m_drop_stats = std::move(drop_stats);
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, int> asst::StageQueueMissionCompletedPlugin::get_drop_stats()
|
||||
{
|
||||
return m_drop_stats;
|
||||
}
|
||||
|
||||
bool asst::StageQueueMissionCompletedPlugin::_run()
|
||||
@@ -76,15 +81,10 @@ void asst::StageQueueMissionCompletedPlugin::drop_info_callback(std::string stag
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
if (m_drop_stats == nullptr) {
|
||||
Log.error(__FUNCTION__, "drop stats is not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, int> cur_drops_count;
|
||||
std::vector<json::value> drops_vec;
|
||||
for (const auto& drop : analyzer.get_drops()) {
|
||||
(*m_drop_stats)[drop.item_id] += drop.quantity;
|
||||
m_drop_stats[drop.item_id] += drop.quantity;
|
||||
cur_drops_count.emplace(drop.item_id, drop.quantity);
|
||||
json::value info;
|
||||
info["itemId"] = drop.item_id;
|
||||
@@ -95,7 +95,7 @@ void asst::StageQueueMissionCompletedPlugin::drop_info_callback(std::string stag
|
||||
}
|
||||
|
||||
std::vector<json::value> stats_vec;
|
||||
for (auto&& [id, count] : *m_drop_stats) {
|
||||
for (auto&& [id, count] : m_drop_stats) {
|
||||
json::value info;
|
||||
info["itemId"] = id;
|
||||
const std::string& name = ItemData.get_item_name(id);
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace asst
|
||||
using AbstractTaskPlugin::AbstractTaskPlugin;
|
||||
virtual ~StageQueueMissionCompletedPlugin() override = default;
|
||||
virtual bool verify(AsstMsg msg, const json::value& details) const override;
|
||||
void set_drop_stats(std::unordered_map<std::string, int>* m_drop_stats);
|
||||
void set_drop_stats(std::unordered_map<std::string, int> m_drop_stats);
|
||||
std::unordered_map<std::string, int> get_drop_stats();
|
||||
|
||||
bool set_enable_penguid(bool enable);
|
||||
bool set_penguin_id(std::string id);
|
||||
@@ -34,7 +35,7 @@ namespace asst
|
||||
void upload_to_penguin(std::string stage_code, int stars);
|
||||
static void report_penguin_callback(AsstMsg msg, const json::value& detail, AbstractTask* task_ptr);
|
||||
|
||||
std::unordered_map<std::string, int>* m_drop_stats = nullptr;
|
||||
std::unordered_map<std::string, int> m_drop_stats;
|
||||
json::value m_cur_info_json;
|
||||
// 企鹅物流上报用
|
||||
bool m_enable_penguid = false;
|
||||
|
||||
@@ -1106,10 +1106,10 @@ namespace MaaWpfGui.Main
|
||||
break;
|
||||
|
||||
case "StageQueueUnableToAgent":
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("StageQueue") + $"{subTaskDetails["stage_code"]}" + LocalizationHelper.GetString("UnableToAgent"), UiLogColor.Info);
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("StageQueue") + $" {subTaskDetails["stage_code"]} " + LocalizationHelper.GetString("UnableToAgent"), UiLogColor.Info);
|
||||
break;
|
||||
case "StageQueueMissionCompleted":
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("StageQueue") + $"{subTaskDetails["stage_code"]} {subTaskDetails["stars"]}★", UiLogColor.Info);
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("StageQueue") + $" {subTaskDetails["stage_code"]} {subTaskDetails["stars"]}★", UiLogColor.Info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user