From a06c48dca5e8b5628b142a76e8ce8e477e641fbc Mon Sep 17 00:00:00 2001 From: SantaSpeen Date: Thu, 17 Aug 2023 21:25:47 +0300 Subject: [PATCH] Add _synced #1 --- src/core/Client.py | 6 ++++++ src/core/Client.pyi | 3 +++ src/core/core.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/Client.py b/src/core/Client.py index 819336f..ac276f1 100644 --- a/src/core/Client.py +++ b/src/core/Client.py @@ -32,6 +32,7 @@ def __init__(self, reader, writer, core): self.nick = None self.roles = None self._guest = True + self._synced = False self._ready = False self._identifiers = [] self._cars = [None] * 21 # Max 20 cars per player + 1 snowman @@ -72,6 +73,10 @@ def key(self): def guest(self): return self._guest + @property + def synced(self): + return self._synced + @property def ready(self): return self._ready @@ -706,6 +711,7 @@ async def _looper(self): tasks = self.__tasks recv = asyncio.create_task(self._recv()) tasks.append(recv) + self._synced = True while self.__alive: if len(self.__packets_queue) > 0: for index, packet in enumerate(self.__packets_queue): diff --git a/src/core/Client.pyi b/src/core/Client.pyi index efaacd3..0e1c6c0 100644 --- a/src/core/Client.pyi +++ b/src/core/Client.pyi @@ -32,6 +32,7 @@ class Client: self.roles: str = None self._guest = True self.__alive = True + self._synced = False self._ready = False self._focus_car = -1 self._identifiers = [] @@ -55,6 +56,8 @@ class Client: @property def guest(self) -> bool: ... @property + def synced(self) -> bool: ... + @property def ready(self) -> bool: ... @property def identifiers(self) -> list: ... diff --git a/src/core/core.py b/src/core/core.py index 1faf756..efa5659 100644 --- a/src/core/core.py +++ b/src/core/core.py @@ -57,7 +57,7 @@ def get_client(self, cid=None, nick=None): return None if cid is not None: if cid == -1: - return [i for i in self.clients if i is not None] + return [i for i in self.clients if i is not None and i.synced] return self.clients_by_id.get(cid) if nick: return self.clients_by_nick.get(nick)