Skip to content

Commit

Permalink
Code code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
MirisWisdom committed Nov 22, 2018
1 parent e2b8628 commit 68f6910
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 33 deletions.
19 changes: 17 additions & 2 deletions Atarashii/Atarashii.API/Profile.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using Atarashii.Modules.Profile;

Expand All @@ -19,7 +20,10 @@ public static class Profile
/// </returns>
public static Configuration Parse(string blamPath)
{
return ConfigurationFactory.GetFromStream(File.Open(blamPath, FileMode.Open));
using (var fs = File.Open(blamPath, FileMode.Open))
{
return ConfigurationFactory.GetFromStream(fs);
}
}

/// <summary>
Expand All @@ -33,7 +37,18 @@ public static Configuration Parse(string blamPath)
/// </param>
public static void Patch(Configuration configuration, string blamPath)
{
new ConfigurationPatcher(configuration).PatchTo(File.Open(blamPath, FileMode.Open));
using (var ms = new MemoryStream())
using (var fs = File.Open(blamPath, FileMode.Open))
{
fs.CopyTo(ms);
new ConfigurationPatcher(configuration).PatchTo(ms);
new ConfigurationForger().Forge(ms);

ms.Position = 0;
fs.Position = 0;

ms.CopyTo(fs);
}
}

/// <summary>
Expand Down
71 changes: 41 additions & 30 deletions Atarashii/Atarashii/Modules/Profile/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,6 @@ namespace Atarashii.Modules.Profile
/// </summary>
public class Configuration
{
/// <summary>
/// Player name.
/// </summary>
public Name Name { get; set; } = new Name();

/// <summary>
/// Player colour.
/// </summary>
public Colour Colour { get; set; } = new Colour();

/// <summary>
/// Mouse settings.
/// </summary>
public Mouse Mouse { get; set; } = new Mouse();

/// <summary>
/// Audio settings.
/// </summary>
public Audio Audio { get; set; } = new Audio();

/// <summary>
/// Video settings.
/// </summary>
public Video Video { get; set; } = new Video();

/// <summary>
/// Network settings.
/// </summary>
public Network Network { get; set; } = new Network();

/// <summary>
/// Length of the blam.sav binary.
/// </summary>
Expand Down Expand Up @@ -154,5 +124,46 @@ public class Configuration
/// Offset of the network client port property.
/// </summary>
public const int NetworkPortClientOffset = 0x1004;

/// <summary>
/// Offset of the blam.sav integrity hash.
/// </summary>
public const int BlamHashOffset = 0x1FFC;

/// <summary>
/// Length of the blam.sav integrity hash.
/// The value is that of a CRC32 length.
/// </summary>
public const int BlamHashLength = 0x4;

/// <summary>
/// Player name.
/// </summary>
public Name Name { get; set; } = new Name();

/// <summary>
/// Player colour.
/// </summary>
public Colour Colour { get; set; } = new Colour();

/// <summary>
/// Mouse settings.
/// </summary>
public Mouse Mouse { get; set; } = new Mouse();

/// <summary>
/// Audio settings.
/// </summary>
public Audio Audio { get; set; } = new Audio();

/// <summary>
/// Video settings.
/// </summary>
public Video Video { get; set; } = new Video();

/// <summary>
/// Network settings.
/// </summary>
public Network Network { get; set; } = new Network();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static Configuration GetFromStream(Stream stream)

return configuration;
}

/// <summary>
/// Returns a byte value from the inbound binary reader at the given offset.
/// </summary>
Expand Down

0 comments on commit 68f6910

Please sign in to comment.