From 5e5492943da3e01115d0d413b9760c3b23e60837 Mon Sep 17 00:00:00 2001 From: flswld Date: Thu, 16 Mar 2023 16:26:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E9=85=8D=E7=BD=AE=E8=A1=A8?= =?UTF-8?q?=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 21 +- README.md | 7 +- {fight => anticheat}/app/app.go | 17 +- cmd/{fight => anticheat}/application.toml | 0 cmd/{fight => anticheat}/main.go | 2 +- cmd/hk4e/{fight.go => anticheat.go} | 8 +- cmd/hk4e/main.go | 2 +- common/mq/nats.go | 6 +- common/mq/net_msg.go | 34 +- common/mq/topic.go | 6 +- docker-compose.yaml | 10 +- docker/anticheat/Dockerfile | 7 + docker/fight/Dockerfile | 7 - fight/engine/fight_engine.go | 284 ---- gate/net/kcp_connect_manager.go | 4 +- gate/net/session.go | 20 +- gdconf/avatar_costume_data.go | 17 +- gdconf/avatar_data.go | 59 +- gdconf/avatar_flycloak_data.go | 17 +- gdconf/avatar_level_data.go | 17 +- gdconf/avatar_promote_data.go | 39 +- gdconf/avatar_skill_data.go | 23 +- gdconf/avatar_skill_depot_data.go | 45 +- gdconf/drop_group_data.go | 11 +- gdconf/fetter_data.go | 19 +- gdconf/game_data_config.go | 97 +- gdconf/game_data_config_test.go | 77 +- gdconf/gather_data.go | 21 +- gdconf/gcg_char_data.go | 47 +- gdconf/gcg_skill_data.go | 23 +- gdconf/item_data.go | 74 +- gdconf/player_level_data.go | 17 +- gdconf/quest_data.go | 111 +- gdconf/reliquary_affix_data.go | 21 +- gdconf/reliquary_main_data.go | 21 +- gdconf/reward_data.go | 51 +- gdconf/scene_data.go | 17 +- gdconf/scene_tag_data.go | 17 +- gdconf/table_struct_mapping.json | 1537 --------------------- gdconf/trigger_data.go | 21 +- gdconf/weapon_level_data.go | 25 +- gdconf/weapon_promote_data.go | 35 +- gdconf/world_area_data.go | 21 +- gs/game/player_common.go | 15 +- gs/game/player_multiplayer.go | 7 - gs/game/player_weapon.go | 4 +- gs/game/route_manager.go | 2 +- gs/game/world_scene.go | 29 - gs/model/player.go | 2 +- node/api/server_type.go | 2 +- node/service/discovery.go | 2 +- 51 files changed, 418 insertions(+), 2560 deletions(-) rename {fight => anticheat}/app/app.go (80%) rename cmd/{fight => anticheat}/application.toml (100%) rename cmd/{fight => anticheat}/main.go (94%) rename cmd/hk4e/{fight.go => anticheat.go} (72%) create mode 100644 docker/anticheat/Dockerfile delete mode 100644 docker/fight/Dockerfile delete mode 100644 fight/engine/fight_engine.go delete mode 100644 gdconf/table_struct_mapping.json diff --git a/Makefile b/Makefile index a8be99e7..c2209dda 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ all: build # 清理 .PHONY: clean clean: - rm -rf ./bin - rm -rf ./protocol/proto + rm -rf ./bin/* + rm -rf ./protocol/proto/* rm -rf ./gate/client_proto/client_proto_gen.go rm -rf ./gs/api/*.pb.go && rm -rf ./node/api/*.pb.go @@ -24,14 +24,14 @@ docker_clean: rm -rf ./docker/node/bin/node rm -rf ./docker/dispatch/bin/dispatch rm -rf ./docker/gate/bin/gate - rm -rf ./docker/fight/bin/fight + rm -rf ./docker/anticheat/bin/anticheat rm -rf ./docker/pathfinding/bin/pathfinding 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/fight:$(VERSION) + docker rmi flswld/anticheat:$(VERSION) docker rmi flswld/pathfinding:$(VERSION) docker rmi flswld/gs:$(VERSION) docker rmi flswld/gm:$(VERSION) @@ -43,7 +43,7 @@ docker_config: mkdir -p ./docker/node/bin && cp -rf ./cmd/node/* ./docker/node/bin/ mkdir -p ./docker/dispatch/bin && cp -rf ./cmd/dispatch/* ./docker/dispatch/bin/ mkdir -p ./docker/gate/bin && cp -rf ./cmd/gate/* ./docker/gate/bin/ - mkdir -p ./docker/fight/bin && cp -rf ./cmd/fight/* ./docker/fight/bin/ + mkdir -p ./docker/anticheat/bin && cp -rf ./cmd/anticheat/* ./docker/anticheat/bin/ mkdir -p ./docker/pathfinding/bin && cp -rf ./cmd/pathfinding/* ./docker/pathfinding/bin/ mkdir -p ./docker/gs/bin && cp -rf ./cmd/gs/* ./docker/gs/bin/ mkdir -p ./docker/gm/bin && cp -rf ./cmd/gm/* ./docker/gm/bin/ @@ -54,14 +54,14 @@ 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/fight/bin && cp -rf ./bin/fight ./docker/fight/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/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/fight:$(VERSION) ./docker/fight + docker build -t flswld/anticheat:$(VERSION) ./docker/anticheat docker build -t flswld/pathfinding:$(VERSION) ./docker/pathfinding docker build -t flswld/gs:$(VERSION) ./docker/gs docker build -t flswld/gm:$(VERSION) ./docker/gm @@ -69,7 +69,7 @@ docker_build: # 安装natsrpc生成工具 .PHONY: dev_tool dev_tool: - go install github.com/golang/protobuf/protoc-gen-go@v1.5.2 + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 go install github.com/byebyebruce/natsrpc/cmd/protoc-gen-natsrpc@develop # 生成natsrpc协议代码 @@ -101,11 +101,6 @@ gen_proto: rm -rf ../proto && mkdir -p ../proto && mv ./proto/* ../proto/ && rm -rf ./proto && \ cd ../../ -# 生成服务器配置表 -.PHONY: gen_csv -gen_csv: - cd gdconf && mkdir -p ./game_data_config/csv && go test -count=1 -v -run TestGenGdCsv . - # 生成客户端协议代理功能所需的代码 .PHONY: gen_client_proto gen_client_proto: diff --git a/README.md b/README.md index 83a16ae9..8d425539 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ * Docker >= 20.10 * Docker Compose >= 1.29 -#### 本项目未使用CGO构建,理论上Windows、Linux、MaxOS系统都可以编译运行 +#### 本项目未使用CGO构建,理论上Windows、Linux、macOS系统都可以编译运行 ## 快速启动 @@ -60,7 +60,6 @@ make docker_build # 构建镜像 * 启动 ```shell -make gen_csv # 生成配置表 cd docker # 启动前请先确保各服务器的配置文件正确(如docker/node/bin/application.toml) docker-compose up -d # 启动服务器 @@ -77,8 +76,8 @@ docker-compose up -d # 启动服务器 * node 节点服务器 (仅单节点 有状态) * dispatch 登录服务器 (可多节点 无状态) * gate 网关服务器 (可多节点 有状态) -* fight 战斗服务器 (可多节点 有状态 非必要 未启动由gs接管) -* pathfinding 寻路服务器 (可多节点 无状态 非必要 未启动由gs接管) +* anticheat 反作弊服务器 (可多节点 有状态 尚不完善非必要启动) +* pathfinding 寻路服务器 (可多节点 无状态 尚不完善非必要启动) * gs 游戏服务器 (可多节点 有状态) * gm 游戏管理服务器 (仅单节点 无状态) diff --git a/fight/app/app.go b/anticheat/app/app.go similarity index 80% rename from fight/app/app.go rename to anticheat/app/app.go index 58581432..fef3cac8 100644 --- a/fight/app/app.go +++ b/anticheat/app/app.go @@ -11,7 +11,6 @@ import ( "hk4e/common/config" "hk4e/common/mq" "hk4e/common/rpc" - "hk4e/fight/engine" "hk4e/node/api" "hk4e/pkg/logger" ) @@ -29,7 +28,7 @@ func Run(ctx context.Context, configFile string) error { // 注册到节点服务器 rsp, err := client.Discovery.RegisterServer(context.TODO(), &api.RegisterServerReq{ - ServerType: api.FIGHT, + ServerType: api.ANTICHEAT, }) if err != nil { return err @@ -40,7 +39,7 @@ func Run(ctx context.Context, configFile string) error { for { <-ticker.C _, err := client.Discovery.KeepaliveServer(context.TODO(), &api.KeepaliveServerReq{ - ServerType: api.FIGHT, + ServerType: api.ANTICHEAT, AppId: APPID, }) if err != nil { @@ -50,22 +49,20 @@ func Run(ctx context.Context, configFile string) error { }() defer func() { _, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{ - ServerType: api.FIGHT, + ServerType: api.ANTICHEAT, AppId: APPID, }) }() - logger.InitLogger("fight_" + APPID) - logger.Warn("fight start, appid: %v", APPID) + logger.InitLogger("anticheat_" + APPID) + logger.Warn("anticheat start, appid: %v", APPID) defer func() { logger.CloseLogger() }() - messageQueue := mq.NewMessageQueue(api.FIGHT, APPID, client) + messageQueue := mq.NewMessageQueue(api.ANTICHEAT, APPID, client) defer messageQueue.Close() - _ = engine.NewFightEngine(messageQueue) - c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) for { @@ -76,7 +73,7 @@ func Run(ctx context.Context, configFile string) error { logger.Warn("get a signal %s", s.String()) switch s { case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT: - logger.Warn("fight exit, appid: %v", APPID) + logger.Warn("anticheat exit, appid: %v", APPID) return nil case syscall.SIGHUP: default: diff --git a/cmd/fight/application.toml b/cmd/anticheat/application.toml similarity index 100% rename from cmd/fight/application.toml rename to cmd/anticheat/application.toml diff --git a/cmd/fight/main.go b/cmd/anticheat/main.go similarity index 94% rename from cmd/fight/main.go rename to cmd/anticheat/main.go index c46728dd..5d3c5911 100644 --- a/cmd/fight/main.go +++ b/cmd/anticheat/main.go @@ -7,7 +7,7 @@ import ( _ "net/http/pprof" "os" - "hk4e/fight/app" + "hk4e/anticheat/app" "hk4e/pkg/statsviz_serve" ) diff --git a/cmd/hk4e/fight.go b/cmd/hk4e/anticheat.go similarity index 72% rename from cmd/hk4e/fight.go rename to cmd/hk4e/anticheat.go index e7701352..492d330d 100644 --- a/cmd/hk4e/fight.go +++ b/cmd/hk4e/anticheat.go @@ -3,16 +3,16 @@ package main import ( "context" - "hk4e/fight/app" + "hk4e/anticheat/app" "github.com/spf13/cobra" ) -func FightCmd() *cobra.Command { +func AnticheatCmd() *cobra.Command { var cfg string c := &cobra.Command{ - Use: "fight", - Short: "fight server", + Use: "anticheat", + Short: "anticheat server", RunE: func(cmd *cobra.Command, args []string) error { return app.Run(context.Background(), cfg) }, diff --git a/cmd/hk4e/main.go b/cmd/hk4e/main.go index 49a5543e..818bfa85 100644 --- a/cmd/hk4e/main.go +++ b/cmd/hk4e/main.go @@ -23,7 +23,7 @@ func main() { NodeCmd(), DispatchCmd(), GateCmd(), - FightCmd(), + AnticheatCmd(), PathfindingCmd(), GSCmd(), GMCmd(), diff --git a/common/mq/nats.go b/common/mq/nats.go index 5565bade..d018a183 100644 --- a/common/mq/nats.go +++ b/common/mq/nats.go @@ -143,7 +143,7 @@ func (m *MessageQueue) sendHandler() { gateTcpMqInstMap := map[string]map[string]*GateTcpMqInst{ api.GATE: make(map[string]*GateTcpMqInst), api.GS: make(map[string]*GateTcpMqInst), - api.FIGHT: make(map[string]*GateTcpMqInst), + api.ANTICHEAT: make(map[string]*GateTcpMqInst), api.PATHFINDING: make(map[string]*GateTcpMqInst), } for { @@ -293,8 +293,8 @@ func (m *MessageQueue) gateTcpMqHandshake(conn net.Conn) { inst.serverType = api.GATE case api.GS: inst.serverType = api.GS - case api.FIGHT: - inst.serverType = api.FIGHT + case api.ANTICHEAT: + inst.serverType = api.ANTICHEAT case api.PATHFINDING: inst.serverType = api.PATHFINDING default: diff --git a/common/mq/net_msg.go b/common/mq/net_msg.go index 6633d6c9..f6ae637a 100644 --- a/common/mq/net_msg.go +++ b/common/mq/net_msg.go @@ -4,7 +4,6 @@ import pb "google.golang.org/protobuf/proto" const ( MsgTypeGame = iota // 来自客户端的游戏消息 - MsgTypeFight // 战斗服务器消息 MsgTypeConnCtrl // GATE客户端连接信息消息 MsgTypeServer // 服务器之间转发的消息 ) @@ -16,7 +15,6 @@ type NetMsg struct { AppId string `msgpack:"-"` Topic string `msgpack:"-"` GameMsg *GameMsg - FightMsg *FightMsg ConnCtrlMsg *ConnCtrlMsg ServerMsg *ServerMsg OriginServerType string @@ -50,22 +48,6 @@ type ConnCtrlMsg struct { KickReason uint32 } -const ( - AddFightRoutine = iota // 添加战斗实例 - DelFightRoutine // 删除战斗实例 - FightRoutineAddEntity // 战斗实例添加实体 - FightRoutineDelEntity // 战斗实例删除实体 -) - -type FightMsg struct { - FightRoutineId uint32 - EntityId uint32 - FightPropMap map[uint32]float32 - Uid uint32 - AvatarGuid uint64 - GateServerAppId string -} - const ( ServerAppidBindNotify = iota // 玩家连接绑定的各个服务器appid通知 ServerUserOnlineStateChangeNotify // 广播玩家上线和离线状态以及所在GS的appid @@ -77,14 +59,14 @@ const ( ) type ServerMsg struct { - FightServerAppId string - UserId uint32 - IsOnline bool - GameServerAppId string - JoinHostUserId uint32 - UserMpInfo *UserMpInfo - ChatMsgInfo *ChatMsgInfo - AddFriendInfo *AddFriendInfo + AnticheatServerAppId string + UserId uint32 + IsOnline bool + GameServerAppId string + JoinHostUserId uint32 + UserMpInfo *UserMpInfo + ChatMsgInfo *ChatMsgInfo + AddFriendInfo *AddFriendInfo } type OriginInfo struct { diff --git a/common/mq/topic.go b/common/mq/topic.go index f5209f2e..1bf3fedf 100644 --- a/common/mq/topic.go +++ b/common/mq/topic.go @@ -35,9 +35,9 @@ func (m *MessageQueue) SendToGs(appId string, netMsg *NetMsg) { m.netMsgInput <- netMsg } -func (m *MessageQueue) SendToFight(appId string, netMsg *NetMsg) { - netMsg.Topic = m.getTopic(api.FIGHT, appId) - netMsg.ServerType = api.FIGHT +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 diff --git a/docker-compose.yaml b/docker-compose.yaml index 0edcbd69..29f6750d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -67,10 +67,10 @@ services: limits: cpus: '4.00' memory: 1024M - fight_services: + anticheat_services: restart: always - image: flswld/fight:1.0.0 - container_name: fight + image: flswld/anticheat:1.0.0 + container_name: anticheat ports: - "5678:5678/tcp" environment: @@ -80,7 +80,7 @@ services: - /etc/localtime:/etc/localtime - /etc/timezone:/etc/timezone - /usr/share/zoneinfo:/usr/share/zoneinfo - - ./fight/bin/application.toml:/fight/application.toml + - ./anticheat/bin/application.toml:/anticheat/application.toml depends_on: - gate_services deploy: @@ -103,7 +103,7 @@ services: - /usr/share/zoneinfo:/usr/share/zoneinfo - ./pathfinding/bin/application.toml:/pathfinding/application.toml depends_on: - - fight_services + - anticheat_services deploy: resources: limits: diff --git a/docker/anticheat/Dockerfile b/docker/anticheat/Dockerfile new file mode 100644 index 00000000..5a20bbe6 --- /dev/null +++ b/docker/anticheat/Dockerfile @@ -0,0 +1,7 @@ +FROM ubuntu:18.04 + +WORKDIR /anticheat +COPY ./bin/anticheat ./anticheat +RUN chmod +x ./anticheat + +ENTRYPOINT ["./anticheat"] diff --git a/docker/fight/Dockerfile b/docker/fight/Dockerfile deleted file mode 100644 index 7bf8e351..00000000 --- a/docker/fight/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM ubuntu:18.04 - -WORKDIR /fight -COPY ./bin/fight ./fight -RUN chmod +x ./fight - -ENTRYPOINT ["./fight"] diff --git a/fight/engine/fight_engine.go b/fight/engine/fight_engine.go deleted file mode 100644 index b1c2859a..00000000 --- a/fight/engine/fight_engine.go +++ /dev/null @@ -1,284 +0,0 @@ -package engine - -import ( - "time" - - "hk4e/common/constant" - "hk4e/common/mq" - "hk4e/pkg/logger" - "hk4e/protocol/cmd" - "hk4e/protocol/proto" - - pb "google.golang.org/protobuf/proto" -) - -type FightEngine struct { - messageQueue *mq.MessageQueue -} - -func NewFightEngine(messageQueue *mq.MessageQueue) (r *FightEngine) { - r = new(FightEngine) - r.messageQueue = messageQueue - go r.fightHandle() - return r -} - -func (f *FightEngine) fightHandle() { - fightRoutineMsgChanMap := make(map[uint32]chan *mq.NetMsg) - fightRoutineCloseChanMap := make(map[uint32]chan bool) - userIdFightRoutineIdMap := make(map[uint32]uint32) - for { - netMsg := <-f.messageQueue.GetNetMsg() - logger.Debug("recv net msg, netMsg: %v", netMsg) - switch netMsg.MsgType { - case mq.MsgTypeGame: - gameMsg := netMsg.GameMsg - if netMsg.EventId != mq.NormalMsg { - continue - } - logger.Debug("recv game msg, gameMsg: %v", gameMsg) - fightRoutineId, exist := userIdFightRoutineIdMap[gameMsg.UserId] - if !exist { - logger.Error("could not found fight routine id by uid: %v", gameMsg.UserId) - continue - } - fightRoutineMsgChan, exist := fightRoutineMsgChanMap[fightRoutineId] - if !exist { - logger.Error("could not found fight routine msg chan by fight routine id: %v", fightRoutineId) - continue - } - fightRoutineMsgChan <- netMsg - case mq.MsgTypeFight: - fightMsg := netMsg.FightMsg - logger.Debug("recv fight msg, fightMsg: %v", fightMsg) - switch netMsg.EventId { - case mq.AddFightRoutine: - fightRoutineMsgChan := make(chan *mq.NetMsg, 1000) - fightRoutineMsgChanMap[fightMsg.FightRoutineId] = fightRoutineMsgChan - fightRoutineCloseChan := make(chan bool, 1) - fightRoutineCloseChanMap[fightMsg.FightRoutineId] = fightRoutineCloseChan - go runFightRoutine(fightMsg.FightRoutineId, fightMsg.GateServerAppId, fightRoutineMsgChan, fightRoutineCloseChan, f.messageQueue) - case mq.DelFightRoutine: - fightRoutineCloseChan, exist := fightRoutineCloseChanMap[fightMsg.FightRoutineId] - if !exist { - logger.Error("could not found fight routine close chan by fight routine id: %v", fightMsg.FightRoutineId) - continue - } - fightRoutineCloseChan <- true - case mq.FightRoutineAddEntity: - if fightMsg.Uid != 0 { - userIdFightRoutineIdMap[fightMsg.Uid] = fightMsg.FightRoutineId - } - fightRoutineMsgChan, exist := fightRoutineMsgChanMap[fightMsg.FightRoutineId] - if !exist { - logger.Error("could not found fight routine msg chan by fight routine id: %v", fightMsg.FightRoutineId) - continue - } - fightRoutineMsgChan <- netMsg - case mq.FightRoutineDelEntity: - if fightMsg.Uid != 0 { - delete(userIdFightRoutineIdMap, fightMsg.Uid) - } - fightRoutineMsgChan, exist := fightRoutineMsgChanMap[fightMsg.FightRoutineId] - if !exist { - logger.Error("could not found fight routine msg chan by fight routine id: %v", fightMsg.FightRoutineId) - continue - } - fightRoutineMsgChan <- netMsg - } - } - } -} - -// SendMsg 发送消息给客户端 -func SendMsg(messageQueue *mq.MessageQueue, cmdId uint16, userId uint32, gateAppId string, payloadMsg pb.Message) { - if userId < 100000000 || payloadMsg == nil { - return - } - gameMsg := new(mq.GameMsg) - gameMsg.UserId = userId - gameMsg.CmdId = cmdId - gameMsg.ClientSeq = 0 - // 在这里直接序列化成二进制数据 防止发送的消息内包含各种游戏数据指针 而造成并发读写的问题 - payloadMessageData, err := pb.Marshal(payloadMsg) - if err != nil { - logger.Error("parse payload msg to bin error: %v", err) - return - } - gameMsg.PayloadMessageData = payloadMessageData - messageQueue.SendToGate(gateAppId, &mq.NetMsg{ - MsgType: mq.MsgTypeGame, - EventId: mq.NormalMsg, - GameMsg: gameMsg, - }) -} - -type Entity struct { - entityId uint32 - fightPropMap map[uint32]float32 - uid uint32 - avatarGuid uint64 -} - -// FightRoutine 战局例程 -type FightRoutine struct { - messageQueue *mq.MessageQueue - entityMap map[uint32]*Entity - combatInvokeEntryList []*proto.CombatInvokeEntry - tickCount uint64 - gateAppId string -} - -func runFightRoutine(fightRoutineId uint32, gateAppId string, fightRoutineMsgChan chan *mq.NetMsg, fightRoutineCloseChan chan bool, messageQueue *mq.MessageQueue) { - f := new(FightRoutine) - f.messageQueue = messageQueue - f.entityMap = make(map[uint32]*Entity) - f.combatInvokeEntryList = make([]*proto.CombatInvokeEntry, 0) - f.tickCount = 0 - f.gateAppId = gateAppId - logger.Debug("create fight routine, fightRoutineId: %v", fightRoutineId) - ticker := time.NewTicker(time.Millisecond * 10) - for { - select { - case netMsg := <-fightRoutineMsgChan: - switch netMsg.MsgType { - case mq.MsgTypeGame: - gameMsg := netMsg.GameMsg - f.attackHandle(gameMsg) - case mq.MsgTypeFight: - fightMsg := netMsg.FightMsg - switch netMsg.EventId { - case mq.FightRoutineAddEntity: - f.entityMap[fightMsg.EntityId] = &Entity{ - entityId: fightMsg.EntityId, - fightPropMap: fightMsg.FightPropMap, - uid: fightMsg.Uid, - avatarGuid: fightMsg.AvatarGuid, - } - case mq.FightRoutineDelEntity: - delete(f.entityMap, fightMsg.EntityId) - } - } - case <-ticker.C: - f.onTick() - case <-fightRoutineCloseChan: - logger.Debug("destroy fight routine, fightRoutineId: %v", fightRoutineId) - return - } - } -} - -func (f *FightRoutine) onTick() { - f.tickCount++ - now := time.Now().UnixMilli() - if f.tickCount%5 == 0 { - f.onTick50MilliSecond(now) - } - if f.tickCount%100 == 0 { - f.onTickSecond(now) - } -} - -func (f *FightRoutine) onTick50MilliSecond(now int64) { - if len(f.combatInvokeEntryList) > 0 { - combatInvocationsNotifyAll := new(proto.CombatInvocationsNotify) - combatInvocationsNotifyAll.InvokeList = f.combatInvokeEntryList - for _, uid := range f.getAllPlayer(f.entityMap) { - SendMsg(f.messageQueue, cmd.CombatInvocationsNotify, uid, f.gateAppId, combatInvocationsNotifyAll) - } - f.combatInvokeEntryList = make([]*proto.CombatInvokeEntry, 0) - } -} - -func (f *FightRoutine) onTickSecond(now int64) { - // 改面板 - for _, entity := range f.entityMap { - if entity.uid == 0 { - continue - } - entity.fightPropMap[constant.FIGHT_PROP_CUR_ATTACK] = 1000000 - entity.fightPropMap[constant.FIGHT_PROP_CRITICAL] = 1.0 - avatarFightPropNotify := &proto.AvatarFightPropNotify{ - AvatarGuid: entity.avatarGuid, - FightPropMap: entity.fightPropMap, - } - SendMsg(f.messageQueue, cmd.AvatarFightPropNotify, entity.uid, f.gateAppId, avatarFightPropNotify) - } -} - -func (f *FightRoutine) attackHandle(gameMsg *mq.GameMsg) { - _ = gameMsg.UserId - cmdId := gameMsg.CmdId - _ = gameMsg.ClientSeq - payloadMsg := gameMsg.PayloadMessage - - switch cmdId { - case cmd.CombatInvocationsNotify: - req := payloadMsg.(*proto.CombatInvocationsNotify) - for _, entry := range req.InvokeList { - if entry.ForwardType != proto.ForwardType_FORWARD_TO_ALL { - continue - } - if entry.ArgumentType != proto.CombatTypeArgument_COMBAT_EVT_BEING_HIT { - continue - } - hitInfo := new(proto.EvtBeingHitInfo) - err := pb.Unmarshal(entry.CombatData, hitInfo) - if err != nil { - logger.Error("parse EvtBeingHitInfo error: %v", err) - continue - } - attackResult := hitInfo.AttackResult - if attackResult == nil { - logger.Error("attackResult is nil") - continue - } - // logger.Debug("run attack handler, attackResult: %v", attackResult) - target := f.entityMap[attackResult.DefenseId] - if target == nil { - logger.Error("could not found target, defense id: %v", attackResult.DefenseId) - continue - } - attackResult.Damage *= 100 - damage := attackResult.Damage - attackerId := attackResult.AttackerId - _ = attackerId - currHp := float32(0) - if target.fightPropMap != nil { - currHp = target.fightPropMap[constant.FIGHT_PROP_CUR_HP] - currHp -= damage - if currHp < 0 { - currHp = 0 - } - target.fightPropMap[constant.FIGHT_PROP_CUR_HP] = currHp - } - entityFightPropUpdateNotify := new(proto.EntityFightPropUpdateNotify) - entityFightPropUpdateNotify.EntityId = target.entityId - entityFightPropUpdateNotify.FightPropMap = make(map[uint32]float32) - entityFightPropUpdateNotify.FightPropMap[constant.FIGHT_PROP_CUR_HP] = currHp - for _, uid := range f.getAllPlayer(f.entityMap) { - SendMsg(f.messageQueue, cmd.EntityFightPropUpdateNotify, uid, f.gateAppId, entityFightPropUpdateNotify) - } - combatData, err := pb.Marshal(hitInfo) - if err != nil { - logger.Error("create combat invocations entity hit info error: %v", err) - } - entry.CombatData = combatData - f.combatInvokeEntryList = append(f.combatInvokeEntryList, entry) - } - } -} - -func (f *FightRoutine) getAllPlayer(entityMap map[uint32]*Entity) []uint32 { - uidMap := make(map[uint32]bool) - for _, entity := range entityMap { - if entity.uid != 0 { - uidMap[entity.uid] = true - } - } - uidList := make([]uint32, 0) - for uid := range uidMap { - uidList = append(uidList, uid) - } - return uidList -} diff --git a/gate/net/kcp_connect_manager.go b/gate/net/kcp_connect_manager.go index 0f0df549..17ab1d8c 100644 --- a/gate/net/kcp_connect_manager.go +++ b/gate/net/kcp_connect_manager.go @@ -162,7 +162,7 @@ func (k *KcpConnectManager) acceptHandle(listener *kcp.Listener) { xorKey: k.dispatchKey, changeXorKeyFin: false, gsServerAppId: "", - fightServerAppId: "", + anticheatServerAppId: "", pathfindingServerAppId: "", changeGameServer: false, joinHostUserId: 0, @@ -278,7 +278,7 @@ type Session struct { xorKey []byte changeXorKeyFin bool gsServerAppId string - fightServerAppId string + anticheatServerAppId string pathfindingServerAppId string changeGameServer bool joinHostUserId uint32 diff --git a/gate/net/session.go b/gate/net/session.go index b70e1580..468d1180 100644 --- a/gate/net/session.go +++ b/gate/net/session.go @@ -132,9 +132,9 @@ func (k *KcpConnectManager) recvMsgHandle(protoMsg *ProtoMsg, session *Session) }) return } - // 转发到战斗服务器 - if session.fightServerAppId != "" && protoMsg.CmdId == cmd.CombatInvocationsNotify { - k.messageQueue.SendToFight(session.fightServerAppId, &mq.NetMsg{ + // 转发到反作弊服务器 + if session.anticheatServerAppId != "" && protoMsg.CmdId == cmd.CombatInvocationsNotify { + k.messageQueue.SendToAnticheat(session.anticheatServerAppId, &mq.NetMsg{ MsgType: mq.MsgTypeGame, EventId: mq.NormalMsg, GameMsg: gameMsg, @@ -182,7 +182,7 @@ func (k *KcpConnectManager) sendMsgHandle() { session.changeGameServer = false session.joinHostUserId = 0 } else { - serverMsg.FightServerAppId = session.fightServerAppId + serverMsg.AnticheatServerAppId = session.anticheatServerAppId } k.messageQueue.SendToGs(session.gsServerAppId, &mq.NetMsg{ MsgType: mq.MsgTypeServer, @@ -255,7 +255,7 @@ func (k *KcpConnectManager) sendMsgHandle() { continue } session.gsServerAppId = serverMsg.GameServerAppId - session.fightServerAppId = "" + session.anticheatServerAppId = "" session.changeGameServer = true session.joinHostUserId = serverMsg.JoinHostUserId // 网关代发登录请求到新的GS @@ -434,13 +434,13 @@ func (k *KcpConnectManager) getPlayerToken(req *proto.GetPlayerTokenReq, session return nil } session.gsServerAppId = gsServerAppId.AppId - fightServerAppId, err := k.discovery.GetServerAppId(context.TODO(), &api.GetServerAppIdReq{ - ServerType: api.FIGHT, + anticheatServerAppId, err := k.discovery.GetServerAppId(context.TODO(), &api.GetServerAppIdReq{ + ServerType: api.ANTICHEAT, }) if err != nil { - logger.Error("get fight server appid error: %v, uid: %v", err, uid) + logger.Error("get anticheat server appid error: %v, uid: %v", err, uid) } - session.fightServerAppId = fightServerAppId.AppId + session.anticheatServerAppId = anticheatServerAppId.AppId pathfindingServerAppId, err := k.discovery.GetServerAppId(context.TODO(), &api.GetServerAppIdReq{ ServerType: api.PATHFINDING, }) @@ -449,7 +449,7 @@ func (k *KcpConnectManager) getPlayerToken(req *proto.GetPlayerTokenReq, session } session.pathfindingServerAppId = pathfindingServerAppId.AppId logger.Debug("session gs appid: %v, uid: %v", session.gsServerAppId, uid) - logger.Debug("session fight appid: %v, uid: %v", session.fightServerAppId, uid) + logger.Debug("session anticheat appid: %v, uid: %v", session.anticheatServerAppId, uid) logger.Debug("session pathfinding appid: %v, uid: %v", session.pathfindingServerAppId, uid) // 返回响应 rsp := new(proto.GetPlayerTokenRsp) diff --git a/gdconf/avatar_costume_data.go b/gdconf/avatar_costume_data.go index 6b558495..63eae155 100644 --- a/gdconf/avatar_costume_data.go +++ b/gdconf/avatar_costume_data.go @@ -1,28 +1,19 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // AvatarCostumeData 角色时装配置表 type AvatarCostumeData struct { - CostumeID int32 `csv:"CostumeID"` // 时装ID - ItemID int32 `csv:"ItemID,omitempty"` // 道具ID + CostumeID int32 `csv:"时装ID"` + ItemID int32 `csv:"道具ID,omitempty"` } func (g *GameDataConfig) loadAvatarCostumeData() { g.AvatarCostumeDataMap = make(map[int32]*AvatarCostumeData) - data := g.readCsvFileData("AvatarCostumeData.csv") - var avatarCostumeDataList []*AvatarCostumeData - err := csvutil.Unmarshal(data, &avatarCostumeDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + avatarCostumeDataList := make([]*AvatarCostumeData, 0) + readTable[AvatarCostumeData](g.tablePrefix+"AvatarCostumeData.txt", &avatarCostumeDataList) for _, avatarCostumeData := range avatarCostumeDataList { // 屏蔽默认时装 if avatarCostumeData.ItemID == 0 { diff --git a/gdconf/avatar_data.go b/gdconf/avatar_data.go index 3deb2f04..f591a74e 100644 --- a/gdconf/avatar_data.go +++ b/gdconf/avatar_data.go @@ -3,32 +3,29 @@ package gdconf import ( "fmt" "os" - "strconv" - "strings" "hk4e/pkg/endec" "hk4e/pkg/logger" "github.com/hjson/hjson-go/v4" - "github.com/jszwec/csvutil" ) // AvatarData 角色配置表 type AvatarData struct { - AvatarId int32 `csv:"AvatarId"` // ID - HpBase float32 `csv:"HpBase,omitempty"` // 基础生命值 - AttackBase float32 `csv:"AttackBase,omitempty"` // 基础攻击力 - DefenseBase float32 `csv:"DefenseBase,omitempty"` // 基础防御力 - Critical float32 `csv:"Critical,omitempty"` // 暴击率 - CriticalHurt float32 `csv:"CriticalHurt,omitempty"` // 暴击伤害 - QualityType int32 `csv:"QualityType,omitempty"` // 角色品质 - ConfigJson string `csv:"ConfigJson,omitempty"` // 战斗config - InitialWeapon int32 `csv:"InitialWeapon,omitempty"` // 初始武器 - WeaponType int32 `csv:"WeaponType,omitempty"` // 武器种类 - SkillDepotId int32 `csv:"SkillDepotId,omitempty"` // 技能库ID - PromoteId int32 `csv:"PromoteId,omitempty"` // 角色突破ID - PromoteRewardLevelStr string `csv:"PromoteRewardLevelStr,omitempty"` // 角色突破奖励获取等阶 - PromoteRewardStr string `csv:"PromoteRewardStr,omitempty"` // 角色突破奖励 + AvatarId int32 `csv:"ID"` + HpBase float32 `csv:"基础生命值,omitempty"` + AttackBase float32 `csv:"基础攻击力,omitempty"` + DefenseBase float32 `csv:"基础防御力,omitempty"` + Critical float32 `csv:"暴击率,omitempty"` + CriticalHurt float32 `csv:"暴击伤害,omitempty"` + QualityType int32 `csv:"角色品质,omitempty"` + ConfigJson string `csv:"战斗config,omitempty"` + InitialWeapon int32 `csv:"初始武器,omitempty"` + WeaponType int32 `csv:"武器种类,omitempty"` + SkillDepotId int32 `csv:"技能库ID,omitempty"` + PromoteId int32 `csv:"角色突破ID,omitempty"` + PromoteRewardLevel IntArray `csv:"角色突破奖励获取等阶,omitempty"` + PromoteReward IntArray `csv:"角色突破奖励,omitempty"` AbilityHashCodeList []int32 PromoteRewardMap map[uint32]uint32 @@ -45,13 +42,8 @@ type ConfigAvatarAbility struct { func (g *GameDataConfig) loadAvatarData() { g.AvatarDataMap = make(map[int32]*AvatarData) - data := g.readCsvFileData("AvatarData.csv") - var avatarDataList []*AvatarData - err := csvutil.Unmarshal(data, &avatarDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + avatarDataList := make([]*AvatarData, 0) + readTable[AvatarData](g.tablePrefix+"AvatarData.txt", &avatarDataList) for _, avatarData := range avatarDataList { // 读取战斗config解析技能并转化为哈希码 fileData, err := os.ReadFile(g.jsonPrefix + "avatar/" + avatarData.ConfigJson + ".json") @@ -73,21 +65,10 @@ func (g *GameDataConfig) loadAvatarData() { avatarData.AbilityHashCodeList = append(avatarData.AbilityHashCodeList, abilityHashCode) } // 突破奖励转换列表 - if avatarData.PromoteRewardLevelStr != "" && avatarData.PromoteRewardStr != "" { - tempRewardLevelList := strings.Split(strings.ReplaceAll(avatarData.PromoteRewardLevelStr, " ", ""), "#") - tempRewardList := strings.Split(strings.ReplaceAll(avatarData.PromoteRewardStr, " ", ""), "#") - avatarData.PromoteRewardMap = make(map[uint32]uint32, len(tempRewardList)) - for i, s := range tempRewardList { - promoteLevel, err := strconv.Atoi(tempRewardLevelList[i]) - if err != nil { - logger.Error("level to i err, %v", err) - return - } - rewardId, err := strconv.Atoi(s) - if err != nil { - logger.Error("reward id to i err, %v", err) - return - } + if len(avatarData.PromoteRewardLevel) != 0 && len(avatarData.PromoteReward) != 0 { + avatarData.PromoteRewardMap = make(map[uint32]uint32, len(avatarData.PromoteReward)) + for index, rewardId := range avatarData.PromoteReward { + promoteLevel := avatarData.PromoteRewardLevel[index] avatarData.PromoteRewardMap[uint32(promoteLevel)] = uint32(rewardId) } } diff --git a/gdconf/avatar_flycloak_data.go b/gdconf/avatar_flycloak_data.go index 89a6cdee..cbc3e326 100644 --- a/gdconf/avatar_flycloak_data.go +++ b/gdconf/avatar_flycloak_data.go @@ -1,28 +1,19 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // AvatarFlycloakData 角色风之翼配置表 type AvatarFlycloakData struct { - FlycloakID int32 `csv:"FlycloakID"` // 风之翼ID - ItemID int32 `csv:"ItemID,omitempty"` // 道具ID + FlycloakID int32 `csv:"风之翼ID"` + ItemID int32 `csv:"道具ID,omitempty"` } func (g *GameDataConfig) loadAvatarFlycloakData() { g.AvatarFlycloakDataMap = make(map[int32]*AvatarFlycloakData) - data := g.readCsvFileData("AvatarFlycloakData.csv") - var avatarFlycloakDataList []*AvatarFlycloakData - err := csvutil.Unmarshal(data, &avatarFlycloakDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + avatarFlycloakDataList := make([]*AvatarFlycloakData, 0) + readTable[AvatarFlycloakData](g.tablePrefix+"AvatarFlycloakData.txt", &avatarFlycloakDataList) for _, avatarFlycloakData := range avatarFlycloakDataList { // list -> map g.AvatarFlycloakDataMap[avatarFlycloakData.FlycloakID] = avatarFlycloakData diff --git a/gdconf/avatar_level_data.go b/gdconf/avatar_level_data.go index e36ac35b..a7e8c54f 100644 --- a/gdconf/avatar_level_data.go +++ b/gdconf/avatar_level_data.go @@ -1,28 +1,19 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // AvatarLevelData 角色等级配置表 type AvatarLevelData struct { - Level int32 `csv:"Level"` // 等级 - Exp int32 `csv:"Exp,omitempty"` // 升到下一级所需经验 + Level int32 `csv:"等级"` + Exp int32 `csv:"升到下一级所需经验,omitempty"` } func (g *GameDataConfig) loadAvatarLevelData() { g.AvatarLevelDataMap = make(map[int32]*AvatarLevelData) - data := g.readCsvFileData("AvatarLevelData.csv") - var avatarLevelDataList []*AvatarLevelData - err := csvutil.Unmarshal(data, &avatarLevelDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + avatarLevelDataList := make([]*AvatarLevelData, 0) + readTable[AvatarLevelData](g.tablePrefix+"AvatarLevelData.txt", &avatarLevelDataList) for _, avatarLevelData := range avatarLevelDataList { // list -> map g.AvatarLevelDataMap[avatarLevelData.Level] = avatarLevelData diff --git a/gdconf/avatar_promote_data.go b/gdconf/avatar_promote_data.go index bc5c4061..acc03676 100644 --- a/gdconf/avatar_promote_data.go +++ b/gdconf/avatar_promote_data.go @@ -1,41 +1,32 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // AvatarPromoteData 角色突破配置表 type AvatarPromoteData struct { - PromoteId int32 `csv:"PromoteId"` // 角色突破ID - PromoteLevel int32 `csv:"PromoteLevel,omitempty"` // 突破等级 - CostCoin int32 `csv:"CostCoin,omitempty"` // 消耗金币 - CostItemId1 int32 `csv:"CostItemId1,omitempty"` // [消耗物品]1ID - CostItemCount1 int32 `csv:"CostItemCount1,omitempty"` // [消耗物品]1数量 - CostItemId2 int32 `csv:"CostItemId2,omitempty"` // [消耗物品]2ID - CostItemCount2 int32 `csv:"CostItemCount2,omitempty"` // [消耗物品]2数量 - CostItemId3 int32 `csv:"CostItemId3,omitempty"` // [消耗物品]3ID - CostItemCount3 int32 `csv:"CostItemCount3,omitempty"` // [消耗物品]3数量 - CostItemId4 int32 `csv:"CostItemId4,omitempty"` // [消耗物品]4ID - CostItemCount4 int32 `csv:"CostItemCount4,omitempty"` // [消耗物品]4数量 - LevelLimit int32 `csv:"LevelLimit,omitempty"` // 解锁等级上限 - MinPlayerLevel int32 `csv:"MinPlayerLevel,omitempty"` // 冒险等级要求 + PromoteId int32 `csv:"角色突破ID"` + PromoteLevel int32 `csv:"突破等级,omitempty"` + CostCoin int32 `csv:"消耗金币,omitempty"` + CostItemId1 int32 `csv:"[消耗物品]1ID,omitempty"` + CostItemCount1 int32 `csv:"[消耗物品]1数量,omitempty"` + CostItemId2 int32 `csv:"[消耗物品]2ID,omitempty"` + CostItemCount2 int32 `csv:"[消耗物品]2数量,omitempty"` + CostItemId3 int32 `csv:"[消耗物品]3ID,omitempty"` + CostItemCount3 int32 `csv:"[消耗物品]3数量,omitempty"` + CostItemId4 int32 `csv:"[消耗物品]4ID,omitempty"` + CostItemCount4 int32 `csv:"[消耗物品]4数量,omitempty"` + LevelLimit int32 `csv:"解锁等级上限,omitempty"` + MinPlayerLevel int32 `csv:"冒险等级要求,omitempty"` CostItemMap map[uint32]uint32 // 消耗物品列表 } func (g *GameDataConfig) loadAvatarPromoteData() { g.AvatarPromoteDataMap = make(map[int32]map[int32]*AvatarPromoteData) - data := g.readCsvFileData("AvatarPromoteData.csv") - var avatarPromoteDataList []*AvatarPromoteData - err := csvutil.Unmarshal(data, &avatarPromoteDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + avatarPromoteDataList := make([]*AvatarPromoteData, 0) + readTable[AvatarPromoteData](g.tablePrefix+"AvatarPromoteData.txt", &avatarPromoteDataList) for _, avatarPromoteData := range avatarPromoteDataList { // list -> map _, ok := g.AvatarPromoteDataMap[avatarPromoteData.PromoteId] diff --git a/gdconf/avatar_skill_data.go b/gdconf/avatar_skill_data.go index 773c0b3f..7589f5f5 100644 --- a/gdconf/avatar_skill_data.go +++ b/gdconf/avatar_skill_data.go @@ -1,32 +1,23 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // AvatarSkillData 角色技能配置表 type AvatarSkillData struct { - AvatarSkillId int32 `csv:"AvatarSkillId"` // ID - AbilityName string `csv:"AbilityName,omitempty"` // Ability名称 + AvatarSkillId int32 `csv:"ID"` + AbilityName string `csv:"Ability名称,omitempty"` // TODO 这个字段实际上并不是拿来直接扣体力的 体力应该由ability来做 但是现在我捋不清所以摆烂了 改了一下表暂时先这么用着 - CostStamina int32 `csv:"CostStamina,omitempty"` // 消耗体力 - CostElemType int32 `csv:"CostElemType,omitempty"` // 消耗能量类型 - CostElemVal int32 `csv:"CostElemVal,omitempty"` // 消耗能量值 + CostStamina int32 `csv:"消耗体力,omitempty"` + CostElemType int32 `csv:"消耗能量类型,omitempty"` + CostElemVal int32 `csv:"消耗能量值,omitempty"` } func (g *GameDataConfig) loadAvatarSkillData() { g.AvatarSkillDataMap = make(map[int32]*AvatarSkillData) - data := g.readCsvFileData("AvatarSkillData.csv") - var avatarSkillDataList []*AvatarSkillData - err := csvutil.Unmarshal(data, &avatarSkillDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + avatarSkillDataList := make([]*AvatarSkillData, 0) + readTable[AvatarSkillData](g.tablePrefix+"AvatarSkillData.txt", &avatarSkillDataList) for _, avatarSkillData := range avatarSkillDataList { // list -> map g.AvatarSkillDataMap[avatarSkillData.AvatarSkillId] = avatarSkillData diff --git a/gdconf/avatar_skill_depot_data.go b/gdconf/avatar_skill_depot_data.go index fe754f63..500453f0 100644 --- a/gdconf/avatar_skill_depot_data.go +++ b/gdconf/avatar_skill_depot_data.go @@ -8,28 +8,27 @@ import ( "hk4e/pkg/logger" "github.com/hjson/hjson-go/v4" - "github.com/jszwec/csvutil" ) // AvatarSkillDepotData 角色技能库配置表 type AvatarSkillDepotData struct { - AvatarSkillDepotId int32 `csv:"AvatarSkillDepotId"` // ID - EnergySkill int32 `csv:"EnergySkill,omitempty"` // 充能技能 - Skill1 int32 `csv:"Skill1,omitempty"` // 技能1 - Skill2 int32 `csv:"Skill2,omitempty"` // 技能2 - Skill3 int32 `csv:"Skill3,omitempty"` // 技能3 - Skill4 int32 `csv:"Skill4,omitempty"` // 技能4 - ProudSkill1GroupId int32 `csv:"ProudSkill1GroupId,omitempty"` // 固有得意技组1ID - ProudSkill1NeedAvatarPromoteLevel int32 `csv:"ProudSkill1NeedAvatarPromoteLevel,omitempty"` // 固有得意技组1激活所需角色突破等级 - ProudSkill2GroupId int32 `csv:"ProudSkill2GroupId,omitempty"` // 固有得意技组2ID - ProudSkill2NeedAvatarPromoteLevel int32 `csv:"ProudSkill2NeedAvatarPromoteLevel,omitempty"` // 固有得意技组2激活所需角色突破等级 - ProudSkill3GroupId int32 `csv:"ProudSkill3GroupId,omitempty"` // 固有得意技组3ID - ProudSkill3NeedAvatarPromoteLevel int32 `csv:"ProudSkill3NeedAvatarPromoteLevel,omitempty"` // 固有得意技组3激活所需角色突破等级 - ProudSkill4GroupId int32 `csv:"ProudSkill4GroupId,omitempty"` // 固有得意技组4ID - ProudSkill4NeedAvatarPromoteLevel int32 `csv:"ProudSkill4NeedAvatarPromoteLevel,omitempty"` // 固有得意技组4激活所需角色突破等级 - ProudSkill5GroupId int32 `csv:"ProudSkill5GroupId,omitempty"` // 固有得意技组5ID - ProudSkill5NeedAvatarPromoteLevel int32 `csv:"ProudSkill5NeedAvatarPromoteLevel,omitempty"` // 固有得意技组5激活所需角色突破等级 - SkillDepotAbilityGroup string `csv:"SkillDepotAbilityGroup,omitempty"` // AbilityGroup + AvatarSkillDepotId int32 `csv:"ID"` + EnergySkill int32 `csv:"充能技能,omitempty"` + Skill1 int32 `csv:"技能1,omitempty"` + Skill2 int32 `csv:"技能2,omitempty"` + Skill3 int32 `csv:"技能3,omitempty"` + Skill4 int32 `csv:"技能4,omitempty"` + ProudSkill1GroupId int32 `csv:"固有得意技组1ID,omitempty"` + ProudSkill1NeedAvatarPromoteLevel int32 `csv:"固有得意技组1激活所需角色突破等级,omitempty"` + ProudSkill2GroupId int32 `csv:"固有得意技组2ID,omitempty"` + ProudSkill2NeedAvatarPromoteLevel int32 `csv:"固有得意技组2激活所需角色突破等级,omitempty"` + ProudSkill3GroupId int32 `csv:"固有得意技组3ID,omitempty"` + ProudSkill3NeedAvatarPromoteLevel int32 `csv:"固有得意技组3激活所需角色突破等级,omitempty"` + ProudSkill4GroupId int32 `csv:"固有得意技组4ID,omitempty"` + ProudSkill4NeedAvatarPromoteLevel int32 `csv:"固有得意技组4激活所需角色突破等级,omitempty"` + ProudSkill5GroupId int32 `csv:"固有得意技组5ID,omitempty"` + ProudSkill5NeedAvatarPromoteLevel int32 `csv:"固有得意技组5激活所需角色突破等级,omitempty"` + SkillDepotAbilityGroup string `csv:"AbilityGroup,omitempty"` Skills []int32 InherentProudSkillOpens []*InherentProudSkillOpens @@ -43,14 +42,8 @@ type InherentProudSkillOpens struct { func (g *GameDataConfig) loadAvatarSkillDepotData() { g.AvatarSkillDepotDataMap = make(map[int32]*AvatarSkillDepotData) - data := g.readCsvFileData("AvatarSkillDepotData.csv") - var avatarSkillDepotDataList []*AvatarSkillDepotData - err := csvutil.Unmarshal(data, &avatarSkillDepotDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } - + avatarSkillDepotDataList := make([]*AvatarSkillDepotData, 0) + readTable[AvatarSkillDepotData](g.tablePrefix+"AvatarSkillDepotData.txt", &avatarSkillDepotDataList) playerElementsFilePath := g.jsonPrefix + "ability_group/AbilityGroup_Other_PlayerElementAbility.json" playerElementsFile, err := os.ReadFile(playerElementsFilePath) if err != nil { diff --git a/gdconf/drop_group_data.go b/gdconf/drop_group_data.go index f96bd5fb..5c7dc693 100644 --- a/gdconf/drop_group_data.go +++ b/gdconf/drop_group_data.go @@ -2,8 +2,6 @@ package gdconf import ( "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // 当初写卡池算法的时候临时建立的表 以后再做迁移吧 @@ -25,13 +23,8 @@ func (g *GameDataConfig) loadDropGroupData() { g.DropGroupDataMap = make(map[int32]*DropGroupData) fileNameList := []string{"DropGachaAvatarUp.csv", "DropGachaWeaponUp.csv", "DropGachaNormal.csv"} for _, fileName := range fileNameList { - data := g.readCsvFileData("../ext/" + fileName) - var dropList []*Drop - err := csvutil.Unmarshal(data, &dropList) - if err != nil { - logger.Error("parse file error: %v", err) - return - } + dropList := make([]*Drop, 0) + readExtCsv[Drop](g.extPrefix+fileName, &dropList) for _, drop := range dropList { dropGroupData, exist := g.DropGroupDataMap[drop.DropId] if !exist { diff --git a/gdconf/fetter_data.go b/gdconf/fetter_data.go index 0d6a1f3b..2f2ccee9 100644 --- a/gdconf/fetter_data.go +++ b/gdconf/fetter_data.go @@ -1,31 +1,22 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // FetterData 角色资料解锁配置表 type FetterData struct { - FetterId int32 `csv:"FetterId"` // ID - AvatarId int32 `csv:"AvatarId"` // 角色ID + FetterId int32 `csv:"ID"` + AvatarId int32 `csv:"角色ID"` } func (g *GameDataConfig) loadFetterData() { g.FetterDataMap = make(map[int32]*FetterData) g.FetterDataAvatarIdMap = make(map[int32][]int32) - fileNameList := []string{"FettersData.csv", "FetterDataStory.csv", "FetterDataIformation.csv", "PhotographExpressionName.csv", "PhotographPoseName.csv"} + fileNameList := []string{"FettersData.txt", "FetterDataStory.txt", "FetterDataIformation.txt", "PhotographExpressionName.txt", "PhotographPoseName.txt"} for _, fileName := range fileNameList { - data := g.readCsvFileData(fileName) - var fetterDataList []*FetterData - err := csvutil.Unmarshal(data, &fetterDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + fetterDataList := make([]*FetterData, 0) + readTable[FetterData](g.tablePrefix+fileName, &fetterDataList) for _, fetterData := range fetterDataList { // list -> map g.FetterDataMap[fetterData.FetterId] = fetterData diff --git a/gdconf/game_data_config.go b/gdconf/game_data_config.go index a0533974..b8016c44 100644 --- a/gdconf/game_data_config.go +++ b/gdconf/game_data_config.go @@ -1,10 +1,14 @@ package gdconf import ( + "bytes" + "encoding/csv" "encoding/json" "fmt" + "io" "os" "runtime" + "strconv" "strings" "time" @@ -12,6 +16,7 @@ import ( "hk4e/common/constant" "hk4e/pkg/logger" + "github.com/jszwec/csvutil" lua "github.com/yuin/gopher-lua" ) @@ -22,9 +27,10 @@ var CONF_RELOAD *GameDataConfig = nil type GameDataConfig struct { // 配置表路径前缀 - csvPrefix string - jsonPrefix string - luaPrefix string + tablePrefix string + jsonPrefix string + luaPrefix string + extPrefix string // 配置表数据 AvatarDataMap map[int32]*AvatarData // 角色 AvatarSkillDataMap map[int32]*AvatarSkillData // 角色技能 @@ -89,13 +95,13 @@ func (g *GameDataConfig) loadAll() { panic(info) } - g.csvPrefix = pathPrefix + "/csv" - dirInfo, err = os.Stat(g.csvPrefix) + g.tablePrefix = pathPrefix + "/txt" + dirInfo, err = os.Stat(g.tablePrefix) if err != nil || !dirInfo.IsDir() { - info := fmt.Sprintf("open game data config csv dir error: %v", err) + info := fmt.Sprintf("open game data config txt dir error: %v", err) panic(info) } - g.csvPrefix += "/" + g.tablePrefix += "/" g.jsonPrefix = pathPrefix + "/json" dirInfo, err = os.Stat(g.jsonPrefix) @@ -113,6 +119,14 @@ func (g *GameDataConfig) loadAll() { } g.luaPrefix += "/" + g.extPrefix = pathPrefix + "/ext" + dirInfo, err = os.Stat(g.extPrefix) + if err != nil || !dirInfo.IsDir() { + info := fmt.Sprintf("open game data config ext dir error: %v", err) + panic(info) + } + g.extPrefix += "/" + g.load() } @@ -147,8 +161,38 @@ func (g *GameDataConfig) load() { g.loadTriggerData() // 场景LUA触发器 } -func (g *GameDataConfig) readCsvFileData(fileName string) []byte { - fileData, err := os.ReadFile(g.csvPrefix + fileName) +// CSV相关 + +func splitStringArray(str string) []string { + if str == "" { + return make([]string, 0) + } else if strings.Contains(str, ";") { + return strings.Split(str, ";") + } else if strings.Contains(str, ",") { + return strings.Split(str, ",") + } else { + return []string{str} + } +} + +type IntArray []int32 + +func (a *IntArray) UnmarshalCSV(data []byte) error { + str := string(data) + str = strings.ReplaceAll(str, " ", "") + intStrList := splitStringArray(str) + for _, intStr := range intStrList { + v, err := strconv.ParseInt(intStr, 10, 32) + if err != nil { + panic(err) + } + *a = append(*a, int32(v)) + } + return nil +} + +func readExtCsv[T any](tablePath string, table *[]*T) { + fileData, err := os.ReadFile(tablePath) if err != nil { info := fmt.Sprintf("open file error: %v", err) panic(info) @@ -160,9 +204,42 @@ func (g *GameDataConfig) readCsvFileData(fileName string) []byte { standardCsvData := make([]byte, 0) standardCsvData = append(standardCsvData, fileData[:index1]...) standardCsvData = append(standardCsvData, fileData[index3+(index2+1)+(index1+1):]...) - return standardCsvData + err = csvutil.Unmarshal(standardCsvData, table) + if err != nil { + info := fmt.Sprintf("parse file error: %v", err) + panic(info) + } } +func readTable[T any](tablePath string, table *[]*T) { + fileData, err := os.ReadFile(tablePath) + if err != nil { + info := fmt.Sprintf("open file error: %v", err) + panic(info) + } + reader := csv.NewReader(bytes.NewBuffer(fileData)) + reader.Comma = '\t' + dec, err := csvutil.NewDecoder(reader) + if err != nil { + info := fmt.Sprintf("create decoder error: %v", err) + panic(info) + } + for { + t := new(T) + err := dec.Decode(t) + if err == io.EOF { + break + } + if err != nil { + info := fmt.Sprintf("decode file error: %v", err) + panic(info) + } + *table = append(*table, t) + } +} + +// LUA相关 + type ScriptLibFunc struct { fnName string fn lua.LGFunction diff --git a/gdconf/game_data_config_test.go b/gdconf/game_data_config_test.go index 88a8647b..6873c242 100644 --- a/gdconf/game_data_config_test.go +++ b/gdconf/game_data_config_test.go @@ -1,11 +1,9 @@ package gdconf import ( - "encoding/json" "image" "image/color" "image/jpeg" - "log" "os" "strings" "testing" @@ -17,79 +15,6 @@ import ( "github.com/hjson/hjson-go/v4" ) -type TableField struct { - FieldName string `json:"field_name"` - FieldType string `json:"field_type"` - OriginName string `json:"origin_name"` -} - -type TableStructMapping struct { - TableName string `json:"table_name"` - FieldList []*TableField `json:"field_list"` -} - -// 生成最终服务器读取的配置表 -func TestGenGdCsv(t *testing.T) { - tableStructMappingList := make([]*TableStructMapping, 0) - configFileData, err := os.ReadFile("./table_struct_mapping.json") - if err != nil { - log.Printf("open config file error: %v", err) - return - } - err = json.Unmarshal(configFileData, &tableStructMappingList) - if err != nil { - log.Printf("parse config file error: %v", err) - return - } - for _, tableStructMapping := range tableStructMappingList { - txtFileData, err := os.ReadFile("./game_data_config/txt/" + tableStructMapping.TableName + ".txt") - if err != nil { - log.Printf("read txt file error: %v", err) - continue - } - // 转换txt配置表格式为csv - originCsv := string(txtFileData) - originCsv = strings.ReplaceAll(originCsv, "\r\n", "\n") - originCsv = strings.ReplaceAll(originCsv, "\r", "\n") - originCsv = strings.ReplaceAll(originCsv, ",", "#") - originCsv = strings.ReplaceAll(originCsv, ";", "#") - originCsv = strings.ReplaceAll(originCsv, "\t", ",") - originCsvLineList := strings.Split(originCsv, "\n") - if len(originCsvLineList) == 0 { - log.Printf("origin csv file is empty") - continue - } - originCsvHeadList := strings.Split(originCsvLineList[0], ",") - if len(originCsvHeadList) == 0 { - log.Printf("origin csv file head is empty") - continue - } - fieldNameHead := "" - fieldTypeHead := "" - for index, originCsvHead := range originCsvHeadList { - for _, tableField := range tableStructMapping.FieldList { - if originCsvHead == tableField.OriginName { - // 字段名匹配成功 - fieldNameHead += tableField.FieldName - fieldTypeHead += tableField.FieldType - } - } - if index < len(originCsvHeadList)-1 { - fieldNameHead += "," - fieldTypeHead += "," - } - } - fieldNameHead += "\n" - fieldTypeHead += "\n" - gdCsvFile := fieldNameHead + fieldTypeHead + originCsv - err = os.WriteFile("./game_data_config/csv/"+tableStructMapping.TableName+".csv", []byte(gdCsvFile), 0644) - if err != nil { - log.Printf("write gd csv file error: %v", err) - continue - } - } -} - // 测试初始化加载配置表 func TestInitGameDataConfig(t *testing.T) { config.InitConfig("./bin/application.toml") @@ -99,7 +24,7 @@ func TestInitGameDataConfig(t *testing.T) { }() logger.Info("start load conf") InitGameDataConfig() - logger.Info("load conf finish, conf: %v", CONF) + logger.Info("load conf finish") time.Sleep(time.Second) } diff --git a/gdconf/gather_data.go b/gdconf/gather_data.go index a9f51097..81ee8fba 100644 --- a/gdconf/gather_data.go +++ b/gdconf/gather_data.go @@ -1,30 +1,21 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // GatherData 采集物配置表 type GatherData struct { - PointType int32 `csv:"PointType"` // 挂节点类型 - GatherId int32 `csv:"GatherId"` // ID - GadgetId int32 `csv:"GadgetId"` // 采集物ID - ItemId int32 `csv:"ItemId"` // 获得物品ID + PointType int32 `csv:"挂节点类型"` + GatherId int32 `csv:"ID"` + GadgetId int32 `csv:"采集物ID"` + ItemId int32 `csv:"获得物品ID"` } func (g *GameDataConfig) loadGatherData() { g.GatherDataMap = make(map[int32]*GatherData) - data := g.readCsvFileData("GatherData.csv") - var gatherDataList []*GatherData - err := csvutil.Unmarshal(data, &gatherDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + gatherDataList := make([]*GatherData, 0) + readTable[GatherData](g.tablePrefix+"GatherData.txt", &gatherDataList) g.GatherDataPointTypeMap = make(map[int32]*GatherData) for _, gatherData := range gatherDataList { // list -> map diff --git a/gdconf/gcg_char_data.go b/gdconf/gcg_char_data.go index 90804ff8..3dad39ac 100644 --- a/gdconf/gcg_char_data.go +++ b/gdconf/gcg_char_data.go @@ -1,40 +1,28 @@ package gdconf import ( - "fmt" - "strconv" - "strings" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // GCGCharData 角色卡牌配置表 type GCGCharData struct { - CharId int32 `csv:"CharId"` // ID - TagId1 int32 `csv:"TagId1,omitempty"` // 卡牌标签列表1 - TagId2 int32 `csv:"TagId2,omitempty"` // 卡牌标签列表2 - TagId3 int32 `csv:"TagId3,omitempty"` // 卡牌标签列表3 - TagId4 int32 `csv:"TagId4,omitempty"` // 卡牌标签列表4 - TagId5 int32 `csv:"TagId5,omitempty"` // 卡牌标签列表5 - SkillListStr string `csv:"SkillListStr,omitempty"` // 卡牌技能列表文本 - HPBase int32 `csv:"HPBase,omitempty"` // 角色生命值 - MaxElemVal int32 `csv:"MaxElemVal,omitempty"` // 角色充能上限 + CharId int32 `csv:"ID"` + TagId1 int32 `csv:"[卡牌标签列表]1,omitempty"` + TagId2 int32 `csv:"[卡牌标签列表]2,omitempty"` + TagId3 int32 `csv:"[卡牌标签列表]3,omitempty"` + TagId4 int32 `csv:"[卡牌标签列表]4,omitempty"` + TagId5 int32 `csv:"[卡牌标签列表]5,omitempty"` + SkillList IntArray `csv:"卡牌技能列表,omitempty"` + HPBase int32 `csv:"角色生命值,omitempty"` + MaxElemVal int32 `csv:"角色充能上限,omitempty"` - TagList []uint32 // 卡牌标签列表 - SkillList []uint32 // 卡牌技能列表 + TagList []uint32 // 卡牌标签列表 } func (g *GameDataConfig) loadGCGCharData() { g.GCGCharDataMap = make(map[int32]*GCGCharData) - data := g.readCsvFileData("GCGCharData.csv") - var gcgCharDataList []*GCGCharData - err := csvutil.Unmarshal(data, &gcgCharDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + gcgCharDataList := make([]*GCGCharData, 0) + readTable[GCGCharData](g.tablePrefix+"GCGCharData.txt", &gcgCharDataList) for _, gcgCharData := range gcgCharDataList { // 将TagId整合进TagList gcgCharData.TagList = make([]uint32, 0, 5) @@ -47,17 +35,6 @@ func (g *GameDataConfig) loadGCGCharData() { } gcgCharData.TagList = append(gcgCharData.TagList, uint32(tagId)) } - // 技能列表读取转换 - tempSkillList := strings.Split(strings.ReplaceAll(gcgCharData.SkillListStr, " ", ""), "#") - gcgCharData.SkillList = make([]uint32, 0, len(tempSkillList)) - for _, s := range tempSkillList { - skillId, err := strconv.Atoi(s) - if err != nil { - logger.Error("skill id to i err, %v", err) - return - } - gcgCharData.SkillList = append(gcgCharData.SkillList, uint32(skillId)) - } // list -> map g.GCGCharDataMap[gcgCharData.CharId] = gcgCharData } diff --git a/gdconf/gcg_skill_data.go b/gdconf/gcg_skill_data.go index 889f7aa2..aad3d3c6 100644 --- a/gdconf/gcg_skill_data.go +++ b/gdconf/gcg_skill_data.go @@ -7,18 +7,16 @@ import ( "hk4e/pkg/logger" "github.com/hjson/hjson-go/v4" - - "github.com/jszwec/csvutil" ) // GCGSkillData 卡牌技能配置表 type GCGSkillData struct { - SkillId int32 `csv:"SkillId"` // ID - ConfigJson string `csv:"ConfigJson,omitempty"` // 效果config - CostType1 int32 `csv:"CostType1,omitempty"` // 消耗的元素骰子类型1 - CostValue1 int32 `csv:"CostValue1,omitempty"` // 消耗的元素骰子数量1 - CostType2 int32 `csv:"CostType2,omitempty"` // 消耗的元素骰子类型2 - CostValue2 int32 `csv:"CostValue2,omitempty"` // 消耗的元素骰子数量2 + SkillId int32 `csv:"ID"` + ConfigJson string `csv:"效果JSON文件,omitempty"` + CostType1 int32 `csv:"[技能费用]1类型,omitempty"` + CostValue1 int32 `csv:"[技能费用]1值,omitempty"` + CostType2 int32 `csv:"[技能费用]2类型,omitempty"` + CostValue2 int32 `csv:"[技能费用]2值,omitempty"` CostMap map[uint32]uint32 // 技能骰子消耗列表 Damage uint32 // 技能伤害 @@ -36,13 +34,8 @@ type ConfigSkillEffectValue struct { func (g *GameDataConfig) loadGCGSkillData() { g.GCGSkillDataMap = make(map[int32]*GCGSkillData) - data := g.readCsvFileData("GCGSkillData.csv") - var gcgSkillDataList []*GCGSkillData - err := csvutil.Unmarshal(data, &gcgSkillDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + gcgSkillDataList := make([]*GCGSkillData, 0) + readTable[GCGSkillData](g.tablePrefix+"GCGSkillData.txt", &gcgSkillDataList) for _, gcgSkillData := range gcgSkillDataList { // 技能消耗整合进CostMap gcgSkillData.CostMap = map[uint32]uint32{ diff --git a/gdconf/item_data.go b/gdconf/item_data.go index bbbec232..18ef5ec9 100644 --- a/gdconf/item_data.go +++ b/gdconf/item_data.go @@ -1,57 +1,44 @@ package gdconf import ( - "fmt" - "strconv" - "strings" - - "hk4e/common/constant" "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // ItemData 道具分类分表整合配置表 type ItemData struct { // 公共表头字段 - ItemId int32 `csv:"ItemId"` // ID - Type int32 `csv:"Type,omitempty"` // 类型 - Weight int32 `csv:"Weight,omitempty"` // 重量 - RankLevel int32 `csv:"RankLevel,omitempty"` // 排序权重 - GadgetId int32 `csv:"GadgetId,omitempty"` // 物件ID - Name string `csv:"Name,omitempty"` // 数值用类型 + ItemId int32 `csv:"ID"` + Type int32 `csv:"类型,omitempty"` + Weight int32 `csv:"重量,omitempty"` + RankLevel int32 `csv:"排序权重,omitempty"` + GadgetId int32 `csv:"物件ID,omitempty"` + Name string `csv:"数值用类型,omitempty"` // 材料 - MaterialType int32 `csv:"MaterialType,omitempty"` // 材料类型 - Use1Param1 string `csv:"Use1Param1,omitempty"` // [使用]1参数1 + MaterialType int32 `csv:"材料类型,omitempty"` + Use1Param1 string `csv:"[使用]1参数1,omitempty"` // 武器 - EquipType int32 `csv:"EquipType,omitempty"` // 武器种类 - EquipLevel int32 `csv:"EquipLevel,omitempty"` // 武器阶数 - SkillAffix1 int32 `csv:"SkillAffix1,omitempty"` // 初始技能词缀1 - SkillAffix2 int32 `csv:"SkillAffix2,omitempty"` // 初始技能词缀2 - PromoteId int32 `csv:"PromoteId,omitempty"` // 武器突破ID - EquipBaseExp int32 `csv:"EquipBaseExp,omitempty"` // 武器初始经验 - AwakenMaterial int32 `csv:"AwakenMaterial,omitempty"` // 武器精炼道具 - AwakenCoinCostStr string `csv:"AwakenCoinCostStr,omitempty"` // 精炼摩拉消耗 - SkillAffix []int32 - AwakenCoinCostList []uint32 + EquipType int32 `csv:"武器种类,omitempty"` + EquipLevel int32 `csv:"武器阶数,omitempty"` + SkillAffix1 int32 `csv:"初始技能词缀1,omitempty"` + SkillAffix2 int32 `csv:"初始技能词缀2,omitempty"` + PromoteId int32 `csv:"武器突破ID,omitempty"` + EquipBaseExp int32 `csv:"武器初始经验,omitempty"` + AwakenMaterial int32 `csv:"精炼道具,omitempty"` + AwakenCoinCost IntArray `csv:"精炼摩拉消耗,omitempty"` + SkillAffix []int32 // 圣遗物 - ReliquaryType int32 `csv:"ReliquaryType,omitempty"` // 圣遗物类别 - MainPropDepotId int32 `csv:"MainPropDepotId,omitempty"` // 主属性库ID - AppendPropDepotId int32 `csv:"AppendPropDepotId,omitempty"` // 追加属性库ID - AppendPropCount int32 `csv:"AppendPropCount,omitempty"` // 追加属性初始条数 + ReliquaryType int32 `csv:"圣遗物类别,omitempty"` + MainPropDepotId int32 `csv:"主属性库ID,omitempty"` + AppendPropDepotId int32 `csv:"追加属性库ID,omitempty"` + AppendPropCount int32 `csv:"追加属性初始条数,omitempty"` } func (g *GameDataConfig) loadItemData() { g.ItemDataMap = make(map[int32]*ItemData) - fileNameList := []string{"MaterialData.csv", "WeaponData.csv", "ReliquaryData.csv", "FurnitureExcelData.csv"} + fileNameList := []string{"MaterialData.txt", "WeaponData.txt", "ReliquaryData.txt", "FurnitureExcelData.txt"} for _, fileName := range fileNameList { - data := g.readCsvFileData(fileName) - var itemDataList []*ItemData - err := csvutil.Unmarshal(data, &itemDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + itemDataList := make([]*ItemData, 0) + readTable[ItemData](g.tablePrefix+fileName, &itemDataList) for _, itemData := range itemDataList { // list -> map itemData.SkillAffix = make([]int32, 0) @@ -61,19 +48,6 @@ func (g *GameDataConfig) loadItemData() { if itemData.SkillAffix2 != 0 { itemData.SkillAffix = append(itemData.SkillAffix, itemData.SkillAffix2) } - // 武器精炼摩拉消耗列表读取转换 - if itemData.Type == constant.ITEM_TYPE_WEAPON && itemData.AwakenCoinCostStr != "" { - tempCostList := strings.Split(strings.ReplaceAll(itemData.AwakenCoinCostStr, " ", ""), "#") - itemData.AwakenCoinCostList = make([]uint32, 0, len(tempCostList)) - for _, s := range tempCostList { - costCount, err := strconv.Atoi(s) - if err != nil { - logger.Error("cost count to i err, %v", err) - return - } - itemData.AwakenCoinCostList = append(itemData.AwakenCoinCostList, uint32(costCount)) - } - } g.ItemDataMap[itemData.ItemId] = itemData } } diff --git a/gdconf/player_level_data.go b/gdconf/player_level_data.go index 5958960c..245b79b1 100644 --- a/gdconf/player_level_data.go +++ b/gdconf/player_level_data.go @@ -1,28 +1,19 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // PlayerLevelData 玩家等级配置表 type PlayerLevelData struct { - Level int32 `csv:"Level"` // 等级 - Exp int32 `csv:"Exp,omitempty"` // 升到下一级所需经验 + Level int32 `csv:"等级"` + Exp int32 `csv:"升到下一级所需经验,omitempty"` } func (g *GameDataConfig) loadPlayerLevelData() { g.PlayerLevelDataMap = make(map[int32]*PlayerLevelData) - data := g.readCsvFileData("PlayerLevelData.csv") - var playerLevelDataList []*PlayerLevelData - err := csvutil.Unmarshal(data, &playerLevelDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + playerLevelDataList := make([]*PlayerLevelData, 0) + readTable[PlayerLevelData](g.tablePrefix+"PlayerLevelData.txt", &playerLevelDataList) for _, playerLevelData := range playerLevelDataList { // list -> map g.PlayerLevelDataMap[playerLevelData.Level] = playerLevelData diff --git a/gdconf/quest_data.go b/gdconf/quest_data.go index a2906565..befb55d8 100644 --- a/gdconf/quest_data.go +++ b/gdconf/quest_data.go @@ -1,11 +1,7 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) type QuestCond struct { @@ -17,57 +13,57 @@ type QuestCond struct { // QuestData 任务配置表 type QuestData struct { - QuestId int32 `csv:"QuestId"` // ID - ParentQuestId int32 `csv:"ParentQuestId,omitempty"` // 父任务ID - Sequence int32 `csv:"Sequence,omitempty"` // 序列 + QuestId int32 `csv:"子任务ID"` + ParentQuestId int32 `csv:"父任务ID,omitempty"` + Sequence int32 `csv:"序列,omitempty"` // 领取条件 - AcceptCondCompose int32 `csv:"AcceptCondCompose,omitempty"` // [领取条件]组合 - AcceptCondType1 int32 `csv:"AcceptCondType1,omitempty"` // [领取条件]1类型 - AcceptCondType1Param1 int32 `csv:"AcceptCondType1Param1,omitempty"` // [领取条件]1参数1 - AcceptCondType1Param2 int32 `csv:"AcceptCondType1Param2,omitempty"` // [领取条件]1参数2 - AcceptCondType1Param3 int32 `csv:"AcceptCondType1Param3,omitempty"` // [领取条件]1参数3 - AcceptCondType2 int32 `csv:"AcceptCondType2,omitempty"` // [领取条件]2类型 - AcceptCondType2Param1 int32 `csv:"AcceptCondType2Param1,omitempty"` // [领取条件]2参数1 - AcceptCondType2Param2 int32 `csv:"AcceptCondType2Param2,omitempty"` // [领取条件]2参数2 - AcceptCondType2Param3 int32 `csv:"AcceptCondType2Param3,omitempty"` // [领取条件]2参数3 - AcceptCondType3 int32 `csv:"AcceptCondType3,omitempty"` // [领取条件]3类型 - AcceptCondType3Param1 int32 `csv:"AcceptCondType3Param1,omitempty"` // [领取条件]3参数1 - AcceptCondType3Param2 int32 `csv:"AcceptCondType3Param2,omitempty"` // [领取条件]3参数2 - AcceptCondType3Param3 int32 `csv:"AcceptCondType3Param3,omitempty"` // [领取条件]3参数3 + AcceptCondCompose int32 `csv:"[领取条件]组合,omitempty"` + AcceptCondType1 int32 `csv:"[领取条件]1类型,omitempty"` + AcceptCondType1Param1 int32 `csv:"[领取条件]1参数1,omitempty"` + AcceptCondType1Param2 int32 `csv:"[领取条件]1参数2,omitempty"` + AcceptCondType1Param3 int32 `csv:"[领取条件]1参数3,omitempty"` + AcceptCondType2 int32 `csv:"[领取条件]2类型,omitempty"` + AcceptCondType2Param1 int32 `csv:"[领取条件]2参数1,omitempty"` + AcceptCondType2Param2 int32 `csv:"[领取条件]2参数2,omitempty"` + AcceptCondType2Param3 int32 `csv:"[领取条件]2参数3,omitempty"` + AcceptCondType3 int32 `csv:"[领取条件]3类型,omitempty"` + AcceptCondType3Param1 int32 `csv:"[领取条件]3参数1,omitempty"` + AcceptCondType3Param2 int32 `csv:"[领取条件]3参数2,omitempty"` + AcceptCondType3Param3 int32 `csv:"[领取条件]3参数3,omitempty"` // 完成条件 - FinishCondCompose int32 `csv:"FinishCondCompose,omitempty"` // [完成条件]组合 - FinishCondType1 int32 `csv:"FinishCondType1,omitempty"` // [完成条件]1类型 - FinishCondType1Param1 int32 `csv:"FinishCondType1Param1,omitempty"` // [完成条件]1参数1 - FinishCondType1Param2 int32 `csv:"FinishCondType1Param2,omitempty"` // [完成条件]1参数2 - FinishCondType1ComplexParam string `csv:"FinishCondType1ComplexParam,omitempty"` // [完成条件]1复杂参数 - FinishCondType1Count int32 `csv:"FinishCondType1Count,omitempty"` // [完成条件]1次数 - FinishCondType2 int32 `csv:"FinishCondType2,omitempty"` // [完成条件]2类型 - FinishCondType2Param1 int32 `csv:"FinishCondType2Param1,omitempty"` // [完成条件]2参数1 - FinishCondType2Param2 int32 `csv:"FinishCondType2Param2,omitempty"` // [完成条件]2参数2 - FinishCondType2ComplexParam string `csv:"FinishCondType2ComplexParam,omitempty"` // [完成条件]2复杂参数 - FinishCondType2Count int32 `csv:"FinishCondType2Count,omitempty"` // [完成条件]2次数 - FinishCondType3 int32 `csv:"FinishCondType3,omitempty"` // [完成条件]3类型 - FinishCondType3Param1 int32 `csv:"FinishCondType3Param1,omitempty"` // [完成条件]3参数1 - FinishCondType3Param2 int32 `csv:"FinishCondType3Param2,omitempty"` // [完成条件]3参数2 - FinishCondType3ComplexParam string `csv:"FinishCondType3ComplexParam,omitempty"` // [完成条件]3复杂参数 - FinishCondType3Count int32 `csv:"FinishCondType3Count,omitempty"` // [完成条件]3次数 + FinishCondCompose int32 `csv:"[完成条件]组合,omitempty"` + FinishCondType1 int32 `csv:"[完成条件]1类型,omitempty"` + FinishCondType1Param1 int32 `csv:"[完成条件]1参数1,omitempty"` + FinishCondType1Param2 int32 `csv:"[完成条件]1参数2,omitempty"` + FinishCondType1ComplexParam string `csv:"[完成条件]1复杂参数,omitempty"` + FinishCondType1Count int32 `csv:"[完成条件]1次数,omitempty"` + FinishCondType2 int32 `csv:"[完成条件]2类型,omitempty"` + FinishCondType2Param1 int32 `csv:"[完成条件]2参数1,omitempty"` + FinishCondType2Param2 int32 `csv:"[完成条件]2参数2,omitempty"` + FinishCondType2ComplexParam string `csv:"[完成条件]2复杂参数,omitempty"` + FinishCondType2Count int32 `csv:"[完成条件]2次数,omitempty"` + FinishCondType3 int32 `csv:"[完成条件]3类型,omitempty"` + FinishCondType3Param1 int32 `csv:"[完成条件]3参数1,omitempty"` + FinishCondType3Param2 int32 `csv:"[完成条件]3参数2,omitempty"` + FinishCondType3ComplexParam string `csv:"[完成条件]3复杂参数,omitempty"` + FinishCondType3Count int32 `csv:"[完成条件]3次数,omitempty"` // 失败条件 - FailCondCompose int32 `csv:"FailCondCompose,omitempty"` // [失败条件]组合 - FailCondType1 int32 `csv:"FailCondType1,omitempty"` // [失败条件]1类型 - FailCondType1Param1 int32 `csv:"FailCondType1Param1,omitempty"` // [失败条件]1参数1 - FailCondType1Param2 int32 `csv:"FailCondType1Param2,omitempty"` // [失败条件]1参数2 - FailCondType1ComplexParam string `csv:"FailCondType1ComplexParam,omitempty"` // [失败条件]1复杂参数 - FailCondType1Count int32 `csv:"FailCondType1Count,omitempty"` // [失败条件]1次数 - FailCondType2 int32 `csv:"FailCondType2,omitempty"` // [失败条件]2类型 - FailCondType2Param1 int32 `csv:"FailCondType2Param1,omitempty"` // [失败条件]2参数1 - FailCondType2Param2 int32 `csv:"FailCondType2Param2,omitempty"` // [失败条件]2参数2 - FailCondType2ComplexParam string `csv:"FailCondType2ComplexParam,omitempty"` // [失败条件]2复杂参数 - FailCondType2Count int32 `csv:"FailCondType2Count,omitempty"` // [失败条件]2次数 - FailCondType3 int32 `csv:"FailCondType3,omitempty"` // [失败条件]3类型 - FailCondType3Param1 int32 `csv:"FailCondType3Param1,omitempty"` // [失败条件]3参数1 - FailCondType3Param2 int32 `csv:"FailCondType3Param2,omitempty"` // [失败条件]3参数2 - FailCondType3ComplexParam string `csv:"FailCondType3ComplexParam,omitempty"` // [失败条件]3复杂参数 - FailCondType3Count int32 `csv:"FailCondType3Count,omitempty"` // [失败条件]3次数 + FailCondCompose int32 `csv:"[失败条件]组合,omitempty"` + FailCondType1 int32 `csv:"[失败条件]1类型,omitempty"` + FailCondType1Param1 int32 `csv:"[失败条件]1参数1,omitempty"` + FailCondType1Param2 int32 `csv:"[失败条件]1参数2,omitempty"` + FailCondType1ComplexParam string `csv:"[失败条件]1复杂参数,omitempty"` + FailCondType1Count int32 `csv:"[失败条件]1次数,omitempty"` + FailCondType2 int32 `csv:"[失败条件]2类型,omitempty"` + FailCondType2Param1 int32 `csv:"[失败条件]2参数1,omitempty"` + FailCondType2Param2 int32 `csv:"[失败条件]2参数2,omitempty"` + FailCondType2ComplexParam string `csv:"[失败条件]2复杂参数,omitempty"` + FailCondType2Count int32 `csv:"[失败条件]2次数,omitempty"` + FailCondType3 int32 `csv:"[失败条件]3类型,omitempty"` + FailCondType3Param1 int32 `csv:"[失败条件]3参数1,omitempty"` + FailCondType3Param2 int32 `csv:"[失败条件]3参数2,omitempty"` + FailCondType3ComplexParam string `csv:"[失败条件]3复杂参数,omitempty"` + FailCondType3Count int32 `csv:"[失败条件]3次数,omitempty"` AcceptCondList []*QuestCond // 领取条件 FinishCondList []*QuestCond // 完成条件 @@ -76,15 +72,10 @@ type QuestData struct { func (g *GameDataConfig) loadQuestData() { g.QuestDataMap = make(map[int32]*QuestData) - fileNameList := []string{"QuestData.csv", "QuestData_Exported.csv"} + fileNameList := []string{"QuestData.txt", "QuestData_Exported.txt"} for _, fileName := range fileNameList { - data := g.readCsvFileData(fileName) - var questDataList []*QuestData - err := csvutil.Unmarshal(data, &questDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + questDataList := make([]*QuestData, 0) + readTable[QuestData](g.tablePrefix+fileName, &questDataList) for _, questData := range questDataList { // list -> map // 领取条件 diff --git a/gdconf/reliquary_affix_data.go b/gdconf/reliquary_affix_data.go index 6f9ca8a0..b6dcd166 100644 --- a/gdconf/reliquary_affix_data.go +++ b/gdconf/reliquary_affix_data.go @@ -1,30 +1,21 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // ReliquaryAffixData 圣遗物追加属性配置表 type ReliquaryAffixData struct { - AppendPropId int32 `csv:"AppendPropId"` // 追加属性ID - AppendPropDepotId int32 `csv:"AppendPropDepotId,omitempty"` // 追加属性库ID - PropType int32 `csv:"PropType,omitempty"` // 属性类别 - RandomWeight int32 `csv:"RandomWeight,omitempty"` // 随机权重 + AppendPropId int32 `csv:"追加属性ID"` + AppendPropDepotId int32 `csv:"追加属性库ID,omitempty"` + PropType int32 `csv:"属性类别,omitempty"` + RandomWeight int32 `csv:"随机权重,omitempty"` } func (g *GameDataConfig) loadReliquaryAffixData() { g.ReliquaryAffixDataMap = make(map[int32]map[int32]*ReliquaryAffixData) - data := g.readCsvFileData("ReliquaryAffixData.csv") - var reliquaryAffixDataList []*ReliquaryAffixData - err := csvutil.Unmarshal(data, &reliquaryAffixDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + reliquaryAffixDataList := make([]*ReliquaryAffixData, 0) + readTable[ReliquaryAffixData](g.tablePrefix+"ReliquaryAffixData.txt", &reliquaryAffixDataList) for _, reliquaryAffixData := range reliquaryAffixDataList { // 通过主属性库ID找到 _, ok := g.ReliquaryAffixDataMap[reliquaryAffixData.AppendPropDepotId] diff --git a/gdconf/reliquary_main_data.go b/gdconf/reliquary_main_data.go index 9ff56ed5..f8150a5e 100644 --- a/gdconf/reliquary_main_data.go +++ b/gdconf/reliquary_main_data.go @@ -1,30 +1,21 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // ReliquaryMainData 圣遗物主属性配置表 type ReliquaryMainData struct { - MainPropId int32 `csv:"MainPropId"` // 主属性ID - MainPropDepotId int32 `csv:"MainPropDepotId,omitempty"` // 主属性库ID - PropType int32 `csv:"PropType,omitempty"` // 属性类别 - RandomWeight int32 `csv:"RandomWeight,omitempty"` // 随机权重 + MainPropId int32 `csv:"主属性ID"` + MainPropDepotId int32 `csv:"主属性库ID,omitempty"` + PropType int32 `csv:"属性类别,omitempty"` + RandomWeight int32 `csv:"随机权重,omitempty"` } func (g *GameDataConfig) loadReliquaryMainData() { g.ReliquaryMainDataMap = make(map[int32]map[int32]*ReliquaryMainData) - data := g.readCsvFileData("ReliquaryMainData.csv") - var reliquaryMainDataList []*ReliquaryMainData - err := csvutil.Unmarshal(data, &reliquaryMainDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + reliquaryMainDataList := make([]*ReliquaryMainData, 0) + readTable[ReliquaryMainData](g.tablePrefix+"ReliquaryMainData.txt", &reliquaryMainDataList) for _, reliquaryMainData := range reliquaryMainDataList { // 通过主属性库ID找到 _, ok := g.ReliquaryMainDataMap[reliquaryMainData.MainPropDepotId] diff --git a/gdconf/reward_data.go b/gdconf/reward_data.go index b67852e4..bea8633f 100644 --- a/gdconf/reward_data.go +++ b/gdconf/reward_data.go @@ -1,47 +1,38 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // RewardData 奖励配置表 type RewardData struct { - RewardID int32 `csv:"RewardID"` // 奖励ID - RewardItem1ID int32 `csv:"RewardItem1ID,omitempty"` // Reward道具1ID - RewardItem1Count int32 `csv:"RewardItem1Count,omitempty"` // Reward道具1数量 - RewardItem2ID int32 `csv:"RewardItem2ID,omitempty"` // Reward道具2ID - RewardItem2Count int32 `csv:"RewardItem2Count,omitempty"` // Reward道具2数量 - RewardItem3ID int32 `csv:"RewardItem3ID,omitempty"` // Reward道具3ID - RewardItem3Count int32 `csv:"RewardItem3Count,omitempty"` // Reward道具3数量 - RewardItem4ID int32 `csv:"RewardItem4ID,omitempty"` // Reward道具4ID - RewardItem4Count int32 `csv:"RewardItem4Count,omitempty"` // Reward道具4数量 - RewardItem5ID int32 `csv:"RewardItem5ID,omitempty"` // Reward道具5ID - RewardItem5Count int32 `csv:"RewardItem5Count,omitempty"` // Reward道具5数量 - RewardItem6ID int32 `csv:"RewardItem6ID,omitempty"` // Reward道具6ID - RewardItem6Count int32 `csv:"RewardItem6Count,omitempty"` // Reward道具6数量 - RewardItem7ID int32 `csv:"RewardItem7ID,omitempty"` // Reward道具7ID - RewardItem7Count int32 `csv:"RewardItem7Count,omitempty"` // Reward道具7数量 - RewardItem8ID int32 `csv:"RewardItem8ID,omitempty"` // Reward道具8ID - RewardItem8Count int32 `csv:"RewardItem8Count,omitempty"` // Reward道具8数量 - RewardItem9ID int32 `csv:"RewardItem9ID,omitempty"` // Reward道具9ID - RewardItem9Count int32 `csv:"RewardItem9Count,omitempty"` // Reward道具9数量 + RewardID int32 `csv:"RewardID"` + RewardItem1ID int32 `csv:"Reward道具1ID,omitempty"` + RewardItem1Count int32 `csv:"Reward道具1数量,omitempty"` + RewardItem2ID int32 `csv:"Reward道具2ID,omitempty"` + RewardItem2Count int32 `csv:"Reward道具2数量,omitempty"` + RewardItem3ID int32 `csv:"Reward道具3ID,omitempty"` + RewardItem3Count int32 `csv:"Reward道具3数量,omitempty"` + RewardItem4ID int32 `csv:"Reward道具4ID,omitempty"` + RewardItem4Count int32 `csv:"Reward道具4数量,omitempty"` + RewardItem5ID int32 `csv:"Reward道具5ID,omitempty"` + RewardItem5Count int32 `csv:"Reward道具5数量,omitempty"` + RewardItem6ID int32 `csv:"Reward道具6ID,omitempty"` + RewardItem6Count int32 `csv:"Reward道具6数量,omitempty"` + RewardItem7ID int32 `csv:"Reward道具7ID,omitempty"` + RewardItem7Count int32 `csv:"Reward道具7数量,omitempty"` + RewardItem8ID int32 `csv:"Reward道具8ID,omitempty"` + RewardItem8Count int32 `csv:"Reward道具8数量,omitempty"` + RewardItem9ID int32 `csv:"Reward道具9ID,omitempty"` + RewardItem9Count int32 `csv:"Reward道具9数量,omitempty"` RewardItemMap map[uint32]uint32 } func (g *GameDataConfig) loadRewardData() { g.RewardDataMap = make(map[int32]*RewardData) - data := g.readCsvFileData("RewardData.csv") - var rewardDataList []*RewardData - err := csvutil.Unmarshal(data, &rewardDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + rewardDataList := make([]*RewardData, 0) + readTable[RewardData](g.tablePrefix+"RewardData.txt", &rewardDataList) for _, rewardData := range rewardDataList { // list -> map // 奖励物品整合 diff --git a/gdconf/scene_data.go b/gdconf/scene_data.go index 299696d7..f3c1119e 100644 --- a/gdconf/scene_data.go +++ b/gdconf/scene_data.go @@ -1,28 +1,19 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // SceneData 场景配置表 type SceneData struct { - SceneId int32 `csv:"SceneId"` // ID - SceneType int32 `csv:"SceneType,omitempty"` // 类型 + SceneId int32 `csv:"ID"` + SceneType int32 `csv:"类型,omitempty"` } func (g *GameDataConfig) loadSceneData() { g.SceneDataMap = make(map[int32]*SceneData) - data := g.readCsvFileData("SceneData.csv") - var sceneDataList []*SceneData - err := csvutil.Unmarshal(data, &sceneDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + sceneDataList := make([]*SceneData, 0) + readTable[SceneData](g.tablePrefix+"SceneData.txt", &sceneDataList) for _, sceneData := range sceneDataList { // list -> map g.SceneDataMap[sceneData.SceneId] = sceneData diff --git a/gdconf/scene_tag_data.go b/gdconf/scene_tag_data.go index 1b8eaa6c..d640cedd 100644 --- a/gdconf/scene_tag_data.go +++ b/gdconf/scene_tag_data.go @@ -1,28 +1,19 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // SceneTagData 场景标签配置表 type SceneTagData struct { - SceneTagId int32 `csv:"SceneTagId"` // ID - SceneId int32 `csv:"SceneId,omitempty"` // 场景ID + SceneTagId int32 `csv:"ID"` + SceneId int32 `csv:"场景ID,omitempty"` } func (g *GameDataConfig) loadSceneTagData() { g.SceneTagDataMap = make(map[int32]*SceneTagData) - data := g.readCsvFileData("SceneTagData.csv") - var sceneTagDataList []*SceneTagData - err := csvutil.Unmarshal(data, &sceneTagDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + sceneTagDataList := make([]*SceneTagData, 0) + readTable[SceneTagData](g.tablePrefix+"SceneTagData.txt", &sceneTagDataList) for _, sceneTagData := range sceneTagDataList { // list -> map g.SceneTagDataMap[sceneTagData.SceneTagId] = sceneTagData diff --git a/gdconf/table_struct_mapping.json b/gdconf/table_struct_mapping.json deleted file mode 100644 index 38f30795..00000000 --- a/gdconf/table_struct_mapping.json +++ /dev/null @@ -1,1537 +0,0 @@ -[ - { - "table_name": "AvatarData", - "field_list": [ - { - "field_name": "AvatarId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "HpBase", - "field_type": "float64", - "origin_name": "基础生命值" - }, - { - "field_name": "AttackBase", - "field_type": "float64", - "origin_name": "基础攻击力" - }, - { - "field_name": "DefenseBase", - "field_type": "float64", - "origin_name": "基础防御力" - }, - { - "field_name": "Critical", - "field_type": "float64", - "origin_name": "暴击率" - }, - { - "field_name": "CriticalHurt", - "field_type": "float64", - "origin_name": "暴击伤害" - }, - { - "field_name": "QualityType", - "field_type": "int32", - "origin_name": "角色品质" - }, - { - "field_name": "ConfigJson", - "field_type": "string", - "origin_name": "战斗config" - }, - { - "field_name": "InitialWeapon", - "field_type": "int32", - "origin_name": "初始武器" - }, - { - "field_name": "WeaponType", - "field_type": "int32", - "origin_name": "武器种类" - }, - { - "field_name": "SkillDepotId", - "field_type": "int32", - "origin_name": "技能库ID" - }, - { - "field_name": "PromoteId", - "field_type": "int32", - "origin_name": "角色突破ID" - }, - { - "field_name": "PromoteRewardLevelStr", - "field_type": "string", - "origin_name": "角色突破奖励获取等阶" - }, - { - "field_name": "PromoteRewardStr", - "field_type": "string", - "origin_name": "角色突破奖励" - } - ] - }, - { - "table_name": "AvatarSkillData", - "field_list": [ - { - "field_name": "AvatarSkillId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "AbilityName", - "field_type": "string", - "origin_name": "Ability名称" - }, - { - "field_name": "CostStamina", - "field_type": "int32", - "origin_name": "消耗体力" - }, - { - "field_name": "CostElemType", - "field_type": "int32", - "origin_name": "消耗能量类型" - }, - { - "field_name": "CostElemVal", - "field_type": "int32", - "origin_name": "消耗能量值" - } - ] - }, - { - "table_name": "AvatarSkillDepotData", - "field_list": [ - { - "field_name": "AvatarSkillDepotId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "EnergySkill", - "field_type": "int32", - "origin_name": "充能技能" - }, - { - "field_name": "Skill1", - "field_type": "int32", - "origin_name": "技能1" - }, - { - "field_name": "Skill2", - "field_type": "int32", - "origin_name": "技能2" - }, - { - "field_name": "Skill3", - "field_type": "int32", - "origin_name": "技能3" - }, - { - "field_name": "Skill4", - "field_type": "int32", - "origin_name": "技能4" - }, - { - "field_name": "ProudSkill1GroupId", - "field_type": "int32", - "origin_name": "固有得意技组1ID" - }, - { - "field_name": "ProudSkill1NeedAvatarPromoteLevel", - "field_type": "int32", - "origin_name": "固有得意技组1激活所需角色突破等级" - }, - { - "field_name": "ProudSkill2GroupId", - "field_type": "int32", - "origin_name": "固有得意技组2ID" - }, - { - "field_name": "ProudSkill2NeedAvatarPromoteLevel", - "field_type": "int32", - "origin_name": "固有得意技组2激活所需角色突破等级" - }, - { - "field_name": "ProudSkill3GroupId", - "field_type": "int32", - "origin_name": "固有得意技组3ID" - }, - { - "field_name": "ProudSkill3NeedAvatarPromoteLevel", - "field_type": "int32", - "origin_name": "固有得意技组3激活所需角色突破等级" - }, - { - "field_name": "ProudSkill4GroupId", - "field_type": "int32", - "origin_name": "固有得意技组4ID" - }, - { - "field_name": "ProudSkill4NeedAvatarPromoteLevel", - "field_type": "int32", - "origin_name": "固有得意技组4激活所需角色突破等级" - }, - { - "field_name": "ProudSkill5GroupId", - "field_type": "int32", - "origin_name": "固有得意技组5ID" - }, - { - "field_name": "ProudSkill5NeedAvatarPromoteLevel", - "field_type": "int32", - "origin_name": "固有得意技组5激活所需角色突破等级" - }, - { - "field_name": "SkillDepotAbilityGroup", - "field_type": "string", - "origin_name": "AbilityGroup" - } - ] - }, - { - "table_name": "FetterDataIformation", - "field_list": [ - { - "field_name": "FetterId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "AvatarId", - "field_type": "int32", - "origin_name": "角色ID" - } - ] - }, - { - "table_name": "FetterDataStory", - "field_list": [ - { - "field_name": "FetterId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "AvatarId", - "field_type": "int32", - "origin_name": "角色ID" - } - ] - }, - { - "table_name": "FettersData", - "field_list": [ - { - "field_name": "FetterId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "AvatarId", - "field_type": "int32", - "origin_name": "角色ID" - } - ] - }, - { - "table_name": "GatherData", - "field_list": [ - { - "field_name": "PointType", - "field_type": "int32", - "origin_name": "挂节点类型" - }, - { - "field_name": "GatherId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "GadgetId", - "field_type": "int32", - "origin_name": "采集物ID" - }, - { - "field_name": "ItemId", - "field_type": "int32", - "origin_name": "获得物品ID" - } - ] - }, - { - "table_name": "GCGCharData", - "field_list": [ - { - "field_name": "CharId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "TagId1", - "field_type": "int32", - "origin_name": "[卡牌标签列表]1" - }, - { - "field_name": "TagId2", - "field_type": "int32", - "origin_name": "[卡牌标签列表]2" - }, - { - "field_name": "TagId3", - "field_type": "int32", - "origin_name": "[卡牌标签列表]3" - }, - { - "field_name": "TagId4", - "field_type": "int32", - "origin_name": "[卡牌标签列表]4" - }, - { - "field_name": "TagId5", - "field_type": "int32", - "origin_name": "[卡牌标签列表]5" - }, - { - "field_name": "SkillListStr", - "field_type": "string", - "origin_name": "卡牌技能列表" - }, - { - "field_name": "HPBase", - "field_type": "int32", - "origin_name": "角色生命值" - }, - { - "field_name": "MaxElemVal", - "field_type": "int32", - "origin_name": "角色充能上限" - } - ] - }, - { - "table_name": "GCGSkillData", - "field_list": [ - { - "field_name": "SkillId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "ConfigJson", - "field_type": "string", - "origin_name": "效果JSON文件" - }, - { - "field_name": "CostType1", - "field_type": "int32", - "origin_name": "[技能费用]1类型" - }, - { - "field_name": "CostValue1", - "field_type": "int32", - "origin_name": "[技能费用]1值" - }, - { - "field_name": "CostType2", - "field_type": "int32", - "origin_name": "[技能费用]2类型" - }, - { - "field_name": "CostValue2", - "field_type": "int32", - "origin_name": "[技能费用]2值" - } - ] - }, - { - "table_name": "PhotographExpressionName", - "field_list": [ - { - "field_name": "FetterId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "AvatarId", - "field_type": "int32", - "origin_name": "角色ID" - } - ] - }, - { - "table_name": "PhotographPoseName", - "field_list": [ - { - "field_name": "FetterId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "AvatarId", - "field_type": "int32", - "origin_name": "角色ID" - } - ] - }, - { - "table_name": "SceneData", - "field_list": [ - { - "field_name": "SceneId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "SceneType", - "field_type": "int32", - "origin_name": "类型" - } - ] - }, - { - "table_name": "SceneTagData", - "field_list": [ - { - "field_name": "SceneTagId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "SceneId", - "field_type": "int32", - "origin_name": "场景ID" - } - ] - }, - { - "table_name": "WorldAreaData", - "field_list": [ - { - "field_name": "WorldAreaId", - "field_type": "int32", - "origin_name": "条目ID" - }, - { - "field_name": "SceneId", - "field_type": "int32", - "origin_name": "场景ID" - }, - { - "field_name": "AreaId1", - "field_type": "int32", - "origin_name": "一级区域ID" - }, - { - "field_name": "AreaId2", - "field_type": "int32", - "origin_name": "二级区域ID" - } - ] - }, - { - "table_name": "MaterialData", - "field_list": [ - { - "field_name": "ItemId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "Type", - "field_type": "int32", - "origin_name": "类型" - }, - { - "field_name": "Weight", - "field_type": "int32", - "origin_name": "重量" - }, - { - "field_name": "RankLevel", - "field_type": "int32", - "origin_name": "排序权重" - }, - { - "field_name": "GadgetId", - "field_type": "int32", - "origin_name": "物件ID" - }, - { - "field_name": "Name", - "field_type": "string", - "origin_name": "数值用类型" - }, - { - "field_name": "MaterialType", - "field_type": "int32", - "origin_name": "材料类型" - }, - { - "field_name": "Use1Param1", - "field_type": "string", - "origin_name": "[使用]1参数1" - } - ] - }, - { - "table_name": "WeaponData", - "field_list": [ - { - "field_name": "ItemId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "Type", - "field_type": "int32", - "origin_name": "类型" - }, - { - "field_name": "Weight", - "field_type": "int32", - "origin_name": "重量" - }, - { - "field_name": "RankLevel", - "field_type": "int32", - "origin_name": "排序权重" - }, - { - "field_name": "GadgetId", - "field_type": "int32", - "origin_name": "物件ID" - }, - { - "field_name": "Name", - "field_type": "string", - "origin_name": "数值用类型" - }, - { - "field_name": "EquipType", - "field_type": "int32", - "origin_name": "武器种类" - }, - { - "field_name": "EquipLevel", - "field_type": "int32", - "origin_name": "武器阶数" - }, - { - "field_name": "SkillAffix1", - "field_type": "int32", - "origin_name": "初始技能词缀1" - }, - { - "field_name": "SkillAffix2", - "field_type": "int32", - "origin_name": "初始技能词缀2" - }, - { - "field_name": "PromoteId", - "field_type": "int32", - "origin_name": "武器突破ID" - }, - { - "field_name": "EquipBaseExp", - "field_type": "int32", - "origin_name": "武器初始经验" - }, - { - "field_name": "AwakenMaterial", - "field_type": "int32", - "origin_name": "精炼道具" - }, - { - "field_name": "AwakenCoinCostStr", - "field_type": "string", - "origin_name": "精炼摩拉消耗" - } - ] - }, - { - "table_name": "ReliquaryData", - "field_list": [ - { - "field_name": "ItemId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "Type", - "field_type": "int32", - "origin_name": "类型" - }, - { - "field_name": "Weight", - "field_type": "int32", - "origin_name": "重量" - }, - { - "field_name": "RankLevel", - "field_type": "int32", - "origin_name": "排序权重" - }, - { - "field_name": "GadgetId", - "field_type": "int32", - "origin_name": "物件ID" - }, - { - "field_name": "Name", - "field_type": "string", - "origin_name": "数值用类型" - }, - { - "field_name": "ReliquaryType", - "field_type": "int32", - "origin_name": "圣遗物类别" - }, - { - "field_name": "MainPropDepotId", - "field_type": "int32", - "origin_name": "主属性库ID" - }, - { - "field_name": "AppendPropDepotId", - "field_type": "int32", - "origin_name": "追加属性库ID" - }, - { - "field_name": "AppendPropCount", - "field_type": "int32", - "origin_name": "追加属性初始条数" - } - ] - }, - { - "table_name": "FurnitureExcelData", - "field_list": [ - { - "field_name": "ItemId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "Type", - "field_type": "int32", - "origin_name": "类型" - }, - { - "field_name": "Weight", - "field_type": "int32", - "origin_name": "重量" - }, - { - "field_name": "RankLevel", - "field_type": "int32", - "origin_name": "排序权重" - }, - { - "field_name": "GadgetId", - "field_type": "int32", - "origin_name": "物件ID" - }, - { - "field_name": "Name", - "field_type": "string", - "origin_name": "数值用类型" - } - ] - }, - { - "table_name": "AvatarLevelData", - "field_list": [ - { - "field_name": "Level", - "field_type": "int32", - "origin_name": "等级" - }, - { - "field_name": "Exp", - "field_type": "int32", - "origin_name": "升到下一级所需经验" - } - ] - }, - { - "table_name": "AvatarPromoteData", - "field_list": [ - { - "field_name": "PromoteId", - "field_type": "int32", - "origin_name": "角色突破ID" - }, - { - "field_name": "PromoteLevel", - "field_type": "int32", - "origin_name": "突破等级" - }, - { - "field_name": "CostCoin", - "field_type": "int32", - "origin_name": "消耗金币" - }, - { - "field_name": "CostItemId1", - "field_type": "int32", - "origin_name": "[消耗物品]1ID" - }, - { - "field_name": "CostItemCount1", - "field_type": "int32", - "origin_name": "[消耗物品]1数量" - }, - { - "field_name": "CostItemId2", - "field_type": "int32", - "origin_name": "[消耗物品]2ID" - }, - { - "field_name": "CostItemCount2", - "field_type": "int32", - "origin_name": "[消耗物品]2数量" - }, - { - "field_name": "CostItemId3", - "field_type": "int32", - "origin_name": "[消耗物品]3ID" - }, - { - "field_name": "CostItemCount3", - "field_type": "int32", - "origin_name": "[消耗物品]3数量" - }, - { - "field_name": "CostItemId4", - "field_type": "int32", - "origin_name": "[消耗物品]4ID" - }, - { - "field_name": "CostItemCount4", - "field_type": "int32", - "origin_name": "[消耗物品]4数量" - }, - { - "field_name": "LevelLimit", - "field_type": "int32", - "origin_name": "解锁等级上限" - }, - { - "field_name": "MinPlayerLevel", - "field_type": "int32", - "origin_name": "冒险等级要求" - } - ] - }, - { - "table_name": "PlayerLevelData", - "field_list": [ - { - "field_name": "Level", - "field_type": "int32", - "origin_name": "等级" - }, - { - "field_name": "Exp", - "field_type": "int32", - "origin_name": "升到下一级所需经验" - } - ] - }, - { - "table_name": "WeaponLevelData", - "field_list": [ - { - "field_name": "Level", - "field_type": "int32", - "origin_name": "等级" - }, - { - "field_name": "ExpByStar1", - "field_type": "int32", - "origin_name": "武器升级经验1" - }, - { - "field_name": "ExpByStar2", - "field_type": "int32", - "origin_name": "武器升级经验2" - }, - { - "field_name": "ExpByStar3", - "field_type": "int32", - "origin_name": "武器升级经验3" - }, - { - "field_name": "ExpByStar4", - "field_type": "int32", - "origin_name": "武器升级经验4" - }, - { - "field_name": "ExpByStar5", - "field_type": "int32", - "origin_name": "武器升级经验5" - } - ] - }, - { - "table_name": "WeaponPromoteData", - "field_list": [ - { - "field_name": "PromoteId", - "field_type": "int32", - "origin_name": "武器突破ID" - }, - { - "field_name": "PromoteLevel", - "field_type": "int32", - "origin_name": "突破等级" - }, - { - "field_name": "CostItemId1", - "field_type": "int32", - "origin_name": "[消耗物品]1ID" - }, - { - "field_name": "CostItemCount1", - "field_type": "int32", - "origin_name": "[消耗物品]1数量" - }, - { - "field_name": "CostItemId2", - "field_type": "int32", - "origin_name": "[消耗物品]2ID" - }, - { - "field_name": "CostItemCount2", - "field_type": "int32", - "origin_name": "[消耗物品]2数量" - }, - { - "field_name": "CostItemId3", - "field_type": "int32", - "origin_name": "[消耗物品]3ID" - }, - { - "field_name": "CostItemCount3", - "field_type": "int32", - "origin_name": "[消耗物品]3数量" - }, - { - "field_name": "CostCoin", - "field_type": "int32", - "origin_name": "突破消耗金币" - }, - { - "field_name": "LevelLimit", - "field_type": "int32", - "origin_name": "突破后解锁等级上限" - }, - { - "field_name": "MinPlayerLevel", - "field_type": "int32", - "origin_name": "冒险等级要求" - } - ] - }, - { - "table_name": "RewardData", - "field_list": [ - { - "field_name": "RewardID", - "field_type": "int32", - "origin_name": "RewardID" - }, - { - "field_name": "RewardItem1ID", - "field_type": "int32", - "origin_name": "Reward道具1ID" - }, - { - "field_name": "RewardItem1Count", - "field_type": "int32", - "origin_name": "Reward道具1数量" - }, - { - "field_name": "RewardItem2ID", - "field_type": "int32", - "origin_name": "Reward道具2ID" - }, - { - "field_name": "RewardItem2Count", - "field_type": "int32", - "origin_name": "Reward道具2数量" - }, - { - "field_name": "RewardItem3ID", - "field_type": "int32", - "origin_name": "Reward道具3ID" - }, - { - "field_name": "RewardItem3Count", - "field_type": "int32", - "origin_name": "Reward道具3数量" - }, - { - "field_name": "RewardItem4ID", - "field_type": "int32", - "origin_name": "Reward道具4ID" - }, - { - "field_name": "RewardItem4Count", - "field_type": "int32", - "origin_name": "Reward道具4数量" - }, - { - "field_name": "RewardItem5ID", - "field_type": "int32", - "origin_name": "Reward道具5ID" - }, - { - "field_name": "RewardItem5Count", - "field_type": "int32", - "origin_name": "Reward道具5数量" - }, - { - "field_name": "RewardItem6ID", - "field_type": "int32", - "origin_name": "Reward道具6ID" - }, - { - "field_name": "RewardItem6Count", - "field_type": "int32", - "origin_name": "Reward道具6数量" - }, - { - "field_name": "RewardItem7ID", - "field_type": "int32", - "origin_name": "Reward道具7ID" - }, - { - "field_name": "RewardItem7Count", - "field_type": "int32", - "origin_name": "Reward道具7数量" - }, - { - "field_name": "RewardItem8ID", - "field_type": "int32", - "origin_name": "Reward道具8ID" - }, - { - "field_name": "RewardItem8Count", - "field_type": "int32", - "origin_name": "Reward道具8数量" - }, - { - "field_name": "RewardItem9ID", - "field_type": "int32", - "origin_name": "Reward道具8ID" - }, - { - "field_name": "RewardItem9Count", - "field_type": "int32", - "origin_name": "Reward道具8数量" - } - ] - }, - { - "table_name": "AvatarCostumeData", - "field_list": [ - { - "field_name": "CostumeID", - "field_type": "int32", - "origin_name": "时装ID" - }, - { - "field_name": "ItemID", - "field_type": "int32", - "origin_name": "道具ID" - } - ] - }, - { - "table_name": "AvatarFlycloakData", - "field_list": [ - { - "field_name": "FlycloakID", - "field_type": "int32", - "origin_name": "风之翼ID" - }, - { - "field_name": "ItemID", - "field_type": "int32", - "origin_name": "道具ID" - } - ] - }, - { - "table_name": "ReliquaryMainData", - "field_list": [ - { - "field_name": "MainPropId", - "field_type": "int32", - "origin_name": "主属性ID" - }, - { - "field_name": "MainPropDepotId", - "field_type": "int32", - "origin_name": "主属性库ID" - }, - { - "field_name": "PropType", - "field_type": "int32", - "origin_name": "属性类别" - }, - { - "field_name": "RandomWeight", - "field_type": "int32", - "origin_name": "随机权重" - } - ] - }, - { - "table_name": "ReliquaryAffixData", - "field_list": [ - { - "field_name": "AppendPropId", - "field_type": "int32", - "origin_name": "追加属性ID" - }, - { - "field_name": "AppendPropDepotId", - "field_type": "int32", - "origin_name": "追加属性库ID" - }, - { - "field_name": "PropType", - "field_type": "int32", - "origin_name": "属性类别" - }, - { - "field_name": "RandomWeight", - "field_type": "int32", - "origin_name": "随机权重" - } - ] - }, - { - "table_name": "QuestData", - "field_list": [ - { - "field_name": "QuestId", - "field_type": "int32", - "origin_name": "子任务ID" - }, - { - "field_name": "ParentQuestId", - "field_type": "int32", - "origin_name": "父任务ID" - }, - { - "field_name": "Sequence", - "field_type": "int32", - "origin_name": "序列" - }, - { - "field_name": "AcceptCondCompose", - "field_type": "int32", - "origin_name": "[领取条件]组合" - }, - { - "field_name": "AcceptCondType1", - "field_type": "int32", - "origin_name": "[领取条件]1类型" - }, - { - "field_name": "AcceptCondType1Param1", - "field_type": "int32", - "origin_name": "[领取条件]1参数1" - }, - { - "field_name": "AcceptCondType1Param2", - "field_type": "int32", - "origin_name": "[领取条件]1参数2" - }, - { - "field_name": "AcceptCondType1Param3", - "field_type": "int32", - "origin_name": "[领取条件]1参数3" - }, - { - "field_name": "AcceptCondType2", - "field_type": "int32", - "origin_name": "[领取条件]2类型" - }, - { - "field_name": "AcceptCondType2Param1", - "field_type": "int32", - "origin_name": "[领取条件]2参数1" - }, - { - "field_name": "AcceptCondType2Param2", - "field_type": "int32", - "origin_name": "[领取条件]2参数2" - }, - { - "field_name": "AcceptCondType2Param3", - "field_type": "int32", - "origin_name": "[领取条件]2参数3" - }, - { - "field_name": "AcceptCondType3", - "field_type": "int32", - "origin_name": "[领取条件]3类型" - }, - { - "field_name": "AcceptCondType3Param1", - "field_type": "int32", - "origin_name": "[领取条件]3参数1" - }, - { - "field_name": "AcceptCondType3Param2", - "field_type": "int32", - "origin_name": "[领取条件]3参数2" - }, - { - "field_name": "AcceptCondType3Param3", - "field_type": "int32", - "origin_name": "[领取条件]3参数3" - }, - { - "field_name": "FinishCondCompose", - "field_type": "int32", - "origin_name": "[完成条件]组合" - }, - { - "field_name": "FinishCondType1", - "field_type": "int32", - "origin_name": "[完成条件]1类型" - }, - { - "field_name": "FinishCondType1Param1", - "field_type": "int32", - "origin_name": "[完成条件]1参数1" - }, - { - "field_name": "FinishCondType1Param2", - "field_type": "int32", - "origin_name": "[完成条件]1参数2" - }, - { - "field_name": "FinishCondType1ComplexParam", - "field_type": "string", - "origin_name": "[完成条件]1复杂参数" - }, - { - "field_name": "FinishCondType1Count", - "field_type": "int32", - "origin_name": "[完成条件]1次数" - }, - { - "field_name": "FinishCondType2", - "field_type": "int32", - "origin_name": "[完成条件]2类型" - }, - { - "field_name": "FinishCondType2Param1", - "field_type": "int32", - "origin_name": "[完成条件]2参数1" - }, - { - "field_name": "FinishCondType2Param2", - "field_type": "int32", - "origin_name": "[完成条件]2参数2" - }, - { - "field_name": "FinishCondType2ComplexParam", - "field_type": "string", - "origin_name": "[完成条件]2复杂参数" - }, - { - "field_name": "FinishCondType2Count", - "field_type": "int32", - "origin_name": "[完成条件]2次数" - }, - { - "field_name": "FinishCondType3", - "field_type": "int32", - "origin_name": "[完成条件]3类型" - }, - { - "field_name": "FinishCondType3Param1", - "field_type": "int32", - "origin_name": "[完成条件]3参数1" - }, - { - "field_name": "FinishCondType3Param2", - "field_type": "int32", - "origin_name": "[完成条件]3参数2" - }, - { - "field_name": "FinishCondType3ComplexParam", - "field_type": "string", - "origin_name": "[完成条件]3复杂参数" - }, - { - "field_name": "FinishCondType3Count", - "field_type": "int32", - "origin_name": "[完成条件]3次数" - }, - { - "field_name": "FailCondCompose", - "field_type": "int32", - "origin_name": "[失败条件]组合" - }, - { - "field_name": "FailCondType1", - "field_type": "int32", - "origin_name": "[失败条件]1类型" - }, - { - "field_name": "FailCondType1Param1", - "field_type": "int32", - "origin_name": "[失败条件]1参数1" - }, - { - "field_name": "FailCondType1Param2", - "field_type": "int32", - "origin_name": "[失败条件]1参数2" - }, - { - "field_name": "FailCondType1ComplexParam", - "field_type": "string", - "origin_name": "[失败条件]1复杂参数" - }, - { - "field_name": "FailCondType1Count", - "field_type": "int32", - "origin_name": "[失败条件]1次数" - }, - { - "field_name": "FailCondType2", - "field_type": "int32", - "origin_name": "[失败条件]2类型" - }, - { - "field_name": "FailCondType2Param1", - "field_type": "int32", - "origin_name": "[失败条件]2参数1" - }, - { - "field_name": "FailCondType2Param2", - "field_type": "int32", - "origin_name": "[失败条件]2参数2" - }, - { - "field_name": "FailCondType2ComplexParam", - "field_type": "string", - "origin_name": "[失败条件]2复杂参数" - }, - { - "field_name": "FailCondType2Count", - "field_type": "int32", - "origin_name": "[失败条件]2次数" - }, - { - "field_name": "FailCondType3", - "field_type": "int32", - "origin_name": "[失败条件]3类型" - }, - { - "field_name": "FailCondType3Param1", - "field_type": "int32", - "origin_name": "[失败条件]3参数1" - }, - { - "field_name": "FailCondType3Param2", - "field_type": "int32", - "origin_name": "[失败条件]3参数2" - }, - { - "field_name": "FailCondType3ComplexParam", - "field_type": "string", - "origin_name": "[失败条件]3复杂参数" - }, - { - "field_name": "FailCondType3Count", - "field_type": "int32", - "origin_name": "[失败条件]3次数" - } - ] - }, - { - "table_name": "QuestData_Exported", - "field_list": [ - { - "field_name": "QuestId", - "field_type": "int32", - "origin_name": "子任务ID" - }, - { - "field_name": "ParentQuestId", - "field_type": "int32", - "origin_name": "父任务ID" - }, - { - "field_name": "Sequence", - "field_type": "int32", - "origin_name": "序列" - }, - { - "field_name": "AcceptCondCompose", - "field_type": "int32", - "origin_name": "[领取条件]组合" - }, - { - "field_name": "AcceptCondType1", - "field_type": "int32", - "origin_name": "[领取条件]1类型" - }, - { - "field_name": "AcceptCondType1Param1", - "field_type": "int32", - "origin_name": "[领取条件]1参数1" - }, - { - "field_name": "AcceptCondType1Param2", - "field_type": "int32", - "origin_name": "[领取条件]1参数2" - }, - { - "field_name": "AcceptCondType1Param3", - "field_type": "int32", - "origin_name": "[领取条件]1参数3" - }, - { - "field_name": "AcceptCondType2", - "field_type": "int32", - "origin_name": "[领取条件]2类型" - }, - { - "field_name": "AcceptCondType2Param1", - "field_type": "int32", - "origin_name": "[领取条件]2参数1" - }, - { - "field_name": "AcceptCondType2Param2", - "field_type": "int32", - "origin_name": "[领取条件]2参数2" - }, - { - "field_name": "AcceptCondType2Param3", - "field_type": "int32", - "origin_name": "[领取条件]2参数3" - }, - { - "field_name": "AcceptCondType3", - "field_type": "int32", - "origin_name": "[领取条件]3类型" - }, - { - "field_name": "AcceptCondType3Param1", - "field_type": "int32", - "origin_name": "[领取条件]3参数1" - }, - { - "field_name": "AcceptCondType3Param2", - "field_type": "int32", - "origin_name": "[领取条件]3参数2" - }, - { - "field_name": "AcceptCondType3Param3", - "field_type": "int32", - "origin_name": "[领取条件]3参数3" - }, - { - "field_name": "FinishCondCompose", - "field_type": "int32", - "origin_name": "[完成条件]组合" - }, - { - "field_name": "FinishCondType1", - "field_type": "int32", - "origin_name": "[完成条件]1类型" - }, - { - "field_name": "FinishCondType1Param1", - "field_type": "int32", - "origin_name": "[完成条件]1参数1" - }, - { - "field_name": "FinishCondType1Param2", - "field_type": "int32", - "origin_name": "[完成条件]1参数2" - }, - { - "field_name": "FinishCondType1ComplexParam", - "field_type": "string", - "origin_name": "[完成条件]1复杂参数" - }, - { - "field_name": "FinishCondType1Count", - "field_type": "int32", - "origin_name": "[完成条件]1次数" - }, - { - "field_name": "FinishCondType2", - "field_type": "int32", - "origin_name": "[完成条件]2类型" - }, - { - "field_name": "FinishCondType2Param1", - "field_type": "int32", - "origin_name": "[完成条件]2参数1" - }, - { - "field_name": "FinishCondType2Param2", - "field_type": "int32", - "origin_name": "[完成条件]2参数2" - }, - { - "field_name": "FinishCondType2ComplexParam", - "field_type": "string", - "origin_name": "[完成条件]2复杂参数" - }, - { - "field_name": "FinishCondType2Count", - "field_type": "int32", - "origin_name": "[完成条件]2次数" - }, - { - "field_name": "FinishCondType3", - "field_type": "int32", - "origin_name": "[完成条件]3类型" - }, - { - "field_name": "FinishCondType3Param1", - "field_type": "int32", - "origin_name": "[完成条件]3参数1" - }, - { - "field_name": "FinishCondType3Param2", - "field_type": "int32", - "origin_name": "[完成条件]3参数2" - }, - { - "field_name": "FinishCondType3ComplexParam", - "field_type": "string", - "origin_name": "[完成条件]3复杂参数" - }, - { - "field_name": "FinishCondType3Count", - "field_type": "int32", - "origin_name": "[完成条件]3次数" - }, - { - "field_name": "FailCondCompose", - "field_type": "int32", - "origin_name": "[失败条件]组合" - }, - { - "field_name": "FailCondType1", - "field_type": "int32", - "origin_name": "[失败条件]1类型" - }, - { - "field_name": "FailCondType1Param1", - "field_type": "int32", - "origin_name": "[失败条件]1参数1" - }, - { - "field_name": "FailCondType1Param2", - "field_type": "int32", - "origin_name": "[失败条件]1参数2" - }, - { - "field_name": "FailCondType1ComplexParam", - "field_type": "string", - "origin_name": "[失败条件]1复杂参数" - }, - { - "field_name": "FailCondType1Count", - "field_type": "int32", - "origin_name": "[失败条件]1次数" - }, - { - "field_name": "FailCondType2", - "field_type": "int32", - "origin_name": "[失败条件]2类型" - }, - { - "field_name": "FailCondType2Param1", - "field_type": "int32", - "origin_name": "[失败条件]2参数1" - }, - { - "field_name": "FailCondType2Param2", - "field_type": "int32", - "origin_name": "[失败条件]2参数2" - }, - { - "field_name": "FailCondType2ComplexParam", - "field_type": "string", - "origin_name": "[失败条件]2复杂参数" - }, - { - "field_name": "FailCondType2Count", - "field_type": "int32", - "origin_name": "[失败条件]2次数" - }, - { - "field_name": "FailCondType3", - "field_type": "int32", - "origin_name": "[失败条件]3类型" - }, - { - "field_name": "FailCondType3Param1", - "field_type": "int32", - "origin_name": "[失败条件]3参数1" - }, - { - "field_name": "FailCondType3Param2", - "field_type": "int32", - "origin_name": "[失败条件]3参数2" - }, - { - "field_name": "FailCondType3ComplexParam", - "field_type": "string", - "origin_name": "[失败条件]3复杂参数" - }, - { - "field_name": "FailCondType3Count", - "field_type": "int32", - "origin_name": "[失败条件]3次数" - } - ] - }, - { - "table_name": "TriggerData", - "field_list": [ - { - "field_name": "TriggerId", - "field_type": "int32", - "origin_name": "ID" - }, - { - "field_name": "SceneId", - "field_type": "int32", - "origin_name": "场景ID" - }, - { - "field_name": "GroupId", - "field_type": "int32", - "origin_name": "组ID" - }, - { - "field_name": "TriggerName", - "field_type": "string", - "origin_name": "触发器" - } - ] - } -] diff --git a/gdconf/trigger_data.go b/gdconf/trigger_data.go index f4e86074..7ebf1311 100644 --- a/gdconf/trigger_data.go +++ b/gdconf/trigger_data.go @@ -1,30 +1,21 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // TriggerData 场景LUA触发器配置表 type TriggerData struct { - TriggerId int32 `csv:"TriggerId"` // ID - SceneId int32 `csv:"SceneId,omitempty"` // 场景ID - GroupId int32 `csv:"GroupId,omitempty"` // 组ID - TriggerName string `csv:"TriggerName,omitempty"` // 触发器 + TriggerId int32 `csv:"ID"` + SceneId int32 `csv:"场景ID,omitempty"` + GroupId int32 `csv:"组ID,omitempty"` + TriggerName string `csv:"触发器,omitempty"` } func (g *GameDataConfig) loadTriggerData() { g.TriggerDataMap = make(map[int32]*TriggerData) - data := g.readCsvFileData("TriggerData.csv") - var triggerDataList []*TriggerData - err := csvutil.Unmarshal(data, &triggerDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + triggerDataList := make([]*TriggerData, 0) + readTable[TriggerData](g.tablePrefix+"TriggerData.txt", &triggerDataList) for _, triggerData := range triggerDataList { g.TriggerDataMap[triggerData.TriggerId] = triggerData } diff --git a/gdconf/weapon_level_data.go b/gdconf/weapon_level_data.go index fc52deec..1c9ee386 100644 --- a/gdconf/weapon_level_data.go +++ b/gdconf/weapon_level_data.go @@ -1,34 +1,25 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // WeaponLevelData 武器等级配置表 type WeaponLevelData struct { - Level int32 `csv:"Level"` // 等级 - ExpByStar1 int32 `csv:"ExpByStar1,omitempty"` // 武器升级经验1 - ExpByStar2 int32 `csv:"ExpByStar2,omitempty"` // 武器升级经验2 - ExpByStar3 int32 `csv:"ExpByStar3,omitempty"` // 武器升级经验3 - ExpByStar4 int32 `csv:"ExpByStar4,omitempty"` // 武器升级经验4 - ExpByStar5 int32 `csv:"ExpByStar5,omitempty"` // 武器升级经验5 + Level int32 `csv:"等级"` + ExpByStar1 int32 `csv:"武器升级经验1,omitempty"` + ExpByStar2 int32 `csv:"武器升级经验2,omitempty"` + ExpByStar3 int32 `csv:"武器升级经验3,omitempty"` + ExpByStar4 int32 `csv:"武器升级经验4,omitempty"` + ExpByStar5 int32 `csv:"武器升级经验5,omitempty"` ExpByStarMap map[uint32]uint32 // 星级对应武器升级经验 } func (g *GameDataConfig) loadWeaponLevelData() { g.WeaponLevelDataMap = make(map[int32]*WeaponLevelData) - data := g.readCsvFileData("WeaponLevelData.csv") - var weaponLevelDataList []*WeaponLevelData - err := csvutil.Unmarshal(data, &weaponLevelDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + weaponLevelDataList := make([]*WeaponLevelData, 0) + readTable[WeaponLevelData](g.tablePrefix+"WeaponLevelData.txt", &weaponLevelDataList) for _, weaponLevelData := range weaponLevelDataList { // list -> map weaponLevelData.ExpByStarMap = map[uint32]uint32{ diff --git a/gdconf/weapon_promote_data.go b/gdconf/weapon_promote_data.go index cb31dd43..0664c3f9 100644 --- a/gdconf/weapon_promote_data.go +++ b/gdconf/weapon_promote_data.go @@ -1,39 +1,30 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // WeaponPromoteData 武器突破配置表 type WeaponPromoteData struct { - PromoteId int32 `csv:"PromoteId"` // 武器突破ID - PromoteLevel int32 `csv:"PromoteLevel,omitempty"` // 突破等级 - CostItemId1 int32 `csv:"CostItemId1,omitempty"` // [消耗物品]1ID - CostItemCount1 int32 `csv:"CostItemCount1,omitempty"` // [消耗物品]1数量 - CostItemId2 int32 `csv:"CostItemId2,omitempty"` // [消耗物品]2ID - CostItemCount2 int32 `csv:"CostItemCount2,omitempty"` // [消耗物品]2数量 - CostItemId3 int32 `csv:"CostItemId3,omitempty"` // [消耗物品]3ID - CostItemCount3 int32 `csv:"CostItemCount3,omitempty"` // [消耗物品]3数量 - CostCoin int32 `csv:"CostCoin,omitempty"` // 突破消耗金币 - LevelLimit int32 `csv:"LevelLimit,omitempty"` // 突破后解锁等级上限 - MinPlayerLevel int32 `csv:"MinPlayerLevel,omitempty"` // 冒险等级要求 + PromoteId int32 `csv:"武器突破ID"` + PromoteLevel int32 `csv:"突破等级,omitempty"` + CostItemId1 int32 `csv:"[消耗物品]1ID,omitempty"` + CostItemCount1 int32 `csv:"[消耗物品]1数量,omitempty"` + CostItemId2 int32 `csv:"[消耗物品]2ID,omitempty"` + CostItemCount2 int32 `csv:"[消耗物品]2数量,omitempty"` + CostItemId3 int32 `csv:"[消耗物品]3ID,omitempty"` + CostItemCount3 int32 `csv:"[消耗物品]3数量,omitempty"` + CostCoin int32 `csv:"突破消耗金币,omitempty"` + LevelLimit int32 `csv:"突破后解锁等级上限,omitempty"` + MinPlayerLevel int32 `csv:"冒险等级要求,omitempty"` CostItemMap map[uint32]uint32 // 消耗物品列表 } func (g *GameDataConfig) loadWeaponPromoteData() { g.WeaponPromoteDataMap = make(map[int32]map[int32]*WeaponPromoteData) - data := g.readCsvFileData("WeaponPromoteData.csv") - var weaponPromoteDataList []*WeaponPromoteData - err := csvutil.Unmarshal(data, &weaponPromoteDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + weaponPromoteDataList := make([]*WeaponPromoteData, 0) + readTable[WeaponPromoteData](g.tablePrefix+"WeaponPromoteData.txt", &weaponPromoteDataList) for _, weaponPromoteData := range weaponPromoteDataList { // list -> map _, ok := g.WeaponPromoteDataMap[weaponPromoteData.PromoteId] diff --git a/gdconf/world_area_data.go b/gdconf/world_area_data.go index 559ca7be..a3a2cc0e 100644 --- a/gdconf/world_area_data.go +++ b/gdconf/world_area_data.go @@ -1,30 +1,21 @@ package gdconf import ( - "fmt" - "hk4e/pkg/logger" - - "github.com/jszwec/csvutil" ) // WorldAreaData 世界区域配置表 type WorldAreaData struct { - WorldAreaId int32 `csv:"WorldAreaId"` // 条目ID - SceneId int32 `csv:"SceneId,omitempty"` // 场景ID - AreaId1 int32 `csv:"AreaId1,omitempty"` // 一级区域ID - AreaId2 int32 `csv:"AreaId2,omitempty"` // 二级区域ID + WorldAreaId int32 `csv:"条目ID"` + SceneId int32 `csv:"场景ID,omitempty"` + AreaId1 int32 `csv:"一级区域ID,omitempty"` + AreaId2 int32 `csv:"二级区域ID,omitempty"` } func (g *GameDataConfig) loadWorldAreaData() { g.WorldAreaDataMap = make(map[int32]*WorldAreaData) - data := g.readCsvFileData("WorldAreaData.csv") - var worldAreaDataList []*WorldAreaData - err := csvutil.Unmarshal(data, &worldAreaDataList) - if err != nil { - info := fmt.Sprintf("parse file error: %v", err) - panic(info) - } + worldAreaDataList := make([]*WorldAreaData, 0) + readTable[WorldAreaData](g.tablePrefix+"WorldAreaData.txt", &worldAreaDataList) for _, worldAreaData := range worldAreaDataList { // list -> map g.WorldAreaDataMap[worldAreaData.WorldAreaId] = worldAreaData diff --git a/gs/game/player_common.go b/gs/game/player_common.go index 94bee090..f726b9db 100644 --- a/gs/game/player_common.go +++ b/gs/game/player_common.go @@ -3,7 +3,6 @@ package game import ( "time" - "hk4e/common/mq" "hk4e/gate/kcp" "hk4e/gs/model" "hk4e/pkg/logger" @@ -136,7 +135,7 @@ func (g *GameManager) SetEntityClientDataNotify(player *model.Player, payloadMsg g.SendMsg(cmd.SetEntityClientDataNotify, player.PlayerID, player.ClientSeq, ntf) } -func (g *GameManager) ServerAppidBindNotify(userId uint32, fightAppId string, joinHostUserId uint32) { +func (g *GameManager) ServerAppidBindNotify(userId uint32, anticheatAppId string, joinHostUserId uint32) { player := USER_MANAGER.GetOnlineUser(userId) if player == nil { logger.Error("player is nil, uid: %v", userId) @@ -151,18 +150,10 @@ func (g *GameManager) ServerAppidBindNotify(userId uint32, fightAppId string, jo g.JoinOtherWorld(player, hostPlayer) return } - logger.Debug("server appid bind notify, uid: %v, fightAppId: %v", userId, fightAppId) - player.FightAppId = fightAppId + logger.Debug("server appid bind notify, uid: %v, anticheatAppId: %v", userId, anticheatAppId) + player.AnticheatAppId = anticheatAppId // 创建世界 world := WORLD_MANAGER.CreateWorld(player) - MESSAGE_QUEUE.SendToFight(fightAppId, &mq.NetMsg{ - MsgType: mq.MsgTypeFight, - EventId: mq.AddFightRoutine, - FightMsg: &mq.FightMsg{ - FightRoutineId: world.GetId(), - GateServerAppId: player.GateAppId, - }, - }) world.AddPlayer(player, player.SceneId) player.WorldId = world.GetId() // 进入场景 diff --git a/gs/game/player_multiplayer.go b/gs/game/player_multiplayer.go index b93db295..ea7cf72d 100644 --- a/gs/game/player_multiplayer.go +++ b/gs/game/player_multiplayer.go @@ -420,13 +420,6 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player) if world.GetOwner().PlayerID == player.PlayerID { // 房主离开销毁世界 WORLD_MANAGER.DestroyWorld(world.GetId()) - MESSAGE_QUEUE.SendToFight(world.GetOwner().FightAppId, &mq.NetMsg{ - MsgType: mq.MsgTypeFight, - EventId: mq.DelFightRoutine, - FightMsg: &mq.FightMsg{ - FightRoutineId: world.GetId(), - }, - }) return } if world.GetMultiplayer() && world.GetWorldPlayerNum() > 0 { diff --git a/gs/game/player_weapon.go b/gs/game/player_weapon.go index a11898b2..d0f5e08d 100644 --- a/gs/game/player_weapon.go +++ b/gs/game/player_weapon.go @@ -124,7 +124,7 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag return } // 确保获取消耗的摩拉索引不越界 - if int(weapon.Refinement) >= len(weaponConfig.AwakenCoinCostList) { + if int(weapon.Refinement) >= len(weaponConfig.AwakenCoinCost) { logger.Error("weapon config cost coin error, itemId: %v", weapon.ItemId) return } @@ -217,7 +217,7 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag return } // 消耗摩拉 - ok = g.CostUserItem(player.PlayerID, []*ChangeItem{{ItemId: constant.ITEM_ID_SCOIN, ChangeCount: weaponConfig.AwakenCoinCostList[weapon.Refinement]}}) + ok = g.CostUserItem(player.PlayerID, []*ChangeItem{{ItemId: constant.ITEM_ID_SCOIN, ChangeCount: uint32(weaponConfig.AwakenCoinCost[weapon.Refinement])}}) if !ok { logger.Error("item count not enough, uid: %v", player.PlayerID) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH) diff --git a/gs/game/route_manager.go b/gs/game/route_manager.go index b7216bb3..bd72faa0 100644 --- a/gs/game/route_manager.go +++ b/gs/game/route_manager.go @@ -183,7 +183,7 @@ func (r *RouteManager) RouteHandle(netMsg *mq.NetMsg) { logger.Debug("remote user online state change, uid: %v, online: %v", serverMsg.UserId, serverMsg.IsOnline) USER_MANAGER.SetRemoteUserOnlineState(serverMsg.UserId, serverMsg.IsOnline, netMsg.OriginServerAppId) case mq.ServerAppidBindNotify: - GAME_MANAGER.ServerAppidBindNotify(serverMsg.UserId, serverMsg.FightServerAppId, serverMsg.JoinHostUserId) + GAME_MANAGER.ServerAppidBindNotify(serverMsg.UserId, serverMsg.AnticheatServerAppId, serverMsg.JoinHostUserId) case mq.ServerUserMpReq: GAME_MANAGER.ServerUserMpReq(serverMsg.UserMpInfo, netMsg.OriginServerAppId) case mq.ServerUserMpRsp: diff --git a/gs/game/world_scene.go b/gs/game/world_scene.go index 43bea84f..c044bb72 100644 --- a/gs/game/world_scene.go +++ b/gs/game/world_scene.go @@ -5,7 +5,6 @@ import ( "time" "hk4e/common/constant" - "hk4e/common/mq" "hk4e/gs/model" "hk4e/pkg/logger" "hk4e/protocol/cmd" @@ -163,17 +162,6 @@ func (s *Scene) CreateEntityAvatar(player *model.Player, avatarId uint32) uint32 }, } s.CreateEntity(entity, 0) - MESSAGE_QUEUE.SendToFight(s.world.owner.FightAppId, &mq.NetMsg{ - MsgType: mq.MsgTypeFight, - EventId: mq.FightRoutineAddEntity, - FightMsg: &mq.FightMsg{ - FightRoutineId: s.world.id, - EntityId: entity.id, - FightPropMap: entity.fightProp, - Uid: entity.avatarEntity.uid, - AvatarGuid: dbAvatar.AvatarMap[avatarId].Guid, - }, - }) return entity.id } @@ -220,15 +208,6 @@ func (s *Scene) CreateEntityMonster(pos, rot *model.Vector, monsterId uint32, le objectId: objectId, } s.CreateEntity(entity, objectId) - MESSAGE_QUEUE.SendToFight(s.world.owner.FightAppId, &mq.NetMsg{ - MsgType: mq.MsgTypeFight, - EventId: mq.FightRoutineAddEntity, - FightMsg: &mq.FightMsg{ - FightRoutineId: s.world.id, - EntityId: entity.id, - FightPropMap: entity.fightProp, - }, - }) return entity.id } @@ -420,14 +399,6 @@ func (s *Scene) DestroyEntity(entityId uint32) { } delete(s.entityMap, entity.id) delete(s.objectIdEntityMap, entity.objectId) - MESSAGE_QUEUE.SendToFight(s.world.owner.FightAppId, &mq.NetMsg{ - MsgType: mq.MsgTypeFight, - EventId: mq.FightRoutineDelEntity, - FightMsg: &mq.FightMsg{ - FightRoutineId: s.world.id, - EntityId: entity.id, - }, - }) } func (s *Scene) GetEntity(entityId uint32) *Entity { diff --git a/gs/model/player.go b/gs/model/player.go index 6db3414a..36f16259 100644 --- a/gs/model/player.go +++ b/gs/model/player.go @@ -75,7 +75,7 @@ type Player struct { CombatInvokeHandler *InvokeHandler[proto.CombatInvokeEntry] `bson:"-" msgpack:"-"` // combat转发器 AbilityInvokeHandler *InvokeHandler[proto.AbilityInvokeEntry] `bson:"-" msgpack:"-"` // ability转发器 GateAppId string `bson:"-" msgpack:"-"` // 网关服务器的appid - FightAppId string `bson:"-" msgpack:"-"` // 战斗服务器的appid + AnticheatAppId string `bson:"-" msgpack:"-"` // 反作弊服务器的appid GCGCurGameGuid uint32 `bson:"-" msgpack:"-"` // GCG玩家所在的游戏guid GCGInfo *GCGInfo `bson:"-" msgpack:"-"` // 七圣召唤信息 XLuaDebug bool `bson:"-" msgpack:"-"` // 是否开启客户端XLUA调试 diff --git a/node/api/server_type.go b/node/api/server_type.go index 61fb8add..b7401029 100644 --- a/node/api/server_type.go +++ b/node/api/server_type.go @@ -3,6 +3,6 @@ package api const ( GATE = "GATE" GS = "GS" - FIGHT = "FIGHT" + ANTICHEAT = "ANTICHEAT" PATHFINDING = "PATHFINDING" ) diff --git a/node/service/discovery.go b/node/service/discovery.go index d6451f15..6b7a6deb 100644 --- a/node/service/discovery.go +++ b/node/service/discovery.go @@ -62,7 +62,7 @@ func NewDiscoveryService() *DiscoveryService { r.serverInstanceMap = make(map[string]*sync.Map) r.serverInstanceMap[api.GATE] = new(sync.Map) r.serverInstanceMap[api.GS] = new(sync.Map) - r.serverInstanceMap[api.FIGHT] = new(sync.Map) + r.serverInstanceMap[api.ANTICHEAT] = new(sync.Map) r.serverInstanceMap[api.PATHFINDING] = new(sync.Map) r.serverAppIdMap = new(sync.Map) go r.removeDeadServer()