summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Robbbert <Robbbert@users.noreply.github.com>2017-05-21 23:22:19 +1000
committer Robbbert <Robbbert@users.noreply.github.com>2017-05-21 23:22:19 +1000
commit3b3ef88bfe7850c63debfb7238a4ca88af9344c0 (patch)
tree2551c35c7272813934ee279b1b3d259d98e4f458
parent3ad2d8f34f8f4387e5d705e6e75f96f02b14889c (diff)
(nw) Removed duplicates from list of approximate software matches.
-rw-r--r--src/emu/softlist_dev.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/emu/softlist_dev.cpp b/src/emu/softlist_dev.cpp
index 9583163a278..8e02afd48ed 100644
--- a/src/emu/softlist_dev.cpp
+++ b/src/emu/softlist_dev.cpp
@@ -155,21 +155,32 @@ void software_list_device::find_approx_matches(const std::string &name, int matc
int shortpenalty = driver_list::penalty_compare(name.c_str(), swinfo.shortname().c_str());
int curpenalty = std::min(longpenalty, shortpenalty);
- // insert into the sorted table of matches
- for (int matchnum = matches - 1; matchnum >= 0; matchnum--)
+ // make sure it isn't already in the table
+ bool skip = false;
+ for (int matchnum = 0; matchnum < matches; matchnum++)
{
- // stop if we're worse than the current entry
- if (curpenalty >= penalty[matchnum])
- break;
+ if ((penalty[matchnum] == curpenalty) && (swinfo.longname() == list[matchnum]->longname()) && (swinfo.shortname() == list[matchnum]->shortname()))
+ skip = true;
+ }
- // as long as this isn't the last entry, bump this one down
- if (matchnum < matches - 1)
+ if (!skip)
+ {
+ // insert into the sorted table of matches
+ for (int matchnum = matches - 1; matchnum >= 0; matchnum--)
{
- penalty[matchnum + 1] = penalty[matchnum];
- list[matchnum + 1] = list[matchnum];
+ // stop if we're worse than the current entry
+ if (curpenalty >= penalty[matchnum])
+ break;
+
+ // as long as this isn't the last entry, bump this one down
+ if (matchnum < matches - 1)
+ {
+ penalty[matchnum + 1] = penalty[matchnum];
+ list[matchnum + 1] = list[matchnum];
+ }
+ list[matchnum] = &swinfo;
+ penalty[matchnum] = curpenalty;
}
- list[matchnum] = &swinfo;
- penalty[matchnum] = curpenalty;
}
}
}