From b9f07a19d7987ae784b77de457040f980bf843db Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Wed, 3 Jul 2024 00:11:08 +0200 Subject: [PATCH] Add additional safety checks --- addons/dialogic/Modules/Character/subsystem_portraits.gd | 4 ++-- addons/dialogic/Modules/Voice/subsystem_voice.gd | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/dialogic/Modules/Character/subsystem_portraits.gd b/addons/dialogic/Modules/Character/subsystem_portraits.gd index e09025417..be96640c2 100644 --- a/addons/dialogic/Modules/Character/subsystem_portraits.gd +++ b/addons/dialogic/Modules/Character/subsystem_portraits.gd @@ -554,8 +554,8 @@ func leave_all_characters(animation_name:="", animation_length:=0.0, animation_w ## Return `null` if the [param character] is not part of the scene. func get_character_node(character: DialogicCharacter) -> Node: if is_character_joined(character): - return dialogic.current_state_info['portraits'][character.resource_path].node - + if is_instance_valid(dialogic.current_state_info['portraits'][character.resource_path].node): + return dialogic.current_state_info['portraits'][character.resource_path].node return null diff --git a/addons/dialogic/Modules/Voice/subsystem_voice.gd b/addons/dialogic/Modules/Voice/subsystem_voice.gd index d289a123b..2f6368c75 100644 --- a/addons/dialogic/Modules/Voice/subsystem_voice.gd +++ b/addons/dialogic/Modules/Voice/subsystem_voice.gd @@ -66,8 +66,7 @@ func _ready() -> void: ## Whether the current event is a text event and has a voice ## event before it. func is_voiced(index: int) -> bool: - if dialogic.current_timeline_events[index] is DialogicTextEvent: - + if index > 0 and dialogic.current_timeline_events[index] is DialogicTextEvent: if dialogic.current_timeline_events[index-1] is DialogicVoiceEvent: return true