/// <summary> /// Checks for updates to TAG /// </summary> /// <param name="info">Additional info used by the Update timer (null)</param> public static void CheckForUpdates(object info) { TagTrace.WriteLine(TraceLevel.Verbose, "Checking for updates..."); if (TagUpdate.IsAbleToUpdate()) { if (TagUpdate.UpdateAvailable()) { TagTrace.WriteLine(TraceLevel.Info, "An update to TAG is available. Performing update..."); TagUpdate.InitiateUpdate(); } } else { TagTrace.WriteLine(TraceLevel.Verbose, "TAG can't update now. Games in progress."); } }
/// <summary> /// Posts the specified game to ASGS, and logs it /// </summary> /// <param name="data">The data to post</param> public static void PostGame(object data) { // Unpackage and prepare data GameData Data = (GameData)data; GameDataset Set = Data.GetDataset(); string Xml = Set.GetXml(); string CompressedXml = Compression.Compress(Xml); TagTrace.WriteLine(TraceLevel.Verbose, "Game data ready to post. Sending to stats server..."); TagTrace.WriteLine(TraceLevel.Verbose, "Use CSS: " + CssConnector.UseCss + ", CSS Url: " + CssConnector.CssUrl); // Post game to ASGS string PostMessage; int GameID; if (CssConnector.UseCss == true) { GameID = CssConnector.PostGame(CompressedXml, out PostMessage); } else { GameID = AsgsConnector.PostGame(CompressedXml, out PostMessage); } TagTrace.WriteLine(TraceLevel.Info, "Game #{0} Posted: {1}", GameID, PostMessage); // Post message to all servers GameServer.SendChat(PostMessage); // Log games as configured XmlLogger.LogGame(Data, GameID); // Get rid of this GameData since we no longer need it Data.Dispose(); TagTrace.WriteLine(TraceLevel.Verbose, "Game data disposed"); // If no games are in progress... if (TagUpdate.IsAbleToUpdate()) { TagTrace.WriteLine(TraceLevel.Verbose, "TAG is able to update. No games are in progress"); // And an update is available... if (TagUpdate.UpdateAvailable()) { TagUpdate.InitiateUpdate(); // Update! } } }
/// <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); } }