1
0
Fork 0
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:
Robin Appelman 2015-02-01 17:26:36 +01:00
commit 9a297a2a9c
4 changed files with 34 additions and 17 deletions

View file

@ -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
}
} }
} }
} }

View file

@ -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);
} }
@ -68,4 +63,19 @@ StringTable.prototype.parsePlayerInfo = function (length) {
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;

View file

@ -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);
}); });