Patch SPR locks to prevent softlock when opening them from behind.

This commit is contained in:
gymnast86
2026-04-17 10:40:37 -07:00
parent 23fe55fdca
commit 39a9dd4029
+37
View File
@@ -7,6 +7,9 @@
#include "d/actor/d_a_obj_Lv5Key.h"
#include "d/d_com_inf_game.h"
#if TARGET_PC
#include "d/d_map.h"
#endif
static int useHeapInit(fopAc_ac_c*);
@@ -113,6 +116,40 @@ void daObjLv5Key_c::Action() {
}
void daObjLv5Key_c::Wait(int param_0) {
#if TARGET_PC
if (randomizer_IsActive()) {
// Prevent softlock that occurs when opening a locked door from behind.
// This patch compares z and x pos depending on yRot and turns the lock to face the player.
Vec player_pos = dMapInfo_n::getMapPlayerPos();
const s32 collisionRotY = shape_angle.y;
float* playerAxisPos = NULL;
float* lockPos = NULL;
if (collisionRotY & 0x4000) {
playerAxisPos = &player_pos.x;
lockPos = &current.pos.x;
} else {
playerAxisPos = &player_pos.z;
lockPos = &current.pos.z;
}
bool swapSides = false;
if (collisionRotY & 0x8000 && *playerAxisPos > *lockPos + 17.f) {
*lockPos += 34.f;
swapSides = true;
} else if (!(collisionRotY & 0x8000) && *playerAxisPos < *lockPos - 17.f) {
*lockPos -= 34.f;
swapSides = true;
}
if (swapSides) {
shape_angle.y ^= 0x8000;
current.angle.y ^= 0x8000;
}
}
#endif
switch (mMode) {
case -1:
break;