From 0f19359ef042805ac645a1817a5c95b722c96a37 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Wed, 8 Mar 2017 01:43:25 +0000 Subject: [PATCH 01/27] They're all bears on unicycles... --- ShiftOS.Server/ShiftnetBackend.cs | 44 ++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/ShiftOS.Server/ShiftnetBackend.cs b/ShiftOS.Server/ShiftnetBackend.cs index 60b3aa4..c7bf0e8 100644 --- a/ShiftOS.Server/ShiftnetBackend.cs +++ b/ShiftOS.Server/ShiftnetBackend.cs @@ -43,37 +43,49 @@ namespace ShiftOS.Server string url = contents as string; if (!url.StartsWith("shiftnet/")) { - server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage + try { - Name = "shiftnet_file", - GUID = "server", - Contents = (File.Exists("badrequest.md") == true) ? File.ReadAllText("badrequest.md") : @"# Bad request. + + server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage + { + Name = "shiftnet_file", + GUID = "server", + Contents = (File.Exists("badrequest.md") == true) ? File.ReadAllText("badrequest.md") : @"# Bad request. You have sent a bad request to the multi-user domain. Please try again." - })); + })); + } + catch { } return; } if (File.Exists(url)) { - server.DispatchTo(new Guid(guid), new NetObject("download", new ServerMessage + try { - Name = "download_meta", - GUID = "server", - Contents = JsonConvert.SerializeObject(File.ReadAllBytes(url)) - })); + server.DispatchTo(new Guid(guid), new NetObject("download", new ServerMessage + { + Name = "download_meta", + GUID = "server", + Contents = JsonConvert.SerializeObject(File.ReadAllBytes(url)) + })); + } + catch { } } else { - server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage + try { - Name = "shiftnet_file", - GUID = "server", - Contents = (File.Exists("notfound.md") == true) ? File.ReadAllText("notfound.md") : @"# Not found. + server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage + { + Name = "shiftnet_file", + GUID = "server", + Contents = (File.Exists("notfound.md") == true) ? File.ReadAllText("notfound.md") : @"# Not found. The page you requested at was not found on this multi-user domain." - })); - + })); + } + catch { } } } From 1c0c7c6fa8cbc2c20f4a25457b934c61ffe4ec43 Mon Sep 17 00:00:00 2001 From: AShifter Date: Tue, 7 Mar 2017 18:53:41 -0700 Subject: [PATCH 02/27] Added ShiftLotto Added ShiftLotto. It's a new shiftorium upgrade that lets you make (and lose) codepoints FAST. --- ShiftOS.WinForms/Applications/ShiftLetters.cs | 5 +- .../Applications/ShiftLotto.Designer.cs | 202 ++++++++++++++++++ ShiftOS.WinForms/Applications/ShiftLotto.cs | 116 ++++++++++ ShiftOS.WinForms/Applications/ShiftLotto.resx | 128 +++++++++++ ShiftOS.WinForms/Resources/Shiftorium.txt | 14 ++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 + 6 files changed, 472 insertions(+), 2 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/ShiftLotto.cs create mode 100644 ShiftOS.WinForms/Applications/ShiftLotto.resx diff --git a/ShiftOS.WinForms/Applications/ShiftLetters.cs b/ShiftOS.WinForms/Applications/ShiftLetters.cs index f1c1d22..d11f6f6 100644 --- a/ShiftOS.WinForms/Applications/ShiftLetters.cs +++ b/ShiftOS.WinForms/Applications/ShiftLetters.cs @@ -50,7 +50,7 @@ namespace ShiftOS.WinForms.Applications "shiftorium", "codepoints", "shiftletters", "shops", "mud", "notification", "namechanger", "skinning", "skinloader", "calculator", "fileskimmer", "lua", "shiftnet", "terminal", "textpad"}; List contributorsWordlist = new List { "philipadams", "carverh", "computelinux", "lempamo", - "wowmom", "michaeltheshifter", "arencclc", "therandommelon", "pfg", "craftxbox"}; + "wowmom", "michaeltheshifter", "arencclc", "therandommelon", "pfg", "craftxbox", "ashifter"}; List osWordlist = new List { @@ -90,7 +90,8 @@ namespace ShiftOS.WinForms.Applications "vienna", "whistler", "windowsxp", - "windowsforworkgroups" + "windowsforworkgroups", + "shiftos" }; public ShiftLetters() diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs b/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs new file mode 100644 index 0000000..3af5d38 --- /dev/null +++ b/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs @@ -0,0 +1,202 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class ShiftLotto + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShiftLotto)); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.cpUpDown = new System.Windows.Forms.NumericUpDown(); + this.difUpDown = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.label7 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.cpUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.difUpDown)).BeginInit(); + this.SuspendLayout(); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(19, 49); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(376, 39); + this.label2.TabIndex = 2; + this.label2.Text = resources.GetString("label2.Text"); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(35, 122); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(60, 13); + this.label3.TabIndex = 3; + this.label3.Text = "Codepoints\r\n"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(319, 122); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(47, 13); + this.label4.TabIndex = 4; + this.label4.Text = "Difficulty"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(22, 164); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(369, 23); + this.button1.TabIndex = 6; + this.button1.Text = "Go!"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // label5 + // + this.label5.Location = new System.Drawing.Point(120, 136); + this.label5.Name = "label5"; + this.label5.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.label5.Size = new System.Drawing.Size(173, 23); + this.label5.TabIndex = 7; + this.label5.Text = "0 CP"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(173, 122); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(74, 13); + this.label6.TabIndex = 8; + this.label6.Text = "You could win"; + // + // cpUpDown + // + this.cpUpDown.Location = new System.Drawing.Point(22, 138); + this.cpUpDown.Maximum = new decimal(new int[] { + 10000000, + 0, + 0, + 0}); + this.cpUpDown.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.cpUpDown.Name = "cpUpDown"; + this.cpUpDown.Size = new System.Drawing.Size(92, 20); + this.cpUpDown.TabIndex = 9; + this.cpUpDown.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // difUpDown + // + this.difUpDown.Location = new System.Drawing.Point(299, 138); + this.difUpDown.Minimum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.difUpDown.Name = "difUpDown"; + this.difUpDown.Size = new System.Drawing.Size(92, 20); + this.difUpDown.TabIndex = 10; + this.difUpDown.Value = new decimal(new int[] { + 10, + 0, + 0, + 0}); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(147, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(115, 13); + this.label1.TabIndex = 11; + this.label1.Text = "Welcome to ShiftLotto!"; + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // label7 + // + this.label7.Location = new System.Drawing.Point(22, 190); + this.label7.Name = "label7"; + this.label7.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.label7.Size = new System.Drawing.Size(369, 23); + this.label7.TabIndex = 12; + this.label7.Text = "Current CP: 0 CP"; + this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // ShiftLotto + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label7); + this.Controls.Add(this.label1); + this.Controls.Add(this.difUpDown); + this.Controls.Add(this.cpUpDown); + this.Controls.Add(this.label6); + this.Controls.Add(this.label5); + this.Controls.Add(this.button1); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Name = "ShiftLotto"; + this.Size = new System.Drawing.Size(419, 252); + ((System.ComponentModel.ISupportInitialize)(this.cpUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.difUpDown)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.NumericUpDown cpUpDown; + private System.Windows.Forms.NumericUpDown difUpDown; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Label label7; + } +} diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.cs b/ShiftOS.WinForms/Applications/ShiftLotto.cs new file mode 100644 index 0000000..a070d43 --- /dev/null +++ b/ShiftOS.WinForms/Applications/ShiftLotto.cs @@ -0,0 +1,116 @@ +/* + * MIT License + * + * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.Applications +{ + [Launcher("ShiftLotto", true, "al_shiftlotto", "Games")] + [RequiresUpgrade("shiftlotto")] + [WinOpen("shiftlotto")] + public partial class ShiftLotto : UserControl, IShiftOSWindow + { + public ShiftLotto() + { + InitializeComponent(); + } + + public void OnLoad() + { + timer1.Start(); + } + + + public void OnSkinLoad() + { + + } + + public bool OnUnload() + { + return true; + } + + public void OnUpgrade() + { + + } + + // The Dynamic Display + private void timer1_Tick(object sender, EventArgs e) + { + int codePoints = Convert.ToInt32(Math.Round(cpUpDown.Value, 0)); + int difficulty = Convert.ToInt32(Math.Round(difUpDown.Value, 0)); + label5.Text = codePoints * difficulty + " CP"; + label7.Text = "Current CP: " + SaveSystem.CurrentSave.Codepoints.ToString() + " CP"; + } + + private void button1_Click(object sender, EventArgs e) + { + // Convert the NumericUpDown to Int + int codePoints = Convert.ToInt32(Math.Round(cpUpDown.Value, 0)); + int difficulty = Convert.ToInt32(Math.Round(difUpDown.Value, 0)); + + // Create Random Ints + Random rnd = new Random(); + + // Set their highest possible number to Difficulty + int guessedNumber = rnd.Next(0, difficulty); + int winningNumber = rnd.Next(0, difficulty); + + // Multiply CodePoints * Difficulty + int jackpot = codePoints * difficulty; + + // Test the random ints + if (guessedNumber == winningNumber) + { + // If you win + + // Add Codepoints + SaveSystem.TransferCodepointsFrom("shiftlotto", jackpot); + + // Infobox + Infobox.Show("YOU WON!", "Good Job! " + jackpot.ToString() + " CP has been added to your account. "); + } + else + { + // If you fail + + // Remove Codepoints + SaveSystem.TransferCodepointsToVoid(jackpot); + + // Infobox + Infobox.Show("YOU FAILED!", "Sorry! " + jackpot.ToString() + " CP has been removed from your account."); + } + } + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.resx b/ShiftOS.WinForms/Applications/ShiftLotto.resx new file mode 100644 index 0000000..4664613 --- /dev/null +++ b/ShiftOS.WinForms/Applications/ShiftLotto.resx @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ShiftLotto lets you to turn a few codepoints into a FOURTUNE! All you need to +do is bet a certain amount of codepoints, set a difficulty, and try your luck. + There have been many winners - Will you be one too? + + + 17, 17 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 841a24e..3de7214 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -125,6 +125,20 @@ Description: "Want to adjust the volume of ShiftOS's audio? This upgrade will let you." }, + //SHIFTLOTTO UPGRADES + { + Name: "ShiftLotto", + Cost: 200, + Dependencies: null, + Description: "Are you feeling lucky? Spend some money on this upgrade! If you have any left, go ahead and bet your money in ShiftLotto!" + }, + { + Name: "AL ShiftLotto", + Cost: 150, + Dependencies: "app_launcher;shiftlotto", + Description: "This upgrade allows you to find ShiftLotto in your App Launcher." + }, + // COLOR DEPTH AND DITHERING { diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 7f728d5..2c36f6c 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -166,6 +166,12 @@ Shifter.cs + + UserControl + + + ShiftLotto.cs + UserControl @@ -335,6 +341,9 @@ Shifter.cs + + ShiftLotto.cs + Shiftnet.cs From ed26b419631065bd743598a249d58589d2eda646 Mon Sep 17 00:00:00 2001 From: AShifter Date: Tue, 7 Mar 2017 19:36:16 -0700 Subject: [PATCH 03/27] Fixed ShiftLotto Fixed a bug in ShiftLotto where the amount of codepoints you had wasn't actually checked. This lead to me having -6732946923443264 Codepoints. Oops. --- .../Applications/ShiftLotto.Designer.cs | 2 +- ShiftOS.WinForms/Applications/ShiftLotto.cs | 66 +++++++++++-------- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs b/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs index 3af5d38..653e3db 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs @@ -105,7 +105,7 @@ // this.cpUpDown.Location = new System.Drawing.Point(22, 138); this.cpUpDown.Maximum = new decimal(new int[] { - 10000000, + 10000, 0, 0, 0}); diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.cs b/ShiftOS.WinForms/Applications/ShiftLotto.cs index a070d43..cc38582 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.cs @@ -76,41 +76,55 @@ namespace ShiftOS.WinForms.Applications private void button1_Click(object sender, EventArgs e) { - // Convert the NumericUpDown to Int + // Make codePoints and difficulty in this function int codePoints = Convert.ToInt32(Math.Round(cpUpDown.Value, 0)); int difficulty = Convert.ToInt32(Math.Round(difUpDown.Value, 0)); - // Create Random Ints - Random rnd = new Random(); - - // Set their highest possible number to Difficulty - int guessedNumber = rnd.Next(0, difficulty); - int winningNumber = rnd.Next(0, difficulty); - - // Multiply CodePoints * Difficulty - int jackpot = codePoints * difficulty; - - // Test the random ints - if (guessedNumber == winningNumber) + if (SaveSystem.CurrentSave.Codepoints <= 1) { - // If you win - - // Add Codepoints - SaveSystem.TransferCodepointsFrom("shiftlotto", jackpot); - - // Infobox - Infobox.Show("YOU WON!", "Good Job! " + jackpot.ToString() + " CP has been added to your account. "); + Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to use ShiftLotto!"); } else { - // If you fail + if (SaveSystem.CurrentSave.Codepoints - (codePoints * difficulty) <= 0) + { + Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to gamble this amount!"); + } + else + { + // Create Random Ints + Random rnd = new Random(); - // Remove Codepoints - SaveSystem.TransferCodepointsToVoid(jackpot); + // Set their highest possible number to Difficulty + int guessedNumber = rnd.Next(0, difficulty); + int winningNumber = rnd.Next(0, difficulty); - // Infobox - Infobox.Show("YOU FAILED!", "Sorry! " + jackpot.ToString() + " CP has been removed from your account."); - } + // Multiply CodePoints * Difficulty + int jackpot = codePoints * difficulty; + + // Test the random ints + if (guessedNumber == winningNumber) + { + // If you win + + // Add Codepoints + SaveSystem.TransferCodepointsFrom("shiftlotto", jackpot); + + // Infobox + Infobox.Show("YOU WON!", "Good Job! " + jackpot.ToString() + " CP has been added to your account. "); + } + else + { + // If you fail + + // Remove Codepoints + SaveSystem.TransferCodepointsToVoid(jackpot); + + // Infobox + Infobox.Show("YOU FAILED!", "Sorry! " + jackpot.ToString() + " CP has been removed from your account."); + } + } + } } } } \ No newline at end of file From 369aefc5e81eba25e31d52c1031f3e8ec750cb04 Mon Sep 17 00:00:00 2001 From: AShifter Date: Tue, 7 Mar 2017 20:04:59 -0700 Subject: [PATCH 04/27] Added ShiftLotto Icon I added a ShiftLotto Icon (and probably did other stuff) --- .../Applications/ShiftLotto.Designer.cs | 26 +++++++++++++++++- ShiftOS.WinForms/Applications/ShiftLotto.cs | 1 + .../Properties/Resources.Designer.cs | 24 ++++++++++------ ShiftOS.WinForms/Properties/Resources.resx | 3 ++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + .../SystemIcons/iconShiftLotto.png | Bin 0 -> 299 bytes 6 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 ShiftOS.WinForms/SystemIcons/iconShiftLotto.png diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs b/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs index 653e3db..943322e 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs @@ -1,4 +1,28 @@ -namespace ShiftOS.WinForms.Applications +/* + * MIT License + * + * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +namespace ShiftOS.WinForms.Applications { partial class ShiftLotto { diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.cs b/ShiftOS.WinForms/Applications/ShiftLotto.cs index cc38582..7acba3e 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.cs @@ -35,6 +35,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [Launcher("ShiftLotto", true, "al_shiftlotto", "Games")] + [DefaultIcon("iconShiftLotto")] [RequiresUpgrade("shiftlotto")] [WinOpen("shiftlotto")] public partial class ShiftLotto : UserControl, IShiftOSWindow diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 2df6f11..6628f0b 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -729,6 +729,16 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap iconShiftLotto { + get { + object obj = ResourceManager.GetObject("iconShiftLotto", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -923,15 +933,11 @@ namespace ShiftOS.WinForms.Properties { /// Company: "ShiftSoft" /// }, /// { - /// Company: "" - /// }, - /// { - /// - /// }, - /// { - /// - /// }, - ///]. + /// Company: "Shiftcast", + /// Name: "NetXtreme Hyper Edition", + /// CostPerMonth: 1500, + /// DownloadSpeed: 524288, //512 kb/s + /// Description: "It's time to supercharge your Shif [rest of string was truncated]";. /// internal static string ShiftnetServices { get { diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index 5100329..bef4f99 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -475,4 +475,7 @@ ..\Resources\ShiftnetServices.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + ..\systemicons\iconshiftlotto.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 2c36f6c..3a603db 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -609,6 +609,7 @@ + diff --git a/ShiftOS.WinForms/SystemIcons/iconShiftLotto.png b/ShiftOS.WinForms/SystemIcons/iconShiftLotto.png new file mode 100644 index 0000000000000000000000000000000000000000..b2a3ad5366171978e799a576f1cb9f80fa42e015 GIT binary patch literal 299 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85p<)L71^VC4M4MP_o1|q9iy!t)x7$D3zfgF*C13FE6!3!9>qM z&(PR}Il2m{Xtt+|V~B-+Z$Bg7VFe!M%Cq-Qp5JaEFiApL_tL^gH}b6IK8N0Tknv&3 zPMiLIYyS03TXkBVu^zm(L*Z;hUZ2}T1+HlUx1Cq-`Cc7qn0xMKLz=s@_>H-T8K Date: Wed, 8 Mar 2017 10:01:12 +0100 Subject: [PATCH 05/27] Fix the typo It's been in here for far too long. --- ShiftOS.WinForms/Applications/ShiftLetters.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShiftOS.WinForms/Applications/ShiftLetters.cs b/ShiftOS.WinForms/Applications/ShiftLetters.cs index d11f6f6..700df7e 100644 --- a/ShiftOS.WinForms/Applications/ShiftLetters.cs +++ b/ShiftOS.WinForms/Applications/ShiftLetters.cs @@ -50,7 +50,7 @@ namespace ShiftOS.WinForms.Applications "shiftorium", "codepoints", "shiftletters", "shops", "mud", "notification", "namechanger", "skinning", "skinloader", "calculator", "fileskimmer", "lua", "shiftnet", "terminal", "textpad"}; List contributorsWordlist = new List { "philipadams", "carverh", "computelinux", "lempamo", - "wowmom", "michaeltheshifter", "arencclc", "therandommelon", "pfg", "craftxbox", "ashifter"}; + "wowmom", "michaeltheshifter", "arencllc", "therandommelon", "pfg", "craftxbox", "ashifter"}; List osWordlist = new List { From e51f51b7d1b379f7d632ee010ad704562aacb797 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 8 Mar 2017 16:26:35 -0500 Subject: [PATCH 06/27] password breaching works now. --- ShiftOS.WinForms/HackerCommands.cs | 32 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index 7861981..f3f132e 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -360,7 +360,7 @@ namespace ShiftOS.WinForms { string usr = args["user"].ToString(); string sys = args["sys"].ToString(); - + bool received = false; ServerMessageReceived msgReceived = null; Console.WriteLine("--hooking system thread..."); @@ -373,30 +373,28 @@ namespace ShiftOS.WinForms var rnd = new Random(); var sw = new Stopwatch(); sw.Start(); - string pass = ""; - for(int i = 0; i < sve.Password.Length; i++) + Thread.Sleep(2000); + if(rnd.Next(0, 100) >= 75) { - char c = '\0'; - while (c != sve.Password[i]) - c = chars[rnd.Next(0, chars.Length)]; - pass += c; - Thread.Sleep(rnd.Next(25,75)); + Console.WriteLine("--operation took too long - failed."); + return; } sw.Stop(); - Console.WriteLine(pass); + Console.WriteLine(sve.Password); Console.WriteLine(); Console.WriteLine("--password breached. Operation took " + sw.ElapsedMilliseconds + " milliseconds."); + received = true; ServerManager.MessageReceived -= msgReceived; } else if(msg.Name == "user_data_not_found") { Console.WriteLine("--access denied."); + received = true; ServerManager.MessageReceived -= msgReceived; } }; Console.WriteLine("--beginning brute-force attack on " + usr + "@" + sys + "..."); - Thread.Sleep(500); ServerManager.MessageReceived += msgReceived; ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new @@ -404,6 +402,7 @@ namespace ShiftOS.WinForms user = usr, sysname = sys })); + Thread.Sleep(500); return true; } @@ -418,7 +417,7 @@ namespace ShiftOS.WinForms string usr = args["user"].ToString(); string sys = args["sys"].ToString(); string pass = args["pass"].ToString(); - + bool received = false; ServerMessageReceived msgReceived = null; Console.WriteLine("--hooking multi-user domain response call..."); @@ -441,18 +440,19 @@ namespace ShiftOS.WinForms { Console.WriteLine("--access denied."); } + received = true; ServerManager.MessageReceived -= msgReceived; } else if (msg.Name == "user_data_not_found") { Console.WriteLine("--access denied."); + received = true; ServerManager.MessageReceived -= msgReceived; } }; Console.WriteLine("--contacting multi-user domain..."); - Thread.Sleep(500); ServerManager.MessageReceived += msgReceived; ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new @@ -460,6 +460,7 @@ namespace ShiftOS.WinForms user = usr, sysname = sys })); + Thread.Sleep(500); return true; } @@ -476,7 +477,7 @@ namespace ShiftOS.WinForms string sys = args["sys"].ToString(); string pass = args["pass"].ToString(); long amount = (long)args["amount"]; - + bool received = false; if(amount < 0) { Console.WriteLine("--invalid codepoint amount - halting..."); @@ -509,12 +510,13 @@ namespace ShiftOS.WinForms { Console.WriteLine("--access denied."); } - + received = true; ServerManager.MessageReceived -= msgReceived; } else if (msg.Name == "user_data_not_found") { Console.WriteLine("--access denied."); + received = true; ServerManager.MessageReceived -= msgReceived; } }; @@ -528,6 +530,8 @@ namespace ShiftOS.WinForms user = usr, sysname = sys })); + Thread.Sleep(500); + return true; } From 5f0cfb100cc0698ede828857393b7fd3f44af73d Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 8 Mar 2017 19:08:35 -0500 Subject: [PATCH 07/27] selecting content in terminal copies to clipboard --- ShiftOS.WinForms/Controls/TerminalBox.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 4fcb429..b75d077 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -61,5 +61,29 @@ namespace ShiftOS.WinForms.Controls { this.AppendText(Localization.Parse(text) + Environment.NewLine); } + + bool quickCopying = false; + + protected override void OnMouseDown(MouseEventArgs e) + { + //if right-clicking, then we initiate a quick-copy. + if (e.Button == MouseButtons.Right) + quickCopying = true; + + //Override the mouse event so that it's a left-click at all times. + base.OnMouseDown(new MouseEventArgs(MouseButtons.Left, e.Clicks, e.X, e.Y, e.Delta)); + } + + protected override void OnMouseUp(MouseEventArgs mevent) + { + if(quickCopying == true) + { + if (!string.IsNullOrWhiteSpace(this.SelectedText)) + { + this.Copy(); + } + } + base.OnMouseUp(mevent); + } } } From 2ff261328740cbb628678605b09800f22c9b67a9 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 8 Mar 2017 19:23:40 -0500 Subject: [PATCH 08/27] Fix notification bug. --- ShiftOS.WinForms/WinformsDesktop.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 8900a69..d30adb4 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -63,8 +63,10 @@ namespace ShiftOS.WinForms NotificationDaemon.NotificationMade += (note) => { //Soon this will pop a balloon note. - btnnotifications.Text = "Notifications (" + NotificationDaemon.GetUnreadCount().ToString() + ")"; - + this.Invoke(new Action(() => + { + btnnotifications.Text = "Notifications (" + NotificationDaemon.GetUnreadCount().ToString() + ")"; + })); }; NotificationDaemon.NotificationRead += () => From abe535200bb348af6288b7cc7d3405b2fea8ffa6 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 8 Mar 2017 19:38:18 -0500 Subject: [PATCH 09/27] Kernel watchdog watches you more... :notjustabluesmileyface: --- ShiftOS_TheReturn/TerminalBackend.cs | 50 ++++++++++++++++++---------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 8be54d0..f78d7a5 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -139,29 +139,29 @@ namespace ShiftOS.Engine { if (Shiftorium.UpgradeAttributesUnlocked(type)) { - if (KernelWatchdog.IsSafe(type)) + foreach (var a in type.GetCustomAttributes(false)) { - foreach (var a in type.GetCustomAttributes(false)) + if (a is Namespace) { - if (a is Namespace) + var ns = a as Namespace; + if (text.Split('.')[0] == ns.name) { - var ns = a as Namespace; - if (text.Split('.')[0] == ns.name) + if (KernelWatchdog.IsSafe(type)) { foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { if (Shiftorium.UpgradeAttributesUnlocked(method)) { - if (KernelWatchdog.IsSafe(method)) + if (CanRunRemotely(method, isRemote)) { - if (CanRunRemotely(method, isRemote)) + foreach (var ma in method.GetCustomAttributes(false)) { - foreach (var ma in method.GetCustomAttributes(false)) + if (ma is Command) { - if (ma is Command) + var cmd = ma as Command; + if (text.Split('.')[1] == cmd.name) { - var cmd = ma as Command; - if (text.Split('.')[1] == cmd.name) + if (KernelWatchdog.IsSafe(method)) { var attr = method.GetCustomAttribute(); @@ -245,23 +245,37 @@ namespace ShiftOS.Engine return (bool)method.Invoke(null, new object[] { }); } } + else + { + Console.WriteLine(" You cannot run this command."); + KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); + return true; + } } + + } } - else - { - Console.WriteLine(text + " cannot be ran in a remote session"); - return true; - } } - + else + { + Console.WriteLine(text + " cannot be ran in a remote session"); + return true; + } } + } + + } + else + { + Console.WriteLine(" You cannot run this command."); + KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); + return true; } } } } - } } } From a9d7195f1e631a88386cf58dd1e33e36cba28a69 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Thu, 9 Mar 2017 14:43:03 +0000 Subject: [PATCH 10/27] make script runner less drunk --- ShiftOS.Server/Core.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs index 4ec421d..a602240 100644 --- a/ShiftOS.Server/Core.cs +++ b/ShiftOS.Server/Core.cs @@ -96,10 +96,11 @@ namespace ShiftOS.Server { Name = "run", GUID = "Server", - Contents = $@"{{ - script:""{File.ReadAllText($"scripts/{user}/{script}.lua").Replace("\"", "\\\"")}"", - args:""{sArgs}"" - }}" + Contents = JsonConvert.SerializeObject(new + { + script = File.ReadAllText($"scripts/{user}/{script}.lua"), + args = sArgs + }) })); } else @@ -115,7 +116,7 @@ namespace ShiftOS.Server { Name = "Error", GUID = "Server", - Contents = JsonConvert.SerializeObject(new MudException("Command parse error")) + Contents = JsonConvert.SerializeObject(new MudException(" Script not found or script error detected.")) })); } catch @@ -182,8 +183,8 @@ namespace ShiftOS.Server GUID = "server", Contents = JsonConvert.SerializeObject(saveFile) })); + return; } - return; } } foreach (var sve in Directory.GetFiles("saves")) @@ -199,8 +200,8 @@ namespace ShiftOS.Server GUID = "server", Contents = JsonConvert.SerializeObject(saveFile) })); + return; } - return; } } From 8db3a2e11c6cc58adb2b62fbce1c1f63426b674c Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 09:48:45 -0500 Subject: [PATCH 11/27] Server-side scripts now get ran. --- ShiftOS_TheReturn/Scripting.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index 3ecf9d9..940e998 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -63,6 +63,19 @@ namespace ShiftOS.Engine.Scripting public dynamic Lua = new DynamicLua.DynamicLua(); public bool Running = true; + static LuaInterpreter() + { + ServerManager.MessageReceived += (msg) => + { + if(msg.Name == "run") + { + var cntnts = JsonConvert.DeserializeObject(msg.Contents); + var interp = new LuaInterpreter(); + interp.Execute(cntnts.script.ToString()); + } + }; + } + public static string CreateSft(string lua) { byte[] bytes = Encoding.UTF8.GetBytes(lua); From 02fd7a883b4592a2200c4f3e912e56bdc09bfdbc Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 09:53:00 -0500 Subject: [PATCH 12/27] callback action can be fired when user closes infobox --- ShiftOS.WinForms/Applications/Dialog.cs | 6 +++++- ShiftOS_TheReturn/Infobox.cs | 6 +++--- ShiftOS_TheReturn/Scripting.cs | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ShiftOS.WinForms/Applications/Dialog.cs b/ShiftOS.WinForms/Applications/Dialog.cs index 26e3040..11fbf1e 100644 --- a/ShiftOS.WinForms/Applications/Dialog.cs +++ b/ShiftOS.WinForms/Applications/Dialog.cs @@ -76,12 +76,16 @@ namespace ShiftOS.WinForms.Applications btnok.Click += (o, a) => { AppearanceManager.Close(this); + OpenCallback?.Invoke(); }; } - public void Open(string title, string msg) + private Action OpenCallback = null; + + public void Open(string title, string msg, Action c = null) { + OpenCallback = c; new Dialog().OpenInternal(title, msg); } diff --git a/ShiftOS_TheReturn/Infobox.cs b/ShiftOS_TheReturn/Infobox.cs index 3e8fa30..e3308dc 100644 --- a/ShiftOS_TheReturn/Infobox.cs +++ b/ShiftOS_TheReturn/Infobox.cs @@ -55,11 +55,11 @@ namespace ShiftOS.Engine /// /// Infobox title /// Infobox message - public static void Show(string title, string message) + public static void Show(string title, string message, Action callback = null) { title = Localization.Parse(title); message = Localization.Parse(message); - _infobox.Open(title, message); + _infobox.Open(title, message, callback); } public static void PromptText(string title, string message, Action callback) @@ -89,7 +89,7 @@ namespace ShiftOS.Engine // Infobox Interface public interface IInfobox { - void Open(string title, string msg); + void Open(string title, string msg, Action callback = null); void PromptText(string title, string message, Action callback); void PromptYesNo(string title, string message, Action callback); } diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index 940e998..b3e5208 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -357,9 +357,9 @@ end"); [Exposed("infobox")] public class InfoboxFunctions { - public void show(string title, string message) + public void show(string title, string message, Action callback = null) { - Infobox.Show(title, message); + Infobox.Show(title, message, callback); } public void question(string title, string message, Action callback) From ea430ac9df46cf01c8c4f8502097057a8da42600 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 10:33:44 -0500 Subject: [PATCH 13/27] mud diagnostics and user info --- ShiftOS_TheReturn/Scripting.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index b3e5208..bb65dc7 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -354,6 +354,35 @@ end"); } } + [Exposed("mud")] + public class MUDFunctions + { + public void sendDiagnostic(string src, string cat, object val) + { + ServerManager.SendMessage("diag_log", $"[{src}] <{cat}>: {val}"); + } + } + + [Exposed("userinfo")] + public class UserInfoFunctions + { + public string getUsername() + { + return SaveSystem.CurrentSave.Username; + } + + public string getSysname() + { + return SaveSystem.CurrentSave.SystemName; + } + + public string getEmail() + { + return getUsername() + "@" + getSysname(); + } + } + + [Exposed("infobox")] public class InfoboxFunctions { From 23671dedd1b715eb3b24d3174530926d7cbc3b52 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Thu, 9 Mar 2017 17:52:24 +0000 Subject: [PATCH 14/27] MUD now collects diagnostics. --- ShiftOS.Server/Core.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs index a602240..e14ca27 100644 --- a/ShiftOS.Server/Core.cs +++ b/ShiftOS.Server/Core.cs @@ -127,6 +127,17 @@ namespace ShiftOS.Server } + [MudRequest("diag_log", typeof(string))] + public static void Diagnostic(string guid, string line) + { + List lines = new List(); + if (File.Exists("diagnostics.log")) + lines = new List(File.ReadAllLines("diagnostics.log")); + + lines.Add(line); + File.WriteAllLines("diagnostics.log", lines.ToArray()); + } + [MudRequest("getusers", typeof(string))] public static void GetAllUsers(string guid, string contents) { From d9b4e79bcffea6139fadefcd95a020029941eda7 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 13:40:33 -0500 Subject: [PATCH 15/27] fix some minor hacking issues You can now purge dead saves. --- ShiftOS.WinForms/HackerCommands.cs | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index f3f132e..b2170cd 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -377,6 +377,7 @@ namespace ShiftOS.WinForms if(rnd.Next(0, 100) >= 75) { Console.WriteLine("--operation took too long - failed."); + ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); return; } sw.Stop(); @@ -498,6 +499,7 @@ namespace ShiftOS.WinForms if(amount > sve.Codepoints) { Console.WriteLine("--can't steal this many codepoints from user."); + ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); return; } @@ -535,6 +537,57 @@ namespace ShiftOS.WinForms return true; } + [Command("purge_user")] + [KernelMode] + [RequiresArgument("pass")] + [RequiresArgument("user")] + [RequiresArgument("sys")] + [RequiresUpgrade("hacker101_deadaccts")] + public static bool PurgeUser(Dictionary args) + { + string usr = args["user"].ToString(); + string sys = args["sys"].ToString(); + string pass = args["pass"].ToString(); + ServerMessageReceived msgReceived = null; + + Console.WriteLine("--hooking multi-user domain response call..."); + + msgReceived = (msg) => + { + if (msg.Name == "user_data") + { + var sve = JsonConvert.DeserializeObject(msg.Contents); + if (sve.Password == pass) + { + ServerManager.SendMessage("delete_dead_save", JsonConvert.SerializeObject(sve)); + Console.WriteLine(" User purged successfully."); + } + else + { + Console.WriteLine("--access denied."); + } + ServerManager.MessageReceived -= msgReceived; + } + else if (msg.Name == "user_data_not_found") + { + Console.WriteLine("--access denied."); + ServerManager.MessageReceived -= msgReceived; + } + }; + + Console.WriteLine("--contacting multi-user domain..."); + Thread.Sleep(500); + ServerManager.MessageReceived += msgReceived; + + ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new + { + user = usr, + sysname = sys + })); + Thread.Sleep(500); + + return true; + } [Command("brute_decrypt", true)] From 3f08cb807c1490af423450e3eb03a46aa11caf2f Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 16:14:35 -0500 Subject: [PATCH 16/27] Colored terminal text --- ShiftOS.WinForms/Controls/TerminalBox.cs | 10 ++++++ ShiftOS.WinForms/Tools/ControlManager.cs | 42 ++++++++++++++++++++++++ ShiftOS_TheReturn/ConsoleEx.cs | 28 ++++++++++++++++ ShiftOS_TheReturn/ServerManager.cs | 2 ++ ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + 5 files changed, 83 insertions(+) create mode 100644 ShiftOS_TheReturn/ConsoleEx.cs diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index b75d077..7c0da57 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -26,9 +26,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Controls { @@ -53,13 +55,21 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { this.HideSelection = true; + this.Select(this.TextLength, 0); + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } public void WriteLine(string text) { + this.HideSelection = true; + this.Select(this.TextLength, 0); + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); + this.HideSelection = false; } bool quickCopying = false; diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 5cc4813..52663d7 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -152,6 +152,48 @@ namespace ShiftOS.WinForms.Tools } } + internal static Color ConvertColor(ConsoleColor cCol) + { + switch (cCol) + { + case ConsoleColor.Black: + return Color.Black; + case ConsoleColor.Gray: + return Color.Gray; + case ConsoleColor.DarkGray: + return Color.DarkGray; + case ConsoleColor.Blue: + return Color.Blue; + case ConsoleColor.Cyan: + return Color.Cyan; + case ConsoleColor.DarkBlue: + return Color.DarkBlue; + case ConsoleColor.DarkCyan: + return Color.DarkCyan; + case ConsoleColor.DarkGreen: + return Color.DarkGreen; + case ConsoleColor.DarkMagenta: + return Color.DarkMagenta; + case ConsoleColor.DarkRed: + return Color.DarkRed; + case ConsoleColor.DarkYellow: + return Color.YellowGreen; + case ConsoleColor.Yellow: + return Color.Yellow; + case ConsoleColor.Green: + return Color.Green; + case ConsoleColor.Magenta: + return Color.Magenta; + case ConsoleColor.Red: + return Color.Red; + case ConsoleColor.White: + return Color.White; + default: + return Color.Black; + } + + } + public static void SetCursor(Control ctrl) { #if STUPID diff --git a/ShiftOS_TheReturn/ConsoleEx.cs b/ShiftOS_TheReturn/ConsoleEx.cs new file mode 100644 index 0000000..69f6a18 --- /dev/null +++ b/ShiftOS_TheReturn/ConsoleEx.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + public static class ConsoleEx + { + static ConsoleEx() + { + ForegroundColor = ConsoleColor.White; + BackgroundColor = ConsoleColor.Black; + + Bold = false; + Italic = false; + Underline = false; + } + + public static ConsoleColor ForegroundColor { get; set; } + public static ConsoleColor BackgroundColor { get; set; } + + public static bool Bold { get; set; } + public static bool Italic { get; set; } + public static bool Underline { get; set; } + } +} diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index a121ab6..7da09f1 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -154,7 +154,9 @@ namespace ShiftOS.Engine { var ex = JsonConvert.DeserializeObject(msg.Contents); TerminalBackend.PrefixEnabled = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine($@"{{MUD_ERROR}}: {ex.Message}"); + ConsoleEx.ForegroundColor = ConsoleColor.White; TerminalBackend.PrefixEnabled = true; Console.Write($"{SaveSystem.CurrentSave.Username}@{CurrentSave.SystemName}:~$ "); } diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 20ca879..00d828f 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -99,6 +99,7 @@ + CrashHandler.cs From 251521835b60024dec292a759d738e2b81bf1417 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 16:46:34 -0500 Subject: [PATCH 17/27] Console colors! --- ShiftOS.WinForms/Applications/Terminal.cs | 4 +-- ShiftOS.WinForms/Controls/TerminalBox.cs | 16 +++++++++++ ShiftOS_TheReturn/ServerManager.cs | 11 ++++++-- ShiftOS_TheReturn/TerminalBackend.cs | 34 ++++++++++++++++++++++- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 7bab213..65a8f0f 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -134,7 +134,7 @@ namespace ShiftOS.WinForms.Applications rtbterm.Text = ""; TerminalBackend.PrefixEnabled = true; TerminalBackend.InStory = false; - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + TerminalBackend.PrintPrompt(); if (Shiftorium.UpgradeInstalled("wm_free_placement")) { this.ParentForm.Width = 640; @@ -276,7 +276,7 @@ namespace ShiftOS.WinForms.Applications } if (TerminalBackend.PrefixEnabled) { - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + TerminalBackend.PrintPrompt(); } } } diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 7c0da57..9e4c61c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading; @@ -56,16 +57,31 @@ namespace ShiftOS.WinForms.Controls { this.HideSelection = true; this.Select(this.TextLength, 0); + this.SelectionFont = ConstructFont(); this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } + private Font ConstructFont() + { + FontStyle fs = FontStyle.Regular; + if (ConsoleEx.Bold) + fs = fs | FontStyle.Bold; + if (ConsoleEx.Italic) + fs = fs | FontStyle.Italic; + if (ConsoleEx.Underline) + fs = fs | FontStyle.Underline; + + return new Font(this.Font, fs); + } + public void WriteLine(string text) { this.HideSelection = true; this.Select(this.TextLength, 0); + this.SelectionFont = ConstructFont(); this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 7da09f1..4d599cd 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -132,6 +132,7 @@ namespace ShiftOS.Engine { Console.WriteLine(acc); } + TerminalBackend.PrintPrompt(); } else if(msg.Name == "update_your_cp") { @@ -154,11 +155,15 @@ namespace ShiftOS.Engine { var ex = JsonConvert.DeserializeObject(msg.Contents); TerminalBackend.PrefixEnabled = true; + ConsoleEx.ForegroundColor = ConsoleColor.Red; + ConsoleEx.Bold = true; + Console.Write($@"{{MUD_ERROR}}: "); + ConsoleEx.Bold = false; + ConsoleEx.Italic = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine($@"{{MUD_ERROR}}: {ex.Message}"); - ConsoleEx.ForegroundColor = ConsoleColor.White; + Console.WriteLine(ex.Message); TerminalBackend.PrefixEnabled = true; - Console.Write($"{SaveSystem.CurrentSave.Username}@{CurrentSave.SystemName}:~$ "); + TerminalBackend.PrintPrompt(); } else { diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index f78d7a5..841fd6a 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -283,7 +283,39 @@ namespace ShiftOS.Engine } return false; } - + + public static void PrintPrompt() + { + ConsoleEx.Italic = false; + ConsoleEx.Underline = false; + + ConsoleEx.ForegroundColor = ConsoleColor.Magenta; + ConsoleEx.Bold = true; + Console.Write(SaveSystem.CurrentSave.Username); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + Console.Write("@"); + ConsoleEx.Italic = true; + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + Console.Write(SaveSystem.CurrentSave.SystemName); + ConsoleEx.Italic = false; + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + Console.Write(":~"); + Console.ForegroundColor = ConsoleColor.White; + ConsoleEx.Italic = true; + if (KernelWatchdog.InKernelMode == true) + Console.Write("#"); + else + Console.Write("$"); + ConsoleEx.Italic = false; + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.White; + Console.Write(" "); + } + + static TerminalBackend() { ServerMessageReceived onMessageReceived = (msg) => From b4a5c854c8b597340cb349ba9d2fe59c2f4a652a Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 16:51:00 -0500 Subject: [PATCH 18/27] hacker commands print the prompt when done --- ShiftOS.WinForms/HackerCommands.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index b2170cd..52d8568 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -386,12 +386,14 @@ namespace ShiftOS.WinForms Console.WriteLine("--password breached. Operation took " + sw.ElapsedMilliseconds + " milliseconds."); received = true; ServerManager.MessageReceived -= msgReceived; + TerminalBackend.PrintPrompt(); } else if(msg.Name == "user_data_not_found") { Console.WriteLine("--access denied."); received = true; ServerManager.MessageReceived -= msgReceived; + TerminalBackend.PrintPrompt(); } }; @@ -443,6 +445,7 @@ namespace ShiftOS.WinForms } received = true; ServerManager.MessageReceived -= msgReceived; + TerminalBackend.PrintPrompt(); } else if (msg.Name == "user_data_not_found") @@ -450,6 +453,7 @@ namespace ShiftOS.WinForms Console.WriteLine("--access denied."); received = true; ServerManager.MessageReceived -= msgReceived; + TerminalBackend.PrintPrompt(); } }; @@ -514,12 +518,14 @@ namespace ShiftOS.WinForms } received = true; ServerManager.MessageReceived -= msgReceived; + TerminalBackend.PrintPrompt(); } else if (msg.Name == "user_data_not_found") { Console.WriteLine("--access denied."); received = true; ServerManager.MessageReceived -= msgReceived; + TerminalBackend.PrintPrompt(); } }; @@ -573,6 +579,7 @@ namespace ShiftOS.WinForms Console.WriteLine("--access denied."); ServerManager.MessageReceived -= msgReceived; } + TerminalBackend.PrintPrompt(); }; Console.WriteLine("--contacting multi-user domain..."); From a9b08eb21676a6c59b0c8bb6046b40bd42e078d5 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 18:15:29 -0500 Subject: [PATCH 19/27] FULLY COMPLETE TERMINAL COLORS --- ShiftOS.WinForms/Applications/Shifter.cs | 24 +++++++++++++++++++++++ ShiftOS.WinForms/Applications/Shiftnet.cs | 7 +++++-- ShiftOS.WinForms/Applications/Terminal.cs | 12 ++++++------ ShiftOS_TheReturn/Skinning.cs | 4 ++-- ShiftOS_TheReturn/TerminalBackend.cs | 3 ++- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 4d29cf8..1adc75a 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -446,6 +446,30 @@ namespace ShiftOS.WinForms.Applications flbody.Controls.Add(color); color.Show(); } + else if(c.Field.FieldType.IsEnum == true) + { + var cBox = new ComboBox(); + cBox.Width = 150; + ControlManager.SetupControl(cBox); + + foreach(var itm in Enum.GetNames(c.Field.FieldType)) + { + cBox.Items.Add(itm); + } + + cBox.Text = c.Field.GetValue(LoadedSkin).ToString(); + + cBox.SelectedIndexChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, Enum.Parse(c.Field.FieldType, cBox.Text)); + }; + + labelHeight = cBox.Height; + + flbody.Controls.Add(cBox); + cBox.Show(); + flbody.SetFlowBreak(cBox, true); + } else if(c.Field.FieldType == typeof(int)) { if (c.Field.HasShifterEnumMask()) diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index 9540794..45f37d4 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -34,6 +34,7 @@ using System.Windows.Forms; using ShiftOS.Engine; using Newtonsoft.Json; using static ShiftOS.Engine.SkinEngine; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { [Launcher("Shiftnet", false, null, "Networking")] @@ -62,6 +63,8 @@ namespace ShiftOS.WinForms.Applications { } public string ConstructHtml(string markdown) { + var TerminalForeColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalForeColorCC); + var TerminalBackColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalBackColorCC); string html = $@" diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 65a8f0f..06a6e8d 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -43,6 +43,7 @@ using System.Collections; using static ShiftOS.Engine.SkinEngine; using ShiftOS.Engine; using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { @@ -350,8 +351,8 @@ namespace ShiftOS.WinForms.Applications txt.Focus(); txt.Font = LoadedSkin.TerminalFont; - txt.ForeColor = LoadedSkin.TerminalForeColor; - txt.BackColor = LoadedSkin.TerminalBackColor; + txt.ForeColor = ControlManager.ConvertColor(LoadedSkin.TerminalForeColorCC); + txt.BackColor = ControlManager.ConvertColor(LoadedSkin.TerminalBackColorCC); } @@ -391,8 +392,7 @@ namespace ShiftOS.WinForms.Applications rtbterm.Text = AppearanceManager.LastTerminalText; rtbterm.Select(rtbterm.TextLength, 0); } - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - + TerminalBackend.PrintPrompt(); } @@ -403,8 +403,8 @@ namespace ShiftOS.WinForms.Applications try { rtbterm.Font = LoadedSkin.TerminalFont; - rtbterm.ForeColor = LoadedSkin.TerminalForeColor; - rtbterm.BackColor = LoadedSkin.TerminalBackColor; + rtbterm.ForeColor = ControlManager.ConvertColor(LoadedSkin.TerminalForeColorCC); + rtbterm.BackColor = ControlManager.ConvertColor(LoadedSkin.TerminalBackColorCC); } catch { diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 43e0b5d..800b107 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -865,12 +865,12 @@ namespace ShiftOS.Engine { [ShifterMeta("System")] [ShifterCategory("General")] [ShifterName("Terminal text color")] - public Color TerminalForeColor = DefaultForeground; + public ConsoleColor TerminalForeColorCC = ConsoleColor.White; [ShifterMeta("System")] [ShifterCategory("General")] [ShifterName("Terminal background color")] - public Color TerminalBackColor = DesktopBG; + public ConsoleColor TerminalBackColorCC = ConsoleColor.Black; [ShifterMeta("Desktop")] [ShifterCategory("Desktop Panel")] diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 841fd6a..5c08cfe 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -286,6 +286,7 @@ namespace ShiftOS.Engine public static void PrintPrompt() { + ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; ConsoleEx.Italic = false; ConsoleEx.Underline = false; @@ -311,7 +312,7 @@ namespace ShiftOS.Engine Console.Write("$"); ConsoleEx.Italic = false; ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.White; + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; Console.Write(" "); } From a9754b7df28795b6bb2c5cfe04c1b38b19fb0d05 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 10 Mar 2017 12:29:28 -0500 Subject: [PATCH 20/27] Lock certain apps away when system offline. --- ShiftOS.WinForms/Applications/Artpad.cs | 1 + ShiftOS.WinForms/Applications/Chat.cs | 1 + ShiftOS.WinForms/Applications/Downloader.cs | 1 + ShiftOS.WinForms/Applications/FormatEditor.cs | 1 + .../Applications/GraphicPicker.cs | 1 + .../Applications/MUDControlCentre.cs | 1 + ShiftOS.WinForms/Applications/NameChanger.cs | 1 + ShiftOS.WinForms/Applications/Pong.cs | 1 + ShiftOS.WinForms/Applications/ShiftLetters.cs | 1 + ShiftOS.WinForms/Applications/ShiftLotto.cs | 1 + ShiftOS.WinForms/Applications/ShiftSweeper.cs | 1 + ShiftOS.WinForms/Applications/Shifter.cs | 1 + ShiftOS.WinForms/Applications/Shiftnet.cs | 1 + .../Applications/ShiftoriumFrontend.cs | 1 + ShiftOS.WinForms/HackerCommands.cs | 10 +++++ ShiftOS.WinForms/WinformsWindowManager.cs | 18 +++++++++ ShiftOS_TheReturn/AppLauncherDaemon.cs | 20 ++++++++-- ShiftOS_TheReturn/KernelWatchdog.cs | 38 ++++++++++++++++++- ShiftOS_TheReturn/Scripting.cs | 7 +++- 19 files changed, 100 insertions(+), 7 deletions(-) diff --git a/ShiftOS.WinForms/Applications/Artpad.cs b/ShiftOS.WinForms/Applications/Artpad.cs index 6c1bc1c..71f7afb 100644 --- a/ShiftOS.WinForms/Applications/Artpad.cs +++ b/ShiftOS.WinForms/Applications/Artpad.cs @@ -41,6 +41,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Artpad", true, "al_artpad", "Graphics")] [RequiresUpgrade("artpad")] [WinOpen("artpad")] diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index 06a7873..caf8cd2 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -36,6 +36,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] public partial class Chat : UserControl, IShiftOSWindow { public Chat(string chatId) diff --git a/ShiftOS.WinForms/Applications/Downloader.cs b/ShiftOS.WinForms/Applications/Downloader.cs index da90c6d..1f240bf 100644 --- a/ShiftOS.WinForms/Applications/Downloader.cs +++ b/ShiftOS.WinForms/Applications/Downloader.cs @@ -41,6 +41,7 @@ using System.IO.Compression; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Downloader", false, null, "Networking")] [DefaultIcon("iconDownloader")] public partial class Downloader : UserControl, IShiftOSWindow diff --git a/ShiftOS.WinForms/Applications/FormatEditor.cs b/ShiftOS.WinForms/Applications/FormatEditor.cs index ef44b47..56b0253 100644 --- a/ShiftOS.WinForms/Applications/FormatEditor.cs +++ b/ShiftOS.WinForms/Applications/FormatEditor.cs @@ -34,6 +34,7 @@ using System.Windows.Forms; using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("FormatEditor", true, "al_format_editor", "Games")] [RequiresUpgrade("format_editor")] [WinOpen("formateditor")] diff --git a/ShiftOS.WinForms/Applications/GraphicPicker.cs b/ShiftOS.WinForms/Applications/GraphicPicker.cs index 2dfe7ec..b3dd8bf 100644 --- a/ShiftOS.WinForms/Applications/GraphicPicker.cs +++ b/ShiftOS.WinForms/Applications/GraphicPicker.cs @@ -37,6 +37,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [DefaultTitle("Choose graphic")] [DefaultIcon("icongraphicpicker")] public partial class GraphicPicker : UserControl, IShiftOSWindow { diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs index 02fe868..e2668bd 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs @@ -38,6 +38,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [RequiresUpgrade("mud_fundamentals")] [Launcher("MUD Control Centre", true, "al_mud_control_centre", "Networking")] [WinOpen("mud_control_centre")] diff --git a/ShiftOS.WinForms/Applications/NameChanger.cs b/ShiftOS.WinForms/Applications/NameChanger.cs index ca76e57..d7c99f7 100644 --- a/ShiftOS.WinForms/Applications/NameChanger.cs +++ b/ShiftOS.WinForms/Applications/NameChanger.cs @@ -38,6 +38,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Name Changer", true, "al_name_changer", "Customization")] [RequiresUpgrade("name_changer")] [WinOpen("name_changer")] diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index af1e156..157ce8c 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -37,6 +37,7 @@ using ShiftOS.Objects; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Pong", true, "al_pong", "Games")] [WinOpen("pong")] [DefaultIcon("iconPong")] diff --git a/ShiftOS.WinForms/Applications/ShiftLetters.cs b/ShiftOS.WinForms/Applications/ShiftLetters.cs index 700df7e..b5e9aa4 100644 --- a/ShiftOS.WinForms/Applications/ShiftLetters.cs +++ b/ShiftOS.WinForms/Applications/ShiftLetters.cs @@ -36,6 +36,7 @@ using System.Windows.Forms; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("ShiftLetters", false, null, "Games")] [RequiresUpgrade("shiftletters")] [WinOpen("shiftletters")] diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.cs b/ShiftOS.WinForms/Applications/ShiftLotto.cs index 7acba3e..33f357f 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.cs @@ -35,6 +35,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [Launcher("ShiftLotto", true, "al_shiftlotto", "Games")] + [MultiplayerOnly] [DefaultIcon("iconShiftLotto")] [RequiresUpgrade("shiftlotto")] [WinOpen("shiftlotto")] diff --git a/ShiftOS.WinForms/Applications/ShiftSweeper.cs b/ShiftOS.WinForms/Applications/ShiftSweeper.cs index b13880f..cf6d331 100644 --- a/ShiftOS.WinForms/Applications/ShiftSweeper.cs +++ b/ShiftOS.WinForms/Applications/ShiftSweeper.cs @@ -36,6 +36,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [Launcher("ShiftSweeper", true, "al_shiftsweeper", "Games")] [RequiresUpgrade("shiftsweeper")] + [MultiplayerOnly] [WinOpen("shiftsweeper")] [DefaultIcon("iconShiftSweeper")] public partial class ShiftSweeper : UserControl, IShiftOSWindow { diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 1adc75a..fe2bf20 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -40,6 +40,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Shifter", true, "al_shifter", "Customization")] [RequiresUpgrade("shifter")] [WinOpen("shifter")] diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index 45f37d4..c1c81d5 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -38,6 +38,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { [Launcher("Shiftnet", false, null, "Networking")] + [MultiplayerOnly] [DefaultIcon("iconShiftnet")] public partial class Shiftnet : UserControl, IShiftOSWindow { public Shiftnet() { diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index b3724ae..0580b47 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -39,6 +39,7 @@ namespace ShiftOS.WinForms.Applications { [Launcher("Shiftorium", true, "al_shiftorium", "Utilities")] [RequiresUpgrade("shiftorium_gui")] + [MultiplayerOnly] [WinOpen("shiftorium")] [DefaultTitle("Shiftorium")] [DefaultIcon("iconShiftorium")] diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index 52d8568..d9504d3 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -668,5 +668,15 @@ namespace ShiftOS.WinForms return true; } + + [Command("experience", description = "Marks a story plot as experienced without triggering the plot.", usage ="{id:}")] + [RequiresArgument("id")] + [RemoteLock] + public static bool Experience(Dictionary args) + { + SaveSystem.CurrentSave.StoriesExperienced.Add(args["id"].ToString()); + SaveSystem.SaveGame(); + return true; + } } } diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index b8f0cae..eeaa6c9 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -106,6 +106,24 @@ namespace ShiftOS.WinForms return; } + foreach(var attr in form.GetType().GetCustomAttributes(true)) + { + if(attr is MultiplayerOnlyAttribute) + { + if(KernelWatchdog.MudConnected == false) + { + Infobox.PromptYesNo("Disconnected from MUD", "This application requires a connection to the MUD. Would you like to reconnect?", new Action((answer) => + { + if(answer == true) + { + KernelWatchdog.MudConnected = true; + SetupWindow(form); + } + })); + return; + } + } + } if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType())) { diff --git a/ShiftOS_TheReturn/AppLauncherDaemon.cs b/ShiftOS_TheReturn/AppLauncherDaemon.cs index 7ef34c1..5e3bd72 100644 --- a/ShiftOS_TheReturn/AppLauncherDaemon.cs +++ b/ShiftOS_TheReturn/AppLauncherDaemon.cs @@ -66,12 +66,24 @@ namespace ShiftOS.Engine { foreach (var attr in type.GetCustomAttributes(false)) { - if (attr is LauncherAttribute) + bool isAllowed = true; + if(attr is MultiplayerOnlyAttribute) { - var launch = attr as LauncherAttribute; - if (launch.UpgradeInstalled) + if(KernelWatchdog.MudConnected == false) { - win.Add(new LauncherItem { DisplayData = launch, LaunchType = type }); + isAllowed = false; + + } + } + if (isAllowed == true) + { + if (attr is LauncherAttribute) + { + var launch = attr as LauncherAttribute; + if (launch.UpgradeInstalled) + { + win.Add(new LauncherItem { DisplayData = launch, LaunchType = type }); + } } } } diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs index 1b59b25..e69c9ba 100644 --- a/ShiftOS_TheReturn/KernelWatchdog.cs +++ b/ShiftOS_TheReturn/KernelWatchdog.cs @@ -25,8 +25,44 @@ namespace ShiftOS.Engine } } + private static bool _mudConnected = true; + public static bool InKernelMode { get; private set; } - public static bool MudConnected { get; set; } + public static bool MudConnected + { + get + { + return _mudConnected; + } + set + { + if(value == false) + { + foreach(var win in AppearanceManager.OpenForms) + { + foreach(var attr in win.ParentWindow.GetType().GetCustomAttributes(true)) + { + if(attr is MultiplayerOnlyAttribute) + { + ConsoleEx.Bold = true; + ConsoleEx.Underline = false; + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.Red; + Console.Write("Error:"); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine("Cannot disconnect from multi-user domain because an app that depends on it is open."); + TerminalBackend.PrintPrompt(); + return; + } + } + } + } + + _mudConnected = value; + Desktop.PopulateAppLauncher(); + } + } public static bool IsSafe(Type type) { diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index bb65dc7..6768efb 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -67,11 +67,14 @@ namespace ShiftOS.Engine.Scripting { ServerManager.MessageReceived += (msg) => { - if(msg.Name == "run") + if (msg.Name == "run") { var cntnts = JsonConvert.DeserializeObject(msg.Contents); var interp = new LuaInterpreter(); - interp.Execute(cntnts.script.ToString()); + Desktop.InvokeOnWorkerThread(() => + { + interp.Execute(cntnts.script.ToString()); + }); } }; } From 26864e97ccd153bce3f266e2e5e001bd1d89b1f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 10 Mar 2017 18:57:55 -0500 Subject: [PATCH 21/27] Update VB skin converter --- ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb b/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb index 0a65a5e..161012d 100644 --- a/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb +++ b/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb @@ -206,7 +206,7 @@ Public Class SkinConverterCommands skn.Header2Font = New Font("Microsoft Sans Serif", 15, FontStyle.Regular) skn.Header3Font = New Font("Microsoft Sans Serif", 12.5, FontStyle.Regular) - skn.TerminalBackColor = Color.Black + skn.TerminalBackColorCC = ConsoleColor.Black Console.WriteLine(" ...done!") Console.WriteLine("Skin conversion complete.") From fa83ec01d2ae3623648cd4b055e5be069b87ec96 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 11 Mar 2017 08:11:27 -0500 Subject: [PATCH 22/27] even more uhhhhhhhhh --- ShiftOS_TheReturn.sln | 12 ++++++++++++ ShiftOS_TheReturn/TerminalBackend.cs | 1 + 2 files changed, 13 insertions(+) diff --git a/ShiftOS_TheReturn.sln b/ShiftOS_TheReturn.sln index 7f7acdf..a3eb2a0 100644 --- a/ShiftOS_TheReturn.sln +++ b/ShiftOS_TheReturn.sln @@ -21,6 +21,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModLauncher", "ModLauncher\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShiftOS.Server.WebAdmin", "ShiftOS.Server.WebAdmin\ShiftOS.Server.WebAdmin.csproj", "{B29FDD06-E6FE-40A2-8258-283728CED81A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gwen", "Gwen\Gwen.csproj", "{ADDA2F43-96C0-497F-8216-29C67ABC9806}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gwen.Renderer.OpenTK", "Gwen.Renderer.OpenTK\Gwen.Renderer.OpenTK.csproj", "{41650C82-D630-4E5C-845A-F1513C8FDC99}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -63,6 +67,14 @@ Global {B29FDD06-E6FE-40A2-8258-283728CED81A}.Debug|Any CPU.Build.0 = Debug|Any CPU {B29FDD06-E6FE-40A2-8258-283728CED81A}.Release|Any CPU.ActiveCfg = Release|Any CPU {B29FDD06-E6FE-40A2-8258-283728CED81A}.Release|Any CPU.Build.0 = Release|Any CPU + {ADDA2F43-96C0-497F-8216-29C67ABC9806}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ADDA2F43-96C0-497F-8216-29C67ABC9806}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ADDA2F43-96C0-497F-8216-29C67ABC9806}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ADDA2F43-96C0-497F-8216-29C67ABC9806}.Release|Any CPU.Build.0 = Release|Any CPU + {41650C82-D630-4E5C-845A-F1513C8FDC99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {41650C82-D630-4E5C-845A-F1513C8FDC99}.Debug|Any CPU.Build.0 = Debug|Any CPU + {41650C82-D630-4E5C-845A-F1513C8FDC99}.Release|Any CPU.ActiveCfg = Release|Any CPU + {41650C82-D630-4E5C-845A-F1513C8FDC99}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 5c08cfe..5022cd1 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -292,6 +292,7 @@ namespace ShiftOS.Engine ConsoleEx.ForegroundColor = ConsoleColor.Magenta; ConsoleEx.Bold = true; + Console.Write(SaveSystem.CurrentSave.Username); ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = ConsoleColor.Gray; From b9c3a0e30f6a939b1e1e3142cb507dfe7993b683 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 11 Mar 2017 08:32:13 -0500 Subject: [PATCH 23/27] Fix deadlocks in hacker commands. --- ShiftOS.WinForms/HackerCommands.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index d9504d3..59d0f4e 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -378,6 +378,8 @@ namespace ShiftOS.WinForms { Console.WriteLine("--operation took too long - failed."); ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); + ServerManager.MessageReceived -= msgReceived; + TerminalBackend.PrefixEnabled = true; return; } sw.Stop(); @@ -395,6 +397,7 @@ namespace ShiftOS.WinForms ServerManager.MessageReceived -= msgReceived; TerminalBackend.PrintPrompt(); } + TerminalBackend.PrefixEnabled = true; }; Console.WriteLine("--beginning brute-force attack on " + usr + "@" + sys + "..."); @@ -405,6 +408,7 @@ namespace ShiftOS.WinForms user = usr, sysname = sys })); + TerminalBackend.PrefixEnabled = false; Thread.Sleep(500); return true; } @@ -446,7 +450,7 @@ namespace ShiftOS.WinForms received = true; ServerManager.MessageReceived -= msgReceived; TerminalBackend.PrintPrompt(); - + } else if (msg.Name == "user_data_not_found") { @@ -455,6 +459,7 @@ namespace ShiftOS.WinForms ServerManager.MessageReceived -= msgReceived; TerminalBackend.PrintPrompt(); } + TerminalBackend.PrefixEnabled = true; }; Console.WriteLine("--contacting multi-user domain..."); @@ -466,6 +471,7 @@ namespace ShiftOS.WinForms sysname = sys })); Thread.Sleep(500); + TerminalBackend.PrefixEnabled = false; return true; } @@ -504,6 +510,7 @@ namespace ShiftOS.WinForms { Console.WriteLine("--can't steal this many codepoints from user."); ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); + TerminalBackend.PrefixEnabled = true; return; } @@ -527,6 +534,7 @@ namespace ShiftOS.WinForms ServerManager.MessageReceived -= msgReceived; TerminalBackend.PrintPrompt(); } + TerminalBackend.PrefixEnabled = true; }; Console.WriteLine("--contacting multi-user domain..."); @@ -539,7 +547,7 @@ namespace ShiftOS.WinForms sysname = sys })); Thread.Sleep(500); - + TerminalBackend.PrefixEnabled = false; return true; } @@ -580,6 +588,7 @@ namespace ShiftOS.WinForms ServerManager.MessageReceived -= msgReceived; } TerminalBackend.PrintPrompt(); + TerminalBackend.PrefixEnabled = true; }; Console.WriteLine("--contacting multi-user domain..."); @@ -592,7 +601,7 @@ namespace ShiftOS.WinForms sysname = sys })); Thread.Sleep(500); - + TerminalBackend.PrefixEnabled = false; return true; } From 49812bf46cb153af6bab8e2a095024da84fcc149 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 11 Mar 2017 09:04:45 -0500 Subject: [PATCH 24/27] Lock down various commands while offline. --- ShiftOS.WinForms/HackerCommands.cs | 6 + ShiftOS_TheReturn/Commands.cs | 50 +------ ShiftOS_TheReturn/KernelWatchdog.cs | 26 ++++ ShiftOS_TheReturn/TerminalBackend.cs | 213 +++++++++++++++++---------- 4 files changed, 172 insertions(+), 123 deletions(-) diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index 59d0f4e..f9d3bcc 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -351,6 +351,7 @@ namespace ShiftOS.WinForms const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_"; + [MultiplayerOnly] [Command("breach_user_password")] [KernelMode] [RequiresArgument("user")] @@ -413,6 +414,8 @@ namespace ShiftOS.WinForms return true; } + + [MultiplayerOnly] [Command("print_user_info")] [KernelMode] [RequiresArgument("pass")] @@ -475,6 +478,7 @@ namespace ShiftOS.WinForms return true; } + [MultiplayerOnly] [Command("steal_codepoints")] [KernelMode] [RequiresArgument("amount")] @@ -551,6 +555,7 @@ namespace ShiftOS.WinForms return true; } + [MultiplayerOnly] [Command("purge_user")] [KernelMode] [RequiresArgument("pass")] @@ -646,6 +651,7 @@ namespace ShiftOS.WinForms } } + [MultiplayerOnly] [Namespace("storydev")] public static class StoryDevCommands { diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 0ea00e5..12c371f 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -133,6 +133,7 @@ namespace ShiftOS.Engine [Namespace("mud")] public static class MUDCommands { + [MultiplayerOnly] [Command("status")] public static bool Status() { @@ -174,6 +175,7 @@ namespace ShiftOS.Engine return true; } + [MultiplayerOnly] [Command("disconnect")] [RequiresUpgrade("hacker101_deadaccts")] public static bool Disconnect() @@ -183,6 +185,7 @@ namespace ShiftOS.Engine return true; } + [MultiplayerOnly] [Command("sendmsg")] [KernelMode] [RequiresUpgrade("hacker101_deadaccts")] @@ -195,48 +198,6 @@ namespace ShiftOS.Engine } } - [RequiresUpgrade("mud_fundamentals")] - [Namespace("chat")] - public static class ChatCommands - { - [RequiresArgument("id")] - [RequiresArgument("name")] - [RequiresArgument("topic")] - [Command("create")] - public static bool CreateChat(Dictionary args) - { - string id = ""; - string topic = ""; - string name = ""; - int max_users = 0; - - id = args["id"] as string; - name = args["topic"] as string; - topic = args["name"] as string; - - bool valid = true; - - if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(topic)) - valid = false; - - if (valid) - { - ServerManager.SendMessage("chat_create", $@"{{ - id: ""{id}"", - name: ""{name}"", - topic: ""{topic}"", - max_users: {max_users} -}}"); - } - else - { - Console.WriteLine("{CHAT_PLEASE_PROVIDE_VALID_CHANNEL_DATA}"); - } - return true; - } - - } - [TutorialLock] [Namespace("trm")] public static class TerminalCommands @@ -266,6 +227,7 @@ namespace ShiftOS.Engine } } + [MultiplayerOnly] [Namespace("dev")] public static class ShiftOSDevCommands { @@ -474,6 +436,7 @@ namespace ShiftOS.Engine return true; } + [MultiplayerOnly] [Command("save")] public static bool Save() { @@ -481,6 +444,7 @@ namespace ShiftOS.Engine return true; } + [MultiplayerOnly] [Command("status")] public static bool Status() { @@ -493,7 +457,7 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, } } - + [MultiplayerOnly] [Namespace("shiftorium")] public static class ShiftoriumCommands { diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs index e69c9ba..cc03f5a 100644 --- a/ShiftOS_TheReturn/KernelWatchdog.cs +++ b/ShiftOS_TheReturn/KernelWatchdog.cs @@ -102,5 +102,31 @@ namespace ShiftOS.Engine InKernelMode = false; Console.WriteLine(" Kernel mode disabled."); } + + internal static bool CanRunOffline(Type method) + { + if (MudConnected) + return true; + + foreach (var attr in method.GetCustomAttributes(false)) + { + if (attr is MultiplayerOnlyAttribute) + return false; + } + return true; + } + + internal static bool CanRunOffline(MethodInfo method) + { + if (MudConnected) + return true; + + foreach(var attr in method.GetCustomAttributes(false)) + { + if (attr is MultiplayerOnlyAttribute) + return false; + } + return true; + } } } diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 5022cd1..c7852f1 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -148,128 +148,181 @@ namespace ShiftOS.Engine { if (KernelWatchdog.IsSafe(type)) { - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + if (KernelWatchdog.CanRunOffline(type)) { - if (Shiftorium.UpgradeAttributesUnlocked(method)) + foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { - if (CanRunRemotely(method, isRemote)) + if (Shiftorium.UpgradeAttributesUnlocked(method)) { - foreach (var ma in method.GetCustomAttributes(false)) + if (CanRunRemotely(method, isRemote)) { - if (ma is Command) + foreach (var ma in method.GetCustomAttributes(false)) { - var cmd = ma as Command; - if (text.Split('.')[1] == cmd.name) + if (ma is Command) { - if (KernelWatchdog.IsSafe(method)) + var cmd = ma as Command; + if (text.Split('.')[1] == cmd.name) { - - var attr = method.GetCustomAttribute(); - - if (attr != null) + if (KernelWatchdog.IsSafe(method)) { - string newcommand = attr.newcommand; - if (attr.warn) + if (KernelWatchdog.CanRunOffline(method)) { - Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { + var attr = method.GetCustomAttribute(); + + if (attr != null) + { + string newcommand = attr.newcommand; + if (attr.warn) + { + Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { {"%newcommand", newcommand} })); - } - if (newcommand != "") - { - // redo the entire process running newcommand + } + if (newcommand != "") + { + // redo the entire process running newcommand - return RunClient(newcommand, args); - } - } + return RunClient(newcommand, args); + } + } - var requiresArgs = method.GetCustomAttributes(); + var requiresArgs = method.GetCustomAttributes(); - bool error = false; - bool providedusage = false; + bool error = false; + bool providedusage = false; - foreach (RequiresArgument argument in requiresArgs) - { - if (!args.ContainsKey(argument.argument)) - { - - if (!providedusage) + foreach (RequiresArgument argument in requiresArgs) { - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { + if (!args.ContainsKey(argument.argument)) + { + + if (!providedusage) + { + string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; + if (usageparse == Localization.Parse(usageparse)) + usageparse = ""; + else + usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { {"%ns", ns.name}, {"%cmd", cmd.name} }) : ""; - Console.WriteLine(usageparse); + Console.WriteLine(usageparse); - providedusage = true; - } + providedusage = true; + } - if (Shiftorium.UpgradeInstalled("help_usage")) - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { + if (Shiftorium.UpgradeInstalled("help_usage")) + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { {"%argument", argument.argument} })); - } - else - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); + } + else + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); + } + + error = true; + } } - error = true; + if (error) + { + throw new Exception("{ERROR_COMMAND_WRONG}"); + } + + try + { + return (bool)method.Invoke(null, new[] { args }); + } + catch (TargetInvocationException e) + { + Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); + Console.WriteLine(e.InnerException.Message); + Console.WriteLine(e.InnerException.StackTrace); + return true; + } + catch + { + return (bool)method.Invoke(null, new object[] { }); + } + } + else + { + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; + Console.Write("session_mgr"); + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + ConsoleEx.Bold = false; + Console.Write(">"); + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); + return true; + } } - - if (error) + else { - throw new Exception("{ERROR_COMMAND_WRONG}"); - } - - try - { - return (bool)method.Invoke(null, new[] { args }); - } - catch (TargetInvocationException e) - { - Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); - Console.WriteLine(e.InnerException.Message); - Console.WriteLine(e.InnerException.StackTrace); + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; + Console.Write("watchdog"); + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + ConsoleEx.Bold = false; + Console.Write(">"); + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(" You cannot run this command."); + KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); return true; } - catch - { - return (bool)method.Invoke(null, new object[] { }); - } - } - else - { - Console.WriteLine(" You cannot run this command."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); - return true; } + + } - - } } + else + { + Console.WriteLine(text + " cannot be ran in a remote session"); + return true; + } } - else - { - Console.WriteLine(text + " cannot be ran in a remote session"); - return true; - } + } + } + else + { + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; + Console.Write("session_mgr"); + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + ConsoleEx.Bold = false; + Console.Write(">"); + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); + return true; } - } else { - Console.WriteLine(" You cannot run this command."); + + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; + Console.Write("watchdog"); + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + ConsoleEx.Bold = false; + Console.Write(">"); + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(" You cannot run this command."); KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); return true; } From dad61e325cfcd1ce12ae6f29d3778d1c919c6ab3 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 11 Mar 2017 09:54:44 -0500 Subject: [PATCH 25/27] fix the hacker101 story some more --- ShiftOS.WinForms/Applications/TutorialBox.cs | 3 +++ ShiftOS.WinForms/HackerCommands.cs | 24 +++++++++++++++++--- ShiftOS_TheReturn/Scripting.cs | 4 ++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/ShiftOS.WinForms/Applications/TutorialBox.cs b/ShiftOS.WinForms/Applications/TutorialBox.cs index 25921e1..3c74443 100644 --- a/ShiftOS.WinForms/Applications/TutorialBox.cs +++ b/ShiftOS.WinForms/Applications/TutorialBox.cs @@ -21,6 +21,8 @@ namespace ShiftOS.WinForms.Applications InitializeComponent(); IsComplete = false; lbltuttext.Text = ""; + lbltuttext.Padding = new Padding(15); + lbltuttext.Margin = lbltuttext.Padding; } bool stillTyping = false; @@ -47,6 +49,7 @@ namespace ShiftOS.WinForms.Applications })); Thread.Sleep(75); } + Thread.Sleep(5000); stillTyping = false; }).Start(); } diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index f9d3bcc..e2c4d12 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -59,10 +59,25 @@ namespace ShiftOS.WinForms { private static void writeSlow(string text) { - Console.Write("[hacker101@undisclosed]: "); - Thread.Sleep(200); + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + ConsoleEx.Bold = false; + ConsoleEx.Italic = false; + Console.Write("["); + ConsoleEx.ForegroundColor = ConsoleColor.Magenta; + ConsoleEx.Bold = true; + Console.Write("hacker101"); + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + ConsoleEx.Italic = true; + Console.Write("@"); + ConsoleEx.ForegroundColor = ConsoleColor.White; + Console.Write("undisclosed"); + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + ConsoleEx.Bold = false; + ConsoleEx.Italic = false; + Console.Write("]: "); + Thread.Sleep(850); Console.WriteLine(text); - Thread.Sleep(1000); + Thread.Sleep(4000); } [Story("hacker101_deadaccts")] @@ -121,9 +136,12 @@ namespace ShiftOS.WinForms TerminalBackend.PrefixEnabled = true; Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); StartHackerTutorial(); + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); }); t.IsBackground = true; t.Start(); + TerminalBackend.PrefixEnabled = false; } internal static void StartHackerTutorial() diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index 6768efb..d96bc98 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -69,12 +69,16 @@ namespace ShiftOS.Engine.Scripting { if (msg.Name == "run") { + TerminalBackend.PrefixEnabled = false; var cntnts = JsonConvert.DeserializeObject(msg.Contents); var interp = new LuaInterpreter(); Desktop.InvokeOnWorkerThread(() => { interp.Execute(cntnts.script.ToString()); + }); + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); } }; } From 01420ff329ab1819f1be1ea444c46785328b44cb Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 11 Mar 2017 10:28:16 -0500 Subject: [PATCH 26/27] fix mud.connect deadlock --- ShiftOS.WinForms/HackerCommands.cs | 3 +- ShiftOS_TheReturn/Commands.cs | 2 + ShiftOS_TheReturn/ServerManager.cs | 2 + ShiftOS_TheReturn/TerminalBackend.cs | 57 +++++++++++++++------------- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index e2c4d12..107343b 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -158,8 +158,7 @@ namespace ShiftOS.WinForms int tutPos = 0; Action ondec = () => { - if (tutPos == 2) - tutPos++; + tutPos++; }; TerminalBackend.CommandProcessed += (o, a) => { diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 12c371f..7e517c1 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -156,6 +156,8 @@ namespace ShiftOS.Engine { Console.WriteLine("{ERROR}: " + ex.Message); } + + TerminalBackend.PrefixEnabled = false; return true; } catch (Exception ex) diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 4d599cd..31b3129 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -125,6 +125,8 @@ namespace ShiftOS.Engine { thisGuid = new Guid(msg.Contents); GUIDReceived?.Invoke(msg.Contents); + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); } else if(msg.Name == "allusers") { diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index c7852f1..e4bad33 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -339,35 +339,38 @@ namespace ShiftOS.Engine public static void PrintPrompt() { - ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; - ConsoleEx.Italic = false; - ConsoleEx.Underline = false; + if (SaveSystem.CurrentSave != null) + { + ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; + ConsoleEx.Italic = false; + ConsoleEx.Underline = false; - ConsoleEx.ForegroundColor = ConsoleColor.Magenta; - ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Magenta; + ConsoleEx.Bold = true; - Console.Write(SaveSystem.CurrentSave.Username); - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.Write("@"); - ConsoleEx.Italic = true; - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.Yellow; - Console.Write(SaveSystem.CurrentSave.SystemName); - ConsoleEx.Italic = false; - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.Write(":~"); - Console.ForegroundColor = ConsoleColor.White; - ConsoleEx.Italic = true; - if (KernelWatchdog.InKernelMode == true) - Console.Write("#"); - else - Console.Write("$"); - ConsoleEx.Italic = false; - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - Console.Write(" "); + Console.Write(SaveSystem.CurrentSave.Username); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + Console.Write("@"); + ConsoleEx.Italic = true; + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + Console.Write(SaveSystem.CurrentSave.SystemName); + ConsoleEx.Italic = false; + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + Console.Write(":~"); + Console.ForegroundColor = ConsoleColor.White; + ConsoleEx.Italic = true; + if (KernelWatchdog.InKernelMode == true) + Console.Write("#"); + else + Console.Write("$"); + ConsoleEx.Italic = false; + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + Console.Write(" "); + } } From 5a8cb0cdf76d65e096bd9aeda6ee9c6246a31134 Mon Sep 17 00:00:00 2001 From: AShifter Date: Sat, 11 Mar 2017 09:24:15 -0700 Subject: [PATCH 27/27] I don't think Michael liked the ShiftLotto limits so i fixed it - 1 billion limit combined --- ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs | 7 ++++++- ShiftOS.WinForms/Applications/ShiftLotto.cs | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs b/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs index 943322e..8b43636 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.Designer.cs @@ -129,7 +129,7 @@ namespace ShiftOS.WinForms.Applications // this.cpUpDown.Location = new System.Drawing.Point(22, 138); this.cpUpDown.Maximum = new decimal(new int[] { - 10000, + 1000000, 0, 0, 0}); @@ -150,6 +150,11 @@ namespace ShiftOS.WinForms.Applications // difUpDown // this.difUpDown.Location = new System.Drawing.Point(299, 138); + this.difUpDown.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); this.difUpDown.Minimum = new decimal(new int[] { 10, 0, diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.cs b/ShiftOS.WinForms/Applications/ShiftLotto.cs index 7acba3e..4b1c983 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.cs @@ -81,7 +81,7 @@ namespace ShiftOS.WinForms.Applications int codePoints = Convert.ToInt32(Math.Round(cpUpDown.Value, 0)); int difficulty = Convert.ToInt32(Math.Round(difUpDown.Value, 0)); - if (SaveSystem.CurrentSave.Codepoints <= 1) + if (SaveSystem.CurrentSave.Codepoints <= 9) { Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to use ShiftLotto!"); } @@ -121,6 +121,8 @@ namespace ShiftOS.WinForms.Applications // Remove Codepoints SaveSystem.TransferCodepointsToVoid(jackpot); + + // Infobox Infobox.Show("YOU FAILED!", "Sorry! " + jackpot.ToString() + " CP has been removed from your account."); }