Skip to content

Commit

Permalink
feat: update protobuf and apigen processes, regen protos
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed Sep 12, 2019
1 parent e6e55d1 commit 1fadfcb
Show file tree
Hide file tree
Showing 105 changed files with 140,942 additions and 66,714 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "generator/GameTracking-Dota2"]
path = generator/GameTracking-Dota2
url = https://github.com/SteamDatabase/GameTracking-Dota2
78 changes: 0 additions & 78 deletions Gopkg.lock

This file was deleted.

35 changes: 0 additions & 35 deletions Gopkg.toml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This mechanism is used everywhere, these objects are not exposed in their own ev

```go
import (
gcmm "github.com/paralin/go-dota2/protocol/dota_gcmessages_common_match_management"
gcmm "github.com/paralin/go-dota2/protocol"
"github.com/paralin/go-dota2/cso"
)

Expand Down
19 changes: 9 additions & 10 deletions apigen/api_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"unicode"

gcm "github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"
gcm "github.com/paralin/go-dota2/protocol"
"github.com/pkg/errors"
"github.com/serenize/snaker"
)
Expand All @@ -29,14 +29,13 @@ func GenerateAPI(ctx context.Context, clientOutput, eventsOutput io.Writer) erro
var requestFuncs []*generatedRequestFunc

eventsImports := make(map[string]struct{})
eventsImports["github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"] = struct{}{}
eventsImports["github.com/paralin/go-dota2/protocol"] = struct{}{}
eventsImports["github.com/golang/protobuf/proto"] = struct{}{}

clientImports := make(map[string]struct{})
clientImports["context"] = struct{}{}
clientImports["github.com/paralin/go-dota2/protocol/dota_shared_enums"] = struct{}{}
clientImports["github.com/paralin/go-dota2/protocol"] = struct{}{}
clientImports["github.com/faceit/go-steam/steamid"] = struct{}{}
clientImports["github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"] = struct{}{}
clientImports["github.com/paralin/go-dota2/events"] = struct{}{}

// responseMsgs are messages that are known to be responses.
Expand Down Expand Up @@ -236,11 +235,11 @@ func GenerateAPI(ctx context.Context, clientOutput, eventsOutput io.Writer) erro
return err
}
fmt.Fprintf(clientOutput, "{}\n\n\treturn resp, d.MakeRequest(\n")
fmt.Fprintf(clientOutput, "\t\tctx,\n\t\tuint32(dota_gcmessages_msgid.EDOTAGCMsg_%s),\n", f.reqMsgID.String())
fmt.Fprintf(clientOutput, "\t\treq,\n\t\tuint32(dota_gcmessages_msgid.EDOTAGCMsg_%s),\n", f.respMsgID.String())
fmt.Fprintf(clientOutput, "\t\tctx,\n\t\tuint32(protocol.EDOTAGCMsg_%s),\n", f.reqMsgID.String())
fmt.Fprintf(clientOutput, "\t\treq,\n\t\tuint32(protocol.EDOTAGCMsg_%s),\n", f.respMsgID.String())
fmt.Fprintf(clientOutput, "\t\tresp,\n\t)\n")
} else {
fmt.Fprintf(clientOutput, "\td.write(uint32(dota_gcmessages_msgid.EDOTAGCMsg_%s), req)\n", f.reqMsgID.String())
fmt.Fprintf(clientOutput, "\td.write(uint32(protocol.EDOTAGCMsg_%s), req)\n", f.reqMsgID.String())
}

fmt.Fprintf(clientOutput, "}\n")
Expand Down Expand Up @@ -270,8 +269,8 @@ func GenerateAPI(ctx context.Context, clientOutput, eventsOutput io.Writer) erro
fmt.Fprintf(eventsOutput, "\n}\n")

fmt.Fprintf(eventsOutput, "\n// GetDotaEventMsgID returns the dota message ID of the event.\n")
fmt.Fprintf(eventsOutput, "func (e *%s) GetDotaEventMsgID() dota_gcmessages_msgid.EDOTAGCMsg {\n", eventHandler.eventName)
fmt.Fprintf(eventsOutput, "\treturn dota_gcmessages_msgid.EDOTAGCMsg_%s\n", eventHandler.msgID.String())
fmt.Fprintf(eventsOutput, "func (e *%s) GetDotaEventMsgID() protocol.EDOTAGCMsg {\n", eventHandler.eventName)
fmt.Fprintf(eventsOutput, "\treturn protocol.EDOTAGCMsg_%s\n", eventHandler.msgID.String())
fmt.Fprintf(eventsOutput, "}\n")

fmt.Fprintf(eventsOutput, "\n// GetEventBody returns the event body.\n")
Expand All @@ -286,7 +285,7 @@ func GenerateAPI(ctx context.Context, clientOutput, eventsOutput io.Writer) erro

fmt.Fprintf(
clientOutput,
"\td.handlers[uint32(dota_gcmessages_msgid.EDOTAGCMsg_%s)] = d.getEventEmitter(func() events.Event {\n",
"\td.handlers[uint32(protocol.EDOTAGCMsg_%s)] = d.getEventEmitter(func() events.Event {\n",
eventHandler.msgID.String(),
)
fmt.Fprintf(clientOutput, "\t\treturn &events.%s{}\n\t})\n", eventHandler.eventName)
Expand Down
2 changes: 1 addition & 1 deletion apigen/api_generate_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

gcm "github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"
gcm "github.com/paralin/go-dota2/protocol"
)

type generatedEventHandler struct {
Expand Down
2 changes: 1 addition & 1 deletion apigen/api_generate_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"

"github.com/fatih/camelcase"
gcm "github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"
gcm "github.com/paralin/go-dota2/protocol"
"github.com/pkg/errors"
)

Expand Down
7 changes: 7 additions & 0 deletions apigen/apigen.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -eo pipefail

echo "This script should be run in GOPATH due to go-mod compatibility issues."
GO111MODULE=on go build -o apigen ./
GO111MODULE=on go mod vendor
GO111MODULE=off ./apigen generate-api
2 changes: 1 addition & 1 deletion apigen/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"sort"

"github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"
dota_gcmessages_msgid "github.com/paralin/go-dota2/protocol"
)

// IsValidMsg checks if the message is valid.
Expand Down
2 changes: 1 addition & 1 deletion apigen/msg_event_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"strings"

"github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"
dota_gcmessages_msgid "github.com/paralin/go-dota2/protocol"
)

// GetMessageEventName returns the event name for the message.
Expand Down
2 changes: 1 addition & 1 deletion apigen/msg_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"

"github.com/fatih/camelcase"
"github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"
dota_gcmessages_msgid "github.com/paralin/go-dota2/protocol"
)

// GetMessageFuncName determines what function name we should assign a message.
Expand Down
Loading

0 comments on commit 1fadfcb

Please sign in to comment.