简化配置表读取

This commit is contained in:
flswld
2023-03-16 16:26:14 +08:00
parent 2a3ce25898
commit 5e5492943d
51 changed files with 418 additions and 2560 deletions

View File

@@ -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()
// 进入场景

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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:

View File

@@ -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 {