From 2aa9ef9997bce5c9ea2dc386237f1f70b8ae3a27 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 1 Mar 2014 11:32:22 +0100 Subject: [PATCH] Fixed so bots cannot idle timeout. --- src/players/bots.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/players/bots.py b/src/players/bots.py index c5abd9e17a..205edb208a 100644 --- a/src/players/bots.py +++ b/src/players/bots.py @@ -12,7 +12,6 @@ from src.commands.cmdset import CmdSet from src.utils import search _IDLE_TIMEOUT = settings.IDLE_TIMEOUT -_IDLE_COMMAND = settings.IDLE_COMMAND _SESSIONS = None @@ -42,8 +41,18 @@ class BotStarter(Script): self.db.started = True def at_repeat(self): - "Called self.interval seconds to keep connection." - self.obj.dbobj.execute_cmd(_IDLE_COMMAND) + """ + Called self.interval seconds to keep connection. We cannot use + the IDLE command from inside the game since the system will + not catch it (commands executed from the server side usually + has no sessions). So we update the idle counter manually here + instead. This keeps the bot getting hit by IDLE_TIMEOUT. + """ + global _SESSIONS + if not _SESSIONS: + from src.server.sessionhandler import SESSIONS as _SESSIONS + for session in _SESSIONS.sessions_from_player(self.player): + session.update_session_counters(idle=True) def at_server_reload(self): """ @@ -66,6 +75,7 @@ class CmdBotListen(Command): """ key = "bot_data_in" def func(self): + "Relay to typeclass" self.obj.typeclass.execute_cmd(self.args.strip(), sessid=self.sessid) class BotCmdSet(CmdSet):