fix(runtime): High cpu usage in idle cause of while loop

This commit is contained in:
aeon0
2021-11-06 15:11:23 +01:00
parent 06b0d4fb27
commit 01bdc022ec
3 changed files with 8 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ from utils.remove_mouse_flags import remove_mouse_flag
from utils.auto_settings import adjust_settings
import threading
from beautifultable import BeautifulTable
import time
def start_bot():
@@ -54,6 +55,7 @@ if __name__ == "__main__":
elif keyboard.is_pressed(config.general['color_checker_key']):
run_color_checker()
break
time.sleep(0.02)
remove_flags_thread.join()
print("Press Enter to exit ...")

View File

@@ -5,6 +5,7 @@ from typing import Tuple, Union, List
import numpy as np
from logger import Logger
import time
from config import Config
def load_template(path, scale_factor):
@@ -21,6 +22,7 @@ class TemplateFinder:
self.debug_last_score = -1.0
self._screen = screen
self._scale_factor = scale_factor
self._config = Config()
self._templates = {
# Templates for node in A5 Town
"A5_TOWN_0": [load_template("assets/templates/a5_town/a5_town_0.png", self._scale_factor), self._scale_factor],

View File

@@ -186,7 +186,7 @@ class UiManager():
if x_range[0] < pos[0] < x_range[1]:
x, y = self._screen.convert_screen_to_monitor((self._config.ui_pos["hell_x"], self._config.ui_pos["hell_y"]))
Logger.debug("Found Hell Btn -> clicking it")
custom_mouse.move(x, y, duration=(random.random() * 0.2 + 0.5), randomize=5)
custom_mouse.move(x, y, duration=(random.random() * 0.2 + 1.0), randomize=5)
mouse.click(button="left")
else:
Logger.debug("Sanity position check on hell btn failed")
@@ -198,7 +198,7 @@ class UiManager():
if server_issue:
Logger.warning("Server connection issue. waiting 20s")
x, y = self._screen.convert_screen_to_monitor((self._config.ui_pos["issue_occured_ok_x"], self._config.ui_pos["issue_occured_ok_y"]))
custom_mouse.move(x, y, duration=(random.random() * 0.4 + 0.5), randomize=5)
custom_mouse.move(x, y, duration=(random.random() * 0.4 + 1.0), randomize=5)
mouse.click(button="left")
wait(1, 2)
keyboard.send("esc")
@@ -347,6 +347,7 @@ if __name__ == "__main__":
screen = Screen(config.general["monitor"])
template_finder = TemplateFinder(screen)
ui_manager = UiManager(screen, template_finder)
ui_manager.stash_all_items(6)
ui_manager.start_hell_game()
# ui_manager.stash_all_items(6)
# ui_manager.use_wp(4, 1)
# ui_manager.fill_up_belt_from_inventory(10)