-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
28 lines (21 loc) · 770 Bytes
/
app.js
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
'use strict';
const defaultFileName = 'Tibia.dat';
const ProtoBuf = require('protobufjs'),
fs = require('fs'),
argv = require('minimist')(process.argv.slice(2),
{ alias: { 'file': 'f' },
default: { 'file': defaultFileName } });
const ProtoDatFile = ProtoBuf.loadProtoFile('./dat.proto').build('DatFile');
console.log(`>> Loading ${argv.file}..`);
fs.readFile(`./${argv.file}`, (err, content) => {
if (err) {
console.log(`>> Error: Unable to load ${argv.file}..`)
return;
}
console.log(`>> Decoding ${argv.file}..`);
const data = ProtoDatFile.decode(content, content.length);
for (const object of data.objects) {
if (object.attributes.marketData !== null)
console.log(object.clientID, object.attributes.marketData.name);
}
});