This object (which is a singleton) manages the local server's view of the game world wide state (data for all servers and players is locally stored here). State elements are, generally, lazily added to the game world manager's state cache. Only when a character, player, or server has actually been observed will it be added to the local cache. This helps prevent the local cache from growing too large up front, as it does not need to have the entire database contents pre-downloaded. As identifiers for unknown servers, players, or characters are seen, the local state cache is updated from the database. The local state cache is also updated based on polling the online player list periodically. In effect, the state cache serves as the current server's view of player presence across the entire game world, spanning every online server. All internal operations on the GameWorldManager assume that the caller has provided appropriate synchronization. Many operations may block on the first reference to a previously unresolved object identifier or object name.
        /// <summary>
        /// Initialize the ServerNetworkManager instance.
        /// </summary>
        /// <param name="WorldManager">Supplies the game world manager to which
        /// the network manager instance is bound.</param>
        /// <param name="LocalServerId">Supplies the server id of the local
        /// server.</param>
        public ServerNetworkManager(GameWorldManager WorldManager, int LocalServerId)
        {
            SocketIo.Initialize();

            this.WorldManager = WorldManager;
            this.LocalServerId = LocalServerId;
        }
 public GameCharacter(GameWorldManager WorldManager)
 {
     this.WorldManager = WorldManager;
     Player = null;
     Server = null;
     Visited = false;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Construct a new GameServer object.
 /// </summary>
 /// <param name="WorldManager">Supplies the game world manager.
 /// </param>
 public GameServer(GameWorldManager WorldManager)
 {
     this.WorldManager = WorldManager;
     this.Characters = new List<GameCharacter>();
     this.ServerIPAddress = IPAddress.None;
     this.DatabaseOnline = true;
 }
        /// <summary>
        /// This method initializes the server communicator (one-time startup
        /// processing).
        /// </summary>
        private void InitializeServerCommunicator()
        {
            int ServerId;

            if (Database == null)
                Database = new ALFA.Database(this);

            ServerId = Database.ACR_GetServerID();

            WorldManager = new GameWorldManager(
                ServerId,
                GetName(GetModule()));
            NetworkManager = new ServerNetworkManager(WorldManager, ServerId);
            PlayerStateTable = new Dictionary<uint, PlayerState>();

            //
            // Remove any stale IPC commands to this server, as we are starting
            // up fresh.
            //

            Database.ACR_SQLExecute(String.Format(
                "DELETE FROM `server_ipc_events` WHERE `DestinationServerID`={0}",
                Database.ACR_GetServerID()));

            WriteTimestampedLogEntry(String.Format(
                "ACR_ServerCommunicator.InitializeServerCommunicator: Purged {0} old records from server_ipc_events for server id {1}.",
                Database.ACR_SQLGetAffectedRows(),
                Database.ACR_GetServerID()));
            WriteTimestampedLogEntry(String.Format(
                "ACR_ServerCommunicator.InitializeServerCommunicator: Server started with ACR version {0} and IPC subsystem version {1}.",
                Database.ACR_GetVersion(),
                Assembly.GetExecutingAssembly().GetName().Version.ToString()));

            if (GetLocalInt(GetModule(), "ACR_SERVER_IPC_DISABLE_LATENCY_CHECK") == FALSE)
                EnableLatencyCheck = true;
            else
                EnableLatencyCheck = false;

            if (!EnableLatencyCheck)
                WriteTimestampedLogEntry("ACR_ServerCommunicator.InitializeServerCommunicator: Latency check turned off by configuration.");

            RecordModuleResources();
            PatchContentFiles();
            ConfigureWer();

            RunPatchInitScript();

            //
            // Finally, drop into the command polling loop.
            //

            CommandDispatchLoop();
            UpdateServerExternalAddress();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Construct a new GamePlayer object.
 /// </summary>
 public GamePlayer(GameWorldManager WorldManager)
 {
     this.WorldManager = WorldManager;
     this.Characters = new List<GameCharacter>();
     this.OnlineCharacter = null;
 }
        /// <summary>
        /// This method initializes the server communicator (one-time startup
        /// processing).
        /// </summary>
        private void InitializeServerCommunicator()
        {
            int ServerId;

            if (Database == null)
                Database = new ALFA.Database(this);

            ServerId = Database.ACR_GetServerID();

            WorldManager = new GameWorldManager(
                ServerId,
                GetName(GetModule()));
            NetworkManager = new ServerNetworkManager(WorldManager, ServerId, this);
            PlayerStateTable = new Dictionary<uint, PlayerState>();

            //
            // Remove any stale IPC commands to this server, as we are starting
            // up fresh.
            //

            Database.ACR_SQLExecute(String.Format(
                "DELETE FROM `server_ipc_events` WHERE `DestinationServerID`={0}",
                Database.ACR_GetServerID()));

            WriteTimestampedLogEntry(String.Format(
                "ACR_ServerCommunicator.InitializeServerCommunicator: Purged {0} old records from server_ipc_events for server id {1}.",
                Database.ACR_SQLGetAffectedRows(),
                Database.ACR_GetServerID()));
            WriteTimestampedLogEntry(String.Format(
                "ACR_ServerCommunicator.InitializeServerCommunicator: Server started with ACR version {0} and IPC subsystem version {1}.",
                Database.ACR_GetVersion(),
                Assembly.GetExecutingAssembly().GetName().Version.ToString()));

            if (GetLocalInt(GetModule(), "ACR_SERVER_IPC_DISABLE_LATENCY_CHECK") == FALSE)
                EnableLatencyCheck = true;
            else
                EnableLatencyCheck = false;

            if (!EnableLatencyCheck)
                WriteTimestampedLogEntry("ACR_ServerCommunicator.InitializeServerCommunicator: Latency check turned off by configuration.");

            WorldManager.SynchronizeInitialConfiguration(Database);

            //
            // Check that the module is allowed to come online.  If it may be
            // hosted on another machine due to a recovery event, do not allow
            // the module to come online.
            //

            if (!ConfirmModuleOnline())
            {
                //
                // This module has been administratively prevented from loading
                // on all but a specific machine.  Await that condition to be
                // cleared from the database.  Do not initialize the vault
                // connector so that new logons are blocked, and set the
                // offline variable so that periodic time update does not mark
                // the server as online in the database.
                //

                WriteTimestampedLogEntry("ACR_ServerCommunicator.InitializeServerCommunicator: Module offlined because MachineName in servers table for this server is not NULL and does not match the machine name of this server.  This indicates that server startup was blocked for manual recovery.  Clear the MachineName field from the servers table in the database for this server to allow this server to start up normally.");
                SetLocalInt(GetModule(), "ACR_MODULE_OFFLINE", TRUE);
                PollModuleOnlineAllowed();
                SendInfrastructureDiagnosticIrcMessage(String.Format(
                    "Server '{0}' started on a machine that is administratively prohibited from loading the module, going into offline mode until MachineName is cleared in the servers table in the database for this server.",
                    GetName(GetModule())));
                WorldManager.PauseUpdates = true;
                return;
            }

            if (!ServerVaultConnector.Initialize(this, WorldManager.Configuration.VaultConnectionString, WorldManager.Configuration.VerboseVaultLogging))
                WriteTimestampedLogEntry("ACR_ServerCommunicator.InitializeServerCommunicator: ServerVaultConnector failed to initialize.");

            if (!String.IsNullOrEmpty(WorldManager.Configuration.VaultConnectionString))
                WriteTimestampedLogEntry("ACR_ServerCommunicator.InitializeServerCommunicator: Using Azure-based vault storage.");

            RecordModuleResources();
            PatchContentFiles();
            ConfigureWer();

            RunPatchInitScript();

            //
            // Finally, drop into the command polling loop.
            //

            CommandDispatchLoop();
            UpdateServerExternalAddress();
            GameDifficultyCheck();
        }
 /// <summary>
 /// Create a new GameEventQueue.
 /// </summary>
 /// <param name="WorldManager">Supplies the associated WorldManager
 /// object.</param>
 public GameEventQueue(GameWorldManager WorldManager)
 {
     this.WorldManager = WorldManager;
 }