mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Test and fix commented code. It works now!
This commit is contained in:
@@ -1119,15 +1119,13 @@ Make a selection:
|
|||||||
/// <param name="old">True if the output file should be in ClrMamePro format (default false)</param>
|
/// <param name="old">True if the output file should be in ClrMamePro format (default false)</param>
|
||||||
private static void InitGenerateAll(string outdir, bool norename, bool old)
|
private static void InitGenerateAll(string outdir, bool norename, bool old)
|
||||||
{
|
{
|
||||||
string actualdir = (outdir == "" ? Environment.CurrentDirectory + "/" : outdir + "/");
|
string actualdir = (outdir == "" ? Environment.CurrentDirectory + Path.DirectorySeparatorChar :
|
||||||
outdir = actualdir + "/temp/";
|
(!outdir.EndsWith(Path.DirectorySeparatorChar.ToString()) ? outdir + Path.DirectorySeparatorChar : outdir));
|
||||||
|
outdir = actualdir + "temp" + Path.DirectorySeparatorChar;
|
||||||
|
|
||||||
// Generate system-merged
|
// Generate system-merged
|
||||||
string query = @"SELECT DISTINCT systems.id
|
string query = "SELECT DISTINCT systems.id FROM systems JOIN games ON systems.id=games.system ORDER BY systems.manufacturer, systems.system";
|
||||||
FROM systems
|
//string query = "SELECT DISTINCT system.id FROM system JOIN gamesystem ON system.id=gamesystem.systemid ORDER BY system.manufacturer, system.name";
|
||||||
JOIN games
|
|
||||||
ON systems.id=games.system
|
|
||||||
ORDER BY systems.manufacturer, systems.system";
|
|
||||||
using (SqliteConnection dbc = new SqliteConnection(_connectionString))
|
using (SqliteConnection dbc = new SqliteConnection(_connectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
@@ -1155,6 +1153,18 @@ Make a selection:
|
|||||||
ON games.source=sources.id
|
ON games.source=sources.id
|
||||||
WHERE systems.id=" + sldr.GetInt32(0).ToString() + @"
|
WHERE systems.id=" + sldr.GetInt32(0).ToString() + @"
|
||||||
ORDER BY sources.name";
|
ORDER BY sources.name";
|
||||||
|
/*
|
||||||
|
string squery = @"SELECT DISTINCT source.id
|
||||||
|
FROM system
|
||||||
|
JOIN gamesystem
|
||||||
|
ON system.id=gamesystem.systemid
|
||||||
|
JOIN gamesource
|
||||||
|
ON gamesystem.game=gamesource.game
|
||||||
|
JOIN source
|
||||||
|
ON gamesource.sourceid=source.id
|
||||||
|
WHERE system.id=" + sldr.GetInt32(0).ToString() + @"
|
||||||
|
ORDER BY source.name";
|
||||||
|
*/
|
||||||
|
|
||||||
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
||||||
{
|
{
|
||||||
@@ -1178,11 +1188,8 @@ Make a selection:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate source-merged
|
// Generate source-merged
|
||||||
query = @"SELECT DISTINCT sources.id, sources.name
|
query = "SELECT DISTINCT sources.id, sources.name FROM sources JOIN games ON sources.id=games.source ORDER BY sources.name";
|
||||||
FROM sources
|
//query = "SELECT DISTINCT source.id, source.name FROM source JOIN gamesource ON source.id=gamesource.sourceid ORDER BY source.name";
|
||||||
JOIN games
|
|
||||||
ON sources.id=games.source
|
|
||||||
ORDER BY sources.name";
|
|
||||||
|
|
||||||
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -268,16 +268,18 @@ JOIN checksums
|
|||||||
// This block would replace the whole block above between BEGIN COMMENT and END COMMENT
|
// This block would replace the whole block above between BEGIN COMMENT and END COMMENT
|
||||||
string query = @"
|
string query = @"
|
||||||
SELECT hash.id AS id, hash.size AS size, hash.crc AS crc, hash.md5 AS md5, hash.sha1 AS sha1,
|
SELECT hash.id AS id, hash.size AS size, hash.crc AS crc, hash.md5 AS md5, hash.sha1 AS sha1,
|
||||||
hashdata.key AS key, hashdata.value AS value,
|
a.key AS key, a.value AS value,
|
||||||
source.id, source.name, source.url,
|
source.id, source.name, source.url,
|
||||||
system.id, system.manufacturer, system.name
|
system.id, system.manufacturer, system.name
|
||||||
FROM hash
|
FROM hash
|
||||||
JOIN hashdata
|
JOIN hashdata a
|
||||||
ON hash.id=hashdata.hashid
|
ON hash.id=a.hashid
|
||||||
|
JOIN hashdata b
|
||||||
|
ON a.hashid=b.hashid
|
||||||
JOIN gamesystem
|
JOIN gamesystem
|
||||||
ON hash.value=gamesystem.game
|
ON b.value=gamesystem.game
|
||||||
JOIN gamesource
|
JOIN gamesource
|
||||||
ON hash.value=gamesource.game
|
ON b.value=gamesource.game
|
||||||
JOIN system
|
JOIN system
|
||||||
ON gamesystem.systemid=system.id
|
ON gamesystem.systemid=system.id
|
||||||
JOIN source
|
JOIN source
|
||||||
@@ -303,30 +305,29 @@ JOIN source
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve and process the roms for merging
|
// Retrieve and process the roms for merging
|
||||||
string lastid = "";
|
int systemid = -1, sourceid = -1;
|
||||||
string name = "";
|
long lastid = -1, size = -1;
|
||||||
string game = "";
|
string name = "", game = "", type = "", manufacturer = "", system = "", source = "", url = "", crc = "", md5 = "", sha1 = "";
|
||||||
string type = "";
|
|
||||||
while (sldr.Read())
|
while (sldr.Read())
|
||||||
{
|
{
|
||||||
// If the hash is different than the last
|
// If the hash is different than the last
|
||||||
if (lastid != "" && sldr.GetString(0) != lastid)
|
if (lastid != -1 && sldr.GetInt64(0) != lastid)
|
||||||
{
|
{
|
||||||
RomData temp = new RomData
|
RomData temp = new RomData
|
||||||
{
|
{
|
||||||
Manufacturer = sldr.GetString(11),
|
Manufacturer = manufacturer,
|
||||||
System = sldr.GetString(12),
|
System = system,
|
||||||
SystemID = sldr.GetInt32(10),
|
SystemID = systemid,
|
||||||
Source = sldr.GetString(8),
|
Source = source,
|
||||||
URL = sldr.GetString(9),
|
URL = url,
|
||||||
SourceID = sldr.GetInt32(7),
|
SourceID = sourceid,
|
||||||
Game = game,
|
Game = game,
|
||||||
Name = name,
|
Name = name,
|
||||||
Type = type,
|
Type = type,
|
||||||
Size = sldr.GetInt64(1),
|
Size = size,
|
||||||
CRC = sldr.GetString(2),
|
CRC = crc,
|
||||||
MD5 = sldr.GetString(3),
|
MD5 = md5,
|
||||||
SHA1 = sldr.GetString(4),
|
SHA1 = sha1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Rename the game associated if it's still valid and we allow renames
|
// Rename the game associated if it's still valid and we allow renames
|
||||||
@@ -344,22 +345,33 @@ JOIN source
|
|||||||
name = "";
|
name = "";
|
||||||
type = "";
|
type = "";
|
||||||
}
|
}
|
||||||
// Otherwise, try to get the values
|
|
||||||
else
|
// Get all of the current ROM information
|
||||||
{
|
manufacturer = sldr.GetString(11);
|
||||||
|
system = sldr.GetString(12);
|
||||||
|
systemid = sldr.GetInt32(10);
|
||||||
|
source = sldr.GetString(8);
|
||||||
|
url = sldr.GetString(9);
|
||||||
|
sourceid = sldr.GetInt32(7);
|
||||||
|
size = sldr.GetInt64(1);
|
||||||
|
crc = sldr.GetString(2);
|
||||||
|
md5 = sldr.GetString(3);
|
||||||
|
sha1 = sldr.GetString(4);
|
||||||
|
|
||||||
switch (sldr.GetString(5))
|
switch (sldr.GetString(5))
|
||||||
{
|
{
|
||||||
case "name":
|
|
||||||
name = sldr.GetString(6);
|
|
||||||
break;
|
|
||||||
case "game":
|
case "game":
|
||||||
game = sldr.GetString(6);
|
game = sldr.GetString(6);
|
||||||
break;
|
break;
|
||||||
|
case "name":
|
||||||
|
name = sldr.GetString(6);
|
||||||
|
break;
|
||||||
case "type":
|
case "type":
|
||||||
type = sldr.GetString(6);
|
type = sldr.GetString(6);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
lastid = sldr.GetInt64(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user