Compare commits

..

No commits in common. "2990de66244b10cf47f9de8294cd70bb1ed0c35d" and "42912cdae6d4e802c29b6a9561c66890152898ea" have entirely different histories.

23 changed files with 165 additions and 619 deletions

2
go.mod
View File

@ -1,6 +1,6 @@
module ecs module ecs
go 1.24 go 1.24.3
require ( require (
github.com/json-iterator/go v1.1.12 github.com/json-iterator/go v1.1.12

8
go.sum
View File

@ -86,11 +86,15 @@ github.com/xuri/nfp v0.0.1/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.17.3 h1:TQyXhnsWfWtgAhMtOgtYHMTkZIfBTpMTsMnd9ZBeHxQ=
go.mongodb.org/mongo-driver v1.17.3/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw= go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw=
go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ= golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ=
@ -107,6 +111,8 @@ golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -134,6 +140,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

View File

@ -135,9 +135,6 @@ const (
// TipLineupsAlreadyMax 需要上级天赋满级 // TipLineupsAlreadyMax 需要上级天赋满级
TipLineupsAlreadyMax StringTipError = "LineupsAlreadyMax" TipLineupsAlreadyMax StringTipError = "LineupsAlreadyMax"
// TipLineupCanNotDelete 阵容无法删除
TipLineupCanNotDelete StringTipError = "LineupCanNotDelete"
// ----------------------- 关卡模块 ----------------------- // ----------------------- 关卡模块 -----------------------
// TipCopyNotFound 找不到副本 // TipCopyNotFound 找不到副本

View File

@ -30,7 +30,7 @@ message HeroListAck {
// //
message HeroChange { message HeroChange {
ChangeType ChangeType = 1; ChangeType ChangeType = 1;
Hero Hero = 2; //ChangeType=ChangeType.Delete时, Hero中只有Uid有值 Hero Hero = 2;
} }
// MsgId.ModHeroChang: 5002 // MsgId.ModHeroChang: 5002

View File

@ -30,7 +30,7 @@ message ItemListAck {
// Change的消息基本都是这样的操作 // Change的消息基本都是这样的操作
message ItemChange { message ItemChange {
ChangeType ChangeType = 1; ChangeType ChangeType = 1;
Item Item = 2; //ChangeType=ChangeType.Delete时, Item中只有Uid有值 Item Item = 2;
} }
// MsgId.ModItemChange: 6002 // MsgId.ModItemChange: 6002
@ -67,13 +67,13 @@ message ItemSaleReq {
message Equip { message Equip {
uint64 Uid = 1; //ID, Id做为键 uint64 Uid = 1; //ID, Id做为键
uint32 Id = 2; //ID uint32 Id = 2;
uint32 Level = 3; // uint32 Level = 3;
uint32 RefineExp = 4; // uint32 RefineExp = 4;
uint32 RefineLevel = 5; // uint32 RefineLevel = 5;
repeated uint64 Holes1 = 6; // repeated uint32 Holes1 = 6;
repeated uint64 Holes2 = 7; // repeated uint32 Holes2 = 7;
uint64 HeroUid = 8; // uint64 HeroUid = 8;
} }
// MsgId.ModEquipList: 6011 // MsgId.ModEquipList: 6011
@ -84,7 +84,7 @@ message EquipListAck {
message EquipChange { message EquipChange {
ChangeType ChangeType = 1; ChangeType ChangeType = 1;
Equip Equip = 2; //ChangeType=ChangeType.Delete时, Equip中只有Uid有值 Equip Equip = 2;
} }
// MsgId.ModEquipChange: 6012 // MsgId.ModEquipChange: 6012
@ -109,13 +109,8 @@ message EquipRefineReq {
message Treasure { message Treasure {
uint64 Uid = 1; //ID, Id做为键 uint64 Uid = 1; //ID, Id做为键
uint32 Id = 2; //ID uint32 Id = 2;
uint32 Exp = 3; // uint64 HeroUid = 7;
uint32 Level = 4; //
uint32 RefineLevel = 5; //
repeated uint64 Holes1 = 6; //
repeated uint64 Holes2 = 7; //
uint64 HeroUid = 8; //
} }
// MsgId.ModItemTreasureList = 6021; // MsgId.ModItemTreasureList = 6021;
@ -126,7 +121,7 @@ message TreasureListAck {
message TreasureChange { message TreasureChange {
ChangeType ChangeType = 1; ChangeType ChangeType = 1;
Treasure Treasure = 2; //ChangeType=ChangeType.Delete时, Treasure中只有Uid有值 Treasure Treasure = 2;
} }
// MsgId.ModItemTreasureChange = 6022; // MsgId.ModItemTreasureChange = 6022;

View File

@ -113,14 +113,14 @@ message LineupHeroChangeReq {
uint64 HeroUid = 3; uint64 HeroUid = 3;
} }
// MsgId.ModRoleLineupHeroPosition = 2008; // MsgId.ModRoleBattleHeroPosition = 2008;
// //
message LineupHeroPositionReq { message LineupHeroPositionReq {
uint64 LineupUid = 1; uint64 LineupUid = 1;
repeated uint32 PositionList = 3; // 6 repeated uint32 PositionList = 3; // 6
} }
// MsgId.ModRoleLineupHeroEquip = 2009; // MsgId.ModRoleBattleHeroEquip = 2009;
// //
message LineupHeroEquipReq { message LineupHeroEquipReq {
uint64 LineupUid = 1; uint64 LineupUid = 1;
@ -129,7 +129,7 @@ message LineupHeroEquipReq {
uint64 EquipUid = 4; // 0 uint64 EquipUid = 4; // 0
} }
// MsgId.ModRoleLineupHeroTreasure = 2010; // MsgId.ModRoleBattleHeroTreasure = 2010;
// //
message LineupHeroTreasureReq { message LineupHeroTreasureReq {
uint64 LineupUid = 1; uint64 LineupUid = 1;
@ -138,7 +138,7 @@ message LineupHeroTreasureReq {
uint64 TreasureUid = 4; // 0 uint64 TreasureUid = 4; // 0
} }
// MsgId.ModRoleLineupHeroArtifact = 2011; // MsgId.ModRoleBattleHeroArtifact = 2011;
// //
message LineupHeroArtifactReq { message LineupHeroArtifactReq {
uint64 LineupUid = 1; uint64 LineupUid = 1;
@ -146,7 +146,7 @@ message LineupHeroArtifactReq {
uint64 ArtifactUid = 3; uint64 ArtifactUid = 3;
} }
// MsgId.ModRoleLineupHeroMounts = 2012; // MsgId.ModRoleBattleHeroMounts = 2012;
// //
message LineupHeroMountsReq { message LineupHeroMountsReq {
uint64 LineupUid = 1; uint64 LineupUid = 1;
@ -154,7 +154,7 @@ message LineupHeroMountsReq {
uint64 MountsUid = 3; uint64 MountsUid = 3;
} }
// MsgId.ModRoleLineupHeroGeneral = 2013; // MsgId.ModRoleBattleHeroGeneral = 2013;
// //
message LineupHeroGeneralReq { message LineupHeroGeneralReq {
uint64 LineupUid = 1; uint64 LineupUid = 1;
@ -162,7 +162,7 @@ message LineupHeroGeneralReq {
uint64 GeneralUid = 3; uint64 GeneralUid = 3;
} }
// MsgId.ModRoleLineupHeroOrnament = 2014; // MsgId.ModRoleBattleHeroOrnament = 2014;
// //
message LineupHeroOrnamentReq { message LineupHeroOrnamentReq {
uint64 LineupUid = 1; uint64 LineupUid = 1;
@ -178,14 +178,6 @@ message LineupHelperChangeReq{
uint64 HeroUid = 3; //0 uint64 HeroUid = 3; //0
} }
// MsgId.ModRoleLineupEquipInlay = 2016;
//
message LineupEquipInlayReq {
uint64 LineupUid = 1;
uint32 Index = 2;
}
message Lineup { message Lineup {
uint64 Uid = 1; // ID(UID会越大) uint64 Uid = 1; // ID(UID会越大)
string Name = 2; // string Name = 2; //
@ -202,7 +194,7 @@ message LineupListAck {
message LineupChange { message LineupChange {
ChangeType ChangeType = 1; ChangeType ChangeType = 1;
Lineup Lineup = 2; //ChangeType=ChangeType.Delete时, Lineup中只有Uid有值 Lineup Lineup = 2;
} }
// MsgId.ModRoleLineupChange = 2022; // MsgId.ModRoleLineupChange = 2022;

View File

@ -125,12 +125,6 @@ enum MsgId {
// //
ModRoleLineupHelperChange = 2015; ModRoleLineupHelperChange = 2015;
//
ModRoleLineupEquipInlay = 2016;
//
ModRoleLineupTreasureInlay = 2017;
// //
ModRoleLineupList = 2021; ModRoleLineupList = 2021;

View File

@ -1,40 +0,0 @@
package data
import json "github.com/json-iterator/go"
type Skill struct {
Id int `json:"id"`
SkillType int `json:"skill_type"`
SkillBuff []int `json:"skill_buff"`
}
type SkillTable struct {
l []*Skill
m map[int]*Skill
}
func (this *SkillTable) load(buf []byte) error {
var err = json.Unmarshal(buf, &this.l)
if err != nil {
return err
}
this.m = make(map[int]*Skill)
for i := range this.l {
this.m[this.l[i].Id] = this.l[i]
}
return nil
}
func (this *SkillTable) List() []*Skill {
return this.l
}
func (this *SkillTable) Get(i int) *Skill {
return this.l[i]
}
func (this *SkillTable) Find(id int) *Skill {
return this.m[id]
}

View File

@ -1,40 +0,0 @@
package data
import json "github.com/json-iterator/go"
type SkillBuff struct {
Id int `json:"id"`
SkillBuffType int `json:"SkillBuff_type"`
SkillBuffBuff []int `json:"SkillBuff_buff"`
}
type SkillBuffTable struct {
l []*SkillBuff
m map[int]*SkillBuff
}
func (this *SkillBuffTable) load(buf []byte) error {
var err = json.Unmarshal(buf, &this.l)
if err != nil {
return err
}
this.m = make(map[int]*SkillBuff)
for i := range this.l {
this.m[this.l[i].Id] = this.l[i]
}
return nil
}
func (this *SkillBuffTable) List() []*SkillBuff {
return this.l
}
func (this *SkillBuffTable) Get(i int) *SkillBuff {
return this.l[i]
}
func (this *SkillBuffTable) Find(id int) *SkillBuff {
return this.m[id]
}

View File

@ -1,10 +1,7 @@
package data package data
import ( import (
"crypto/md5"
"fmt" "fmt"
"github.com/oylshe1314/framework/server"
"github.com/oylshe1314/framework/util"
"os" "os"
"reflect" "reflect"
"strings" "strings"
@ -15,8 +12,6 @@ type tableLoader interface {
} }
type Tables struct { type Tables struct {
dataDir string
Copy CopyTable Copy CopyTable
CopyMain CopyMainTable CopyMain CopyMainTable
Equip EquipTable Equip EquipTable
@ -34,36 +29,20 @@ type Tables struct {
Monster MonsterTable Monster MonsterTable
Scene SceneTable Scene SceneTable
ServerConfig ServerConfigTable ServerConfig ServerConfigTable
Skill SkillTable
SkillBuff SkillBuffTable
Treasure TreasureTable Treasure TreasureTable
TreasureLevel TreasureLevelTable TreasureLevel TreasureLevelTable
TreasureRefine TreasureRefineTable TreasureRefine TreasureRefineTable
UpgradeMaster UpgradeMasterTable UpgradeMaster UpgradeMasterTable
} }
func NewTables(dataDir string) *Tables { func NewTables(dataDir string) (*Tables, error) {
return &Tables{dataDir: dataDir} var tables = new(Tables)
} var tt = reflect.TypeOf(tables).Elem()
var tv = reflect.ValueOf(tables).Elem()
func (this *Tables) Load() error {
allHash, _, err := util.HashAll(md5.New(), true, nil, []string{this.dataDir}, nil)
if err != nil {
return err
}
server.DataHash = allHash[0]
var tt = reflect.TypeOf(this).Elem()
var tv = reflect.ValueOf(this).Elem()
var fn = tt.NumField() var fn = tt.NumField()
for i := range fn { for i := range fn {
var sf = tt.Field(i) var sf = tt.Field(i)
if !sf.IsExported() {
continue
}
var ft = sf.Type var ft = sf.Type
var name = ft.Name() var name = ft.Name()
if strings.HasSuffix(name, "Table") { if strings.HasSuffix(name, "Table") {
@ -77,16 +56,16 @@ func (this *Tables) Load() error {
continue continue
} }
buf, err := os.ReadFile(fmt.Sprintf("%s/tb%s.json", this.dataDir, strings.ToLower(name))) buf, err := os.ReadFile(fmt.Sprintf("%s/tb%s.json", dataDir, strings.ToLower(name)))
if err != nil { if err != nil {
return err return nil, err
} }
err = loader.load(buf) err = loader.load(buf)
if err != nil { if err != nil {
return err return nil, err
} }
} }
return nil return tables, nil
} }

View File

@ -61,15 +61,3 @@ func (this *UpgradeMasterTable) Find1(tipe int) []*UpgradeMaster {
func (this *UpgradeMasterTable) Find2(tipe, level int) *UpgradeMaster { func (this *UpgradeMasterTable) Find2(tipe, level int) *UpgradeMaster {
return this.m2[util.Compose2uint32(uint32(tipe), uint32(level))] return this.m2[util.Compose2uint32(uint32(tipe), uint32(level))]
} }
func (this *UpgradeMasterTable) FindMax(tipe, minLevel int) *UpgradeMaster {
var l = this.Find1(tipe)
var t *UpgradeMaster
for i := range l {
if l[i].NeedLevel >= minLevel {
break
}
t = l[i]
}
return t
}

View File

@ -124,7 +124,7 @@ func (this *PlayerHandler) GmCommand(player *logic.Player, msg *net.Message) {
player.WipeModel(item) player.WipeModel(item)
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemChange), &pb.ItemChangeListAck{ _ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemChange), &pb.ItemChangeListAck{
ChangeList: []*pb.ItemChange{{ChangeType: pb.ChangeType_Delete, Item: item.BuildMsgItem(true)}}, ChangeList: []*pb.ItemChange{{Item: item.BuildMsgItem(), ChangeType: pb.ChangeType_Delete}},
}) })
return return
} }

View File

@ -156,7 +156,7 @@ func (this *PlayerHandler) EquipUpgrade(player *logic.Player, msg *net.Message)
ChangeList: []*pb.EquipChange{{Equip: equip.BuildMsgEquip(), ChangeType: pb.ChangeType_Add}}, ChangeList: []*pb.EquipChange{{Equip: equip.BuildMsgEquip(), ChangeType: pb.ChangeType_Add}},
}) })
player.SendUpgradeMaster(pb.UpgradeMasterType_MasterEquipUpgrade, preLevel, equip.Level, equip.HeroUid) player.CheckUpgradeMaster(pb.UpgradeMasterType_MasterEquipUpgrade, preLevel, equip.Level, equip.HeroUid)
return return
} }
@ -294,7 +294,7 @@ func (this *PlayerHandler) EquipRefine(player *logic.Player, msg *net.Message) {
}) })
if equip.RefineLevel != preLevel { if equip.RefineLevel != preLevel {
player.SendUpgradeMaster(pb.UpgradeMasterType_MasterEquipRefine, preLevel, equip.RefineLevel, equip.HeroUid) player.CheckUpgradeMaster(pb.UpgradeMasterType_MasterEquipRefine, preLevel, equip.RefineLevel, equip.HeroUid)
} }
} }
@ -432,7 +432,7 @@ func (this *PlayerHandler) TreasureUpgrade(player *logic.Player, msg *net.Messag
}) })
if treasure.Level != preLevel { if treasure.Level != preLevel {
player.SendUpgradeMaster(pb.UpgradeMasterType_MasterTreasureUpgrade, preLevel, treasure.Level, treasure.HeroUid) player.CheckUpgradeMaster(pb.UpgradeMasterType_MasterTreasureUpgrade, preLevel, treasure.Level, treasure.HeroUid)
} }
} }
@ -506,6 +506,6 @@ func (this *PlayerHandler) TreasureRefine(player *logic.Player, msg *net.Message
ChangeList: []*pb.TreasureChange{{Treasure: equip.BuildMsgTreasure(), ChangeType: pb.ChangeType_Add}}, ChangeList: []*pb.TreasureChange{{Treasure: equip.BuildMsgTreasure(), ChangeType: pb.ChangeType_Add}},
}) })
player.SendUpgradeMaster(pb.UpgradeMasterType_MasterTreasureRefine, preLevel, equip.Level, equip.HeroUid) player.CheckUpgradeMaster(pb.UpgradeMasterType_MasterTreasureRefine, preLevel, equip.Level, equip.HeroUid)
return return
} }

