Add feature flag to disable the gamedb

This commit is contained in:
YoshiRulz 2024-08-18 16:21:51 +10:00
parent c319bf5fb8
commit d9331c5a28
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 21 additions and 1 deletions

View File

@ -187,6 +187,10 @@ namespace BizHawk.Emulation.Common
public static GameInfo CheckDatabase(string hash)
{
#if BIZHAWKBUILD_GAMEDB_ALWAYS_MISS
_ = hash;
return null;
#else
_acquire.WaitOne();
var hashFormatted = FormatHash(hash);
@ -198,13 +202,16 @@ namespace BizHawk.Emulation.Common
}
return new GameInfo(cgi);
#endif
}
public static GameInfo GetGameInfo(byte[] romData, string fileName)
{
var hashSHA1 = SHA1Checksum.ComputeDigestHex(romData);
#if !BIZHAWKBUILD_GAMEDB_ALWAYS_MISS
_acquire.WaitOne();
var hashSHA1 = SHA1Checksum.ComputeDigestHex(romData);
if (DB.TryGetValue(hashSHA1, out var cgi))
{
return new GameInfo(cgi);
@ -221,6 +228,7 @@ namespace BizHawk.Emulation.Common
{
return new GameInfo(cgi);
}
#endif
// rom is not in database. make some best-guesses
var game = new GameInfo
@ -230,7 +238,9 @@ namespace BizHawk.Emulation.Common
NotInDatabase = true
};
#if !BIZHAWKBUILD_GAMEDB_ALWAYS_MISS
Console.WriteLine($"Game was not in DB. CRC: {hashCRC32} MD5: {hashMD5}");
#endif
var ext = Path.GetExtension(fileName)?.ToUpperInvariant();

View File

@ -51,11 +51,16 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
public static bool IsMAMEMachine(string path)
{
#if BIZHAWKBUILD_GAMEDB_ALWAYS_MISS
_ = path;
return false;
#else
if (_acquire == null) throw new InvalidOperationException("MAME Machine DB not initialized. It's a client responsibility because only a client knows where the database is located.");
if (HawkFile.PathContainsPipe(path)) return false; // binded archive, can't be a mame zip (note | is not a legal filesystem char, at least on windows)
if (Path.GetExtension(path).ToLowerInvariant() is not ".zip" and not ".7z") return false;
_acquire.WaitOne();
return Instance.MachineDB.Contains(Path.GetFileNameWithoutExtension(path).ToLowerInvariant());
#endif
}
}
}

View File

@ -151,9 +151,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public static List<CartInfo> Identify(string sha1)
{
#if BIZHAWKBUILD_GAMEDB_ALWAYS_MISS
_ = sha1;
return new(capacity: 0);
#else
if (acquire == null) throw new InvalidOperationException("Bootgod DB not initialized. It's a client responsibility because only a client knows where the database is located.");
acquire.WaitOne();
return instance._sha1Table[sha1];
#endif
}
}
}