Skip to content

Commit

Permalink
update.
Browse files Browse the repository at this point in the history
  • Loading branch information
a08381 committed Feb 2, 2022
1 parent 355e34f commit 373c384
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 50 deletions.
11 changes: 3 additions & 8 deletions SkipCutscene/Config.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using Dalamud.Configuration;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Dalamud.Configuration;

namespace Plugins.a08381.SkipCutscene
{
class Config : IPluginConfiguration
public class Config : IPluginConfiguration
{

public int Version { get; set; }
Expand Down
5 changes: 2 additions & 3 deletions SkipCutscene/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 有关程序集的一般信息由以下
Expand Down Expand Up @@ -32,5 +31,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.5")]
[assembly: AssemblyFileVersion("1.2.0.5")]
[assembly: AssemblyVersion("1.2.0.6")]
[assembly: AssemblyFileVersion("1.2.0.6")]
69 changes: 30 additions & 39 deletions SkipCutscene/SkipCutscene.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using Dalamud;
using Dalamud.Game;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.Logging;
using Dalamud.Plugin;
using System;
using System.Diagnostics;
using System.Security.Cryptography;

namespace Plugins.a08381.SkipCutscene
{
public class SkipCutscene : IDalamudPlugin
{

private Config config;

private RNGCryptoServiceProvider csp;
private readonly Config _config;
private readonly RNGCryptoServiceProvider _csp;

private readonly decimal _base = uint.MaxValue;

public SkipCutscene()
{
if (Interface.GetPluginConfig() is not Config configuration || configuration.Version == 0)
configuration = new Config() { IsEnabled = true, Version = 1 };
configuration = new Config { IsEnabled = true, Version = 1 };

this.config = configuration;
_config = configuration;

Address = new CutsceneAddressResolver();

Expand All @@ -34,7 +33,7 @@ public SkipCutscene()
if (Address.Offset1 != IntPtr.Zero && Address.Offset2 != IntPtr.Zero)
{
PluginLog.Information("Cutscene Offset Found.");
if (this.config.IsEnabled)
if (_config.IsEnabled)
SetEnabled(true);
}
else
Expand All @@ -45,9 +44,9 @@ public SkipCutscene()
return;
}

csp = new();
_csp = new RNGCryptoServiceProvider();

CommandManager.AddHandler("/sc", new CommandInfo(this.OnCommand)
CommandManager.AddHandler("/sc", new CommandInfo(OnCommand)
{
HelpMessage = "/sc: Roll your sanity check dice."
});
Expand All @@ -56,6 +55,7 @@ public SkipCutscene()
public void Dispose()
{
SetEnabled(false);
GC.SuppressFinalize(this);
}

public string Name => "SkipCutscene";
Expand All @@ -76,40 +76,31 @@ public void Dispose()

public void SetEnabled(bool isEnable)
{
if (Address.Offset1 != IntPtr.Zero && Address.Offset2 != IntPtr.Zero)
if (Address.Offset1 == IntPtr.Zero || Address.Offset2 == IntPtr.Zero) return;
if (isEnable)
{
SafeMemory.Write<short>(Address.Offset1, -28528);
SafeMemory.Write<short>(Address.Offset2, -28528);
}
else
{
if (isEnable)
{
SafeMemory.Write<short>(Address.Offset1, -28528);
SafeMemory.Write<short>(Address.Offset2, -28528);
}
else
{
SafeMemory.Write<short>(Address.Offset1, 13173);
SafeMemory.Write<short>(Address.Offset2, 6260);
}
SafeMemory.Write<short>(Address.Offset1, 13173);
SafeMemory.Write<short>(Address.Offset2, 6260);
}
}

private void OnCommand(string command, string arguments)
{
if (command.ToLower() == "/sc")
{
byte[] rndSeries = new byte[4];
csp.GetBytes(rndSeries);
int rnd = (int)Math.Abs(BitConverter.ToUInt32(rndSeries, 0) / _base * 50 + 1);
if (this.config.IsEnabled)
{
ChatGui.Print(string.Format("sancheck: 1d100={0}, Failed", rnd + 50));
}
else
{
ChatGui.Print(string.Format("sancheck: 1d100={0}, Passed", rnd));
}
this.config.IsEnabled = !this.config.IsEnabled;
SetEnabled(this.config.IsEnabled);
Interface.SavePluginConfig(this.config);
}
if (command.ToLower() != "/sc") return;
byte[] rndSeries = new byte[4];
_csp.GetBytes(rndSeries);
int rnd = (int)Math.Abs(BitConverter.ToUInt32(rndSeries, 0) / _base * 50 + 1);
ChatGui.Print(_config.IsEnabled
? $"sancheck: 1d100={rnd + 50}, Failed"
: $"sancheck: 1d100={rnd}, Passed");
_config.IsEnabled = !_config.IsEnabled;
SetEnabled(_config.IsEnabled);
Interface.SavePluginConfig(_config);
}
}

Expand Down

0 comments on commit 373c384

Please sign in to comment.