Skip to content

Commit

Permalink
Tweak 0.4.x EMF detection for the new 0.4.5 format
Browse files Browse the repository at this point in the history
  • Loading branch information
Cirras committed Sep 3, 2023
1 parent e5f0184 commit 8e305b5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/core/data/emf.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,22 +564,22 @@ export class EMF {
// Many classic EMFs in the wild have been observed to have out-of-bounds values,
// presumably due to broken serializers in early EO community developer tools.
reader.seek(0x1f);
const type = reader.getChar();
const type = reader.getByte() - 1;
if (type > MapType.PK) {
score += 0.2;
}

// In the classic format, 0x20 is the `effect` char field.
// An out-of-bounds value indicates this is a byte in a 0.4.x map name.
const effect = reader.getChar();
const effect = reader.getByte() - 1;
if (effect > MapEffect.Quake4) {
score += 0.4;
}

// In the classic format, 0x22 is the `musicControl` char field.
// An out-of-bounds value indicates this is a byte in a 0.4.x map name.
reader.seek(0x22);
const musicControlField = reader.getChar();
const musicControlField = reader.getByte() - 1;
if (musicControlField > MusicControl.InterruptPlayNothing) {
score += 0.4;
}
Expand All @@ -606,8 +606,6 @@ export class EMF {
}

// In the classic format, 0x2d is a char field which is always zero.
// Any other value indicates this is the second byte of a 0.4.x short
// field.
//
// Some classic EMFs in the wild have been observed to have non-standard (char) values,
// presumably due to broken serializers in early EO community developer tools.
Expand Down

0 comments on commit 8e305b5

Please sign in to comment.