private static void LoadRomFromDat(RvGame rvGame, XmlNode romNode) { if (romNode.Attributes == null) { return; } XmlNode name = romNode.Attributes.GetNamedItem("name"); string loadflag = VarFix.String(romNode.Attributes.GetNamedItem("loadflag")); if (name != null) { RvRom rvRom = new RvRom(); rvRom.Name = VarFix.CleanFullFileName(name); rvRom.Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")); rvRom.CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8); rvRom.SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40); rvRom.Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")); _indexContinue = rvGame.AddRom(rvRom); } else if (loadflag.ToLower() == "continue") { RvRom tROM = rvGame.Roms[_indexContinue]; tROM.Size += VarFix.ULong(romNode.Attributes.GetNamedItem("size")); } else if (loadflag.ToLower() == "ignore") { RvRom tROM = rvGame.Roms[_indexContinue]; tROM.Size += VarFix.ULong(romNode.Attributes.GetNamedItem("size")); } }
private static bool LoadRomFromDat(RvGame rvGame) { if (DatFileLoader.Next != "(") { DatUpdate.SendAndShowDat("( not found after rom", DatFileLoader.Filename); return(false); } DatFileLoader.Gn(); if (DatFileLoader.Next.ToLower() != "name") { DatUpdate.SendAndShowDat("Name not found as first object in ( )", DatFileLoader.Filename); return(false); } RvRom rvRom = new RvRom(); rvRom.Name = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); while (DatFileLoader.Next != ")") { switch (DatFileLoader.Next.ToLower()) { case "size": rvRom.Size = VarFix.ULong(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "crc": rvRom.CRC = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 8); DatFileLoader.Gn(); break; case "sha1": rvRom.SHA1 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 40); DatFileLoader.Gn(); break; case "md5": rvRom.MD5 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 32); DatFileLoader.Gn(); break; case "merge": rvRom.Merge = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "flags": rvRom.Status = VarFix.ToLower(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "date": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "bios": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "region": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "offs": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "nodump": rvRom.Status = "nodump"; DatFileLoader.Gn(); break; default: DatUpdate.SendAndShowDat("Error: key word '" + DatFileLoader.Next + "' not known in rom", DatFileLoader.Filename); DatFileLoader.Gn(); break; } } rvGame.AddRom(rvRom); return(true); }
private static void LoadRomFromDat(RvGame rvGame, XmlNode romNode) { if (romNode.Attributes == null) { return; } RvRom rvRom = new RvRom(); rvRom.Name = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name")); rvRom.Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")); rvRom.CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8); rvRom.SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40); rvRom.MD5 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32); rvRom.Merge = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("merge")); rvRom.Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")); rvGame.AddRom(rvRom); }
private static void LoadRomFromDat(RvGame rvGame, XmlNode romNode, HeaderFileType datFileType) { if (romNode.Attributes == null) { return; } RvRom rvRom = new RvRom { AltType = datFileType, Name = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name")), Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")), CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8), SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40), MD5 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32), Merge = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("merge")), Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")) }; rvGame.AddRom(rvRom); }
private static void DatSetRenameAndRemoveDups(RvDat tDat) { if (tDat.Games == null) { return; } for (int g = 0; g < tDat.Games.Count; g++) { RvGame tGame = tDat.Games[g]; for (int r = 0; r < tGame.RomCount - 1; r++) { RvRom f0 = tGame.Roms[r]; RvRom f1 = tGame.Roms[r + 1]; if (f0.Name != f1.Name) { continue; } if ((f0.Size != f1.Size) || (ArrByte.iCompare(f0.CRC, f1.CRC) != 0)) { tGame.Roms.RemoveAt(r + 1); // remove F1 f1.Name = f1.Name + "_" + ArrByte.ToString(f1.CRC); // rename F1; int pos = tGame.AddRom(f1); // if this rename moved the File back up the list, start checking again from that file. if (pos < r) { r = pos; } } else { tGame.Roms.RemoveAt(r + 1); } r--; } } }
private static void DatSetMergeSets(RvDat tDat) { for (int g = tDat.Games.Count - 1; g >= 0; g--) { RvGame mGame = tDat.Games[g]; List <RvGame> lstParentGames = new List <RvGame>(); FindParentSet(mGame, tDat, ref lstParentGames); while ((lstParentGames.Count > 0) && ((lstParentGames[lstParentGames.Count - 1].IsBios ?? "").ToLower() == "yes")) { lstParentGames.RemoveAt(lstParentGames.Count - 1); } if (lstParentGames.Count <= 0) { continue; } RvGame romofGame = lstParentGames[lstParentGames.Count - 1]; bool founderror = false; for (int r = 0; r < mGame.RomCount; r++) { string name = mGame.Roms[r].Name; string mergename = mGame.Roms[r].Merge; for (int r1 = 0; r1 < romofGame.RomCount; r1++) { if ( ((name == romofGame.Roms[r1].Name.ToLower()) || (mergename == romofGame.Roms[r1].Name.ToLower())) && ((ArrByte.iCompare(mGame.Roms[r].CRC, romofGame.Roms[r1].CRC) != 0) || (mGame.Roms[r].Size != romofGame.Roms[r1].Size)) ) { founderror = true; } } } if (founderror) { mGame.RomOf = null; continue; } for (int r = 0; r < mGame.RomCount; r++) { string name = mGame.Roms[r].Name; string mergename = mGame.Roms[r].Merge; bool found = false; for (int r1 = 0; r1 < romofGame.RomCount; r1++) { if ( ((name == romofGame.Roms[r1].Name.ToLower()) || (mergename == romofGame.Roms[r1].Name.ToLower())) && (ArrByte.iCompare(mGame.Roms[r].CRC, romofGame.Roms[r1].CRC) == 0) && (mGame.Roms[r].Size == romofGame.Roms[r1].Size) ) { found = true; break; } } if (!found) { romofGame.AddRom(mGame.Roms[r]); } } tDat.Games.RemoveAt(g); } }
private static void CopyDir(DatDir datD, HeaderFileType headerFileType, RvDat retDat = null, RvGame retGame = null) { DatBase[] datB = datD.ToArray(); if (datB == null) { return; } foreach (DatBase b in datB) { switch (b) { case DatDir nDir: if (nDir.DGame == null) { break; } DatGame dGame = nDir.DGame; RvGame cGame = new RvGame(); cGame.Name = b.Name; cGame.Description = dGame.Description; cGame.Manufacturer = dGame.Manufacturer; cGame.CloneOf = dGame.CloneOf; cGame.RomOf = dGame.RomOf; cGame.SampleOf = dGame.SampleOf; cGame.SourceFile = dGame.SourceFile; cGame.IsBios = dGame.IsBios; cGame.Board = dGame.Board; cGame.Year = dGame.Year; if (dGame.IsEmuArc) { cGame.IsTrurip = true; cGame.Publisher = dGame.Publisher; cGame.Developer = dGame.Developer; //cGame.Edition //cGame.Version //cGame.Type //cGame.Media //cGame.Language cGame.Players = dGame.Players; cGame.Ratings = dGame.Ratings; cGame.Genre = dGame.Genre; //cGame.Peripheral //cGame.BarCode //cGame.MediaCatalogNumber } retDat?.AddGame(cGame); CopyDir(nDir, headerFileType, null, cGame); break; case DatFile nFile: if (nFile.isDisk) { break; } RvRom nf = new RvRom() { Name = nFile.Name, Size = nFile.Size, CRC = nFile.CRC, SHA1 = nFile.SHA1, MD5 = nFile.MD5, Merge = nFile.Merge, Status = nFile.Status, AltType = headerFileType }; retGame?.AddRom(nf); break; } } }
private static bool LoadRomFromDat(RvGame rvGame, HeaderFileType datFileType) { if (DatFileLoader.Next != "(") { DatUpdate.SendAndShowDat("( not found after rom on line " + DatFileLoader.LineNumber, DatFileLoader.Filename); return(false); } DatFileLoader.Gn(); if (DatFileLoader.Next.ToLower() != "name") { DatUpdate.SendAndShowDat("Name not found as first object in ( ) on line " + DatFileLoader.LineNumber, DatFileLoader.Filename); return(false); } RvRom rvRom = new RvRom { Name = VarFix.CleanFullFileName(DatFileLoader.Gn()), AltType = datFileType }; DatFileLoader.Gn(); while (rvRom.CRC == null || rvRom.Size == null || DatFileLoader.Next != ")") { switch (DatFileLoader.Next.ToLower()) { case "size": rvRom.Size = VarFix.ULong(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "crc": rvRom.CRC = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 8); DatFileLoader.Gn(); break; case "md5": rvRom.MD5 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 32); DatFileLoader.Gn(); break; case "sha1": rvRom.SHA1 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 40); DatFileLoader.Gn(); break; case "sha256": // No-op until larger hashes are supported DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "sha384": // No-op until larger hashes are supported DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "sha512": // No-op until larger hashes are supported DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "date": rvRom.Date = DatFileLoader.Gn(); rvRom.Date += " " + DatFileLoader.Gn(); DatFileLoader.Gn(); break; default: rvRom.Name += " " + DatFileLoader.Next; DatFileLoader.Gn(); break; } } rvGame.AddRom(rvRom); return(true); }