mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-03-01 00:35:36 +08:00
修复未在队伍角色无法更换时装的问题
顺便给获取scene的都判断了下nil
This commit is contained in:
@@ -36,6 +36,14 @@ func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb
|
|||||||
logger.Debug("user change avatar costume, uid: %v", player.PlayerID)
|
logger.Debug("user change avatar costume, uid: %v", player.PlayerID)
|
||||||
req := payloadMsg.(*proto.AvatarChangeCostumeReq)
|
req := payloadMsg.(*proto.AvatarChangeCostumeReq)
|
||||||
|
|
||||||
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
g.SendError(cmd.AvatarChangeCostumeRsp, player, &proto.AvatarChangeCostumeRsp{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 确保角色存在
|
// 确保角色存在
|
||||||
avatar, ok := player.GameObjectGuidMap[req.AvatarGuid].(*model.Avatar)
|
avatar, ok := player.GameObjectGuidMap[req.AvatarGuid].(*model.Avatar)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -44,6 +52,7 @@ func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 确保要更换的时装已获得
|
||||||
exist := false
|
exist := false
|
||||||
for _, v := range player.CostumeList {
|
for _, v := range player.CostumeList {
|
||||||
if v == req.CostumeId {
|
if v == req.CostumeId {
|
||||||
@@ -62,11 +71,18 @@ func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb
|
|||||||
// 设置角色时装
|
// 设置角色时装
|
||||||
avatar.Costume = req.CostumeId
|
avatar.Costume = req.CostumeId
|
||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
// 角色更换时装通知
|
||||||
scene := world.GetSceneById(player.SceneId)
|
|
||||||
|
|
||||||
avatarChangeCostumeNotify := new(proto.AvatarChangeCostumeNotify)
|
avatarChangeCostumeNotify := new(proto.AvatarChangeCostumeNotify)
|
||||||
avatarChangeCostumeNotify.EntityInfo = g.PacketSceneEntityInfoAvatar(scene, player, avatar.AvatarId)
|
// 要更换时装的角色实体不存在代表更换的是仓库内的角色
|
||||||
|
if scene.GetWorld().GetPlayerWorldAvatarEntityId(player, avatar.AvatarId) == 0 {
|
||||||
|
avatarChangeCostumeNotify.EntityInfo = &proto.SceneEntityInfo{
|
||||||
|
Entity: &proto.SceneEntityInfo_Avatar{
|
||||||
|
Avatar: g.PacketSceneAvatarInfo(scene, player, avatar.AvatarId),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
avatarChangeCostumeNotify.EntityInfo = g.PacketSceneEntityInfoAvatar(scene, player, avatar.AvatarId)
|
||||||
|
}
|
||||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||||
g.SendMsg(cmd.AvatarChangeCostumeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarChangeCostumeNotify)
|
g.SendMsg(cmd.AvatarChangeCostumeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarChangeCostumeNotify)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ func (g *GameManager) MassiveEntityElementOpBatchNotify(player *model.Player, pa
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
ntf.OpIdx = scene.GetMeeoIndex()
|
ntf.OpIdx = scene.GetMeeoIndex()
|
||||||
scene.SetMeeoIndex(scene.GetMeeoIndex() + 1)
|
scene.SetMeeoIndex(scene.GetMeeoIndex() + 1)
|
||||||
g.SendToWorldA(world, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, ntf)
|
g.SendToWorldA(world, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, ntf)
|
||||||
@@ -100,6 +104,10 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, entry := range req.InvokeList {
|
for _, entry := range req.InvokeList {
|
||||||
switch entry.ArgumentType {
|
switch entry.ArgumentType {
|
||||||
case proto.CombatTypeArgument_COMBAT_EVT_BEING_HIT:
|
case proto.CombatTypeArgument_COMBAT_EVT_BEING_HIT:
|
||||||
@@ -261,6 +269,10 @@ func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector,
|
|||||||
aoiManager, exist := sceneBlockAoiMap[player.SceneId]
|
aoiManager, exist := sceneBlockAoiMap[player.SceneId]
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
if exist {
|
if exist {
|
||||||
oldGid := aoiManager.GetGidByPos(float32(oldPos.X), 0.0, float32(oldPos.Z))
|
oldGid := aoiManager.GetGidByPos(float32(oldPos.X), 0.0, float32(oldPos.Z))
|
||||||
newGid := aoiManager.GetGidByPos(float32(newPos.X), 0.0, float32(newPos.Z))
|
newGid := aoiManager.GetGidByPos(float32(newPos.X), 0.0, float32(newPos.Z))
|
||||||
@@ -531,6 +543,10 @@ func (g *GameManager) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.
|
|||||||
logger.Debug("EvtCreateGadgetNotify: %v", req)
|
logger.Debug("EvtCreateGadgetNotify: %v", req)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
scene.CreateEntityGadgetClient(&model.Vector{
|
scene.CreateEntityGadgetClient(&model.Vector{
|
||||||
X: float64(req.InitPos.X),
|
X: float64(req.InitPos.X),
|
||||||
Y: float64(req.InitPos.Y),
|
Y: float64(req.InitPos.Y),
|
||||||
@@ -552,6 +568,10 @@ func (g *GameManager) EvtDestroyGadgetNotify(player *model.Player, payloadMsg pb
|
|||||||
logger.Debug("EvtDestroyGadgetNotify: %v", req)
|
logger.Debug("EvtDestroyGadgetNotify: %v", req)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
scene.DestroyEntity(req.EntityId)
|
scene.DestroyEntity(req.EntityId)
|
||||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{req.EntityId})
|
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{req.EntityId})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,14 @@ func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.
|
|||||||
logger.Debug("user change avatar fly cloak, uid: %v", player.PlayerID)
|
logger.Debug("user change avatar fly cloak, uid: %v", player.PlayerID)
|
||||||
req := payloadMsg.(*proto.AvatarWearFlycloakReq)
|
req := payloadMsg.(*proto.AvatarWearFlycloakReq)
|
||||||
|
|
||||||
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
g.SendError(cmd.AvatarWearFlycloakRsp, player, &proto.AvatarWearFlycloakRsp{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 确保角色存在
|
// 确保角色存在
|
||||||
avatar, ok := player.GameObjectGuidMap[req.AvatarGuid].(*model.Avatar)
|
avatar, ok := player.GameObjectGuidMap[req.AvatarGuid].(*model.Avatar)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -44,6 +52,7 @@ func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 确保要更换的风之翼已获得
|
||||||
exist := false
|
exist := false
|
||||||
for _, v := range player.FlyCloakList {
|
for _, v := range player.FlyCloakList {
|
||||||
if v == req.FlycloakId {
|
if v == req.FlycloakId {
|
||||||
@@ -59,9 +68,6 @@ func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.
|
|||||||
// 设置角色风之翼
|
// 设置角色风之翼
|
||||||
avatar.FlyCloak = req.FlycloakId
|
avatar.FlyCloak = req.FlycloakId
|
||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
|
||||||
scene := world.GetSceneById(player.SceneId)
|
|
||||||
|
|
||||||
avatarFlycloakChangeNotify := &proto.AvatarFlycloakChangeNotify{
|
avatarFlycloakChangeNotify := &proto.AvatarFlycloakChangeNotify{
|
||||||
AvatarGuid: req.AvatarGuid,
|
AvatarGuid: req.AvatarGuid,
|
||||||
FlycloakId: req.FlycloakId,
|
FlycloakId: req.FlycloakId,
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, s
|
|||||||
player.SceneJump = jumpScene
|
player.SceneJump = jumpScene
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
oldScene := world.GetSceneById(oldSceneId)
|
oldScene := world.GetSceneById(oldSceneId)
|
||||||
|
if oldScene == nil {
|
||||||
|
logger.Error("old scene is nil, sceneId: %v", oldSceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
||||||
g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_REMOVE, []uint32{world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)})
|
g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_REMOVE, []uint32{world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)})
|
||||||
if jumpScene {
|
if jumpScene {
|
||||||
@@ -90,6 +94,10 @@ func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, s
|
|||||||
oldScene.RemovePlayer(player)
|
oldScene.RemovePlayer(player)
|
||||||
player.SceneId = newSceneId
|
player.SceneId = newSceneId
|
||||||
newScene := world.GetSceneById(newSceneId)
|
newScene := world.GetSceneById(newSceneId)
|
||||||
|
if newScene == nil {
|
||||||
|
logger.Error("new scene is nil, sceneId: %v", newSceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
newScene.AddPlayer(player)
|
newScene.AddPlayer(player)
|
||||||
}
|
}
|
||||||
player.SceneLoadState = model.SceneNone
|
player.SceneLoadState = model.SceneNone
|
||||||
|
|||||||
@@ -400,6 +400,10 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 仅仅把当前的场上角色的实体消失掉
|
// 仅仅把当前的场上角色的实体消失掉
|
||||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
|
|||||||
logger.Debug("user scene init finish, uid: %v", player.PlayerID)
|
logger.Debug("user scene init finish, uid: %v", player.PlayerID)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
serverTimeNotify := &proto.ServerTimeNotify{
|
serverTimeNotify := &proto.ServerTimeNotify{
|
||||||
ServerTime: uint64(time.Now().UnixMilli()),
|
ServerTime: uint64(time.Now().UnixMilli()),
|
||||||
@@ -240,6 +244,10 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
logger.Debug("user enter scene done, uid: %v", player.PlayerID)
|
logger.Debug("user enter scene done, uid: %v", player.PlayerID)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if world.GetMultiplayer() && world.IsPlayerFirstEnter(player) {
|
if world.GetMultiplayer() && world.IsPlayerFirstEnter(player) {
|
||||||
guestPostEnterSceneNotify := &proto.GuestPostEnterSceneNotify{
|
guestPostEnterSceneNotify := &proto.GuestPostEnterSceneNotify{
|
||||||
@@ -323,6 +331,10 @@ func (g *GameManager) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
gameTime := req.GameTime
|
gameTime := req.GameTime
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
scene.ChangeGameTime(gameTime)
|
scene.ChangeGameTime(gameTime)
|
||||||
|
|
||||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||||
@@ -412,6 +424,10 @@ func (g *GameManager) CreateConfigEntity(scene *Scene, objectId int64, entityCon
|
|||||||
func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify {
|
func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return new(proto.PlayerEnterSceneNotify)
|
||||||
|
}
|
||||||
player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000))
|
player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000))
|
||||||
playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
|
playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
|
||||||
SceneId: player.SceneId,
|
SceneId: player.SceneId,
|
||||||
@@ -460,6 +476,10 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyMp(
|
|||||||
) *proto.PlayerEnterSceneNotify {
|
) *proto.PlayerEnterSceneNotify {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return new(proto.PlayerEnterSceneNotify)
|
||||||
|
}
|
||||||
player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000))
|
player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000))
|
||||||
playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
|
playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
|
||||||
PrevSceneId: prevSceneId,
|
PrevSceneId: prevSceneId,
|
||||||
@@ -538,6 +558,10 @@ func (g *GameManager) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType
|
|||||||
func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType proto.VisionType, entityIdList []uint32, broadcast bool, aec bool) {
|
func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType proto.VisionType, entityIdList []uint32, broadcast bool, aec bool) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
// 如果总数量太多则分包发送
|
// 如果总数量太多则分包发送
|
||||||
times := int(math.Ceil(float64(len(entityIdList)) / float64(ENTITY_MAX_BATCH_SEND_NUM)))
|
times := int(math.Ceil(float64(len(entityIdList)) / float64(ENTITY_MAX_BATCH_SEND_NUM)))
|
||||||
for i := 0; i < times; i++ {
|
for i := 0; i < times; i++ {
|
||||||
|
|||||||
@@ -293,6 +293,10 @@ func (g *GameManager) SkillStartStamina(player *model.Player, casterId uint32, s
|
|||||||
func (g *GameManager) VehicleRestoreStaminaHandler(player *model.Player) {
|
func (g *GameManager) VehicleRestoreStaminaHandler(player *model.Player) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 玩家暂停状态不更新耐力
|
// 玩家暂停状态不更新耐力
|
||||||
if player.Pause {
|
if player.Pause {
|
||||||
@@ -323,6 +327,10 @@ func (g *GameManager) VehicleRestoreStaminaHandler(player *model.Player) {
|
|||||||
func (g *GameManager) SustainStaminaHandler(player *model.Player) {
|
func (g *GameManager) SustainStaminaHandler(player *model.Player) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
// 玩家暂停状态不更新耐力
|
// 玩家暂停状态不更新耐力
|
||||||
if player.Pause {
|
if player.Pause {
|
||||||
return
|
return
|
||||||
@@ -460,6 +468,10 @@ func (g *GameManager) DrownBackHandler(player *model.Player) {
|
|||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player))
|
activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player))
|
||||||
avatarEntity := scene.GetEntity(activeAvatar.GetAvatarEntityId())
|
avatarEntity := scene.GetEntity(activeAvatar.GetAvatarEntityId())
|
||||||
if avatarEntity == nil {
|
if avatarEntity == nil {
|
||||||
@@ -525,6 +537,10 @@ func (g *GameManager) HandleDrown(player *model.Player, stamina uint32) {
|
|||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player))
|
activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player))
|
||||||
avatarEntity := scene.GetEntity(activeAvatar.GetAvatarEntityId())
|
avatarEntity := scene.GetEntity(activeAvatar.GetAvatarEntityId())
|
||||||
if avatarEntity == nil {
|
if avatarEntity == nil {
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
targetAvatarGuid := req.Guid
|
targetAvatarGuid := req.Guid
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
targetAvatarId := player.GetAvatarIdByGuid(targetAvatarGuid)
|
targetAvatarId := player.GetAvatarIdByGuid(targetAvatarGuid)
|
||||||
oldAvatarId := world.GetPlayerActiveAvatarId(player)
|
oldAvatarId := world.GetPlayerActiveAvatarId(player)
|
||||||
if targetAvatarId == oldAvatarId {
|
if targetAvatarId == oldAvatarId {
|
||||||
@@ -211,6 +215,10 @@ func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeam
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
worldPlayerScene := world.GetSceneById(worldPlayer.SceneId)
|
worldPlayerScene := world.GetSceneById(worldPlayer.SceneId)
|
||||||
|
if worldPlayerScene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", worldPlayer.SceneId)
|
||||||
|
return new(proto.SceneTeamUpdateNotify)
|
||||||
|
}
|
||||||
worldPlayerAvatar := worldPlayer.AvatarMap[worldAvatar.GetAvatarId()]
|
worldPlayerAvatar := worldPlayer.AvatarMap[worldAvatar.GetAvatarId()]
|
||||||
equipIdList := make([]uint32, 0)
|
equipIdList := make([]uint32, 0)
|
||||||
weapon := worldPlayerAvatar.EquipWeapon
|
weapon := worldPlayerAvatar.EquipWeapon
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ import (
|
|||||||
func (g *GameManager) VehicleDestroyMotion(player *model.Player, entity *Entity, state proto.MotionState) {
|
func (g *GameManager) VehicleDestroyMotion(player *model.Player, entity *Entity, state proto.MotionState) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 状态等于 MOTION_STATE_DESTROY_VEHICLE 代表请求销毁
|
// 状态等于 MOTION_STATE_DESTROY_VEHICLE 代表请求销毁
|
||||||
if state == proto.MotionState_MOTION_DESTROY_VEHICLE {
|
if state == proto.MotionState_MOTION_DESTROY_VEHICLE {
|
||||||
@@ -29,6 +33,11 @@ func (g *GameManager) CreateVehicleReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 创建载具冷却时间
|
// 创建载具冷却时间
|
||||||
createVehicleCd := int64(5000) // TODO 冷却时间读取配置表
|
createVehicleCd := int64(5000) // TODO 冷却时间读取配置表
|
||||||
@@ -190,6 +199,11 @@ func (g *GameManager) VehicleInteractReq(player *model.Player, payloadMsg pb.Mes
|
|||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 获取载具实体
|
// 获取载具实体
|
||||||
entity := scene.GetEntity(req.EntityId)
|
entity := scene.GetEntity(req.EntityId)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package game
|
package game
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"hk4e/pkg/logger"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
@@ -223,6 +224,10 @@ func (g *GameManager) VideoPlayerUpdate(rgb bool) {
|
|||||||
}
|
}
|
||||||
world := WORLD_MANAGER.GetAiWorld()
|
world := WORLD_MANAGER.GetAiWorld()
|
||||||
scene := world.GetSceneById(3)
|
scene := world.GetSceneById(3)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", 3)
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, v := range SCREEN_ENTITY_ID_LIST {
|
for _, v := range SCREEN_ENTITY_ID_LIST {
|
||||||
scene.DestroyEntity(v)
|
scene.DestroyEntity(v)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,6 +340,10 @@ func (w *World) AddPlayer(player *model.Player, sceneId uint32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
scene := w.GetSceneById(sceneId)
|
scene := w.GetSceneById(sceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", sceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
scene.AddPlayer(player)
|
scene.AddPlayer(player)
|
||||||
w.InitPlayerTeamEntityId(player)
|
w.InitPlayerTeamEntityId(player)
|
||||||
}
|
}
|
||||||
@@ -459,6 +463,10 @@ func (w *World) GetWorldAvatarByEntityId(avatarEntityId uint32) *WorldAvatar {
|
|||||||
// InitPlayerWorldAvatar 初始化某玩家在世界队伍中的所有角色
|
// InitPlayerWorldAvatar 初始化某玩家在世界队伍中的所有角色
|
||||||
func (w *World) InitPlayerWorldAvatar(player *model.Player) {
|
func (w *World) InitPlayerWorldAvatar(player *model.Player) {
|
||||||
scene := w.GetSceneById(player.SceneId)
|
scene := w.GetSceneById(player.SceneId)
|
||||||
|
if scene == nil {
|
||||||
|
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, worldAvatar := range w.GetWorldAvatarList() {
|
for _, worldAvatar := range w.GetWorldAvatarList() {
|
||||||
if worldAvatar.uid != player.PlayerID {
|
if worldAvatar.uid != player.PlayerID {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user