mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 15:52:27 +08:00
fix nil ptr panic
This commit is contained in:
@@ -158,7 +158,7 @@ func (g *GameManager) run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) gameMainLoopD() {
|
func (g *GameManager) gameMainLoopD() {
|
||||||
for times := 1; times <= 1000; times++ {
|
for times := 1; times <= 100000; times++ {
|
||||||
logger.Warn("start game main loop, times: %v", times)
|
logger.Warn("start game main loop, times: %v", times)
|
||||||
g.gameMainLoop()
|
g.gameMainLoop()
|
||||||
logger.Warn("game main loop stop")
|
logger.Warn("game main loop stop")
|
||||||
|
|||||||
@@ -325,17 +325,20 @@ 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 player.Pause {
|
if player.Pause {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取玩家处于的载具实体
|
// 获取玩家处于的载具实体
|
||||||
entity := scene.GetEntity(player.VehicleInfo.InVehicleEntityId)
|
entity := scene.GetEntity(player.VehicleInfo.InVehicleEntityId)
|
||||||
|
if entity == nil {
|
||||||
|
// 更新玩家耐力
|
||||||
|
g.UpdatePlayerStamina(player, player.StaminaInfo.CostStamina)
|
||||||
|
return
|
||||||
|
}
|
||||||
// 确保实体类型是否为载具 且 根据玩家是否处于载具中更新耐力
|
// 确保实体类型是否为载具 且 根据玩家是否处于载具中更新耐力
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetEntity := entity.GetGadgetEntity()
|
||||||
if entity != nil && (gadgetEntity != nil && gadgetEntity.GetGadgetVehicleEntity() != nil) && g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
if gadgetEntity != nil && gadgetEntity.GetGadgetVehicleEntity() != nil && g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
||||||
// 更新载具耐力
|
// 更新载具耐力
|
||||||
g.UpdateVehicleStamina(player, entity, player.StaminaInfo.CostStamina)
|
g.UpdateVehicleStamina(player, entity, player.StaminaInfo.CostStamina)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -346,10 +346,10 @@ func (t *TickManager) onTickSecond(now int64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// GCG游戏Tick
|
// // GCG游戏Tick
|
||||||
for _, game := range GCG_MANAGER.gameMap {
|
// for _, game := range GCG_MANAGER.gameMap {
|
||||||
game.onTick()
|
// game.onTick()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TickManager) onTick200MilliSecond(now int64) {
|
func (t *TickManager) onTick200MilliSecond(now int64) {
|
||||||
|
|||||||
Reference in New Issue
Block a user