File tree Expand file tree Collapse file tree 5 files changed +29
-10
lines changed Expand file tree Collapse file tree 5 files changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ type Player struct {
49
49
IsDefusing bool
50
50
IsPlanting bool
51
51
IsReloading bool
52
+ IsUnknown bool // Used to identify unknown/broken players. see https://github.com/markus-wa/demoinfocs-golang/issues/162
52
53
HasDefuseKit bool
53
54
HasHelmet bool
54
55
}
Original file line number Diff line number Diff line change @@ -193,21 +193,33 @@ func (p *Parser) bindNewPlayer(playerEntity st.IEntity) {
193
193
isNew := false
194
194
pl := p .gameState .playersByEntityID [entityID ]
195
195
if pl == nil {
196
- pl = p .gameState .playersByUserID [rp .userID ]
196
+ if rp != nil {
197
+ pl = p .gameState .playersByUserID [rp .userID ]
197
198
198
- if pl == nil {
199
- isNew = true
199
+ if pl == nil {
200
+ isNew = true
200
201
201
- // TODO: read tickRate from CVARs as fallback
202
+ pl = common .NewPlayer (p .demoInfoProvider )
203
+ pl .Name = rp .name
204
+ pl .SteamID = rp .xuid
205
+ pl .IsBot = rp .isFakePlayer || rp .guid == "BOT"
206
+ pl .UserID = rp .userID
207
+ }
208
+ } else {
209
+ // see #162.
210
+ // GOTV doesn't crash here either so we just initialize this player with default values.
211
+ // this happens in some demos since November 2019 for players that were are actually connected.
212
+ // in GOTV these players are just called "unknown".
202
213
pl = common .NewPlayer (p .demoInfoProvider )
203
- pl .Name = rp .name
204
- pl .SteamID = rp .xuid
205
- pl .IsBot = rp .isFakePlayer || rp .guid == "BOT"
206
- pl .UserID = rp .userID
214
+ pl .Name = "unknown"
215
+ pl .IsUnknown = true
207
216
}
208
217
}
209
218
p .gameState .playersByEntityID [entityID ] = pl
210
- p .gameState .playersByUserID [rp .userID ] = pl
219
+
220
+ if rp != nil {
221
+ p .gameState .playersByUserID [rp .userID ] = pl
222
+ }
211
223
212
224
pl .EntityID = entityID
213
225
pl .Entity = playerEntity
Original file line number Diff line number Diff line change @@ -282,6 +282,11 @@ func (geh gameEventHandler) weaponFire(data map[string]*msg.CSVCMsg_GameEventKey
282
282
283
283
func (geh gameEventHandler ) weaponReload (data map [string ]* msg.CSVCMsg_GameEventKeyT ) {
284
284
pl := geh .playerByUserID32 (data ["userid" ].GetValShort ())
285
+ if pl == nil {
286
+ // see #162, "unknown" players since November 2019 update
287
+ return
288
+ }
289
+
285
290
pl .IsReloading = true
286
291
geh .dispatch (events.WeaponReload {
287
292
Player : pl ,
Original file line number Diff line number Diff line change @@ -280,6 +280,7 @@ func (p demoInfoProvider) IngameTick() int {
280
280
}
281
281
282
282
func (p demoInfoProvider ) TickRate () float64 {
283
+ // TODO: read tickRate from CVARs as fallback
283
284
return p .parser .header .TickRate ()
284
285
}
285
286
Submodule
cs-demos updated from fd76b0a to e8d2851
You can’t perform that action at this time.
0 commit comments