fixed crash with puzzleholes if there is no trigger (#1098)

This commit is contained in:
Nemoel-Tomo 2023-05-05 11:03:29 +02:00 committed by GitHub
parent dda0ce85a4
commit f54e612e79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -230,6 +230,10 @@ void PuzzleDoneCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* co
// NOTE: Only execute code below if Triggertype is switch trigger.
auto triggerIndex = GetTriggerIndex(&receptacleItem);
if (triggerIndex == 0)
return;
int triggerType = (*(triggerIndex++) >> 8) & 0x3F;
if (triggerType != TRIGGER_TYPES::SWITCH)
@ -326,6 +330,10 @@ void PuzzleDoneCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* co
void PuzzleDone(ItemInfo* item, short itemNumber)
{
auto triggerIndex = GetTriggerIndex(item);
if (triggerIndex == 0)
return;
short triggerType = (*(triggerIndex++) >> 8) & 0x3F;
if (triggerType == TRIGGER_TYPES::SWITCH)
@ -437,6 +445,10 @@ void KeyHoleCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll)
auto* player = GetLaraInfo(laraItem);
short* triggerIndexPtr = GetTriggerIndex(keyHoleItem);
if (triggerIndexPtr == 0)
return;
short triggerType = (*(triggerIndexPtr++) >> 8) & 0x3F;
bool isActionReady = (IsHeld(In::Action) || g_Gui.GetInventoryItemChosen() != NO_ITEM);