mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 18:01:26 +08:00
feat.增加关卡掉落识别的时间戳检查,解决万一卡住了会连续识别并上传的问题
This commit is contained in:
@@ -21,6 +21,12 @@ bool asst::StageDropsTaskPlugin::verify(AsstMsg msg, const json::value& details)
|
||||
}
|
||||
|
||||
if (details.at("details").at("task").as_string() == "EndOfAction") {
|
||||
int64_t pre_start_time = Status.get("LastStartButton2");
|
||||
int64_t pre_recognize_time = Status.get("LastRecognizeDrops");
|
||||
if (pre_start_time + RecognizationTimeOffset == pre_recognize_time) {
|
||||
Log.info("Recognization time too close, pass", pre_start_time, pre_recognize_time);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -68,6 +74,9 @@ bool asst::StageDropsTaskPlugin::recognize_drops()
|
||||
std::string res = Resrc.penguin().recognize(image);
|
||||
Log.trace("Results of penguin recognition:\n", res);
|
||||
m_cur_drops = json::parse(res).value();
|
||||
|
||||
Status.set("LastRecognizeDrops", Status.get("LastStartButton2") + RecognizationTimeOffset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -112,10 +121,10 @@ void asst::StageDropsTaskPlugin::set_startbutton_delay()
|
||||
LogTraceFunction;
|
||||
|
||||
if (!m_startbutton_delay_setted) {
|
||||
int64_t start_times = Status.get("LastStartButton2");
|
||||
int64_t pre_start_time = Status.get("LastStartButton2");
|
||||
|
||||
if (start_times > 0) {
|
||||
int64_t duration = time(nullptr) - start_times;
|
||||
if (pre_start_time > 0) {
|
||||
int64_t duration = time(nullptr) - pre_start_time;
|
||||
int elapsed = Task.get("EndOfAction")->pre_delay + Task.get("PRTS")->rear_delay;
|
||||
int64_t delay = duration * 1000 - elapsed;
|
||||
m_cast_ptr->set_rear_delay("StartButton2", static_cast<int>(delay));
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace asst
|
||||
void set_startbutton_delay();
|
||||
void upload_to_penguin();
|
||||
|
||||
static constexpr int64_t RecognizationTimeOffset = 20;
|
||||
std::unordered_map<std::string, int> m_drop_stats;
|
||||
json::value m_cur_drops;
|
||||
bool m_startbutton_delay_setted = false;
|
||||
|
||||
Reference in New Issue
Block a user