public static void AddClient(BaseRoom room, Client client)
        {
            if (room.GetRoomInfo().players == 0 && room.noHost)
            {
                room.ForceTransferHost(client.playerInfo);
            }

            room.roomClients.Add(client);
        }
        public static bool ClientJoined(Client client, uint roomId, string password)
        {
#if DEBUG
            Logger.Instance.Log($"Client joining room {roomId}");
#endif

            NetOutgoingMessage outMsg = HubListener.ListenerServer.CreateMessage();

            if (rooms.Any(x => x.roomId == roomId))
            {
                BaseRoom room     = rooms.First(x => x.roomId == roomId);
                RoomInfo roomInfo = room.GetRoomInfo();

                if (roomInfo.players < roomInfo.maxPlayers || roomInfo.maxPlayers == 0)
                {
                    if (roomInfo.usePassword)
                    {
                        if (room.roomSettings.Password == password)
                        {
                            outMsg.Write((byte)CommandType.JoinRoom);
                            outMsg.Write((byte)JoinResult.Success);

                            client.playerConnection.SendMessage(outMsg, NetDeliveryMethod.ReliableOrdered, 0);
                            Program.networkBytesOutNow += outMsg.LengthBytes;

                            client.joinedRoomID = room.roomId;
                            if (room.roomClients.Any(x => x.playerInfo == client.playerInfo))
                            {
                                Client loggedIn = room.roomClients.Find(x => x.playerInfo == client.playerInfo);
                                if (loggedIn.playerConnection != client.playerConnection)
                                {
                                    loggedIn.KickClient("You logged in from another location");
                                }
                                else
                                {
                                    room.roomClients.Remove(loggedIn);
                                }
                            }
                            AddClient(room, client);
                            return(true);
                        }
                        else
                        {
                            outMsg.Write((byte)CommandType.JoinRoom);
                            outMsg.Write((byte)JoinResult.IncorrectPassword);

                            client.playerConnection.SendMessage(outMsg, NetDeliveryMethod.ReliableOrdered, 0);
                            Program.networkBytesOutNow += outMsg.LengthBytes;
                            return(false);
                        }
                    }
                    else
                    {
                        outMsg.Write((byte)CommandType.JoinRoom);
                        outMsg.Write((byte)JoinResult.Success);

                        client.playerConnection.SendMessage(outMsg, NetDeliveryMethod.ReliableOrdered, 0);
                        Program.networkBytesOutNow += outMsg.LengthBytes;

                        client.joinedRoomID = room.roomId;
                        if (room.roomClients.Any(x => x.playerInfo == client.playerInfo))
                        {
                            Client loggedIn = room.roomClients.Find(x => x.playerInfo.Equals(client.playerInfo));
                            if (!loggedIn.playerConnection.Equals(client.playerConnection))
                            {
                                loggedIn.KickClient("You logged in from another location");
                            }
                            else
                            {
                                room.roomClients.Remove(loggedIn);
                            }
                        }
                        AddClient(room, client);
                        return(true);
                    }
                }
                else
                {
                    outMsg.Write((byte)CommandType.JoinRoom);
                    outMsg.Write((byte)JoinResult.TooMuchPlayers);

                    client.playerConnection.SendMessage(outMsg, NetDeliveryMethod.ReliableOrdered, 0);
                    Program.networkBytesOutNow += outMsg.LengthBytes;
                    return(false);
                }
            }
            else
            {
                outMsg.Write((byte)CommandType.JoinRoom);
                outMsg.Write((byte)JoinResult.RoomNotFound);

                client.playerConnection.SendMessage(outMsg, NetDeliveryMethod.ReliableOrdered, 0);
                Program.networkBytesOutNow += outMsg.LengthBytes;
                return(false);
            }
        }