public bool addCRCToDbItem(int i, string thecrc, romTypes type) { if (this.db.item[i] == null) { this.db.item[i] = new crcDbItemType(); } if (this.db.item[i].filled >= 50) { return(false); } for (int j = 0; j < this.db.item[i].filled; j++) { if (this.db.item[i].possible_crc[j].hash == thecrc) { return(false); } } if (this.db.item[i].possible_crc[this.db.item[i].filled] == null) { this.db.item[i].possible_crc[this.db.item[i].filled] = new possibleCrcType(); } this.db.item[i].possible_crc[this.db.item[i].filled].hash = thecrc.ToUpper(); this.db.item[i].possible_crc[this.db.item[i].filled].type = type; crcDbItemType type1 = this.db.item[i]; type1.filled++; return(true); }
public bool loadDb() { string path = "data/databases/crc_dupes.dscrcdb"; if (System.IO.File.Exists(path)) { this.db.filled = 0; string str2 = ""; try { string sKey = this.run.hexAndMathFunction.convertHexToEncryptionKey("790077003F0028003F0050003F003F00"); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); using (StreamReader reader = new StreamReader(this.encryptor.createDecryptionReadStream(sKey, fs))) { while ((str2 = reader.ReadLine()) != null) { try { string[] strArray = str2.Split(new char[] { '|' }); int num = 0; foreach (string str4 in strArray) { if ((num == 0) && (str4.Length == 8)) { if (this.db.item[this.db.filled] == null) { this.db.item[this.db.filled] = new crcDbItemType(); } this.db.item[this.db.filled].clean_crc = str4.ToUpper(); this.db.item[this.db.filled].filled = 0; this.db.filled++; } else { if ((num <= 0) || (str4.Length != 10)) { break; } string[] strArray2 = str4.Split(new char[] { ',' }); if (this.db.item[this.db.filled - 1].possible_crc[this.db.item[this.db.filled - 1].filled] == null) { this.db.item[this.db.filled - 1].possible_crc[this.db.item[this.db.filled - 1].filled] = new possibleCrcType(); } this.db.item[this.db.filled - 1].possible_crc[this.db.item[this.db.filled - 1].filled].hash = strArray2[0].ToUpper(); this.db.item[this.db.filled - 1].possible_crc[this.db.item[this.db.filled - 1].filled].type = (romTypes)int.Parse(strArray2[1]); crcDbItemType type1 = this.db.item[this.db.filled - 1]; type1.filled++; } num++; } continue; } catch { continue; } } reader.Close(); fs.Close(); } } catch (Exception exception) { MessageBox.Show(exception.Message + "\r\n" + str2 + "\r\nCRC Database is corrupt", "CRC Database Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } return(true); }