Skip to content

Commit

Permalink
Feature: detect "cracked" games, treat as non-retail (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Apr 7, 2024
1 parent ec43210 commit 3b6579b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
8 changes: 8 additions & 0 deletions docs/roms/filtering-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ Enables all the following `--no-*` options, as well as filtering out games that
Sword (Alpha) (PD) [C]
```

- **Cracked**: games that contain `[cr]` or `[cr *]` in their name, e.g.:

```text
Jet Set Willy (1984)(Software Projects)[cr]
Buck Rogers - Countdown to Doomsday v1.0 (1991)(SSI)(Disk 1 of 3)[cr2][FD installed]
Dungeon Master (1987)(FTL)[cr 42-Crew]
```

- **Fixed**: games that contain `[f]` or `[f#]` in their name, e.g.:

```text
Expand Down
2 changes: 1 addition & 1 deletion src/modules/datParentInferrer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default class DATParentInferrer extends Module {
.replace(/\(M[0-9]+\)/, '') // language
.replace(/\((CW|CW-R|FW|GW|GW-R|LW|PD|SW|SW-R)\)/i, '') // copyright
.replace(/\((alpha|beta|preview|pre-release|proto)\)/i, '') // development
.replace(/(\[(cr|f|h|m|p|t|tr|o|u|v|b|a|!)( [a-z0-9.+ -]+)?\])+/i, '')
.replace(/(\[(cr|f|h|m|p|t|tr|o|u|v|b|a|!)([0-9]+| [^\]]+)?\])+/i, '')
// ***** Console-specific *****
// Nintendo - Game Boy
.replace(/\(SGB Enhanced\)/i, '')
Expand Down
19 changes: 15 additions & 4 deletions src/types/dats/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum GameType {
BAD = 'Bad',
BETA = 'Beta',
BIOS = 'BIOS',
CRACKED = 'Cracked',
DEBUG = 'Debug',
DEMO = 'Demo',
DEVICE = 'Device',
Expand Down Expand Up @@ -262,8 +263,8 @@ export default class Game implements GameProps {
// Sometimes [!] can get mixed with [c], consider it not bad
return false;
}
return this.name.match(/\[c\]/) !== null // "known bad checksum but good dump"
|| this.name.match(/\[x\]/) !== null; // "thought to have a bad checksum"
return this.name.includes('[c]') // "known bad checksum but good dump"
|| this.name.includes('[x]'); // "thought to have a bad checksum"
}

/**
Expand All @@ -273,6 +274,13 @@ export default class Game implements GameProps {
return this.name.match(/\(Beta[a-z0-9. ]*\)/i) !== null;
}

/**
* Is this game a "cracked" release (has copy protection removed)?
*/
isCracked(): boolean {
return this.name.match(/\[cr([0-9]+| [^\]]+)?\]/) !== null;
}

/**
* Does this game contain debug symbols?
*/
Expand Down Expand Up @@ -337,7 +345,7 @@ export default class Game implements GameProps {
* Is this game a pending dump (works, but isn't a proper dump)?
*/
isPendingDump(): boolean {
return this.name.match(/\[!p\]/) !== null;
return this.name.includes('[!p]');
}

/**
Expand Down Expand Up @@ -389,7 +397,7 @@ export default class Game implements GameProps {
* Is this game an explicitly verified dump?
*/
isVerified(): boolean {
return this.name.match(/\[!\]/) !== null;
return this.name.includes('[!]');
}

/**
Expand Down Expand Up @@ -423,6 +431,7 @@ export default class Game implements GameProps {
&& !this.isAlpha()
&& !this.isBad()
&& !this.isBeta()
&& !this.isCracked()
&& !this.isDebug()
&& !this.isDemo()
&& !this.isFixed()
Expand Down Expand Up @@ -456,6 +465,8 @@ export default class Game implements GameProps {
return GameType.BAD;
} if (this.isBeta()) {
return GameType.BETA;
} if (this.isCracked()) {
return GameType.CRACKED;
} if (this.isDebug()) {
return GameType.DEBUG;
} if (this.isDemo()) {
Expand Down
13 changes: 13 additions & 0 deletions test/types/dats/game.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ describe('isBeta', () => {
});
});

describe('isCracked', () => {
test.each([
['Grand Prix 500 2 (1990)(Microids)(FR)(Disk 1 of 2)[cr]', true],
['Buck Rogers - Countdown to Doomsday v1.0 (1991)(SSI)(Disk 1 of 3)[cr2][FD installed]', true],
['Dungeon Master (1987)(FTL)[cr 42-Crew]', true],
['221B Baker Street (1986)(Datasoft)(Side B)[cr Digital Gang]', true],
['221B Baker Street (1986)(Datasoft)(Side B)', false],
])('%s', (name, expected) => {
expect(new Game({ name }).isCracked()).toEqual(expected);
expect(new Game({ name }).isRetail()).toEqual(!expected);
});
});

describe('isDemo', () => {
test.each([
// No-Intro
Expand Down

0 comments on commit 3b6579b

Please sign in to comment.