Skip to content

Commit

Permalink
add map info
Browse files Browse the repository at this point in the history
  • Loading branch information
h3902340 committed Dec 4, 2023
1 parent 2bb1091 commit 623ec3e
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 8 deletions.
9 changes: 9 additions & 0 deletions dist/index.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface GameSetting {
gameType: number;
mapCRC: number;
mapName: string;
mapInfo: MapInfo;
mapSet: string;
freeForAll: boolean;
hostTime: number;
Expand Down Expand Up @@ -73,6 +74,14 @@ interface Message {
message: string;
time: number;
}
interface MapInfo {
id: number;
idStr: string;
displayNameID: string;
details: string;
imagepath: string;
isLarge?: boolean;
}

declare function parseChat(fileArrayBuffer: ArrayBuffer): Message[];

Expand Down
9 changes: 9 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface GameSetting {
gameType: number;
mapCRC: number;
mapName: string;
mapInfo: MapInfo;
mapSet: string;
freeForAll: boolean;
hostTime: number;
Expand Down Expand Up @@ -73,6 +74,14 @@ interface Message {
message: string;
time: number;
}
interface MapInfo {
id: number;
idStr: string;
displayNameID: string;
details: string;
imagepath: string;
isLarge?: boolean;
}

declare function parseChat(fileArrayBuffer: ArrayBuffer): Message[];

Expand Down
8 changes: 7 additions & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion dist/index.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "jest"
},
"name": "@canyougiant/aoe3de-replay-parser",
"version": "1.4.0",
"version": "1.5.0",
"description": "Parsing Age3Yrec file of AOE3DE",
"repository": {
"type": "git",
Expand Down
10 changes: 10 additions & 0 deletions src/dataStructures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface GameSetting {
gameType: number,
mapCRC: number,
mapName: string,
mapInfo: MapInfo,
mapSet: string,
freeForAll: boolean,
hostTime: number, // ?
Expand Down Expand Up @@ -70,4 +71,13 @@ export interface Message {
toId: number,
message: string,
time: number,
}

export interface MapInfo {
id: number;
idStr: string;
displayNameID: string;
details: string;
imagepath: string;
isLarge?: boolean;
}
1 change: 1 addition & 0 deletions src/maps.json

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/parseReplay.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { inflateRaw } from "pako";
import { Civ, civMap, civToInfo, headerLength } from "./constant";
import { Replay, GameSetting, Player, Deck, Team } from "./dataStructures";
import { Replay, GameSetting, Player, Deck, Team, MapInfo } from "./dataStructures";
import { parseDeck } from "./parseDeck";
import { parseField } from "./parseField";
import { parseTeam } from "./parseTeam";
import { readInt32, readString } from "./util";
import mapJson from './maps.json';

let mapInfos: { [k: string]: MapInfo } = mapJson;
export function parseReplay(fileArrayBuffer: ArrayBuffer): Replay {
let uint8Ary: Uint8Array = inflateRaw(fileArrayBuffer.slice(headerLength));
let dataView: DataView = new DataView(uint8Ary.buffer);
Expand All @@ -14,6 +16,7 @@ export function parseReplay(fileArrayBuffer: ArrayBuffer): Replay {
const exeInfo = readString(dataView, position, stringLength);
let version: number = Number(exeInfo.split(' ')[1]);
let dictionary = parseField(dataView);
let mapName: string = dictionary['gamefilename'];
let gameSetting: GameSetting = {
gameName: dictionary['gamename'],
allowCheats: dictionary['gameallowcheats'],
Expand All @@ -26,7 +29,8 @@ export function parseReplay(fileArrayBuffer: ArrayBuffer): Replay {
allowTradeMonopoly: dictionary['gametrademonopoly'],
gameType: dictionary['gametype'],
mapCRC: dictionary['gamefilecrc'],
mapName: dictionary['gamefilename'],
mapName: mapName,
mapInfo: mapInfos[mapName.toLocaleLowerCase()],
mapSet: dictionary['gamefilenameext'],
freeForAll: dictionary['gamefreeforall'],
hostTime: dictionary['gamehosttime'],
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
"resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

Expand Down

0 comments on commit 623ec3e

Please sign in to comment.