Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds checksumSha1 of map to parser output #70

Merged
merged 1 commit into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/W3GReplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ export default class W3GReplay extends EventEmitter {
path: this.meta.map.mapName,
file: convert.mapFilename(this.meta.map.mapName),
checksum: this.meta.map.mapChecksum,
checksumSha1: this.meta.map.mapChecksumSha1,
},
version: convert.gameVersion(this.info.subheader.version),
buildNumber: this.info.subheader.buildNo,
Expand Down
4 changes: 4 additions & 0 deletions src/parsers/MetadataParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type MapMetadata = {
randomRaces: boolean;
referees: boolean;
mapChecksum: string;
mapChecksumSha1: string;
mapName: string;
creator: string;
};
Expand Down Expand Up @@ -177,6 +178,8 @@ export default class MetadataParser extends StatefulBufferParser {
parser.skip(0);
const mapName = parser.readZeroTermString("utf-8");
const creator = parser.readZeroTermString("utf-8");
parser.skip(1);
const checksumSha1 = parser.readStringOfLength(20, "hex");
return {
speed,
hideTerrain: !!(secondByte & 0b00000001),
Expand All @@ -193,6 +196,7 @@ export default class MetadataParser extends StatefulBufferParser {
mapName: mapName,
creator: creator,
mapChecksum: checksum,
mapChecksumSha1: checksumSha1,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface ParserOutput {
path: string;
file: string;
checksum: string;
checksumSha1: string;
};
buildNumber: number;
version: string;
Expand Down
2 changes: 2 additions & 0 deletions test/replays/126/replays.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ it("parses a 2on2standard 1.29 replay properly", async () => {
expect(test.players.length).toBe(4);
expect(test.map).toEqual({
checksum: "b4230d1e",
checksumSha1: "1f75e2a24fd995a6d7b123bb44d8afae7b5c6222",
file: "w3arena__maelstrom__v2.w3x",
path: "Maps\\w3arena\\w3arena__maelstrom__v2.w3x",
});
Expand All @@ -43,6 +44,7 @@ it("parses a standard 1.26 replay properly", async () => {
expect(test.players.length).toBe(2);
expect(test.map).toEqual({
checksum: "51a1c63b",
checksumSha1: "0b4f05ca7dcc23b9501422b4fa26a86c7d2a0ee0",
file: "w3arena__amazonia__v3.w3x",
path: "Maps\\w3arena\\w3arena__amazonia__v3.w3x",
});
Expand Down
2 changes: 2 additions & 0 deletions test/replays/129/replays.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ it("parses a netease 1.29 replay properly", async () => {
expect(test.players.length).toBe(2);
expect(test.map).toEqual({
checksum: "281f9d6a",
checksumSha1: "c232d68286eb4604cc66db42d45e28017b78e3c4",
file: "(4)TurtleRock.w3x",
path: "Maps/1.29\\(4)TurtleRock.w3x",
});
Expand Down Expand Up @@ -89,6 +90,7 @@ it("parses a standard 1.29 replay with observers properly", async () => {
expect(test.parseTime).toBe(Math.round(test.parseTime));
expect(test.map).toEqual({
checksum: "008ab7f1",
checksumSha1: "79ba7579f28e5ccfd741a1ebfbff95a56813086e",
file: "w3arena__twistedmeadows__v3.w3x",
path: "Maps\\w3arena\\w3arena__twistedmeadows__v3.w3x",
});
Expand Down
1 change: 1 addition & 0 deletions test/replays/130/replays.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ it("parses a standard 1.30 replay properly", async () => {
expect(test.map).toEqual({
file: "(4)TwistedMeadows.w3x",
checksum: "c3cae01d",
checksumSha1: "23dc614cca6fd7ec232fbba4898d318a90b95bc6",
path: "Maps\\FrozenThrone\\(4)TwistedMeadows.w3x",
});
});
Expand Down
22 changes: 21 additions & 1 deletion test/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,26 @@
"(4)TwistedMeadows.w3x"
],
"pattern": "^(.*)$"
},
"checksum": {
"$id": "#/properties/map/properties/checksum",
"type": "string",
"title": "The Checksum Schema",
"default": "",
"examples": [
"b4230d1e"
],
"pattern": "^(.*)$"
},
"checksumSha1": {
"$id": "#/properties/map/properties/checksumSha1",
"type": "string",
"title": "The ChecksumSha1 Schema",
"default": "",
"examples": [
"1f75e2a24fd995a6d7b123bb44d8afae7b5c6222"
],
"pattern": "^(.*)$"
}
}
},
Expand Down Expand Up @@ -772,4 +792,4 @@
}
}
}
}
}