Skip to content

Commit 753a3cc

Browse files
committed
Improve godoc
1 parent f73754d commit 753a3cc

File tree

13 files changed

+136
-52
lines changed

13 files changed

+136
-52
lines changed

bitread/bitread.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Package bitread provides a wrapper for github.com/markus-wa/gobitread with CS:GO demo parsing specific helpers.
2+
//
3+
// Intended for internal use only.
24
package bitread
35

46
import (

common/constants.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,14 @@ func (e EquipmentElement) Class() EquipmentClass {
151151
}
152152

153153
// String returns a human readable name for the equipment.
154-
// E.g. AK-47, UMP-45, Smoke Grenade etc.
154+
// E.g. 'AK-47', 'UMP-45', 'Smoke Grenade' etc.
155155
func (e EquipmentElement) String() string {
156156
return eqElementToName[e]
157157
}
158158

159159
// EquipmentClass constants give information about the type of an equipment (SMG, Rifle, Grenade etc.).
160-
// Note: EquipmentElement / 100 = EquipmentClass
160+
//
161+
// Note: (EquipmentElement+99) / 100 = EquipmentClass
161162
const (
162163
EqClassUnknown EquipmentClass = 0
163164
EqClassPistols EquipmentClass = 1

common/structs.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
st "github.com/markus-wa/demoinfocs-golang/sendtables"
99
)
1010

11-
// DemoHeader contains information about the demo's header.
11+
// DemoHeader contains information from a demo's header.
1212
type DemoHeader struct {
1313
Filestamp string
1414
Protocol int
@@ -76,7 +76,7 @@ func (p *Player) ActiveWeapon() *Equipment {
7676
return p.RawWeapons[p.ActiveWeaponID]
7777
}
7878

79-
// Weapons returns all weapons in the player's possession
79+
// Weapons returns all weapons in the player's possession.
8080
func (p *Player) Weapons() []*Equipment {
8181
res := make([]*Equipment, 0, len(p.RawWeapons))
8282
for _, w := range p.RawWeapons {
@@ -140,6 +140,8 @@ func (e Equipment) UniqueID() int64 {
140140
}
141141

142142
// NewGrenadeProjectile creates a grenade projectile and sets.
143+
//
144+
// Intended for internal use only.
143145
func NewGrenadeProjectile() *GrenadeProjectile {
144146
return &GrenadeProjectile{uniqueID: rand.Int63()}
145147
}
@@ -152,11 +154,15 @@ func (g GrenadeProjectile) UniqueID() int64 {
152154
}
153155

154156
// NewEquipment is a wrapper for NewSkinEquipment to create weapons without skins.
157+
//
158+
// Intended for internal use only.
155159
func NewEquipment(eqName string) Equipment {
156160
return NewSkinEquipment(eqName, "")
157161
}
158162

159163
// NewSkinEquipment creates an equipment with a skin from a skinID and equipment name.
164+
//
165+
// Intended for internal use only.
160166
func NewSkinEquipment(eqName string, skinID string) Equipment {
161167
var wep EquipmentElement
162168
if len(eqName) > 0 {
@@ -168,6 +174,8 @@ func NewSkinEquipment(eqName string, skinID string) Equipment {
168174
}
169175

170176
// NewPlayer creates a *Player with an initialized equipment map.
177+
//
178+
// Intended for internal use only.
171179
func NewPlayer() *Player {
172180
return &Player{RawWeapons: make(map[int]*Equipment)}
173181
}

demopacket.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import (
1010
msg "github.com/markus-wa/demoinfocs-golang/msg"
1111
)
1212

13+
// NetMessageCreator creates additional net-messages to be dispatched to net-message handlers.
14+
//
15+
// See also: ParserConfig.AdditionalNetMessageCreators & Parser.RegisterNetMessageHandler()
16+
type NetMessageCreator func() proto.Message
17+
1318
var byteSlicePool = sync.Pool{
1419
New: func() interface{} {
1520
s := make([]byte, 0, 256)
@@ -101,10 +106,6 @@ func (p *Parser) parsePacket() {
101106
p.bitReader.EndChunk()
102107
}
103108

104-
// NetMessageCreator creates additional net-messages to be dispatched to net-message handlers.
105-
// See also: ParserConfig.AdditionalNetMessageCreators & Parser.RegisterNetMessageHandler()
106-
type NetMessageCreator func() proto.Message
107-
108109
/*
109110
Format of 'CommandInfos' - I honestly have no clue what they are good for.
110111
If you find a use for this please let me know!

doc.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
// Package demoinfocs provides a demo parser for the game Counter-Strike: Global Offensive.
2-
// It is based on the official demoinfogo tool by Valve as well as Stats Helix's demoinfo.
3-
// A good entry point to using the library is the Parser type.
4-
// Demo events are documented in the events package.
1+
/*
2+
Package demoinfocs provides a demo parser for the game Counter-Strike: Global Offensive.
3+
It is based on the official demoinfogo tool by Valve as well as Stats Helix's demoinfo.
4+
5+
A good entry point to using the library is the Parser type.
6+
7+
Demo events are documented in the events package.
8+
*/
59
package demoinfocs

events/events.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type LastRoundHalfEvent struct{}
6060
// FreezetimeEndedEvent signals that the freeze time is over.
6161
type FreezetimeEndedEvent struct{}
6262

63-
// PlayerFootstepEvent occurs when a player makes a footstep
63+
// PlayerFootstepEvent occurs when a player makes a footstep.
6464
type PlayerFootstepEvent struct {
6565
Player *common.Player
6666
}
@@ -118,7 +118,7 @@ type NadeEvent struct {
118118
NadeEntityID int
119119
}
120120

121-
// Base returns the NadeEvent itself, used for catching all events with NadeEventIf
121+
// Base returns the NadeEvent itself, used for catching all events with NadeEventIf.
122122
func (ne NadeEvent) Base() NadeEvent {
123123
return ne
124124
}
@@ -164,7 +164,7 @@ type FireNadeEndEvent struct {
164164
NadeEvent
165165
}
166166

167-
// NadeProjectileBouncedEvent signals that a nade has just bounced off a wall/floor/ceiling or object
167+
// NadeProjectileBouncedEvent signals that a nade has just bounced off a wall/floor/ceiling or object.
168168
type NadeProjectileBouncedEvent struct {
169169
Projectile *common.GrenadeProjectile
170170
BounceNr int
@@ -297,7 +297,7 @@ type RankUpdateEvent struct {
297297
RankChange float32
298298
}
299299

300-
// ItemEquipEvent signals an item was equipped
300+
// ItemEquipEvent signals an item was equipped.
301301
type ItemEquipEvent struct {
302302
Weapon common.Equipment
303303
Player *common.Player
@@ -309,7 +309,7 @@ type ItemPickupEvent struct {
309309
Player *common.Player
310310
}
311311

312-
// ItemDropEvent signals an item was dropped
312+
// ItemDropEvent signals an item was dropped.
313313
type ItemDropEvent struct {
314314
Weapon common.Equipment
315315
Player *common.Player

fuzzy/team_switch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ import (
88
)
99

1010
// TeamSwitchEvent signals that the teams have switched.
11+
//
1112
// See also: ValveMatchmakingTeamSwitchEmitter
1213
type TeamSwitchEvent struct{}
1314

1415
// ValveMatchmakingTeamSwitchEmitter emits a TeamSwitchEvent for Valve MM demos.
1516
// Sadly this WON'T work for Major games as it currently doesn't account for overtime.
17+
//
1618
// This is a beta feature and may be changed or replaced without notice.
19+
//
1720
// See also: github.com/markus-wa/demoinfocs-golang/ParserConfig.AdditionalEventEmitters
1821
type ValveMatchmakingTeamSwitchEmitter struct {
1922
parser *dem.Parser

game_state.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,22 @@ func (gs *GameState) handleIngameTickNumber(n ingameTickNumber) {
2121
}
2222

2323
// IngameTick returns the latest actual tick number of the server during the game.
24+
//
2425
// Watch out, I've seen this return wonky negative numbers at the start of demos.
2526
func (gs GameState) IngameTick() int {
2627
return gs.ingameTick
2728
}
2829

2930
// CTState returns the TeamState of the CT team.
30-
// Make sure you handle swapping sides properly if you keep the reference.
31+
//
32+
// Make sure to handle swapping sides properly if you keep the reference.
3133
func (gs *GameState) CTState() *TeamState {
3234
return &gs.ctState
3335
}
3436

3537
// TState returns the TeamState of the T team.
36-
// Make sure you handle swapping sides properly if you keep the reference.
38+
//
39+
// Make sure to handle swapping sides properly if you keep the reference.
3740
func (gs *GameState) TState() *TeamState {
3841
return &gs.tState
3942
}
@@ -70,8 +73,10 @@ func (gs GameState) TeamMembers(team common.Team) []*common.Player {
7073
return r
7174
}
7275

73-
// GrenadeProjectiles returns a map with all grenade projectiles. The map contains only projectiles
74-
// that are currently in-flight, i.e. have been thrown but have yet to detonate.
76+
// GrenadeProjectiles returns a map from entity-IDs to all live grenade projectiles.
77+
//
78+
// Only constains projectiles currently in-flight or still active (smokes etc.),
79+
// i.e. have been thrown but have yet to detonate.
7580
func (gs GameState) GrenadeProjectiles() map[int]*common.GrenadeProjectile {
7681
return gs.grenadeProjectiles
7782
}
@@ -92,6 +97,7 @@ type TeamState struct {
9297
}
9398

9499
// ID returns the team-ID.
100+
//
95101
// This stays the same even after switching sides.
96102
func (ts TeamState) ID() int {
97103
return ts.id
@@ -108,6 +114,7 @@ func (ts TeamState) ClanName() string {
108114
}
109115

110116
// Flag returns the team's country flag.
117+
//
111118
// Watch out, in some demos this is upper-case and in some lower-case.
112119
func (ts TeamState) Flag() string {
113120
return ts.flag

msg/msg.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Package msg contains the generated protobuf demo message code.
2+
//
23
// Use 'go generate' to generate the code from the .proto files inside the proto sub directory.
34
package msg
45

0 commit comments

Comments
 (0)