mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 00:54:14 +02:00
good user info
This commit is contained in:
parent
7402548783
commit
9a297a2a9c
4 changed files with 34 additions and 17 deletions
|
|
@ -7,7 +7,7 @@ var DataTable = function (type, tick, stream, length) {
|
||||||
|
|
||||||
DataTable.prototype.parse = function () {
|
DataTable.prototype.parse = function () {
|
||||||
//while (this.stream.byteIndex < this.length) {
|
//while (this.stream.byteIndex < this.length) {
|
||||||
//console.log(this.stream.readASCIIString());
|
// console.log(this.stream.readASCIIString());
|
||||||
//}
|
//}
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,14 @@ Parser.prototype.parseBody = function () {
|
||||||
if (packet.tables.userinfo) {
|
if (packet.tables.userinfo) {
|
||||||
for (var j = 0; j < packet.tables.userinfo.length; j++) {
|
for (var j = 0; j < packet.tables.userinfo.length; j++) {
|
||||||
if (packet.tables.userinfo[j].extraData) {
|
if (packet.tables.userinfo[j].extraData) {
|
||||||
this.state.users[packet.tables.userinfo[j].text] = packet.tables.userinfo[j].extraData
|
var name = packet.tables.userinfo[j].extraData[0];
|
||||||
|
var steamId = packet.tables.userinfo[j].extraData[2];
|
||||||
|
var userId = packet.tables.userinfo[j].extraData[1].charCodeAt(0);
|
||||||
|
this.state.users[userId] = {
|
||||||
|
name : name,
|
||||||
|
userId: userId,
|
||||||
|
steamId: steamId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,7 @@ StringTable.prototype.parse = function () {
|
||||||
};
|
};
|
||||||
if (this.stream.readBits(1)) {
|
if (this.stream.readBits(1)) {
|
||||||
extraDataLength = this.stream.readBits(16);
|
extraDataLength = this.stream.readBits(16);
|
||||||
//if (tableName === 'userinfo') {
|
entry.extraData = this.readExtraData(extraDataLength);
|
||||||
// entry.extraData = this.parsePlayerInfo(extraDataLength);
|
|
||||||
//} else {
|
|
||||||
entry.extraData = this.stream.readUTF8String(extraDataLength);
|
|
||||||
//}
|
|
||||||
//console.log(entry.extraData.length-extraDataLength);
|
|
||||||
}
|
}
|
||||||
entries.push(entry);
|
entries.push(entry);
|
||||||
}
|
}
|
||||||
|
|
@ -56,16 +51,31 @@ StringTable.prototype.parsePlayerInfo = function (length) {
|
||||||
var name = this.stream.readUTF8String(128);
|
var name = this.stream.readUTF8String(128);
|
||||||
console.log(length);
|
console.log(length);
|
||||||
//if (name === 'Icewind') {
|
//if (name === 'Icewind') {
|
||||||
console.log(name);
|
console.log(name);
|
||||||
var userId = this.stream.readBits(32);
|
var userId = this.stream.readBits(32);
|
||||||
console.log(userId);
|
console.log(userId);
|
||||||
var guid = this.stream.readASCIIString(33);
|
var guid = this.stream.readASCIIString(33);
|
||||||
console.log('guid: ' + guid);
|
console.log('guid: ' + guid);
|
||||||
//console.log(this.stream.readASCIIString(33));
|
//console.log(this.stream.readASCIIString(33));
|
||||||
//console.log(this.stream.readASCIIString());
|
//console.log(this.stream.readASCIIString());
|
||||||
//throw false;
|
//throw false;
|
||||||
//}
|
//}
|
||||||
this.stream._index = pos + (length * 8);
|
this.stream._index = pos + (length * 8);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringTable.prototype.readExtraData = function (length) {
|
||||||
|
var end = this.stream._index + (length * 8);
|
||||||
|
var data = [];
|
||||||
|
//console.log(this.stream.readUTF8String());
|
||||||
|
data.push(this.stream.readUTF8String());
|
||||||
|
while (this.stream._index < end) {
|
||||||
|
var string = this.stream.readUTF8String();
|
||||||
|
if (string) {
|
||||||
|
data.push(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.stream._index = end;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = StringTable;
|
module.exports = StringTable;
|
||||||
|
|
|
||||||
2
test.js
2
test.js
|
|
@ -8,5 +8,5 @@ fs.readFile("process.dem", function (err, data) {
|
||||||
var head = parser.readHeader();
|
var head = parser.readHeader();
|
||||||
//console.log(head);
|
//console.log(head);
|
||||||
var body = parser.parseBody()
|
var body = parser.parseBody()
|
||||||
//console.log(body);
|
console.log(body.users);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue