From cf4804c44412eb7202d970853dda33ecce903667 Mon Sep 17 00:00:00 2001 From: UnKownOwO <80520429@qq.com> Date: Mon, 19 Dec 2022 17:53:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E8=BD=BD=E5=85=B7?= =?UTF-8?q?=E5=90=8E=E4=B8=8D=E6=8C=81=E7=BB=AD=E5=9B=9E=E5=A4=8D=E6=88=96?= =?UTF-8?q?=E6=B6=88=E8=80=97=E8=80=90=E5=8A=9B=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gs/game/user_stamina.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/gs/game/user_stamina.go b/gs/game/user_stamina.go index 9c5c7d3d..bdf76a3d 100644 --- a/gs/game/user_stamina.go +++ b/gs/game/user_stamina.go @@ -308,15 +308,8 @@ func (g *GameManager) SustainStaminaHandler(player *model.Player) { // 获取玩家处于的载具实体 entity := scene.GetEntity(player.VehicleInfo.InVehicleEntityId) - if entity == nil { - return - } - // 确保实体类型是否为载具 - if entity.gadgetEntity == nil || entity.gadgetEntity.gadgetVehicleEntity == nil { - return - } - // 根据玩家是否处于载具中更新耐力 - if g.IsPlayerInVehicle(player, entity.gadgetEntity.gadgetVehicleEntity) { + // 确保实体类型是否为载具 且 根据玩家是否处于载具中更新耐力 + if entity != nil && (entity.gadgetEntity != nil && entity.gadgetEntity.gadgetVehicleEntity != nil) && g.IsPlayerInVehicle(player, entity.gadgetEntity.gadgetVehicleEntity) { // 更新载具耐力 g.UpdateVehicleStamina(player, entity, player.StaminaInfo.CostStamina) } else { @@ -442,7 +435,7 @@ func (g *GameManager) SetPlayerStamina(player *model.Player, stamina uint32) { // 设置玩家的耐力 prop := constant.PlayerPropertyConst.PROP_CUR_PERSIST_STAMINA player.PropertiesMap[prop] = stamina - // logger.Debug("player stamina set, stamina: %v", stamina) + //logger.Debug("player stamina set, stamina: %v", stamina) // PacketPlayerPropNotify playerPropNotify := new(proto.PlayerPropNotify)