From bf3dbc26a5579e9c2134435d272aafe857ffd1d1 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Tue, 7 Mar 2017 01:09:53 +0000 Subject: the mud called me a drunk --- ShiftOS.Server/RandomUserGenerator.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ShiftOS.Server/RandomUserGenerator.cs') diff --git a/ShiftOS.Server/RandomUserGenerator.cs b/ShiftOS.Server/RandomUserGenerator.cs index afaee46..8c1e430 100644 --- a/ShiftOS.Server/RandomUserGenerator.cs +++ b/ShiftOS.Server/RandomUserGenerator.cs @@ -214,12 +214,18 @@ namespace ShiftOS.Server targets = new Dictionary(); foreach(var dir in dirs) { - string sDir = dir.Replace("\\", "/"); - while (!sDir.StartsWith("shiftnet/")) + if (!string.IsNullOrWhiteSpace(dir)) { - sDir = sDir.Remove(0, 1); + string sDir = dir.Replace("\\", "/"); + if (sDir.Contains("shiftnet")) + { + while (!sDir.StartsWith("shiftnet/")) + { + sDir = sDir.Remove(0, 1); + } + targets.Add(dir, output + "/" + sDir); + } } - targets.Add(dir, output + "/" + sDir); } } -- cgit v1.2.3 From 01530d637d790a101ea4dcb0e183664420d98ff9 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Tue, 7 Mar 2017 13:14:07 +0000 Subject: Fix NPC generation --- ShiftOS.Objects/ShiftFS.cs | 5 ++++- ShiftOS.Server/RandomUserGenerator.cs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'ShiftOS.Server/RandomUserGenerator.cs') diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index e14c2a8..2c6b28b 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -291,10 +291,13 @@ namespace ShiftOS.Objects.ShiftFS { string[] pathlist = path.Split('/'); int vol = Convert.ToInt32(pathlist[0].Replace(":", "")); + if (Mounts[vol] == null) + Mounts[vol] = new Directory(); var dir = Mounts[vol]; + for (int i = 1; i <= pathlist.Length - 1; i++) { - dir = dir.FindDirectoryByName(pathlist[i]); + dir = dir?.FindDirectoryByName(pathlist[i]); } return dir != null; diff --git a/ShiftOS.Server/RandomUserGenerator.cs b/ShiftOS.Server/RandomUserGenerator.cs index 8c1e430..672f25d 100644 --- a/ShiftOS.Server/RandomUserGenerator.cs +++ b/ShiftOS.Server/RandomUserGenerator.cs @@ -119,6 +119,7 @@ namespace ShiftOS.Server var dir = new ShiftOS.Objects.ShiftFS.Directory(); //name the directory after the user dir.Name = sve.Username; + dir.permissions = Objects.ShiftFS.Permissions.All; //json the object and mount string json = Newtonsoft.Json.JsonConvert.SerializeObject(dir); //mount it to the MUD @@ -219,7 +220,7 @@ namespace ShiftOS.Server string sDir = dir.Replace("\\", "/"); if (sDir.Contains("shiftnet")) { - while (!sDir.StartsWith("shiftnet/")) + while (!sDir.StartsWith("shiftnet")) { sDir = sDir.Remove(0, 1); } -- cgit v1.2.3 From 9c143b1249e03fa63492c7aa5283bf60f88c118b Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Tue, 7 Mar 2017 14:17:58 +0000 Subject: auto crash handling --- ShiftOS.Server/Program.cs | 21 +++++++++++++++++++++ ShiftOS.Server/RandomUserGenerator.cs | 7 +++++-- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'ShiftOS.Server/RandomUserGenerator.cs') diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 7e5a517..9093c35 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -123,6 +123,27 @@ namespace ShiftOS.Server Console.WriteLine("Client connected."); server.DispatchTo(a.Guid, new NetObject("welcome", new ServerMessage { Name = "Welcome", Contents = a.Guid.ToString(), GUID = "Server" })); }; + + server.OnClientDisconnected += (o, a) => + { + Console.WriteLine("Client disconnected."); + }; + + server.OnClientRejected += (o, a) => + { + Console.WriteLine("FUCK. Something HORRIBLE JUST HAPPENED."); + }; + + AppDomain.CurrentDomain.UnhandledException += (o, a) => + { + ChatBackend.Broadcast("**Automatic Broadcast:** The multi-user domain is restarting because of a crash."); +#if DEBUG + ChatBackend.Broadcast("Crash summary: " + a.ExceptionObject.ToString()); +#endif + if(server.IsOnline == true) + server.Stop(); + System.Diagnostics.Process.Start("ShiftOS.Server.exe"); + }; server.OnReceived += (o, a) => { diff --git a/ShiftOS.Server/RandomUserGenerator.cs b/ShiftOS.Server/RandomUserGenerator.cs index 672f25d..3a62f9c 100644 --- a/ShiftOS.Server/RandomUserGenerator.cs +++ b/ShiftOS.Server/RandomUserGenerator.cs @@ -114,7 +114,7 @@ namespace ShiftOS.Server sve.Codepoints = rnd.Next(startCP, maxAmt); //FS treasure generation. - + /* //create a ramdisk dir var dir = new ShiftOS.Objects.ShiftFS.Directory(); //name the directory after the user @@ -181,16 +181,19 @@ namespace ShiftOS.Server WriteAllBytes(kv.Value, File.ReadAllBytes(file)); } } - } + }*/ //save the save file to disk. File.WriteAllText("deadsaves/" + sve.Username + ".save", Newtonsoft.Json.JsonConvert.SerializeObject(sve, Newtonsoft.Json.Formatting.Indented)); //We don't care about the encryption algorithm because these saves can't be logged into as regular users. + /* //Now we export the mount. string exportedMount = ExportMount(mountid); //And save it to disk. File.WriteAllText("deadsaves/" + sve.Username + ".mfs", exportedMount); + */ + Thread.Sleep((60 * 60) * 1000); //approx. 1 hour. -- cgit v1.2.3