This commit is contained in:
lu.bai
2022-11-24 22:47:24 +08:00
parent f6a161d52f
commit 71d0135d6f
3213 changed files with 583576 additions and 216 deletions

3
.gitignore vendored
View File

@@ -20,6 +20,3 @@
# Binaries file # Binaries file
bin bin
# ProtoBuf generate file
*.pb.go

View File

@@ -9,4 +9,9 @@ dev_tool:
.PHONY: gen .PHONY: gen
# gen 生成代码 # gen 生成代码
gen: gen:
cd protocol/proto && make gen cd protocol/proto && make gen
.PHONY: build
# build
build:
mkdir -p bin/ && CGO_ENABLED=0 go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./cmd/...

View File

@@ -1,22 +1,23 @@
package main package main
import ( import (
"hk4e/common/config"
"hk4e/dispatch/controller"
"hk4e/dispatch/dao"
"hk4e/logger"
_ "net/http/pprof" _ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
"time" "time"
"hk4e/common/config"
"hk4e/dispatch/controller"
"hk4e/dispatch/dao"
"hk4e/pkg/logger"
) )
func main() { func main() {
filePath := "./application.toml" filePath := "./application.toml"
config.InitConfig(filePath) config.InitConfig(filePath)
logger.InitLogger("dispatch") logger.InitLogger("dispatch", config.CONF.Logger)
logger.LOG.Info("dispatch start") logger.LOG.Info("dispatch start")
db := dao.NewDao() db := dao.NewDao()

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

View File

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -1,26 +1,28 @@
package main package main
import ( import (
"github.com/arl/statsviz"
"hk4e/common/config"
"hk4e/gate/forward"
"hk4e/gate/mq"
"hk4e/gate/net"
"hk4e/logger"
"hk4e/protocol/cmd"
"net/http" "net/http"
_ "net/http/pprof" _ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
"time" "time"
"hk4e/common/config"
"hk4e/gate/forward"
"hk4e/gate/mq"
"hk4e/gate/net"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"github.com/arl/statsviz"
) )
func main() { func main() {
filePath := "./application.toml" filePath := "./application.toml"
config.InitConfig(filePath) config.InitConfig(filePath)
logger.InitLogger("gate") logger.InitLogger("gate", config.CONF.Logger)
logger.LOG.Info("gate start") logger.LOG.Info("gate start")
go func() { go func() {

View File

@@ -1,20 +1,21 @@
package main package main
import ( import (
"hk4e/common/config"
"hk4e/gm/controller"
"hk4e/logger"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
"time" "time"
"hk4e/common/config"
"hk4e/gm/controller"
"hk4e/pkg/logger"
) )
func main() { func main() {
filePath := "./application.toml" filePath := "./application.toml"
config.InitConfig(filePath) config.InitConfig(filePath)
logger.InitLogger("gm") logger.InitLogger("gm", config.CONF.Logger)
logger.LOG.Info("gm start") logger.LOG.Info("gm start")
_ = controller.NewController() _ = controller.NewController()

24
cmd/gs/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# GoLand
.idea
*.iml
# Binaries file
bin
GameDataConfigTable

View File

@@ -1,28 +1,30 @@
package main package main
import ( import (
"github.com/arl/statsviz"
"hk4e/common/config"
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/gs/dao"
"hk4e/gs/game"
"hk4e/gs/mq"
"hk4e/logger"
"hk4e/protocol/cmd"
"net/http" "net/http"
_ "net/http/pprof" _ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
"time" "time"
"hk4e/common/config"
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/gs/dao"
"hk4e/gs/game"
"hk4e/gs/mq"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"github.com/arl/statsviz"
) )
func main() { func main() {
filePath := "./application.toml" filePath := "./application.toml"
config.InitConfig(filePath) config.InitConfig(filePath)
logger.InitLogger("gs") logger.InitLogger("gs", config.CONF.Logger)
logger.LOG.Info("gs start") logger.LOG.Info("gs start")
go func() { go func() {

View File

@@ -2,6 +2,9 @@ package config
import ( import (
"fmt" "fmt"
"hk4e/pkg/logger"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
) )
@@ -9,18 +12,11 @@ var CONF *Config = nil
// 配置 // 配置
type Config struct { type Config struct {
HttpPort int `toml:"http_port"` HttpPort int `toml:"http_port"`
Logger Logger `toml:"logger"` Logger logger.Config `toml:"logger"`
Database Database `toml:"database"` Database Database `toml:"database"`
Hk4e Hk4e `toml:"hk4e"` Hk4e Hk4e `toml:"hk4e"`
MQ MQ `toml:"mq"` MQ MQ `toml:"mq"`
}
// 日志配置
type Logger struct {
Level string `toml:"level"`
Method string `toml:"method"`
TrackLine bool `toml:"track_line"`
} }
// 数据库配置 // 数据库配置

View File

@@ -2,11 +2,13 @@ package region
import ( import (
"encoding/base64" "encoding/base64"
pb "google.golang.org/protobuf/proto"
"hk4e/common/utils/endec"
"hk4e/logger"
"hk4e/protocol/proto"
"os" "os"
"hk4e/pkg/endec"
"hk4e/pkg/logger"
"hk4e/protocol/proto"
pb "google.golang.org/protobuf/proto"
) )
func LoadRsaKey() (signRsaKey []byte, encRsaKeyMap map[string][]byte, pwdRsaKey []byte) { func LoadRsaKey() (signRsaKey []byte, encRsaKeyMap map[string][]byte, pwdRsaKey []byte) {

View File

@@ -1,10 +1,12 @@
package controller package controller
import ( import (
"github.com/gin-gonic/gin"
"hk4e/logger"
"net/http" "net/http"
"os" "os"
"hk4e/pkg/logger"
"github.com/gin-gonic/gin"
) )
func (c *Controller) headDataVersions(context *gin.Context) { func (c *Controller) headDataVersions(context *gin.Context) {

View File

@@ -2,14 +2,16 @@ package controller
import ( import (
"encoding/base64" "encoding/base64"
"github.com/gin-gonic/gin" "net/http"
pb "google.golang.org/protobuf/proto" "strconv"
"hk4e/common/config" "hk4e/common/config"
"hk4e/common/region" "hk4e/common/region"
"hk4e/dispatch/dao" "hk4e/dispatch/dao"
"hk4e/logger" "hk4e/pkg/logger"
"net/http"
"strconv" "github.com/gin-gonic/gin"
pb "google.golang.org/protobuf/proto"
) )
type Controller struct { type Controller struct {

View File

@@ -3,15 +3,17 @@ package controller
import ( import (
"bytes" "bytes"
"encoding/base64" "encoding/base64"
"github.com/gin-gonic/gin"
"hk4e/common/utils/endec"
"hk4e/dispatch/entity/api"
"hk4e/logger"
"math" "math"
"net/http" "net/http"
"os" "os"
"regexp" "regexp"
"strconv" "strconv"
"hk4e/dispatch/api"
"hk4e/pkg/endec"
"hk4e/pkg/logger"
"github.com/gin-gonic/gin"
) )
func (c *Controller) query_security_file(context *gin.Context) { func (c *Controller) query_security_file(context *gin.Context) {

View File

@@ -1,11 +1,13 @@
package controller package controller
import ( import (
"github.com/gin-gonic/gin"
"hk4e/logger"
"net/http" "net/http"
"os" "os"
"strings" "strings"
"hk4e/pkg/logger"
"github.com/gin-gonic/gin"
) )
// 返回固定数据 // 返回固定数据

View File

@@ -3,18 +3,20 @@ package controller
import ( import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"github.com/gin-gonic/gin"
appConfig "hk4e/common/config"
"hk4e/common/utils/endec"
"hk4e/common/utils/httpclient"
"hk4e/common/utils/random"
"hk4e/dispatch/entity/api"
"hk4e/dispatch/entity/db"
"hk4e/logger"
"net/http" "net/http"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
appConfig "hk4e/common/config"
"hk4e/dispatch/api"
db "hk4e/dispatch/model"
"hk4e/pkg/endec"
"hk4e/pkg/httpclient"
"hk4e/pkg/logger"
"hk4e/pkg/random"
"github.com/gin-gonic/gin"
) )
type SdkUserLoginReq struct { type SdkUserLoginReq struct {

View File

@@ -2,12 +2,14 @@ package dao
import ( import (
"context" "context"
dbEntity "hk4e/dispatch/model"
"hk4e/pkg/logger"
"github.com/pkg/errors" "github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
dbEntity "hk4e/dispatch/entity/db"
"hk4e/logger"
) )
func (d *Dao) GetNextYuanShenUid() (uint64, error) { func (d *Dao) GetNextYuanShenUid() (uint64, error) {

View File

@@ -2,10 +2,12 @@ package dao
import ( import (
"context" "context"
"hk4e/common/config"
"hk4e/pkg/logger"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
"hk4e/common/config"
"hk4e/logger"
) )
type Dao struct { type Dao struct {

View File

@@ -1,4 +1,4 @@
package db package model
import "go.mongodb.org/mongo-driver/bson/primitive" import "go.mongodb.org/mongo-driver/bson/primitive"

View File

@@ -1,4 +1,4 @@
package db package model
type PlayerIDCounter struct { type PlayerIDCounter struct {
ID string `bson:"_id"` ID string `bson:"_id"`

View File

@@ -1,4 +1,4 @@
package gm package service
type ForbidUserInfo struct { type ForbidUserInfo struct {
UserId uint32 UserId uint32

View File

@@ -2,7 +2,6 @@ package service
import ( import (
"hk4e/dispatch/dao" "hk4e/dispatch/dao"
"hk4e/dispatch/entity/gm"
) )
type Service struct { type Service struct {
@@ -37,7 +36,7 @@ func (f *Service) UserPasswordChange(uid uint32) bool {
} }
// 封号 // 封号
func (f *Service) ForbidUser(info *gm.ForbidUserInfo) bool { func (f *Service) ForbidUser(info *ForbidUserInfo) bool {
if info == nil { if info == nil {
return false return false
} }

View File

@@ -1,18 +1,19 @@
package forward package forward
import ( import (
"os"
"runtime"
"sync"
"time"
"hk4e/common/config" "hk4e/common/config"
"hk4e/common/region" "hk4e/common/region"
"hk4e/gate/entity/gm" "hk4e/gate/entity/gm"
"hk4e/gate/kcp" "hk4e/gate/kcp"
"hk4e/gate/net" "hk4e/gate/net"
"hk4e/logger" "hk4e/pkg/logger"
"hk4e/protocol/cmd" "hk4e/protocol/cmd"
"hk4e/protocol/proto" "hk4e/protocol/proto"
"os"
"runtime"
"sync"
"time"
) )
const ( const (

View File

@@ -4,13 +4,14 @@ import (
"bytes" "bytes"
"encoding/base64" "encoding/base64"
"encoding/binary" "encoding/binary"
"hk4e/common/utils/endec"
"hk4e/gate/kcp"
"hk4e/gate/net"
"hk4e/logger"
"hk4e/protocol/proto"
"strconv" "strconv"
"strings" "strings"
"hk4e/gate/kcp"
"hk4e/gate/net"
"hk4e/pkg/endec"
"hk4e/pkg/logger"
"hk4e/protocol/proto"
) )
func (f *ForwardManager) getPlayerToken(convId uint64, req *proto.GetPlayerTokenReq) (rsp *proto.GetPlayerTokenRsp) { func (f *ForwardManager) getPlayerToken(convId uint64, req *proto.GetPlayerTokenReq) (rsp *proto.GetPlayerTokenRsp) {

View File

@@ -1,12 +1,13 @@
package mq package mq
import ( import (
"hk4e/common/config"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"github.com/nats-io/nats.go" "github.com/nats-io/nats.go"
"github.com/vmihailenco/msgpack/v5" "github.com/vmihailenco/msgpack/v5"
pb "google.golang.org/protobuf/proto" pb "google.golang.org/protobuf/proto"
"hk4e/common/config"
"hk4e/logger"
"hk4e/protocol/cmd"
) )
type MessageQueue struct { type MessageQueue struct {

View File

@@ -3,14 +3,15 @@ package net
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"hk4e/common/config"
"hk4e/common/utils/random"
"hk4e/gate/kcp"
"hk4e/logger"
"os" "os"
"strconv" "strconv"
"sync" "sync"
"time" "time"
"hk4e/common/config"
"hk4e/gate/kcp"
"hk4e/pkg/logger"
"hk4e/pkg/random"
) )
type KcpXorKey struct { type KcpXorKey struct {

View File

@@ -3,8 +3,9 @@ package net
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"hk4e/common/utils/endec"
"hk4e/logger" "hk4e/pkg/endec"
"hk4e/pkg/logger"
) )
/* /*

View File

@@ -1,6 +1,6 @@
package net package net
import "hk4e/logger" import "hk4e/pkg/logger"
const ( const (
KcpXorKeyChange = iota KcpXorKeyChange = iota

View File

@@ -1,10 +1,11 @@
package net package net
import ( import (
pb "google.golang.org/protobuf/proto" "hk4e/pkg/logger"
"hk4e/logger"
"hk4e/protocol/cmd" "hk4e/protocol/cmd"
"hk4e/protocol/proto" "hk4e/protocol/proto"
pb "google.golang.org/protobuf/proto"
) )
type ProtoEnDecode struct { type ProtoEnDecode struct {

View File

@@ -1,11 +1,13 @@
package controller package controller
import ( import (
"github.com/gin-gonic/gin"
"hk4e/common/config"
"hk4e/logger"
"net/http" "net/http"
"strconv" "strconv"
"hk4e/common/config"
"hk4e/pkg/logger"
"github.com/gin-gonic/gin"
) )
type Controller struct { type Controller struct {

View File

@@ -1,8 +1,9 @@
package controller package controller
import ( import (
"hk4e/pkg/logger"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"hk4e/logger"
) )
type GmCmdReq struct { type GmCmdReq struct {

View File

@@ -2,9 +2,10 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/logger"
"os" "os"
"strings" "strings"
"hk4e/pkg/logger"
) )
type AvatarConfigAbility struct { type AvatarConfigAbility struct {

View File

@@ -2,10 +2,11 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/common/utils/endec"
"hk4e/logger"
"os" "os"
"strings" "strings"
"hk4e/pkg/endec"
"hk4e/pkg/logger"
) )
type AvatarData struct { type AvatarData struct {

View File

@@ -2,9 +2,10 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/gs/constant"
"hk4e/logger"
"os" "os"
"hk4e/gs/constant"
"hk4e/pkg/logger"
) )
type AvatarSkillData struct { type AvatarSkillData struct {

View File

@@ -2,10 +2,11 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/common/utils/endec"
"hk4e/gs/constant"
"hk4e/logger"
"os" "os"
"hk4e/gs/constant"
"hk4e/pkg/endec"
"hk4e/pkg/logger"
) )
type InherentProudSkillOpens struct { type InherentProudSkillOpens struct {

View File

@@ -1,10 +1,12 @@
package config package config
import ( import (
"github.com/jszwec/csvutil"
"hk4e/logger"
"os" "os"
"strings" "strings"
"hk4e/pkg/logger"
"github.com/jszwec/csvutil"
) )
type Drop struct { type Drop struct {

View File

@@ -2,8 +2,9 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/logger"
"os" "os"
"hk4e/pkg/logger"
) )
type FetterData struct { type FetterData struct {

View File

@@ -2,9 +2,10 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/gs/constant"
"hk4e/logger"
"os" "os"
"hk4e/gs/constant"
"hk4e/pkg/logger"
) )
type GadgetData struct { type GadgetData struct {

View File

@@ -1,9 +1,10 @@
package config package config
import ( import (
appConfig "hk4e/common/config"
"hk4e/logger"
"os" "os"
appConfig "hk4e/common/config"
"hk4e/pkg/logger"
) )
var CONF *GameDataConfig = nil var CONF *GameDataConfig = nil

View File

@@ -2,8 +2,9 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/logger"
"os" "os"
"hk4e/pkg/logger"
) )
type GameDepot struct { type GameDepot struct {

View File

@@ -2,8 +2,9 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/logger"
"os" "os"
"hk4e/pkg/logger"
) )
type GatherData struct { type GatherData struct {

View File

@@ -2,9 +2,10 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/gs/constant"
"hk4e/logger"
"os" "os"
"hk4e/gs/constant"
"hk4e/pkg/logger"
) )
type ItemUseData struct { type ItemUseData struct {

View File

@@ -2,9 +2,10 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/logger"
"os" "os"
"strings" "strings"
"hk4e/pkg/logger"
) )
type SkillPointModifier struct { type SkillPointModifier struct {

View File

@@ -2,10 +2,11 @@ package config
import ( import (
"encoding/json" "encoding/json"
"hk4e/logger"
"os" "os"
"strconv" "strconv"
"strings" "strings"
"hk4e/pkg/logger"
) )
type ScenePointEntry struct { type ScenePointEntry struct {

View File

@@ -1,6 +1,6 @@
package constant package constant
import "hk4e/common/utils/endec" import "hk4e/pkg/endec"
var ElementTypeConst *ElementType var ElementTypeConst *ElementType

View File

@@ -1,6 +1,6 @@
package constant package constant
import "hk4e/common/utils/endec" import "hk4e/pkg/endec"
var GameConstantConst *GameConstant var GameConstantConst *GameConstant

View File

@@ -2,10 +2,12 @@ package dao
import ( import (
"context" "context"
"hk4e/common/config"
"hk4e/pkg/logger"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
"hk4e/common/config"
"hk4e/logger"
) )
type Dao struct { type Dao struct {

View File

@@ -2,7 +2,8 @@ package aoi
import ( import (
"fmt" "fmt"
"hk4e/logger"
"hk4e/pkg/logger"
) )
// aoi管理模块 // aoi管理模块

View File

@@ -1,15 +1,16 @@
package aoi package aoi
import ( import (
"hk4e/common/config"
"hk4e/logger"
"testing" "testing"
"hk4e/common/config"
"hk4e/pkg/logger"
) )
func TestAoiManagerGetSurrGridListByGid(t *testing.T) { func TestAoiManagerGetSurrGridListByGid(t *testing.T) {
filePath := "./application.toml" filePath := "./application.toml"
config.InitConfig(filePath) config.InitConfig(filePath)
logger.InitLogger("") logger.InitLogger("", config.CONF.Logger)
aoiManager := NewAoiManager( aoiManager := NewAoiManager(
-150, 150, 3, -150, 150, 3,
-150, 150, 3, -150, 150, 3,

View File

@@ -2,7 +2,8 @@ package aoi
import ( import (
"fmt" "fmt"
"hk4e/logger"
"hk4e/pkg/logger"
) )
// 地图格子 // 地图格子

View File

@@ -2,10 +2,11 @@ package game
import ( import (
"fmt" "fmt"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/protocol/proto"
"strings" "strings"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/protocol/proto"
) )
// CommandPerm 命令权限等级 // CommandPerm 命令权限等级

View File

@@ -1,14 +1,15 @@
package game package game
import ( import (
pb "google.golang.org/protobuf/proto"
"hk4e/common/utils/alg"
"hk4e/gate/entity/gm" "hk4e/gate/entity/gm"
"hk4e/gate/kcp" "hk4e/gate/kcp"
"hk4e/gs/dao" "hk4e/gs/dao"
"hk4e/logger" "hk4e/pkg/alg"
"hk4e/pkg/logger"
"hk4e/protocol/cmd" "hk4e/protocol/cmd"
"hk4e/protocol/proto" "hk4e/protocol/proto"
pb "google.golang.org/protobuf/proto"
) )
type GameManager struct { type GameManager struct {

View File

@@ -1,10 +1,11 @@
package game package game
import ( import (
pb "google.golang.org/protobuf/proto"
"hk4e/gs/model" "hk4e/gs/model"
"hk4e/logger" "hk4e/pkg/logger"
"hk4e/protocol/cmd" "hk4e/protocol/cmd"
pb "google.golang.org/protobuf/proto"
) )
// 接口路由管理器 // 接口路由管理器

Some files were not shown because too many files have changed in this diff Show More