Skip to content

Commit

Permalink
Fix LibRetro alphabetization bug (found in N64)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatmanFan committed Jan 23, 2025
1 parent f40bb19 commit 35d4b81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion FriishProduce/FriishProduce.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Optimize>false</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
Expand Down
26 changes: 13 additions & 13 deletions FriishProduce/_classes/Databases/LibRetro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,11 @@ public static DataTable Parse(Platform In)

// Scan retrieved database for CRC32 hashes, and add to data table
// ****************
for (int i = db_lines[0].Length - 1; i > 1; i--)
for (int i = 0; i < db_lines[0].Length; i++)
{
string line = db_lines[0][i];

if (line.Contains("crc "))
{
if (dt.Select($"crc = '{crc}'")?.Length == 0 && !string.IsNullOrWhiteSpace(name))
{
dt.Rows.Add(crc, name, null, releaseyear, users, image);
image = users = releaseyear = name = crc = null;
}

crc = db_crc(line.Substring(line.IndexOf("crc ") + 4, 8));
}

if (string.IsNullOrEmpty(name) && (line.Contains("name \"") || line.Contains("comment \"")) && !line.Contains("rom ("))
if (string.IsNullOrEmpty(name) && (line.Contains("name \"") || line.Contains("comment \"")) && !line.Contains("rom (") && !line.Contains(db_name))
{
name = line.Replace("\t", "").Replace("name \"", "").Replace("comment \"", "").Replace("\"", "");
image = db_img(name);
Expand All @@ -230,6 +219,17 @@ public static DataTable Parse(Platform In)
{
serial = line.Substring(line.IndexOf("serial ") + 7).TrimStart('\"', ' ', '\t', ')').TrimEnd('\"', ' ', '\t', ')');
}

if (line.Contains("crc "))
{
crc = db_crc(line.Substring(line.IndexOf("crc ") + 4, 8));

if (dt.Select($"crc = '{crc}'")?.Length == 0 && !string.IsNullOrWhiteSpace(name))
{
dt.Rows.Add(crc, name, serial, releaseyear, users, image);
image = users = releaseyear = name = crc = null;
}
}
}

// Add release year, players and others
Expand Down

0 comments on commit 35d4b81

Please sign in to comment.