/// <summary>
        /// This method reads the current configuration data from the
        /// database.
        /// </summary>
        /// <param name="Database">Supplies the database connection.</param>
        public void ReadConfigurationFromDatabase(IALFADatabase Database)
        {
            Database.ACR_SQLQuery("SELECT `variable`, `value` FROM `config`");

            while (Database.ACR_SQLFetch())
            {
                string VarName = Database.ACR_SQLGetData(0);
                string VarValue = Database.ACR_SQLGetData(1);

                if (VarName == "PlayerPassword")
                    PlayerPassword = VarValue;
                else if (VarName == "RestartWatchdogTimeout")
                    RestartWatchdogTimeout = Convert.ToInt32(VarValue);
                else if (VarName == "AccountAssociationSecret")
                    AccountAssociationSecret = VarValue;
                else if (VarName == "AccountAssociationUrl")
                    AccountAssociationUrl = VarValue;
                else if (VarName == "GetHostnameUrl")
                    GetHostnameUrl = VarValue;
                else if (VarName == "DefaultIrcGatewayId")
                    DefaultIrcGatewayId = Convert.ToInt32(VarValue);
                else if (VarName == "DefaultIrcRecipient")
                    DefaultIrcRecipient = VarValue;
                else if (VarName == "DisableSaveInQuarantine")
                    DisableSaveInQuarantine = Convert.ToInt32(VarValue) != 0;
            }
        }
        /// <summary>
        /// Retrieve the properties of the player from the database.
        /// </summary>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        public void PopulateFromDatabase(IALFADatabase Database)
        {
            Database.ACR_SQLQuery(String.Format(
                                      "SELECT `Name`, `IsDM` FROM `players` WHERE `ID` = {0}",
                                      PlayerId));

            if (!Database.ACR_SQLFetch())
            {
                throw new ApplicationException("Failed to populate data for player " + PlayerId);
            }

            PlayerName = Database.ACR_SQLGetData(0);
            IsDM       = GameWorldManager.ConvertToBoolean(Database.ACR_SQLGetData(1));
        }
        /// <summary>
        /// Retrieve the properties of the server from the database.
        /// </summary>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        public void PopulateFromDatabase(IALFADatabase Database)
        {
            Database.ACR_SQLQuery(String.Format(
                "SELECT `Name`, `IPAddress` FROM `servers` WHERE `ID` = {0}",
                ServerId));

            if (!Database.ACR_SQLFetch())
            {
                throw new ApplicationException("Failed to populate data for server " + ServerId);
            }

            ServerName = Database.ACR_SQLGetData(0);
            SetHostnameAndPort(Database.ACR_SQLGetData(1));
        }
        /// <summary>
        /// Retrieve the properties of the player from the database.
        /// </summary>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        public void PopulateFromDatabase(IALFADatabase Database)
        {
            Database.ACR_SQLQuery(String.Format(
                "SELECT `Name`, `IsDM` FROM `players` WHERE `ID` = {0}",
                PlayerId));

            if (!Database.ACR_SQLFetch())
            {
                throw new ApplicationException("Failed to populate data for player " + PlayerId);
            }

            PlayerName = Database.ACR_SQLGetData(0);
            IsDM = GameWorldManager.ConvertToBoolean(Database.ACR_SQLGetData(1));
        }
示例#5
0
        /// <summary>
        /// Retrieve the properties of the server from the database.
        /// </summary>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        public void PopulateFromDatabase(IALFADatabase Database)
        {
            Database.ACR_SQLQuery(String.Format(
                                      "SELECT `Name`, `IPAddress`, `IsPublic` FROM `servers` WHERE `ID` = {0}",
                                      ServerId));

            if (!Database.ACR_SQLFetch())
            {
                throw new ApplicationException("Failed to populate data for server " + ServerId);
            }

            ServerName = Database.ACR_SQLGetData(0);
            SetHostnameAndPort(Database.ACR_SQLGetData(1));
            Public = GameWorldManager.ConvertToBoolean(Database.ACR_SQLGetData(2));
        }
        /// <summary>
        /// Retrieve the properties of the character from the database.
        /// </summary>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        public void PopulateFromDatabase(IALFADatabase Database)
        {
            Database.ACR_SQLQuery(String.Format(
                "SELECT `Name`, `PlayerID`, `IsOnline`, `Location` FROM `characters` WHERE `ID` = {0}",
                CharacterId));

            if (!Database.ACR_SQLFetch())
            {
                throw new ApplicationException("Failed to populate data for character " + CharacterId);
            }

            CharacterName = Database.ACR_SQLGetData(0);
            PlayerId = Convert.ToInt32(Database.ACR_SQLGetData(1));
            IsOnline = GameWorldManager.ConvertToBoolean(Database.ACR_SQLGetData(2));
            LocationString = Database.ACR_SQLGetData(3);
        }
