mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 00:54:14 +02:00
fix not parsing classes when using per-player ready
This commit is contained in:
parent
b7e10ae519
commit
c19d6dfa81
2 changed files with 16 additions and 7 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "tf2-demo",
|
||||
"description": "A parser for TF2 demo files",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"bin": {
|
||||
"demo-analyse": "./bin/analyse.js"
|
||||
},
|
||||
|
|
|
|||
21
state.js
21
state.js
|
|
@ -40,12 +40,9 @@ State.prototype.updateState = function (packet) {
|
|||
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,
|
||||
classes: {}
|
||||
}
|
||||
this.initUser(userId);
|
||||
this.state.users[userId].name= name;
|
||||
this.state.users[userId].steamId = steamId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +71,7 @@ State.prototype.updateState = function (packet) {
|
|||
break;
|
||||
case 'player_spawn':
|
||||
userId = packet.event.values.userid;
|
||||
this.initUser(userId);
|
||||
if (this.state.users[userId]) {
|
||||
if (!this.state.users[userId].team) { //only register first spawn
|
||||
this.state.users[userId].team = packet.event.values.team === 2 ? 'red' : 'blue'
|
||||
|
|
@ -90,4 +88,15 @@ State.prototype.updateState = function (packet) {
|
|||
}
|
||||
};
|
||||
|
||||
State.prototype.initUser = function (userId) {
|
||||
if (!this.state.users[userId]) {
|
||||
this.state.users[userId] = {
|
||||
name : null,
|
||||
userId : userId,
|
||||
steamId: null,
|
||||
classes: {}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = State;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue