Skip to content

Commit

Permalink
Update protos and protobuf package (#140)
Browse files Browse the repository at this point in the history
* use proto v1.5.2, update protos

* update README

* more README improvements for developing
  • Loading branch information
jcoene authored Dec 21, 2021
1 parent 97c62fb commit b470f38
Show file tree
Hide file tree
Showing 111 changed files with 200,553 additions and 141,516 deletions.
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
SED=sed
ifeq ($(shell uname), Darwin)
SED=gsed
endif

default: build

test:
Expand Down Expand Up @@ -28,12 +33,13 @@ update-protobufs:
rm -rf dota
svn export https://github.com/SteamDatabase/GameTracking-Dota2.git/trunk/Protobufs dota
rm -rf dota/gametoolevents.proto dota/dota_messages_mlbot.proto dota/dota_gcmessages_common_bot_script.proto dota/steammessages_base.proto dota/steammessages_clientserver_login.proto dota/*steamworks*.proto dota/tensorflow
sed -i 's/k_EMsgGCSystemMessage/k_EMsgGCSystemMessageCS/' dota/enums_clientserver.proto
sed -i 's/^\(\s*\)\(optional\|repeated\|required\|extend\)\s*\./\1\2 /' dota/*.proto
sed -i 's!^\s*rpc\s*\(\S*\)\s*(\.\([^)]*\))\s*returns\s*(\.\([^)]*\))\s*{!rpc \1 (\2) returns (\3) {!' dota/*.proto
sed -i '1isyntax = "proto2";\n\npackage dota;\n' dota/*.proto
protoc -I dota --go_out=dota dota/*.proto
sed -i 's|google/protobuf|github.com/golang/protobuf/protoc-gen-go/descriptor|' dota/*.pb.go
$(SED) -i 's/^\(\s*\)\(optional\|repeated\|required\|extend\)\s*\./\1\2 /' dota/*.proto
$(SED) -i 's!^\s*rpc\s*\(\S*\)\s*(\.\([^)]*\))\s*returns\s*(\.\([^)]*\))\s*{!rpc \1 (\2) returns (\3) {!' dota/*.proto
$(SED) -i '1isyntax = "proto2";\n\npackage dota;\noption go_package = "github.com/dotabuff/manta/dota;dota";\n' dota/*.proto
$(SED) -i '/^import "google\/protobuf\/valve_extensions\.proto"/d' dota/*.proto
$(SED) -i '/^option (/d' dota/*.proto
$(SED) -i 's/\s\[.*\]//g' dota/*.proto
protoc -I dota --go_out=paths=source_relative:dota dota/*.proto

generate:
go run gen/callbacks.go
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ func main() {

## Developing

To run `make update` you will need the latest version of the `protobuf` package:
To run `make update` you will need a few things installed:

`go get -u github.com/golang/protobuf/...`
```sh
# Install subversion. On OS X:
brew install subversion

You will also need GNU sed. To install GNU sed on Mac OS X:
# Install protoc. On OS X:
brew install protobuf

```
# Install GNU sed
# Install gnu-sed. Not needed on Linux. On OS X:
brew install gnu-sed
# Create a symlink in /usr/local/bin
ln -s /usr/local/bin/gsed /usr/local/bin/sed
# Ensure that /usr/local/bin is foremost in your PATH
export PATH="/usr/local/bin:$PATH"
```

# Install protoc-gen-go:
go install github.com/golang/protobuf/[email protected]
```

## License

Expand All @@ -87,7 +87,7 @@ Looking to parse Source 1 (original Dota 2) replays? Take a look at [Yasha](http

Manta is maintained and development is sponsored by [Dotabuff](http://www.dotabuff.com), a leading Dota 2 community website with an emphasis on statistics. Manta wouldn't exist without the efforts of a number of people:

* [Michael Fellinger](https://github.com/manveru) built Dotabuff's Source 1 parser [yasha](https://github.com/dotabuff/yasha).
* [Robin Dietrich](https://github.com/invokr) built the C++ parser [Alice](https://github.com/AliceStats/Alice).
* [Martin Schrodt](https://github.com/spheenik) built the Java parser [clarity](https://github.com/skadistats/clarity).
* [Drew Schleck](https://github.com/dschleck), built an original C++ parser [edith](https://github.com/dschleck/edith).
- [Michael Fellinger](https://github.com/manveru) built Dotabuff's Source 1 parser [yasha](https://github.com/dotabuff/yasha).
- [Robin Dietrich](https://github.com/invokr) built the C++ parser [Alice](https://github.com/AliceStats/Alice).
- [Martin Schrodt](https://github.com/spheenik) built the Java parser [clarity](https://github.com/skadistats/clarity).
- [Drew Schleck](https://github.com/dschleck), built an original C++ parser [edith](https://github.com/dschleck/edith).
175 changes: 50 additions & 125 deletions callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,16 @@ type Callbacks struct {
onCSVCMsg_ServerSteamID []func(*dota.CSVCMsg_ServerSteamID) error
onCSVCMsg_FullFrameSplit []func(*dota.CSVCMsg_FullFrameSplit) error
onCSVCMsg_RconServerDetails []func(*dota.CSVCMsg_RconServerDetails) error
onCSVCMsg_UserMessage []func(*dota.CSVCMsg_UserMessage) error
onCUserMessageAchievementEvent []func(*dota.CUserMessageAchievementEvent) error
onCUserMessageCloseCaption []func(*dota.CUserMessageCloseCaption) error
onCUserMessageCloseCaptionDirect []func(*dota.CUserMessageCloseCaptionDirect) error
onCUserMessageCurrentTimescale []func(*dota.CUserMessageCurrentTimescale) error
onCUserMessageDesiredTimescale []func(*dota.CUserMessageDesiredTimescale) error
onCUserMessageFade []func(*dota.CUserMessageFade) error
onCUserMessageGameTitle []func(*dota.CUserMessageGameTitle) error
onCUserMessageHintText []func(*dota.CUserMessageHintText) error
onCUserMessageHudMsg []func(*dota.CUserMessageHudMsg) error
onCUserMessageHudText []func(*dota.CUserMessageHudText) error
onCUserMessageKeyHintText []func(*dota.CUserMessageKeyHintText) error
onCUserMessageColoredText []func(*dota.CUserMessageColoredText) error
onCUserMessageRequestState []func(*dota.CUserMessageRequestState) error
onCUserMessageResetHUD []func(*dota.CUserMessageResetHUD) error
Expand All @@ -83,14 +82,11 @@ type Callbacks struct {
onCUserMessageShakeDir []func(*dota.CUserMessageShakeDir) error
onCUserMessageTextMsg []func(*dota.CUserMessageTextMsg) error
onCUserMessageScreenTilt []func(*dota.CUserMessageScreenTilt) error
onCUserMessageTrain []func(*dota.CUserMessageTrain) error
onCUserMessageVGUIMenu []func(*dota.CUserMessageVGUIMenu) error
onCUserMessageVoiceMask []func(*dota.CUserMessageVoiceMask) error
onCUserMessageVoiceSubtitle []func(*dota.CUserMessageVoiceSubtitle) error
onCUserMessageSendAudio []func(*dota.CUserMessageSendAudio) error
onCUserMessageItemPickup []func(*dota.CUserMessageItemPickup) error
onCUserMessageAmmoDenied []func(*dota.CUserMessageAmmoDenied) error
onCUserMessageCrosshairAngle []func(*dota.CUserMessageCrosshairAngle) error
onCUserMessageShowMenu []func(*dota.CUserMessageShowMenu) error
onCUserMessageCreditsMsg []func(*dota.CUserMessageCreditsMsg) error
onCEntityMessagePlayJingle []func(*dota.CEntityMessagePlayJingle) error
Expand All @@ -104,6 +100,7 @@ type Callbacks struct {
onCUserMessageAudioParameter []func(*dota.CUserMessageAudioParameter) error
onCUserMessageHapticsManagerPulse []func(*dota.CUserMessageHapticsManagerPulse) error
onCUserMessageHapticsManagerEffect []func(*dota.CUserMessageHapticsManagerEffect) error
onCUserMessageCommandQueueState []func(*dota.CUserMessageCommandQueueState) error
onCMsgVDebugGameSessionIDEvent []func(*dota.CMsgVDebugGameSessionIDEvent) error
onCMsgPlaceDecalEvent []func(*dota.CMsgPlaceDecalEvent) error
onCMsgClearWorldDecalsEvent []func(*dota.CMsgClearWorldDecalsEvent) error
Expand Down Expand Up @@ -536,6 +533,11 @@ func (c *Callbacks) OnCSVCMsg_RconServerDetails(fn func(*dota.CSVCMsg_RconServer
c.onCSVCMsg_RconServerDetails = append(c.onCSVCMsg_RconServerDetails, fn)
}

// OnCSVCMsg_UserMessage registers a callback for SVC_Messages_svc_UserMessage
func (c *Callbacks) OnCSVCMsg_UserMessage(fn func(*dota.CSVCMsg_UserMessage) error) {
c.onCSVCMsg_UserMessage = append(c.onCSVCMsg_UserMessage, fn)
}

// OnCUserMessageAchievementEvent registers a callback for EBaseUserMessages_UM_AchievementEvent
func (c *Callbacks) OnCUserMessageAchievementEvent(fn func(*dota.CUserMessageAchievementEvent) error) {
c.onCUserMessageAchievementEvent = append(c.onCUserMessageAchievementEvent, fn)
Expand Down Expand Up @@ -571,11 +573,6 @@ func (c *Callbacks) OnCUserMessageGameTitle(fn func(*dota.CUserMessageGameTitle)
c.onCUserMessageGameTitle = append(c.onCUserMessageGameTitle, fn)
}

// OnCUserMessageHintText registers a callback for EBaseUserMessages_UM_HintText
func (c *Callbacks) OnCUserMessageHintText(fn func(*dota.CUserMessageHintText) error) {
c.onCUserMessageHintText = append(c.onCUserMessageHintText, fn)
}

// OnCUserMessageHudMsg registers a callback for EBaseUserMessages_UM_HudMsg
func (c *Callbacks) OnCUserMessageHudMsg(fn func(*dota.CUserMessageHudMsg) error) {
c.onCUserMessageHudMsg = append(c.onCUserMessageHudMsg, fn)
Expand All @@ -586,11 +583,6 @@ func (c *Callbacks) OnCUserMessageHudText(fn func(*dota.CUserMessageHudText) err
c.onCUserMessageHudText = append(c.onCUserMessageHudText, fn)
}

// OnCUserMessageKeyHintText registers a callback for EBaseUserMessages_UM_KeyHintText
func (c *Callbacks) OnCUserMessageKeyHintText(fn func(*dota.CUserMessageKeyHintText) error) {
c.onCUserMessageKeyHintText = append(c.onCUserMessageKeyHintText, fn)
}

// OnCUserMessageColoredText registers a callback for EBaseUserMessages_UM_ColoredText
func (c *Callbacks) OnCUserMessageColoredText(fn func(*dota.CUserMessageColoredText) error) {
c.onCUserMessageColoredText = append(c.onCUserMessageColoredText, fn)
Expand Down Expand Up @@ -646,16 +638,6 @@ func (c *Callbacks) OnCUserMessageScreenTilt(fn func(*dota.CUserMessageScreenTil
c.onCUserMessageScreenTilt = append(c.onCUserMessageScreenTilt, fn)
}

// OnCUserMessageTrain registers a callback for EBaseUserMessages_UM_Train
func (c *Callbacks) OnCUserMessageTrain(fn func(*dota.CUserMessageTrain) error) {
c.onCUserMessageTrain = append(c.onCUserMessageTrain, fn)
}

// OnCUserMessageVGUIMenu registers a callback for EBaseUserMessages_UM_VGUIMenu
func (c *Callbacks) OnCUserMessageVGUIMenu(fn func(*dota.CUserMessageVGUIMenu) error) {
c.onCUserMessageVGUIMenu = append(c.onCUserMessageVGUIMenu, fn)
}

// OnCUserMessageVoiceMask registers a callback for EBaseUserMessages_UM_VoiceMask
func (c *Callbacks) OnCUserMessageVoiceMask(fn func(*dota.CUserMessageVoiceMask) error) {
c.onCUserMessageVoiceMask = append(c.onCUserMessageVoiceMask, fn)
Expand All @@ -681,11 +663,6 @@ func (c *Callbacks) OnCUserMessageAmmoDenied(fn func(*dota.CUserMessageAmmoDenie
c.onCUserMessageAmmoDenied = append(c.onCUserMessageAmmoDenied, fn)
}

// OnCUserMessageCrosshairAngle registers a callback for EBaseUserMessages_UM_CrosshairAngle
func (c *Callbacks) OnCUserMessageCrosshairAngle(fn func(*dota.CUserMessageCrosshairAngle) error) {
c.onCUserMessageCrosshairAngle = append(c.onCUserMessageCrosshairAngle, fn)
}

// OnCUserMessageShowMenu registers a callback for EBaseUserMessages_UM_ShowMenu
func (c *Callbacks) OnCUserMessageShowMenu(fn func(*dota.CUserMessageShowMenu) error) {
c.onCUserMessageShowMenu = append(c.onCUserMessageShowMenu, fn)
Expand Down Expand Up @@ -751,6 +728,11 @@ func (c *Callbacks) OnCUserMessageHapticsManagerEffect(fn func(*dota.CUserMessag
c.onCUserMessageHapticsManagerEffect = append(c.onCUserMessageHapticsManagerEffect, fn)
}

// OnCUserMessageCommandQueueState registers a callback for EBaseUserMessages_UM_CommandQueueState
func (c *Callbacks) OnCUserMessageCommandQueueState(fn func(*dota.CUserMessageCommandQueueState) error) {
c.onCUserMessageCommandQueueState = append(c.onCUserMessageCommandQueueState, fn)
}

// OnCMsgVDebugGameSessionIDEvent registers a callback for EBaseGameEvents_GE_VDebugGameSessionIDEvent
func (c *Callbacks) OnCMsgVDebugGameSessionIDEvent(fn func(*dota.CMsgVDebugGameSessionIDEvent) error) {
c.onCMsgVDebugGameSessionIDEvent = append(c.onCMsgVDebugGameSessionIDEvent, fn)
Expand Down Expand Up @@ -2550,6 +2532,25 @@ func (c *Callbacks) callByPacketType(t int32, buf []byte) error {

return nil

case 72: // dota.SVC_Messages_svc_UserMessage
if c.onCSVCMsg_UserMessage == nil {
return nil
}

msg := &dota.CSVCMsg_UserMessage{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCSVCMsg_UserMessage {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 101: // dota.EBaseUserMessages_UM_AchievementEvent
if c.onCUserMessageAchievementEvent == nil {
return nil
Expand Down Expand Up @@ -2683,25 +2684,6 @@ func (c *Callbacks) callByPacketType(t int32, buf []byte) error {

return nil

case 109: // dota.EBaseUserMessages_UM_HintText
if c.onCUserMessageHintText == nil {
return nil
}

msg := &dota.CUserMessageHintText{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCUserMessageHintText {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 110: // dota.EBaseUserMessages_UM_HudMsg
if c.onCUserMessageHudMsg == nil {
return nil
Expand Down Expand Up @@ -2740,25 +2722,6 @@ func (c *Callbacks) callByPacketType(t int32, buf []byte) error {

return nil

case 112: // dota.EBaseUserMessages_UM_KeyHintText
if c.onCUserMessageKeyHintText == nil {
return nil
}

msg := &dota.CUserMessageKeyHintText{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCUserMessageKeyHintText {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 113: // dota.EBaseUserMessages_UM_ColoredText
if c.onCUserMessageColoredText == nil {
return nil
Expand Down Expand Up @@ -2968,44 +2931,6 @@ func (c *Callbacks) callByPacketType(t int32, buf []byte) error {

return nil

case 126: // dota.EBaseUserMessages_UM_Train
if c.onCUserMessageTrain == nil {
return nil
}

msg := &dota.CUserMessageTrain{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCUserMessageTrain {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 127: // dota.EBaseUserMessages_UM_VGUIMenu
if c.onCUserMessageVGUIMenu == nil {
return nil
}

msg := &dota.CUserMessageVGUIMenu{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCUserMessageVGUIMenu {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 128: // dota.EBaseUserMessages_UM_VoiceMask
if c.onCUserMessageVoiceMask == nil {
return nil
Expand Down Expand Up @@ -3101,25 +3026,6 @@ func (c *Callbacks) callByPacketType(t int32, buf []byte) error {

return nil

case 133: // dota.EBaseUserMessages_UM_CrosshairAngle
if c.onCUserMessageCrosshairAngle == nil {
return nil
}

msg := &dota.CUserMessageCrosshairAngle{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCUserMessageCrosshairAngle {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 134: // dota.EBaseUserMessages_UM_ShowMenu
if c.onCUserMessageShowMenu == nil {
return nil
Expand Down Expand Up @@ -3367,6 +3273,25 @@ func (c *Callbacks) callByPacketType(t int32, buf []byte) error {

return nil

case 152: // dota.EBaseUserMessages_UM_CommandQueueState
if c.onCUserMessageCommandQueueState == nil {
return nil
}

msg := &dota.CUserMessageCommandQueueState{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCUserMessageCommandQueueState {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 200: // dota.EBaseGameEvents_GE_VDebugGameSessionIDEvent
if c.onCMsgVDebugGameSessionIDEvent == nil {
return nil
Expand Down
Loading

0 comments on commit b470f38

Please sign in to comment.