示例#7
0
        /// <summary>
        /// Retrieve the properties of the character from the database.
        /// </summary>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        public void PopulateFromDatabase(IALFADatabase Database)
        {
            Database.ACR_SQLQuery(String.Format(
                                      "SELECT `Name`, `PlayerID`, `IsOnline`, `Location` FROM `characters` WHERE `ID` = {0}",
                                      CharacterId));

            if (!Database.ACR_SQLFetch())
            {
                throw new ApplicationException("Failed to populate data for character " + CharacterId);
            }

            CharacterName  = Database.ACR_SQLGetData(0);
            PlayerId       = Convert.ToInt32(Database.ACR_SQLGetData(1));
            IsOnline       = GameWorldManager.ConvertToBoolean(Database.ACR_SQLGetData(2));
            LocationString = Database.ACR_SQLGetData(3);
        }
        /// <summary>
        /// This routine returns the specified column of data from the current
        /// SQL rowset.
        /// </summary>
        /// <param name="ColumnIndex">Supplies the zero-based column index to
        /// retrieve.</param>
        /// <returns>The column data is returned.</returns>
        public string ACR_SQLGetData(int ColumnIndex)
        {
            IALFADatabase DefaultDatabase = ModuleLinkage.DefaultDatabase;

            if (DefaultDatabase != null)
            {
                return(DefaultDatabase.ACR_SQLGetData(ColumnIndex));
            }

            return(Script.NWNXGetString("SQL", "GETDATA", "", ColumnIndex));
        }
        /// <summary>
        /// This method reads the current configuration data from the
        /// database.
        /// </summary>
        /// <param name="Database">Supplies the database connection.</param>
        public void ReadConfigurationFromDatabase(IALFADatabase Database)
        {
            Database.ACR_SQLQuery("SELECT `variable`, `value` FROM `config`");

            while (Database.ACR_SQLFetch())
            {
                string VarName  = Database.ACR_SQLGetData(0);
                string VarValue = Database.ACR_SQLGetData(1);

                if (VarName == "PlayerPassword")
                {
                    PlayerPassword = VarValue;
                }
                else if (VarName == "RestartWatchdogTimeout")
                {
                    RestartWatchdogTimeout = Convert.ToInt32(VarValue);
                }
                else if (VarName == "AccountAssociationSecret")
                {
                    AccountAssociationSecret = VarValue;
                }
                else if (VarName == "AccountAssociationUrl")
                {
                    AccountAssociationUrl = VarValue;
                }
                else if (VarName == "GetHostnameUrl")
                {
                    GetHostnameUrl = VarValue;
                }
                else if (VarName == "DefaultIrcGatewayId")
                {
                    DefaultIrcGatewayId = Convert.ToInt32(VarValue);
                }
                else if (VarName == "DefaultIrcRecipient")
                {
                    DefaultIrcRecipient = VarValue;
                }
                else if (VarName == "ErrorNotifyIrcRecipient")
                {
                    ErrorNotifyIrcRecipient = VarValue;
                }
                else if (VarName == "DisableSaveInQuarantine")
                {
                    DisableSaveInQuarantine = Convert.ToInt32(VarValue) != 0;
                }
                else if (VarName == "ProtectionLevel")
                {
                    ProtectionLevel = (MemberProtectionLevel)Convert.ToInt32(VarValue);
                }
                else if (VarName == "VaultConnectionString")
                {
                    VaultConnectionString = VarValue;
                }
                else if (VarName == "UpdaterConnectionString")
                {
                    UpdaterConnectionString = VarValue;
                }
                else if (VarName == "VerboseVaultLogging")
                {
                    VerboseVaultLogging = Convert.ToInt32(VarValue) != 0;
                }
            }
        }
        /// <summary>
        /// Reference the data for a character by the character name.  If the
        /// data was not yet available, it is retrieved from the database.
        /// </summary>
        /// <param name="CharacterName">Supplies the object name.</param>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        /// <returns>The object data is returned, else null if the object did
        /// not exist.</returns>
        public GameCharacter ReferenceCharacterByName(string CharacterName, IALFADatabase Database)
        {
            //
            // Check if the object is already known first.
            //

            GameCharacter Character = (from C in Characters
                                       where C.CharacterName.Equals(CharacterName, StringComparison.InvariantCultureIgnoreCase)
                                       orderby C.Online descending
                                       select C).FirstOrDefault();

            if (Character != null)
                return Character;

            //
            // Need to pull the data from the database.
            //

            if (Database == null)
                return null;

            int ServerId;

            Database.ACR_SQLQuery(String.Format(
                "SELECT `ID`, `PlayerID`, `IsOnline`, `ServerID`, `Name`, `Location` FROM `characters` WHERE `Name` = '{0}' AND `IsDeleted` = 0 AND `IsPlayable` = 1 ORDER BY `ID` ASC ",
                Database.ACR_SQLEncodeSpecialChars(CharacterName)));

            if (!Database.ACR_SQLFetch())
                return null;

            Character = new GameCharacter(this);

            Character.CharacterId = Convert.ToInt32(Database.ACR_SQLGetData(0));
            Character.PlayerId = Convert.ToInt32(Database.ACR_SQLGetData(1));
            Character.Online = ConvertToBoolean(Database.ACR_SQLGetData(2));
            ServerId = Convert.ToInt32(Database.ACR_SQLGetData(3));
            Character.CharacterName = Database.ACR_SQLGetData(4);
            Character.LocationString = Database.ACR_SQLGetData(5);

            InsertNewCharacter(Character, ServerId, Database, null);

            return Character;
        }
        /// <summary>
        /// Reference the data for a server by the server id.  If the data
        /// was not yet available, it is retrieved from the database.
        /// </summary>
        /// <param name="ServerId">Supplies the object id.</param>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        /// <returns>The object data is returned, else null if the object did
        /// not exist.</returns>
        public GameServer ReferenceServerById(int ServerId, IALFADatabase Database)
        {
            //
            // Check if the object is already known first.
            //

            GameServer Server = (from S in Servers
                                 where S.ServerId == ServerId
                                 select S).FirstOrDefault();

            if (Server != null)
                return Server;

            //
            // Need to pull the data from the database.
            //

            if (Database == null)
                return null;

            Database.ACR_SQLQuery(String.Format(
                "SELECT `Name`, `IPAddress` FROM `servers` WHERE `ID` = {0}",
                ServerId));

            if (!Database.ACR_SQLFetch())
                return null;

            Server = new GameServer(this);

            Server.ServerName = Database.ACR_SQLGetData(0);
            Server.ServerId = ServerId;
            Server.SetHostnameAndPort(Database.ACR_SQLGetData(1));

            InsertNewServer(Server, Database);

            return Server;
        }
        /// <summary>
        /// Reference the data for a server by the server name.  If the data
        /// was not yet available, it is retrieved from the database.
        /// </summary>
        /// <param name="ServerName">Supplies the object name.</param>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        /// <returns>The object data is returned, else null if the object did
        /// not exist.</returns>
        public GameServer ReferenceServerByName(string ServerName, IALFADatabase Database)
        {
            //
            // Check if the object is already known first.
            //

            GameServer Server = (from S in Servers
                                 where S.ServerName.Equals(ServerName, StringComparison.InvariantCultureIgnoreCase)
                                 select S).FirstOrDefault();

            if (Server != null)
                return Server;

            //
            // Need to pull the data from the database.
            //

            if (Database == null)
                return null;

            Database.ACR_SQLQuery(String.Format(
                "SELECT `ID`, `IPAddress`, `Name` FROM `servers` WHERE `Name` = '{0}'",
                Database.ACR_SQLEncodeSpecialChars(ServerName)));

            if (!Database.ACR_SQLFetch())
                return null;

            Server = new GameServer(this);

            Server.ServerId = Convert.ToInt32(Database.ACR_SQLGetData(0));
            Server.SetHostnameAndPort(Database.ACR_SQLGetData(1));
            Server.ServerName = Database.ACR_SQLGetData(2);

            InsertNewServer(Server, Database);

            return Server;
        }
        /// <summary>
        /// Reference the data for a player by the player id.  If the data
        /// was not yet available, it is retrieved from the database.
        /// </summary>
        /// <param name="PlayerId">Supplies the object id.</param>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        /// <returns>The object data is returned, else null if the object did
        /// not exist.</returns>
        public GamePlayer ReferencePlayerById(int PlayerId, IALFADatabase Database)
        {
            //
            // Check if the object is already known first.
            //

            GamePlayer Player = (from P in Players
                                 where P.PlayerId == PlayerId
                                 select P).FirstOrDefault();

            if (Player != null)
                return Player;

            //
            // Need to pull the data from the database.
            //

            if (Database == null)
                return null;

            Database.ACR_SQLQuery(String.Format(
                "SELECT `Name`, `IsDM` FROM `players` WHERE `ID` = {0}",
                PlayerId));

            if (!Database.ACR_SQLFetch())
                return null;

            Player = new GamePlayer(this);

            Player.PlayerName = Database.ACR_SQLGetData(0);
            Player.PlayerId = PlayerId;
            Player.IsDM = ConvertToBoolean(Database.ACR_SQLGetData(1));

            InsertNewPlayer(Player, Database);

            return Player;
        }
        /// <summary>
        /// Reference the data for a player by the player name.  If the data
        /// was not yet available, it is retrieved from the database.
        /// </summary>
        /// <param name="PlayerName">Supplies the object name.</param>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        /// <returns>The object data is returned, else null if the object did
        /// not exist.</returns>
        public GamePlayer ReferencePlayerByName(string PlayerName, IALFADatabase Database)
        {
            //
            // Check if the object is already known first.
            //

            GamePlayer Player = (from P in Players
                                 where P.PlayerName.Equals(PlayerName, StringComparison.InvariantCultureIgnoreCase)
                                 select P).FirstOrDefault();

            if (Player != null)
                return Player;

            //
            // Need to pull the data from the database.
            //

            if (Database == null)
                return null;

            Database.ACR_SQLQuery(String.Format(
                "SELECT `ID`, `IsDM`, `Name` FROM `players` WHERE `Name` = '{0}'",
                Database.ACR_SQLEncodeSpecialChars(PlayerName)));

            if (!Database.ACR_SQLFetch())
                return null;

            Player = new GamePlayer(this);

            Player.PlayerId = Convert.ToInt32(Database.ACR_SQLGetData(0));
            Player.IsDM = ConvertToBoolean(Database.ACR_SQLGetData(1));
            Player.PlayerName = Database.ACR_SQLGetData(2);

            InsertNewPlayer(Player, Database);

            return Player;
        }
        /// <summary>
        /// Reference the data for a character by the character id.  If the
        /// data was not yet available, it is retrieved from the database.
        /// </summary>
        /// <param name="CharacterId">Supplies the object id.</param>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        /// <param name="InitialDMState">Supplies the initial DM state of the
        /// backing player object to update, for a synchronization of an
        /// existing player with a new character.</param>
        /// <returns>The object data is returned, else null if the object did
        /// not exist.</returns>
        public GameCharacter ReferenceCharacterById(int CharacterId, IALFADatabase Database, bool? InitialDMState)
        {
            //
            // Check if the object is already known first.
            //

            GameCharacter Character = (from C in Characters
                                       where C.CharacterId == CharacterId
                                       select C).FirstOrDefault();

            if (Character != null)
                return Character;

            //
            // Need to pull the data from the database.
            //

            if (Database == null)
                return null;

            int ServerId;

            Database.ACR_SQLQuery(String.Format(
                "SELECT `Name`, `PlayerID`, `IsOnline`, `ServerID`, `Location` FROM `characters` WHERE `ID` = {0}",
                CharacterId));

            if (!Database.ACR_SQLFetch())
                return null;

            Character = new GameCharacter(this);

            Character.CharacterName = Database.ACR_SQLGetData(0);
            Character.CharacterId = CharacterId;
            Character.PlayerId = Convert.ToInt32(Database.ACR_SQLGetData(1));
            Character.Online = ConvertToBoolean(Database.ACR_SQLGetData(2));
            ServerId = Convert.ToInt32(Database.ACR_SQLGetData(3));
            Character.LocationString = Database.ACR_SQLGetData(4);

            InsertNewCharacter(Character, ServerId, Database, InitialDMState);

            return Character;
        }