Skip to content

Commit

Permalink
Added WriteNullBytes and updated Delete functions
Browse files Browse the repository at this point in the history
	modified:   Sonic-06-Mod-Manager/Properties/AssemblyInfo.cs
	modified:   Sonic-06-Mod-Manager/src/UnifyPatcher.cs
	modified:   Sonic-06-Mod-Manager/src/UnifyProgram.cs
  • Loading branch information
HyperPolygon64 committed Mar 16, 2020
1 parent 41880d5 commit c9a15e2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Sonic-06-Mod-Manager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
[assembly: ComVisible(false)]
[assembly: Guid("277111e3-79d8-41b5-b0d7-7609dff6e36f")]
[assembly: AssemblyVersion("2.0.0.6")]
[assembly: AssemblyFileVersion("3.1.2.0")]
[assembly: AssemblyFileVersion("3.1.3.0")]
27 changes: 21 additions & 6 deletions Sonic-06-Mod-Manager/src/UnifyPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class ModEngine
/// <param name="mod">File path to the mod's INI file.</param>
/// <param name="name">Name of the mod by Title key.</param>
public static void InstallMods(string mod, string name) {
string platform = INI.DeserialiseKey("Platform", mod); // Deserialise 'Platform' key
bool merge = bool.Parse(INI.DeserialiseKey("Merge", mod)); // Deserialise 'Merge' key and parse as a Boolean value
string[] custom = INI.DeserialiseKey("Custom", mod).Split(','); // Deserialise 'Custom' key
string platform = INI.DeserialiseKey("Platform", mod); // Deserialise 'Platform' key
bool merge = bool.Parse(INI.DeserialiseKey("Merge", mod)); // Deserialise 'Merge' key and parse as a Boolean value
string[] custom = INI.DeserialiseKey("Custom", mod).Split(','); // Deserialise 'Custom' key
string[] read_only = INI.DeserialiseKey("Read-only", mod).Split(','); // Deserialise 'Read-only' key

//Skip the mod if the platform is invalid
Expand Down Expand Up @@ -406,12 +406,16 @@ public static void InstallPatches(string patch, string name) {
}

if (line.StartsWith("Write")) {
string[] _WriteByte = Lua.DeserialiseParameterList("WriteByte", line, false), // Deserialise 'WriteByte' parameter
_WriteNopPPC = Lua.DeserialiseParameterList("WriteNopPPC", line, false), // Deserialise 'WriteNopPPC' parameter
_WriteBase64 = Lua.DeserialiseParameterList("WriteBase64", line, false); // Deserialise 'WriteBase64' parameter
string[] _WriteByte = Lua.DeserialiseParameterList("WriteByte", line, false), // Deserialise 'WriteByte' parameter
_WriteNullBytes = Lua.DeserialiseParameterList("WriteNullBytes", line, false), // Deserialise 'WriteNullBytes' parameter
_WriteNopPPC = Lua.DeserialiseParameterList("WriteNopPPC", line, false), // Deserialise 'WriteNopPPC' parameter
_WriteBase64 = Lua.DeserialiseParameterList("WriteBase64", line, false); // Deserialise 'WriteBase64' parameter

if (line.StartsWith("WriteByte") && _WriteByte.Length != 0)
WriteByte(Literal.CoreReplace(_WriteByte[0]), Convert.ToInt32(_WriteByte[1], 16), Convert.ToByte(_WriteByte[2], 16));
else if (line.StartsWith("WriteNullBytes") && _WriteNullBytes.Length != 0)
for (int i = 0; i < Convert.ToInt32(_WriteNullBytes[2]); i++)
WriteByte(Literal.CoreReplace(_WriteNullBytes[0]), Convert.ToInt32(_WriteNullBytes[1], 16) + i, 0);
else if (line.StartsWith("WriteNopPPC") && _WriteNopPPC.Length != 0)
WriteNopPPC(Literal.CoreReplace(_WriteNopPPC[0]), Convert.ToInt32(_WriteNopPPC[1], 16));
else if (line.StartsWith("WriteBase64") && _WriteBase64.Length != 0)
Expand Down Expand Up @@ -524,6 +528,17 @@ private static void Delete(string location) {
}

if (File.Exists(location)) File.Delete(location);
else if (Directory.Exists(location) && _archive != string.Empty) {
try {
// Erases the directory
DirectoryInfo data = new DirectoryInfo(location);
if (Directory.Exists(location)) {
foreach (FileInfo file in data.GetFiles()) file.Delete();
foreach (DirectoryInfo directory in data.GetDirectories()) directory.Delete(true);
Directory.Delete(location);
}
} catch { }
}
}

private static void EndBlock() {
Expand Down
4 changes: 2 additions & 2 deletions Sonic-06-Mod-Manager/src/UnifyProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace Unify.Environment3
{
static class Program
{
public static readonly string VersionNumber = "Version 3.12",
VersionNumberDev = $"Version 3.12-indev-{DateTime.Now.ToString("ddMMyy")}r2";
public static readonly string VersionNumber = "Version 3.13",
VersionNumberDev = $"Version 3.13-indev-{DateTime.Now.ToString("ddMMyy")}r2";

public static string ApplicationData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
_7Zip = $"{ApplicationData}\\Unify\\Tools\\7z.exe",
Expand Down

0 comments on commit c9a15e2

Please sign in to comment.