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

View File

@@ -1,14 +0,0 @@
[hk4e]
resource_path = "./GameDataConfigTable"
gacha_history_server = "https://hk4e.flswld.com/api/v1"
[logger]
level = "DEBUG"
method = "CONSOLE"
track_line = true
[database]
url = "mongodb://mongo:27017"
[mq]
nats_url = "nats://nats1:4222,nats://nats2:4222,nats://nats3:4222"

View File

@@ -1,73 +0,0 @@
package main
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/pprof"
"os"
"os/signal"
"syscall"
"time"
)
func main() {
filePath := "./application.toml"
config.InitConfig(filePath)
logger.InitLogger("gs")
logger.LOG.Info("gs start")
go func() {
// 性能检测
err := statsviz.RegisterDefault()
if err != nil {
logger.LOG.Error("statsviz init error: %v", err)
}
err = http.ListenAndServe("0.0.0.0:3456", nil)
if err != nil {
logger.LOG.Error("perf debug http start error: %v", err)
}
}()
constant.InitConstant()
gdc.InitGameDataConfig()
db := dao.NewDao()
netMsgInput := make(chan *cmd.NetMsg, 10000)
netMsgOutput := make(chan *cmd.NetMsg, 10000)
messageQueue := mq.NewMessageQueue(netMsgInput, netMsgOutput)
messageQueue.Start()
gameManager := game.NewGameManager(db, netMsgInput, netMsgOutput)
gameManager.Start()
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
logger.LOG.Info("get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
logger.LOG.Info("gs exit")
gameManager.Stop()
db.CloseDao()
messageQueue.Close()
time.Sleep(time.Second)
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,13 +1,14 @@
package game
import (
"hk4e/common/utils/random"
"time"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/pkg/random"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"time"
)
// 游戏服务器定时帧管理器

View File

@@ -1,14 +1,15 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"hk4e/common/utils/object"
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/pkg/object"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) GetAllAvatarDataConfig() map[int32]*gdc.AvatarData {

View File

@@ -1,12 +1,14 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"time"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"time"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) PullRecentChatReq(player *model.Player, payloadMsg pb.Message) {

View File

@@ -1,11 +1,12 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Message) {

View File

@@ -1,12 +1,14 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"time"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"time"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) PlayerSetPauseReq(player *model.Player, payloadMsg pb.Message) {

View File

@@ -1,16 +1,18 @@
package game
import (
"github.com/golang-jwt/jwt/v4"
pb "google.golang.org/protobuf/proto"
"time"
"hk4e/common/config"
"hk4e/common/utils/random"
gdc "hk4e/gs/config"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/pkg/random"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"time"
"github.com/golang-jwt/jwt/v4"
pb "google.golang.org/protobuf/proto"
)
type UserInfo struct {

View File

@@ -3,7 +3,7 @@ package game
import (
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
)

View File

@@ -1,15 +1,17 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"hk4e/common/utils/reflection"
"time"
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/pkg/reflection"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"time"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) OnLogin(userId uint32, clientSeq uint32) {

View File

@@ -2,12 +2,13 @@ package game
import (
"encoding/json"
"hk4e/gs/dao"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/protocol/proto"
"sync"
"time"
"hk4e/gs/dao"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/protocol/proto"
)
type UserManager struct {

View File

@@ -1,14 +1,16 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"strconv"
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"strconv"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.Message) {

View File

@@ -1,13 +1,15 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"time"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"time"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) PlayerApplyEnterMpReq(player *model.Player, payloadMsg pb.Message) {

View File

@@ -1,17 +1,19 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"hk4e/common/utils/object"
"hk4e/common/utils/random"
"strconv"
"time"
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/pkg/object"
"hk4e/pkg/random"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"strconv"
"time"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {

View File

@@ -1,13 +1,15 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"time"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"time"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) GetShopmallDataReq(player *model.Player, payloadMsg pb.Message) {

View File

@@ -1,16 +1,18 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"hk4e/common/utils/object"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"regexp"
"time"
"unicode/utf8"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/pkg/object"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) GetPlayerSocialDetailReq(player *model.Player, payloadMsg pb.Message) {

View File

@@ -1,14 +1,15 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"hk4e/common/utils/endec"
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/endec"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Message) {

View File

@@ -3,7 +3,7 @@ package game
import (
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/logger"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
)

View File

@@ -1,16 +1,18 @@
package game
import (
pb "google.golang.org/protobuf/proto"
"hk4e/common/utils/alg"
"math"
"time"
"hk4e/gs/constant"
"hk4e/gs/game/aoi"
"hk4e/gs/model"
"hk4e/logger"
"hk4e/pkg/alg"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"math"
"time"
pb "google.golang.org/protobuf/proto"
)
// 世界管理器

View File

@@ -3,11 +3,12 @@ package game
import (
"bytes"
"encoding/gob"
"hk4e/common/utils/alg"
"unsafe"
gdc "hk4e/gs/config"
"hk4e/gs/model"
"hk4e/logger"
"unsafe"
"hk4e/pkg/alg"
"hk4e/pkg/logger"
)
// 世界的静态资源坐标点数据

View File

@@ -1,10 +1,11 @@
package model
import (
"time"
gdc "hk4e/gs/config"
"hk4e/gs/constant"
"hk4e/logger"
"time"
"hk4e/pkg/logger"
)
type Avatar struct {

View File

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