View File

@ -6,7 +6,6 @@ import (
"ecs/servers/game/logic" "ecs/servers/game/logic"
"github.com/oylshe1314/framework/net" "github.com/oylshe1314/framework/net"
"github.com/oylshe1314/framework/util" "github.com/oylshe1314/framework/util"
"sort"
"strings" "strings"
) )
@ -144,16 +143,11 @@ func (this *PlayerHandler) LineupHeroChange(player *logic.Player, msg *net.Messa
var setups [7]bool var setups [7]bool
for i := 0; i < 8; i++ { for i := 0; i < 8; i++ {
if lineup.Heroes[i] == nil { if lineup.Heroes[i] != nil && hero.Uid == lineup.Heroes[i].HeroUid {
continue
}
if hero.Uid == lineup.Heroes[i].HeroUid {
this.logger.Errorf("The hero has set into the lineup, hero.Uid: %d, index: %d", hero.Uid, i) this.logger.Errorf("The hero has set into the lineup, hero.Uid: %d, index: %d", hero.Uid, i)
_ = player.TipNotice(proto.TipLineupHeroHasSet) _ = player.TipNotice(proto.TipLineupHeroHasSet)
return return
} }
if i < 6 { if i < 6 {
if lineup.Heroes[i].Position > 0 { if lineup.Heroes[i].Position > 0 {
setups[lineup.Heroes[i].Position] = true setups[lineup.Heroes[i].Position] = true
@ -242,10 +236,16 @@ func (this *PlayerHandler) LineupHeroPosition(player *logic.Player, msg *net.Mes
setups[req.PositionList[i]] = true setups[req.PositionList[i]] = true
} }
for i := range 6 { for i, lineupHero := range lineup.Heroes {
if lineup.Heroes[i] != nil { if i > 5 {
lineup.Heroes[i].Position = req.PositionList[i] break
} }
if lineupHero == nil {
continue
}
lineupHero.Position = req.PositionList[i]
} }
player.SaveField("lineup.heroes", lineup.Heroes) player.SaveField("lineup.heroes", lineup.Heroes)
@ -321,7 +321,6 @@ func (this *PlayerHandler) LineupHeroEquip(player *logic.Player, msg *net.Messag
} }
var lineupHeroList []*pb.LineupHero var lineupHeroList []*pb.LineupHero
var heroChangeList []*pb.HeroChange
var equipChangeList []*pb.EquipChange var equipChangeList []*pb.EquipChange
if lineupHero.Equip[req.EquipType] != 0 { if lineupHero.Equip[req.EquipType] != 0 {
@ -340,35 +339,18 @@ func (this *PlayerHandler) LineupHeroEquip(player *logic.Player, msg *net.Messag
player.SaveArray("lineup.heroes", int(req.Index), lineupHero) player.SaveArray("lineup.heroes", int(req.Index), lineupHero)
lineupHeroList = append(lineupHeroList, lineupHero.BuildMsgLineupHero(req.Index)) lineupHeroList = append(lineupHeroList, lineupHero.BuildMsgLineupHero(req.Index))
if hero, ok := player.Hero[lineupHero.HeroUid]; ok {
if player.UpdateHeroAttrs(hero) {
heroChangeList = append(heroChangeList, &pb.HeroChange{ChangeType: pb.ChangeType_Changed, Hero: hero.BuildMsgHero()})
}
}
if equip != nil { if equip != nil {
if equip.HeroUid != 0 { if equip.HeroUid != 0 {
util.SliceFindValue(lineup.Heroes[:], func(i int) bool { for i := range lineup.Heroes {
if lineup.Heroes[i] == nil {
return false
}
if lineup.Heroes[i].HeroUid == equip.HeroUid { if lineup.Heroes[i].HeroUid == equip.HeroUid {
var preLineupHero = lineup.Heroes[i] var preLineupHero = lineup.Heroes[i]
if preLineupHero.Equip[req.EquipType] != 0 { if preLineupHero.Equip[req.EquipType] != 0 {
preLineupHero.Equip[req.EquipType] = 0 preLineupHero.Equip[req.EquipType] = 0
player.SaveArray("lineup.heroes", i, preLineupHero) player.SaveArray("lineup.heroes", i, preLineupHero)
lineupHeroList = append(lineupHeroList, preLineupHero.BuildMsgLineupHero(uint32(i))) lineupHeroList = append(lineupHeroList, preLineupHero.BuildMsgLineupHero(uint32(i)))
if preHero, ok := player.Hero[preLineupHero.HeroUid]; ok {
if player.UpdateHeroAttrs(preHero) {
heroChangeList = append(heroChangeList, &pb.HeroChange{ChangeType: pb.ChangeType_Changed, Hero: preHero.BuildMsgHero()})
} }
} }
} }
return true
}
return false
})
} }
equip.HeroUid = lineupHero.HeroUid equip.HeroUid = lineupHero.HeroUid
@ -383,7 +365,6 @@ func (this *PlayerHandler) LineupHeroEquip(player *logic.Player, msg *net.Messag
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}}, ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
}) })
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipChange), &pb.EquipChangeListAck{ChangeList: equipChangeList}) _ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemEquipChange), &pb.EquipChangeListAck{ChangeList: equipChangeList})
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{ChangeList: heroChangeList})
return return
} }
@ -453,7 +434,6 @@ func (this *PlayerHandler) LineupHeroTreasure(player *logic.Player, msg *net.Mes
} }
var lineupHeroList []*pb.LineupHero var lineupHeroList []*pb.LineupHero
var heroChangeList []*pb.HeroChange
var equipChangeList []*pb.TreasureChange var equipChangeList []*pb.TreasureChange
if lineupHero.Treasure[req.TreasureType] != 0 { if lineupHero.Treasure[req.TreasureType] != 0 {
@ -472,36 +452,18 @@ func (this *PlayerHandler) LineupHeroTreasure(player *logic.Player, msg *net.Mes
player.SaveArray("lineup.heroes", int(req.Index), lineupHero) player.SaveArray("lineup.heroes", int(req.Index), lineupHero)
lineupHeroList = append(lineupHeroList, lineupHero.BuildMsgLineupHero(req.Index)) lineupHeroList = append(lineupHeroList, lineupHero.BuildMsgLineupHero(req.Index))
if hero, ok := player.Hero[lineupHero.HeroUid]; ok {
if player.UpdateHeroAttrs(hero) {
heroChangeList = append(heroChangeList, &pb.HeroChange{ChangeType: pb.ChangeType_Changed, Hero: hero.BuildMsgHero()})
}
}
if treasure != nil { if treasure != nil {
if treasure.HeroUid != 0 { if treasure.HeroUid != 0 {
util.SliceFindValue(lineup.Heroes[:], func(i int) bool { for i := range lineup.Heroes {
if lineup.Heroes[i] == nil {
return false
}
if lineup.Heroes[i].HeroUid == treasure.HeroUid { if lineup.Heroes[i].HeroUid == treasure.HeroUid {
var preLineupHero = lineup.Heroes[i] var preLineupHero = lineup.Heroes[i]
if preLineupHero.Treasure[req.TreasureType] != 0 { if preLineupHero.Treasure[req.TreasureType] != 0 {
preLineupHero.Treasure[req.TreasureType] = 0 preLineupHero.Treasure[req.TreasureType] = 0
player.SaveArray("lineup.heroes", i, preLineupHero) player.SaveArray("lineup.heroes", i, preLineupHero)
lineupHeroList = append(lineupHeroList, preLineupHero.BuildMsgLineupHero(uint32(i))) lineupHeroList = append(lineupHeroList, preLineupHero.BuildMsgLineupHero(uint32(i)))
if preHero, ok := player.Hero[preLineupHero.HeroUid]; ok {
if player.UpdateHeroAttrs(preHero) {
heroChangeList = append(heroChangeList, &pb.HeroChange{ChangeType: pb.ChangeType_Changed, Hero: preHero.BuildMsgHero()})
} }
} }
} }
return true
}
return false
})
} }
treasure.HeroUid = lineupHero.HeroUid treasure.HeroUid = lineupHero.HeroUid
@ -516,7 +478,6 @@ func (this *PlayerHandler) LineupHeroTreasure(player *logic.Player, msg *net.Mes
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}}, ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
}) })
_ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureChange), &pb.TreasureChangeListAck{ChangeList: equipChangeList}) _ = player.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureChange), &pb.TreasureChangeListAck{ChangeList: equipChangeList})
_ = player.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{ChangeList: heroChangeList})
return return
} }
@ -568,17 +529,6 @@ func (this *PlayerHandler) LineupHelperChange(player *logic.Player, msg *net.Mes
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{ _ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}}, ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
}) })
player.SendLineupHeroChange(lineup)
return
}
func (this *PlayerHandler) LineupEquipInlay(player *logic.Player, msg *net.Message) {
}
func (this *PlayerHandler) LineupTreasureInlay(player *logic.Player, msg *net.Message) {
} }
func (this *PlayerHandler) LineupCreate(player *logic.Player, msg *net.Message) { func (this *PlayerHandler) LineupCreate(player *logic.Player, msg *net.Message) {
@ -601,9 +551,14 @@ func (this *PlayerHandler) LineupCreate(player *logic.Player, msg *net.Message)
return return
} }
var previous = util.MapFindValue(player.Lineup, func(v *logic.PlayerLineup) bool { var previous *logic.PlayerLineup
return v.Active for _, v := range player.Lineup {
}) if v.Active {
previous = v
break
}
}
if previous == nil { if previous == nil {
_ = player.TipNotice(proto.TipServerError) _ = player.TipNotice(proto.TipServerError)
return return
@ -670,7 +625,7 @@ func (this *PlayerHandler) LineupChangeName(player *logic.Player, msg *net.Messa
player.SaveModel(lineup) player.SaveModel(lineup)
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{ _ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Add, Lineup: lineup.BuildMsgLineup()}}, ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
}) })
} }
@ -696,35 +651,13 @@ func (this *PlayerHandler) LineupActivate(player *logic.Player, msg *net.Message
return return
} }
if lineup.Active {
return
}
var lineupChangeList []*pb.LineupChange
var preLineup *logic.PlayerLineup
for _, v := range player.Lineup {
if v.Active {
preLineup = v
}
}
if preLineup != nil {
preLineup.Active = false
player.SaveModel(lineup)
lineupChangeList = append(lineupChangeList, &pb.LineupChange{ChangeType: pb.ChangeType_Changed, Lineup: preLineup.BuildMsgLineup()})
}
lineup.Active = true lineup.Active = true
player.SaveModel(lineup) player.SaveModel(lineup)
lineupChangeList = append(lineupChangeList, &pb.LineupChange{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()})
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{ _ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}}, ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()}},
}) })
player.SendLineupHeroChange(preLineup, lineup)
return
} }
func (this *PlayerHandler) LineupDelete(player *logic.Player, msg *net.Message) { func (this *PlayerHandler) LineupDelete(player *logic.Player, msg *net.Message) {
@ -742,45 +675,20 @@ func (this *PlayerHandler) LineupDelete(player *logic.Player, msg *net.Message)
return return
} }
var delLineup = player.Lineup[req.Uid] var lineup = player.Lineup[req.Uid]
if delLineup == nil { if lineup == nil {
this.logger.Error("Player lineup not found, req.Uid: ", req.Uid) this.logger.Error("Player lineup not found, req.Uid: ", req.Uid)
_ = player.TipNotice(proto.TipLineupNotFound) _ = player.TipNotice(proto.TipLineupNotFound)
return return
} }
if len(player.Lineup) == 1 { delete(player.Lineup, req.Uid)
this.logger.Error("Player lineup can not delete, len(player.Lineup) == 1")
_ = player.TipNotice(proto.TipLineupCanNotDelete)
return
}
var lineupChangeList []*pb.LineupChange
delLineup.Active = false
delete(player.Lineup, delLineup.Uid)
player.WipeModel(delLineup)
lineupChangeList = append(lineupChangeList, &pb.LineupChange{ChangeType: pb.ChangeType_Delete, Lineup: delLineup.BuildMsgLineup()})
var lineupList = make([]*logic.PlayerLineup, 0, len(player.Lineup))
for _, v := range player.Lineup {
lineupList = append(lineupList, v)
}
sort.Slice(lineupList, func(i, j int) bool {
return lineupList[i].Uid < lineupList[j].Uid
})
var lineup = lineupList[0]
lineup.Active = true
player.WipeModel(lineup) player.WipeModel(lineup)
lineupChangeList = append(lineupChangeList, &pb.LineupChange{ChangeType: pb.ChangeType_Changed, Lineup: lineup.BuildMsgLineup()})
_ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{ _ = player.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChange), &pb.LineupChangeListAck{
ChangeList: lineupChangeList, ChangeList: []*pb.LineupChange{{ChangeType: pb.ChangeType_Delete, Lineup: lineup.BuildMsgLineup()}},
}) })
player.SendLineupHeroChange(delLineup, lineup)
} }
// //

