mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-18 09:40:38 +01:00
Improve dayz mod parsing with more random reverse engineering guesses
This commit is contained in:
parent
685a955233
commit
b11eac277d
2 changed files with 28 additions and 10 deletions
|
@ -28,6 +28,10 @@ class Reader {
|
||||||
this.i = 0;
|
this.i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setOffset(offset) {
|
||||||
|
this.i = offset;
|
||||||
|
}
|
||||||
|
|
||||||
offset() {
|
offset() {
|
||||||
return this.i;
|
return this.i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const Bzip2 = require('compressjs').Bzip2,
|
const Bzip2 = require('compressjs').Bzip2;
|
||||||
Core = require('./core'),
|
const Core = require('./core');
|
||||||
Results = require('../lib/Results');
|
const Results = require('../lib/Results');
|
||||||
|
const Reader = require('../lib/reader');
|
||||||
|
|
||||||
const AppId = {
|
const AppId = {
|
||||||
Squad: 393380,
|
Squad: 393380,
|
||||||
|
@ -318,26 +319,39 @@ class Valve extends Core {
|
||||||
this.logger.debug("overflow " + overflow);
|
this.logger.debug("overflow " + overflow);
|
||||||
this.logger.debug("dlc1 " + dlc1);
|
this.logger.debug("dlc1 " + dlc1);
|
||||||
this.logger.debug("dlc2 " + dlc2);
|
this.logger.debug("dlc2 " + dlc2);
|
||||||
|
if (dlc1) {
|
||||||
|
const unknown = this.readDayzUint(reader, 4); // ?
|
||||||
|
this.logger.debug("unknown " + unknown);
|
||||||
|
}
|
||||||
|
if (dlc2) {
|
||||||
|
const unknown = this.readDayzUint(reader, 4); // ?
|
||||||
|
this.logger.debug("unknown " + unknown);
|
||||||
|
}
|
||||||
const mods = [];
|
const mods = [];
|
||||||
mods.push(...this.readDayzModsSection(reader, true));
|
mods.push(...this.readDayzModsSection(reader, true));
|
||||||
mods.push(...this.readDayzModsSection(reader, false));
|
mods.push(...this.readDayzModsSection(reader, false));
|
||||||
|
this.logger.debug("dayz buffer rest:", reader.rest());
|
||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
readDayzModsSection(reader, withHeader) {
|
readDayzModsSection(/** Reader */ reader, withHeader) {
|
||||||
const out = [];
|
const out = [];
|
||||||
const count = this.readDayzByte(reader);
|
const count = this.readDayzByte(reader);
|
||||||
|
this.logger.debug("dayz mod section withHeader:" + withHeader + " count:" + count);
|
||||||
for(let i = 0; i < count; i++) {
|
for(let i = 0; i < count; i++) {
|
||||||
|
if (reader.done()) break;
|
||||||
const mod = {};
|
const mod = {};
|
||||||
if (withHeader) {
|
if (withHeader) {
|
||||||
const unknown = this.readDayzUint(reader, 4); // mod hash?
|
mod.unknown = this.readDayzUint(reader, 4); // ?
|
||||||
if (i !== count - 1) {
|
|
||||||
// For some reason this is 4 on all of them, but doesn't exist on the last one?
|
// For some reason this is 4 on all of them, but doesn't exist on the last one? but only sometimes?
|
||||||
const flag = this.readDayzByte(reader);
|
const offset = reader.offset();
|
||||||
//mod.flag = flag;
|
const flag = this.readDayzByte(reader);
|
||||||
}
|
if (flag !== 4) reader.setOffset(offset);
|
||||||
|
|
||||||
mod.workshopId = this.readDayzUint(reader, 4);
|
mod.workshopId = this.readDayzUint(reader, 4);
|
||||||
}
|
}
|
||||||
mod.title = this.readDayzString(reader);
|
mod.title = this.readDayzString(reader);
|
||||||
|
this.logger.debug(mod);
|
||||||
out.push(mod);
|
out.push(mod);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|
Loading…
Reference in a new issue