From 885f19f435681e514f9a9db025c220b6b126063e Mon Sep 17 00:00:00 2001 From: JC Snider Date: Sat, 28 Mar 2020 22:29:01 -0400 Subject: [PATCH 01/15] Update dev build number to 6.2 (#45) --- Intersect (Core)/Properties/AssemblyInfo.cs | 4 ++-- Intersect.Client.Framework/Properties/AssemblyInfo.cs | 4 ++-- Intersect.Client/Properties/AssemblyInfo.cs | 4 ++-- Intersect.Editor/Properties/AssemblyInfo.cs | 4 ++-- Intersect.Network/Properties/AssemblyInfo.cs | 4 ++-- Intersect.Server/Properties/AssemblyInfo.cs | 4 ++-- Intersect.Utilities/Properties/AssemblyInfo.cs | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Intersect (Core)/Properties/AssemblyInfo.cs b/Intersect (Core)/Properties/AssemblyInfo.cs index c6ce518186..99e5698bbb 100644 --- a/Intersect (Core)/Properties/AssemblyInfo.cs +++ b/Intersect (Core)/Properties/AssemblyInfo.cs @@ -38,5 +38,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.1.0")] -[assembly: AssemblyFileVersion("0.6.1.0")] +[assembly: AssemblyVersion("0.6.2.0")] +[assembly: AssemblyFileVersion("0.6.2.0")] diff --git a/Intersect.Client.Framework/Properties/AssemblyInfo.cs b/Intersect.Client.Framework/Properties/AssemblyInfo.cs index 7581d8fcf2..9f5c897cbe 100644 --- a/Intersect.Client.Framework/Properties/AssemblyInfo.cs +++ b/Intersect.Client.Framework/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.1.0")] -[assembly: AssemblyFileVersion("0.6.1.0")] +[assembly: AssemblyVersion("0.6.2.0")] +[assembly: AssemblyFileVersion("0.6.2.0")] diff --git a/Intersect.Client/Properties/AssemblyInfo.cs b/Intersect.Client/Properties/AssemblyInfo.cs index f9c52ff2f7..310c0395da 100644 --- a/Intersect.Client/Properties/AssemblyInfo.cs +++ b/Intersect.Client/Properties/AssemblyInfo.cs @@ -38,5 +38,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.1.0")] -[assembly: AssemblyFileVersion("0.6.1.0")] +[assembly: AssemblyVersion("0.6.2.0")] +[assembly: AssemblyFileVersion("0.6.2.0")] diff --git a/Intersect.Editor/Properties/AssemblyInfo.cs b/Intersect.Editor/Properties/AssemblyInfo.cs index 294e3dc85b..bb98d9d33e 100644 --- a/Intersect.Editor/Properties/AssemblyInfo.cs +++ b/Intersect.Editor/Properties/AssemblyInfo.cs @@ -38,5 +38,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.1.0")] -[assembly: AssemblyFileVersion("0.6.1.0")] +[assembly: AssemblyVersion("0.6.2.0")] +[assembly: AssemblyFileVersion("0.6.2.0")] diff --git a/Intersect.Network/Properties/AssemblyInfo.cs b/Intersect.Network/Properties/AssemblyInfo.cs index 96c498904f..cc43036dab 100644 --- a/Intersect.Network/Properties/AssemblyInfo.cs +++ b/Intersect.Network/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.1.0")] -[assembly: AssemblyFileVersion("0.6.1.0")] +[assembly: AssemblyVersion("0.6.2.0")] +[assembly: AssemblyFileVersion("0.6.2.0")] diff --git a/Intersect.Server/Properties/AssemblyInfo.cs b/Intersect.Server/Properties/AssemblyInfo.cs index e881ac39c4..5de6cc8a7f 100644 --- a/Intersect.Server/Properties/AssemblyInfo.cs +++ b/Intersect.Server/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Revision // -[assembly: AssemblyVersion("0.6.1.0")] -[assembly: AssemblyFileVersion("0.6.1.0")] +[assembly: AssemblyVersion("0.6.2.0")] +[assembly: AssemblyFileVersion("0.6.2.0")] diff --git a/Intersect.Utilities/Properties/AssemblyInfo.cs b/Intersect.Utilities/Properties/AssemblyInfo.cs index d305dd269d..f15060d56f 100644 --- a/Intersect.Utilities/Properties/AssemblyInfo.cs +++ b/Intersect.Utilities/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.1.0")] -[assembly: AssemblyFileVersion("0.6.1.0")] +[assembly: AssemblyVersion("0.6.2.0")] +[assembly: AssemblyFileVersion("0.6.2.0")] From cb7b3ec04942fa87ee0c77b91a89b4ee74c9836f Mon Sep 17 00:00:00 2001 From: Kibbelz Date: Mon, 30 Mar 2020 14:17:27 +0100 Subject: [PATCH 02/15] Added 4 new event variable operators (#46) Added: -Multiplication -Division -Left Bit Shift -Right Bit Shift --- Intersect (Core)/Enums/SwitchVariableTypes.cs | 25 ++ .../Forms/Editors/Events/CommandPrinter.cs | 64 ++++ ...EventCommand_ConditionalBranch.Designer.cs | 12 +- .../EventCommand_Variable.Designer.cs | 322 ++++++++++-------- .../Event Commands/EventCommand_Variable.cs | 170 ++++++++- Intersect.Editor/Localization/Strings.cs | 32 ++ .../Entities/Events/CommandProcessing.cs | 73 ++++ 7 files changed, 553 insertions(+), 145 deletions(-) diff --git a/Intersect (Core)/Enums/SwitchVariableTypes.cs b/Intersect (Core)/Enums/SwitchVariableTypes.cs index 73a2b55483..ebba45a7ed 100644 --- a/Intersect (Core)/Enums/SwitchVariableTypes.cs +++ b/Intersect (Core)/Enums/SwitchVariableTypes.cs @@ -23,6 +23,8 @@ public enum VariableTypes } + //Should properly seperate static value, player & global vars into a seperate enum. + //But technical debt :/ public enum VariableMods { @@ -50,6 +52,29 @@ public enum VariableMods Replace, + Multiply, + + MultiplyPlayerVar, + + MultiplyGlobalVar, + + Divide, + + DividePlayerVar, + + DivideGlobalVar, + + LeftShift, + + LeftShiftPlayerVar, + + LeftShiftGlobalVar, + + RightShift, + + RightShiftPlayerVar, + + RightShiftGlobalVar } public enum VariableComparators diff --git a/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs b/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs index b3497aa0d3..6137148339 100644 --- a/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs +++ b/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs @@ -1079,6 +1079,22 @@ private static string GetVariableModText(SetVariableCommand command, IntegerVari case Enums.VariableMods.Subtract: varvalue = Strings.EventCommandList.subtractvariable.ToString(mod.Value); + break; + case Enums.VariableMods.Multiply: + varvalue = Strings.EventCommandList.multiplyvariable.ToString(mod.Value); + + break; + case Enums.VariableMods.Divide: + varvalue = Strings.EventCommandList.dividevariable.ToString(mod.Value); + + break; + case Enums.VariableMods.LeftShift: + varvalue = Strings.EventCommandList.leftshiftvariable.ToString(mod.Value); + + break; + case Enums.VariableMods.RightShift: + varvalue = Strings.EventCommandList.rightshiftvariable.ToString(mod.Value); + break; case Enums.VariableMods.Random: varvalue = Strings.EventCommandList.randvariable.ToString(mod.Value, mod.HighValue); @@ -1123,6 +1139,54 @@ private static string GetVariableModText(SetVariableCommand command, IntegerVari ServerVariableBase.GetName(mod.DuplicateVariableId) ); + break; + case Enums.VariableMods.MultiplyPlayerVar: + varvalue = Strings.EventCommandList.multiplyplayervariable.ToString( + PlayerVariableBase.GetName(mod.DuplicateVariableId) + ); + + break; + case Enums.VariableMods.MultiplyGlobalVar: + varvalue = Strings.EventCommandList.multiplyglobalvariable.ToString( + ServerVariableBase.GetName(mod.DuplicateVariableId) + ); + + break; + case Enums.VariableMods.DividePlayerVar: + varvalue = Strings.EventCommandList.divideplayervariable.ToString( + PlayerVariableBase.GetName(mod.DuplicateVariableId) + ); + + break; + case Enums.VariableMods.DivideGlobalVar: + varvalue = Strings.EventCommandList.divideglobalvariable.ToString( + ServerVariableBase.GetName(mod.DuplicateVariableId) + ); + + break; + case Enums.VariableMods.LeftShiftPlayerVar: + varvalue = Strings.EventCommandList.leftshiftplayervariable.ToString( + PlayerVariableBase.GetName(mod.DuplicateVariableId) + ); + + break; + case Enums.VariableMods.LeftShiftGlobalVar: + varvalue = Strings.EventCommandList.leftshiftglobalvariable.ToString( + ServerVariableBase.GetName(mod.DuplicateVariableId) + ); + + break; + case Enums.VariableMods.RightShiftPlayerVar: + varvalue = Strings.EventCommandList.rightshiftplayervariable.ToString( + PlayerVariableBase.GetName(mod.DuplicateVariableId) + ); + + break; + case Enums.VariableMods.RightShiftGlobalVar: + varvalue = Strings.EventCommandList.rightshiftglobalvariable.ToString( + ServerVariableBase.GetName(mod.DuplicateVariableId) + ); + break; } diff --git a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_ConditionalBranch.Designer.cs b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_ConditionalBranch.Designer.cs index c17cd77097..e236aef297 100644 --- a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_ConditionalBranch.Designer.cs +++ b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_ConditionalBranch.Designer.cs @@ -592,14 +592,14 @@ private void InitializeComponent() this.nudVariableValue.ForeColor = System.Drawing.Color.Gainsboro; this.nudVariableValue.Location = new System.Drawing.Point(115, 48); this.nudVariableValue.Maximum = new decimal(new int[] { - 1000000000, - 0, - 0, + -1, + -1, + -1, 0}); this.nudVariableValue.Minimum = new decimal(new int[] { - 1000000000, - 0, - 0, + -1, + -1, + -1, -2147483648}); this.nudVariableValue.Name = "nudVariableValue"; this.nudVariableValue.Size = new System.Drawing.Size(125, 20); diff --git a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.Designer.cs b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.Designer.cs index 20ec2a8ab3..0b67b2fb0e 100644 --- a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.Designer.cs +++ b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.Designer.cs @@ -40,8 +40,17 @@ private void InitializeComponent() this.btnCancel = new DarkUI.Controls.DarkButton(); this.btnSave = new DarkUI.Controls.DarkButton(); this.grpStringVariable = new DarkUI.Controls.DarkGroupBox(); - this.txtStringValue = new DarkUI.Controls.DarkTextBox(); + this.lblStringTextVariables = new System.Windows.Forms.Label(); + this.grpStringReplace = new DarkUI.Controls.DarkGroupBox(); + this.txtStringReplace = new DarkUI.Controls.DarkTextBox(); + this.txtStringFind = new DarkUI.Controls.DarkTextBox(); + this.lblStringReplace = new System.Windows.Forms.Label(); + this.lblStringFind = new System.Windows.Forms.Label(); + this.optReplaceString = new DarkUI.Controls.DarkRadioButton(); this.optStaticString = new DarkUI.Controls.DarkRadioButton(); + this.grpStringSet = new DarkUI.Controls.DarkGroupBox(); + this.lblStringValue = new System.Windows.Forms.Label(); + this.txtStringValue = new DarkUI.Controls.DarkTextBox(); this.grpBooleanVariable = new DarkUI.Controls.DarkGroupBox(); this.cmbBooleanCloneGlobalVar = new DarkUI.Controls.DarkComboBox(); this.cmbBooleanClonePlayerVar = new DarkUI.Controls.DarkComboBox(); @@ -67,18 +76,15 @@ private void InitializeComponent() this.nudLow = new DarkUI.Controls.DarkNumericUpDown(); this.lblNumericRandomHigh = new System.Windows.Forms.Label(); this.lblNumericRandomLow = new System.Windows.Forms.Label(); - this.optReplaceString = new DarkUI.Controls.DarkRadioButton(); - this.grpStringReplace = new DarkUI.Controls.DarkGroupBox(); - this.lblStringReplace = new System.Windows.Forms.Label(); - this.lblStringFind = new System.Windows.Forms.Label(); - this.lblStringValue = new System.Windows.Forms.Label(); - this.txtStringFind = new DarkUI.Controls.DarkTextBox(); - this.txtStringReplace = new DarkUI.Controls.DarkTextBox(); - this.grpStringSet = new DarkUI.Controls.DarkGroupBox(); - this.lblStringTextVariables = new System.Windows.Forms.Label(); + this.optNumericMultiply = new DarkUI.Controls.DarkRadioButton(); + this.optNumericDivide = new DarkUI.Controls.DarkRadioButton(); + this.optNumericLeftShift = new DarkUI.Controls.DarkRadioButton(); + this.optNumericRightShift = new DarkUI.Controls.DarkRadioButton(); this.grpSetVariable.SuspendLayout(); this.grpSelectVariable.SuspendLayout(); this.grpStringVariable.SuspendLayout(); + this.grpStringReplace.SuspendLayout(); + this.grpStringSet.SuspendLayout(); this.grpBooleanVariable.SuspendLayout(); this.grpNumericVariable.SuspendLayout(); this.grpNumericValues.SuspendLayout(); @@ -86,8 +92,6 @@ private void InitializeComponent() this.grpNumericRandom.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudHigh)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudLow)).BeginInit(); - this.grpStringReplace.SuspendLayout(); - this.grpStringSet.SuspendLayout(); this.SuspendLayout(); // // grpSetVariable @@ -97,9 +101,9 @@ private void InitializeComponent() this.grpSetVariable.Controls.Add(this.grpSelectVariable); this.grpSetVariable.Controls.Add(this.btnCancel); this.grpSetVariable.Controls.Add(this.btnSave); + this.grpSetVariable.Controls.Add(this.grpNumericVariable); this.grpSetVariable.Controls.Add(this.grpStringVariable); this.grpSetVariable.Controls.Add(this.grpBooleanVariable); - this.grpSetVariable.Controls.Add(this.grpNumericVariable); this.grpSetVariable.ForeColor = System.Drawing.Color.Gainsboro; this.grpSetVariable.Location = new System.Drawing.Point(3, 3); this.grpSetVariable.Name = "grpSetVariable"; @@ -216,15 +220,82 @@ private void InitializeComponent() this.grpStringVariable.Text = "String Variable:"; this.grpStringVariable.Visible = false; // - // txtStringValue + // lblStringTextVariables // - this.txtStringValue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(69)))), ((int)(((byte)(73)))), ((int)(((byte)(74))))); - this.txtStringValue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtStringValue.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220))))); - this.txtStringValue.Location = new System.Drawing.Point(71, 25); - this.txtStringValue.Name = "txtStringValue"; - this.txtStringValue.Size = new System.Drawing.Size(207, 20); - this.txtStringValue.TabIndex = 62; + this.lblStringTextVariables.AutoSize = true; + this.lblStringTextVariables.BackColor = System.Drawing.Color.Transparent; + this.lblStringTextVariables.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblStringTextVariables.ForeColor = System.Drawing.SystemColors.MenuHighlight; + this.lblStringTextVariables.Location = new System.Drawing.Point(6, 159); + this.lblStringTextVariables.Name = "lblStringTextVariables"; + this.lblStringTextVariables.Size = new System.Drawing.Size(249, 13); + this.lblStringTextVariables.TabIndex = 68; + this.lblStringTextVariables.Text = "Text variables work with strings. Click here for a list!"; + this.lblStringTextVariables.Click += new System.EventHandler(this.lblStringTextVariables_Click); + // + // grpStringReplace + // + this.grpStringReplace.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65))))); + this.grpStringReplace.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90))))); + this.grpStringReplace.Controls.Add(this.txtStringReplace); + this.grpStringReplace.Controls.Add(this.txtStringFind); + this.grpStringReplace.Controls.Add(this.lblStringReplace); + this.grpStringReplace.Controls.Add(this.lblStringFind); + this.grpStringReplace.ForeColor = System.Drawing.Color.Gainsboro; + this.grpStringReplace.Location = new System.Drawing.Point(6, 55); + this.grpStringReplace.Name = "grpStringReplace"; + this.grpStringReplace.Size = new System.Drawing.Size(284, 90); + this.grpStringReplace.TabIndex = 65; + this.grpStringReplace.TabStop = false; + this.grpStringReplace.Text = "Replace"; + // + // txtStringReplace + // + this.txtStringReplace.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(69)))), ((int)(((byte)(73)))), ((int)(((byte)(74))))); + this.txtStringReplace.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtStringReplace.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220))))); + this.txtStringReplace.Location = new System.Drawing.Point(77, 52); + this.txtStringReplace.Name = "txtStringReplace"; + this.txtStringReplace.Size = new System.Drawing.Size(201, 20); + this.txtStringReplace.TabIndex = 64; + // + // txtStringFind + // + this.txtStringFind.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(69)))), ((int)(((byte)(73)))), ((int)(((byte)(74))))); + this.txtStringFind.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtStringFind.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220))))); + this.txtStringFind.Location = new System.Drawing.Point(77, 20); + this.txtStringFind.Name = "txtStringFind"; + this.txtStringFind.Size = new System.Drawing.Size(201, 20); + this.txtStringFind.TabIndex = 63; + // + // lblStringReplace + // + this.lblStringReplace.AutoSize = true; + this.lblStringReplace.Location = new System.Drawing.Point(9, 54); + this.lblStringReplace.Name = "lblStringReplace"; + this.lblStringReplace.Size = new System.Drawing.Size(47, 13); + this.lblStringReplace.TabIndex = 39; + this.lblStringReplace.Text = "Replace"; + // + // lblStringFind + // + this.lblStringFind.AutoSize = true; + this.lblStringFind.Location = new System.Drawing.Point(11, 27); + this.lblStringFind.Name = "lblStringFind"; + this.lblStringFind.Size = new System.Drawing.Size(27, 13); + this.lblStringFind.TabIndex = 40; + this.lblStringFind.Text = "Find"; + // + // optReplaceString + // + this.optReplaceString.AutoSize = true; + this.optReplaceString.Location = new System.Drawing.Point(62, 19); + this.optReplaceString.Name = "optReplaceString"; + this.optReplaceString.Size = new System.Drawing.Size(65, 17); + this.optReplaceString.TabIndex = 63; + this.optReplaceString.Text = "Replace"; + this.optReplaceString.CheckedChanged += new System.EventHandler(this.optReplaceString_CheckedChanged); // // optStaticString // @@ -236,6 +307,39 @@ private void InitializeComponent() this.optStaticString.Text = "Set"; this.optStaticString.CheckedChanged += new System.EventHandler(this.optStaticString_CheckedChanged); // + // grpStringSet + // + this.grpStringSet.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65))))); + this.grpStringSet.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90))))); + this.grpStringSet.Controls.Add(this.lblStringValue); + this.grpStringSet.Controls.Add(this.txtStringValue); + this.grpStringSet.ForeColor = System.Drawing.Color.Gainsboro; + this.grpStringSet.Location = new System.Drawing.Point(6, 55); + this.grpStringSet.Name = "grpStringSet"; + this.grpStringSet.Size = new System.Drawing.Size(284, 90); + this.grpStringSet.TabIndex = 67; + this.grpStringSet.TabStop = false; + this.grpStringSet.Text = "Set"; + // + // lblStringValue + // + this.lblStringValue.AutoSize = true; + this.lblStringValue.Location = new System.Drawing.Point(6, 28); + this.lblStringValue.Name = "lblStringValue"; + this.lblStringValue.Size = new System.Drawing.Size(37, 13); + this.lblStringValue.TabIndex = 66; + this.lblStringValue.Text = "Value:"; + // + // txtStringValue + // + this.txtStringValue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(69)))), ((int)(((byte)(73)))), ((int)(((byte)(74))))); + this.txtStringValue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtStringValue.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220))))); + this.txtStringValue.Location = new System.Drawing.Point(71, 25); + this.txtStringValue.Name = "txtStringValue"; + this.txtStringValue.Size = new System.Drawing.Size(207, 20); + this.txtStringValue.TabIndex = 62; + // // grpBooleanVariable // this.grpBooleanVariable.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65))))); @@ -336,6 +440,10 @@ private void InitializeComponent() // this.grpNumericVariable.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65))))); this.grpNumericVariable.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90))))); + this.grpNumericVariable.Controls.Add(this.optNumericRightShift); + this.grpNumericVariable.Controls.Add(this.optNumericLeftShift); + this.grpNumericVariable.Controls.Add(this.optNumericDivide); + this.grpNumericVariable.Controls.Add(this.optNumericMultiply); this.grpNumericVariable.Controls.Add(this.optNumericSet); this.grpNumericVariable.Controls.Add(this.optNumericAdd); this.grpNumericVariable.Controls.Add(this.optNumericRandom); @@ -364,7 +472,7 @@ private void InitializeComponent() // optNumericAdd // this.optNumericAdd.AutoSize = true; - this.optNumericAdd.Location = new System.Drawing.Point(57, 19); + this.optNumericAdd.Location = new System.Drawing.Point(50, 19); this.optNumericAdd.Name = "optNumericAdd"; this.optNumericAdd.Size = new System.Drawing.Size(44, 17); this.optNumericAdd.TabIndex = 25; @@ -374,7 +482,7 @@ private void InitializeComponent() // optNumericRandom // this.optNumericRandom.AutoSize = true; - this.optNumericRandom.Location = new System.Drawing.Point(178, 19); + this.optNumericRandom.Location = new System.Drawing.Point(116, 42); this.optNumericRandom.Name = "optNumericRandom"; this.optNumericRandom.Size = new System.Drawing.Size(65, 17); this.optNumericRandom.TabIndex = 23; @@ -384,7 +492,7 @@ private void InitializeComponent() // optNumericSubtract // this.optNumericSubtract.AutoSize = true; - this.optNumericSubtract.Location = new System.Drawing.Point(107, 19); + this.optNumericSubtract.Location = new System.Drawing.Point(98, 19); this.optNumericSubtract.Name = "optNumericSubtract"; this.optNumericSubtract.Size = new System.Drawing.Size(65, 17); this.optNumericSubtract.TabIndex = 24; @@ -393,9 +501,9 @@ private void InitializeComponent() // // optNumericSystemTime // - this.optNumericSystemTime.Location = new System.Drawing.Point(9, 42); + this.optNumericSystemTime.Location = new System.Drawing.Point(181, 42); this.optNumericSystemTime.Name = "optNumericSystemTime"; - this.optNumericSystemTime.Size = new System.Drawing.Size(125, 17); + this.optNumericSystemTime.Size = new System.Drawing.Size(109, 17); this.optNumericSystemTime.TabIndex = 39; this.optNumericSystemTime.Text = "System Time (Ms)"; this.optNumericSystemTime.CheckedChanged += new System.EventHandler(this.optNumericSystemTime_CheckedChanged); @@ -423,14 +531,14 @@ private void InitializeComponent() this.nudNumericValue.ForeColor = System.Drawing.Color.Gainsboro; this.nudNumericValue.Location = new System.Drawing.Point(143, 9); this.nudNumericValue.Maximum = new decimal(new int[] { - 1000000000, - 0, - 0, + -1, + -1, + -1, 0}); this.nudNumericValue.Minimum = new decimal(new int[] { - 1000000000, - 0, - 0, + -1, + -1, + -1, -2147483648}); this.nudNumericValue.Name = "nudNumericValue"; this.nudNumericValue.Size = new System.Drawing.Size(125, 20); @@ -596,105 +704,45 @@ private void InitializeComponent() this.lblNumericRandomLow.TabIndex = 40; this.lblNumericRandomLow.Text = "Low"; // - // optReplaceString - // - this.optReplaceString.AutoSize = true; - this.optReplaceString.Location = new System.Drawing.Point(62, 19); - this.optReplaceString.Name = "optReplaceString"; - this.optReplaceString.Size = new System.Drawing.Size(65, 17); - this.optReplaceString.TabIndex = 63; - this.optReplaceString.Text = "Replace"; - this.optReplaceString.CheckedChanged += new System.EventHandler(this.optReplaceString_CheckedChanged); - // - // grpStringReplace - // - this.grpStringReplace.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65))))); - this.grpStringReplace.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90))))); - this.grpStringReplace.Controls.Add(this.txtStringReplace); - this.grpStringReplace.Controls.Add(this.txtStringFind); - this.grpStringReplace.Controls.Add(this.lblStringReplace); - this.grpStringReplace.Controls.Add(this.lblStringFind); - this.grpStringReplace.ForeColor = System.Drawing.Color.Gainsboro; - this.grpStringReplace.Location = new System.Drawing.Point(6, 55); - this.grpStringReplace.Name = "grpStringReplace"; - this.grpStringReplace.Size = new System.Drawing.Size(284, 90); - this.grpStringReplace.TabIndex = 65; - this.grpStringReplace.TabStop = false; - this.grpStringReplace.Text = "Replace"; - // - // lblStringReplace - // - this.lblStringReplace.AutoSize = true; - this.lblStringReplace.Location = new System.Drawing.Point(9, 54); - this.lblStringReplace.Name = "lblStringReplace"; - this.lblStringReplace.Size = new System.Drawing.Size(47, 13); - this.lblStringReplace.TabIndex = 39; - this.lblStringReplace.Text = "Replace"; - // - // lblStringFind - // - this.lblStringFind.AutoSize = true; - this.lblStringFind.Location = new System.Drawing.Point(11, 27); - this.lblStringFind.Name = "lblStringFind"; - this.lblStringFind.Size = new System.Drawing.Size(27, 13); - this.lblStringFind.TabIndex = 40; - this.lblStringFind.Text = "Find"; - // - // lblStringValue - // - this.lblStringValue.AutoSize = true; - this.lblStringValue.Location = new System.Drawing.Point(6, 28); - this.lblStringValue.Name = "lblStringValue"; - this.lblStringValue.Size = new System.Drawing.Size(37, 13); - this.lblStringValue.TabIndex = 66; - this.lblStringValue.Text = "Value:"; - // - // txtStringFind - // - this.txtStringFind.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(69)))), ((int)(((byte)(73)))), ((int)(((byte)(74))))); - this.txtStringFind.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtStringFind.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220))))); - this.txtStringFind.Location = new System.Drawing.Point(77, 20); - this.txtStringFind.Name = "txtStringFind"; - this.txtStringFind.Size = new System.Drawing.Size(201, 20); - this.txtStringFind.TabIndex = 63; - // - // txtStringReplace - // - this.txtStringReplace.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(69)))), ((int)(((byte)(73)))), ((int)(((byte)(74))))); - this.txtStringReplace.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtStringReplace.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220))))); - this.txtStringReplace.Location = new System.Drawing.Point(77, 52); - this.txtStringReplace.Name = "txtStringReplace"; - this.txtStringReplace.Size = new System.Drawing.Size(201, 20); - this.txtStringReplace.TabIndex = 64; - // - // grpStringSet - // - this.grpStringSet.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65))))); - this.grpStringSet.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90))))); - this.grpStringSet.Controls.Add(this.lblStringValue); - this.grpStringSet.Controls.Add(this.txtStringValue); - this.grpStringSet.ForeColor = System.Drawing.Color.Gainsboro; - this.grpStringSet.Location = new System.Drawing.Point(6, 55); - this.grpStringSet.Name = "grpStringSet"; - this.grpStringSet.Size = new System.Drawing.Size(284, 90); - this.grpStringSet.TabIndex = 67; - this.grpStringSet.TabStop = false; - this.grpStringSet.Text = "Set"; - // - // lblStringTextVariables - // - this.lblStringTextVariables.AutoSize = true; - this.lblStringTextVariables.BackColor = System.Drawing.Color.Transparent; - this.lblStringTextVariables.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblStringTextVariables.ForeColor = System.Drawing.SystemColors.MenuHighlight; - this.lblStringTextVariables.Location = new System.Drawing.Point(6, 159); - this.lblStringTextVariables.Name = "lblStringTextVariables"; - this.lblStringTextVariables.Size = new System.Drawing.Size(249, 13); - this.lblStringTextVariables.TabIndex = 68; - this.lblStringTextVariables.Text = "Text variables work with strings. Click here for a list!"; - this.lblStringTextVariables.Click += new System.EventHandler(this.lblStringTextVariables_Click); + // optNumericMultiply + // + this.optNumericMultiply.AutoSize = true; + this.optNumericMultiply.Location = new System.Drawing.Point(169, 19); + this.optNumericMultiply.Name = "optNumericMultiply"; + this.optNumericMultiply.Size = new System.Drawing.Size(60, 17); + this.optNumericMultiply.TabIndex = 40; + this.optNumericMultiply.Text = "Multiply"; + this.optNumericMultiply.CheckedChanged += new System.EventHandler(this.optNumericMultiply_CheckedChanged); + // + // optNumericDivide + // + this.optNumericDivide.AutoSize = true; + this.optNumericDivide.Location = new System.Drawing.Point(235, 19); + this.optNumericDivide.Name = "optNumericDivide"; + this.optNumericDivide.Size = new System.Drawing.Size(55, 17); + this.optNumericDivide.TabIndex = 41; + this.optNumericDivide.Text = "Divide"; + this.optNumericDivide.CheckedChanged += new System.EventHandler(this.optNumericDivide_CheckedChanged); + // + // optNumericLeftShift + // + this.optNumericLeftShift.AutoSize = true; + this.optNumericLeftShift.Location = new System.Drawing.Point(9, 42); + this.optNumericLeftShift.Name = "optNumericLeftShift"; + this.optNumericLeftShift.Size = new System.Drawing.Size(52, 17); + this.optNumericLeftShift.TabIndex = 42; + this.optNumericLeftShift.Text = "LShift"; + this.optNumericLeftShift.CheckedChanged += new System.EventHandler(this.optNumericLeftShift_CheckedChanged); + // + // optNumericRightShift + // + this.optNumericRightShift.AutoSize = true; + this.optNumericRightShift.Location = new System.Drawing.Point(62, 42); + this.optNumericRightShift.Name = "optNumericRightShift"; + this.optNumericRightShift.Size = new System.Drawing.Size(54, 17); + this.optNumericRightShift.TabIndex = 43; + this.optNumericRightShift.Text = "RShift"; + this.optNumericRightShift.CheckedChanged += new System.EventHandler(this.optNumericRightShift_CheckedChanged); // // EventCommandVariable // @@ -710,6 +758,10 @@ private void InitializeComponent() this.grpSelectVariable.PerformLayout(); this.grpStringVariable.ResumeLayout(false); this.grpStringVariable.PerformLayout(); + this.grpStringReplace.ResumeLayout(false); + this.grpStringReplace.PerformLayout(); + this.grpStringSet.ResumeLayout(false); + this.grpStringSet.PerformLayout(); this.grpBooleanVariable.ResumeLayout(false); this.grpBooleanVariable.PerformLayout(); this.grpNumericVariable.ResumeLayout(false); @@ -721,10 +773,6 @@ private void InitializeComponent() this.grpNumericRandom.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudHigh)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudLow)).EndInit(); - this.grpStringReplace.ResumeLayout(false); - this.grpStringReplace.PerformLayout(); - this.grpStringSet.ResumeLayout(false); - this.grpStringSet.PerformLayout(); this.ResumeLayout(false); } @@ -776,5 +824,9 @@ private void InitializeComponent() private DarkRadioButton optStaticString; private DarkGroupBox grpStringSet; private System.Windows.Forms.Label lblStringTextVariables; + internal DarkRadioButton optNumericRightShift; + internal DarkRadioButton optNumericLeftShift; + internal DarkRadioButton optNumericDivide; + internal DarkRadioButton optNumericMultiply; } } diff --git a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.cs b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.cs index 847c2ad276..48072b7bfc 100644 --- a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.cs +++ b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.cs @@ -69,6 +69,10 @@ private void InitLocalization() optNumericSet.Text = Strings.EventSetVariable.numericset; optNumericAdd.Text = Strings.EventSetVariable.numericadd; optNumericSubtract.Text = Strings.EventSetVariable.numericsubtract; + optNumericMultiply.Text = Strings.EventSetVariable.numericmultiply; + optNumericDivide.Text = Strings.EventSetVariable.numericdivide; + optNumericLeftShift.Text = Strings.EventSetVariable.numericleftshift; + optNumericRightShift.Text = Strings.EventSetVariable.numericrightshift; optNumericRandom.Text = Strings.EventSetVariable.numericrandom; optNumericSystemTime.Text = Strings.EventSetVariable.numericsystemtime; optNumericClonePlayerVar.Text = Strings.EventSetVariable.numericcloneplayervariablevalue; @@ -343,6 +347,8 @@ private void TryLoadNumericMod(VariableMod varMod) { var mod = (IntegerVariableMod) varMod; + //Should properly seperate static value, player & global vars into a seperate enum. + //But technical debt :/ switch (mod.ModType) { case VariableMods.Set: @@ -366,6 +372,34 @@ private void TryLoadNumericMod(VariableMod varMod) break; + case VariableMods.Multiply: + optNumericMultiply.Checked = true; + optNumericStaticVal.Checked = true; + nudNumericValue.Value = mod.Value; + + break; + + case VariableMods.Divide: + optNumericDivide.Checked = true; + optNumericStaticVal.Checked = true; + nudNumericValue.Value = mod.Value; + + break; + + case VariableMods.LeftShift: + optNumericLeftShift.Checked = true; + optNumericStaticVal.Checked = true; + nudNumericValue.Value = mod.Value; + + break; + + case VariableMods.RightShift: + optNumericRightShift.Checked = true; + optNumericStaticVal.Checked = true; + nudNumericValue.Value = mod.Value; + + break; + case VariableMods.Random: optNumericRandom.Checked = true; nudLow.Value = mod.Value; @@ -418,6 +452,62 @@ private void TryLoadNumericMod(VariableMod varMod) optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); + break; + + case VariableMods.MultiplyPlayerVar: + optNumericMultiply.Checked = true; + optNumericClonePlayerVar.Checked = true; + cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); + + break; + + case VariableMods.MultiplyGlobalVar: + optNumericMultiply.Checked = true; + optNumericCloneGlobalVar.Checked = true; + cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); + + break; + + case VariableMods.DividePlayerVar: + optNumericDivide.Checked = true; + optNumericClonePlayerVar.Checked = true; + cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); + + break; + + case VariableMods.DivideGlobalVar: + optNumericDivide.Checked = true; + optNumericCloneGlobalVar.Checked = true; + cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); + + break; + + case VariableMods.LeftShiftPlayerVar: + optNumericLeftShift.Checked = true; + optNumericClonePlayerVar.Checked = true; + cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); + + break; + + case VariableMods.LeftShiftGlobalVar: + optNumericLeftShift.Checked = true; + optNumericCloneGlobalVar.Checked = true; + cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); + + break; + + case VariableMods.RightShiftPlayerVar: + optNumericRightShift.Checked = true; + optNumericClonePlayerVar.Checked = true; + cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); + + break; + + case VariableMods.RightShiftGlobalVar: + optNumericRightShift.Checked = true; + optNumericCloneGlobalVar.Checked = true; + cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); + break; } } @@ -426,7 +516,8 @@ private void TryLoadNumericMod(VariableMod varMod) private void UpdateNumericFormElements() { grpNumericRandom.Visible = optNumericRandom.Checked; - grpNumericValues.Visible = optNumericAdd.Checked | optNumericSubtract.Checked | optNumericSet.Checked; + grpNumericValues.Visible = optNumericAdd.Checked | optNumericSubtract.Checked | optNumericSet.Checked | optNumericMultiply.Checked | + optNumericDivide.Checked | optNumericLeftShift.Checked | optNumericRightShift.Checked; } private void optNumericSet_CheckedChanged(object sender, EventArgs e) @@ -444,6 +535,26 @@ private void optNumericSubtract_CheckedChanged(object sender, EventArgs e) UpdateNumericFormElements(); } + private void optNumericMultiply_CheckedChanged(object sender, EventArgs e) + { + UpdateNumericFormElements(); + } + + private void optNumericDivide_CheckedChanged(object sender, EventArgs e) + { + UpdateNumericFormElements(); + } + + private void optNumericLeftShift_CheckedChanged(object sender, EventArgs e) + { + UpdateNumericFormElements(); + } + + private void optNumericRightShift_CheckedChanged(object sender, EventArgs e) + { + UpdateNumericFormElements(); + } + private void optNumericRandom_CheckedChanged(object sender, EventArgs e) { UpdateNumericFormElements(); @@ -482,6 +593,26 @@ private IntegerVariableMod GetNumericVariableMod() mod.ModType = VariableMods.Subtract; mod.Value = (int) nudNumericValue.Value; } + else if (optNumericMultiply.Checked && optNumericStaticVal.Checked) + { + mod.ModType = VariableMods.Multiply; + mod.Value = (int)nudNumericValue.Value; + } + else if (optNumericDivide.Checked && optNumericStaticVal.Checked) + { + mod.ModType = VariableMods.Divide; + mod.Value = (int)nudNumericValue.Value; + } + else if (optNumericLeftShift.Checked && optNumericStaticVal.Checked) + { + mod.ModType = VariableMods.LeftShift; + mod.Value = (int)nudNumericValue.Value; + } + else if (optNumericRightShift.Checked && optNumericStaticVal.Checked) + { + mod.ModType = VariableMods.RightShift; + mod.Value = (int)nudNumericValue.Value; + } else if (optNumericRandom.Checked) { mod.ModType = VariableMods.Random; @@ -508,10 +639,26 @@ private IntegerVariableMod GetNumericVariableMod() { mod.ModType = VariableMods.AddPlayerVar; } - else + else if (optNumericSubtract.Checked) { mod.ModType = VariableMods.SubtractPlayerVar; } + else if (optNumericMultiply.Checked) + { + mod.ModType = VariableMods.MultiplyPlayerVar; + } + else if (optNumericDivide.Checked) + { + mod.ModType = VariableMods.DividePlayerVar; + } + else if (optNumericLeftShift.Checked) + { + mod.ModType = VariableMods.LeftShiftPlayerVar; + } + else + { + mod.ModType = VariableMods.RightShiftPlayerVar; + } mod.DuplicateVariableId = PlayerVariableBase.IdFromList(cmbNumericClonePlayerVar.SelectedIndex); } @@ -525,10 +672,26 @@ private IntegerVariableMod GetNumericVariableMod() { mod.ModType = VariableMods.AddGlobalVar; } - else + else if (optNumericSubtract.Checked) { mod.ModType = VariableMods.SubtractGlobalVar; } + else if (optNumericMultiply.Checked) + { + mod.ModType = VariableMods.MultiplyGlobalVar; + } + else if (optNumericDivide.Checked) + { + mod.ModType = VariableMods.DivideGlobalVar; + } + else if (optNumericLeftShift.Checked) + { + mod.ModType = VariableMods.LeftShiftGlobalVar; + } + else + { + mod.ModType = VariableMods.RightShiftGlobalVar; + } mod.DuplicateVariableId = ServerVariableBase.IdFromList(cmbNumericCloneGlobalVar.SelectedIndex); } @@ -610,7 +773,6 @@ private void optReplaceString_CheckedChanged(object sender, EventArgs e) } #endregion - } } diff --git a/Intersect.Editor/Localization/Strings.cs b/Intersect.Editor/Localization/Strings.cs index 7432fe66ef..d21c0a94a5 100644 --- a/Intersect.Editor/Localization/Strings.cs +++ b/Intersect.Editor/Localization/Strings.cs @@ -1423,6 +1423,8 @@ public struct EventCommandList public static LocalizedString despawnnpcs = @"Despawn NPCs"; + public static LocalizedString dividevariable = @"Divide {00}"; + public static LocalizedString dupglobalvariable = @"Global Variable: {00}'s Value"; public static LocalizedString dupplayervariable = @"Player Variable: {00}'s Value"; @@ -1435,6 +1437,22 @@ public struct EventCommandList public static LocalizedString subtractplayervariable = @"Subtract Player Variable: {00}'s Value"; + public static LocalizedString multiplyglobalvariable = @"Multiply Global Variable: {00}'s Value"; + + public static LocalizedString multiplyplayervariable = @"Multiply Player Variable: {00}'s Value"; + + public static LocalizedString divideglobalvariable = @"Divide Global Variable: {00}'s Value"; + + public static LocalizedString divideplayervariable = @"Divide Player Variable: {00}'s Value"; + + public static LocalizedString leftshiftglobalvariable = @"Left Bit Shift Global Variable: {00}'s Value"; + + public static LocalizedString leftshiftplayervariable = @"Left Bit Shift Player Variable: {00}'s Value"; + + public static LocalizedString rightshiftglobalvariable = @"Right Bit Shift Global Variable: {00}'s Value"; + + public static LocalizedString rightshiftplayervariable = @"Right Bit Shift Player Variable: {00}'s Value"; + public static LocalizedString enditemchange = @"End Item Change"; public static LocalizedString endoptions = @"End Options"; @@ -1481,6 +1499,8 @@ public struct EventCommandList public static LocalizedString label = @"Label: {00}"; + public static LocalizedString leftshiftvariable = @"Left Bit Shift {00}"; + public static LocalizedString levelup = @"Level Up Player"; public static LocalizedString linestart = @"@>"; @@ -1497,6 +1517,8 @@ public struct EventCommandList public static LocalizedString moverouteplayer = @"Player"; + public static LocalizedString multiplyvariable = @"Multiply {00}"; + public static LocalizedString notcommon = @"Cannot use this command in common events."; public static LocalizedString notcommoncaption = @"Common Event Warning!"; @@ -1534,6 +1556,8 @@ public struct EventCommandList public static LocalizedString restorempby = @"Adjust Player MP ({00})"; + public static LocalizedString rightshiftvariable = @"Right Bit Shift {00}"; + public static LocalizedString runcompletionevent = @"Running Completion Event"; public static LocalizedString selfswitch = @"Set Self Switch {00} to {01}"; @@ -2469,10 +2493,16 @@ public struct EventSetVariable public static LocalizedString numericadd = @"Add"; + public static LocalizedString numericdivide = @"Divide"; + + public static LocalizedString numericleftshift = @"LShift"; + public static LocalizedString numericcloneglobalvariablevalue = @"Global Variable Value: "; public static LocalizedString numericcloneplayervariablevalue = @"Player Variable Value: "; + public static LocalizedString numericmultiply = @"Multiply"; + public static LocalizedString numericrandom = @"Random"; public static LocalizedString numericrandomhigh = @"High:"; @@ -2481,6 +2511,8 @@ public struct EventSetVariable public static LocalizedString numericrandomdesc = @"Random Number:"; + public static LocalizedString numericrightshift = @"RShift"; + public static LocalizedString numericset = @"Set"; public static LocalizedString numericsubtract = @"Subtract"; diff --git a/Intersect.Server/Entities/Events/CommandProcessing.cs b/Intersect.Server/Entities/Events/CommandProcessing.cs index 27d1e0bc7e..c52bbc6b51 100644 --- a/Intersect.Server/Entities/Events/CommandProcessing.cs +++ b/Intersect.Server/Entities/Events/CommandProcessing.cs @@ -1506,6 +1506,25 @@ Event instance case Enums.VariableMods.Subtract: value.Integer -= mod.Value; + break; + case Enums.VariableMods.Multiply: + value.Integer *= mod.Value; + + break; + case Enums.VariableMods.Divide: + if (mod.Value != 0) //Idiot proofing divide by 0 LOL + { + value.Integer /= mod.Value; + } + + break; + case Enums.VariableMods.LeftShift: + value.Integer = value.Integer << (int)mod.Value; + + break; + case Enums.VariableMods.RightShift: + value.Integer = value.Integer >> (int)mod.Value; + break; case Enums.VariableMods.Random: //TODO: Fix - Random doesnt work with longs lolz @@ -1554,6 +1573,60 @@ Event instance value.Integer -= ssv.Value.Integer; } + break; + case Enums.VariableMods.MultiplyPlayerVar: + value.Integer *= player.GetVariableValue(mod.DuplicateVariableId).Integer; + + break; + case Enums.VariableMods.MultiplyGlobalVar: + var msv = ServerVariableBase.Get(mod.DuplicateVariableId); + if (msv != null) + { + value.Integer *= msv.Value.Integer; + } + + break; + case Enums.VariableMods.DividePlayerVar: + if (player.GetVariableValue(mod.DuplicateVariableId).Integer != 0) //Idiot proofing divide by 0 LOL + { + value.Integer /= player.GetVariableValue(mod.DuplicateVariableId).Integer; + } + + break; + case Enums.VariableMods.DivideGlobalVar: + var dsv = ServerVariableBase.Get(mod.DuplicateVariableId); + if (dsv != null) + { + if (dsv.Value != 0) //Idiot proofing divide by 0 LOL + { + value.Integer /= dsv.Value.Integer; + } + } + + break; + case Enums.VariableMods.LeftShiftPlayerVar: + value.Integer = value.Integer << (int)player.GetVariableValue(mod.DuplicateVariableId).Integer; + + break; + case Enums.VariableMods.LeftShiftGlobalVar: + var lhsv = ServerVariableBase.Get(mod.DuplicateVariableId); + if (lhsv != null) + { + value.Integer = value.Integer << (int)lhsv.Value.Integer; + } + + break; + case Enums.VariableMods.RightShiftPlayerVar: + value.Integer = value.Integer >> (int)player.GetVariableValue(mod.DuplicateVariableId).Integer; + + break; + case Enums.VariableMods.RightShiftGlobalVar: + var rhsv = ServerVariableBase.Get(mod.DuplicateVariableId); + if (rhsv != null) + { + value.Integer = value.Integer >> (int)rhsv.Value.Integer; + } + break; } From 5ef2b5fb567d129ea6533d5ea8e779525620b748 Mon Sep 17 00:00:00 2001 From: JC Snider Date: Mon, 30 Mar 2020 10:18:52 -0400 Subject: [PATCH 03/15] Fixing bugs (#47) (#48) * Should fix 198, server crash due to projectile trying to hit an event * Harden accept trade packet to return if counterparty is null. * Fixing potential NREs * Fixes another potential NRE and out of bounds error * Don't want to handle packets for null clients, but also don't want to be throwing exceptions * Fixes a small error where empty passwords crash the server during migration --- Intersect.Server/Database/DbInterface.cs | 3 ++- Intersect.Server/Entities/Player.cs | 5 +++++ Intersect.Server/Entities/ProjectileSpawn.cs | 2 ++ Intersect.Server/Networking/PacketHandler.cs | 6 ++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Intersect.Server/Database/DbInterface.cs b/Intersect.Server/Database/DbInterface.cs index d23dfe15a8..ddaf49ed26 100644 --- a/Intersect.Server/Database/DbInterface.cs +++ b/Intersect.Server/Database/DbInterface.cs @@ -373,6 +373,7 @@ public static User GetUser([NotNull] string username) public static Player GetUserCharacter(User user, Guid characterId) { + if (user == null) return null; foreach (var character in user.Players) { if (character.Id == characterId) @@ -1892,7 +1893,7 @@ public static string GetPassword() } else if (i.Key == ConsoleKey.Backspace) { - if (pwd.Length > 0) + if (pwd.Length > 1) { pwd = pwd.Remove(pwd.Length - 2, 1); Console.Write("\b \b"); diff --git a/Intersect.Server/Entities/Player.cs b/Intersect.Server/Entities/Player.cs index c5405e0452..f3289df37e 100644 --- a/Intersect.Server/Entities/Player.cs +++ b/Intersect.Server/Entities/Player.cs @@ -3316,6 +3316,11 @@ public void RevokeItem(int slot, int amount) return; } + if (slot < 0 || slot >= Trading.Offer.Length || Trading.Offer[slot] == null) + { + return; + } + var itemBase = ItemBase.Get(Trading.Offer[slot].ItemId); if (itemBase == null) { diff --git a/Intersect.Server/Entities/ProjectileSpawn.cs b/Intersect.Server/Entities/ProjectileSpawn.cs index a4a646297b..86bdff8eaf 100644 --- a/Intersect.Server/Entities/ProjectileSpawn.cs +++ b/Intersect.Server/Entities/ProjectileSpawn.cs @@ -2,6 +2,7 @@ using Intersect.GameObjects; using Intersect.Server.Entities.Combat; +using Intersect.Server.Entities.Events; using Intersect.Server.General; using Intersect.Server.Networking; @@ -58,6 +59,7 @@ public bool IsAtLocation(Guid mapId, int x, int y, int z) public bool HitEntity(Entity en) { var targetEntity = en; + if (targetEntity is EventPageInstance) return false; if (targetEntity != null && targetEntity != Parent.Owner) { if (targetEntity.GetType() == typeof(Player)) //Player diff --git a/Intersect.Server/Networking/PacketHandler.cs b/Intersect.Server/Networking/PacketHandler.cs index 6c4b2b40cb..f857a6891c 100644 --- a/Intersect.Server/Networking/PacketHandler.cs +++ b/Intersect.Server/Networking/PacketHandler.cs @@ -39,7 +39,7 @@ public bool PreProcessPacket(IConnection connection, long pSize) var client = Client.FindBeta4Client(connection); if (client == null) { - throw new Exception("Client is null!"); + return false; } if (client.Banned || client.FloodKicked) @@ -1646,7 +1646,7 @@ public void HandlePacket(Client client, Player player, [NotNull] RevokeTradeItem //AcceptTradePacket public void HandlePacket(Client client, Player player, AcceptTradePacket packet) { - if (player == null) + if (player == null || player.Trading.Counterparty == null) { return; } @@ -1866,6 +1866,7 @@ public void HandlePacket(Client client, Player player, FriendRequestResponsePack //SelectCharacterPacket public void HandlePacket(Client client, Player player, SelectCharacterPacket packet) { + if (client.User == null) return; var character = DbInterface.GetUserCharacter(client.User, packet.CharacterId); if (character != null) { @@ -1887,6 +1888,7 @@ public void HandlePacket(Client client, Player player, SelectCharacterPacket pac //DeleteCharacterPacket public void HandlePacket(Client client, Player player, DeleteCharacterPacket packet) { + if (client.User == null) return; var character = DbInterface.GetUserCharacter(client.User, packet.CharacterId); if (character != null) { From e6186b6127b5727930f4c2cb7ce167a3dc41b95c Mon Sep 17 00:00:00 2001 From: JC Snider Date: Tue, 31 Mar 2020 20:53:34 -0400 Subject: [PATCH 04/15] Merging bug fixes and other edits into development (#53) * Fixing bugs (#47) * Should fix 198, server crash due to projectile trying to hit an event * Harden accept trade packet to return if counterparty is null. * Fixing potential NREs * Fixes another potential NRE and out of bounds error * Don't want to handle packets for null clients, but also don't want to be throwing exceptions * Fixes a small error where empty passwords crash the server during migration * Updated licensing leading up to open source release (#49) * Create FUNDING.yml (#50) * Use dynamicsoundeffects for music instead of mediaplayer (#51) * Fixing bugs (#52) * Should fix 198, server crash due to projectile trying to hit an event * Harden accept trade packet to return if counterparty is null. * Fixing potential NREs * Fixes another potential NRE and out of bounds error * Don't want to handle packets for null clients, but also don't want to be throwing exceptions * Fixes a small error where empty passwords crash the server during migration * Small edit so that networking doesn't alter ui, only triggers ui to update next draw * Fixed events jumping all over the place * Allow checking of evtMap parameter even if no page instance has spawned * Basic bounds checking on pathfinding to potentially fix Weylon's bug. * Fix for events being able to step on traps. * Stop caching of expressions as they are used once * Fixed select character window not resetting paperdolls properly when cycling through characters * Fixes empty friends list when opening friends via a hotkey * Added server loop lock for when updating game objects (less likely to have deadlocks if not processing npcs when updating npcs, for example) * Fix collection changed bug when maps update while server loop is running * Fixes weird instance where the server would error while trying to send a map to a client who didn't have an entity set --- .github/FUNDING.yml | 13 + Documentation/Client/LICENSE.md | 2 +- Intersect (Core)/LICENSE.md | 2 +- Intersect.Client.Framework/LICENSE.md | 21 + .../Interface/Game/GameInterface.cs | 11 +- Intersect.Client/Interface/Game/Menu.cs | 6 +- .../Interface/Menu/SelectCharacterWindow.cs | 4 +- Intersect.Client/LICENSE.md | 2 +- .../MonoGame/Audio/MonoMusicInstance.cs | 84 ++- .../MonoGame/Audio/MonoMusicSource.cs | 68 +- Intersect.Client/Networking/PacketHandler.cs | 2 +- Intersect.Network/LICENSE.md | 2 +- Intersect.Server/Core/ServerLoop.cs | 73 +- Intersect.Server/Database/DbInterface.cs | 31 +- Intersect.Server/Entities/Entity.cs | 2 +- Intersect.Server/Entities/Events/Event.cs | 8 +- .../Entities/Pathfinding/Pathfinder.cs | 4 +- Intersect.Server/General/Formulas.cs | 2 + Intersect.Server/Maps/MapInstance.cs | 36 +- Intersect.Server/Maps/MapTrapInstance.cs | 6 + Intersect.Server/Networking/PacketHandler.cs | 72 +- Intersect.Server/Networking/PacketSender.cs | 11 +- Intersect.Shared/LICENSE.md | 21 + Intersect.Utilities/LICENSE.md | 621 ++++++++++++++++++ README.md | 5 +- 25 files changed, 963 insertions(+), 146 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 Intersect.Client.Framework/LICENSE.md create mode 100644 Intersect.Shared/LICENSE.md create mode 100644 Intersect.Utilities/LICENSE.md diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..d245d4429d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +custom: https://www.ascensiongamedev.com/donate/make-donation/ diff --git a/Documentation/Client/LICENSE.md b/Documentation/Client/LICENSE.md index 9c3d1b965e..375feb9e74 100644 --- a/Documentation/Client/LICENSE.md +++ b/Documentation/Client/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Ascension Game Dev +Copyright (c) 2020 Ascension Game Dev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Intersect (Core)/LICENSE.md b/Intersect (Core)/LICENSE.md index 9c3d1b965e..375feb9e74 100644 --- a/Intersect (Core)/LICENSE.md +++ b/Intersect (Core)/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Ascension Game Dev +Copyright (c) 2020 Ascension Game Dev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Intersect.Client.Framework/LICENSE.md b/Intersect.Client.Framework/LICENSE.md new file mode 100644 index 0000000000..375feb9e74 --- /dev/null +++ b/Intersect.Client.Framework/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Ascension Game Dev + +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. diff --git a/Intersect.Client/Interface/Game/GameInterface.cs b/Intersect.Client/Interface/Game/GameInterface.cs index 565cf382dc..96cc7330af 100644 --- a/Intersect.Client/Interface/Game/GameInterface.cs +++ b/Intersect.Client/Interface/Game/GameInterface.cs @@ -69,6 +69,8 @@ public class GameInterface private bool mShouldUpdateQuestLog = true; + private bool mShouldUpdateFriendsList; + private string mTradingTarget; private TradingWindow mTradingWindow; @@ -114,9 +116,9 @@ public void SetChatboxText(string msg) } //Friends Window - public void UpdateFriendsList() + public void NotifyUpdateFriendsList() { - GameMenu.UpdateFriendsList(); + mShouldUpdateFriendsList = true; } //Admin Window @@ -458,6 +460,11 @@ public void Draw() } } + if (mShouldUpdateFriendsList) + { + GameMenu.UpdateFriendsList(); + } + mShouldCloseTrading = false; if (FocusChat) diff --git a/Intersect.Client/Interface/Game/Menu.cs b/Intersect.Client/Interface/Game/Menu.cs index 4e385040bc..86e579789a 100644 --- a/Intersect.Client/Interface/Game/Menu.cs +++ b/Intersect.Client/Interface/Game/Menu.cs @@ -180,6 +180,7 @@ public bool ToggleFriendsWindow() else { HideWindows(); + PacketSender.SendRequestFriends(); mFriendsWindow.UpdateList(); mFriendsWindow.Show(); } @@ -252,10 +253,7 @@ private void PartyBtn_Clicked(Base sender, ClickedEventArgs arguments) private void FriendsBtn_Clicked(Base sender, ClickedEventArgs arguments) { - if (ToggleFriendsWindow()) - { - PacketSender.SendRequestFriends(); - } + ToggleFriendsWindow(); } private void QuestBtn_Clicked(Base sender, ClickedEventArgs arguments) diff --git a/Intersect.Client/Interface/Menu/SelectCharacterWindow.cs b/Intersect.Client/Interface/Menu/SelectCharacterWindow.cs index 499a1f80c2..d22ba2f565 100644 --- a/Intersect.Client/Interface/Menu/SelectCharacterWindow.cs +++ b/Intersect.Client/Interface/Menu/SelectCharacterWindow.cs @@ -156,9 +156,9 @@ private void UpdateDisplay() mPrevCharButton.BringToFront(); } - for (var i = 0; i < Options.EquipmentSlots.Count; i++) + for (var i = 0; i < mPaperdollPortraits.Length; i++) { - mPaperdollPortraits[i].Hide(); + mPaperdollPortraits[i]?.Hide(); } if (Characters[mSelectedChar] != null) diff --git a/Intersect.Client/LICENSE.md b/Intersect.Client/LICENSE.md index 9c3d1b965e..375feb9e74 100644 --- a/Intersect.Client/LICENSE.md +++ b/Intersect.Client/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Ascension Game Dev +Copyright (c) 2020 Ascension Game Dev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Intersect.Client/MonoGame/Audio/MonoMusicInstance.cs b/Intersect.Client/MonoGame/Audio/MonoMusicInstance.cs index 6aba8cc321..4308dc6b85 100644 --- a/Intersect.Client/MonoGame/Audio/MonoMusicInstance.cs +++ b/Intersect.Client/MonoGame/Audio/MonoMusicInstance.cs @@ -4,6 +4,7 @@ using JetBrains.Annotations; +using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Media; namespace Intersect.Client.MonoGame.Audio @@ -12,7 +13,11 @@ namespace Intersect.Client.MonoGame.Audio public class MonoMusicInstance : MonoAudioInstance { - private readonly Song mSong; + public static MonoMusicInstance Instance = null; + + private readonly DynamicSoundEffectInstance mSong; + + private readonly MonoMusicSource mSource; private bool mDisposed; @@ -21,6 +26,18 @@ public class MonoMusicInstance : MonoAudioInstance // ReSharper disable once SuggestBaseTypeForParameter public MonoMusicInstance([NotNull] MonoMusicSource source) : base(source) { + //Only allow one music player at a time + if (Instance != null) + { + Instance.Stop(); + Instance.Dispose(); + Instance = null; + } + + Instance = this; + mSource = source; + + mSong = source.LoadSong(); } @@ -28,19 +45,19 @@ public override AudioInstanceState State { get { - if (mDisposed) + if (mSong == null || mSong.IsDisposed) { return AudioInstanceState.Disposed; } - switch (MediaPlayer.State) + switch (mSong.State) { - case MediaState.Playing: + case SoundState.Playing: return AudioInstanceState.Playing; - case MediaState.Stopped: - return AudioInstanceState.Stopped; - case MediaState.Paused: + case SoundState.Paused: return AudioInstanceState.Paused; + case SoundState.Stopped: + return AudioInstanceState.Stopped; default: return AudioInstanceState.Disposed; } @@ -49,36 +66,45 @@ public override AudioInstanceState State public override void Play() { - if (mSong != null) + if (mSong != null && !mSong.IsDisposed) { - MediaPlayer.Play(mSong); + mSong.Play(); } } public override void Pause() { - MediaPlayer.Pause(); + if (mSong != null && !mSong.IsDisposed) + { + mSong.Pause(); + } } public override void Stop() { - MediaPlayer.Stop(); + if (mSong != null && !mSong.IsDisposed) + { + mSong.Stop(); + } } public override void SetVolume(int volume, bool isMusic = false) { - mVolume = volume; - try + if (mSong != null && !mSong.IsDisposed) { - MediaPlayer.Volume = mVolume * (Globals.Database.MusicVolume / 100f) / 100f; - } - catch (NullReferenceException) - { - // song changed while changing volume - } - catch (Exception) - { - // device not ready + mVolume = volume; + try + { + mSong.Volume = mVolume * (Globals.Database.MusicVolume / 100f) / 100f; + } + catch (NullReferenceException) + { + // song changed while changing volume + } + catch (Exception) + { + // device not ready + } } } @@ -89,7 +115,10 @@ public override int GetVolume() protected override void InternalLoopSet() { - MediaPlayer.IsRepeating = IsLooping; + if (mSong != null) + { + //mSong.IsLooped = IsLooping; + } } public override void Dispose() @@ -97,8 +126,13 @@ public override void Dispose() mDisposed = true; try { - MediaPlayer.Stop(); - mSong.Dispose(); + if (mSong != null && !mSong.IsDisposed) + { + mSong.Stop(); + mSong.Dispose(); + } + + mSource.Close(); } catch { diff --git a/Intersect.Client/MonoGame/Audio/MonoMusicSource.cs b/Intersect.Client/MonoGame/Audio/MonoMusicSource.cs index 18d87f3bea..45b386ef10 100644 --- a/Intersect.Client/MonoGame/Audio/MonoMusicSource.cs +++ b/Intersect.Client/MonoGame/Audio/MonoMusicSource.cs @@ -3,10 +3,14 @@ using Intersect.Client.Framework.Audio; using Intersect.Client.Interface.Game.Chat; using Intersect.Client.Localization; +using Intersect.Client.Utilities; using Intersect.Logging; +using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Media; +using NVorbis; + namespace Intersect.Client.MonoGame.Audio { @@ -15,6 +19,10 @@ public class MonoMusicSource : GameAudioSource private readonly string mPath; + private VorbisReader mReader; + + private DynamicSoundEffectInstance mInstance; + public MonoMusicSource(string path) { mPath = path; @@ -25,13 +33,28 @@ public override GameAudioInstance CreateInstance() return new MonoMusicInstance(this); } - public Song LoadSong() + public DynamicSoundEffectInstance LoadSong() { if (!string.IsNullOrWhiteSpace(mPath)) { try { - return Song.FromUri(mPath, new Uri(mPath, UriKind.Relative)); + if (mReader == null) + { + mReader = new VorbisReader(mPath); + } + + if (mInstance != null) + { + mInstance.Dispose(); + mInstance = null; + } + + mInstance = new DynamicSoundEffectInstance(mReader.SampleRate, mReader.Channels == 1 ? AudioChannels.Mono : AudioChannels.Stereo); + mInstance.BufferNeeded += BufferNeeded; + + + return mInstance; } catch (Exception exception) { @@ -47,6 +70,47 @@ public Song LoadSong() return null; } + public void Close() + { + if (mReader != null) + { + mReader.Dispose(); + mReader = null; + } + } + + private void BufferNeeded(object sender, EventArgs args) + => FillBuffers(); + + private void FillBuffers(int buffers = 3, int samples = 44100) + { + float[] sampleBuffer = null; + + while (mInstance.PendingBufferCount < buffers && mReader != null) + { + if (sampleBuffer == null) + sampleBuffer = new float[samples]; + + var read = mReader.ReadSamples(sampleBuffer, 0, sampleBuffer.Length); + if (read == 0) + { + mReader.DecodedPosition = 0; + continue; + } + + var dataBuffer = new byte[read << 1]; + for (var sampleIndex = 0; sampleIndex < read; ++sampleIndex) + { + var sample = (short)MathHelper.Clamp(sampleBuffer[sampleIndex] * 32767f, short.MinValue, short.MaxValue); + var sampleData = BitConverter.GetBytes(sample); + for (var sampleByteIndex = 0; sampleByteIndex < sampleData.Length; ++sampleByteIndex) + dataBuffer[(sampleIndex << 1) + sampleByteIndex] = sampleData[sampleByteIndex]; + } + + mInstance.SubmitBuffer(dataBuffer, 0, read << 1); + } + } + } } diff --git a/Intersect.Client/Networking/PacketHandler.cs b/Intersect.Client/Networking/PacketHandler.cs index 8513f4ac59..c69ec70dc3 100644 --- a/Intersect.Client/Networking/PacketHandler.cs +++ b/Intersect.Client/Networking/PacketHandler.cs @@ -1581,7 +1581,7 @@ private static void HandlePacket(FriendsPacket packet) Globals.Me.Friends.Add(f); } - Interface.Interface.GameUi.UpdateFriendsList(); + Interface.Interface.GameUi.NotifyUpdateFriendsList(); } //FriendRequestPacket diff --git a/Intersect.Network/LICENSE.md b/Intersect.Network/LICENSE.md index 9c3d1b965e..375feb9e74 100644 --- a/Intersect.Network/LICENSE.md +++ b/Intersect.Network/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Ascension Game Dev +Copyright (c) 2020 Ascension Game Dev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Intersect.Server/Core/ServerLoop.cs b/Intersect.Server/Core/ServerLoop.cs index 8af8ba779d..2aeb0c00fb 100644 --- a/Intersect.Server/Core/ServerLoop.cs +++ b/Intersect.Server/Core/ServerLoop.cs @@ -12,7 +12,7 @@ namespace Intersect.Server.Core public static class ServerLoop { - + public static object Lock = new object(); public static void RunServerLoop() { try @@ -25,48 +25,51 @@ public static void RunServerLoop() long dbBackupMinutes = 120; while (ServerContext.Instance.IsRunning) { - //TODO: If there are no players online then loop slower and save the poor cpu - var timeMs = Globals.Timing.TimeMs; - var maps = MapInstance.Lookup.Values.ToArray(); - - //TODO: Could be optimized by keeping a list of active maps or something - foreach (MapInstance map in maps) + lock (Lock) { - map.Update(timeMs); - } + //TODO: If there are no players online then loop slower and save the poor cpu + var timeMs = Globals.Timing.TimeMs; + var maps = MapInstance.Lookup.Values.ToArray(); - if (minuteTimer < timeMs) - { - if (lastDbUpdate.AddMinutes(dbBackupMinutes) < DateTime.Now) + //TODO: Could be optimized by keeping a list of active maps or something + foreach (MapInstance map in maps) { - Task.Run(() => DbInterface.BackupDatabase()); - lastDbUpdate = DateTime.Now; + map.Update(timeMs); } - DbInterface.SavePlayerDatabaseAsync(); - minuteTimer = timeMs + 60000; - } + if (minuteTimer < timeMs) + { + if (lastDbUpdate.AddMinutes(dbBackupMinutes) < DateTime.Now) + { + Task.Run(() => DbInterface.BackupDatabase()); + lastDbUpdate = DateTime.Now; + } - cps++; - if (timeMs >= cpsTimer) - { - Globals.Cps = cps; - cps = 0; - cpsTimer = timeMs + 1000; - } + DbInterface.SavePlayerDatabaseAsync(); + minuteTimer = timeMs + 60000; + } - Time.Update(); - var currentTime = Globals.Timing.TimeMs; - if (Globals.CpsLock && currentTime < timeMs + 10) - { - var waitTime = (int) (timeMs + 10 - currentTime); - Thread.Sleep(waitTime); - } + cps++; + if (timeMs >= cpsTimer) + { + Globals.Cps = cps; + cps = 0; + cpsTimer = timeMs + 1000; + } - if (timeMs > lastGameSave) - { - Task.Run(() => DbInterface.SaveGameDatabase()); - lastGameSave = timeMs + 60000; + Time.Update(); + var currentTime = Globals.Timing.TimeMs; + if (Globals.CpsLock && currentTime < timeMs + 10) + { + var waitTime = (int)(timeMs + 10 - currentTime); + Thread.Sleep(waitTime); + } + + if (timeMs > lastGameSave) + { + Task.Run(() => DbInterface.SaveGameDatabase()); + lastGameSave = timeMs + 60000; + } } } } diff --git a/Intersect.Server/Database/DbInterface.cs b/Intersect.Server/Database/DbInterface.cs index ddaf49ed26..e7ee21b585 100644 --- a/Intersect.Server/Database/DbInterface.cs +++ b/Intersect.Server/Database/DbInterface.cs @@ -1264,24 +1264,27 @@ public static void GenerateMapGrids() foreach (MapInstance map in MapInstance.Lookup.Values) { - map.SurroundingMaps.Clear(); - var myGrid = map.MapGrid; - for (var x = map.MapGridX - 1; x <= map.MapGridX + 1; x++) + lock (map.GetMapLock()) { - for (var y = map.MapGridY - 1; y <= map.MapGridY + 1; y++) + map.SurroundingMaps.Clear(); + var myGrid = map.MapGrid; + for (var x = map.MapGridX - 1; x <= map.MapGridX + 1; x++) { - if (x == map.MapGridX && y == map.MapGridY) + for (var y = map.MapGridY - 1; y <= map.MapGridY + 1; y++) { - continue; - } + if (x == map.MapGridX && y == map.MapGridY) + { + continue; + } - if (x >= MapGrids[myGrid].XMin && - x < MapGrids[myGrid].XMax && - y >= MapGrids[myGrid].YMin && - y < MapGrids[myGrid].YMax && - MapGrids[myGrid].MyGrid[x, y] != Guid.Empty) - { - map.SurroundingMaps.Add(MapGrids[myGrid].MyGrid[x, y]); + if (x >= MapGrids[myGrid].XMin && + x < MapGrids[myGrid].XMax && + y >= MapGrids[myGrid].YMin && + y < MapGrids[myGrid].YMax && + MapGrids[myGrid].MyGrid[x, y] != Guid.Empty) + { + map.SurroundingMaps.Add(MapGrids[myGrid].MyGrid[x, y]); + } } } } diff --git a/Intersect.Server/Entities/Entity.cs b/Intersect.Server/Entities/Entity.cs index a94bd2b1e9..5bd4fa8ebe 100644 --- a/Intersect.Server/Entities/Entity.cs +++ b/Intersect.Server/Entities/Entity.cs @@ -792,7 +792,7 @@ public virtual void Move(int moveDir, Player forPlayer, bool doNotUpdate = false if (doNotUpdate == false) { - if (this is EventPage) + if (this is EventPageInstance) { if (forPlayer != null) { diff --git a/Intersect.Server/Entities/Events/Event.cs b/Intersect.Server/Entities/Events/Event.cs index 3e3486a189..ecf43b6f9c 100644 --- a/Intersect.Server/Entities/Events/Event.cs +++ b/Intersect.Server/Entities/Events/Event.cs @@ -308,17 +308,21 @@ public void Update(long timeMs) prams.Add("evtName", BaseEvent.Name); + var map = MapInstance.Get(BaseEvent.MapId); + if (map != null) + { + prams.Add("evtMap", map.Name); + } + if (MapId != Guid.Empty) { if (GlobalPageInstance != null) { - prams.Add("evtMap", GlobalPageInstance[PageIndex].Map.Name); prams.Add("evtX", GlobalPageInstance[PageIndex].X.ToString()); prams.Add("evtY", GlobalPageInstance[PageIndex].Y.ToString()); } else if (PageInstance != null) { - prams.Add("evtMap", PageInstance.Map.Name); prams.Add("evtX", PageInstance.X.ToString()); prams.Add("evtY", PageInstance.Y.ToString()); } diff --git a/Intersect.Server/Entities/Pathfinding/Pathfinder.cs b/Intersect.Server/Entities/Pathfinding/Pathfinder.cs index 9869ef1b33..bde7d0ac22 100644 --- a/Intersect.Server/Entities/Pathfinding/Pathfinder.cs +++ b/Intersect.Server/Entities/Pathfinding/Pathfinder.cs @@ -188,7 +188,7 @@ public PathfinderResult Update(long timeMs) //Block of Players, Npcs, and Resources foreach (var en in tmpMap.GetEntities()) { - if (!en.IsPassable()) + if (!en.IsPassable() && en.X > -1 && en.X < Options.MapWidth && en.Y > -1 && en.Y < Options.MapHeight) { mapGrid[(x + 1 - gridX) * Options.MapWidth + en.X, (y + 1 - gridY) * Options.MapHeight + en.Y] @@ -199,7 +199,7 @@ public PathfinderResult Update(long timeMs) //Block Global Events if they are not passable. foreach (var en in tmpMap.GlobalEventInstances) { - if (en.Value != null) + if (en.Value != null && en.Value.X > -1 && en.Value.X < Options.MapWidth && en.Value.Y > -1 && en.Value.Y < Options.MapHeight) { foreach (var page in en.Value.GlobalPageInstance) { diff --git a/Intersect.Server/General/Formulas.cs b/Intersect.Server/General/Formulas.cs index 22f593af26..f8b73da72b 100644 --- a/Intersect.Server/General/Formulas.cs +++ b/Intersect.Server/General/Formulas.cs @@ -44,6 +44,8 @@ public static void LoadFormulas() } File.WriteAllText(FORMULAS_FILE, JsonConvert.SerializeObject(mFormulas, Formatting.Indented)); + + Expression.CacheEnabled = false; } catch (Exception ex) { diff --git a/Intersect.Server/Maps/MapInstance.cs b/Intersect.Server/Maps/MapInstance.cs index 0f5ee9085a..60b2a47b1e 100644 --- a/Intersect.Server/Maps/MapInstance.cs +++ b/Intersect.Server/Maps/MapInstance.cs @@ -759,15 +759,22 @@ public void RemoveTrap(MapTrapInstance trap) public void ClearEntityTargetsOf(Entity en) { - lock (GetMapLock()) + if (Monitor.TryEnter(GetMapLock(), new TimeSpan(0, 0, 0, 0, 1))) { - foreach (var entity in mEntities) + try { - if (entity.GetType() == typeof(Npc) && ((Npc) entity).Target == en) + foreach (var entity in mEntities) { - ((Npc) entity).RemoveTarget(); + if (entity.GetType() == typeof(Npc) && ((Npc)entity).Target == en) + { + ((Npc)entity).RemoveTarget(); + } } } + finally + { + Monitor.Exit(GetMapLock()); + } } } @@ -921,17 +928,20 @@ public void Update(long timeMs) public List GetSurroundingMaps(bool includingSelf = false) { Debug.Assert(Lookup != null, "Lookup != null"); - var maps = SurroundingMaps?.Select(mapNum => Lookup.Get(mapNum)) - .Where(map => map != null) - .ToList() ?? - new List(); - - if (includingSelf) + lock (GetMapLock()) { - maps.Add(this); - } + var maps = SurroundingMaps?.Select(mapNum => Lookup.Get(mapNum)) + .Where(map => map != null) + .ToList() ?? + new List(); - return maps; + if (includingSelf) + { + maps.Add(this); + } + + return maps; + } } public List GetSurroundingMapIds(bool includingSelf = false) diff --git a/Intersect.Server/Maps/MapTrapInstance.cs b/Intersect.Server/Maps/MapTrapInstance.cs index f19beb4c26..65c32cdc5f 100644 --- a/Intersect.Server/Maps/MapTrapInstance.cs +++ b/Intersect.Server/Maps/MapTrapInstance.cs @@ -2,6 +2,7 @@ using Intersect.GameObjects; using Intersect.Server.Entities; +using Intersect.Server.Entities.Events; using Intersect.Server.General; using Intersect.Server.Maps; @@ -56,6 +57,11 @@ public void CheckEntityHasDetonatedTrap(Entity entity) } } + if (entity is EventPageInstance) + { + return; + } + Owner.TryAttack(entity, ParentSpell, false, true); Triggered = true; } diff --git a/Intersect.Server/Networking/PacketHandler.cs b/Intersect.Server/Networking/PacketHandler.cs index f857a6891c..5814f5e7d9 100644 --- a/Intersect.Server/Networking/PacketHandler.cs +++ b/Intersect.Server/Networking/PacketHandler.cs @@ -16,6 +16,7 @@ using Intersect.Network; using Intersect.Network.Packets.Client; using Intersect.Server.Admin.Actions; +using Intersect.Server.Core; using Intersect.Server.Database; using Intersect.Server.Database.PlayerData; using Intersect.Server.Database.PlayerData.Security; @@ -2896,55 +2897,58 @@ public void HandlePacket(Client client, Player player, Network.Packets.Editor.Sa if (obj != null) { - //if Item or Resource, kill all global entities of that kind - if (type == GameObjectType.Item) - { - Globals.KillItemsOf((ItemBase) obj); - } - else if (type == GameObjectType.Npc) - { - Globals.KillNpcsOf((NpcBase) obj); - } - else if (type == GameObjectType.Projectile) + lock (ServerLoop.Lock) { - Globals.KillProjectilesOf((ProjectileBase) obj); - } + //if Item or Resource, kill all global entities of that kind + if (type == GameObjectType.Item) + { + Globals.KillItemsOf((ItemBase)obj); + } + else if (type == GameObjectType.Npc) + { + Globals.KillNpcsOf((NpcBase)obj); + } + else if (type == GameObjectType.Projectile) + { + Globals.KillProjectilesOf((ProjectileBase)obj); + } - obj.Load(packet.Data); + obj.Load(packet.Data); - if (type == GameObjectType.Quest) - { - var qst = (QuestBase) obj; - foreach (var evt in qst.RemoveEvents) + if (type == GameObjectType.Quest) { - var evtb = EventBase.Get(evt); - if (evtb != null) + var qst = (QuestBase)obj; + foreach (var evt in qst.RemoveEvents) { - DbInterface.DeleteGameObject(evtb); + var evtb = EventBase.Get(evt); + if (evtb != null) + { + DbInterface.DeleteGameObject(evtb); + } } - } - foreach (var evt in qst.AddEvents) - { - var evtb = (EventBase) DbInterface.AddGameObject(GameObjectType.Event, evt.Key); - evtb.CommonEvent = false; - foreach (var tsk in qst.Tasks) + foreach (var evt in qst.AddEvents) { - if (tsk.Id == evt.Key) + var evtb = (EventBase)DbInterface.AddGameObject(GameObjectType.Event, evt.Key); + evtb.CommonEvent = false; + foreach (var tsk in qst.Tasks) { - tsk.CompletionEvent = evtb; + if (tsk.Id == evt.Key) + { + tsk.CompletionEvent = evtb; + } } + + evtb.Load(evt.Value.JsonData); } - evtb.Load(evt.Value.JsonData); + qst.AddEvents.Clear(); + qst.RemoveEvents.Clear(); } - qst.AddEvents.Clear(); - qst.RemoveEvents.Clear(); + PacketSender.CacheGameDataPacket(); + PacketSender.SendGameObjectToAll(obj, false); } - - PacketSender.CacheGameDataPacket(); - PacketSender.SendGameObjectToAll(obj, false); DbInterface.SaveGameDatabase(); } } diff --git a/Intersect.Server/Networking/PacketSender.cs b/Intersect.Server/Networking/PacketSender.cs index 94ee04d8f5..9c1f7b58a5 100644 --- a/Intersect.Server/Networking/PacketSender.cs +++ b/Intersect.Server/Networking/PacketSender.cs @@ -243,11 +243,14 @@ public static void SendMap(Client client, Guid mapId, bool allEditors = false) else { client.SendPacket(GenerateMapPacket(client, mapId)); - - //TODO: INCLUDE EVENTS IN MAP PACKET - if (mapId == client.Entity.MapId) + var entity = client.Entity; + if (entity != null) { - client.Entity.SendEvents(); + //TODO: INCLUDE EVENTS IN MAP PACKET + if (mapId == entity.MapId) + { + entity.SendEvents(); + } } //TODO - Include Aggression and Equipment in ENTITY DATA PACKETS! diff --git a/Intersect.Shared/LICENSE.md b/Intersect.Shared/LICENSE.md new file mode 100644 index 0000000000..375feb9e74 --- /dev/null +++ b/Intersect.Shared/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Ascension Game Dev + +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. diff --git a/Intersect.Utilities/LICENSE.md b/Intersect.Utilities/LICENSE.md new file mode 100644 index 0000000000..94a0453222 --- /dev/null +++ b/Intersect.Utilities/LICENSE.md @@ -0,0 +1,621 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md index 1fb1dbe143..1d697948e4 100644 --- a/README.md +++ b/README.md @@ -74,11 +74,14 @@ This project has split licensing. See license.md within each of the projects' fo | Project | License | |:---|--------| -| Intersect.Client | [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://tldrlegal.com/license/mit-license) | | Intersect.Core | [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://tldrlegal.com/license/mit-license) | +| Intersect.Client | [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://tldrlegal.com/license/mit-license) | +| Intersect.Client.Framework | [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://tldrlegal.com/license/mit-license) | | Intersect.Network | [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://tldrlegal.com/license/mit-license) | +| Intersect.Shared | [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://tldrlegal.com/license/mit-license) | | Intersect.Editor | [![GPLv3 license](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)) | | Intersect.Server | [![GPLv3 license](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)) | +| Intersect.Utilities | [![GPLv3 license](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)) | Third-party libraries used by Intersect are under their own licenses. Please refer to those libraries for details on the license they use. From 9095c698a3a7dd6e03775a30f032a74399dd3200 Mon Sep 17 00:00:00 2001 From: JC Snider Date: Wed, 1 Apr 2020 10:18:15 -0400 Subject: [PATCH 05/15] Moving db context snapshot model fixes into dev (#59) * Fixing bugs (#47) * Should fix 198, server crash due to projectile trying to hit an event * Harden accept trade packet to return if counterparty is null. * Fixing potential NREs * Fixes another potential NRE and out of bounds error * Don't want to handle packets for null clients, but also don't want to be throwing exceptions * Fixes a small error where empty passwords crash the server during migration * Updated licensing leading up to open source release (#49) * Create FUNDING.yml (#50) * Use dynamicsoundeffects for music instead of mediaplayer (#51) * Fixing bugs (#52) * Should fix 198, server crash due to projectile trying to hit an event * Harden accept trade packet to return if counterparty is null. * Fixing potential NREs * Fixes another potential NRE and out of bounds error * Don't want to handle packets for null clients, but also don't want to be throwing exceptions * Fixes a small error where empty passwords crash the server during migration * Small edit so that networking doesn't alter ui, only triggers ui to update next draw * Fixed events jumping all over the place * Allow checking of evtMap parameter even if no page instance has spawned * Basic bounds checking on pathfinding to potentially fix Weylon's bug. * Fix for events being able to step on traps. * Stop caching of expressions as they are used once * Fixed select character window not resetting paperdolls properly when cycling through characters * Fixes empty friends list when opening friends via a hotkey * Added server loop lock for when updating game objects (less likely to have deadlocks if not processing npcs when updating npcs, for example) * Fix collection changed bug when maps update while server loop is running * Fixes weird instance where the server would error while trying to send a map to a client who didn't have an entity set * Adds SpellCd back into the PlayerContextModelSnapshot since it was never actually removed from the database. (#56) * Fixing db context model snapshot formatting (#58) * Adds SpellCd back into the PlayerContextModelSnapshot since it was never actually removed from the database. * EF expected formatting fix for game context model snapshot --- .../Game/GameContextModelSnapshot.cs | 470 +++++++++--------- .../Migrations/PlayerContextModelSnapshot.cs | 288 +++++------ 2 files changed, 378 insertions(+), 380 deletions(-) diff --git a/Intersect.Server/Migrations/Game/GameContextModelSnapshot.cs b/Intersect.Server/Migrations/Game/GameContextModelSnapshot.cs index 3696dc6dcc..fbfd65a8a9 100644 --- a/Intersect.Server/Migrations/Game/GameContextModelSnapshot.cs +++ b/Intersect.Server/Migrations/Game/GameContextModelSnapshot.cs @@ -1,28 +1,25 @@ // - using System; - using Intersect.Server.Database.GameData; - using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Intersect.Server.Migrations.Game { - [DbContext(typeof(GameContext))] partial class GameContextModelSnapshot : ModelSnapshot { - protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "2.1.3-rtm-32065"); + modelBuilder + .HasAnnotation("ProductVersion", "2.1.3-rtm-32065"); - modelBuilder.Entity( - "Intersect.GameObjects.AnimationBase", b => + modelBuilder.Entity("Intersect.GameObjects.AnimationBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("CompleteSound"); @@ -37,15 +34,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Animations"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.ClassBase", b => + modelBuilder.Entity("Intersect.GameObjects.ClassBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); - b.Property("AttackAnimationId").HasColumnName("AttackAnimation"); + b.Property("AttackAnimationId") + .HasColumnName("AttackAnimation"); b.Property("AttackSpeedModifier"); @@ -65,21 +62,27 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ExpIncrease"); - b.Property("ExpOverridesJson").HasColumnName("ExperienceOverrides"); + b.Property("ExpOverridesJson") + .HasColumnName("ExperienceOverrides"); b.Property("Folder"); b.Property("IncreasePercentage"); - b.Property("JsonBaseStats").HasColumnName("BaseStats"); + b.Property("JsonBaseStats") + .HasColumnName("BaseStats"); - b.Property("JsonBaseVitals").HasColumnName("BaseVitals"); + b.Property("JsonBaseVitals") + .HasColumnName("BaseVitals"); - b.Property("JsonItems").HasColumnName("Items"); + b.Property("JsonItems") + .HasColumnName("Items"); - b.Property("JsonSpells").HasColumnName("Spells"); + b.Property("JsonSpells") + .HasColumnName("Spells"); - b.Property("JsonSprites").HasColumnName("Sprites"); + b.Property("JsonSprites") + .HasColumnName("Sprites"); b.Property("Locked"); @@ -87,7 +90,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("PointIncrease"); - b.Property("RegenJson").HasColumnName("VitalRegen"); + b.Property("RegenJson") + .HasColumnName("VitalRegen"); b.Property("Scaling"); @@ -95,32 +99,35 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SpawnDir"); - b.Property("SpawnMapId").HasColumnName("SpawnMap"); + b.Property("SpawnMapId") + .HasColumnName("SpawnMap"); b.Property("SpawnX"); b.Property("SpawnY"); - b.Property("StatIncreaseJson").HasColumnName("StatIncreases"); + b.Property("StatIncreaseJson") + .HasColumnName("StatIncreases"); b.Property("TimeCreated"); - b.Property("VitalIncreaseJson").HasColumnName("VitalIncreases"); + b.Property("VitalIncreaseJson") + .HasColumnName("VitalIncreases"); b.HasKey("Id"); b.ToTable("Classes"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.Crafting.CraftBase", b => + modelBuilder.Entity("Intersect.GameObjects.Crafting.CraftBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("Folder"); - b.Property("IngredientsJson").HasColumnName("Ingredients"); + b.Property("IngredientsJson") + .HasColumnName("Ingredients"); b.Property("ItemId"); @@ -135,15 +142,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Crafts"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.CraftingTableBase", b => + modelBuilder.Entity("Intersect.GameObjects.CraftingTableBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); - b.Property("CraftsJson").HasColumnName("Crafts"); + b.Property("CraftsJson") + .HasColumnName("Crafts"); b.Property("Folder"); @@ -154,13 +161,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("CraftingTables"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.Events.EventBase", b => + modelBuilder.Entity("Intersect.GameObjects.Events.EventBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("CommonEvent"); @@ -172,7 +178,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Name"); - b.Property("PagesJson").HasColumnName("Pages"); + b.Property("PagesJson") + .HasColumnName("Pages"); b.Property("SpawnX"); @@ -183,17 +190,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Events"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.ItemBase", b => + modelBuilder.Entity("Intersect.GameObjects.ItemBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); - b.Property("AnimationId").HasColumnName("Animation"); + b.Property("AnimationId") + .HasColumnName("Animation"); - b.Property("AttackAnimationId").HasColumnName("AttackAnimation"); + b.Property("AttackAnimationId") + .HasColumnName("AttackAnimation"); b.Property("AttackSpeedModifier"); @@ -215,11 +223,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DestroySpell"); - b.Property("EquipmentAnimationId").HasColumnName("EquipmentAnimation"); + b.Property("EquipmentAnimationId") + .HasColumnName("EquipmentAnimation"); b.Property("EquipmentSlot"); - b.Property("EventId").HasColumnName("Event"); + b.Property("EventId") + .HasColumnName("Event"); b.Property("FemalePaperdoll"); @@ -229,19 +239,23 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ItemType"); - b.Property("JsonUsageRequirements").HasColumnName("UsageRequirements"); + b.Property("JsonUsageRequirements") + .HasColumnName("UsageRequirements"); b.Property("MalePaperdoll"); b.Property("Name"); - b.Property("PercentageStatsJson").HasColumnName("PercentageStatsGiven"); + b.Property("PercentageStatsJson") + .HasColumnName("PercentageStatsGiven"); - b.Property("PercentageVitalsJson").HasColumnName("PercentageVitalsGiven"); + b.Property("PercentageVitalsJson") + .HasColumnName("PercentageVitalsGiven"); b.Property("Price"); - b.Property("ProjectileId").HasColumnName("Projectile"); + b.Property("ProjectileId") + .HasColumnName("Projectile"); b.Property("QuickCast"); @@ -255,13 +269,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Speed"); - b.Property("SpellId").HasColumnName("Spell"); + b.Property("SpellId") + .HasColumnName("Spell"); b.Property("Stackable"); b.Property("StatGrowth"); - b.Property("StatsJson").HasColumnName("StatsGiven"); + b.Property("StatsJson") + .HasColumnName("StatsGiven"); b.Property("TimeCreated"); @@ -269,47 +285,51 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TwoHanded"); - b.Property("VitalsJson").HasColumnName("VitalsGiven"); + b.Property("VitalsJson") + .HasColumnName("VitalsGiven"); - b.Property("VitalsRegenJson").HasColumnName("VitalsRegen"); + b.Property("VitalsRegenJson") + .HasColumnName("VitalsRegen"); b.HasKey("Id"); b.ToTable("Items"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.Maps.MapList.MapList", b => + modelBuilder.Entity("Intersect.GameObjects.Maps.MapList.MapList", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); - b.Property("JsonData").HasColumnName("JsonData"); + b.Property("JsonData") + .HasColumnName("JsonData"); b.HasKey("Id"); b.ToTable("MapFolders"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.NpcBase", b => + modelBuilder.Entity("Intersect.GameObjects.NpcBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("Aggressive"); b.Property("AttackAllies"); - b.Property("AttackAnimationId").HasColumnName("AttackAnimation"); + b.Property("AttackAnimationId") + .HasColumnName("AttackAnimation"); - b.Property("AttackOnSightConditionsJson").HasColumnName("AttackOnSightConditions"); + b.Property("AttackOnSightConditionsJson") + .HasColumnName("AttackOnSightConditions"); b.Property("AttackSpeedModifier"); b.Property("AttackSpeedValue"); - b.Property("CraftsJson").HasColumnName("Spells"); + b.Property("CraftsJson") + .HasColumnName("Spells"); b.Property("CritChance"); @@ -327,13 +347,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Folder"); - b.Property("JsonAggroList").HasColumnName("AggroList"); + b.Property("JsonAggroList") + .HasColumnName("AggroList"); - b.Property("JsonDrops").HasColumnName("Drops"); + b.Property("JsonDrops") + .HasColumnName("Drops"); - b.Property("JsonMaxVital").HasColumnName("MaxVital"); + b.Property("JsonMaxVital") + .HasColumnName("MaxVital"); - b.Property("JsonStat").HasColumnName("Stats"); + b.Property("JsonStat") + .HasColumnName("Stats"); b.Property("Level"); @@ -343,15 +367,20 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("NpcVsNpcEnabled"); - b.Property("OnDeathEventId").HasColumnName("OnDeathEvent"); + b.Property("OnDeathEventId") + .HasColumnName("OnDeathEvent"); - b.Property("OnDeathPartyEventId").HasColumnName("OnDeathPartyEvent"); + b.Property("OnDeathPartyEventId") + .HasColumnName("OnDeathPartyEvent"); - b.Property("PlayerCanAttackConditionsJson").HasColumnName("PlayerCanAttackConditions"); + b.Property("PlayerCanAttackConditionsJson") + .HasColumnName("PlayerCanAttackConditions"); - b.Property("PlayerFriendConditionsJson").HasColumnName("PlayerFriendConditions"); + b.Property("PlayerFriendConditionsJson") + .HasColumnName("PlayerFriendConditions"); - b.Property("RegenJson").HasColumnName("VitalRegen"); + b.Property("RegenJson") + .HasColumnName("VitalRegen"); b.Property("Scaling"); @@ -372,13 +401,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Npcs"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.PlayerVariableBase", b => + modelBuilder.Entity("Intersect.GameObjects.PlayerVariableBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("Folder"); @@ -393,19 +421,20 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("PlayerVariables"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.ProjectileBase", b => + modelBuilder.Entity("Intersect.GameObjects.ProjectileBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); - b.Property("AmmoItemId").HasColumnName("Ammo"); + b.Property("AmmoItemId") + .HasColumnName("Ammo"); b.Property("AmmoRequired"); - b.Property("AnimationsJson").HasColumnName("Animations"); + b.Property("AnimationsJson") + .HasColumnName("Animations"); b.Property("Delay"); @@ -431,36 +460,39 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Range"); - b.Property("SpawnsJson").HasColumnName("SpawnLocations"); + b.Property("SpawnsJson") + .HasColumnName("SpawnLocations"); b.Property("Speed"); - b.Property("SpellId").HasColumnName("Spell"); + b.Property("SpellId") + .HasColumnName("Spell"); b.Property("TimeCreated"); b.HasKey("Id"); b.ToTable("Projectiles"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.QuestBase", b => + modelBuilder.Entity("Intersect.GameObjects.QuestBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("BeforeDescription"); b.Property("EndDescription"); - b.Property("EndEventId").HasColumnName("EndEvent"); + b.Property("EndEventId") + .HasColumnName("EndEvent"); b.Property("Folder"); b.Property("InProgressDescription"); - b.Property("JsonRequirements").HasColumnName("Requirements"); + b.Property("JsonRequirements") + .HasColumnName("Requirements"); b.Property("LogAfterComplete"); @@ -474,32 +506,37 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StartDescription"); - b.Property("StartEventId").HasColumnName("StartEvent"); + b.Property("StartEventId") + .HasColumnName("StartEvent"); - b.Property("TasksJson").HasColumnName("Tasks"); + b.Property("TasksJson") + .HasColumnName("Tasks"); b.Property("TimeCreated"); b.HasKey("Id"); b.ToTable("Quests"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.ResourceBase", b => + modelBuilder.Entity("Intersect.GameObjects.ResourceBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); - b.Property("AnimationId").HasColumnName("Animation"); + b.Property("AnimationId") + .HasColumnName("Animation"); - b.Property("EventId").HasColumnName("Event"); + b.Property("EventId") + .HasColumnName("Event"); b.Property("Folder"); - b.Property("JsonDrops").HasColumnName("Drops"); + b.Property("JsonDrops") + .HasColumnName("Drops"); - b.Property("JsonHarvestingRequirements").HasColumnName("HarvestingRequirements"); + b.Property("JsonHarvestingRequirements") + .HasColumnName("HarvestingRequirements"); b.Property("MaxHp"); @@ -522,17 +559,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Resources"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.ServerVariableBase", b => + modelBuilder.Entity("Intersect.GameObjects.ServerVariableBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("Folder"); - b.Property("Json").HasColumnName("Value"); + b.Property("Json") + .HasColumnName("Value"); b.Property("Name"); @@ -545,23 +582,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("ServerVariables"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.ShopBase", b => + modelBuilder.Entity("Intersect.GameObjects.ShopBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("BuyingWhitelist"); - b.Property("DefaultCurrencyId").HasColumnName("DefaultCurrency"); + b.Property("DefaultCurrencyId") + .HasColumnName("DefaultCurrency"); b.Property("Folder"); - b.Property("JsonBuyingItems").HasColumnName("BuyingItems"); + b.Property("JsonBuyingItems") + .HasColumnName("BuyingItems"); - b.Property("JsonSellingItems").HasColumnName("SellingItems"); + b.Property("JsonSellingItems") + .HasColumnName("SellingItems"); b.Property("Name"); @@ -570,17 +609,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Shops"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.SpellBase", b => + modelBuilder.Entity("Intersect.GameObjects.SpellBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("Bound"); - b.Property("CastAnimationId").HasColumnName("CastAnimation"); + b.Property("CastAnimationId") + .HasColumnName("CastAnimation"); b.Property("CastDuration"); @@ -588,15 +627,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Description"); - b.Property("EventId").HasColumnName("Event"); + b.Property("EventId") + .HasColumnName("Event"); b.Property("Folder"); - b.Property("HitAnimationId").HasColumnName("HitAnimation"); + b.Property("HitAnimationId") + .HasColumnName("HitAnimation"); b.Property("Icon"); - b.Property("JsonCastRequirements").HasColumnName("CastRequirements"); + b.Property("JsonCastRequirements") + .HasColumnName("CastRequirements"); b.Property("Name"); @@ -604,18 +646,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TimeCreated"); - b.Property("VitalCostJson").HasColumnName("VitalCost"); + b.Property("VitalCostJson") + .HasColumnName("VitalCost"); b.HasKey("Id"); b.ToTable("Spells"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.TilesetBase", b => + modelBuilder.Entity("Intersect.GameObjects.TilesetBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("Name"); @@ -624,15 +666,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Tilesets"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.TimeBase", b => + modelBuilder.Entity("Intersect.GameObjects.TimeBase", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); - b.Property("DaylightHuesJson").HasColumnName("DaylightHues"); + b.Property("DaylightHuesJson") + .HasColumnName("DaylightHues"); b.Property("RangeInterval"); @@ -643,17 +685,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Time"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Maps.MapInstance", b => + modelBuilder.Entity("Intersect.Server.Maps.MapInstance", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("AHue"); - b.Property("AttributeData").HasColumnName("Attributes"); + b.Property("AttributeData") + .HasColumnName("Attributes"); b.Property("BHue"); @@ -661,7 +703,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Down"); - b.Property("EventIdsJson").HasColumnName("Events"); + b.Property("EventIdsJson") + .HasColumnName("Events"); b.Property("Fog"); @@ -677,19 +720,22 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Left"); - b.Property("LightsJson").HasColumnName("Lights"); + b.Property("LightsJson") + .HasColumnName("Lights"); b.Property("Music"); b.Property("Name"); - b.Property("NpcSpawnsJson").HasColumnName("NpcSpawns"); + b.Property("NpcSpawnsJson") + .HasColumnName("NpcSpawns"); b.Property("OverlayGraphic"); b.Property("Panorama"); - b.Property("PlayerLightColorJson").HasColumnName("PlayerLightColor"); + b.Property("PlayerLightColorJson") + .HasColumnName("PlayerLightColor"); b.Property("PlayerLightExpand"); @@ -711,7 +757,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Up"); - b.Property("WeatherAnimationId").HasColumnName("WeatherAnimation"); + b.Property("WeatherAnimationId") + .HasColumnName("WeatherAnimation"); b.Property("WeatherIntensity"); @@ -724,14 +771,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Maps"); - } - ); + }); - modelBuilder.Entity( - "Intersect.GameObjects.AnimationBase", b => + modelBuilder.Entity("Intersect.GameObjects.AnimationBase", b => { - b.OwnsOne( - "Intersect.GameObjects.AnimationLayer", "Lower", b1 => + b.OwnsOne("Intersect.GameObjects.AnimationLayer", "Lower", b1 => { b1.Property("AnimationBaseId"); @@ -759,11 +803,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithOne("Lower") .HasForeignKey("Intersect.GameObjects.AnimationLayer", "AnimationBaseId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - b.OwnsOne( - "Intersect.GameObjects.AnimationLayer", "Upper", b1 => + b.OwnsOne("Intersect.GameObjects.AnimationLayer", "Upper", b1 => { b1.Property("AnimationBaseId"); @@ -791,16 +833,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithOne("Upper") .HasForeignKey("Intersect.GameObjects.AnimationLayer", "AnimationBaseId") .OnDelete(DeleteBehavior.Cascade); - } - ); - } - ); + }); + }); - modelBuilder.Entity( - "Intersect.GameObjects.ItemBase", b => + modelBuilder.Entity("Intersect.GameObjects.ItemBase", b => { - b.OwnsOne( - "Intersect.GameObjects.ConsumableData", "Consumable", b1 => + b.OwnsOne("Intersect.GameObjects.ConsumableData", "Consumable", b1 => { b1.Property("ItemBaseId"); @@ -816,11 +854,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithOne("Consumable") .HasForeignKey("Intersect.GameObjects.ConsumableData", "ItemBaseId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - b.OwnsOne( - "Intersect.GameObjects.EffectData", "Effect", b1 => + b.OwnsOne("Intersect.GameObjects.EffectData", "Effect", b1 => { b1.Property("ItemBaseId"); @@ -834,16 +870,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithOne("Effect") .HasForeignKey("Intersect.GameObjects.EffectData", "ItemBaseId") .OnDelete(DeleteBehavior.Cascade); - } - ); - } - ); + }); + }); - modelBuilder.Entity( - "Intersect.GameObjects.ResourceBase", b => + modelBuilder.Entity("Intersect.GameObjects.ResourceBase", b => { - b.OwnsOne( - "Intersect.GameObjects.ResourceState", "Exhausted", b1 => + b.OwnsOne("Intersect.GameObjects.ResourceState", "Exhausted", b1 => { b1.Property("ResourceBaseId"); @@ -867,11 +899,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithOne("Exhausted") .HasForeignKey("Intersect.GameObjects.ResourceState", "ResourceBaseId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - b.OwnsOne( - "Intersect.GameObjects.ResourceState", "Initial", b1 => + b.OwnsOne("Intersect.GameObjects.ResourceState", "Initial", b1 => { b1.Property("ResourceBaseId"); @@ -895,16 +925,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithOne("Initial") .HasForeignKey("Intersect.GameObjects.ResourceState", "ResourceBaseId") .OnDelete(DeleteBehavior.Cascade); - } - ); - } - ); + }); + }); - modelBuilder.Entity( - "Intersect.GameObjects.SpellBase", b => + modelBuilder.Entity("Intersect.GameObjects.SpellBase", b => { - b.OwnsOne( - "Intersect.GameObjects.SpellCombatData", "Combat", b1 => + b.OwnsOne("Intersect.GameObjects.SpellCombatData", "Combat", b1 => { b1.Property("SpellBaseId"); @@ -928,25 +954,31 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.Property("HotDotInterval"); - b1.Property("OnHitDuration").HasColumnName("OnHit"); + b1.Property("OnHitDuration") + .HasColumnName("OnHit"); - b1.Property("PercentageStatDiffJson").HasColumnName("PercentageStatDiff"); + b1.Property("PercentageStatDiffJson") + .HasColumnName("PercentageStatDiff"); - b1.Property("ProjectileId").HasColumnName("Projectile"); + b1.Property("ProjectileId") + .HasColumnName("Projectile"); b1.Property("Scaling"); b1.Property("ScalingStat"); - b1.Property("StatDiffJson").HasColumnName("StatDiff"); + b1.Property("StatDiffJson") + .HasColumnName("StatDiff"); b1.Property("TargetType"); b1.Property("TransformSprite"); - b1.Property("TrapDuration").HasColumnName("Trap"); + b1.Property("TrapDuration") + .HasColumnName("Trap"); - b1.Property("VitalDiffJson").HasColumnName("VitalDiff"); + b1.Property("VitalDiffJson") + .HasColumnName("VitalDiff"); b1.ToTable("Spells"); @@ -954,11 +986,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithOne("Combat") .HasForeignKey("Intersect.GameObjects.SpellCombatData", "SpellBaseId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - b.OwnsOne( - "Intersect.GameObjects.SpellDashOpts", "Dash", b1 => + b.OwnsOne("Intersect.GameObjects.SpellDashOpts", "Dash", b1 => { b1.Property("SpellBaseId"); @@ -976,11 +1006,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithOne("Dash") .HasForeignKey("Intersect.GameObjects.SpellDashOpts", "SpellBaseId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - b.OwnsOne( - "Intersect.GameObjects.SpellWarpData", "Warp", b1 => + b.OwnsOne("Intersect.GameObjects.SpellWarpData", "Warp", b1 => { b1.Property("SpellBaseId"); @@ -998,13 +1026,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithOne("Warp") .HasForeignKey("Intersect.GameObjects.SpellWarpData", "SpellBaseId") .OnDelete(DeleteBehavior.Cascade); - } - ); - } - ); + }); + }); #pragma warning restore 612, 618 } - } - } diff --git a/Intersect.Server/Migrations/PlayerContextModelSnapshot.cs b/Intersect.Server/Migrations/PlayerContextModelSnapshot.cs index fe45cf5c6c..80857543b8 100644 --- a/Intersect.Server/Migrations/PlayerContextModelSnapshot.cs +++ b/Intersect.Server/Migrations/PlayerContextModelSnapshot.cs @@ -1,28 +1,25 @@ // - using System; - using Intersect.Server.Database.PlayerData; - using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Intersect.Server.Migrations { - [DbContext(typeof(PlayerContext))] partial class PlayerContextModelSnapshot : ModelSnapshot { - protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "2.1.3-rtm-32065"); + modelBuilder + .HasAnnotation("ProductVersion", "2.1.3-rtm-32065"); - modelBuilder.Entity( - "Intersect.Server.Classes.Database.PlayerData.Api.RefreshToken", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Api.RefreshToken", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("ClientId"); @@ -30,9 +27,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Issued"); - b.Property("Subject").IsRequired(); + b.Property("Subject") + .IsRequired(); - b.Property("Ticket").IsRequired(); + b.Property("Ticket") + .IsRequired(); b.Property("TicketId"); @@ -43,13 +42,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("UserId"); b.ToTable("RefreshTokens"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Ban", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Ban", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("Banner"); @@ -61,20 +59,21 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StartTime"); - b.Property("UserId").HasColumnName("PlayerId"); + b.Property("UserId") + .HasColumnName("PlayerId"); b.HasKey("Id"); - b.HasIndex("UserId").IsUnique(); + b.HasIndex("UserId") + .IsUnique(); b.ToTable("Bans"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Mute", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Mute", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("EndTime"); @@ -86,33 +85,33 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StartTime"); - b.Property("UserId").HasColumnName("PlayerId"); + b.Property("UserId") + .HasColumnName("PlayerId"); b.HasKey("Id"); - b.HasIndex("UserId").IsUnique(); + b.HasIndex("UserId") + .IsUnique(); b.ToTable("Mutes"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.Bag", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.Bag", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("SlotCount"); b.HasKey("Id"); b.ToTable("Bags"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.BagSlot", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.BagSlot", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("BagId"); @@ -124,7 +123,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Slot"); - b.Property("StatBuffsJson").HasColumnName("StatBuffs"); + b.Property("StatBuffsJson") + .HasColumnName("StatBuffs"); b.HasKey("Id"); @@ -133,13 +133,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ParentBagId"); b.ToTable("Bag_Items"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.BankSlot", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.BankSlot", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("BagId"); @@ -151,7 +150,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Slot"); - b.Property("StatBuffsJson").HasColumnName("StatBuffs"); + b.Property("StatBuffsJson") + .HasColumnName("StatBuffs"); b.HasKey("Id"); @@ -160,13 +160,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("PlayerId"); b.ToTable("Player_Bank"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.Friend", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.Friend", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("OwnerId"); @@ -179,13 +178,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TargetId"); b.ToTable("Player_Friends"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.HotbarSlot", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.HotbarSlot", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("BagId"); @@ -195,20 +193,20 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Slot"); - b.Property("StatBuffsJson").HasColumnName("PreferredStatBuffs"); + b.Property("StatBuffsJson") + .HasColumnName("PreferredStatBuffs"); b.HasKey("Id"); b.HasIndex("PlayerId"); b.ToTable("Player_Hotbar"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.InventorySlot", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.InventorySlot", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("BagId"); @@ -220,7 +218,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Slot"); - b.Property("StatBuffsJson").HasColumnName("StatBuffs"); + b.Property("StatBuffsJson") + .HasColumnName("StatBuffs"); b.HasKey("Id"); @@ -229,13 +228,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("PlayerId"); b.ToTable("Player_Items"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.Quest", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.Quest", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("Completed"); @@ -251,21 +249,23 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("PlayerId"); - b.HasIndex("QuestId", "PlayerId").IsUnique(); + b.HasIndex("QuestId", "PlayerId") + .IsUnique(); b.ToTable("Player_Quests"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.SpellSlot", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.SpellSlot", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("PlayerId"); b.Property("Slot"); + b.Property("SpellCd"); + b.Property("SpellId"); b.HasKey("Id"); @@ -273,15 +273,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("PlayerId"); b.ToTable("Player_Spells"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.Variable", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.Variable", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); - b.Property("Json").HasColumnName("Value"); + b.Property("Json") + .HasColumnName("Value"); b.Property("PlayerId"); @@ -291,16 +291,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("PlayerId"); - b.HasIndex("VariableId", "PlayerId").IsUnique(); + b.HasIndex("VariableId", "PlayerId") + .IsUnique(); b.ToTable("Player_Variables"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.User", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.User", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("Email"); @@ -312,38 +312,42 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("PasswordResetTime"); - b.Property("PowerJson").HasColumnName("Power"); + b.Property("PowerJson") + .HasColumnName("Power"); b.Property("Salt"); b.HasKey("Id"); b.ToTable("Users"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Entities.Player", b => + modelBuilder.Entity("Intersect.Server.Entities.Player", b => { - b.Property("Id").ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd(); b.Property("ClassId"); b.Property("Dir"); - b.Property("EquipmentJson").HasColumnName("Equipment"); + b.Property("EquipmentJson") + .HasColumnName("Equipment"); b.Property("Exp"); b.Property("Face"); - b.Property("FooterLabelJson").HasColumnName("FooterLabel"); + b.Property("FooterLabelJson") + .HasColumnName("FooterLabel"); b.Property("Gender"); - b.Property("HeaderLabelJson").HasColumnName("HeaderLabel"); + b.Property("HeaderLabelJson") + .HasColumnName("HeaderLabel"); - b.Property("ItemCooldownsJson").HasColumnName("ItemCooldowns"); + b.Property("ItemCooldownsJson") + .HasColumnName("ItemCooldowns"); b.Property("LastOnline"); @@ -353,21 +357,26 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Name"); - b.Property("NameColorJson").HasColumnName("NameColor"); + b.Property("NameColorJson") + .HasColumnName("NameColor"); - b.Property("SpellCooldownsJson").HasColumnName("SpellCooldowns"); + b.Property("SpellCooldownsJson") + .HasColumnName("SpellCooldowns"); b.Property("Sprite"); b.Property("StatPoints"); - b.Property("StatPointsJson").HasColumnName("StatPointAllocations"); + b.Property("StatPointsJson") + .HasColumnName("StatPointAllocations"); - b.Property("StatsJson").HasColumnName("BaseStats"); + b.Property("StatsJson") + .HasColumnName("BaseStats"); b.Property("UserId"); - b.Property("VitalsJson").HasColumnName("Vitals"); + b.Property("VitalsJson") + .HasColumnName("Vitals"); b.Property("X"); @@ -380,44 +389,33 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("UserId"); b.ToTable("Players"); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Classes.Database.PlayerData.Api.RefreshToken", - b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Api.RefreshToken", b => { b.HasOne("Intersect.Server.Database.PlayerData.User", "User") .WithMany("RefreshTokens") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Ban", - b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Ban", b => { b.HasOne("Intersect.Server.Database.PlayerData.User", "User") .WithOne("Ban") .HasForeignKey("Intersect.Server.Database.PlayerData.Ban", "UserId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Mute", - b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Mute", b => { b.HasOne("Intersect.Server.Database.PlayerData.User", "User") .WithOne("Mute") .HasForeignKey("Intersect.Server.Database.PlayerData.Mute", "UserId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.BagSlot", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.BagSlot", b => { b.HasOne("Intersect.Server.Database.PlayerData.Players.Bag", "Bag") .WithMany() @@ -427,11 +425,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithMany("Slots") .HasForeignKey("ParentBagId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.BankSlot", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.BankSlot", b => { b.HasOne("Intersect.Server.Database.PlayerData.Players.Bag", "Bag") .WithMany() @@ -441,11 +437,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithMany("Bank") .HasForeignKey("PlayerId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.Friend", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.Friend", b => { b.HasOne("Intersect.Server.Entities.Player", "Owner") .WithMany("Friends") @@ -456,22 +450,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithMany() .HasForeignKey("TargetId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.HotbarSlot", - b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.HotbarSlot", b => { b.HasOne("Intersect.Server.Entities.Player", "Player") .WithMany("Hotbar") .HasForeignKey("PlayerId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.InventorySlot", b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.InventorySlot", b => { b.HasOne("Intersect.Server.Database.PlayerData.Players.Bag", "Bag") .WithMany() @@ -481,55 +470,40 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithMany("Items") .HasForeignKey("PlayerId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.Quest", - b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.Quest", b => { b.HasOne("Intersect.Server.Entities.Player", "Player") .WithMany("Quests") .HasForeignKey("PlayerId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.SpellSlot", - b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.SpellSlot", b => { b.HasOne("Intersect.Server.Entities.Player", "Player") .WithMany("Spells") .HasForeignKey("PlayerId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Database.PlayerData.Players.Variable", - b => + modelBuilder.Entity("Intersect.Server.Database.PlayerData.Players.Variable", b => { b.HasOne("Intersect.Server.Entities.Player", "Player") .WithMany("Variables") .HasForeignKey("PlayerId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); - modelBuilder.Entity( - "Intersect.Server.Entities.Player", - b => + modelBuilder.Entity("Intersect.Server.Entities.Player", b => { b.HasOne("Intersect.Server.Database.PlayerData.User", "User") .WithMany("Players") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade); - } - ); + }); #pragma warning restore 612, 618 } - } - } From f926b0445c277afb92caaf8c9294d2f88e2ac28c Mon Sep 17 00:00:00 2001 From: JC Snider Date: Thu, 2 Apr 2020 20:30:55 -0400 Subject: [PATCH 06/15] Bringing the most recent bug fixes from master into dev (#73) * Fixing bugs (#47) * Should fix 198, server crash due to projectile trying to hit an event * Harden accept trade packet to return if counterparty is null. * Fixing potential NREs * Fixes another potential NRE and out of bounds error * Don't want to handle packets for null clients, but also don't want to be throwing exceptions * Fixes a small error where empty passwords crash the server during migration * Updated licensing leading up to open source release (#49) * Create FUNDING.yml (#50) * Use dynamicsoundeffects for music instead of mediaplayer (#51) * Fixing bugs (#52) * Should fix 198, server crash due to projectile trying to hit an event * Harden accept trade packet to return if counterparty is null. * Fixing potential NREs * Fixes another potential NRE and out of bounds error * Don't want to handle packets for null clients, but also don't want to be throwing exceptions * Fixes a small error where empty passwords crash the server during migration * Small edit so that networking doesn't alter ui, only triggers ui to update next draw * Fixed events jumping all over the place * Allow checking of evtMap parameter even if no page instance has spawned * Basic bounds checking on pathfinding to potentially fix Weylon's bug. * Fix for events being able to step on traps. * Stop caching of expressions as they are used once * Fixed select character window not resetting paperdolls properly when cycling through characters * Fixes empty friends list when opening friends via a hotkey * Added server loop lock for when updating game objects (less likely to have deadlocks if not processing npcs when updating npcs, for example) * Fix collection changed bug when maps update while server loop is running * Fixes weird instance where the server would error while trying to send a map to a client who didn't have an entity set * Adds SpellCd back into the PlayerContextModelSnapshot since it was never actually removed from the database. (#56) * Fixing db context model snapshot formatting (#58) * Adds SpellCd back into the PlayerContextModelSnapshot since it was never actually removed from the database. * EF expected formatting fix for game context model snapshot * We don't need to be handling input for all the players we are updating only our player. (#62) * Properly load list data within locking region (#70) * Cleanup code in RefreshToken * Actually load list data before exiting locking region * Fix event graphic selector not opening to current graphic (#72) Co-authored-by: Robert Lodico --- Intersect.Client/Entities/Player.cs | 8 ++- .../Event Commands/Event_GraphicSelector.cs | 6 +- .../Database/PlayerData/Api/RefreshToken.cs | 61 +++---------------- Intersect.Server/Database/PlayerData/User.cs | 4 +- Intersect.Server/Entities/Player.Database.cs | 8 +-- 5 files changed, 26 insertions(+), 61 deletions(-) diff --git a/Intersect.Client/Entities/Player.cs b/Intersect.Client/Entities/Player.cs index 4620cea9ec..e7af06e01a 100644 --- a/Intersect.Client/Entities/Player.cs +++ b/Intersect.Client/Entities/Player.cs @@ -143,7 +143,13 @@ public bool IsBusy() public override bool Update() { - HandleInput(); + + if (Globals.Me == this) + { + HandleInput(); + } + + if (!IsBusy()) { if (this == Globals.Me && IsMoving == false) diff --git a/Intersect.Editor/Forms/Editors/Events/Event Commands/Event_GraphicSelector.cs b/Intersect.Editor/Forms/Editors/Events/Event Commands/Event_GraphicSelector.cs index bdfc110691..cf11796a47 100644 --- a/Intersect.Editor/Forms/Editors/Events/Event Commands/Event_GraphicSelector.cs +++ b/Intersect.Editor/Forms/Editors/Events/Event Commands/Event_GraphicSelector.cs @@ -41,11 +41,13 @@ public partial class EventGraphicSelector : UserControl ) { InitializeComponent(); + InitLocalization(); mEditingGraphic = editingGraphic; mEventEditor = eventEditor; mLoading = true; + cmbGraphicType.SelectedIndex = (int)mEditingGraphic.Type; UpdateGraphicList(); - if (cmbGraphic.Items.IndexOf(mEditingGraphic.Filename) > -1) + if (cmbGraphic.Items.Contains(mEditingGraphic.Filename)) { cmbGraphic.SelectedIndex = cmbGraphic.Items.IndexOf(mEditingGraphic.Filename); } @@ -53,8 +55,6 @@ public partial class EventGraphicSelector : UserControl mRouteDesigner = moveRouteDesigner; mNewRouteAction = newMoveRouteAction; mLoading = false; - InitLocalization(); - cmbGraphicType.SelectedIndex = (int) mEditingGraphic.Type; mTmpGraphic.CopyFrom(mEditingGraphic); UpdatePreview(); } diff --git a/Intersect.Server/Database/PlayerData/Api/RefreshToken.cs b/Intersect.Server/Database/PlayerData/Api/RefreshToken.cs index bb6bdcd547..1cdb8695e0 100644 --- a/Intersect.Server/Database/PlayerData/Api/RefreshToken.cs +++ b/Intersect.Server/Database/PlayerData/Api/RefreshToken.cs @@ -86,16 +86,12 @@ public class RefreshToken return true; } + [CanBeNull] public static RefreshToken Find(Guid id) { lock (DbInterface.GetPlayerContextLock()) { - if (DbInterface.GetPlayerContext()?.RefreshTokens == null) - { - return null; - } - - return DbInterface.GetPlayerContext()?.RefreshTokens.Find(id); + return DbInterface.GetPlayerContext()?.RefreshTokens?.Find(id); } } @@ -108,23 +104,16 @@ public static RefreshToken FindForTicket([CanBeNull] Guid ticketId) lock (DbInterface.GetPlayerContextLock()) { - if (DbInterface.GetPlayerContext()?.RefreshTokens == null) - { - return null; - } - var playerContext = DbInterface.GetPlayerContext(); - var refreshToken = playerContext?.RefreshTokens?.Where(queryToken => queryToken.TicketId == ticketId) - .FirstOrDefault(); + var refreshToken = + playerContext?.RefreshTokens.FirstOrDefault(queryToken => queryToken.TicketId == ticketId); if (refreshToken == null || DateTime.UtcNow < refreshToken.Expires) { return refreshToken; } - else - { - Remove(refreshToken, true); - } + + Remove(refreshToken, true); } return null; @@ -139,13 +128,8 @@ public static IEnumerable FindForClient(Guid clientId) lock (DbInterface.GetPlayerContextLock()) { - if (DbInterface.GetPlayerContext()?.RefreshTokens == null) - { - return null; - } - var tokenQuery = DbInterface.GetPlayerContext() - ?.RefreshTokens?.Where(queryToken => queryToken.ClientId == clientId); + ?.RefreshTokens.Where(queryToken => queryToken.ClientId == clientId); return tokenQuery.AsEnumerable()?.ToList(); } @@ -160,13 +144,8 @@ public static IEnumerable FindForUser(Guid userId) lock (DbInterface.GetPlayerContextLock()) { - if (DbInterface.GetPlayerContext()?.RefreshTokens == null) - { - return null; - } - var tokenQuery = DbInterface.GetPlayerContext() - ?.RefreshTokens?.Where(queryToken => queryToken.UserId == userId); + ?.RefreshTokens.Where(queryToken => queryToken.UserId == userId); return tokenQuery.AsEnumerable()?.ToList(); } @@ -181,13 +160,8 @@ public static RefreshToken FindOneForUser(Guid userId) { lock (DbInterface.GetPlayerContextLock()) { - if (DbInterface.GetPlayerContext()?.RefreshTokens == null) - { - return null; - } - var token = DbInterface.GetPlayerContext() - ?.RefreshTokens?.First(queryToken => queryToken.UserId == userId); + ?.RefreshTokens.First(queryToken => queryToken.UserId == userId); return token; } @@ -202,23 +176,13 @@ public static bool Remove(Guid id, bool commit = false) { var token = Find(id); - if (token == null) - { - return false; - } - - return Remove(token, commit); + return token != null && Remove(token, commit); } public static bool Remove([NotNull] RefreshToken token, bool commit = false) { lock (DbInterface.GetPlayerContextLock()) { - if (DbInterface.GetPlayerContext()?.RefreshTokens == null) - { - return false; - } - DbInterface.GetPlayerContext()?.RefreshTokens.Remove(token); return true; @@ -229,11 +193,6 @@ public static bool RemoveAll([NotNull] IEnumerable tokens, bool co { lock (DbInterface.GetPlayerContextLock()) { - if (DbInterface.GetPlayerContext()?.RefreshTokens == null) - { - return false; - } - DbInterface.GetPlayerContext()?.RefreshTokens.RemoveRange(tokens); return true; diff --git a/Intersect.Server/Database/PlayerData/User.cs b/Intersect.Server/Database/PlayerData/User.cs index d71f7fc941..65acc01d71 100644 --- a/Intersect.Server/Database/PlayerData/User.cs +++ b/Intersect.Server/Database/PlayerData/User.cs @@ -247,7 +247,7 @@ public static IEnumerable List(int page, int count, [CanBeNull] PlayerCont var context = DbInterface.GetPlayerContext(); try { - return QueryUsers(context, page * count, count) ?? throw new InvalidOperationException(); + return QueryUsers(context, page * count, count)?.ToList() ?? throw new InvalidOperationException(); } catch (Exception exception) { @@ -259,7 +259,7 @@ public static IEnumerable List(int page, int count, [CanBeNull] PlayerCont } else { - return QueryUsers(playerContext, page, count) ?? throw new InvalidOperationException(); + return QueryUsers(playerContext, page, count)?.ToList() ?? throw new InvalidOperationException(); } } diff --git a/Intersect.Server/Entities/Player.Database.cs b/Intersect.Server/Entities/Player.Database.cs index d09abb91bf..97b8cd3196 100644 --- a/Intersect.Server/Entities/Player.Database.cs +++ b/Intersect.Server/Entities/Player.Database.cs @@ -154,7 +154,7 @@ public static int Count() } [NotNull] - public static IEnumerable List(int page, int count, [CanBeNull] PlayerContext playerContext = null) + public static IList List(int page, int count, [CanBeNull] PlayerContext playerContext = null) { if (playerContext == null) { @@ -162,12 +162,12 @@ public static IEnumerable List(int page, int count, [CanBeNull] PlayerCo { var context = DbInterface.GetPlayerContext(); - return QueryPlayers(context, page * count, count) ?? throw new InvalidOperationException(); + return QueryPlayers(context, page * count, count)?.ToList() ?? throw new InvalidOperationException(); } } else { - return QueryPlayers(playerContext, page * count, count) ?? throw new InvalidOperationException(); + return QueryPlayers(playerContext, page * count, count)?.ToList() ?? throw new InvalidOperationException(); } } @@ -192,7 +192,7 @@ public static IEnumerable List(int page, int count, [CanBeNull] PlayerCo ? QueryPlayersWithRankAscending(context, page * count, count) : QueryPlayersWithRank(context, page * count, count); - return results ?? throw new InvalidOperationException(); + return results?.ToList() ?? throw new InvalidOperationException(); } } From cb1d854ba4434456e7fff10a29112cc803ba5201 Mon Sep 17 00:00:00 2001 From: JC Snider Date: Fri, 3 Apr 2020 23:23:44 -0400 Subject: [PATCH 07/15] Added in enhanced party options so you can configure how close players need to be to get xp and for the npc death party common events to run --- Intersect (Core)/Config/Options.cs | 10 ++++++++-- Intersect (Core)/Config/PartyOptions.cs | 19 +++++++++++++++++++ Intersect (Core)/Config/PlayerOptions.cs | 2 -- Intersect (Core)/Intersect (Core).csproj | 1 + Intersect.Server/Networking/PacketHandler.cs | 2 +- 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 Intersect (Core)/Config/PartyOptions.cs diff --git a/Intersect (Core)/Config/Options.cs b/Intersect (Core)/Config/Options.cs index c3ad1b7c22..40e9cb474f 100644 --- a/Intersect (Core)/Config/Options.cs +++ b/Intersect (Core)/Config/Options.cs @@ -50,6 +50,8 @@ public class Options [JsonProperty("Player")] public PlayerOptions PlayerOpts = new PlayerOptions(); + [JsonProperty("Party")] public PartyOptions PartyOpts = new PartyOptions(); + [JsonProperty("Security")] public SecurityOptions SecurityOpts = new SecurityOptions(); public SmtpSettings SmtpSettings = new SmtpSettings(); @@ -79,9 +81,13 @@ public class Options public static int RequestTimeout => Instance.PlayerOpts.RequestTimeout; - public static int TradeRange => Instance.PlayerOpts.TradeRange; + public static int PartyInviteRange => Instance.PartyOpts.InviteRange; + + public static int PartySharedXpRange => Instance.PartyOpts.SharedXpRange; - public static int PartyRange => Instance.PlayerOpts.PartyRange; + public static int PartyStartCommonEventRange => Instance.PartyOpts.NpcDeathCommonEventStartRange; + + public static int TradeRange => Instance.PlayerOpts.TradeRange; public static int WeaponIndex => Instance.EquipmentOpts.WeaponSlot; diff --git a/Intersect (Core)/Config/PartyOptions.cs b/Intersect (Core)/Config/PartyOptions.cs new file mode 100644 index 0000000000..5aaf2894b3 --- /dev/null +++ b/Intersect (Core)/Config/PartyOptions.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Intersect.Config +{ + public class PartyOptions + { + + public int InviteRange = 40; + + public int SharedXpRange = 40; + + public int NpcDeathCommonEventStartRange = 0; + + } +} diff --git a/Intersect (Core)/Config/PlayerOptions.cs b/Intersect (Core)/Config/PlayerOptions.cs index 7e5c5ca66f..91aa3e8657 100644 --- a/Intersect (Core)/Config/PlayerOptions.cs +++ b/Intersect (Core)/Config/PlayerOptions.cs @@ -18,8 +18,6 @@ public class PlayerOptions public int MaxStat = 255; - public int PartyRange = 80; - public int RequestTimeout = 300000; public int TradeRange = 6; diff --git a/Intersect (Core)/Intersect (Core).csproj b/Intersect (Core)/Intersect (Core).csproj index 6b16e4c303..addab33e35 100644 --- a/Intersect (Core)/Intersect (Core).csproj +++ b/Intersect (Core)/Intersect (Core).csproj @@ -192,6 +192,7 @@ + diff --git a/Intersect.Server/Networking/PacketHandler.cs b/Intersect.Server/Networking/PacketHandler.cs index 5814f5e7d9..07a76617cd 100644 --- a/Intersect.Server/Networking/PacketHandler.cs +++ b/Intersect.Server/Networking/PacketHandler.cs @@ -1446,7 +1446,7 @@ public void HandlePacket(Client client, Player player, PartyInvitePacket packet) var target = Player.FindOnline(packet.TargetId); - if (target != null && target.Id != player.Id && player.InRangeOf(target, Options.PartyRange)) + if (target != null && target.Id != player.Id && player.InRangeOf(target, Options.PartyInviteRange)) { target.InviteToParty(player); From 801090c8f9ceefdd64873893a776c2a8fb6392fa Mon Sep 17 00:00:00 2001 From: JC Snider Date: Thu, 2 Apr 2020 20:41:06 -0400 Subject: [PATCH 08/15] Fixes collection was modified error when looping through map traps (#74) --- Intersect.Server/Entities/Entity.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Intersect.Server/Entities/Entity.cs b/Intersect.Server/Entities/Entity.cs index 5bd4fa8ebe..74cc77427f 100644 --- a/Intersect.Server/Entities/Entity.cs +++ b/Intersect.Server/Entities/Entity.cs @@ -844,9 +844,15 @@ public virtual void Move(int moveDir, Player forPlayer, bool doNotUpdate = false } //Check for traps - foreach (var trap in MapInstance.Get(MapId).MapTraps) + if (currentMap != null) { - trap.CheckEntityHasDetonatedTrap(this); + lock (currentMap.GetMapLock()) + { + foreach (var trap in currentMap.MapTraps) + { + trap.CheckEntityHasDetonatedTrap(this); + } + } } // TODO: Why was this scoped to only Event entities? From 6d83e7f58f48906fc86789734f15c30edbb705d0 Mon Sep 17 00:00:00 2001 From: Robert Lodico Date: Sat, 4 Apr 2020 15:28:41 -0400 Subject: [PATCH 09/15] Add additional logging to diagnose the real cause of #80 --- Intersect.Server/Core/ServerContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Intersect.Server/Core/ServerContext.cs b/Intersect.Server/Core/ServerContext.cs index 9d4d89c9e7..35811b5676 100644 --- a/Intersect.Server/Core/ServerContext.cs +++ b/Intersect.Server/Core/ServerContext.cs @@ -133,8 +133,9 @@ protected override void Dispose(bool disposing) { ThreadConsole.Abort(); } - catch (ThreadAbortException ex) + catch (ThreadAbortException threadAbortException) { + Log.Error(threadAbortException, $"{nameof(ThreadConsole)} aborted."); } } } @@ -148,8 +149,9 @@ protected override void Dispose(bool disposing) { ThreadLogic.Abort(); } - catch (ThreadAbortException ex) + catch (ThreadAbortException threadAbortException) { + Log.Error(threadAbortException, $"{nameof(ThreadLogic)} aborted."); } } } From 5cc32bd950747c8cdbc178cd76c5b5bbd3537af7 Mon Sep 17 00:00:00 2001 From: Robert Lodico Date: Fri, 3 Apr 2020 21:54:19 -0400 Subject: [PATCH 10/15] Server status details with additional strings --- Intersect (Core)/Intersect (Core).csproj | 2 + .../Network/Events/ConnectionEventArgs.cs | 11 ++ .../Network/INetworkLayerInterface.cs | 9 +- Intersect (Core)/Network/NetworkStatus.cs | 23 +++ .../Network/GameSocket.cs | 21 ++- Intersect.Client/Interface/Menu/MainMenu.cs | 20 +-- Intersect.Client/Localization/Strings.cs | 6 + Intersect.Client/MonoGame/IntersectGame.cs | 6 +- .../MonoGame/Network/MonoSocket.cs | 6 +- Intersect.Client/Networking/Network.cs | 9 +- Intersect.Client/Networking/NetworkStatus.cs | 25 ++- Intersect.Editor/Networking/Network.cs | 5 +- Intersect.Network/ClientNetwork.cs | 25 +-- Intersect.Network/LidgrenInterface.cs | 167 +++++++++++------- .../Networking/Lidgren/ServerNetwork.cs | 38 ++-- 15 files changed, 221 insertions(+), 152 deletions(-) create mode 100644 Intersect (Core)/Network/Events/ConnectionEventArgs.cs create mode 100644 Intersect (Core)/Network/NetworkStatus.cs diff --git a/Intersect (Core)/Intersect (Core).csproj b/Intersect (Core)/Intersect (Core).csproj index addab33e35..d4b4f31316 100644 --- a/Intersect (Core)/Intersect (Core).csproj +++ b/Intersect (Core)/Intersect (Core).csproj @@ -297,6 +297,8 @@ + + diff --git a/Intersect (Core)/Network/Events/ConnectionEventArgs.cs b/Intersect (Core)/Network/Events/ConnectionEventArgs.cs new file mode 100644 index 0000000000..af5bb618a8 --- /dev/null +++ b/Intersect (Core)/Network/Events/ConnectionEventArgs.cs @@ -0,0 +1,11 @@ +using System; + +namespace Intersect.Network.Events +{ + public class ConnectionEventArgs : EventArgs + { + public NetworkStatus NetworkStatus { get; set; } + + public IConnection Connection { get; set; } + } +} diff --git a/Intersect (Core)/Network/INetworkLayerInterface.cs b/Intersect (Core)/Network/INetworkLayerInterface.cs index f78cb28757..795a5cb4c7 100644 --- a/Intersect (Core)/Network/INetworkLayerInterface.cs +++ b/Intersect (Core)/Network/INetworkLayerInterface.cs @@ -2,15 +2,18 @@ using System.Collections.Generic; using Intersect.Memory; +using Intersect.Network.Events; + +using JetBrains.Annotations; namespace Intersect.Network { - public delegate void HandlePacketAvailable(INetworkLayerInterface sender); + public delegate void HandlePacketAvailable([NotNull] INetworkLayerInterface sender); - public delegate void HandleConnectionEvent(INetworkLayerInterface sender, IConnection connection); + public delegate void HandleConnectionEvent([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs); - public delegate bool HandleConnectionRequest(INetworkLayerInterface sender, IConnection connection); + public delegate bool HandleConnectionRequest([NotNull] INetworkLayerInterface sender, IConnection connection); public interface INetworkLayerInterface : IDisposable { diff --git a/Intersect (Core)/Network/NetworkStatus.cs b/Intersect (Core)/Network/NetworkStatus.cs new file mode 100644 index 0000000000..5ad91f5296 --- /dev/null +++ b/Intersect (Core)/Network/NetworkStatus.cs @@ -0,0 +1,23 @@ +namespace Intersect.Network +{ + public enum NetworkStatus + { + + Unknown = 0, + + Connecting, + + Online, + + Offline, + + Failed, + + VersionMismatch, + + ServerFull, + + HandshakeFailure + + } +} diff --git a/Intersect.Client.Framework/Network/GameSocket.cs b/Intersect.Client.Framework/Network/GameSocket.cs index 4d602d0d3f..261341ee50 100644 --- a/Intersect.Client.Framework/Network/GameSocket.cs +++ b/Intersect.Client.Framework/Network/GameSocket.cs @@ -1,4 +1,7 @@ using Intersect.Network; +using Intersect.Network.Events; + +using JetBrains.Annotations; namespace Intersect.Client.Framework.Network { @@ -33,29 +36,29 @@ protected void OnDataReceived(IPacket packet) DataReceived?.Invoke(packet); } - protected void OnConnected() + protected void OnConnected([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { - Connected?.Invoke(); + Connected?.Invoke(sender, connectionEventArgs); } - protected void OnConnectionFailed(bool denied) + protected void OnConnectionFailed([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs, bool denied) { - ConnectionFailed?.Invoke(denied); + ConnectionFailed?.Invoke(sender, connectionEventArgs, denied); } - protected void OnDisconnected() + protected void OnDisconnected([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { - Disconnected?.Invoke(); + Disconnected?.Invoke(sender, connectionEventArgs); } } public delegate void DataReceivedHandler(IPacket packet); - public delegate void ConnectedHandler(); + public delegate void ConnectedHandler([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs); - public delegate void ConnectionFailedHandler(bool denied); + public delegate void ConnectionFailedHandler([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs, bool denied); - public delegate void DisconnectedHandler(); + public delegate void DisconnectedHandler([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs); } diff --git a/Intersect.Client/Interface/Menu/MainMenu.cs b/Intersect.Client/Interface/Menu/MainMenu.cs index e3d95bd5f6..e42d21f744 100644 --- a/Intersect.Client/Interface/Menu/MainMenu.cs +++ b/Intersect.Client/Interface/Menu/MainMenu.cs @@ -9,6 +9,8 @@ using Intersect.Client.Interface.Shared; using Intersect.Client.Localization; using Intersect.Client.Networking; +using Intersect.Network; +using Intersect.Network.Events; using JetBrains.Annotations; @@ -326,7 +328,7 @@ private void UpdateDisabled() { mLoginButton.IsDisabled = ActiveNetworkStatus != NetworkStatus.Online; mRegisterButton.IsDisabled = ActiveNetworkStatus != NetworkStatus.Online || - Options.Loaded && Options.BlockClientRegistrations == true; + Options.Loaded && Options.BlockClientRegistrations; } public static void OnNetworkConnecting() @@ -334,21 +336,9 @@ public static void OnNetworkConnecting() ActiveNetworkStatus = NetworkStatus.Connecting; } - public static void OnNetworkConnected() + public static void SetNetworkStatus(NetworkStatus networkStatus) { - ActiveNetworkStatus = NetworkStatus.Online; - NetworkStatusChanged?.Invoke(); - } - - public static void OnNetworkDisconnected() - { - ActiveNetworkStatus = NetworkStatus.Offline; - NetworkStatusChanged?.Invoke(); - } - - public static void OnNetworkFailed(bool denied) - { - ActiveNetworkStatus = denied ? NetworkStatus.Failed : NetworkStatus.Connecting; + ActiveNetworkStatus = networkStatus; NetworkStatusChanged?.Invoke(); } diff --git a/Intersect.Client/Localization/Strings.cs b/Intersect.Client/Localization/Strings.cs index 466cfc6872..f364be9bc9 100644 --- a/Intersect.Client/Localization/Strings.cs +++ b/Intersect.Client/Localization/Strings.cs @@ -1335,6 +1335,12 @@ public struct Server public static LocalizedString Unknown = @"Unknown"; + public static LocalizedString VersionMismatch = @"Version mismatch"; + + public static LocalizedString ServerFull = @"Server Full"; + + public static LocalizedString HandshakeFailure = @"Handshake Failure"; + } public struct Shop diff --git a/Intersect.Client/MonoGame/IntersectGame.cs b/Intersect.Client/MonoGame/IntersectGame.cs index 5b26f4f1c5..a8f8f531ec 100644 --- a/Intersect.Client/MonoGame/IntersectGame.cs +++ b/Intersect.Client/MonoGame/IntersectGame.cs @@ -95,9 +95,9 @@ protected override void Initialize() // TODO: Remove old netcode Networking.Network.Socket = new MonoSocket(); - Networking.Network.Socket.Connected += MainMenu.OnNetworkConnected; - Networking.Network.Socket.ConnectionFailed += MainMenu.OnNetworkFailed; - Networking.Network.Socket.Disconnected += MainMenu.OnNetworkDisconnected; + Networking.Network.Socket.Connected += (sender, connectionEventArgs) => MainMenu.SetNetworkStatus(connectionEventArgs.NetworkStatus); + Networking.Network.Socket.ConnectionFailed += (sender, connectionEventArgs, denied) => MainMenu.SetNetworkStatus(connectionEventArgs.NetworkStatus); + Networking.Network.Socket.Disconnected += (sender, connectionEventArgs) => MainMenu.SetNetworkStatus(connectionEventArgs.NetworkStatus); Main.Start(); base.Initialize(); diff --git a/Intersect.Client/MonoGame/Network/MonoSocket.cs b/Intersect.Client/MonoGame/Network/MonoSocket.cs index 0793adcc5e..b49103fcd3 100644 --- a/Intersect.Client/MonoGame/Network/MonoSocket.cs +++ b/Intersect.Client/MonoGame/Network/MonoSocket.cs @@ -48,9 +48,9 @@ public override void Connect(string host, int port) } ClientLidgrenNetwork.Handler = AddPacketToQueue; - ClientLidgrenNetwork.OnConnected += delegate { OnConnected(); }; - ClientLidgrenNetwork.OnDisconnected += delegate { OnDisconnected(); }; - ClientLidgrenNetwork.OnConnectionDenied += delegate { OnConnectionFailed(true); }; + ClientLidgrenNetwork.OnConnected += OnConnected; + ClientLidgrenNetwork.OnDisconnected += OnDisconnected; + ClientLidgrenNetwork.OnConnectionDenied += (sender, connectionEventArgs) => OnConnectionFailed(sender, connectionEventArgs, true); if (!ClientLidgrenNetwork.Connect()) { diff --git a/Intersect.Client/Networking/Network.cs b/Intersect.Client/Networking/Network.cs index fea18bc702..f57b792d55 100644 --- a/Intersect.Client/Networking/Network.cs +++ b/Intersect.Client/Networking/Network.cs @@ -6,6 +6,9 @@ using Intersect.Configuration; using Intersect.Logging; using Intersect.Network; +using Intersect.Network.Events; + +using JetBrains.Annotations; namespace Intersect.Client.Networking { @@ -50,7 +53,7 @@ private static void TryConnect() Socket?.Connect(ClientConfiguration.Instance.Host, ClientConfiguration.Instance.Port); } - private static void MySocket_OnConnectionFailed(bool denied) + private static void MySocket_OnConnectionFailed([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs, bool denied) { sConnected = false; if (!denied) @@ -64,7 +67,7 @@ private static void MySocket_OnDataReceived(IPacket packet) PacketHandler.HandlePacket(packet); } - private static void MySocket_OnDisconnected() + private static void MySocket_OnDisconnected([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { //Not sure how to handle this yet! sConnected = false; @@ -81,7 +84,7 @@ private static void MySocket_OnDisconnected() } } - private static void MySocket_OnConnected() + private static void MySocket_OnConnected([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { //Not sure how to handle this yet! sConnected = true; diff --git a/Intersect.Client/Networking/NetworkStatus.cs b/Intersect.Client/Networking/NetworkStatus.cs index b7ee0ceaeb..d99d249e52 100644 --- a/Intersect.Client/Networking/NetworkStatus.cs +++ b/Intersect.Client/Networking/NetworkStatus.cs @@ -1,25 +1,11 @@ using System; using Intersect.Client.Localization; +using Intersect.Network; namespace Intersect.Client.Networking { - public enum NetworkStatus - { - - Unknown = 0, - - Connecting, - - Online, - - Offline, - - Failed - - } - public static class NetworkStatusExtensions { @@ -42,6 +28,15 @@ public static string ToLocalizedString(this NetworkStatus networkStatus) case NetworkStatus.Failed: return Strings.Server.Failed; + case NetworkStatus.VersionMismatch: + return Strings.Server.VersionMismatch; + + case NetworkStatus.ServerFull: + return Strings.Server.ServerFull; + + case NetworkStatus.HandshakeFailure: + return Strings.Server.HandshakeFailure; + default: throw new ArgumentOutOfRangeException(nameof(networkStatus), networkStatus, null); } diff --git a/Intersect.Editor/Networking/Network.cs b/Intersect.Editor/Networking/Network.cs index eda34c9c66..bae81cbf09 100644 --- a/Intersect.Editor/Networking/Network.cs +++ b/Intersect.Editor/Networking/Network.cs @@ -9,6 +9,9 @@ using Intersect.Network; using Intersect.Network.Crypto; using Intersect.Network.Crypto.Formats; +using Intersect.Network.Events; + +using JetBrains.Annotations; namespace Intersect.Editor.Networking { @@ -80,7 +83,7 @@ public static void DestroyNetwork() } } - public static void HandleDc(INetworkLayerInterface netInterface, IConnection netConnection) + public static void HandleDc([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { DestroyNetwork(); if (Globals.MainForm != null && Globals.MainForm.Visible) diff --git a/Intersect.Network/ClientNetwork.cs b/Intersect.Network/ClientNetwork.cs index 1a37c19855..3808b36aa9 100644 --- a/Intersect.Network/ClientNetwork.cs +++ b/Intersect.Network/ClientNetwork.cs @@ -4,6 +4,7 @@ using System.Security.Cryptography; using Intersect.Logging; +using Intersect.Network.Events; using JetBrains.Annotations; @@ -94,30 +95,30 @@ public override bool Send(ICollection connections, IPacket packet) return Send(packet); } - protected virtual void HandleInterfaceOnConnected(INetworkLayerInterface sender, IConnection connection) + protected virtual void HandleInterfaceOnConnected([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { - Log.Info($"Connected [{connection?.Guid}]."); + Log.Info($"Connected [{connectionEventArgs.Connection?.Guid}]."); IsConnected = true; - OnConnected?.Invoke(sender, connection); + OnConnected?.Invoke(sender, connectionEventArgs); } - protected virtual void HandleInterfaceOnConnectonApproved(INetworkLayerInterface sender, IConnection connection) + protected virtual void HandleInterfaceOnConnectonApproved([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { - Log.Info($"Connection approved [{connection?.Guid}]."); - OnConnectionApproved?.Invoke(sender, connection); + Log.Info($"Connection approved [{connectionEventArgs.Connection?.Guid}]."); + OnConnectionApproved?.Invoke(sender, connectionEventArgs); } - protected virtual void HandleInterfaceOnConnectonDenied(INetworkLayerInterface sender, IConnection connection) + protected virtual void HandleInterfaceOnConnectonDenied([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { - Log.Info($"Connection denied [{connection?.Guid}]."); - OnConnectionDenied?.Invoke(sender, connection); + Log.Info($"Connection denied [{connectionEventArgs.Connection?.Guid}]."); + OnConnectionDenied?.Invoke(sender, connectionEventArgs); } - protected virtual void HandleInterfaceOnDisconnected(INetworkLayerInterface sender, IConnection connection) + protected virtual void HandleInterfaceOnDisconnected([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { - Log.Info($"Disconnected [{connection?.Guid ?? Guid.Empty}]."); + Log.Info($"Disconnected [{connectionEventArgs.Connection?.Guid ?? Guid.Empty}]."); IsConnected = false; - OnDisconnected?.Invoke(sender, connection); + OnDisconnected?.Invoke(sender, connectionEventArgs); } public void Close() diff --git a/Intersect.Network/LidgrenInterface.cs b/Intersect.Network/LidgrenInterface.cs index eb629c65a0..920afd7cef 100644 --- a/Intersect.Network/LidgrenInterface.cs +++ b/Intersect.Network/LidgrenInterface.cs @@ -7,6 +7,7 @@ using Intersect.Logging; using Intersect.Memory; +using Intersect.Network.Events; using Intersect.Network.Packets; using Intersect.Utilities; @@ -22,12 +23,6 @@ public sealed class LidgrenInterface : INetworkLayerInterface public delegate void HandleUnconnectedMessage(NetPeer peer, NetIncomingMessage message); - private const string RejectBadHail = "bad_hail"; - - private const string RejectBadVersion = "bad_version"; - - private const string RejectServerError = "server_error"; - private static readonly IConnection[] EmptyConnections = { }; [NotNull] private readonly Ceras mCeras = new Ceras(true); @@ -494,6 +489,7 @@ private NetIncomingMessage TryHandleInboundMessage() Log.Diagnostic($"{message.MessageType}: {message} [{connection?.Status}]"); break; + case NetConnectionStatus.Disconnecting: Log.Debug($"{message.MessageType}: {message} [{connection?.Status}]"); @@ -515,7 +511,14 @@ private NetIncomingMessage TryHandleInboundMessage() } FireHandler( - OnConnectionApproved, nameof(OnConnectionApproved), this, intersectConnection + OnConnectionApproved, + nameof(OnConnectionApproved), + this, + new ConnectionEventArgs + { + NetworkStatus = NetworkStatus.Connecting, + Connection = intersectConnection + } ); Debug.Assert(connection != null, "connection != null"); @@ -523,14 +526,13 @@ private NetIncomingMessage TryHandleInboundMessage() if (!intersectConnection.HandleApproval(approval)) { - mNetwork?.Disconnect("bad_handshake_secret"); - connection.Disconnect("bad_handshake_secret"); + mNetwork.Disconnect(NetworkStatus.HandshakeFailure.ToString()); + connection.Disconnect(NetworkStatus.HandshakeFailure.ToString()); break; } - var clientNetwork = mNetwork as ClientNetwork; - if (clientNetwork == null) + if (!(mNetwork is ClientNetwork clientNetwork)) { throw new InvalidOperationException(); } @@ -559,7 +561,16 @@ private NetIncomingMessage TryHandleInboundMessage() intersectConnection?.HandleConnected(); } - FireHandler(OnConnected, nameof(OnConnected), this, intersectConnection); + FireHandler( + OnConnected, + nameof(OnConnected), + this, + new ConnectionEventArgs + { + NetworkStatus = NetworkStatus.Online, + Connection = intersectConnection + } + ); } break; @@ -571,29 +582,45 @@ private NetIncomingMessage TryHandleInboundMessage() var result = (NetConnectionStatus) message.ReadByte(); var reason = message.ReadString(); + NetworkStatus networkStatus; + try + { + networkStatus = (NetworkStatus) Enum.Parse(typeof(NetworkStatus), reason, true); + } + catch (Exception exception) + { + Log.Diagnostic(exception); + networkStatus = NetworkStatus.Unknown; + } + HandleConnectionEvent disconnectHandler; string disconnectHandlerName; - switch (reason) + switch (networkStatus) { - case RejectBadHail: - case RejectBadVersion: - case RejectServerError: + case NetworkStatus.Unknown: + case NetworkStatus.HandshakeFailure: + case NetworkStatus.ServerFull: + case NetworkStatus.VersionMismatch: + case NetworkStatus.Failed: disconnectHandler = OnConnectionDenied; disconnectHandlerName = nameof(OnConnectionDenied); - break; - default: + case NetworkStatus.Connecting: + case NetworkStatus.Online: + case NetworkStatus.Offline: disconnectHandler = OnDisconnected; disconnectHandlerName = nameof(OnDisconnected); - break; + + default: + throw new ArgumentOutOfRangeException(); } if (!mGuidLookup.TryGetValue(lidgrenId, out var guid)) { Log.Debug($"Unknown client disconnected ({lidgrenIdHex})."); - FireHandler(disconnectHandler, disconnectHandlerName, this, null); + FireHandler(disconnectHandler, disconnectHandlerName, this, new ConnectionEventArgs { NetworkStatus = networkStatus }); break; } @@ -602,7 +629,8 @@ private NetIncomingMessage TryHandleInboundMessage() if (client != null) { client.HandleDisconnected(); - FireHandler(disconnectHandler, disconnectHandlerName, this, client); + + FireHandler(disconnectHandler, disconnectHandlerName, this, new ConnectionEventArgs { Connection = client, NetworkStatus = NetworkStatus.Offline }); mNetwork.RemoveConnection(client); } @@ -625,59 +653,66 @@ private NetIncomingMessage TryHandleInboundMessage() case NetIncomingMessageType.ConnectionApproval: { - var hail = (HailPacket) mCeras.Deserialize(message.Data); - - Debug.Assert(SharedConstants.VersionData != null, "SharedConstants.VERSION_DATA != null"); - Debug.Assert(hail.VersionData != null, "hail.VersionData != null"); - if (!SharedConstants.VersionData.SequenceEqual(hail.VersionData)) + try { - Log.Error($"Bad version detected, denying connection [{lidgrenIdHex}]."); - connection?.Deny(RejectBadVersion); + var hail = (HailPacket) mCeras.Deserialize(message.Data); - break; - } + Debug.Assert(SharedConstants.VersionData != null, "SharedConstants.VERSION_DATA != null"); + Debug.Assert(hail.VersionData != null, "hail.VersionData != null"); + if (!SharedConstants.VersionData.SequenceEqual(hail.VersionData)) + { + Log.Error($"Bad version detected, denying connection [{lidgrenIdHex}]."); + connection?.Deny(NetworkStatus.VersionMismatch.ToString()); - if (OnConnectionApproved == null) - { - Log.Error($"No handlers for OnConnectionApproved, denying connection [{lidgrenIdHex}]."); - connection?.Deny(RejectServerError); + break; + } - break; - } + if (OnConnectionApproved == null) + { + Log.Error($"No handlers for OnConnectionApproved, denying connection [{lidgrenIdHex}]."); + connection?.Deny(NetworkStatus.Failed.ToString()); - /* Approving connection from here-on. */ - var aesKey = new byte[32]; - mRng?.GetNonZeroBytes(aesKey); - var client = new LidgrenConnection(mNetwork, connection, aesKey, hail.RsaParameters); + break; + } - if (!OnConnectionRequested(this, client)) - { - Log.Warn($"Connection blocked due to ban or ip filter!"); - connection?.Deny(RejectServerError); + /* Approving connection from here-on. */ + var aesKey = new byte[32]; + mRng?.GetNonZeroBytes(aesKey); + var client = new LidgrenConnection(mNetwork, connection, aesKey, hail.RsaParameters); - break; - } + if (!OnConnectionRequested(this, client)) + { + Log.Warn($"Connection blocked due to ban or ip filter!"); + connection?.Deny(NetworkStatus.Failed.ToString()); - Debug.Assert(mNetwork != null, "mNetwork != null"); - if (!mNetwork.AddConnection(client)) - { - Log.Error($"Failed to add the connection."); - connection?.Deny(RejectServerError); + break; + } - break; - } + Debug.Assert(mNetwork != null, "mNetwork != null"); + if (!mNetwork.AddConnection(client)) + { + Log.Error($"Failed to add the connection."); + connection?.Deny(NetworkStatus.Failed.ToString()); - Debug.Assert(mGuidLookup != null, "mGuidLookup != null"); - Debug.Assert(connection != null, "connection != null"); - mGuidLookup.Add(connection.RemoteUniqueIdentifier, client.Guid); + break; + } - Debug.Assert(mPeer != null, "mPeer != null"); - var approval = new ApprovalPacket(client.Rsa, hail.HandshakeSecret, aesKey, client.Guid); - var approvalMessage = mPeer.CreateMessage(); - approvalMessage.Data = approval.Data; - approvalMessage.LengthBytes = approvalMessage.Data.Length; - connection.Approve(approvalMessage); - OnConnectionApproved(this, client); + Debug.Assert(mGuidLookup != null, "mGuidLookup != null"); + Debug.Assert(connection != null, "connection != null"); + mGuidLookup.Add(connection.RemoteUniqueIdentifier, client.Guid); + + Debug.Assert(mPeer != null, "mPeer != null"); + var approval = new ApprovalPacket(client.Rsa, hail.HandshakeSecret, aesKey, client.Guid); + var approvalMessage = mPeer.CreateMessage(); + approvalMessage.Data = approval.Data; + approvalMessage.LengthBytes = approvalMessage.Data.Length; + connection.Approve(approvalMessage); + OnConnectionApproved(this, new ConnectionEventArgs { Connection = client, NetworkStatus = NetworkStatus.Online }); + } + catch + { + connection?.Deny(NetworkStatus.Failed.ToString()); + } break; } @@ -726,11 +761,11 @@ private NetIncomingMessage TryHandleInboundMessage() private bool FireHandler( HandleConnectionEvent handler, string name, - INetworkLayerInterface sender, - IConnection connection + [NotNull] INetworkLayerInterface sender, + [NotNull] ConnectionEventArgs connectionEventArgs ) { - handler?.Invoke(sender, connection); + handler?.Invoke(sender, connectionEventArgs); if (handler == null) { diff --git a/Intersect.Server/Networking/Lidgren/ServerNetwork.cs b/Intersect.Server/Networking/Lidgren/ServerNetwork.cs index 810e5d9df4..f83e09f1ef 100644 --- a/Intersect.Server/Networking/Lidgren/ServerNetwork.cs +++ b/Intersect.Server/Networking/Lidgren/ServerNetwork.cs @@ -5,6 +5,7 @@ using Intersect.Logging; using Intersect.Network; +using Intersect.Network.Events; using Intersect.Server.Entities; using JetBrains.Annotations; @@ -45,24 +46,24 @@ public bool Listen() return true; } - protected virtual void HandleInterfaceOnConnected(INetworkLayerInterface sender, IConnection connection) + protected virtual void HandleInterfaceOnConnected([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { - Log.Info($"Connected [{connection?.Guid}]."); - Client.CreateBeta4Client(connection); - OnConnected?.Invoke(sender, connection); + Log.Info($"Connected [{connectionEventArgs.Connection?.Guid}]."); + Client.CreateBeta4Client(connectionEventArgs.Connection); + OnConnected?.Invoke(sender, connectionEventArgs); } - protected virtual void HandleInterfaceOnConnectonApproved(INetworkLayerInterface sender, IConnection connection) + protected virtual void HandleInterfaceOnConnectonApproved([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { - Log.Info($"Connection approved [{connection?.Guid}]."); - OnConnectionApproved?.Invoke(sender, connection); + Log.Info($"Connection approved [{connectionEventArgs.Connection?.Guid}]."); + OnConnectionApproved?.Invoke(sender, connectionEventArgs); } - protected virtual void HandleInterfaceOnDisconnected(INetworkLayerInterface sender, IConnection connection) + protected virtual void HandleInterfaceOnDisconnected([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs) { - Log.Info($"Disconnected [{connection?.Guid}]."); - Client.RemoveBeta4Client(connection); - OnDisconnected?.Invoke(sender, connection); + Log.Info($"Disconnected [{connectionEventArgs.Connection?.Guid}]."); + Client.RemoveBeta4Client(connectionEventArgs.Connection); + OnDisconnected?.Invoke(sender, connectionEventArgs); } protected virtual void HandleOnUnconnectedMessage(NetPeer peer, NetIncomingMessage message) @@ -81,20 +82,13 @@ protected virtual void HandleOnUnconnectedMessage(NetPeer peer, NetIncomingMessa protected virtual bool HandleConnectionRequested(INetworkLayerInterface sender, IConnection connection) { - if (connection != null) + if (string.IsNullOrEmpty(connection?.Ip)) { - if (!string.IsNullOrEmpty(connection.Ip)) - { - return string.IsNullOrEmpty(Database.PlayerData.Ban.CheckBan(connection.Ip.Trim())) && - Options.Instance.SecurityOpts.CheckIp(connection.Ip.Trim()); - } - else - { - return false; - } + return false; } - return true; + return string.IsNullOrEmpty(Database.PlayerData.Ban.CheckBan(connection.Ip.Trim())) && + Options.Instance.SecurityOpts.CheckIp(connection.Ip.Trim()); } public override bool Send(IPacket packet) From 9a70a324918db1ad1bb5314c061718a8ecef39cc Mon Sep 17 00:00:00 2001 From: JC Snider Date: Sat, 4 Apr 2020 03:44:34 -0400 Subject: [PATCH 11/15] Shortened strings, consistent capitalization. Removed Server Status: Server Full in favor of Server Status: Full --- Intersect.Client/Localization/Strings.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Intersect.Client/Localization/Strings.cs b/Intersect.Client/Localization/Strings.cs index f364be9bc9..97da33f11d 100644 --- a/Intersect.Client/Localization/Strings.cs +++ b/Intersect.Client/Localization/Strings.cs @@ -1335,11 +1335,11 @@ public struct Server public static LocalizedString Unknown = @"Unknown"; - public static LocalizedString VersionMismatch = @"Version mismatch"; + public static LocalizedString VersionMismatch = @"Bad Version"; - public static LocalizedString ServerFull = @"Server Full"; + public static LocalizedString ServerFull = @"Full"; - public static LocalizedString HandshakeFailure = @"Handshake Failure"; + public static LocalizedString HandshakeFailure = @"Handshake Error"; } From 3b223598ae0247a29fb945a608cd2a432424c0f8 Mon Sep 17 00:00:00 2001 From: JC Snider Date: Sat, 4 Apr 2020 18:41:32 -0400 Subject: [PATCH 12/15] Fix version mismatch identification --- Intersect.Network/LidgrenInterface.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Intersect.Network/LidgrenInterface.cs b/Intersect.Network/LidgrenInterface.cs index 920afd7cef..549c80ca71 100644 --- a/Intersect.Network/LidgrenInterface.cs +++ b/Intersect.Network/LidgrenInterface.cs @@ -585,7 +585,16 @@ private NetIncomingMessage TryHandleInboundMessage() NetworkStatus networkStatus; try { - networkStatus = (NetworkStatus) Enum.Parse(typeof(NetworkStatus), reason, true); + switch (reason) + { + //Lidgren won't accept a connection with a bad version and sends this message back so we need to manually handle it + case "Wrong application identifier!": + networkStatus = NetworkStatus.VersionMismatch; + break; + default: + networkStatus = (NetworkStatus)Enum.Parse(typeof(NetworkStatus), reason, true); + break; + } } catch (Exception exception) { From 6d25ec65ea9ae2bf03aa76f3d253579669e39537 Mon Sep 17 00:00:00 2001 From: JC Snider Date: Sat, 4 Apr 2020 19:02:41 -0400 Subject: [PATCH 13/15] Fixes order of character rendering with paperdolls for #75 --- .../Interface/Game/Character/CharacterWindow.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Intersect.Client/Interface/Game/Character/CharacterWindow.cs b/Intersect.Client/Interface/Game/Character/CharacterWindow.cs index ca93238caf..edc8ae99cb 100644 --- a/Intersect.Client/Interface/Game/Character/CharacterWindow.cs +++ b/Intersect.Client/Interface/Game/Character/CharacterWindow.cs @@ -194,11 +194,6 @@ public void Update() else */ if (Globals.Me.MySprite != "" && Globals.Me.MySprite != mCurrentSprite && entityTex != null) { - mCharacterPortrait.Texture = entityTex; - mCharacterPortrait.SetTextureRect(0, 0, entityTex.GetWidth() / 4, entityTex.GetHeight() / 4); - mCharacterPortrait.SizeToContents(); - Align.Center(mCharacterPortrait); - mCharacterPortrait.IsHidden = false; for (var z = 0; z < Options.PaperdollOrder[1].Count; z++) { var paperdoll = ""; @@ -227,8 +222,16 @@ public void Update() } } } + else if (Options.PaperdollOrder[1][z] == "Player") + { + PaperdollPanels[z].Show(); + PaperdollPanels[z].Texture = entityTex; + PaperdollPanels[z].SetTextureRect(0, 0, entityTex.GetWidth() / 4, entityTex.GetHeight() / 4); + PaperdollPanels[z].SizeToContents(); + Align.Center(PaperdollPanels[z]); + } - if (paperdoll == "" && PaperdollTextures[z] != "") + if (paperdoll == "" && PaperdollTextures[z] != "" && Options.PaperdollOrder[1][z] != "Player") { PaperdollPanels[z].Texture = null; PaperdollPanels[z].Hide(); From 5f05cee7e8e6e5d4c3fccf3dc464c72fbd748812 Mon Sep 17 00:00:00 2001 From: JC Snider Date: Sat, 4 Apr 2020 19:07:22 -0400 Subject: [PATCH 14/15] Picky pandaz --- Intersect.Client/Interface/Game/Character/CharacterWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Intersect.Client/Interface/Game/Character/CharacterWindow.cs b/Intersect.Client/Interface/Game/Character/CharacterWindow.cs index edc8ae99cb..ce0cf2ee52 100644 --- a/Intersect.Client/Interface/Game/Character/CharacterWindow.cs +++ b/Intersect.Client/Interface/Game/Character/CharacterWindow.cs @@ -231,7 +231,7 @@ public void Update() Align.Center(PaperdollPanels[z]); } - if (paperdoll == "" && PaperdollTextures[z] != "" && Options.PaperdollOrder[1][z] != "Player") + if (string.IsNullOrWhiteSpace(paperdoll) && !string.IsNullOrWhiteSpace(PaperdollTextures[z]) && Options.PaperdollOrder[1][z] != "Player") { PaperdollPanels[z].Texture = null; PaperdollPanels[z].Hide(); From 3641c1f506d3bc70544f848b4d420a914a158862 Mon Sep 17 00:00:00 2001 From: Robert Lodico Date: Sun, 5 Apr 2020 16:01:51 -0400 Subject: [PATCH 15/15] chore - Cleanup an empty issues (#93) * Remove empty RsaUtils * Move Lidgren-specific code into isolated namespace * Cleaned up empty de/constructors, catch clauses, statements --- Intersect (Core)/Crypto/RsaUtils.cs | 9 --------- .../GameObjects/Events/EventMoveRoute.cs | 5 ----- Intersect (Core)/GameObjects/Maps/MapAttribute.cs | 5 ----- Intersect (Core)/Intersect (Core).csproj | 1 - .../Logging/Formatting/DefaultFormatter.cs | 1 - Intersect (Core)/Network/CerasPacket.cs | 5 ----- .../File Management/GameContentManager.cs | 7 +++++-- .../GenericClasses/OpenFileDialog.cs | 5 ----- .../GenericClasses/SaveFileDialog.cs | 5 ----- Intersect.Client.Framework/Gwen/Control/Base.cs | 6 ++++-- Intersect.Client.Framework/Gwen/Renderer/Base.cs | 12 +++++++----- Intersect.Client.Framework/Gwen/Skin/Base.cs | 13 ++++++++----- Intersect.Client/Interface/Game/Draggable.cs | 1 - Intersect.Client/Items/Item.cs | 4 ---- .../MonoGame/Graphics/MonoTileBuffer.cs | 11 +++-------- Intersect.Client/MonoGame/Network/MonoSocket.cs | 4 ---- Intersect.Network/ClientNetwork.cs | 1 + Intersect.Network/Intersect.Network.csproj | 7 ++++--- Intersect.Network/{ => Lidgren}/LidgrenBuffer.cs | 2 +- .../{ => Lidgren}/LidgrenConnection.cs | 2 +- Intersect.Network/{ => Lidgren}/LidgrenInterface.cs | 2 +- .../Database/GameData/Migrations/Beta6Migration.cs | 6 +++--- Intersect.Server/Entities/Player.cs | 2 -- Intersect.Server/Networking/Helpers/PortChecker.cs | 5 ++++- .../Networking/Lidgren/ServerNetwork.cs | 1 + .../Attributes/ConfigurableAuthorizeAttribute.cs | 5 ----- 26 files changed, 43 insertions(+), 84 deletions(-) delete mode 100644 Intersect (Core)/Crypto/RsaUtils.cs rename Intersect.Network/{ => Lidgren}/LidgrenBuffer.cs (99%) rename Intersect.Network/{ => Lidgren}/LidgrenConnection.cs (99%) rename Intersect.Network/{ => Lidgren}/LidgrenInterface.cs (99%) diff --git a/Intersect (Core)/Crypto/RsaUtils.cs b/Intersect (Core)/Crypto/RsaUtils.cs deleted file mode 100644 index 7294c7faee..0000000000 --- a/Intersect (Core)/Crypto/RsaUtils.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Intersect.Crypto -{ - - public static class RsaUtils - { - - } - -} diff --git a/Intersect (Core)/GameObjects/Events/EventMoveRoute.cs b/Intersect (Core)/GameObjects/Events/EventMoveRoute.cs index f200ec51b0..fbc597cc23 100644 --- a/Intersect (Core)/GameObjects/Events/EventMoveRoute.cs +++ b/Intersect (Core)/GameObjects/Events/EventMoveRoute.cs @@ -8,11 +8,6 @@ namespace Intersect.GameObjects.Events public class EventMoveRoute { - - public EventMoveRoute() - { - } - public List Actions { get; set; } = new List(); public bool IgnoreIfBlocked { get; set; } diff --git a/Intersect (Core)/GameObjects/Maps/MapAttribute.cs b/Intersect (Core)/GameObjects/Maps/MapAttribute.cs index 1ba68866bb..2d8cc51d22 100644 --- a/Intersect (Core)/GameObjects/Maps/MapAttribute.cs +++ b/Intersect (Core)/GameObjects/Maps/MapAttribute.cs @@ -9,11 +9,6 @@ namespace Intersect.GameObjects.Maps public abstract class MapAttribute { - - public MapAttribute() - { - } - public abstract MapAttributes Type { get; } public static MapAttribute CreateAttribute(MapAttributes type) diff --git a/Intersect (Core)/Intersect (Core).csproj b/Intersect (Core)/Intersect (Core).csproj index d4b4f31316..2bb173bd2e 100644 --- a/Intersect (Core)/Intersect (Core).csproj +++ b/Intersect (Core)/Intersect (Core).csproj @@ -220,7 +220,6 @@ - diff --git a/Intersect (Core)/Logging/Formatting/DefaultFormatter.cs b/Intersect (Core)/Logging/Formatting/DefaultFormatter.cs index de6aab053e..578c3f7c05 100644 --- a/Intersect (Core)/Logging/Formatting/DefaultFormatter.cs +++ b/Intersect (Core)/Logging/Formatting/DefaultFormatter.cs @@ -120,7 +120,6 @@ private string FormatPrefix([NotNull] LogConfiguration configuration, LogLevel l } var innerException = exception; - ; while ((innerException = innerException.InnerException) != null) { builder.AppendLine(@"Caused By"); diff --git a/Intersect (Core)/Network/CerasPacket.cs b/Intersect (Core)/Network/CerasPacket.cs index 35353346dd..8272849bdc 100644 --- a/Intersect (Core)/Network/CerasPacket.cs +++ b/Intersect (Core)/Network/CerasPacket.cs @@ -10,13 +10,8 @@ namespace Intersect.Network public abstract class CerasPacket : IPacket { - [NotNull] private static readonly Ceras sCerasInstance = new Ceras(true); - protected CerasPacket() - { - } - /// public virtual void Dispose() { diff --git a/Intersect.Client.Framework/File Management/GameContentManager.cs b/Intersect.Client.Framework/File Management/GameContentManager.cs index 38ce3612d8..ffdc0f9886 100644 --- a/Intersect.Client.Framework/File Management/GameContentManager.cs +++ b/Intersect.Client.Framework/File Management/GameContentManager.cs @@ -5,6 +5,7 @@ using Intersect.Client.Framework.Audio; using Intersect.Client.Framework.Graphics; +using Intersect.Logging; namespace Intersect.Client.Framework.File_Management { @@ -400,8 +401,9 @@ public virtual void SaveUIJson(UI stage, string name, string json, string resolu { File.WriteAllText(path, json); } - catch (Exception) + catch (Exception exception) { + Log.Debug(exception); } return; @@ -413,8 +415,9 @@ public virtual void SaveUIJson(UI stage, string name, string json, string resolu { File.WriteAllText(path, json); } - catch (Exception) + catch (Exception exception) { + Log.Debug(exception); } } diff --git a/Intersect.Client.Framework/GenericClasses/OpenFileDialog.cs b/Intersect.Client.Framework/GenericClasses/OpenFileDialog.cs index 4e7a845592..1c4622c45d 100644 --- a/Intersect.Client.Framework/GenericClasses/OpenFileDialog.cs +++ b/Intersect.Client.Framework/GenericClasses/OpenFileDialog.cs @@ -10,11 +10,6 @@ public enum DialogResult public class OpenFileDialog { - - public OpenFileDialog() - { - } - public string Title { get; set; } public string InitialDirectory { get; set; } diff --git a/Intersect.Client.Framework/GenericClasses/SaveFileDialog.cs b/Intersect.Client.Framework/GenericClasses/SaveFileDialog.cs index 391d62ef3e..ed155a30cf 100644 --- a/Intersect.Client.Framework/GenericClasses/SaveFileDialog.cs +++ b/Intersect.Client.Framework/GenericClasses/SaveFileDialog.cs @@ -3,11 +3,6 @@ public class SaveFileDialog { - - public SaveFileDialog() - { - } - public string Title { get; set; } public string InitialDirectory { get; set; } diff --git a/Intersect.Client.Framework/Gwen/Control/Base.cs b/Intersect.Client.Framework/Gwen/Control/Base.cs index fb7ac0382b..afb6eb6998 100644 --- a/Intersect.Client.Framework/Gwen/Control/Base.cs +++ b/Intersect.Client.Framework/Gwen/Control/Base.cs @@ -11,6 +11,9 @@ using Intersect.Client.Framework.Gwen.ControlInternal; using Intersect.Client.Framework.Gwen.DragDrop; using Intersect.Client.Framework.Gwen.Input; +#if DEBUG +using Intersect.Logging; +#endif using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -1097,8 +1100,7 @@ private bool HasNamedChildren() #if DEBUG ~Base() { - //throw new InvalidOperationException(String.Format("IDisposable object finalized [{1:X}]: {0}", this, GetHashCode())); - ////debug.print(String.Format("IDisposable object finalized: {0}", GetType())); + Log.Debug($"IDisposable object finalized: {GetType()}"); } #endif diff --git a/Intersect.Client.Framework/Gwen/Renderer/Base.cs b/Intersect.Client.Framework/Gwen/Renderer/Base.cs index 2021a793dd..cf9b92f402 100644 --- a/Intersect.Client.Framework/Gwen/Renderer/Base.cs +++ b/Intersect.Client.Framework/Gwen/Renderer/Base.cs @@ -1,7 +1,10 @@ -using System; - -using Intersect.Client.Framework.GenericClasses; +using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; +#if DEBUG +using Intersect.Logging; +#endif + +using System; namespace Intersect.Client.Framework.Gwen.Renderer { @@ -96,8 +99,7 @@ public virtual void Dispose() #if DEBUG ~Base() { - //throw new InvalidOperationException(String.Format("IDisposable object finalized: {0}", GetType())); - ////debug.print(String.Format("IDisposable object finalized: {0}", GetType())); + Log.Debug($"IDisposable object finalized: {GetType()}"); } #endif diff --git a/Intersect.Client.Framework/Gwen/Skin/Base.cs b/Intersect.Client.Framework/Gwen/Skin/Base.cs index d058341eb3..8ac4bd3abe 100644 --- a/Intersect.Client.Framework/Gwen/Skin/Base.cs +++ b/Intersect.Client.Framework/Gwen/Skin/Base.cs @@ -1,8 +1,12 @@ -using System; - -using Intersect.Client.Framework.GenericClasses; +using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; +using System; + +#if DEBUG +using Intersect.Logging; +#endif + namespace Intersect.Client.Framework.Gwen.Skin { @@ -56,8 +60,7 @@ public virtual void Dispose() #if DEBUG ~Base() { - //throw new InvalidOperationException(String.Format("IDisposable object finalized: {0}", GetType())); - ////debug.print(String.Format("IDisposable object finalized: {0}", GetType())); + Log.Debug($"IDisposable object finalized: {GetType()}"); } #endif diff --git a/Intersect.Client/Interface/Game/Draggable.cs b/Intersect.Client/Interface/Game/Draggable.cs index cf4585c929..2b23a278a3 100644 --- a/Intersect.Client/Interface/Game/Draggable.cs +++ b/Intersect.Client/Interface/Game/Draggable.cs @@ -61,7 +61,6 @@ public void Dispose() Active = null; } - ; Interface.GameUi.GameCanvas.RemoveChild(mPnl, false); } diff --git a/Intersect.Client/Items/Item.cs b/Intersect.Client/Items/Item.cs index 815f612939..be2daa4210 100644 --- a/Intersect.Client/Items/Item.cs +++ b/Intersect.Client/Items/Item.cs @@ -17,10 +17,6 @@ public class Item public int[] StatBuffs = new int[(int) Stats.StatCount]; - public Item() - { - } - public ItemBase Base => ItemBase.Get(ItemId); public void Load(Guid id, int quantity, Guid? bagId, int[] statBuffs) diff --git a/Intersect.Client/MonoGame/Graphics/MonoTileBuffer.cs b/Intersect.Client/MonoGame/Graphics/MonoTileBuffer.cs index 60f9b33899..1b80c0c1cb 100644 --- a/Intersect.Client/MonoGame/Graphics/MonoTileBuffer.cs +++ b/Intersect.Client/MonoGame/Graphics/MonoTileBuffer.cs @@ -176,16 +176,11 @@ public override bool SetData() public override void Dispose() { - if (vertexBuffer != null) - { - ; - } - - vertexBuffer.Dispose(); + vertexBuffer?.Dispose(); vertexBuffer = null; - indexBuffer.Dispose(); - TileBufferCount--; + indexBuffer?.Dispose(); indexBuffer = null; + TileBufferCount--; disposed = true; } diff --git a/Intersect.Client/MonoGame/Network/MonoSocket.cs b/Intersect.Client/MonoGame/Network/MonoSocket.cs index b49103fcd3..5c859c77e5 100644 --- a/Intersect.Client/MonoGame/Network/MonoSocket.cs +++ b/Intersect.Client/MonoGame/Network/MonoSocket.cs @@ -21,10 +21,6 @@ public class MonoSocket : GameSocket public static ConcurrentQueue> PacketQueue = new ConcurrentQueue>(); - public MonoSocket() - { - } - public override void Connect(string host, int port) { if (ClientLidgrenNetwork != null) diff --git a/Intersect.Network/ClientNetwork.cs b/Intersect.Network/ClientNetwork.cs index 3808b36aa9..83ee9b4d0a 100644 --- a/Intersect.Network/ClientNetwork.cs +++ b/Intersect.Network/ClientNetwork.cs @@ -5,6 +5,7 @@ using Intersect.Logging; using Intersect.Network.Events; +using Intersect.Network.Lidgren; using JetBrains.Annotations; diff --git a/Intersect.Network/Intersect.Network.csproj b/Intersect.Network/Intersect.Network.csproj index 7bb56f63fc..7ab8109b88 100644 --- a/Intersect.Network/Intersect.Network.csproj +++ b/Intersect.Network/Intersect.Network.csproj @@ -73,9 +73,9 @@ - - - + + + @@ -89,5 +89,6 @@ Intersect %28Core%29 + \ No newline at end of file diff --git a/Intersect.Network/LidgrenBuffer.cs b/Intersect.Network/Lidgren/LidgrenBuffer.cs similarity index 99% rename from Intersect.Network/LidgrenBuffer.cs rename to Intersect.Network/Lidgren/LidgrenBuffer.cs index f4ad88d1d6..521f702c07 100644 --- a/Intersect.Network/LidgrenBuffer.cs +++ b/Intersect.Network/Lidgren/LidgrenBuffer.cs @@ -5,7 +5,7 @@ using Lidgren.Network; -namespace Intersect.Network +namespace Intersect.Network.Lidgren { public class LidgrenBuffer : IBuffer diff --git a/Intersect.Network/LidgrenConnection.cs b/Intersect.Network/Lidgren/LidgrenConnection.cs similarity index 99% rename from Intersect.Network/LidgrenConnection.cs rename to Intersect.Network/Lidgren/LidgrenConnection.cs index 4b171f8fbf..a395c929cd 100644 --- a/Intersect.Network/LidgrenConnection.cs +++ b/Intersect.Network/Lidgren/LidgrenConnection.cs @@ -7,7 +7,7 @@ using Lidgren.Network; -namespace Intersect.Network +namespace Intersect.Network.Lidgren { public sealed class LidgrenConnection : AbstractConnection diff --git a/Intersect.Network/LidgrenInterface.cs b/Intersect.Network/Lidgren/LidgrenInterface.cs similarity index 99% rename from Intersect.Network/LidgrenInterface.cs rename to Intersect.Network/Lidgren/LidgrenInterface.cs index 3b6c6f4d67..f51ebaf03e 100644 --- a/Intersect.Network/LidgrenInterface.cs +++ b/Intersect.Network/Lidgren/LidgrenInterface.cs @@ -15,7 +15,7 @@ using Lidgren.Network; -namespace Intersect.Network +namespace Intersect.Network.Lidgren { public sealed class LidgrenInterface : INetworkLayerInterface diff --git a/Intersect.Server/Database/GameData/Migrations/Beta6Migration.cs b/Intersect.Server/Database/GameData/Migrations/Beta6Migration.cs index f797d15ead..6bdb7f0100 100644 --- a/Intersect.Server/Database/GameData/Migrations/Beta6Migration.cs +++ b/Intersect.Server/Database/GameData/Migrations/Beta6Migration.cs @@ -204,11 +204,12 @@ private static void ParseJson(JToken obj) { try { - var newJson = FixJson(property.Value.ToString()); + var newJson = FixJson(property.Value?.ToString()); property.Value = newJson; } - catch (Exception ex) + catch { + // Not important to abort or log } } } @@ -695,7 +696,6 @@ private static byte[] ReencodeTileData(byte[] tileData) } return mCeras.Compress(Layers); - ; } private static byte[] Decompress(byte[] data) diff --git a/Intersect.Server/Entities/Player.cs b/Intersect.Server/Entities/Player.cs index 62c97db995..feca3c026e 100644 --- a/Intersect.Server/Entities/Player.cs +++ b/Intersect.Server/Entities/Player.cs @@ -59,8 +59,6 @@ public partial class Player : Entity #endregion - public Player() { } - public static int OnlineCount => OnlinePlayers.Count; [JsonProperty("MaxVitals"), NotMapped] diff --git a/Intersect.Server/Networking/Helpers/PortChecker.cs b/Intersect.Server/Networking/Helpers/PortChecker.cs index f0038092e1..67566ca507 100644 --- a/Intersect.Server/Networking/Helpers/PortChecker.cs +++ b/Intersect.Server/Networking/Helpers/PortChecker.cs @@ -2,6 +2,8 @@ using System.Linq; using System.Net; +using Intersect.Logging; + using WebSocketSharp; namespace Intersect.Server.Networking.Helpers @@ -41,8 +43,9 @@ public static bool CanYouSeeMe(int port, out string externalIp) } } } - catch (Exception ex) + catch (Exception exception) { + Log.Debug(exception); } return false; diff --git a/Intersect.Server/Networking/Lidgren/ServerNetwork.cs b/Intersect.Server/Networking/Lidgren/ServerNetwork.cs index f83e09f1ef..0bc3e7d696 100644 --- a/Intersect.Server/Networking/Lidgren/ServerNetwork.cs +++ b/Intersect.Server/Networking/Lidgren/ServerNetwork.cs @@ -6,6 +6,7 @@ using Intersect.Logging; using Intersect.Network; using Intersect.Network.Events; +using Intersect.Network.Lidgren; using Intersect.Server.Entities; using JetBrains.Annotations; diff --git a/Intersect.Server/Web/RestApi/Attributes/ConfigurableAuthorizeAttribute.cs b/Intersect.Server/Web/RestApi/Attributes/ConfigurableAuthorizeAttribute.cs index a6981d8cd5..7b110a988a 100644 --- a/Intersect.Server/Web/RestApi/Attributes/ConfigurableAuthorizeAttribute.cs +++ b/Intersect.Server/Web/RestApi/Attributes/ConfigurableAuthorizeAttribute.cs @@ -18,11 +18,6 @@ namespace Intersect.Server.Web.RestApi.Attributes [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = false)] internal class ConfigurableAuthorizeAttribute : AuthorizeAttribute { - - public ConfigurableAuthorizeAttribute() : base() - { - } - [NotNull] protected IEnumerable InternalRoles => Roles?.Split(',').Where(role => !string.IsNullOrWhiteSpace(role)).Select(role => role.Trim()) ??