mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Convert Dat from a struct to an object
This effectively doesn't do much for the time being since there's only one "Dat type" that's being used. Realistically, this is probably the best bet since a given DAT should not be restricted to an output type as much as an ItemType is bound to its data. This also removes the experimental classes that won't be in use for forever. More work still might need to be done but it is unknown at this point.
This commit is contained in:
@@ -3,154 +3,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace SabreTools.Helper
|
||||
{
|
||||
#region Hash-to-Dat structs [Currently Unused]
|
||||
|
||||
/* Thought experiment
|
||||
|
||||
So, here's a connundrum: Should the internal structure of how DATs work (down to the hash level) mirror
|
||||
how people see it (Dat to multiple games, game to multiple roms, rom to single hash) or
|
||||
should it more closely mirror real life (Hash to multiple roms, rom to multiple games, game to single DAT)
|
||||
|
||||
If I use the "how people see it":
|
||||
Things are pretty much how they are now with redundant data and the like
|
||||
It makes sense to write things out to file, though. And life is easier when output is easier.
|
||||
No code changes (big plus!)
|
||||
|
||||
If I use the "how it is":
|
||||
Less data is likely to be mirrored
|
||||
Refs to DAT files are possible so that there aren't duplicates
|
||||
A lot of code will have to change...
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing Hash data (NEW SYSTEM)
|
||||
/// </summary>
|
||||
public struct HashData : IEquatable<HashData>
|
||||
{
|
||||
public long Size;
|
||||
public byte[] CRC;
|
||||
public byte[] MD5;
|
||||
public byte[] SHA1;
|
||||
public List<RomData> Roms;
|
||||
|
||||
public bool Equals(HashData other)
|
||||
{
|
||||
return this.Equals(other, false);
|
||||
}
|
||||
|
||||
public bool Equals(HashData other, bool IsDisk)
|
||||
{
|
||||
bool equals = false;
|
||||
|
||||
if (!IsDisk &&
|
||||
((this.MD5 == null || other.MD5 == null) || this.MD5 == other.MD5) &&
|
||||
((this.SHA1 == null || other.SHA1 == null) || this.SHA1 == other.SHA1))
|
||||
{
|
||||
equals = true;
|
||||
}
|
||||
else if (!IsDisk &&
|
||||
(this.Size == other.Size) &&
|
||||
((this.CRC == null || other.CRC != null) || this.CRC == other.CRC) &&
|
||||
((this.MD5 == null || other.MD5 == null) || this.MD5 == other.MD5) &&
|
||||
((this.SHA1 == null || other.SHA1 == null) || this.SHA1 == other.SHA1))
|
||||
{
|
||||
equals = true;
|
||||
}
|
||||
|
||||
return equals;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing Rom data (NEW SYSTEM)
|
||||
/// </summary>
|
||||
public struct RomData
|
||||
{
|
||||
public string Name;
|
||||
public ItemType Type;
|
||||
public bool Nodump;
|
||||
public string Date;
|
||||
public DupeType DupeType;
|
||||
public MachineData Machine;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing Game/Machine data (NEW SYSTEM)
|
||||
/// </summary>
|
||||
public struct MachineData
|
||||
{
|
||||
// Data specific to Machine/Game
|
||||
public string Name;
|
||||
public string Comment;
|
||||
public string Description;
|
||||
public string Year;
|
||||
public string Manufacturer;
|
||||
public string RomOf;
|
||||
public string CloneOf;
|
||||
public string SampleOf;
|
||||
public string SourceFile;
|
||||
public bool IsBios;
|
||||
public string Board;
|
||||
public string RebuildTo;
|
||||
public bool TorrentZipped;
|
||||
|
||||
// Data specific to the source of the Machine/Game
|
||||
public int SystemID;
|
||||
public string System;
|
||||
public int SourceID;
|
||||
public string Source;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing DAT data (NEW SYSTEM)
|
||||
/// </summary>
|
||||
public struct DatData
|
||||
{
|
||||
// Data common to most DAT types
|
||||
public string FileName;
|
||||
public string Name;
|
||||
public string Description;
|
||||
public string RootDir;
|
||||
public string Category;
|
||||
public string Version;
|
||||
public string Date;
|
||||
public string Author;
|
||||
public string Email;
|
||||
public string Homepage;
|
||||
public string Url;
|
||||
public string Comment;
|
||||
public string Header;
|
||||
public string Type; // Generally only used for SuperDAT
|
||||
public ForceMerging ForceMerging;
|
||||
public ForceNodump ForceNodump;
|
||||
public ForcePacking ForcePacking;
|
||||
public OutputFormat OutputFormat;
|
||||
public bool MergeRoms;
|
||||
public List<HashData> Hashes;
|
||||
|
||||
// Data specific to the Miss DAT type
|
||||
public bool UseGame;
|
||||
public string Prefix;
|
||||
public string Postfix;
|
||||
public bool Quotes;
|
||||
public string RepExt;
|
||||
public string AddExt;
|
||||
public bool GameName;
|
||||
public bool Romba;
|
||||
public bool? XSV; // true for tab-deliminated output, false for comma-deliminated output
|
||||
|
||||
// Statistical data related to the DAT
|
||||
public long RomCount;
|
||||
public long DiskCount;
|
||||
public long TotalSize;
|
||||
public long CRCCount;
|
||||
public long MD5Count;
|
||||
public long SHA1Count;
|
||||
public long NodumpCount;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dat-to-Hash structs
|
||||
|
||||
/// <summary>
|
||||
@@ -191,136 +43,6 @@ namespace SabreTools.Helper
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding DAT information
|
||||
/// </summary>
|
||||
public struct Dat : ICloneable
|
||||
{
|
||||
// Data common to most DAT types
|
||||
public string FileName;
|
||||
public string Name;
|
||||
public string Description;
|
||||
public string RootDir;
|
||||
public string Category;
|
||||
public string Version;
|
||||
public string Date;
|
||||
public string Author;
|
||||
public string Email;
|
||||
public string Homepage;
|
||||
public string Url;
|
||||
public string Comment;
|
||||
public string Header;
|
||||
public string Type; // Generally only used for SuperDAT
|
||||
public ForceMerging ForceMerging;
|
||||
public ForceNodump ForceNodump;
|
||||
public ForcePacking ForcePacking;
|
||||
public OutputFormat OutputFormat;
|
||||
public bool MergeRoms;
|
||||
public Dictionary<string, List<DatItem>> Files;
|
||||
|
||||
// Data specific to the Miss DAT type
|
||||
public bool UseGame;
|
||||
public string Prefix;
|
||||
public string Postfix;
|
||||
public bool Quotes;
|
||||
public string RepExt;
|
||||
public string AddExt;
|
||||
public bool RemExt;
|
||||
public bool GameName;
|
||||
public bool Romba;
|
||||
public bool? XSV; // true for tab-deliminated output, false for comma-deliminated output
|
||||
|
||||
// Statistical data related to the DAT
|
||||
public long RomCount;
|
||||
public long DiskCount;
|
||||
public long TotalSize;
|
||||
public long CRCCount;
|
||||
public long MD5Count;
|
||||
public long SHA1Count;
|
||||
public long NodumpCount;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new Dat
|
||||
{
|
||||
FileName = this.FileName,
|
||||
Name = this.Name,
|
||||
Description = this.Description,
|
||||
RootDir = this.RootDir,
|
||||
Category = this.Category,
|
||||
Version = this.Version,
|
||||
Date = this.Date,
|
||||
Author = this.Author,
|
||||
Email = this.Email,
|
||||
Homepage = this.Homepage,
|
||||
Url = this.Url,
|
||||
Comment = this.Comment,
|
||||
Header = this.Header,
|
||||
Type = this.Type,
|
||||
ForceMerging = this.ForceMerging,
|
||||
ForceNodump = this.ForceNodump,
|
||||
ForcePacking = this.ForcePacking,
|
||||
OutputFormat = this.OutputFormat,
|
||||
MergeRoms = this.MergeRoms,
|
||||
Files = this.Files,
|
||||
UseGame = this.UseGame,
|
||||
Prefix = this.Prefix,
|
||||
Postfix = this.Postfix,
|
||||
Quotes = this.Quotes,
|
||||
RepExt = this.RepExt,
|
||||
AddExt = this.AddExt,
|
||||
RemExt = this.RemExt,
|
||||
GameName = this.GameName,
|
||||
Romba = this.Romba,
|
||||
XSV = this.XSV,
|
||||
RomCount = this.RomCount,
|
||||
DiskCount = this.DiskCount,
|
||||
TotalSize = this.TotalSize,
|
||||
CRCCount = this.CRCCount,
|
||||
MD5Count = this.MD5Count,
|
||||
SHA1Count = this.SHA1Count,
|
||||
NodumpCount = this.NodumpCount,
|
||||
};
|
||||
}
|
||||
|
||||
public object CloneHeader()
|
||||
{
|
||||
return new Dat
|
||||
{
|
||||
FileName = this.FileName,
|
||||
Name = this.Name,
|
||||
Description = this.Description,
|
||||
RootDir = this.RootDir,
|
||||
Category = this.Category,
|
||||
Version = this.Version,
|
||||
Date = this.Date,
|
||||
Author = this.Author,
|
||||
Email = this.Email,
|
||||
Homepage = this.Homepage,
|
||||
Url = this.Url,
|
||||
Comment = this.Comment,
|
||||
Header = this.Header,
|
||||
Type = this.Type,
|
||||
ForceMerging = this.ForceMerging,
|
||||
ForceNodump = this.ForceNodump,
|
||||
ForcePacking = this.ForcePacking,
|
||||
OutputFormat = this.OutputFormat,
|
||||
MergeRoms = this.MergeRoms,
|
||||
Files = new Dictionary<string, List<DatItem>>(),
|
||||
UseGame = this.UseGame,
|
||||
Prefix = this.Prefix,
|
||||
Postfix = this.Postfix,
|
||||
Quotes = this.Quotes,
|
||||
RepExt = this.RepExt,
|
||||
AddExt = this.AddExt,
|
||||
RemExt = this.RemExt,
|
||||
GameName = this.GameName,
|
||||
Romba = this.Romba,
|
||||
XSV = this.XSV,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Skipper structs
|
||||
|
||||
Reference in New Issue
Block a user