public void AbortRestart(string message) { if (m_CountdownTimer != null) { m_CountdownTimer.Stop(); m_CountdownTimer = null; if (m_DialogModule != null && message != String.Empty) { m_DialogModule.SendGeneralAlert(message); } } }
public void AbortRestart(string message) { if (m_CountdownTimer != null) { m_CountdownTimer.Stop(); m_CountdownTimer = null; if (m_DialogModule != null && message != string.Empty) { m_DialogModule.SendGeneralAlert(message); } MainConsole.Instance.Warn("[Restart]: Region restart aborted"); } }
public void loadSession(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } if (args.Length <= 2) { log("Error loading session, Usage: aar load <id>"); return; } string sessionId = args[2]; Dictionary <string, int> sessions = getSessions(); if (!sessions.ContainsKey(sessionId)) { log("Error loading session: session does not exist"); return; } dialog.SendGeneralAlert("AAR Module: Halting scripts in preparation for Playback"); haltScripts(); dialog.SendGeneralAlert("AAR Module: Initializing scene"); loadSession(sessionId, sessions[sessionId]); dialog.SendGeneralAlert("AAR Module: Scene ready for playback"); }
public object RegionSendAlertHandler(IList args, IPEndPoint remoteClient) { m_admin.CheckSessionValid(new UUID((string)args[0])); if (args.Count < 3) { return(false); } Scene scene; if (!m_app.SceneManager.TryGetScene((string)args[1], out scene)) { throw new Exception("region not found"); } String message = (string)args[2]; IDialogModule dialogModule = scene.RequestModuleInterface <IDialogModule>(); if (dialogModule != null) { dialogModule.SendGeneralAlert(message); } return(true); }
void Dialog(string message) { if (m_dialogmod != null) { m_dialogmod.SendGeneralAlert("Sierpinski Module: " + message); } }
public void Alert(string message) { if (m_dialogmod != null) { m_dialogmod.SendGeneralAlert(String.Format("{0}: {1}", Name, message)); } }
void DialogToAll(string dialogMessage) //All avatars in the region are notified when logging is turned on, off, or the log is cleared { if (m_dialogMod != null) { m_dialogMod.SendGeneralAlert(dialogMessage); } }
private void OnTimedShutdown(Object source, ElapsedEventArgs e) { countdownTimeNow = Util.GetLongTickCount(); if (countdownTimeNow >= countdownTimeEnd) { shutdownCounter.Stop(); m_app.Shutdown(); countdownTimeEnd = 0; return; } ulong countdownRemaining = countdownTimeEnd - countdownTimeNow; if (countdownRemaining % (60UL * 1000UL) < 1000UL) // Within a second of every minute from 0. { string message = GenerateShutdownMessage((int)(countdownRemaining / 1000UL)); m_log.DebugFormat("[RADMIN] Shutdown: {0}", message); IDialogModule dialogModule = rebootedScene.RequestModuleInterface <IDialogModule>(); if (dialogModule != null) { dialogModule.SendGeneralAlert(message); } } }
private void WriteParametersToLocalCurrentFile(string[] parameters) { try { System.IO.StreamWriter outputStream; outputStream = System.IO.File.CreateText(m_currentFile); foreach (string parameter in parameters) { outputStream.WriteLine(parameter); } outputStream.Close(); } catch //failed to write for some reason { m_log.Error("[vpgParameters] Error writing to \"" + m_currentFile + "\". Parameters will not be persistent over region restarts.."); foreach (Scene scene in m_scenes) { IDialogModule dialogmod = scene.RequestModuleInterface <IDialogModule>(); if (dialogmod != null) { dialogmod.SendGeneralAlert("Parameters Module: Error writing parameters to disk. Parameters will not persist over region restarts..."); } } } }
void Dialog(string message) { if (m_dialogmod != null) { m_dialogmod.SendGeneralAlert("ConwayGOL Module: " + message); } }
void DialogToAll(string dialogMessage) { IDialogModule dialogMod = m_scene.RequestModuleInterface <IDialogModule>(); if (dialogMod != null) { dialogMod.SendGeneralAlert(dialogMessage); } }
void AnnounceVisit(ScenePresence presence) { if (m_dialogmod != null) { m_dialogmod.SendGeneralAlert("Visit-Logger Module: " + presence.Firstname + " " + presence.Lastname + " entered the region"); } }
void DialogToAll(string message) { foreach (Scene scene in m_scenes) { IDialogModule dialogmod = scene.RequestModuleInterface <IDialogModule>(); if (dialogmod != null) { dialogmod.SendGeneralAlert(message); } } }
void Dialog(string message) { if (m_dialogmod != null) { m_dialogmod.SendGeneralAlert("CellularAutomata Module: " + message); } else { m_log.Info("Oops"); } }
protected bool OnSceneGroupMove(UUID groupId, Vector3 delta) { OSDMap attrs = null; SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId); if (sop == null) { return(true); } if (!sop.DynAttrs.TryGetStore(Namespace, StoreName, out attrs)) { attrs = new OSDMap(); } OSDInteger newValue; // We have to lock on the entire dynamic attributes map to avoid race conditions with serialization code. lock (sop.DynAttrs) { if (!attrs.ContainsKey("moves")) { newValue = new OSDInteger(1); } else { newValue = new OSDInteger(attrs["moves"].AsInteger() + 1); } attrs["moves"] = newValue; sop.DynAttrs.SetStore(Namespace, StoreName, attrs); } sop.ParentGroup.HasGroupChanged = true; string msg = string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue); m_log.DebugFormat("[DA EXAMPLE MODULE]: {0}", msg); m_dialogMod.SendGeneralAlert(msg); return(true); }
private bool OnSceneGroupMove(UUID groupId, Vector3 delta) { SceneObjectGroup so = m_scene.GetSceneObjectGroup(groupId); if (so == null) { return(true); } object rawObj = so.RootPart.DynObjs.Get(Name); if (rawObj != null) { MyObject myObj = (MyObject)rawObj; m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", so.Name, so.UUID, ++myObj.Moves)); } return(true); }
public object RegionShutdownHandler(IList args, IPEndPoint remoteClient) { m_admin.CheckSessionValid(new UUID((string)args[0])); try { Scene rebootedScene; string message; UUID regionID = new UUID(Convert.ToString(args[1])); int delay = Convert.ToInt32(args[2]); if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene)) { throw new Exception("Region not found"); } message = GenerateShutdownMessage(delay); m_log.DebugFormat("[RADMIN] Shutdown: {0}", message); IDialogModule dialogModule = rebootedScene.RequestModuleInterface <IDialogModule>(); if (dialogModule != null) { dialogModule.SendGeneralAlert(message); } ulong tcNow = Util.GetLongTickCount(); ulong endTime = tcNow + (ulong)(delay * 1000); ulong nextReport = tcNow + (ulong)(60 * 1000); // Perform shutdown if (delay > 0) { while (true) { System.Threading.Thread.Sleep(1000); tcNow = Util.GetLongTickCount(); if (tcNow >= endTime) { break; } if (tcNow >= nextReport) { delay -= 60; if (delay >= 0) { GenerateShutdownMessage(delay); nextReport = tcNow + (ulong)(60 * 1000); } } } } // Do this on a new thread so the actual shutdown call returns successfully. Task.Factory.StartNew(() => { m_app.Shutdown(); }); } catch (Exception e) { m_log.ErrorFormat("[RADMIN] Shutdown: failed: {0}", e.Message); m_log.DebugFormat("[RADMIN] Shutdown: failed: {0}", e.ToString()); throw e; } m_log.Info("[RADMIN]: Shutdown Administrator Request complete"); return(true); }
// Region.Shutdown(string sessionid, optional string regionid, optional int delay) public object RegionShutdownHandler(IList args, IPEndPoint remoteClient) { m_admin.CheckSessionValid(new UUID((string)args[0])); if (countdownTimeEnd > 0) { throw new Exception("remote shutdown already in progress"); } if (countdownTimeEnd > 0) { throw new Exception("remote shutdown already in progress"); } string regionIDInput = ""; int delay = 30; // Make the region ID and delay optional. Though if both are sepcified they have to be in order of ID then delay. // Note that there are always more entries in the args array than were sent. if (args[1] is Int32) // Delay was provided. { delay = Math.Max(0, Convert.ToInt32(args[1])); // And region ID is not expected. } else if (args[1] is String) // Region ID was provided. { regionIDInput = Convert.ToString(args[1]); // Try for both entries. if (args.Count >= 3 && args[2] is Int32) { delay = Math.Max(0, Convert.ToInt32(args[2])); } // else Only the region ID was specified. } try { string message; if (regionIDInput.Length > 0) { var regionID = new UUID(regionIDInput); if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene)) { throw new Exception("Region not found"); } } else { rebootedScene = m_app.SceneManager.CurrentOrFirstScene; } message = GenerateShutdownMessage(delay); m_log.DebugFormat("[RADMIN] Shutdown: {0}", message); IDialogModule dialogModule = rebootedScene.RequestModuleInterface <IDialogModule>(); if (dialogModule != null) { dialogModule.SendGeneralAlert(message); } // Do the countdown in a timer so the actual shutdown call returns successfully and immediately. countdownTimeNow = Util.GetLongTickCount(); countdownTimeEnd = countdownTimeNow + (ulong)delay * 1000UL; shutdownCounter = new Timer(800); // Fine enough resolution to always hit a 1 second window. shutdownCounter.AutoReset = true; shutdownCounter.Elapsed += OnTimedShutdown; shutdownCounter.Start(); } catch (Exception e) { m_log.ErrorFormat("[RADMIN] Shutdown: failed: {0}", e.Message); m_log.DebugFormat("[RADMIN] Shutdown: failed: {0}", e.ToString()); throw; } m_log.Info("[RADMIN]: Shutdown Administrator Request complete"); return(true); }
void OnChat(Object sender, OSChatMessage chat) { if ((chat.Channel != m_listenChannel) || (m_resetRequested)) { return; } else if (chat.Message.ToLower() == "kill") { //Immediately stop accepting commands from the simulation m_resetRequested = true; m_dialogmod.SendGeneralAlert("Manager Module: Deleting all objects and resetting module. Please be patient..."); //Remove all objects, clear the list of recyclables and reset the population size limit. m_scene.DeleteAllSceneObjects(); m_overLimit = false; m_recyclables = new Queue <ScriptAndHostPair>(); if (m_dialogmod != null) { m_dialogmod.SendGeneralAlert("Manager Module: Cleared old population. Reloading region with default objects..."); } //Start accepting commands from the simulation again m_resetRequested = false; //Reload content from the default oar file try { IRegionArchiverModule archivermod = m_scene.RequestModuleInterface <IRegionArchiverModule>(); if (archivermod != null) { string oarFilePath = System.IO.Path.Combine(m_oarPath, "vpgsim_default_content.oar"); archivermod.DearchiveRegion(oarFilePath); m_dialogmod.SendGeneralAlert("Manager Module: Loaded default objects..."); } } catch { m_dialogmod.SendGeneralAlert("Manager Module: Couldn't load default objects!"); m_log.WarnFormat("[vpgManager] Couldn't load default objects..."); } } else if (chat.Message.Length > 9) { if (chat.Message.Substring(0, 3).ToLower() == "oar") { IRegionArchiverModule archivermod = m_scene.RequestModuleInterface <IRegionArchiverModule>(); if (chat.Message.Substring(3, 5).ToLower() == "-load") { //Load the specified oar file if (archivermod != null) { //Immediately stop accepting commands from the simulation m_resetRequested = true; m_dialogmod.SendGeneralAlert("Manager Module: Loading archive file. Please be patient..."); //Remove all objects from the scene. The Archiver Module does this anyway, //but we need to be able to reset the list of recyclables after the scene //objects are deleted but before the new objects start to load, so the module //is ready to receive registration requests from recyclables in the oar. m_scene.DeleteAllSceneObjects(); m_overLimit = false; m_recyclables = new Queue <ScriptAndHostPair>(); //Start accepting commands from the simulation again m_resetRequested = false; try { string oarFilePath = System.IO.Path.Combine(m_oarPath, chat.Message.Substring(9)); archivermod.DearchiveRegion(oarFilePath); m_dialogmod.SendGeneralAlert("Manager Module: Loaded archive file..."); } catch { m_dialogmod.SendGeneralAlert("Manager Module: Couldn't load archive file!"); m_log.WarnFormat("[vpgManager] Couldn't load archive file..."); } } } else if (chat.Message.Substring(3, 5).ToLower() == "-save") { //Save the specified oar file if (archivermod != null) { m_dialogmod.SendGeneralAlert("Manager Module: Saving archive file. Please be patient..."); try { string oarFilePath = System.IO.Path.Combine(m_oarPath, chat.Message.Substring(9)); archivermod.ArchiveRegion(oarFilePath, new Dictionary <string, object>()); if (m_dialogmod != null) { m_dialogmod.SendGeneralAlert("Manager Module: Saved archive file..."); } } catch { m_dialogmod.SendGeneralAlert("Manager Module: Couldn't save archive file!"); m_log.WarnFormat("[vpgManager] Couldn't save archive file.."); } } } } else { //Try to parse the string as a new plant generation command string[] parsedMessage = chat.Message.Split(','); if (parsedMessage.Length != 7) { //Invalid message string m_log.WarnFormat("[vpgManager] Invalid new plant generation string..."); m_dialogmod.SendGeneralAlert("Manager Module: Invalid command - wrong number of arguments. No new plants generated..."); } else { m_dialogmod.SendGeneralAlert("Manager Module: Processing request. Please be patient..."); string geneticInfo = parsedMessage[0]; int xMin = int.Parse(parsedMessage[1]); int xMax = int.Parse(parsedMessage[2]); int yMin = int.Parse(parsedMessage[3]); int yMax = int.Parse(parsedMessage[4]); int quantity = int.Parse(parsedMessage[5]); int strictQuantity = int.Parse(parsedMessage[6]); bool errorStatus = false; int failureCount = 0; int successCount = 0; //The webform already checks these same things before creating the input string, but check them again in case the user manually edits the input string if ((xMin < 0) || (xMin > 256) || (xMax < 0) || (xMax > 256) || (yMin < 0) || (yMin > 256) || (yMax < 0) || (yMax > 256) || (xMin >= xMax) || (yMin >= yMax) || (quantity <= 0) || (quantity > 500) || !((geneticInfo.Length == 5) || (geneticInfo.Length == 10))) { m_dialogmod.SendGeneralAlert("Manager Module: Invalid command string."); errorStatus = true; } while ((quantity > 0) && (!errorStatus) && (failureCount < m_maxFailures)) { int randomGenotype = GenerateGenotype(geneticInfo); Vector3 randomLocation = GenerateRandomLocation(xMin, xMax, yMin, yMax); if (randomGenotype < 0) { m_dialogmod.SendGeneralAlert("Manager Module: Invalid command - Incorrect genotype format. No new plants generated..."); errorStatus = true; } else if (randomLocation.Z > WaterLevel(randomLocation)) { ScriptAndHostPair messageTarget = new ScriptAndHostPair(); lock (m_recyclables) { if (m_recyclables.Count == 0) //Nothing available to recycle { //Nothing available to recycle. vpgPlanter will need to rez a new one messageTarget.scriptUUID = m_vpgPlanter.scriptUUID; } else { //There are objects available to recycle. Recycle one from the queue messageTarget = m_recyclables.Dequeue(); } } //Format the coordinates in the vector format expected by the LSL script string coordinates = '<' + randomLocation.X.ToString() + ',' + randomLocation.Y.ToString() + ',' + randomLocation.Z.ToString() + '>'; //Send message to vpgPlanter or plant to be recycled m_scriptmod.DispatchReply(messageTarget.scriptUUID, randomGenotype, coordinates, ""); //We have to pause between messages or the vpgPlanter gets overloaded and puts all the plants in the same location. Thread.Sleep(50); successCount++; quantity--; } else if (strictQuantity == 0) { failureCount++; quantity--; } else { failureCount++; if (failureCount == m_maxFailures) { m_dialogmod.SendGeneralAlert("Manager Module: Too many failed attempts. Are you sure there is dry land in the selected range? Successfully planted:" + successCount.ToString() + " Failures:" + failureCount.ToString()); errorStatus = true; } } } if (m_dialogmod != null) { if (errorStatus == false) { m_dialogmod.SendGeneralAlert("Manager Module: Successfully planted:" + successCount.ToString() + " Failures:" + failureCount.ToString()); } } } } } }
public int DoOneNotice() { if (m_Alerts.Count == 0 || m_Alerts[0] == 0) { m_Scene.RestartNow(); return(0); } int nextAlert = 0; while (m_Alerts.Count > 1) { if (m_Alerts[1] == m_Alerts[0]) { m_Alerts.RemoveAt(0); continue; } nextAlert = m_Alerts[1]; break; } int currentAlert = m_Alerts[0]; m_Alerts.RemoveAt(0); int minutes = currentAlert / 60; string currentAlertString = String.Empty; if (minutes > 0) { if (minutes == 1) { currentAlertString += "1 minute"; } else { currentAlertString += String.Format("{0} minutes", minutes); } if ((currentAlert % 60) != 0) { currentAlertString += " and "; } } if ((currentAlert % 60) != 0) { int seconds = currentAlert % 60; if (seconds == 1) { currentAlertString += "1 second"; } else { currentAlertString += String.Format("{0} seconds", seconds); } } string msg = String.Format(m_Message, currentAlertString); if (m_DialogModule != null && msg != String.Empty) { if (m_Notice) { m_DialogModule.SendGeneralAlert(msg); } else { m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); } } return(currentAlert - nextAlert); }
private void ReadParameters(string fileName, bool local) { string[] parametersFromFile = new string[98]; if (local) //Read from a local file { try { if (System.IO.File.Exists(fileName)) { parametersFromFile = System.IO.File.ReadAllLines(fileName); SaveParametersToVariables(parametersFromFile); m_log.Info("[vpgParameters] Loaded parameters from file \"" + fileName + "\"..."); if (fileName != m_currentFile) { System.IO.File.Copy(fileName, m_currentFile, true); } foreach (Scene scene in m_scenes) { IDialogModule dialogmod = scene.RequestModuleInterface <IDialogModule>(); if (dialogmod != null) { dialogmod.SendGeneralAlert("Parameters Module: Loaded new parameters..."); } } m_successfullyLoaded = true; } else { m_log.Error("[vpgParameters] File \"" + fileName + "\" does not exist..."); foreach (Scene scene in m_scenes) { IDialogModule dialogmod = scene.RequestModuleInterface <IDialogModule>(); if (dialogmod != null) { dialogmod.SendGeneralAlert("Parameters Module: Error loading parameters..."); } } if (!m_successfullyLoaded) { LoadDefaultParameters(); } } } catch { m_log.Error("[vpgParameters] Error loading parameters from file \"" + fileName + "\"..."); foreach (Scene scene in m_scenes) { IDialogModule dialogmod = scene.RequestModuleInterface <IDialogModule>(); if (dialogmod != null) { dialogmod.SendGeneralAlert("Parameters Module: Error loading parameters..."); } } if (!m_successfullyLoaded) { LoadDefaultParameters(); } } } else //Read from a url { WebRequest parameterUrl = WebRequest.Create(fileName); try { StreamReader urlData = new StreamReader(parameterUrl.GetResponse().GetResponseStream()); int lineCounter = 0; string line; while ((line = urlData.ReadLine()) != null) { parametersFromFile[lineCounter] = line; lineCounter++; } SaveParametersToVariables(parametersFromFile); m_log.Info("[vpgParameters] Loaded parameters from url \"" + fileName + "\"..."); foreach (Scene scene in m_scenes) { IDialogModule dialogmod = scene.RequestModuleInterface <IDialogModule>(); if (dialogmod != null) { dialogmod.SendGeneralAlert("Parameters Module: Loaded new parameters..."); } } WriteParametersToLocalCurrentFile(parametersFromFile); m_successfullyLoaded = true; } catch //failed to get the data for some reason { m_log.Error("[vpgParameters] Error loading parameters from url \"" + fileName + "\"..."); foreach (Scene scene in m_scenes) { IDialogModule dialogmod = scene.RequestModuleInterface <IDialogModule>(); if (dialogmod != null) { dialogmod.SendGeneralAlert("Parameters Module: Error loading parameters..."); } } if (!m_successfullyLoaded) { LoadDefaultParameters(); } } } }