mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 10:57:45 +08:00
perf. use static_cast
This commit is contained in:
@@ -33,7 +33,7 @@ Assistant::Assistant(AsstApiCallback callback, void* callback_arg)
|
||||
LogTraceFunction;
|
||||
|
||||
m_status = std::make_shared<RuntimeStatus>();
|
||||
m_ctrler = std::make_shared<Controller>(task_callback, (void*)this);
|
||||
m_ctrler = std::make_shared<Controller>(task_callback, static_cast<void*>(this));
|
||||
|
||||
m_working_thread = std::thread(&Assistant::working_proc, this);
|
||||
m_msg_thread = std::thread(&Assistant::msg_proc, this);
|
||||
@@ -85,31 +85,31 @@ asst::Assistant::TaskId asst::Assistant::append_task(const std::string& type, co
|
||||
std::shared_ptr<PackageTask> ptr = nullptr;
|
||||
|
||||
if (type == FightTask::TaskType) {
|
||||
ptr = std::make_shared<FightTask>(task_callback, (void*)this);
|
||||
ptr = std::make_shared<FightTask>(task_callback, static_cast<void*>(this));
|
||||
}
|
||||
else if (type == StartUpTask::TaskType) {
|
||||
ptr = std::make_shared<StartUpTask>(task_callback, (void*)this);
|
||||
ptr = std::make_shared<StartUpTask>(task_callback, static_cast<void*>(this));
|
||||
}
|
||||
else if (type == AwardTask::TaskType) {
|
||||
ptr = std::make_shared<AwardTask>(task_callback, (void*)this);
|
||||
ptr = std::make_shared<AwardTask>(task_callback, static_cast<void*>(this));
|
||||
}
|
||||
else if (type == VisitTask::TaskType) {
|
||||
ptr = std::make_shared<VisitTask>(task_callback, (void*)this);
|
||||
ptr = std::make_shared<VisitTask>(task_callback, static_cast<void*>(this));
|
||||
}
|
||||
else if (type == MallTask::TaskType) {
|
||||
ptr = std::make_shared<MallTask>(task_callback, (void*)this);
|
||||
ptr = std::make_shared<MallTask>(task_callback, static_cast<void*>(this));
|
||||
}
|
||||
else if (type == InfrastTask::TaskType) {
|
||||
ptr = std::make_shared<InfrastTask>(task_callback, (void*)this);
|
||||
ptr = std::make_shared<InfrastTask>(task_callback, static_cast<void*>(this));
|
||||
}
|
||||
else if (type == RecruitTask::TaskType) {
|
||||
ptr = std::make_shared<RecruitTask>(task_callback, (void*)this);
|
||||
ptr = std::make_shared<RecruitTask>(task_callback, static_cast<void*>(this));
|
||||
}
|
||||
else if (type == RoguelikeTask::TaskType) {
|
||||
ptr = std::make_shared<RoguelikeTask>(task_callback, (void*)this);
|
||||
ptr = std::make_shared<RoguelikeTask>(task_callback, static_cast<void*>(this));
|
||||
}
|
||||
else if (type == CopilotTask::TaskType) {
|
||||
ptr = std::make_shared<CopilotTask>(task_callback, (void*)this);
|
||||
ptr = std::make_shared<CopilotTask>(task_callback, static_cast<void*>(this));
|
||||
}
|
||||
#ifdef ASST_DEBUG
|
||||
else if (type == DebugTask::TaskType) {
|
||||
@@ -293,7 +293,7 @@ void Assistant::msg_proc()
|
||||
|
||||
void Assistant::task_callback(AsstMsg msg, const json::value& detail, void* custom_arg)
|
||||
{
|
||||
Assistant* p_this = (Assistant*)custom_arg;
|
||||
Assistant* p_this = static_cast<Assistant*>(custom_arg);
|
||||
json::value more_detail = detail;
|
||||
more_detail["uuid"] = p_this->m_uuid;
|
||||
|
||||
|
||||
@@ -781,7 +781,7 @@ int asst::Controller::swipe_without_scale(const Point& p1, const Point& p2, int
|
||||
extra_cmd = utils::string_replace_all(extra_cmd, "[y1]", std::to_string(p2.y));
|
||||
int end_x = 0, end_y = 0;
|
||||
if (p2.x != p1.x) {
|
||||
double k = (double)(p2.y - p1.y) / (p2.x - p1.x);
|
||||
double k = static_cast<double>(p2.y - p1.y) / (p2.x - p1.x);
|
||||
double temp = extra_swipe_dist / std::sqrt(1 + k * k);
|
||||
end_x = p2.x + static_cast<int>((p2.x > p1.x ? -1.0 : 1.0) * temp);
|
||||
end_y = p2.y + static_cast<int>((p2.y > p1.y ? -1.0 : 1.0) * std::fabs(k) * temp);
|
||||
|
||||
@@ -89,10 +89,10 @@ std::vector<asst::TextRect> asst::OcrPack::recognize(const cv::Mat image, const
|
||||
int* box = m_boxes_buffer + i * 8;
|
||||
int x_collect[4] = { *(box + 0), *(box + 2), *(box + 4), *(box + 6) };
|
||||
int y_collect[4] = { *(box + 1), *(box + 3), *(box + 5), *(box + 7) };
|
||||
int left = int(*std::min_element(x_collect, x_collect + 4));
|
||||
int right = int(*std::max_element(x_collect, x_collect + 4));
|
||||
int top = int(*std::min_element(y_collect, y_collect + 4));
|
||||
int bottom = int(*std::max_element(y_collect, y_collect + 4));
|
||||
int left = static_cast<int>(*std::min_element(x_collect, x_collect + 4));
|
||||
int right = static_cast<int>(*std::max_element(x_collect, x_collect + 4));
|
||||
int top = static_cast<int>(*std::min_element(y_collect, y_collect + 4));
|
||||
int bottom = static_cast<int>(*std::max_element(y_collect, y_collect + 4));
|
||||
rect = Rect(left, top, right - left, bottom - top);
|
||||
}
|
||||
std::string text(*(m_strs_buffer + i));
|
||||
|
||||
Reference in New Issue
Block a user