mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-08 22:12:25 +08:00
给予已有角色重复问题修复
This commit is contained in:
@@ -15,7 +15,8 @@ func TestClientProtoGen(t *testing.T) {
|
||||
for _, entry := range dir {
|
||||
split := strings.Split(entry.Name(), ".")
|
||||
if len(split) != 2 {
|
||||
panic("file name error")
|
||||
continue
|
||||
//panic("file name error")
|
||||
}
|
||||
nameList = append(nameList, split[0])
|
||||
}
|
||||
@@ -23,20 +24,18 @@ func TestClientProtoGen(t *testing.T) {
|
||||
fileData := "package client_proto\n"
|
||||
fileData += "\n"
|
||||
fileData += "import (\n"
|
||||
fileData += "\"hk4e/gate/client_proto/proto\"\n"
|
||||
fileData += "pb \"google.golang.org/protobuf/proto\"\n"
|
||||
fileData += "\t\"hk4e/gate/client_proto/proto\"\n"
|
||||
fileData += ")\n"
|
||||
fileData += "\n"
|
||||
fileData += "func (c *ClientCmdProtoMap) GetClientProtoObjByName(protoObjName string) any {\n"
|
||||
fileData += "switch protoObjName {\n"
|
||||
fileData += "\tswitch protoObjName {\n"
|
||||
for _, protoObjName := range nameList {
|
||||
fileData += "case \"" + protoObjName + "\":\nreturn new(proto." + protoObjName + ")\n"
|
||||
fileData += "\tcase \"" + protoObjName + "\":\n\t\treturn new(proto." + protoObjName + ")\n"
|
||||
}
|
||||
fileData += "default:\n"
|
||||
fileData += "return nil\n"
|
||||
fileData += "\tdefault:\n"
|
||||
fileData += "\t\treturn nil\n"
|
||||
fileData += "\t}\n"
|
||||
fileData += "}\n"
|
||||
fileData += "}\n"
|
||||
fileData += "\n"
|
||||
|
||||
err = os.WriteFile("../client_proto_gen.go", []byte(fileData), 0644)
|
||||
if err != nil {
|
||||
|
||||
@@ -34,12 +34,13 @@ func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
player.AddAvatar(avatarId)
|
||||
avatar := player.AvatarMap[avatarId]
|
||||
if avatar == nil {
|
||||
logger.Error("avatar is nil, avatarId", avatarId)
|
||||
// 判断玩家是否已有该角色
|
||||
_, ok := player.AvatarMap[avatarId]
|
||||
if ok {
|
||||
// TODO 如果已有转换命座材料
|
||||
return
|
||||
}
|
||||
player.AddAvatar(avatarId)
|
||||
|
||||
// 添加初始武器
|
||||
avatarDataConfig, ok := gdc.CONF.AvatarDataMap[int32(avatarId)]
|
||||
@@ -55,7 +56,7 @@ func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
|
||||
g.UpdateUserAvatarFightProp(player.PlayerID, avatarId)
|
||||
|
||||
avatarAddNotify := &proto.AvatarAddNotify{
|
||||
Avatar: g.PacketAvatarInfo(avatar),
|
||||
Avatar: g.PacketAvatarInfo(player.AvatarMap[avatarId]),
|
||||
IsInTeam: false,
|
||||
}
|
||||
g.SendMsg(cmd.AvatarAddNotify, userId, player.ClientSeq, avatarAddNotify)
|
||||
|
||||
Reference in New Issue
Block a user