mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Variable cleanup for future changes
This commit is contained in:
@@ -10,8 +10,8 @@ namespace DATabase
|
|||||||
class Generate
|
class Generate
|
||||||
{
|
{
|
||||||
// Private instance variables
|
// Private instance variables
|
||||||
private int _system;
|
private int _systems;
|
||||||
private int _source;
|
private int _sources;
|
||||||
private string _connectionString;
|
private string _connectionString;
|
||||||
private bool _norename;
|
private bool _norename;
|
||||||
private bool _old;
|
private bool _old;
|
||||||
@@ -19,20 +19,10 @@ namespace DATabase
|
|||||||
// Private required variables
|
// Private required variables
|
||||||
private Dictionary<int, string> _headers;
|
private Dictionary<int, string> _headers;
|
||||||
|
|
||||||
// Public instance variables
|
public Generate(int systems, int sources, string connectionString, bool norename = false, bool old = false)
|
||||||
public int System
|
|
||||||
{
|
{
|
||||||
get { return _system; }
|
_systems = systems;
|
||||||
}
|
_sources = sources;
|
||||||
public int Source
|
|
||||||
{
|
|
||||||
get { return _source; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Generate(int system, int source, string connectionString, bool norename = false, bool old = false)
|
|
||||||
{
|
|
||||||
_system = system;
|
|
||||||
_source = source;
|
|
||||||
_connectionString = connectionString;
|
_connectionString = connectionString;
|
||||||
_norename = norename;
|
_norename = norename;
|
||||||
_old = old;
|
_old = old;
|
||||||
@@ -51,9 +41,9 @@ namespace DATabase
|
|||||||
{
|
{
|
||||||
// Get the system name, if applicable
|
// Get the system name, if applicable
|
||||||
string systemname = "ALL";
|
string systemname = "ALL";
|
||||||
if (_system != -1)
|
if (_systems != -1)
|
||||||
{
|
{
|
||||||
string query = "SELECT manufacturer, system FROM systems WHERE id=" + _system;
|
string query = "SELECT manufacturer, system FROM systems WHERE id=" + _systems;
|
||||||
using (SQLiteConnection dbc = new SQLiteConnection(_connectionString))
|
using (SQLiteConnection dbc = new SQLiteConnection(_connectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
@@ -64,7 +54,7 @@ namespace DATabase
|
|||||||
// If there are no games for this combination, return nothing
|
// If there are no games for this combination, return nothing
|
||||||
if (!sldr.HasRows)
|
if (!sldr.HasRows)
|
||||||
{
|
{
|
||||||
Console.WriteLine("No system could be found with id " + _system + ". Please check and try again.");
|
Console.WriteLine("No system could be found with id " + _systems + ". Please check and try again.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,9 +67,9 @@ namespace DATabase
|
|||||||
}
|
}
|
||||||
|
|
||||||
string sourcename = "Merged";
|
string sourcename = "Merged";
|
||||||
if (_source != -1)
|
if (_sources != -1)
|
||||||
{
|
{
|
||||||
string query = "SELECT name FROM sources WHERE id=" + _source;
|
string query = "SELECT name FROM sources WHERE id=" + _sources;
|
||||||
using (SQLiteConnection dbc = new SQLiteConnection(_connectionString))
|
using (SQLiteConnection dbc = new SQLiteConnection(_connectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
@@ -90,7 +80,7 @@ namespace DATabase
|
|||||||
// If there are no games for this combination, return nothing
|
// If there are no games for this combination, return nothing
|
||||||
if (!sldr.HasRows)
|
if (!sldr.HasRows)
|
||||||
{
|
{
|
||||||
Console.WriteLine("No source could be found with id " + _source + ". Please check and try again.");
|
Console.WriteLine("No source could be found with id " + _sources + ". Please check and try again.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,16 +114,16 @@ namespace DATabase
|
|||||||
StreamWriter sw = new StreamWriter(fs);
|
StreamWriter sw = new StreamWriter(fs);
|
||||||
|
|
||||||
// Temporarilly set _system if we're in MEGAMERGED mode to get the right header skip XML
|
// Temporarilly set _system if we're in MEGAMERGED mode to get the right header skip XML
|
||||||
if (_system == -1 && _source == -1)
|
if (_systems == -1 && _sources == -1)
|
||||||
{
|
{
|
||||||
_system = 0;
|
_systems = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
string header_old = "clrmamepro (\n" +
|
string header_old = "clrmamepro (\n" +
|
||||||
"\tname \"" + HttpUtility.HtmlEncode(datname) + "\"\n" +
|
"\tname \"" + HttpUtility.HtmlEncode(datname) + "\"\n" +
|
||||||
"\tdescription \"" + HttpUtility.HtmlEncode(datname) + "\"\n" +
|
"\tdescription \"" + HttpUtility.HtmlEncode(datname) + "\"\n" +
|
||||||
"\tversion \"" + version + "\"\n" +
|
"\tversion \"" + version + "\"\n" +
|
||||||
(_system >= 0 && _headers.ContainsKey(_system) ? " header \"" + _headers[_system] + "\"\n" : "") +
|
(_systems >= 0 && _headers.ContainsKey(_systems) ? " header \"" + _headers[_systems] + "\"\n" : "") +
|
||||||
"\tcomment \"\"\n" +
|
"\tcomment \"\"\n" +
|
||||||
"\tauthor \"The Wizard of DATz\"\n" +
|
"\tauthor \"The Wizard of DATz\"\n" +
|
||||||
")\n";
|
")\n";
|
||||||
@@ -148,13 +138,13 @@ namespace DATabase
|
|||||||
"\t\t\t<version>" + version + "</version>\n" +
|
"\t\t\t<version>" + version + "</version>\n" +
|
||||||
"\t\t\t<date>" + version + "</date>\n" +
|
"\t\t\t<date>" + version + "</date>\n" +
|
||||||
"\t\t\t<author>The Wizard of DATz</author>\n" +
|
"\t\t\t<author>The Wizard of DATz</author>\n" +
|
||||||
"\t\t\t<clrmamepro" + (_system >= 0 && _headers.ContainsKey(_system) ? " header=\"" + _headers[_system] + "\"" : "") + "/>\n" +
|
"\t\t\t<clrmamepro" + (_systems >= 0 && _headers.ContainsKey(_systems) ? " header=\"" + _headers[_systems] + "\"" : "") + "/>\n" +
|
||||||
"\t\t</header>\n";
|
"\t\t</header>\n";
|
||||||
|
|
||||||
// Unset _system again if we're in MEGAMERGED mode
|
// Unset _system again if we're in MEGAMERGED mode
|
||||||
if (_system == 0 && _source == -1)
|
if (_systems == 0 && _sources == -1)
|
||||||
{
|
{
|
||||||
_system = -1;
|
_systems = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the header out
|
// Write the header out
|
||||||
@@ -220,8 +210,8 @@ namespace DATabase
|
|||||||
List<RomData> roms = new List<RomData>();
|
List<RomData> roms = new List<RomData>();
|
||||||
|
|
||||||
// Check if we're in a merged mode
|
// Check if we're in a merged mode
|
||||||
bool sysmerged = (_system == -1);
|
bool sysmerged = (_systems == -1);
|
||||||
bool srcmerged = (_source == -1);
|
bool srcmerged = (_sources == -1);
|
||||||
bool merged = sysmerged || srcmerged;
|
bool merged = sysmerged || srcmerged;
|
||||||
|
|
||||||
string query = @"
|
string query = @"
|
||||||
@@ -239,9 +229,9 @@ JOIN files
|
|||||||
JOIN checksums
|
JOIN checksums
|
||||||
ON files.id=checksums.file" +
|
ON files.id=checksums.file" +
|
||||||
(!sysmerged || !srcmerged ? "\nWHERE" : "") +
|
(!sysmerged || !srcmerged ? "\nWHERE" : "") +
|
||||||
(!srcmerged ? " sources.id=" + _source : "") +
|
(!srcmerged ? " sources.id=" + _sources : "") +
|
||||||
(!srcmerged && !sysmerged ? " AND" : "") +
|
(!srcmerged && !sysmerged ? " AND" : "") +
|
||||||
(!sysmerged ? " systems.id=" + _system : "") + "\n" +
|
(!sysmerged ? " systems.id=" + _systems : "") + "\n" +
|
||||||
"\nORDER BY " +
|
"\nORDER BY " +
|
||||||
(merged ? "checksums.size, checksums.crc, checksums.md5, checksums.sha1"
|
(merged ? "checksums.size, checksums.crc, checksums.md5, checksums.sha1"
|
||||||
: "systems.id, sources.id, games.name, files.name");
|
: "systems.id, sources.id, games.name, files.name");
|
||||||
|
|||||||
Reference in New Issue
Block a user