From f2052fe31a966e6ba7c9e07d5101fb9e2ba891e2 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 18 Jun 2020 20:22:13 -0700 Subject: [PATCH] Null checks --- client/game/mode/fugitive/hud/EndGameHud.gd | 2 +- common/game/mode/fugitive/cop_car/CopCar.gd | 7 ++++++- common/game/mode/fugitive/seeker/Seeker.gd | 2 +- extras/release-scripts/README.txt | 2 +- networking/GameData.gd | 4 +++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/client/game/mode/fugitive/hud/EndGameHud.gd b/client/game/mode/fugitive/hud/EndGameHud.gd index dee58d04..455487b5 100644 --- a/client/game/mode/fugitive/hud/EndGameHud.gd +++ b/client/game/mode/fugitive/hud/EndGameHud.gd @@ -62,7 +62,7 @@ func team_won(winningTeam: int): for playerObj in hiders: var playerInfoData := GameData.get_player(playerObj.id) - if playerObj != null: + if playerObj != null and playerInfoData != null: var playerStatsListItem := playerStatsListItemScene.instance() playerStatsListItem.populate(playerInfoData, playerObj) playerList.add_child(playerStatsListItem) diff --git a/common/game/mode/fugitive/cop_car/CopCar.gd b/common/game/mode/fugitive/cop_car/CopCar.gd index 5513c541..176d6a3d 100644 --- a/common/game/mode/fugitive/cop_car/CopCar.gd +++ b/common/game/mode/fugitive/cop_car/CopCar.gd @@ -114,8 +114,10 @@ remotesync func on_request_enter_car(playerId: int): var player = GameData.currentGame.get_player(playerId) var isHider = player.playerType == FugitiveTeamResolver.PlayerType.Hider + if player == null: + canEnter = false # No one can enter if they are frozen - if seatIndex < 0: + elif seatIndex < 0: print("No free seats in car") canEnter = false elif player.frozen: @@ -148,6 +150,9 @@ remotesync func on_car_entered(playerId: int, seatIndex: int): mutex.lock() var player = GameData.currentGame.get_player(playerId) var seat = seats[seatIndex] + + if player == null: + return var isHider = player.playerType == FugitiveTeamResolver.PlayerType.Hider # Car starts locked, first cop unlocks it diff --git a/common/game/mode/fugitive/seeker/Seeker.gd b/common/game/mode/fugitive/seeker/Seeker.gd index 25c7e61c..0e0ab659 100644 --- a/common/game/mode/fugitive/seeker/Seeker.gd +++ b/common/game/mode/fugitive/seeker/Seeker.gd @@ -94,7 +94,7 @@ func body_entered_detection_radius(body: Node): if gameStarted and not gameEnded: if body.has_method("get_player"): var player = body.get_player() - if player.playerType == FugitiveTeamResolver.PlayerType.Hider: + if player != null and player.playerType == FugitiveTeamResolver.PlayerType.Hider: # 1) Neither Hider nor Seeker may be in a car # 2) Hider must not be in a win zone # 3) Hider must not be frozen diff --git a/extras/release-scripts/README.txt b/extras/release-scripts/README.txt index d2b00023..89c99851 100644 --- a/extras/release-scripts/README.txt +++ b/extras/release-scripts/README.txt @@ -1,5 +1,5 @@ 1) Apply credentials patch in git -2) Export All from Godot +2) Export All from Godot (Release) 3) run pack-releases.bat 4) run itch-push-all.bat 5) Upload Quest build to GitHub releases diff --git a/networking/GameData.gd b/networking/GameData.gd index 9323e28f..6409227a 100644 --- a/networking/GameData.gd +++ b/networking/GameData.gd @@ -81,7 +81,9 @@ func get_current_player_id() -> int: func update_player_from_raw_data(player_data_dictionary: Dictionary): var playerId = player_data_dictionary.id - get_player(playerId).load(player_data_dictionary) + var player := get_player(playerId) + if player != null: + player.load(player_data_dictionary) func get_host() -> PlayerData: