mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-24 23:27:14 -05:00
Update validation & add bypass
Require first uint to match, can bypass others
This commit is contained in:
parent
e62191b65a
commit
1ff26a3be7
|
|
@ -10,6 +10,12 @@ public class AutoInjector
|
|||
|
||||
public bool AutoInjectEnabled { private get; set; }
|
||||
|
||||
public bool ValidateEnabled
|
||||
{
|
||||
get => Injector.ValidateEnabled;
|
||||
set => Injector.ValidateEnabled = value;
|
||||
}
|
||||
|
||||
public AutoInjector(IDataInjector inj, Action<InjectionResult> read, Action<InjectionResult> write)
|
||||
{
|
||||
Injector = inj;
|
||||
|
|
|
|||
|
|
@ -10,5 +10,6 @@ public interface IDataInjector
|
|||
bool Validate(byte[] data);
|
||||
uint WriteOffset { set; }
|
||||
bool Connected { get; }
|
||||
bool ValidateEnabled { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ public enum InjectionResult
|
|||
{
|
||||
Skipped,
|
||||
Success,
|
||||
Fail,
|
||||
FailValidate,
|
||||
Same,
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ public class PocketInjector : IDataInjector
|
|||
public bool Connected => Bot.Connected;
|
||||
|
||||
public uint WriteOffset { private get; set; }
|
||||
public bool ValidateEnabled { get; set; } = true;
|
||||
|
||||
public PocketInjector(IReadOnlyList<Item> items, IRAMReadWriter bot)
|
||||
{
|
||||
|
|
@ -36,7 +37,7 @@ public bool ReadValidate(out byte[] data)
|
|||
public InjectionResult Read()
|
||||
{
|
||||
if (!ReadValidate(out var data))
|
||||
return InjectionResult.Fail;
|
||||
return InjectionResult.FailValidate;
|
||||
|
||||
if (LastData?.SequenceEqual(data) == true)
|
||||
return InjectionResult.Same;
|
||||
|
|
@ -60,7 +61,7 @@ public InjectionResult Read()
|
|||
public InjectionResult Write()
|
||||
{
|
||||
if (!ReadValidate(out var data))
|
||||
return InjectionResult.Fail;
|
||||
return InjectionResult.FailValidate;
|
||||
|
||||
var orig = (byte[])data.Clone();
|
||||
|
||||
|
|
@ -89,6 +90,9 @@ public bool Validate(byte[] data)
|
|||
if (BitConverter.ToUInt32(data, pocket) > 20) // pouch21-39 count
|
||||
return false;
|
||||
|
||||
if (!ValidateEnabled)
|
||||
return true;
|
||||
|
||||
for (int i = 4; i < 0x18; i += 4)
|
||||
{
|
||||
var val = BitConverter.ToInt32(data, pocket + i);
|
||||
|
|
|
|||
18
NHSE.WinForms/Subforms/SysBot/SysBotUI.Designer.cs
generated
18
NHSE.WinForms/Subforms/SysBot/SysBotUI.Designer.cs
generated
|
|
@ -42,6 +42,7 @@ private void InitializeComponent()
|
|||
this.B_ReadCurrent = new System.Windows.Forms.Button();
|
||||
this.B_WriteCurrent = new System.Windows.Forms.Button();
|
||||
this.TIM_Interval = new System.Windows.Forms.Timer(this.components);
|
||||
this.CHK_Validate = new System.Windows.Forms.CheckBox();
|
||||
this.GB_Inject.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
|
@ -93,6 +94,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// GB_Inject
|
||||
//
|
||||
this.GB_Inject.Controls.Add(this.CHK_Validate);
|
||||
this.GB_Inject.Controls.Add(this.CHK_AutoRead);
|
||||
this.GB_Inject.Controls.Add(this.CHK_AutoWrite);
|
||||
this.GB_Inject.Controls.Add(this.RamOffset);
|
||||
|
|
@ -110,7 +112,7 @@ private void InitializeComponent()
|
|||
// CHK_AutoRead
|
||||
//
|
||||
this.CHK_AutoRead.AutoSize = true;
|
||||
this.CHK_AutoRead.Location = new System.Drawing.Point(18, 93);
|
||||
this.CHK_AutoRead.Location = new System.Drawing.Point(18, 85);
|
||||
this.CHK_AutoRead.Name = "CHK_AutoRead";
|
||||
this.CHK_AutoRead.Size = new System.Drawing.Size(74, 17);
|
||||
this.CHK_AutoRead.TabIndex = 22;
|
||||
|
|
@ -173,6 +175,19 @@ private void InitializeComponent()
|
|||
//
|
||||
this.TIM_Interval.Interval = 5000;
|
||||
//
|
||||
// CHK_Validate
|
||||
//
|
||||
this.CHK_Validate.AutoSize = true;
|
||||
this.CHK_Validate.Checked = true;
|
||||
this.CHK_Validate.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.CHK_Validate.Location = new System.Drawing.Point(18, 100);
|
||||
this.CHK_Validate.Name = "CHK_Validate";
|
||||
this.CHK_Validate.Size = new System.Drawing.Size(90, 17);
|
||||
this.CHK_Validate.TabIndex = 23;
|
||||
this.CHK_Validate.Text = "Validate Data";
|
||||
this.CHK_Validate.UseVisualStyleBackColor = true;
|
||||
this.CHK_Validate.CheckedChanged += new System.EventHandler(this.CHK_Validate_CheckedChanged);
|
||||
//
|
||||
// SysBotUI
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
@ -213,5 +228,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.CheckBox CHK_AutoWrite;
|
||||
private System.Windows.Forms.CheckBox CHK_AutoRead;
|
||||
private System.Windows.Forms.Timer TIM_Interval;
|
||||
private System.Windows.Forms.CheckBox CHK_Validate;
|
||||
}
|
||||
}
|
||||
|
|
@ -78,6 +78,7 @@ private void B_ReadCurrent_Click(object sender, EventArgs e)
|
|||
|
||||
private void CHK_AutoWrite_CheckedChanged(object sender, EventArgs e) => Injector.AutoInjectEnabled = CHK_AutoWrite.Checked;
|
||||
private void CHK_AutoRead_CheckedChanged(object sender, EventArgs e) => TIM_Interval.Enabled = CHK_AutoRead.Checked;
|
||||
private void CHK_Validate_CheckedChanged(object sender, EventArgs e) => Injector.ValidateEnabled = CHK_Validate.Checked;
|
||||
|
||||
private void RamOffset_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user