Skip to content

Commit

Permalink
合并杂项功能服务器节点到multi服务器节点
Browse files Browse the repository at this point in the history
  • Loading branch information
flswld committed Oct 22, 2023
1 parent 64699c2 commit 6cca998
Show file tree
Hide file tree
Showing 42 changed files with 344 additions and 647 deletions.
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ docker_clean:
rm -rf ./docker/node/bin/node
rm -rf ./docker/dispatch/bin/dispatch
rm -rf ./docker/gate/bin/gate
rm -rf ./docker/anticheat/bin/anticheat
rm -rf ./docker/pathfinding/bin/pathfinding
rm -rf ./docker/multi/bin/multi
rm -rf ./docker/gs/bin/gs
rm -rf ./docker/gm/bin/gm
docker rmi flswld/node:$(VERSION)
docker rmi flswld/dispatch:$(VERSION)
docker rmi flswld/gate:$(VERSION)
docker rmi flswld/anticheat:$(VERSION)
docker rmi flswld/pathfinding:$(VERSION)
docker rmi flswld/multi:$(VERSION)
docker rmi flswld/gs:$(VERSION)
docker rmi flswld/gm:$(VERSION)

Expand All @@ -45,8 +43,7 @@ docker_config:
mkdir -p ./docker/node/bin && cp -rf ./cmd/node/* ./docker/node/bin/ && rm -rf ./docker/node/bin/*.go
mkdir -p ./docker/dispatch/bin && cp -rf ./cmd/dispatch/* ./docker/dispatch/bin/ && rm -rf ./docker/dispatch/bin/*.go
mkdir -p ./docker/gate/bin && cp -rf ./cmd/gate/* ./docker/gate/bin/ && rm -rf ./docker/gate/bin/*.go
mkdir -p ./docker/anticheat/bin && cp -rf ./cmd/anticheat/* ./docker/anticheat/bin/ && rm -rf ./docker/anticheat/bin/*.go
mkdir -p ./docker/pathfinding/bin && cp -rf ./cmd/pathfinding/* ./docker/pathfinding/bin/ && rm -rf ./docker/pathfinding/bin/*.go
mkdir -p ./docker/multi/bin && cp -rf ./cmd/multi/* ./docker/multi/bin/ && rm -rf ./docker/multi/bin/*.go
mkdir -p ./docker/gs/bin && cp -rf ./cmd/gs/* ./docker/gs/bin/ && rm -rf ./docker/gs/bin/*.go
mkdir -p ./docker/gm/bin && cp -rf ./cmd/gm/* ./docker/gm/bin/ && rm -rf ./docker/gm/bin/*.go

Expand All @@ -56,15 +53,13 @@ docker_build:
mkdir -p ./docker/node/bin && cp -rf ./bin/node ./docker/node/bin/
mkdir -p ./docker/dispatch/bin && cp -rf ./bin/dispatch ./docker/dispatch/bin/
mkdir -p ./docker/gate/bin && cp -rf ./bin/gate ./docker/gate/bin/
mkdir -p ./docker/anticheat/bin && cp -rf ./bin/anticheat ./docker/anticheat/bin/
mkdir -p ./docker/pathfinding/bin && cp -rf ./bin/pathfinding ./docker/pathfinding/bin/
mkdir -p ./docker/multi/bin && cp -rf ./bin/multi ./docker/multi/bin/
mkdir -p ./docker/gs/bin && cp -rf ./bin/gs ./docker/gs/bin/
mkdir -p ./docker/gm/bin && cp -rf ./bin/gm ./docker/gm/bin/
docker build -t flswld/node:$(VERSION) ./docker/node
docker build -t flswld/dispatch:$(VERSION) ./docker/dispatch
docker build -t flswld/gate:$(VERSION) ./docker/gate
docker build -t flswld/anticheat:$(VERSION) ./docker/anticheat
docker build -t flswld/pathfinding:$(VERSION) ./docker/pathfinding
docker build -t flswld/multi:$(VERSION) ./docker/multi
docker build -t flswld/gs:$(VERSION) ./docker/gs
docker build -t flswld/gm:$(VERSION) ./docker/gm

Expand Down
11 changes: 5 additions & 6 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

[Download version 3.2.0 from miHoYo](https://autopatchhk.yuanshen.com/client_app/download/pc_zip/20221024103618_h2e3o3zijYKEqHnQ/GenshinImpact_3.2.0.zip)

#### You need to use an https proxy and a patch to use it. Grasscutter is a good example.
#### You need to use a https proxy and a patch to use it. Grasscutter is a good example.

#### You can use a newer patch to avoid using https proxies. It supports custom keys and multiple servers. Special thanks to [Jx2f/mhypbase](https://github.com/Jx2f/mhypbase)

## Features

* Native high-availability cluster architecture. Crashes on any node servers won't affect the whole system. So it is
highly extendable
* Player-level non-status game server. Non-lock single thread structure. Easy to develope. And fully-featured player
* Player-level non-status game server. Non-lock single thread structure. Easy to develop. And fully-featured player
data exchanger(`Memory<->Cache<->Database`), say goodbye to
* synchronization-blocked database access
* Grand new cross-server player migration
Expand Down Expand Up @@ -48,7 +48,7 @@ make dev_tool
```shell
make gen_natsrpc # Generate natsrpc protocol
make gen_proto # Generate client protocol
make gen_client_proto # Generate client proxy protocol(not very necessary, for further informations: gate/client_proto/README.md)
make gen_client_proto # Generate client proxy protocol(not very necessary, for further information: gate/client_proto/README.md)
```

* Compile
Expand Down Expand Up @@ -78,10 +78,9 @@ docker-compose up -d # Launch server
* `node` Node server (Single node, with status)
* `dispatch` Login server (Multi nodes, without status)
* `gate` Gateway server (Multi nodes, with status)
* `anticheat` Anti-cheat server (Multi nodes, with status **STILL UNDER CONSTRUCTION**)
* `pathfinding` Path-finding server (Multi nodes, without status **STILL UNDER CONSTRUCTION**)
* `multi` Multi-function server (Multi nodes, with status **STILL UNDER CONSTRUCTION**)
* `gs` Game server (Multi nodes, with status)
* `gm` Game menagement server (Single node, without status)
* `gm` Game management server (Single node, without status)

#### Misc

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ docker-compose up -d # 启动服务器
* node 节点服务器 (仅单节点 有状态)
* dispatch 登录服务器 (可多节点 无状态)
* gate 网关服务器 (可多节点 有状态)
* anticheat 反作弊服务器 (可多节点 有状态 尚不完善非必要启动)
* pathfinding 寻路服务器 (可多节点 无状态 尚不完善非必要启动)
* multi 多功能服务器 (可多节点 有状态 尚不完善非必要启动)
* gs 游戏服务器 (可多节点 有状态)
* gm 游戏管理服务器 (仅单节点 无状态)

Expand Down
92 changes: 0 additions & 92 deletions anticheat/app/app.go

This file was deleted.

3 changes: 1 addition & 2 deletions cmd/hk4e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ func main() {
NodeCmd(),
DispatchCmd(),
GateCmd(),
AnticheatCmd(),
PathfindingCmd(),
GSCmd(),
MultiCmd(),
GMCmd(),
)

Expand Down
8 changes: 4 additions & 4 deletions cmd/hk4e/anticheat.go → cmd/hk4e/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package main
import (
"context"

"hk4e/anticheat/app"
"hk4e/multi/app"

"github.com/spf13/cobra"
)

func AnticheatCmd() *cobra.Command {
func MultiCmd() *cobra.Command {
var cfg string
app.APPVERSION = VERSION
c := &cobra.Command{
Use: "anticheat",
Short: "anticheat server",
Use: "multi",
Short: "multi server",
RunE: func(cmd *cobra.Command, args []string) error {
return app.Run(context.Background(), cfg)
},
Expand Down
23 changes: 0 additions & 23 deletions cmd/hk4e/pathfinding.go

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/anticheat/main.go → cmd/multi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
_ "net/http/pprof"
"os"

"hk4e/anticheat/app"
"hk4e/multi/app"
"hk4e/pkg/statsviz_serve"
)

Expand Down
8 changes: 0 additions & 8 deletions cmd/pathfinding/application.toml

This file was deleted.

31 changes: 0 additions & 31 deletions cmd/pathfinding/main.go

This file was deleted.

17 changes: 7 additions & 10 deletions common/mq/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewMessageQueue(serverType string, appId string, discoveryClient *rpc.Disco
r.discoveryClient = discoveryClient
if serverType == api.GATE {
go r.runGateTcpMqServer()
} else if serverType == api.GS || serverType == api.ANTICHEAT || serverType == api.PATHFINDING || serverType == api.ROBOT {
} else if serverType == api.GS || serverType == api.MULTI || serverType == api.ROBOT {
go r.runGateTcpMqClient()
}
go r.natsMsgRecvHandler()
Expand Down Expand Up @@ -170,11 +170,10 @@ func (m *MessageQueue) parseNetMsg(rawData []byte) *NetMsg {
func (m *MessageQueue) sendHandler() {
// 网关tcp连接消息收发快速通道 key1:服务器类型 key2:服务器appid value:连接实例
gateTcpMqInstMap := map[string]map[string]*GateTcpMqInst{
api.GATE: make(map[string]*GateTcpMqInst),
api.GS: make(map[string]*GateTcpMqInst),
api.ANTICHEAT: make(map[string]*GateTcpMqInst),
api.PATHFINDING: make(map[string]*GateTcpMqInst),
api.ROBOT: make(map[string]*GateTcpMqInst),
api.GATE: make(map[string]*GateTcpMqInst),
api.GS: make(map[string]*GateTcpMqInst),
api.MULTI: make(map[string]*GateTcpMqInst),
api.ROBOT: make(map[string]*GateTcpMqInst),
}
for {
select {
Expand Down Expand Up @@ -320,10 +319,8 @@ func (m *MessageQueue) gateTcpMqHandshake(conn *net.TCPConn) {
inst.serverType = api.GATE
case api.GS:
inst.serverType = api.GS
case api.ANTICHEAT:
inst.serverType = api.ANTICHEAT
case api.PATHFINDING:
inst.serverType = api.PATHFINDING
case api.MULTI:
inst.serverType = api.MULTI
case api.ROBOT:
inst.serverType = api.ROBOT
default:
Expand Down
20 changes: 10 additions & 10 deletions common/mq/net_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ const (
)

type ServerMsg struct {
AnticheatServerAppId string
UserId uint32
IsOnline bool
GameServerAppId string
JoinHostUserId uint32
PlayerMpInfo *PlayerMpInfo
ChatMsgInfo *ChatMsgInfo
AddFriendInfo *AddFriendInfo
ForwardDispatchInfo *ForwardDispatchInfo
AppVersion string
MultiServerAppId string
UserId uint32
IsOnline bool
GameServerAppId string
JoinHostUserId uint32
PlayerMpInfo *PlayerMpInfo
ChatMsgInfo *ChatMsgInfo
AddFriendInfo *AddFriendInfo
ForwardDispatchInfo *ForwardDispatchInfo
AppVersion string
}

type OriginInfo struct {
Expand Down
16 changes: 3 additions & 13 deletions common/mq/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,9 @@ func (m *MessageQueue) SendToGs(appId string, netMsg *NetMsg) {
m.netMsgInput <- netMsg
}

func (m *MessageQueue) SendToAnticheat(appId string, netMsg *NetMsg) {
netMsg.Topic = m.getTopic(api.ANTICHEAT, appId)
netMsg.ServerType = api.ANTICHEAT
netMsg.AppId = appId
originServerType, originServerAppId := m.getOriginServer()
netMsg.OriginServerType = originServerType
netMsg.OriginServerAppId = originServerAppId
m.netMsgInput <- netMsg
}

func (m *MessageQueue) SendToPathfinding(appId string, netMsg *NetMsg) {
netMsg.Topic = m.getTopic(api.PATHFINDING, appId)
netMsg.ServerType = api.PATHFINDING
func (m *MessageQueue) SendToMulti(appId string, netMsg *NetMsg) {
netMsg.Topic = m.getTopic(api.MULTI, appId)
netMsg.ServerType = api.MULTI
netMsg.AppId = appId
originServerType, originServerAppId := m.getOriginServer()
netMsg.OriginServerType = originServerType
Expand Down
Loading

0 comments on commit 6cca998

Please sign in to comment.