mirror of
https://github.com/demostf/demo.js
synced 2026-06-03 16:44:12 +02:00
fix parsing user info
This commit is contained in:
parent
1c33058cb4
commit
a36208c693
4 changed files with 19 additions and 20 deletions
|
|
@ -71,6 +71,8 @@ export class Match {
|
|||
handlePacket(packet) {
|
||||
var userState;
|
||||
switch (packet.packetType) {
|
||||
case 'packetEntities':
|
||||
break;
|
||||
case 'netTick':
|
||||
if (this.startTick === 0) {
|
||||
this.startTick = packet.tick;
|
||||
|
|
@ -89,15 +91,17 @@ export class Match {
|
|||
});
|
||||
break;
|
||||
case 'stringTable':
|
||||
if (packet.tables.userinfo) {
|
||||
for (var j = 0; j < packet.tables.userinfo.length; j++) {
|
||||
if (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);
|
||||
userState = this.getUserState(userId);
|
||||
userState.name = name;
|
||||
userState.steamId = steamId;
|
||||
for (const table of <StringTable[]>packet.tables) {
|
||||
if (table.name === 'userinfo') {
|
||||
for (const userData of table.entries) {
|
||||
if (userData.extraData) {
|
||||
const name = userData.extraData.readUTF8String(32);
|
||||
const userId = userData.extraData.readUint32();
|
||||
const steamId = userData.extraData.readUTF8String();
|
||||
userState = this.getUserState(userId);
|
||||
userState.name = name;
|
||||
userState.steamId = steamId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -134,12 +138,12 @@ export class Match {
|
|||
}
|
||||
break;
|
||||
case 'player_spawn':
|
||||
userId = packet.event.values.userid;
|
||||
const userId = packet.event.values.userid;
|
||||
userState = this.getUserState(userId);
|
||||
if (!userState.team) { //only register first spawn
|
||||
userState.team = packet.event.values.team === 2 ? 'red' : 'blue'
|
||||
}
|
||||
var classId = packet.event.values.class;
|
||||
const classId = packet.event.values.class;
|
||||
if (!userState.classes[classId]) {
|
||||
userState.classes[classId] = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export function CreateStringTable(stream: BitStream, match: Match): Packet { //
|
|||
|
||||
match.stringTables.push(table);
|
||||
return {
|
||||
packetType: 'createStringTable',
|
||||
table: table
|
||||
packetType: 'stringTable',
|
||||
tables: [table]
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,11 +89,6 @@ export function PacketEntities(stream: BitStream, match: Match): Packet { //26:
|
|||
const end = stream.index + length;
|
||||
let entityId = -1;
|
||||
|
||||
// stream.index = end;
|
||||
// return {
|
||||
// packetType: 'packetEntities'
|
||||
// };
|
||||
|
||||
if (updatedBaseLine) {
|
||||
if (baseLine === 0) {
|
||||
match.instanceBaselines[1] = match.instanceBaselines[0];
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export function UpdateStringTable(stream: BitStream, match: Match): Packet { //
|
|||
parseStringTable(data, table, changedEntries, match);
|
||||
|
||||
return {
|
||||
packetType: 'updateStringTable',
|
||||
table: table
|
||||
packetType: 'stringTable',
|
||||
tables: [table]
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue