From bd4a6ad24a60b0f151005bc9111069930fabf9db Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 1 Jul 2020 00:13:33 +0100 Subject: [PATCH] Spawn players next to each other in rooms This is an experimental fix for a bug in the vanilla client where players would appear invisible and their actions would not be relayed to the rest of the room. --- houdini/data/room.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/houdini/data/room.py b/houdini/data/room.py index 8d5d40a..1d23e89 100644 --- a/houdini/data/room.py +++ b/houdini/data/room.py @@ -1,3 +1,5 @@ +import random + from houdini.data import AbstractDataCollection, db @@ -32,6 +34,12 @@ class RoomMixin: if p.character: self.penguins_by_character_id[p.character] = p + player_positions = {(penguin.x, penguin.y) for penguin in self.penguins_by_id.values()} + free_positions = [(tx, ty) for tx in range(p.x - self.max_users // 4, p.x + self.max_users // 4) + for ty in range(p.y - self.max_users // 4, p.y + self.max_users // 4) + if (tx, ty) not in player_positions] + + p.x, p.y = random.choice(free_positions) p.room = self async def remove_penguin(self, p):