-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPOR_DatabaseDecoder.js
More file actions
38 lines (35 loc) · 1.24 KB
/
POR_DatabaseDecoder.js
File metadata and controls
38 lines (35 loc) · 1.24 KB
1
2
3
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
//=============================================================================
// POR_Database Decoder
//=============================================================================
/*:
* @plugindesc Reads files compressed by POR_DatabaseEncoder
* @author Poryg
*
* @help
* Plugin used as a way to decode database files inside database encoder.
*/
function decodeDataFile(databaseFile) {
return LZString.decompressFromBase64(databaseFile);
}
POR_DatabaseCompressor_DataManager_loadDataFile = DataManager.loadDataFile;
DataManager.loadDataFile = function(name, src) {
if (Utils.isOptionValid("test")) {
POR_DatabaseCompressor_DataManager_loadDataFile.call(this, name, src);
return;
}
var xhr = new XMLHttpRequest();
var url = 'data/' + src + 'o';
xhr.open('GET', url);
xhr.onload = function() {
if (xhr.status < 400) {
var LZDecompressed = decodeDataFile(xhr.responseText);
window[name] = JSON.parse(LZDecompressed);
DataManager.onLoad(window[name]);
}
};
xhr.onerror = this._mapLoader || function() {
DataManager._errorUrl = DataManager._errorUrl || url;
};
window[name] = null;
xhr.send();
};