Skip to content

Commit de04794

Browse files
committed
Document Parser fields
1 parent d59f443 commit de04794

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

parser.go

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,38 @@ import (
1919
// After parsing the header Parser.ParseNextFrame() and Parser.ParseToEnd() can be used to parse the demo.
2020
// Use Parser.RegisterEventHandler() to receive notifications about events.
2121
type Parser struct {
22+
// Important fields
23+
2224
bitReader *bit.BitReader
2325
stParser st.SendTableParser
24-
msgDispatcher dp.Dispatcher
25-
additionalNetMessageCreators map[int]NetMessageCreator
26+
additionalNetMessageCreators map[int]NetMessageCreator // Map of net-message-IDs to NetMessageCreators (for parsing custom net-messages)
27+
msgQueue chan interface{} // Queue of net-messages
28+
msgDispatcher dp.Dispatcher // Net-message dispatcher
2629
eventDispatcher dp.Dispatcher
27-
msgQueue chan interface{}
28-
gameState GameState
29-
currentFrame int
30-
bombsiteA bombsite
31-
bombsiteB bombsite
30+
currentFrame int // Demo-frame, not ingame-tick
3231
header *common.DemoHeader // Pointer so we can check for nil
33-
equipmentMapping map[*st.ServerClass]common.EquipmentElement
34-
rawPlayers map[int]*playerInfo
35-
entityIDToPlayers map[int]*common.Player // Temporary storage since we need to map players from entityID to userID later
36-
additionalPlayerInfo [maxPlayers]common.AdditionalPlayerInformation
37-
entities map[int]*st.Entity
38-
modelPreCache []string // Used to find out whether a weapon is a p250 or cz for example (same id)
39-
weapons [maxEntities]common.Equipment // Used to remember what a weapon is (p250 / cz etc.)
40-
triggers map[int]*boundingBoxInformation
41-
instanceBaselines map[int][]byte
42-
preprocessedBaselines map[int]map[int]st.PropValue
43-
gameEventDescs map[int32]*msg.CSVCMsg_GameEventListDescriptorT
44-
grenadeModelIndicies map[int]common.EquipmentElement // Used to map model indicies to grenades (used for grenade projectiles)
45-
stringTables []*msg.CSVCMsg_CreateStringTable
46-
cancelChan chan struct{}
47-
err error
48-
errLock sync.Mutex
32+
gameState GameState
33+
cancelChan chan struct{} // Non-anime-related, used for aborting the parsing
34+
err error // Contains a error that occurred during parsing if any
35+
errLock sync.Mutex // Used to sync up error mutations between parsing & handling go-routines
36+
37+
// Additional fields, mainly caching & tracking things
38+
39+
bombsiteA bombsite
40+
bombsiteB bombsite
41+
equipmentMapping map[*st.ServerClass]common.EquipmentElement // Maps server classes to equipment-types
42+
rawPlayers map[int]*playerInfo // Maps entity IDs to 'raw' player info
43+
entityIDToPlayers map[int]*common.Player // Temporary storage since we need to map players from entityID to userID later
44+
additionalPlayerInfo [maxPlayers]common.AdditionalPlayerInformation // Maps entity IDs to additional player info (scoreboard info)
45+
entities map[int]*st.Entity // Maps entity IDs to entities
46+
modelPreCache []string // Used to find out whether a weapon is a p250 or cz for example (same id)
47+
weapons [maxEntities]common.Equipment // Used to remember what a weapon is (p250 / cz etc.)
48+
triggers map[int]*boundingBoxInformation // Maps entity IDs to triggers (used for bombsites)
49+
instanceBaselines map[int][]byte // Maps server-class IDs to instance baselines
50+
preprocessedBaselines map[int]map[int]st.PropValue // Maps server-class IDs to preprocessed baselines (preprocessed-baseline = property-index to value map)
51+
gameEventDescs map[int32]*msg.CSVCMsg_GameEventListDescriptorT // Maps game-event IDs to descriptors
52+
grenadeModelIndicies map[int]common.EquipmentElement // Used to map model indicies to grenades (used for grenade projectiles)
53+
stringTables []*msg.CSVCMsg_CreateStringTable // Contains all created sendtables, needed when updating them
4954
}
5055

5156
type bombsite struct {

0 commit comments

Comments
 (0)