Skip to content

Commit

Permalink
Null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Wavesonics committed Jun 19, 2020
1 parent e0516e1 commit f2052fe
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/game/mode/fugitive/hud/EndGameHud.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion common/game/mode/fugitive/cop_car/CopCar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion common/game/mode/fugitive/seeker/Seeker.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion extras/release-scripts/README.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion networking/GameData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f2052fe

Please sign in to comment.