diff --git a/DATabaseTwo/DATabaseTwo.cs b/DATabaseTwo/DATabaseTwo.cs
index e3d36fcc..a6b7b54c 100644
--- a/DATabaseTwo/DATabaseTwo.cs
+++ b/DATabaseTwo/DATabaseTwo.cs
@@ -53,21 +53,10 @@ namespace SabreTools
_logger = new Logger(true, "database2.log");
_logger.Start();
- // Call initial setup
- Setup();
-
- // If there's no arguments, show the menu
- if (args.Length == 0)
- {
- _logger.ToFile = true;
- ShowMainMenu();
- _logger.Close();
- return;
- }
-
// Set all default values
bool help = false,
genall = false,
+ ignore = false,
listsys = false,
norename = false,
old = false;
@@ -87,6 +76,10 @@ namespace SabreTools
case "--generate-all":
genall = true;
break;
+ case "-i":
+ case "--ignore":
+ ignore = true;
+ break;
case "-lsy":
case "--list-systems":
listsys = true;
@@ -124,6 +117,18 @@ namespace SabreTools
return;
}
+ // Call initial setup because everything after here requires it
+ Import(ignore);
+
+ // If there's no arguments, show the menu
+ if (args.Length == 0)
+ {
+ _logger.ToFile = true;
+ ShowMainMenu();
+ _logger.Close();
+ return;
+ }
+
// If we want a list of systems
if (listsys)
{
@@ -512,7 +517,8 @@ ORDER BY system.manufacturer, system.name";
///
/// Perform initial setup for the program
///
- private static void Setup()
+ /// False if each DAT that has no defined source asks for user input (default), true otherwise
+ private static void Import(bool ignore = false)
{
Remapping.CreateRemappings();
Build.Start("DATabaseTwo");
@@ -556,7 +562,7 @@ ORDER BY system.manufacturer, system.name";
{
while (sldr.Read())
{
- int id = sldr.GetInt32(0);
+ int systemid = sldr.GetInt32(0);
string system = _datroot + Path.DirectorySeparatorChar + sldr.GetString(1) + " - " + sldr.GetString(2);
system = system.Trim();
@@ -601,6 +607,12 @@ COMMIT;";
// Add the hash to the temporary Dictionary
hashes.Add(hash, hashid);
+ // If we don't care about source, stop here
+ if (ignore)
+ {
+ continue;
+ }
+
// Now try to determine the source for the file based on the name
string source = GetSourceFromFileName(Path.GetFileName(file));
int sourceid = 0;
@@ -679,8 +691,10 @@ COMMIT;";
}
// Otherwise, we should already have an ID
- // Add the source link to the database
- string uquery = "INSERT OR IGNORE INTO datsdata (id, key, value) VALUES (" + hashid + ", 'source', '" + sourceid + "')";
+ // Add the source and system link to the database
+ string uquery = @"INSERT OR IGNORE INTO datsdata (id, key, value)
+VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
+(" + hashid + ", 'system', '" + systemid + "')";
using (SqliteCommand uslc = new SqliteCommand(uquery, dbc))
{
uslc.ExecuteNonQuery();
diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs
index f266db6c..037e5bb3 100644
--- a/SabreHelper/Build.cs
+++ b/SabreHelper/Build.cs
@@ -200,6 +200,7 @@ Usage: DATabaseTwo [options]
Options:
-h, -?, --help Show this help dialog
-ga, --generate-all Start tool in generate all mode
+ -i, --ignore Don't prompt for new sources
-lsy, --list-systems List all systems (id <= name)
-o, --old Output DAT in CMP format instead of XML
-sys=, --system= System ID to generate from