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 () {
|
||||
//while (this.stream.byteIndex < this.length) {
|
||||
//console.log(this.stream.readASCIIString());
|
||||
// console.log(this.stream.readASCIIString());
|
||||
//}
|
||||
return [];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -76,7 +76,14 @@ Parser.prototype.parseBody = function () {
|
|||
if (packet.tables.userinfo) {
|
||||
for (var j = 0; j < packet.tables.userinfo.length; j++) {
|
||||
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)) {
|
||||
extraDataLength = this.stream.readBits(16);
|
||||
//if (tableName === 'userinfo') {
|
||||
// entry.extraData = this.parsePlayerInfo(extraDataLength);
|
||||
//} else {
|
||||
entry.extraData = this.stream.readUTF8String(extraDataLength);
|
||||
//}
|
||||
//console.log(entry.extraData.length-extraDataLength);
|
||||
entry.extraData = this.readExtraData(extraDataLength);
|
||||
}
|
||||
entries.push(entry);
|
||||
}
|
||||
|
|
@ -68,4 +63,19 @@ StringTable.prototype.parsePlayerInfo = function (length) {
|
|||
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;
|
||||
|
|
|
|||
2
test.js
2
test.js
|
|
@ -8,5 +8,5 @@ fs.readFile("process.dem", function (err, data) {
|
|||
var head = parser.readHeader();
|
||||
//console.log(head);
|
||||
var body = parser.parseBody()
|
||||
//console.log(body);
|
||||
console.log(body.users);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue