mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
fix nil ptr panic
This commit is contained in:
@@ -158,7 +158,7 @@ func (g *GameManager) run() {
|
||||
}
|
||||
|
||||
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)
|
||||
g.gameMainLoop()
|
||||
logger.Warn("game main loop stop")
|
||||
|
||||
@@ -325,17 +325,20 @@ func (g *GameManager) VehicleRestoreStaminaHandler(player *model.Player) {
|
||||
func (g *GameManager) SustainStaminaHandler(player *model.Player) {
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
|
||||
// 玩家暂停状态不更新耐力
|
||||
if player.Pause {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取玩家处于的载具实体
|
||||
entity := scene.GetEntity(player.VehicleInfo.InVehicleEntityId)
|
||||
if entity == nil {
|
||||
// 更新玩家耐力
|
||||
g.UpdatePlayerStamina(player, player.StaminaInfo.CostStamina)
|
||||
return
|
||||
}
|
||||
// 确保实体类型是否为载具 且 根据玩家是否处于载具中更新耐力
|
||||
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)
|
||||
} else {
|
||||
|
||||
@@ -346,10 +346,10 @@ func (t *TickManager) onTickSecond(now int64) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// GCG游戏Tick
|
||||
for _, game := range GCG_MANAGER.gameMap {
|
||||
game.onTick()
|
||||
}
|
||||
// // GCG游戏Tick
|
||||
// for _, game := range GCG_MANAGER.gameMap {
|
||||
// game.onTick()
|
||||
// }
|
||||
}
|
||||
|
||||
func (t *TickManager) onTick200MilliSecond(now int64) {
|
||||
|
||||
Reference in New Issue
Block a user