Example #1
0
        /// <summary>
        /// Reads the config file and initializes tracing and logging
        /// </summary>
        public static void LoadConfiguration()
        {
            if (_config == null)
            {
                // Try to read the configuration
                try
                {
                    _config = (TagConfig)ConfigurationSettings.GetConfig("TagConfig");

                    if (_config == null)
                    {
                        throw new ConfigurationException("Error parsing TagConfig section of config file");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error loading Config file: {0}", e.Message);
                    Console.WriteLine("Exiting...");
                    return;
                }

                // Make the configuration available to the CallsignHelper for ServerAdmin tags
                CallsignHelper.SetServerAdmins(_config.ServerAdmins);

                // Initialize tracing
                TagTrace.Initialize(_config.TraceLevel, _config.TracePath, _config.TraceArchiveDir, _config.TraceConsole, null);

                TagTrace.WriteLine(TraceLevel.Info, "TAG Build {0} is starting...", Build.ToString());

                // Initialize reconnect timer
                ReconnectTimer.Initialize(_config.ReconnectInterval, _config.MaxRetries);
                ReconnectTimer.ShutdownTagEvent += new AsyncCallback(ReconnectShutdown);

                // Configure ASGS as necessary
                if (_config.AsgsUrl != null)
                {
                    AsgsConnector.Initialize(_config.AsgsUrl, _config.PostTimeout);
                }

                if (_config.CssUrl != null)
                {
                    CssConnector.Initialize(_config.CssUrl, _config.PostTimeout, _config.UseCss);
                }

                TagTrace.WriteLine(TraceLevel.Verbose, "Initializing logging...");
                GameLogger.Initialize(_config.XmlPath);

                TagTrace.WriteLine(TraceLevel.Info, "Configuration Loaded.");
            }
        }
Example #2
0
        /// <summary>
        /// Handles the AdminPaged AGCEvent
        /// </summary>
        /// <param name="sender">The object firing the event</param>
        /// <param name="e">The arguments of the event</param>
        public static void AdminPagedAGCEventHandler(object sender, AdminPagedAGCEventArgs e)
        {
            try
            {
                TagTrace.WriteLine(TraceLevel.Verbose, "AdminPage Event received from {0}: {1}", e.Callsign, e.Message);
                Game CurrentGame = GameServer.Games.GetGameByID(e.GameID);
                if (CurrentGame != null)
                {
                    TagTrace.WriteLine(TraceLevel.Verbose, "AdminPage Event waiting to lock GameData...");
                    lock (CurrentGame.GetSyncRoot())
                    {
                        CurrentGame.GameData.LogAdminPage(e.Time, e.Callsign, e.Message);
                        TagTrace.WriteLine(TraceLevel.Verbose, "AdminPage logged.");
                    }

                    // If it's a #command, parse it
                    if (e.Message.StartsWith("#"))
                    {
                        int    SpacePosition = e.Message.IndexOf(" ");
                        string CommandName   = (SpacePosition < 0) ? e.Message : e.Message.Substring(0, SpacePosition);
                        string Params        = (SpacePosition < 0) ? string.Empty : e.Message.Substring(SpacePosition + 1);

                        switch (CommandName)
                        {
                        case "#debugkills":                                             // Allows debugging of kill logging
                            CurrentGame.DebugKills = !CurrentGame.DebugKills;
                            CurrentGame.SendChat("Kill debugging is now " + ((CurrentGame.DebugKills) ? "on" : "off"));
                            break;

                        case "#hq":
                            if (CallsignHelper.GetAuthLevel(e.Callsign) > AuthLevel.User)
                            {
                                GameServer.SendChat(Params);
                            }
                            else
                            {
                                GameServer.SendChat(e.Callsign, "You must be logged in with administrative tokens or tags in order to broadcast across the server");
                            }
                            break;

                        case "#hqgame":
                            if (CallsignHelper.GetAuthLevel(e.Callsign) > AuthLevel.User)
                            {
                                CurrentGame.SendChat(Params);
                            }
                            else
                            {
                                GameServer.SendChat(e.Callsign, "You must be logged in with administrative tokens or tags in order to broadcast to this game");
                            }
                            break;

//							case "#smite":
//								if (CurrentGame.SmitePlayer(Params, e.Callsign))
//									GameServer.SendChat(e.Callsign, "Player smited");
//								else
//									GameServer.SendChat(e.Callsign, "Specified player not found");
//
//								break;
                        case "#tag":
                            if (CallsignHelper.GetAuthLevel(e.Callsign) > AuthLevel.User)
                            {
                                CurrentGame.GameData.TagGame(e.Time, e.Callsign, Params);
                                GameServer.SendChat(e.Callsign, "This game has been tagged " + Params + ".");
                            }
                            else
                            {
                                GameServer.SendChat(e.Callsign, "You must be logged in with administrative tokens or tags in order to #tag a game");
                            }
                            break;

                        case "#update":                                 // Forces an update-check for TAG
                            if (TagUpdate.IsAbleToUpdate() || CallsignHelper.GetAuthLevel(e.Callsign) == AuthLevel.Admin)
                            {
                                if (TagUpdate.UpdateAvailable())
                                {
                                    GameServer.SendChat(e.Callsign, "TAG update available. Installing...");
                                    TagUpdate.InitiateUpdate();
                                }
                                else
                                {
                                    GameServer.SendChat(e.Callsign, "TAG is already up to date.");
                                }
                            }
                            else
                            {
                                GameServer.SendChat(e.Callsign, "TAG can't update now. There are games in progress.");
                            }
                            break;

                        case "#version":                                                // A simple version check to see what version is running
                            Version TagVersion       = Assembly.GetEntryAssembly().GetName().Version;
                            string  TagVersionString = string.Format("TAG v{0}.{1}.{2}.{3} online", TagVersion.Major, TagVersion.Minor, TagVersion.Build, TagVersion.Revision);
                            GameServer.SendChat(e.Callsign, TagVersionString);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TagTrace.WriteLine(TraceLevel.Error, "Error handling AdminPaged event: {0}", ex.Message);
            }
        }