View File

@ -174,20 +174,6 @@ func (this *PlayerManager) storeChanges(player *Player) {
} }
} }
func (this *PlayerManager) tick(player *Player, now, elapsed int64) int64 {
player.lock()
defer player.unlock()
this.clearChanges(player)
var b = util.UnixMilli()
player.tick(now, elapsed)
var e = util.UnixMilli()
this.storeChanges(player)
return e - b
}
func (this *PlayerManager) run(player *Player) { func (this *PlayerManager) run(player *Player) {
go func(player *Player) { go func(player *Player) {
this.waitGroup.Add(1) this.waitGroup.Add(1)
@ -197,22 +183,32 @@ func (this *PlayerManager) run(player *Player) {
this.waitGroup.Done() this.waitGroup.Done()
}() }()
var spend int64 var b, e int64
var elapsed int64 var elapsed int64 = 0
for { for {
now := <-ticker.C now := <-ticker.C
elapsed++ elapsed++
spend = this.tick(player, now.Unix(), elapsed) player.lock() // lock
this.clearChanges(player)
b = util.UnixMilli()
player.tick(now.Unix(), elapsed)
e = util.UnixMilli()
this.storeChanges(player)
if this.closed || player.exited { if this.closed || player.exited {
player.unlock() // unlock
return return
} }
if spend >= 1000 { player.unlock() // unlock
this.logger.Warnf("[%s:%d] The time spent executing the player loop function was too long, Time: %dms, userId: %d, roleId: %d", if e-b >= 1000 {
this.logger.Warnf("[%s:%d] The executing time of the player loop function is too long, Time: %dms, userId: %d, roleId: %d",
player.Temp.Address, player.Temp.Address,
player.RoleId, player.RoleId,
spend, e-b,
player.UserId, player.UserId,
player.RoleId) player.RoleId)
} }
@ -235,7 +231,7 @@ func (this *PlayerManager) NewPlayer() *Player {
Artifact: map[uint64]*PlayerArtifact{}, Artifact: map[uint64]*PlayerArtifact{},
//Achievement: map[uint64]*PlayerAchievement{}, //Achievement: map[uint64]*PlayerAchievement{},
//BattlePass: map[uint32]*PlayerBattlePass{}, //BattlePass: map[uint32]*PlayerBattlePass{},
//CdKey: map[string]*PlayerCdKey{}, //Cdkey: map[string]*PlayerCdkey{},
//CopyPassed: map[uint32]*PlayerCopyPassed{}, //CopyPassed: map[uint32]*PlayerCopyPassed{},
//CopySpeed: map[uint32]*PlayerCopySpeed{}, //CopySpeed: map[uint32]*PlayerCopySpeed{},
//CopyStatus: map[uint64]*PlayerCopyStatus{}, //CopyStatus: map[uint64]*PlayerCopyStatus{},
@ -420,11 +416,10 @@ func (this *PlayerManager) Enter(player *Player, conn *net.Conn) {
this.PutPlayer(player) this.PutPlayer(player)
player.lock() player.lock()
defer player.unlock()
this.clearChanges(player) this.clearChanges(player)
player.enter(conn) player.enter(conn)
this.storeChanges(player) this.storeChanges(player)
player.unlock()
this.run(player) this.run(player)
@ -435,9 +430,8 @@ func (this *PlayerManager) Reenter(player *Player, conn *net.Conn) {
this.logger.Infof("[%s] The player reenter game, userId: %d, roleId: %d", player.Temp.Address, player.UserId, player.RoleId) this.logger.Infof("[%s] The player reenter game, userId: %d, roleId: %d", player.Temp.Address, player.UserId, player.RoleId)
player.lock() player.lock()
defer player.unlock()
player.reenter(conn) player.reenter(conn)
player.unlock()
this.serverManager.AddOnline(1) this.serverManager.AddOnline(1)
} }
@ -448,9 +442,8 @@ func (this *PlayerManager) Exit(player *Player) {
this.RemovePlayer(player.UserId) this.RemovePlayer(player.UserId)
player.lock() player.lock()
defer player.unlock()
player.exit() player.exit()
player.lock()
this.serverManager.ReduceOnline(1) this.serverManager.ReduceOnline(1)
} }
@ -459,20 +452,10 @@ func (this *PlayerManager) Lost(player *Player) {
this.logger.Infof("[%s] The player lost, userId: %d, roleId: %d", player.Temp.Address, player.UserId, player.RoleId) this.logger.Infof("[%s] The player lost, userId: %d, roleId: %d", player.Temp.Address, player.UserId, player.RoleId)
player.lock() player.lock()
defer player.unlock()
player.lost(func() { player.lost(func() {
this.RemovePlayer(player.UserId) this.RemovePlayer(player.UserId)
}) })
player.unlock()
this.serverManager.ReduceOnline(1)
}
func (this *PlayerManager) kick(player *Player, message string) {
player.lock()
defer player.unlock()
player.kick(message)
this.serverManager.ReduceOnline(1) this.serverManager.ReduceOnline(1)
} }
@ -482,7 +465,11 @@ func (this *PlayerManager) Kick(player *Player, message string) {
this.RemovePlayer(player.UserId) this.RemovePlayer(player.UserId)
this.kick(player, message) player.lock()
player.kick(message)
player.unlock()
this.serverManager.ReduceOnline(1)
} }
func (this *PlayerManager) KickAll(message string) { func (this *PlayerManager) KickAll(message string) {
@ -492,7 +479,11 @@ func (this *PlayerManager) KickAll(message string) {
defer this.locker.Unlock() defer this.locker.Unlock()
for _, player := range this.players { for _, player := range this.players {
this.kick(player, message) player.lock()
player.kick(message)
player.unlock()
this.serverManager.ReduceOnline(1)
} }
this.players = map[uint64]*Player{} this.players = map[uint64]*Player{}
} }

View File

@ -99,7 +99,7 @@ type Player struct {
//Non-data //Non-data
conn *net.Conn conn *net.Conn
locker sync.Mutex mutex sync.Mutex
exited bool exited bool
@ -129,11 +129,11 @@ func (this *Player) TipNotice(err proto.TipError) error {
} }
func (this *Player) lock() { func (this *Player) lock() {
this.locker.Lock() this.mutex.Lock()
} }
func (this *Player) unlock() { func (this *Player) unlock() {
this.locker.Unlock() this.mutex.Unlock()
} }
func (this *Player) sync() { func (this *Player) sync() {

View File

@ -213,10 +213,6 @@ func (this *Player) initLineup(cur *GameTime) {
var i = uint32(1) var i = uint32(1)
for _, hero := range this.Hero { for _, hero := range this.Hero {
if i > 5 {
break
}
var lineupHero = &PlayerLineupHero{ var lineupHero = &PlayerLineupHero{
HeroUid: hero.Uid, HeroUid: hero.Uid,
Position: i + 1, Position: i + 1,

View File

@ -12,8 +12,8 @@ type PlayerEquip struct {
Level uint32 `bson:"level"` Level uint32 `bson:"level"`
RefineExp uint32 `bson:"refine_exp"` RefineExp uint32 `bson:"refine_exp"`
RefineLevel uint32 `bson:"refine_level"` RefineLevel uint32 `bson:"refine_level"`
Holes1 []uint64 `bson:"holes"` Holes1 []uint32 `bson:"holes"`
Holes2 []uint64 `bson:"holes"` Holes2 []uint32 `bson:"holes"`
HeroUid uint64 `bson:"hero_id"` HeroUid uint64 `bson:"hero_id"`
} }
@ -49,8 +49,8 @@ func (this *Player) addEquip(equipTable *data.Equip, logType LogType) bool {
Level: uint32(levelTable.Level), Level: uint32(levelTable.Level),
RefineExp: 0, RefineExp: 0,
RefineLevel: uint32(refineTable.RefineLevel), RefineLevel: uint32(refineTable.RefineLevel),
Holes1: make([]uint64, equipTable.Holes1), Holes1: make([]uint32, equipTable.Holes1),
Holes2: make([]uint64, equipTable.Holes2), Holes2: make([]uint32, equipTable.Holes2),
HeroUid: 0, HeroUid: 0,
} }
@ -105,15 +105,15 @@ func (this *Player) AddEquips(equipId, nums uint32, logType LogType) bool {
Level: uint32(levelTable.Level), Level: uint32(levelTable.Level),
RefineExp: 0, RefineExp: 0,
RefineLevel: uint32(refineTable.RefineLevel), RefineLevel: uint32(refineTable.RefineLevel),
Holes1: make([]uint64, equipTable.Holes1), Holes1: make([]uint32, equipTable.Holes1),
Holes2: make([]uint64, equipTable.Holes2), Holes2: make([]uint32, equipTable.Holes2),
HeroUid: 0, HeroUid: 0,
} }
this.Equip[equip.Uid] = equip this.Equip[equip.Uid] = equip
this.SaveModel(equip) this.SaveModel(equip)
changeList = append(changeList, &pb.EquipChange{ChangeType: pb.ChangeType_Add, Equip: equip.BuildMsgEquip()}) changeList = append(changeList, &pb.EquipChange{Equip: equip.BuildMsgEquip(), ChangeType: pb.ChangeType_Add})
//this.CheckAchievement(proto.AchievementTypeEquipLevel, uint32(equipTable.Level), 1) //this.CheckAchievement(proto.AchievementTypeEquipLevel, uint32(equipTable.Level), 1)
} }

View File

@ -4,7 +4,6 @@ import (
"ecs/proto/pb" "ecs/proto/pb"
"ecs/servers/game/data" "ecs/servers/game/data"
"github.com/oylshe1314/framework/util" "github.com/oylshe1314/framework/util"
"math"
"slices" "slices"
) )
@ -24,10 +23,7 @@ type PlayerHero struct {
attrs Attrs attrs Attrs
} }
func (this *PlayerHero) BuildMsgHero(deleted ...bool) *pb.Hero { func (this *PlayerHero) BuildMsgHero() *pb.Hero {
if len(deleted) > 0 && deleted[0] {
return &pb.Hero{Uid: this.Uid}
}
return &pb.Hero{ return &pb.Hero{
Uid: this.Uid, Uid: this.Uid,
Id: this.Id, Id: this.Id,
@ -238,50 +234,16 @@ func (this *Player) calcHeroEquipsAttrs(hero *PlayerHero, lineup *PlayerLineup,
if lineup == nil || lineupHero == nil { if lineup == nil || lineupHero == nil {
return return
} }
var minLevel uint32
var minRefineLevel uint32
var masterTable *data.UpgradeMaster
minLevel = math.MaxUint32
for _, equipUid := range lineupHero.Equip { for _, equipUid := range lineupHero.Equip {
if equipUid == 0 { if equipUid == 0 {
continue continue
} }
if equip := this.Equip[equipUid]; equip != nil { var equip = this.Equip[equipUid]
var equipLevelTable = this.manager.tables.EquipLevel.Find3(int(equip.Id), int(equip.Level)) var equipLevelTable = this.manager.tables.EquipLevel.Find3(int(equip.Id), int(equip.Level))
if equipLevelTable != nil { if equipLevelTable != nil {
attrs[equipLevelTable.AttrType] += uint64(equipLevelTable.AttrValue) attrs[equipLevelTable.AttrType] += uint64(equipLevelTable.AttrValue)
} }
if equip.Level < minLevel {
minLevel = equip.Level
}
if equip.RefineLevel < minRefineLevel {
minRefineLevel = equip.RefineLevel
}
}
}
masterTable = this.manager.tables.UpgradeMaster.FindMax(int(pb.UpgradeMasterType_MasterEquipUpgrade), int(minLevel))
if masterTable != nil {
attrs[masterTable.AttrType1] = uint64(masterTable.AttrValue1)
attrs[masterTable.AttrType2] = uint64(masterTable.AttrValue2)
attrs[masterTable.AttrType3] = uint64(masterTable.AttrValue3)
attrs[masterTable.AttrType4] = uint64(masterTable.AttrValue4)
attrs[masterTable.AttrType5] = uint64(masterTable.AttrValue5)
attrs[masterTable.AttrType6] = uint64(masterTable.AttrValue6)
}
masterTable = this.manager.tables.UpgradeMaster.FindMax(int(pb.UpgradeMasterType_MasterEquipUpgrade), int(minRefineLevel))
if masterTable != nil {
attrs[masterTable.AttrType1] = uint64(masterTable.AttrValue1)
attrs[masterTable.AttrType2] = uint64(masterTable.AttrValue2)
attrs[masterTable.AttrType3] = uint64(masterTable.AttrValue3)
attrs[masterTable.AttrType4] = uint64(masterTable.AttrValue4)
attrs[masterTable.AttrType5] = uint64(masterTable.AttrValue5)
attrs[masterTable.AttrType6] = uint64(masterTable.AttrValue6)
} }
return return
} }
@ -290,50 +252,16 @@ func (this *Player) calcHeroTreasuresAttrs(hero *PlayerHero, lineup *PlayerLineu
if lineup == nil || lineupHero == nil { if lineup == nil || lineupHero == nil {
return return
} }
var minLevel uint32
var minRefineLevel uint32
var masterTable *data.UpgradeMaster
minLevel = math.MaxUint32
for _, treasureUid := range lineupHero.Treasure { for _, treasureUid := range lineupHero.Treasure {
if treasureUid == 0 { if treasureUid == 0 {
continue continue
} }
if treasure := this.Treasure[treasureUid]; treasure != nil { var treasure = this.Treasure[treasureUid]
var treasureLevelTable = this.manager.tables.TreasureLevel.Find3(int(treasure.Id), int(treasure.Level)) var treasureLevelTable = this.manager.tables.TreasureLevel.Find3(int(treasure.Id), int(treasure.Level))
if treasureLevelTable != nil { if treasureLevelTable != nil {
attrs[treasureLevelTable.AttrType] += uint64(treasureLevelTable.AttrValue) attrs[treasureLevelTable.AttrType] += uint64(treasureLevelTable.AttrValue)
} }
if treasure.Level < minLevel {
minLevel = treasure.Level
}
if treasure.RefineLevel < minRefineLevel {
minRefineLevel = treasure.RefineLevel
}
}
}
masterTable = this.manager.tables.UpgradeMaster.FindMax(int(pb.UpgradeMasterType_MasterTreasureUpgrade), int(minLevel))
if masterTable != nil {
attrs[masterTable.AttrType1] = uint64(masterTable.AttrValue1)
attrs[masterTable.AttrType2] = uint64(masterTable.AttrValue2)
attrs[masterTable.AttrType3] = uint64(masterTable.AttrValue3)
attrs[masterTable.AttrType4] = uint64(masterTable.AttrValue4)
attrs[masterTable.AttrType5] = uint64(masterTable.AttrValue5)
attrs[masterTable.AttrType6] = uint64(masterTable.AttrValue6)
}
masterTable = this.manager.tables.UpgradeMaster.FindMax(int(pb.UpgradeMasterType_MasterTreasureRefine), int(minRefineLevel))
if masterTable != nil {
attrs[masterTable.AttrType1] = uint64(masterTable.AttrValue1)
attrs[masterTable.AttrType2] = uint64(masterTable.AttrValue2)
attrs[masterTable.AttrType3] = uint64(masterTable.AttrValue3)
attrs[masterTable.AttrType4] = uint64(masterTable.AttrValue4)
attrs[masterTable.AttrType5] = uint64(masterTable.AttrValue5)
attrs[masterTable.AttrType6] = uint64(masterTable.AttrValue6)
} }
return return
} }
@ -360,13 +288,15 @@ func (this *Player) calcHeroAttrs(hero *PlayerHero, attrsList ...Attrs) bool {
} }
} }
if newAttrs == hero.attrs { for i := range newAttrs {
return false if hero.attrs[i] != newAttrs[i] {
}
hero.attrs = newAttrs hero.attrs = newAttrs
return true return true
} }
}
return false
}
func (this *Player) updateHeroAttrs(hero *PlayerHero, lineup *PlayerLineup, lineupHero *PlayerLineupHero) bool { func (this *Player) updateHeroAttrs(hero *PlayerHero, lineup *PlayerLineup, lineupHero *PlayerLineupHero) bool {
return this.calcHeroAttrs(hero, return this.calcHeroAttrs(hero,
@ -390,7 +320,7 @@ func (this *Player) UpdateHeroAttrs(hero *PlayerHero) bool {
for _, lineup := range this.Lineup { for _, lineup := range this.Lineup {
if lineup.Active { if lineup.Active {
for _, lineupHero := range lineup.Heroes { for _, lineupHero := range lineup.Heroes {
if lineupHero != nil && lineupHero.HeroUid == hero.Uid { if lineupHero.HeroUid == hero.Uid {
return this.updateHeroAttrs(hero, lineup, lineupHero) return this.updateHeroAttrs(hero, lineup, lineupHero)
} }
} }
@ -406,12 +336,16 @@ func (this *Player) reduceHero(hero *PlayerHero, logType LogType) *pb.HeroChange
this.WipeModel(hero) this.WipeModel(hero)
//if logType > LogTypeNone { //if logType > LogTypeNone {
// this.manager.eventManager.PlayerHeroConsume(this, logType, hero.Id, itemNum) // this.manager.eventManager.PlayerHeroConsume(this, logType, itemId, itemNum)
//} //}
return &pb.HeroChange{ChangeType: pb.ChangeType_Delete, Hero: hero.BuildMsgHero()} return &pb.HeroChange{ChangeType: pb.ChangeType_Delete, Hero: hero.BuildMsgHero()}
} }
func (this *Player) ReduceHero(hero *PlayerHero, logType LogType) {
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), &pb.HeroChangeListAck{ChangeList: []*pb.HeroChange{this.reduceHero(hero, logType)}})
}
func (this *Player) ReduceHeroes(heroes map[uint64]*PlayerHero, logType LogType) { func (this *Player) ReduceHeroes(heroes map[uint64]*PlayerHero, logType LogType) {
var changeList = make([]*pb.HeroChange, 0, len(heroes)) var changeList = make([]*pb.HeroChange, 0, len(heroes))
for _, hero := range heroes { for _, hero := range heroes {

View File

@ -12,10 +12,7 @@ type PlayerItem struct {
Expired int64 `bson:"expired"` Expired int64 `bson:"expired"`
} }
func (this *PlayerItem) BuildMsgItem(deleted ...bool) *pb.Item { func (this *PlayerItem) BuildMsgItem() *pb.Item {
if len(deleted) > 0 && deleted[0] {
return &pb.Item{ItemId: this.Id}
}
return &pb.Item{ItemId: this.Id, ItemNum: this.Num, Expired: this.Expired} return &pb.Item{ItemId: this.Id, ItemNum: this.Num, Expired: this.Expired}
} }
@ -160,13 +157,8 @@ func (this *Player) CheckItem(itemId, itemNum uint32) (bool, proto.TipError) {
return true, nil return true, nil
} }
return false, proto.TipItemNotEnough return false, proto.TipItemNotEnough
case pb.ItemType_ItemHero:
case pb.ItemType_ItemEquip: case pb.ItemType_ItemEquip:
case pb.ItemType_ItemTreasure: case pb.ItemType_ItemTreasure:
if this.CheckTreasure(uint32(itemTable.Value), itemNum) {
return true, nil
}
return false, proto.TipItemNotEnough
case pb.ItemType_ItemArtifact: case pb.ItemType_ItemArtifact:
case pb.ItemType_ItemSack: case pb.ItemType_ItemSack:
case pb.ItemType_ItemOrnament: case pb.ItemType_ItemOrnament:
@ -197,19 +189,17 @@ func (this *Player) reduceItem(itemId, itemNum uint32, logType LogType) {
item.Num -= itemNum item.Num -= itemNum
var deleted = false
var changeType pb.ChangeType var changeType pb.ChangeType
if item.Num == 0 { if item.Num == 0 {
delete(this.Item, item.Id) delete(this.Item, item.Id)
this.WipeModel(item) this.WipeModel(item)
deleted = true
changeType = pb.ChangeType_Delete changeType = pb.ChangeType_Delete
} else { } else {
this.SaveModel(item) this.SaveModel(item)
changeType = pb.ChangeType_Changed changeType = pb.ChangeType_Changed
} }
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemChange), &pb.ItemChangeListAck{ChangeList: []*pb.ItemChange{{Item: item.BuildMsgItem(deleted), ChangeType: changeType}}}) _ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemChange), &pb.ItemChangeListAck{ChangeList: []*pb.ItemChange{{Item: item.BuildMsgItem(), ChangeType: changeType}}})
//if logType > LogTypeNone { //if logType > LogTypeNone {
// this.manager.eventManager.PlayerItemConsume(this, logType, itemId, itemNum) // this.manager.eventManager.PlayerItemConsume(this, logType, itemId, itemNum)
@ -231,10 +221,8 @@ func (this *Player) ReduceItem(itemId, itemNum uint32, logType LogType) {
this.ReduceMoney(pb.MoneyType(itemTable.SubType), itemNum, logType) this.ReduceMoney(pb.MoneyType(itemTable.SubType), itemNum, logType)
case pb.ItemType_ItemProp: case pb.ItemType_ItemProp:
this.reduceItem(itemId, itemNum, logType) this.reduceItem(itemId, itemNum, logType)
case pb.ItemType_ItemHero:
case pb.ItemType_ItemEquip: case pb.ItemType_ItemEquip:
case pb.ItemType_ItemTreasure: case pb.ItemType_ItemTreasure:
this.ReduceTreasure(uint32(itemTable.Value), itemNum, logType)
case pb.ItemType_ItemArtifact: case pb.ItemType_ItemArtifact:
case pb.ItemType_ItemSack: case pb.ItemType_ItemSack:
case pb.ItemType_ItemOrnament: case pb.ItemType_ItemOrnament:

View File

@ -3,7 +3,6 @@ package logic
import ( import (
"ecs/proto/pb" "ecs/proto/pb"
"ecs/servers/game/data" "ecs/servers/game/data"
"github.com/oylshe1314/framework/util"
"sort" "sort"
) )
@ -15,10 +14,7 @@ type PlayerLineup struct {
Helper [8]uint64 `bson:"helper"` Helper [8]uint64 `bson:"helper"`
} }
func (this *PlayerLineup) BuildMsgLineup(deleted ...bool) *pb.Lineup { func (this *PlayerLineup) BuildMsgLineup() *pb.Lineup {
if len(deleted) > 0 && deleted[0] {
return &pb.Lineup{Uid: this.Uid}
}
var msg = &pb.Lineup{Uid: this.Uid, Name: this.Name, Active: this.Active} var msg = &pb.Lineup{Uid: this.Uid, Name: this.Name, Active: this.Active}
if this.Active { if this.Active {
msg.HeroList = make([]*pb.LineupHero, 8) msg.HeroList = make([]*pb.LineupHero, 8)
@ -34,46 +30,11 @@ func (this *PlayerLineup) BuildMsgLineup(deleted ...bool) *pb.Lineup {
return msg return msg
} }
func (this *Player) SendLineupHeroChange(lineups ...*PlayerLineup) { func (this *Player) CheckUpgradeMaster(masterType pb.UpgradeMasterType, preLevel, curLevel uint32, heroUid uint64) {
var heroChangeList []*pb.HeroChange
for _, lineup := range lineups {
if lineup == nil {
continue
}
for _, lineupHero := range lineup.Heroes {
if lineupHero == nil {
continue
}
if hero, ok := this.Hero[lineupHero.HeroUid]; ok {
if lineup.Active {
if this.updateHeroAttrs(hero, lineup, lineupHero) {
heroChangeList = append(heroChangeList, &pb.HeroChange{ChangeType: pb.ChangeType_Changed, Hero: hero.BuildMsgHero()})
}
} else {
if this.updateHeroAttrs(hero, nil, nil) {
heroChangeList = append(heroChangeList, &pb.HeroChange{ChangeType: pb.ChangeType_Changed, Hero: hero.BuildMsgHero()})
}
}
}
}
}
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), pb.HeroChangeListAck{
ChangeList: heroChangeList,
})
}
func (this *Player) SendUpgradeMaster(masterType pb.UpgradeMasterType, preLevel, curLevel uint32, heroUid uint64) {
if heroUid == 0 { if heroUid == 0 {
return return
} }
var hero = this.Hero[heroUid]
if hero == nil {
return
}
var masterTables = this.manager.tables.UpgradeMaster.Find1(int(masterType)) var masterTables = this.manager.tables.UpgradeMaster.Find1(int(masterType))
if len(masterTables) == 0 { if len(masterTables) == 0 {
return return
@ -98,16 +59,24 @@ func (this *Player) SendUpgradeMaster(masterType pb.UpgradeMasterType, preLevel,
return return
} }
var lineup = util.MapFindValue(this.Lineup, func(v *PlayerLineup) bool { var lineup *PlayerLineup
return v.Active for _, v := range this.Lineup {
}) if v.Active {
lineup = v
}
}
if lineup == nil { if lineup == nil {
return return
} }
var lineupHero = util.SliceFindValue(lineup.Heroes[:], func(i int) bool { var lineupHero *PlayerLineupHero
return lineup.Heroes[i] != nil && lineup.Heroes[i].HeroUid == hero.Uid for _, v := range lineup.Heroes {
}) if v.HeroUid == heroUid {
lineupHero = v
}
}
if lineupHero == nil { if lineupHero == nil {
return return
} }
@ -163,12 +132,6 @@ func (this *Player) SendUpgradeMaster(masterType pb.UpgradeMasterType, preLevel,
} }
_ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleUpgradeMaster), ack) _ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleUpgradeMaster), ack)
if this.updateHeroAttrs(hero, lineup, lineupHero) {
_ = this.Send(uint16(pb.ModId_ModuleHero), uint16(pb.MsgId_ModHeroChange), pb.HeroChangeListAck{
ChangeList: []*pb.HeroChange{{ChangeType: pb.ChangeType_Changed, Hero: hero.BuildMsgHero()}},
})
}
} }
func (this *Player) BuildMsgLineupListAck() *pb.LineupListAck { func (this *Player) BuildMsgLineupListAck() *pb.LineupListAck {

View File

@ -1,9 +1,6 @@
package logic package logic
import ( import "ecs/proto/pb"
"ecs/proto/pb"
"github.com/oylshe1314/framework/util"
)
type PlayerTreasure struct { type PlayerTreasure struct {
Uid uint64 `bson:"uid" key:"1"` Uid uint64 `bson:"uid" key:"1"`
@ -11,122 +8,21 @@ type PlayerTreasure struct {
Exp uint32 `bson:"exp"` Exp uint32 `bson:"exp"`
Level uint32 `bson:"level"` Level uint32 `bson:"level"`
RefineLevel uint32 `bson:"refine_level"` RefineLevel uint32 `bson:"refine_level"`
Holes1 []uint64 `bson:"holes"`
Holes2 []uint64 `bson:"holes"`
HeroUid uint64 `bson:"hero_id"` HeroUid uint64 `bson:"hero_id"`
} }
func (this *PlayerTreasure) BuildMsgTreasure(deleted ...bool) *pb.Treasure { func (this *PlayerTreasure) BuildMsgTreasure() *pb.Treasure {
if len(deleted) > 0 && deleted[0] {
return &pb.Treasure{Uid: this.Uid}
}
return &pb.Treasure{ return &pb.Treasure{
Uid: this.Uid, Uid: this.Uid,
Id: this.Id, Id: this.Id,
Exp: this.Exp,
Level: this.Level,
RefineLevel: this.RefineLevel,
Holes1: this.Holes1,
Holes2: this.Holes2,
HeroUid: this.HeroUid, HeroUid: this.HeroUid,
} }
} }
func (this *Player) AddTreasures(treasureId, nums uint32, logType LogType) bool { func (this *Player) AddTreasures(equipId, nums uint32, logType LogType) bool {
var treasureTable = this.manager.tables.Treasure.Find1(int(treasureId))
if treasureTable == nil {
this.manager.logger.Errorf("Table 'Treasure' was not found, treasureId: %d, level: %d", treasureId, 1)
return false return false
} }
var levelTable = this.manager.tables.TreasureLevel.Find3(treasureTable.Id, 1)
if levelTable == nil {
this.manager.logger.Errorf("Table 'TreasureLevel' was not found, treasureId %d, level: %d", treasureTable.Id, 1)
return false
}
var refineTable = this.manager.tables.TreasureRefine.Find3(treasureTable.Id, 0)
if refineTable == nil {
this.manager.logger.Errorf("Table 'EquipRefine' was not fount, treasureId %d, level: %d", treasureTable.Id, 1)
return false
}
if nums < 1 {
nums = 1
}
var changeList []*pb.TreasureChange
for range nums {
var treasure = &PlayerTreasure{
Uid: util.RandomUid(),
Id: uint32(treasureTable.Id),
Exp: 0,
Level: uint32(levelTable.Level),
RefineLevel: uint32(refineTable.RefineLevel),
Holes1: make([]uint64, treasureTable.Holes1),
Holes2: make([]uint64, treasureTable.Holes2),
HeroUid: 0,
}
this.Treasure[treasure.Uid] = treasure
this.SaveModel(treasure)
changeList = append(changeList, &pb.TreasureChange{ChangeType: pb.ChangeType_Add, Treasure: treasure.BuildMsgTreasure()})
//this.CheckAchievement(proto.AchievementTypeEquipLevel, uint32(treasureTable.Level), 1)
}
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureChange), &pb.TreasureChangeListAck{
ChangeList: changeList,
})
return true
}
func (this *Player) CheckTreasure(treasureId uint32, nums uint32) bool {
for _, treasure := range this.Treasure {
if treasure.Id == treasureId && treasure.Level <= 1 && treasure.RefineLevel == 0 && treasure.HeroUid == 0 {
nums -= 1
if nums == 0 {
return true
}
}
}
return false
}
func (this *Player) reduceTreasure(treasure *PlayerTreasure, logType LogType) *pb.TreasureChange {
delete(this.Treasure, treasure.Uid)
this.WipeModel(treasure)
//if logType > LogTypeNone {
// this.manager.eventManager.PlayerTreasureConsume(this, logType, treasure.Id, itemNum)
//}
return &pb.TreasureChange{ChangeType: pb.ChangeType_Delete, Treasure: treasure.BuildMsgTreasure()}
}
func (this *Player) ReduceTreasures(treasures map[uint64]*PlayerTreasure, logType LogType) {
var changeList = make([]*pb.TreasureChange, 0, len(treasures))
for _, treasure := range treasures {
changeList = append(changeList, this.reduceTreasure(treasure, logType))
}
_ = this.Send(uint16(pb.ModId_ModuleItem), uint16(pb.MsgId_ModItemTreasureChange), &pb.TreasureChangeListAck{ChangeList: changeList})
}
func (this *Player) ReduceTreasure(treasureId uint32, nums uint32, logType LogType) {
var treasures = map[uint64]*PlayerTreasure{}
for _, treasure := range this.Treasure {
if treasure.Id == treasureId && treasure.Level <= 1 && treasure.RefineLevel == 0 && treasure.HeroUid == 0 {
treasures[treasure.Uid] = treasure
if uint32(len(treasures)) == nums {
this.ReduceTreasures(treasures, logType)
return
}
}
}
this.manager.logger.Error("Reduce treasure out of range, did not check before deducting?")
}
func (this *Player) BuildMsgTreasureListAck() *pb.TreasureListAck { func (this *Player) BuildMsgTreasureListAck() *pb.TreasureListAck {
var list []*pb.Treasure var list []*pb.Treasure
for _, treasure := range this.Treasure { for _, treasure := range this.Treasure {

View File

@ -163,8 +163,6 @@ func (this *gameServer) Init() (err error) {
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroGeneral), this.playerHandler.LineupHeroGeneral) this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroGeneral), this.playerHandler.LineupHeroGeneral)
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroOrnament), this.playerHandler.LineupHeroOrnament) this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHeroOrnament), this.playerHandler.LineupHeroOrnament)
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHelperChange), this.playerHandler.LineupHelperChange) this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupHelperChange), this.playerHandler.LineupHelperChange)
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupEquipInlay), this.playerHandler.LineupEquipInlay)
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupTreasureInlay), this.playerHandler.LineupTreasureInlay)
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupCreate), this.playerHandler.LineupCreate) this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupCreate), this.playerHandler.LineupCreate)
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChangeName), this.playerHandler.LineupChangeName) this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupChangeName), this.playerHandler.LineupChangeName)
this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupActivate), this.playerHandler.LineupActivate) this.playerManager.Handler(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRoleLineupActivate), this.playerHandler.LineupActivate)
@ -284,8 +282,7 @@ func (this *gameServer) Close() error {
} }
func (this *gameServer) Load(dir string) error { func (this *gameServer) Load(dir string) error {
var dataTables = data.NewTables(dir) var dataTables, err = data.NewTables(dir)
var err = dataTables.Load()
if err != nil { if err != nil {
return err return err
} }