internal gamePlayer(virtualUser User, int roomUID, Game Game) { this.User = User; this.roomUID = roomUID; this.Game = Game; this.teamID = -1; }
/// <summary> /// Adds a virtualUser class together with the userID to the userManager. Login ticket will be nulled and previous logged in instances of this user will be dropped. /// </summary> /// <param name="userID">The ID of the user to add.</param> /// <param name="User">The virtualUser class of this user.</param> public static void addUser(int userID, virtualUser User) { if (_Users.ContainsKey(userID)) { virtualUser oldUser = ((virtualUser)_Users[userID]); oldUser.Disconnect(); if (_Users.ContainsKey(userID)) _Users.Remove(userID); } using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.AddParamWithValue("name", User._Username); if (User.connectionRemoteIP == dbClient.getString("SELECT ipaddress_last FROM users WHERE name = @name LIMIT 1")) { _Users.Add(userID, User); dbClient.runQuery("UPDATE users SET ticket_sso = NULL WHERE id = '" + userID + "' LIMIT 1"); Out.WriteLine("Username " + User._Username + " logged in. [ " + userID + " ]"); } else { User.Disconnect(1000); User.sendData("BK" + "Invalid Session Ticket, please use the SSO Fix!"); } if (_Users.Count > dbClient.getInt("SELECT onlinecount_peak FROM system")) { _peakUserCount = _Users.Count; } } }
/// <summary> /// Adds a virtualUser class together with the userID to the userManager. Login ticket will be nulled and previous logged in instances of this user will be dropped. /// </summary> /// <param name="userID">The ID of the user to add.</param> /// <param name="User">The virtualUser class of this user.</param> public static void addUser(int userID, virtualUser User) { if (_Users.ContainsKey(userID)) { virtualUser oldUser = ((virtualUser)_Users[userID]); oldUser.Disconnect(); if(_Users.ContainsKey(userID)) _Users.Remove(userID); } _Users.Add(userID,User); DB.runQuery("UPDATE users SET ticket_sso = NULL WHERE id = '" + userID + "' LIMIT 1"); Out.WriteLine("User " + userID + " logged in. [" + User._Username + "]",Out.logFlags.BelowStandardAction); if(_Users.Count > _peakUserCount) _peakUserCount = _Users.Count; }
private static void connectionRequest(IAsyncResult iAr) { try { int connectionID = 0; for (int i = 1; i < _maxConnections; i++) { if (_activeConnections.Contains(i) == false) { connectionID = i; break; } } if (connectionID > 0) { Socket connectionSocket = ((Socket)iAr.AsyncState).EndAccept(iAr); Out.WriteLine("Accepted connection [" + connectionID + "] from " + connectionSocket.RemoteEndPoint.ToString().Split(':')[0]); _activeConnections.Add(connectionID); _acceptedConnections++; virtualUser newUser = new virtualUser(connectionID, connectionSocket); } } catch { } socketHandler.BeginAccept(new AsyncCallback(connectionRequest), socketHandler); }
internal void addUser(virtualUser User) { if (User._teleporterID == 0 && (User._ROOMACCESS_PRIMARY_OK == false || User._ROOMACCESS_SECONDARY_OK == false)) return; User.statusManager = new virtualRoomUserStatusManager(User.userID, this.roomID); User.roomUser = new virtualRoomUser(User.userID, roomID, getFreeRoomIdentifier(), User, User.statusManager); if (User._teleporterID == 0) { User.roomUser.X = this.doorX; User.roomUser.Y = this.doorY; User.roomUser.Z1 = this.doorZ; User.roomUser.Z2 = this.doorZ; User.roomUser.H = this.doorH; } else { floorItem Teleporter = floorItemManager.getItem(User._teleporterID); User.roomUser.X = Teleporter.X; User.roomUser.Y = Teleporter.Y; User.roomUser.H = Teleporter.H; User.roomUser.Z1 = Teleporter.Z; User.roomUser.Z2 = Teleporter.Z; User._teleporterID = 0; sendData(@"A\" + Teleporter.ID + "/" + User._Username + "/" + Teleporter.Sprite); } User.roomUser.goalX = -1; _Users.Add(User.roomUser.roomUID, User.roomUser); if (this.isPublicroom == false) { if (User._hasRights) if (User._isOwner == false) { User.statusManager.addStatus("flatctrl", "onlyfurniture"); } if (User._isOwner) User.statusManager.addStatus("flatctrl", "useradmin"); using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { User.roomUser.hasVoted = dbClient.findsResult("SELECT userid FROM room_votes WHERE userid = '" + User.userID + "' AND roomid = '" + this.roomID + "'"); } } else { if (this.hasSwimmingPool) // This room has a swimming pool { using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { User.roomUser.swimOutfit = dbClient.getString("SELECT figure_swim FROM users WHERE id = '" + User.userID + "'"); } } if (this.Lobby != null) // Game lobby here { using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { User.roomUser.gamePoints = dbClient.getInt("SELECT " + Lobby.Type + "_totalpoints FROM users WHERE id = '" + User.userID + "'"); } sendData("Cz" + "I" + Encoding.encodeVL64(User.roomUser.roomUID) + User.roomUser.gamePoints + Convert.ToChar(2) + rankManager.getGameRankTitle(Lobby.isBattleBall, User.roomUser.gamePoints) + Convert.ToChar(2)); } } sendData(@"@\" + User.roomUser.detailsString); if (User._groupID > 0 && _activeGroups.Contains(User._groupID) == false) { string groupBadge; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { groupBadge = dbClient.getString("SELECT badge FROM groups_details WHERE id = '" + User._groupID + "'"); } sendData("Du" + "I" + Encoding.encodeVL64(User._groupID) + groupBadge + Convert.ToChar(2)); _activeGroups.Add(User._groupID); } roomManager.updateRoomVisitorCount(this.roomID, this._Users.Count); }
/// <summary> /// Initializes a virtual room user. /// </summary> /// <param name="userID">The database ID of the virtual user of this room user object.</param> /// <param name="roomID">The database ID of the room where the room user is in.</param> /// <param name="roomUID">The ID that identifies the room user in the virtual room.</param> /// <param name="User">The parent vittual user of this room user.</param> /// <param name="statusManager">The status manager of this room user.</param> internal virtualRoomUser(int userID, int roomID, int roomUID, virtualUser User, virtualRoomUserStatusManager statusManager) { this.userID = userID; this.roomID = roomID; this.roomUID = roomUID; this.User = User; this.statusManager = statusManager; }
internal void addUser(virtualUser User) { if (User._teleporterID == 0 && (User._ROOMACCESS_PRIMARY_OK == false || User._ROOMACCESS_SECONDARY_OK == false)) return; User.statusManager = new virtualRoomUserStatusManager(User.userID, this.roomID); User.roomUser = new virtualRoomUser(User.userID, roomID, getFreeRoomIdentifier(), User, User.statusManager); if (User._teleporterID == 0) { User.roomUser.X = this.doorX; User.roomUser.Y = this.doorY; User.roomUser.Z1 = this.doorZ; User.roomUser.Z2 = this.doorZ; User.roomUser.H = this.doorH; } else { floorItem Teleporter = floorItemManager.getItem(User._teleporterID); User.roomUser.X = Teleporter.X; User.roomUser.Y = Teleporter.Y; User.roomUser.H = Teleporter.H; User.roomUser.Z1 = Teleporter.Z; User.roomUser.Z2 = Teleporter.Z; User._teleporterID = 0; sendData(@"A\" + Teleporter.ID + "/" + User._Username + "/" + Teleporter.Sprite); } User.roomUser.goalX = -1; _Users.Add(User.roomUser.roomUID, User.roomUser); if (this.isPublicroom == false) { if (User._hasRights) if (User._isOwner == false) { User.statusManager.addStatus("flatctrl", "onlyfurniture"); } if (User._isOwner) User.statusManager.addStatus("flatctrl", "useradmin"); User.roomUser.hasVoted = DB.checkExists("SELECT userid FROM room_votes WHERE userid = '" + User.userID + "' AND roomid = '" + this.roomID + "'"); } else if (this.hasSwimmingPool) User.roomUser.SwimOutfit = DB.runRead("SELECT figure_swim FROM users WHERE id = '" + User.userID + "'"); sendData(@"@\" + User.roomUser.detailsString); if (User._groupID > 0 && _activeGroups.Contains(User._groupID) == false) { string groupBadge = DB.runRead("SELECT badge FROM groups_details WHERE id = '" + User._groupID + "'"); sendData("Du" + "I" + Encoding.encodeVL64(User._groupID) + groupBadge + Convert.ToChar(2)); _activeGroups.Add(User._groupID); } roomManager.updateRoomVisitorCount(this.roomID, this._Users.Count); }
private static void connectionRequest(IAsyncResult iAr) { //lock (connObj) //{ try { int connectionID = 0; for (int i = 1; i < _maxConnections; i++) { if (_activeConnections.Contains(i) == false) { connectionID = i; break; } } if (connectionID > 0) { Socket connectionSocket = ((Socket)iAr.AsyncState).EndAccept(iAr); int ipCount = 0; for (int i = 1; i < (_maxConnections * 4); i++) { if (_activeIPs[i].StartsWith(connectionSocket.RemoteEndPoint.ToString().Split(':')[0] + ":")) { ipCount = ipCount + 1; } } if (ipCount >= 4) { Out.WriteLine("Rejected connection [x" + (ipCount + 1) + "] [" + connectionID + "] from " + connectionSocket.RemoteEndPoint.ToString().Split(':')[0]); connectionSocket.BeginDisconnect(true, new AsyncCallback(DisconnectOK), connectionSocket); } else { Out.WriteLine("Accepted connection [x" + (ipCount + 1) + "] [" + connectionID + "] from " + connectionSocket.RemoteEndPoint.ToString().Split(':')[0]); _activeConnections.Add(connectionID); _activeIPs[connectionID] = connectionSocket.RemoteEndPoint.ToString(); _acceptedConnections++; virtualUser newUser = new virtualUser(connectionID, connectionSocket); } } } catch { } socketHandler.BeginAccept(new AsyncCallback(connectionRequest), socketHandler); //} }