Skip to content

Commit e06d053

Browse files
committed
partial POV demo support (#2)
1 parent 78d6704 commit e06d053

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ Check out the [examples](examples) folder for more examples, like [how to genera
104104
* Access to entities, server-classes & data-tables - [docs](https://godoc.org/github.com/markus-wa/demoinfocs-golang/sendtables#ServerClasses) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/entities)
105105
* Access to all net-messages - [docs](https://godoc.org/github.com/markus-wa/demoinfocs-golang#NetMessageCreator) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/net-messages)
106106
* Chat & console messages <sup id="achat1">1</sup> - [docs](https://godoc.org/github.com/markus-wa/demoinfocs-golang/events#ChatMessage) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/print-events)
107+
* POV demo support <sup id="achat1">2</sup>
107108
* [Easy debugging via build-flags](#debugging)
108109
* Built with performance & concurrency in mind
109110

110111
1. <small id="f1">Only for some demos; in MM demos the chat is encrypted for example.</small>
112+
2. <small id="f2">Only partially supported (as good as other parsers), some POV demos seem to be inherently broken</small>
111113

112114
## Performance / Benchmarks
113115

entities.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55

66
bit "github.com/markus-wa/demoinfocs-golang/bitread"
7-
msg "github.com/markus-wa/demoinfocs-golang/msg"
7+
"github.com/markus-wa/demoinfocs-golang/msg"
88
)
99

1010
const entitySentinel = 9999
@@ -26,8 +26,10 @@ func (p *Parser) handlePacketEntities(pe *msg.CSVCMsg_PacketEntities) {
2626

2727
if r.ReadBit() {
2828
// Leave PVS
29-
p.gameState.entities[currentEntity].Destroy()
30-
delete(p.gameState.entities, currentEntity)
29+
if entity := p.gameState.entities[currentEntity]; entity != nil {
30+
entity.Destroy()
31+
delete(p.gameState.entities, currentEntity)
32+
}
3133

3234
// 'Force Delete' flag, not exactly sure what it's supposed to do
3335
r.ReadBit()
@@ -41,7 +43,9 @@ func (p *Parser) handlePacketEntities(pe *msg.CSVCMsg_PacketEntities) {
4143
p.gameState.entities[currentEntity] = p.stParser.ReadEnterPVS(r, currentEntity)
4244
} else {
4345
// Delta Update
44-
p.gameState.entities[currentEntity].ApplyUpdate(r)
46+
if entity := p.gameState.entities[currentEntity]; entity != nil {
47+
entity.ApplyUpdate(r)
48+
}
4549
}
4650
}
4751
r.Pool()

0 commit comments

Comments
 (0)