Fixed bug when bot is killed due to max game length violation while transmuting. Transmuting should now complete before game exits.

This commit is contained in:
Randi
2026-03-16 19:10:07 -04:00
parent 5f2149ed1e
commit d96eb2d34c
3 changed files with 9 additions and 1 deletions

View File

@@ -42,6 +42,7 @@ from run import Pindle, ShenkEld, Trav, Nihlathak, Arcane, Diablo, Vizier
from town import TownManager, A1, A2, A3, A4, A5, town_manager
from messages import Messenger
from threading import Lock
class Bot:
@@ -50,6 +51,7 @@ class Bot:
self._messenger = Messenger()
self._pather = Pather()
self._pickit = PickIt()
self._stash_mutex = Lock()
# Create Character
match Config().char["type"]:
@@ -379,12 +381,16 @@ class Bot:
# Stash stuff
if keep_items or stash_gold:
Logger.info("Stashing items")
self._curr_loc, result_items = self._town_manager.stash(self._curr_loc, items=items)
sell_items = any([item.sell for item in result_items]) if result_items else None
#Acquire mutex to prevent controller from killing thread during transmutes
self._stash_mutex.acquire()
Logger.info("Running transmutes")
self._transmute.run_transmutes(force=False)
common.close()
self._stash_mutex.release()
if not self._curr_loc:
return self.trigger_or_stop("end_game", failed=True)
self._picked_up_items = False

View File

@@ -55,8 +55,10 @@ class GameController:
self.game_stats.log_death(self.death_manager._last_death_screenshot)
elif did_chicken:
self.game_stats.log_chicken(self.health_manager._last_chicken_screenshot)
self.bot._stash_mutex.acquire() #Grab mutex to ensure stashing is not occuring
self.bot.stop()
kill_thread(self.bot_thread)
self.bot._stash_mutex.release()
# Try to recover from whatever situation we are and go back to hero selection
if max_consecutive_fails_reached:
msg = f"Consecutive fails {self.game_stats.get_consecutive_runs_failed()} >= Max {Config().general['max_consecutive_fails']}. Quitting botty."

View File

@@ -8,7 +8,7 @@ from utils.misc import wait
from ui_manager import wait_until_hidden, wait_until_visible, detect_screen_object, select_screen_object_match, ScreenObjects, list_visible_objects, is_visible
from inventory import common
from screen import convert_screen_to_monitor
from threading import Thread, Lock
from threading import Lock
exit_mutex = Lock()