/// <summary> /// Initializes a 'SnowStorm' game. /// </summary> /// <param name="Lobby">The gameLobby object of the lobby where this game is hosted in.</param> /// <param name="ID">The ID of this game.</param> /// <param name="Name">The display name of this game.</param> /// <param name="mapID">The ID of the map that is played with this game.</param> /// <param name="teamAmount">The amount of teams that is used with the game.</param> /// <param name="totalTime">The total amount of gametime in seconds.</param> /// <param name="Owner">The gamePlayer instance of the virtual user that has created this game.</param> internal Game(gameLobby Lobby, int ID, string Name, int mapID, int teamAmount, int totalTime, gamePlayer Owner) { this.Lobby = Lobby; this.ID = ID; this.Name = Name; this.mapID = mapID; this.Owner = Owner; this.totalTime = totalTime; this.leftTime = totalTime; this.isBattleBall = false; // Dimension teams this.Teams = new Collection <gamePlayer> [teamAmount]; for (int i = 0; i < teamAmount; i++) { Teams[i] = new Collection <gamePlayer>(); } }
/// <summary> /// Initializes a 'BattleBall' game. /// </summary> /// <param name="Lobby">The gameLobby object of the lobby where this game is hosted in.</param> /// <param name="ID">The ID of this game.</param> /// <param name="Name">The display name of this game.</param> /// <param name="mapID">The ID of the map that is played with this game.</param> /// <param name="teamAmount">The amount of teams that is used with the game.</param> /// <param name="enabledPowerups">The numbers of the enabled powerups for this game.</param> /// <param name="Owner">The gamePlayer instance of the virtual user that has created this game.</param> internal Game(gameLobby Lobby, int ID, string Name, int mapID, int teamAmount, int[] enabledPowerups, gamePlayer Owner) { this.Lobby = Lobby; this.ID = ID; this.Name = Name; this.mapID = mapID; this.Owner = Owner; this.enabledPowerups = enabledPowerups; this.totalTime = Config.Game_BattleBall_gameLength_Seconds; this.leftTime = Config.Game_BattleBall_gameLength_Seconds; this.isBattleBall = true; // Dimension teams this.Teams = new Collection <gamePlayer> [teamAmount]; for (int i = 0; i < teamAmount; i++) { Teams[i] = new Collection <gamePlayer>(); } }
internal void Crash() { try { #region User kicking try { foreach (virtualRoomUser roomUser in _Users.Values) { roomUser.User.sendData("@R"); roomUser.User.statusManager.Clear(); roomUser.User.statusManager = null; roomUser.User._roomID = 0; roomUser.User._inPublicroom = false; roomUser.User._ROOMACCESS_PRIMARY_OK = false; roomUser.User._ROOMACCESS_SECONDARY_OK = false; roomUser.User._isOwner = false; roomUser.User._hasRights = false; roomUser.User.Room = null; roomUser.User.roomUser = null; if (roomUser.User._tradePartnerRoomUID != -1) roomUser.User.abortTrade(); if (roomUser.User.gamePlayer != null && roomUser.User.gamePlayer.enteringGame == false) roomUser.User.leaveGame(); } } catch { } foreach (virtualBot roomBot in _Bots.Values) roomBot.Kill(); _Users.Clear(); _Bots.Clear(); #endregion _statusUpdates = null; if (isPublicroom == false) { floorItemManager.Clear(); wallItemManager.Clear(); } else { try { specialCastHandler.Abort(); } catch { } if (Lobby != null) Lobby.Clear(); Lobby = null; } roomManager.removeRoom(this.roomID); _statusHandler.Abort(); } catch { } }
/// <summary> /// Removes a room user from the virtual room. /// </summary> /// <param name="roomUID">The room identifier of the room user to remove.</param> /// <param name="sendKick">Specifies if the user must be kicked with the @R packet.</param> /// <param name="moderatorMessage">Specifies a moderator message [B!] packet to be used at kick.</param> internal void removeUser(int roomUID, bool sendKick, string moderatorMessage) { if (_Users.Contains(roomUID) == false) return; virtualRoomUser roomUser = (virtualRoomUser)_Users[roomUID]; if (sendKick) { roomUser.User.sendData("@R"); if (moderatorMessage != "") roomUser.User.sendData("@a" + moderatorMessage + Convert.ToChar(2) + "holo.cast.modkick"); } sqUNIT[roomUser.X, roomUser.Y] = false; roomUser.User.statusManager.Clear(); roomUser.User.statusManager = null; roomUser.User._roomID = 0; roomUser.User._inPublicroom = false; roomUser.User._ROOMACCESS_PRIMARY_OK = false; roomUser.User._ROOMACCESS_SECONDARY_OK = false; roomUser.User._isOwner = false; roomUser.User._hasRights = false; roomUser.User.Room = null; roomUser.User.roomUser = null; if (roomUser.User._tradePartnerRoomUID != -1) roomUser.User.abortTrade(); if (roomUser.User.gamePlayer != null && roomUser.User.gamePlayer.enteringGame == false) roomUser.User.leaveGame(); _Users.Remove(roomUID); if (_Users.Count > 0) // Still users in room { if (roomUser.User._groupID > 0) { bool removeBadge = true; try { foreach (virtualRoomUser rUser in _Users.Values) { if (rUser.roomUID != roomUser.roomUID && rUser.User._groupID == roomUser.User._groupID) { removeBadge = false; break; } } } catch { } if (removeBadge) _activeGroups.Remove(roomUser.User._groupID); } sendData("@]" + roomUID); roomManager.updateRoomVisitorCount(this.roomID, _Users.Count); } else { _Users.Clear(); _Bots.Clear(); _statusUpdates = null; if (isPublicroom == false) { floorItemManager.Clear(); wallItemManager.Clear(); } else { try { specialCastHandler.Abort(); } catch { } if (Lobby != null) Lobby.Clear(); Lobby = null; } roomManager.removeRoom(this.roomID); _statusHandler.Abort(); } }
/// <summary> /// Initializes a new instance of a virtual room. The room is prepared for usage. /// </summary> /// <param name="roomID"></param> /// <param name="isPublicroom"></param> public virtualRoom(int roomID, bool isPublicroom) { this.roomID = roomID; this.isPublicroom = isPublicroom; string roomModel; DataRow dRow; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { roomModel = dbClient.getString("SELECT model FROM rooms WHERE id = '" + roomID + "'"); dRow = dbClient.getRow("SELECT door_x,door_y,door_h,door_z,heightmap,publicroom_items, swimmingpool FROM room_modeldata WHERE model = '" + roomModel + "'"); //needs caching } doorX = Convert.ToInt32(dRow["door_x"]); doorY = Convert.ToInt32(dRow["door_y"]); doorH = Convert.ToInt32(dRow["door_h"]); doorZ = Convert.ToByte(dRow["door_z"]); _Heightmap = Convert.ToString(dRow["heightmap"]); string[] tmpHeightmap = _Heightmap.Split(Convert.ToChar(13)); int colX = tmpHeightmap[0].Length; int colY = tmpHeightmap.Length - 1; sqSTATE = new squareState[colX, colY]; sqFLOORHEIGHT = new byte[colX, colY]; sqITEMROT = new byte[colX, colY]; sqITEMHEIGHT = new double[colX, colY]; sqUNIT = new bool[colX, colY]; sqSTACK = new furnitureStack[colX, colY]; sqTRIGGER = new squareTrigger[colX, colY]; for (int y = 0; y < colY; y++) { for (int x = 0; x < colX; x++) { string _SQ = tmpHeightmap[y].Substring(x, 1).Trim().ToLower(); if (_SQ == "x") sqSTATE[x, y] = squareState.Blocked; else { sqSTATE[x, y] = squareState.Open; try { sqFLOORHEIGHT[x, y] = byte.Parse(_SQ); } catch { } } } } if (isPublicroom) { string[] Items = Convert.ToString(dRow["publicroom_items"]).Split("\n".ToCharArray()); for (int i = 0; i < Items.Length; i++) { string[] itemData = Items[i].Split(' '); int X = int.Parse(itemData[2]); int Y = int.Parse(itemData[3]); squareState sType = (squareState)int.Parse(itemData[6]); sqSTATE[X, Y] = sType; if (sType == squareState.Seat) { sqITEMROT[X, Y] = byte.Parse(itemData[5]); sqITEMHEIGHT[X, Y] = 1.0; } _publicroomItems += itemData[0] + " " + itemData[1] + " " + itemData[2] + " " + itemData[3] + " " + itemData[4] + " " + itemData[5] + Convert.ToChar(13); } DataTable dTable; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dTable = dbClient.getTable("SELECT object,x,y,goalx,goaly,stepx,stepy,roomid,state FROM room_modeldata_triggers WHERE model = '" + roomModel + "'"); } foreach (DataRow dbRow in dTable.Rows) { sqTRIGGER[Convert.ToInt32(dbRow["x"]), Convert.ToInt32(dbRow["y"])] = new squareTrigger(Convert.ToString(dbRow["object"]), Convert.ToInt32(dbRow["goalx"]), Convert.ToInt32(dbRow["goaly"]), Convert.ToInt32(dbRow["stepx"]), Convert.ToInt32(dbRow["stepy"]), (Convert.ToInt32(dbRow["state"]) == 1), Convert.ToInt32(dbRow["roomid"])); } bool result = false; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { result = dbClient.findsResult("SELECT specialcast_interval FROM room_modeldata WHERE model = '" + roomModel + "' AND specialcast_interval > 0"); } if (result) { specialCastHandler = new Thread(new ParameterizedThreadStart(handleSpecialCasts)); specialCastHandler.Priority = ThreadPriority.Lowest; specialCastHandler.Start(roomModel); } using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { int swimmingPool; hasSwimmingPool = (int.TryParse((Convert.ToString(dRow["swimmingpool"])), out swimmingPool)); result = dbClient.findsResult("SELECT id FROM games_lobbies WHERE id = '" + roomID + "'"); } if (result) { using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dRow = dbClient.getRow("SELECT type,rank FROM games_lobbies WHERE id = '" + roomID + "'"); } this.Lobby = new gameLobby(this, (Convert.ToString(dRow["type"]) == "bb"), Convert.ToString(dRow["rank"])); } } else { floorItemManager = new FloorItemManager(this); wallItemManager = new WallItemManager(this); DataTable dTable; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dTable = dbClient.getTable("SELECT furniture.id, furniture.tid, furniture.x, furniture.y, furniture.z, furniture.h, furniture.var, furniture.wallpos FROM rooms, furniture WHERE furniture.roomid = rooms.id AND rooms.id = '" + roomID + "' ORDER BY rooms.id ASC"); } foreach (DataRow dbRow in dTable.Rows) if (Convert.ToString(dbRow["wallpos"]) == "") // Flooritem floorItemManager.addItem(Convert.ToInt32(dbRow["id"]), Convert.ToInt32(dbRow["tid"]), Convert.ToInt32(dbRow["x"]), Convert.ToInt32(dbRow["y"]), Convert.ToInt32(dbRow["z"]), Convert.ToDouble(dbRow["h"]), Convert.ToString(dbRow["var"])); else wallItemManager.addItem(Convert.ToInt32(dbRow["id"]), Convert.ToInt32(dbRow["tid"]), Convert.ToString(dbRow["wallpos"]), Convert.ToString(dbRow["var"]), false); } _Users = new Hashtable(); _Bots = new Hashtable(); loadBots(); _activeGroups = new HashSet<int>(); _statusUpdates = new StringBuilder(); _statusHandler = new Thread(new ThreadStart(cycleStatuses)); _statusHandler.Start(); sqSTATE[doorX, doorY] = 0; // Door always walkable }