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