@wwawing/loader 3.12.10 → 3.12.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/lib/core/decompressor/index.js +6 -6
- package/lib/core/extractor/checksum.js +6 -6
- package/lib/core/extractor/index.js +30 -31
- package/lib/core/index.js +30 -81
- package/lib/core/map-data-client/BaseMapDataClient.js +3 -5
- package/lib/core/map-data-client/BrowserMapDataClient.js +32 -100
- package/lib/core/map-data-client/NodeLocalMapDataClient.js +15 -74
- package/lib/core/map-data-client/index.js +3 -3
- package/lib/core/text-loader/index.js +14 -15
- package/lib/infra/index.js +58 -66
- package/lib/infra/util.js +4 -4
- package/module/core/decompressor/index.js +6 -6
- package/module/core/extractor/checksum.js +4 -4
- package/module/core/extractor/index.js +26 -28
- package/module/core/index.js +26 -78
- package/module/core/map-data-client/BaseMapDataClient.js +3 -6
- package/module/core/map-data-client/BrowserMapDataClient.js +31 -100
- package/module/core/map-data-client/NodeLocalMapDataClient.js +13 -73
- package/module/core/text-loader/index.js +13 -15
- package/module/infra/index.js +58 -68
- package/module/infra/util.js +4 -4
- package/package.json +6 -6
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TextLoader = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const infra_1 = require("../../infra");
|
|
5
|
+
class TextLoader {
|
|
6
|
+
constructor(wwaData, compressedMapData, startPosition, eventEmitter) {
|
|
7
7
|
this.wwaData = wwaData;
|
|
8
8
|
this.compressedMapData = compressedMapData;
|
|
9
9
|
this.startPosition = startPosition;
|
|
10
10
|
this.eventEmitter = eventEmitter;
|
|
11
11
|
this.OLDVER_MESSAGE_MAX = 400;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
load() {
|
|
14
|
+
const wwaData = this.wwaData;
|
|
15
15
|
this.currentPos = this.startPosition;
|
|
16
16
|
if (wwaData.version >= 30) {
|
|
17
17
|
wwaData.worldPassword = this.getMessageFromData();
|
|
@@ -20,7 +20,7 @@ var TextLoader = (function () {
|
|
|
20
20
|
wwaData.messageNum = this.OLDVER_MESSAGE_MAX;
|
|
21
21
|
}
|
|
22
22
|
wwaData.message = new Array(wwaData.messageNum);
|
|
23
|
-
for (
|
|
23
|
+
for (let i = 0; i < wwaData.message.length; i++) {
|
|
24
24
|
wwaData.message[i] = this.getMessageFromData();
|
|
25
25
|
if (i % 200 === 0) {
|
|
26
26
|
this.eventEmitter.dispatch("progress", {
|
|
@@ -61,7 +61,7 @@ var TextLoader = (function () {
|
|
|
61
61
|
wwaData.charCGName = this.getMessageFromData();
|
|
62
62
|
wwaData.mapCGName = this.getMessageFromData();
|
|
63
63
|
wwaData.systemMessage = new Array(infra_1.WWAConsts.SYSTEM_MESSAGE_NUM);
|
|
64
|
-
for (
|
|
64
|
+
for (let i = 0; i < infra_1.WWAConsts.SYSTEM_MESSAGE_NUM; i++) {
|
|
65
65
|
if (wwaData.version >= 30) {
|
|
66
66
|
wwaData.systemMessage[i] = this.getMessageFromData();
|
|
67
67
|
}
|
|
@@ -117,7 +117,7 @@ var TextLoader = (function () {
|
|
|
117
117
|
wwaData.gameSpeedIndex = infra_1.WWAConsts.DEFAULT_SPEED_INDEX;
|
|
118
118
|
wwaData.permitChangeGameSpeed = true;
|
|
119
119
|
wwaData.userVar = new Array(infra_1.WWAConsts.USER_VAR_NUM);
|
|
120
|
-
for (
|
|
120
|
+
for (let i = 0; i < infra_1.WWAConsts.USER_VAR_NUM; i++) {
|
|
121
121
|
wwaData.userVar[i] = 0;
|
|
122
122
|
}
|
|
123
123
|
wwaData.playTime = 0;
|
|
@@ -128,10 +128,10 @@ var TextLoader = (function () {
|
|
|
128
128
|
wwaData.gameOverPolicy = "default";
|
|
129
129
|
wwaData.bgmDelayDurationMs = 0;
|
|
130
130
|
return wwaData;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
}
|
|
132
|
+
getMessageFromData() {
|
|
133
|
+
let str = "";
|
|
134
|
+
let i = 0;
|
|
135
135
|
for (i = 0; i < 1500; i++) {
|
|
136
136
|
if (this.compressedMapData[this.currentPos + i * 2] == 0 &&
|
|
137
137
|
this.compressedMapData[this.currentPos + i * 2 + 1] == 0) {
|
|
@@ -142,7 +142,6 @@ var TextLoader = (function () {
|
|
|
142
142
|
}
|
|
143
143
|
this.currentPos += i * 2 + 2;
|
|
144
144
|
return str;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
}());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
148
147
|
exports.TextLoader = TextLoader;
|
package/lib/infra/index.js
CHANGED
|
@@ -1,73 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDefaultWWAData = exports.LoadStage = exports.PartsType = exports.LoaderProgress = exports.LoaderError = exports.WWAConsts = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
var LoaderError = (function () {
|
|
61
|
-
function LoaderError() {
|
|
62
|
-
}
|
|
63
|
-
return LoaderError;
|
|
64
|
-
}());
|
|
4
|
+
class WWAConsts {
|
|
5
|
+
}
|
|
6
|
+
WWAConsts.ITEMBOX_SIZE = 12;
|
|
7
|
+
WWAConsts.MAP_ATR_MAX = 60;
|
|
8
|
+
WWAConsts.OBJ_ATR_MAX = 60;
|
|
9
|
+
WWAConsts.OLD_MAP_ATR_MAX = 40;
|
|
10
|
+
WWAConsts.OLD_OBJ_ATR_MAX = 40;
|
|
11
|
+
WWAConsts.ATR_CROP1 = 1;
|
|
12
|
+
WWAConsts.ATR_CROP2 = 2;
|
|
13
|
+
WWAConsts.ATR_TYPE = 3;
|
|
14
|
+
WWAConsts.ATR_JUMP_X = 16;
|
|
15
|
+
WWAConsts.ATR_JUMP_Y = 17;
|
|
16
|
+
WWAConsts.MAP_LOCALGATE = 2;
|
|
17
|
+
WWAConsts.OBJECT_LOCALGATE = 18;
|
|
18
|
+
WWAConsts.SYSTEM_MESSAGE_NUM = 20;
|
|
19
|
+
WWAConsts.IMGPOS_DEFAULT_YESNO_X = 3;
|
|
20
|
+
WWAConsts.IMGPOS_DEFAULT_YESNO_Y = 1;
|
|
21
|
+
WWAConsts.IMGPOS_DEFAULT_PLAYER_X = 2;
|
|
22
|
+
WWAConsts.IMGPOS_DEFAULT_PLAYER_Y = 0;
|
|
23
|
+
WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_X = 0;
|
|
24
|
+
WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_Y = 0;
|
|
25
|
+
WWAConsts.IMGPOS_DEFAULT_STATUS_X = 3;
|
|
26
|
+
WWAConsts.IMGPOS_DEFAULT_STATUS_Y = 2;
|
|
27
|
+
WWAConsts.IMGRELPOS_ENERGY_ICON_X = 0;
|
|
28
|
+
WWAConsts.IMGRELPOS_STRENGTH_ICON_X = 1;
|
|
29
|
+
WWAConsts.IMGRELPOS_DEFENCE_ICON_X = 2;
|
|
30
|
+
WWAConsts.IMGRELPOS_GOLD_ICON_X = 3;
|
|
31
|
+
WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_X = 4;
|
|
32
|
+
WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_Y = 3;
|
|
33
|
+
WWAConsts.IMGPOS_DEFAULT_ITEMBOX_X = 1;
|
|
34
|
+
WWAConsts.IMGPOS_DEFAULT_ITEMBOX_Y = 2;
|
|
35
|
+
WWAConsts.IMGPOS_DEFAULT_FRAME_X = 0;
|
|
36
|
+
WWAConsts.IMGPOS_DEFAULT_FRAME_Y = 1;
|
|
37
|
+
WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_X = 3;
|
|
38
|
+
WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_Y = 3;
|
|
39
|
+
WWAConsts.DEFAULT_DISABLE_SAVE = false;
|
|
40
|
+
WWAConsts.DEFAULT_OLDMAP = false;
|
|
41
|
+
WWAConsts.DEFAULT_OBJECT_NO_COLLAPSE = false;
|
|
42
|
+
WWAConsts.DEFAULT_FRAME_COLOR_R = 0xff;
|
|
43
|
+
WWAConsts.DEFAULT_FRAME_COLOR_G = 0xff;
|
|
44
|
+
WWAConsts.DEFAULT_FRAME_COLOR_B = 0xff;
|
|
45
|
+
WWAConsts.DEFAULT_FRAMEOUT_COLOR_R = 0x60;
|
|
46
|
+
WWAConsts.DEFAULT_FRAMEOUT_COLOR_G = 0x60;
|
|
47
|
+
WWAConsts.DEFAULT_FRAMEOUT_COLOR_B = 0x60;
|
|
48
|
+
WWAConsts.DEFAULT_STR_COLOR_R = 0x0;
|
|
49
|
+
WWAConsts.DEFAULT_STR_COLOR_G = 0x0;
|
|
50
|
+
WWAConsts.DEFAULT_STR_COLOR_B = 0x0;
|
|
51
|
+
WWAConsts.DEFAULT_STATUS_COLOR_R = 0x0;
|
|
52
|
+
WWAConsts.DEFAULT_STATUS_COLOR_G = 0x0;
|
|
53
|
+
WWAConsts.DEFAULT_STATUS_COLOR_B = 0x0;
|
|
54
|
+
WWAConsts.DEFAULT_MOVES = 0;
|
|
55
|
+
WWAConsts.DEFAULT_SPEED_INDEX = 3;
|
|
56
|
+
WWAConsts.USER_VAR_NUM = 256;
|
|
57
|
+
exports.WWAConsts = WWAConsts;
|
|
58
|
+
class LoaderError {
|
|
59
|
+
}
|
|
65
60
|
exports.LoaderError = LoaderError;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
return LoaderProgress;
|
|
70
|
-
}());
|
|
61
|
+
class LoaderProgress {
|
|
62
|
+
}
|
|
71
63
|
exports.LoaderProgress = LoaderProgress;
|
|
72
64
|
var PartsType;
|
|
73
65
|
(function (PartsType) {
|
package/lib/infra/util.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.signedByte = exports.new2DArray = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (
|
|
4
|
+
const new2DArray = (size1, size2) => {
|
|
5
|
+
const arr = new Array(size1);
|
|
6
|
+
for (let i = 0; i < arr.length; i++) {
|
|
7
7
|
arr[i] = new Array(size2);
|
|
8
8
|
}
|
|
9
9
|
return arr;
|
|
10
10
|
};
|
|
11
11
|
exports.new2DArray = new2DArray;
|
|
12
|
-
|
|
12
|
+
const signedByte = (b) => {
|
|
13
13
|
b = b % 0x100;
|
|
14
14
|
return b >= 0x80 ? b - 0x100 : b;
|
|
15
15
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const MEM_BLOCK = 65000;
|
|
2
|
+
const EXT_LAST_PADDING = 3;
|
|
3
3
|
export function decompressMapData(srcData) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
let destData = new Uint8Array(srcData.length);
|
|
5
|
+
let srcCounter, destCounter;
|
|
6
6
|
for (srcCounter = 0, destCounter = 0; srcCounter < srcData.length; srcCounter++) {
|
|
7
7
|
if (srcData[srcCounter] === 0 &&
|
|
8
8
|
srcData[srcCounter + 1] === 0 &&
|
|
@@ -11,8 +11,8 @@ export function decompressMapData(srcData) {
|
|
|
11
11
|
}
|
|
12
12
|
destData[destCounter++] = srcData[srcCounter];
|
|
13
13
|
if (srcData[srcCounter] === srcData[srcCounter + 1]) {
|
|
14
|
-
|
|
15
|
-
for (
|
|
14
|
+
const maxim = srcData[srcCounter + 2];
|
|
15
|
+
for (let i = 0; i < maxim; i++) {
|
|
16
16
|
destData[destCounter++] = srcData[srcCounter];
|
|
17
17
|
}
|
|
18
18
|
srcCounter += 2;
|
|
@@ -4,9 +4,9 @@ function calculateCorrectCheckSum(mapData) {
|
|
|
4
4
|
return mapData[BytePosition.CHECK] + mapData[BytePosition.CHECK + 1] * 0x100;
|
|
5
5
|
}
|
|
6
6
|
function calculateByteSum(mapData, dataLength) {
|
|
7
|
-
|
|
7
|
+
let sum = 0;
|
|
8
8
|
if (mapData[BytePosition.VERSION] >= 29) {
|
|
9
|
-
for (
|
|
9
|
+
for (let i = 2; i < dataLength; i++) {
|
|
10
10
|
sum += signedByte(mapData[i]) * (i % 8 + 1);
|
|
11
11
|
}
|
|
12
12
|
sum = (sum % 0x10000) & 0xffff;
|
|
@@ -14,8 +14,8 @@ function calculateByteSum(mapData, dataLength) {
|
|
|
14
14
|
return sum;
|
|
15
15
|
}
|
|
16
16
|
export function checkMapDataBroken(mapData, dataLength) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const correctCheckSum = calculateCorrectCheckSum(mapData);
|
|
18
|
+
const sum = calculateByteSum(mapData, dataLength);
|
|
19
19
|
if (correctCheckSum !== sum) {
|
|
20
20
|
throw new Error("マップデータが壊れているようです。\n チェックサムの値は" +
|
|
21
21
|
correctCheckSum +
|
|
@@ -2,14 +2,14 @@ import { new2DArray } from "../../infra/util";
|
|
|
2
2
|
import { checkMapDataBroken } from "./checksum";
|
|
3
3
|
import { BytePosition } from "./constants";
|
|
4
4
|
import { WWAConsts, PartsType, LoadStage, createDefaultWWAData } from "../../infra";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export class WWADataExtractor {
|
|
6
|
+
constructor(byteMapData, byteMapLength, eventEmitter) {
|
|
7
7
|
this.byteMapData = byteMapData;
|
|
8
8
|
this.eventEmitter = eventEmitter;
|
|
9
9
|
checkMapDataBroken(byteMapData, byteMapLength);
|
|
10
10
|
this.wwaData = createDefaultWWAData();
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
extractAllData() {
|
|
13
13
|
var mapAttrMax, objAttrMax;
|
|
14
14
|
this.wwaData.version = this.byteMapData[BytePosition.VERSION];
|
|
15
15
|
this._extractInitialParameters();
|
|
@@ -31,8 +31,8 @@ var WWADataExtractor = (function () {
|
|
|
31
31
|
}
|
|
32
32
|
this._replaceAllRandomObjects();
|
|
33
33
|
return this.wwaData;
|
|
34
|
-
}
|
|
35
|
-
|
|
34
|
+
}
|
|
35
|
+
_convertAttributeV2toV3(partsType) {
|
|
36
36
|
var partsMax;
|
|
37
37
|
var attributeArray;
|
|
38
38
|
var localGateIndex;
|
|
@@ -81,14 +81,14 @@ var WWADataExtractor = (function () {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
84
|
+
}
|
|
85
|
+
_get1ByteNumber(index) {
|
|
86
86
|
return this.byteMapData[index];
|
|
87
|
-
}
|
|
88
|
-
|
|
87
|
+
}
|
|
88
|
+
_get2BytesNumber(index) {
|
|
89
89
|
return this.byteMapData[index] + this.byteMapData[index + 1] * 0x100;
|
|
90
|
-
}
|
|
91
|
-
|
|
90
|
+
}
|
|
91
|
+
_extractInitialParameters() {
|
|
92
92
|
if (this.wwaData.version > 29) {
|
|
93
93
|
this.wwaData.gameoverX = this._get2BytesNumber(BytePosition.GAMEOVER_X);
|
|
94
94
|
this.wwaData.gameoverY = this._get2BytesNumber(BytePosition.GAMEOVER_Y);
|
|
@@ -119,15 +119,15 @@ var WWADataExtractor = (function () {
|
|
|
119
119
|
this.wwaData.mapWidth = 71;
|
|
120
120
|
else if (this.wwaData.version <= 29)
|
|
121
121
|
this.wwaData.mapWidth = 101;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
}
|
|
123
|
+
_extractInitialItemData() {
|
|
124
|
+
const topIdx = this.wwaData.version > 29 ? BytePosition.ITEMBOX_TOP : BytePosition.OLD_ITEMBOX_TOP;
|
|
125
125
|
this.wwaData.itemBox = new Array(WWAConsts.ITEMBOX_SIZE);
|
|
126
|
-
for (
|
|
126
|
+
for (let i = 0; i < WWAConsts.ITEMBOX_SIZE; i++) {
|
|
127
127
|
this.wwaData.itemBox[i] = this._get1ByteNumber(topIdx + i);
|
|
128
128
|
}
|
|
129
|
-
}
|
|
130
|
-
|
|
129
|
+
}
|
|
130
|
+
_getFieldDataFromBits(partsType, partsMax) {
|
|
131
131
|
var x, y;
|
|
132
132
|
var fieldArray;
|
|
133
133
|
fieldArray = new2DArray(this.wwaData.mapWidth, this.wwaData.mapWidth);
|
|
@@ -151,8 +151,8 @@ var WWADataExtractor = (function () {
|
|
|
151
151
|
}
|
|
152
152
|
this.emitProgress(this.wwaData.mapWidth * this.wwaData.mapWidth, this.wwaData.mapWidth * this.wwaData.mapWidth, partsType === PartsType.MAP ? LoadStage.MAP_LOAD : LoadStage.OBJ_LOAD);
|
|
153
153
|
return fieldArray;
|
|
154
|
-
}
|
|
155
|
-
|
|
154
|
+
}
|
|
155
|
+
_getPartsDataFromBits(partsType, partsMax, attrMax) {
|
|
156
156
|
var i, j;
|
|
157
157
|
var partsData;
|
|
158
158
|
partsData = new2DArray(partsMax, attrMax);
|
|
@@ -172,13 +172,11 @@ var WWADataExtractor = (function () {
|
|
|
172
172
|
}
|
|
173
173
|
this.emitProgress(partsMax * attrMax, partsMax * attrMax, partsType === PartsType.MAP ? LoadStage.MAP_ATTR : LoadStage.OBJ_ATTR);
|
|
174
174
|
return partsData;
|
|
175
|
-
}
|
|
176
|
-
|
|
175
|
+
}
|
|
176
|
+
_replaceAllRandomObjects() {
|
|
177
177
|
this.emitProgress(this.wwaData.mapWidth * this.wwaData.mapWidth, this.wwaData.mapWidth * this.wwaData.mapWidth, LoadStage.RAND_PARTS);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
this.eventEmitter.dispatch("progress", { current
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
}());
|
|
184
|
-
export { WWADataExtractor };
|
|
178
|
+
}
|
|
179
|
+
emitProgress(current, total, stage) {
|
|
180
|
+
this.eventEmitter.dispatch("progress", { current, total, stage });
|
|
181
|
+
}
|
|
182
|
+
}
|
package/module/core/index.js
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
1
|
import { WWADataExtractor } from "./extractor";
|
|
38
2
|
import { decompressMapData } from "./decompressor";
|
|
39
3
|
import { TextLoader } from "./text-loader";
|
|
40
4
|
import { BrowserMapDataClient, NodeLocalMapDataClient } from "./map-data-client";
|
|
41
|
-
|
|
5
|
+
const createMapDataClient = (fileName) => {
|
|
42
6
|
if (typeof window !== "undefined") {
|
|
43
7
|
return new BrowserMapDataClient(fileName);
|
|
44
8
|
}
|
|
@@ -46,53 +10,37 @@ var createMapDataClient = function (fileName) {
|
|
|
46
10
|
return new NodeLocalMapDataClient(fileName);
|
|
47
11
|
}
|
|
48
12
|
};
|
|
49
|
-
|
|
50
|
-
|
|
13
|
+
export class WWALoader {
|
|
14
|
+
constructor(fileName, eventEmitter) {
|
|
51
15
|
this.fileName = fileName;
|
|
52
16
|
this.eventEmitter = eventEmitter;
|
|
53
17
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.eventEmitter.dispatch("mapData", wwaData);
|
|
73
|
-
return [3, 4];
|
|
74
|
-
case 3:
|
|
75
|
-
error_1 = _a.sent();
|
|
76
|
-
name_1 = error_1.name || "";
|
|
77
|
-
message = error_1.message || "";
|
|
78
|
-
this.eventEmitter.dispatch("error", { name: name_1, message: message });
|
|
79
|
-
return [3, 4];
|
|
80
|
-
case 4: return [2];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
WWALoader.prototype.loadMapData = function (data) {
|
|
18
|
+
async requestAndLoadMapData() {
|
|
19
|
+
const client = createMapDataClient(this.fileName);
|
|
20
|
+
try {
|
|
21
|
+
const responseBuffer = await client.request();
|
|
22
|
+
if (!responseBuffer) {
|
|
23
|
+
this.eventEmitter.dispatch("error", { name: "マップデータ取得に失敗しました", message: "mapdata is empty" });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const wwaData = this.loadMapData(responseBuffer);
|
|
27
|
+
this.eventEmitter.dispatch("mapData", wwaData);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const name = error.name || "";
|
|
31
|
+
const message = error.message || "";
|
|
32
|
+
this.eventEmitter.dispatch("error", { name, message });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
loadMapData(data) {
|
|
86
36
|
try {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
37
|
+
const compressedByteMapData = new Uint8Array(data);
|
|
38
|
+
const { byteMapData, byteMapLength, compressedEndPosition } = decompressMapData(compressedByteMapData);
|
|
39
|
+
const wwaData = new WWADataExtractor(byteMapData, byteMapLength, this.eventEmitter).extractAllData();
|
|
90
40
|
return new TextLoader(wwaData, compressedByteMapData, compressedEndPosition, this.eventEmitter).load();
|
|
91
41
|
}
|
|
92
42
|
catch (e) {
|
|
93
43
|
throw e;
|
|
94
44
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}());
|
|
98
|
-
export { WWALoader };
|
|
45
|
+
}
|
|
46
|
+
}
|