Fix Entrance Rando Grotto Voidout Crash when voiding back to an area with a background image (#6379)
Hookify bgimage load cam check and add it to entrance rando
This commit is contained in:
committed by
GitHub
parent
38e684fda3
commit
f2c34d8c11
@@ -21,6 +21,12 @@ void OnGameFrameUpdateUnrestrictedItems() {
|
|||||||
|
|
||||||
void RegisterUnrestrictedItems() {
|
void RegisterUnrestrictedItems() {
|
||||||
COND_HOOK(OnGameFrameUpdate, CVAR_UNRESTRICTED_ITEMS_VALUE, OnGameFrameUpdateUnrestrictedItems);
|
COND_HOOK(OnGameFrameUpdate, CVAR_UNRESTRICTED_ITEMS_VALUE, OnGameFrameUpdateUnrestrictedItems);
|
||||||
|
COND_VB_SHOULD(VB_SHOULD_LOAD_BG_IMAGE, CVAR_UNRESTRICTED_ITEMS_VALUE, {
|
||||||
|
int32_t* camId = va_arg(args, int*);
|
||||||
|
if (*camId == -1) {
|
||||||
|
*should = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterShipInitFunc initFunc(RegisterUnrestrictedItems, { CVAR_UNRESTRICTED_ITEMS_NAME });
|
static RegisterShipInitFunc initFunc(RegisterUnrestrictedItems, { CVAR_UNRESTRICTED_ITEMS_NAME });
|
||||||
|
|||||||
@@ -2720,6 +2720,14 @@ typedef enum {
|
|||||||
// - `*BgHakaHuta`
|
// - `*BgHakaHuta`
|
||||||
// - `*PlayState`
|
// - `*PlayState`
|
||||||
VB_HAKA_HUTA_SPAWN_REDEAD,
|
VB_HAKA_HUTA_SPAWN_REDEAD,
|
||||||
|
|
||||||
|
// #### `result`
|
||||||
|
// ```c
|
||||||
|
// true
|
||||||
|
// ```
|
||||||
|
// #### `args`
|
||||||
|
// - `*int32_t (camId)`
|
||||||
|
VB_SHOULD_LOAD_BG_IMAGE
|
||||||
} GIVanillaBehavior;
|
} GIVanillaBehavior;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,9 +4,18 @@
|
|||||||
#include "3drando/pool_functions.hpp"
|
#include "3drando/pool_functions.hpp"
|
||||||
#include "3drando/item_pool.hpp"
|
#include "3drando/item_pool.hpp"
|
||||||
#include "../debugger/performanceTimer.h"
|
#include "../debugger/performanceTimer.h"
|
||||||
|
#include "soh/Enhancements/gameconsole.h"
|
||||||
|
#include "z64camera.h"
|
||||||
|
#include "z64scene.h"
|
||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "variables.h"
|
||||||
|
#include "macros.h"
|
||||||
|
#include "functions.h"
|
||||||
|
}
|
||||||
|
|
||||||
namespace Rando {
|
namespace Rando {
|
||||||
EntranceLinkInfo NO_RETURN_ENTRANCE = { EntranceType::None, RR_NONE, RR_NONE, -1 };
|
EntranceLinkInfo NO_RETURN_ENTRANCE = { EntranceType::None, RR_NONE, RR_NONE, -1 };
|
||||||
|
|
||||||
@@ -1727,3 +1736,30 @@ const Entrance* EntranceShuffler::GetEntranceByIndex(int16_t index) {
|
|||||||
extern "C" EntranceOverride* Randomizer_GetEntranceOverrides() {
|
extern "C" EntranceOverride* Randomizer_GetEntranceOverrides() {
|
||||||
return Rando::Context::GetInstance()->GetEntranceShuffler()->entranceOverrides.data();
|
return Rando::Context::GetInstance()->GetEntranceShuffler()->entranceOverrides.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SceneID backedUpScene = (SceneID)0xFF;
|
||||||
|
static Camera backupCamera;
|
||||||
|
|
||||||
|
void RegisterEntranceShuffleHooks() {
|
||||||
|
COND_VB_SHOULD(VB_SHOULD_LOAD_BG_IMAGE, IS_RANDO && RAND_GET_OPTION(RSK_SHUFFLE_ENTRANCES), {
|
||||||
|
int32_t* camId = va_arg(args, int*);
|
||||||
|
Camera* camera = GET_ACTIVE_CAM(gPlayState);
|
||||||
|
if (*camId == -1) {
|
||||||
|
if (backedUpScene != gPlayState->sceneNum) {
|
||||||
|
*should = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memcpy(camera, &backupCamera, sizeof(Camera));
|
||||||
|
Camera_ChangeMode(camera, CAM_MODE_TALK);
|
||||||
|
*should = false;
|
||||||
|
} else if (backedUpScene != gPlayState->sceneNum) {
|
||||||
|
memcpy(&backupCamera, camera, sizeof(Camera));
|
||||||
|
backedUpScene = (SceneID)gPlayState->sceneNum;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
COND_HOOK(OnLoadGame, IS_RANDO && RAND_GET_OPTION(RSK_SHUFFLE_ENTRANCES),
|
||||||
|
[](int32_t) { backedUpScene = (SceneID)0xFF; });
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegisterShipInitFunc initFunc(RegisterEntranceShuffleHooks, { "IS_RANDO" });
|
||||||
|
|||||||
@@ -627,3 +627,14 @@ CrowdControl::Effect* CrowdControl::ParseMessage(nlohmann::json dataReceived) {
|
|||||||
|
|
||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RegisterCrowdControlHooks() {
|
||||||
|
COND_VB_SHOULD(VB_SHOULD_LOAD_BG_IMAGE, CVarGetInteger(CVAR_REMOTE_CROWD_CONTROL("Enabled"), 0), {
|
||||||
|
int32_t* camId = va_arg(args, int*);
|
||||||
|
if (*camId == -1) {
|
||||||
|
*should = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegisterShipInitFunc initFunc(RegisterCrowdControlHooks, { CVAR_REMOTE_CROWD_CONTROL("Enabled") });
|
||||||
|
|||||||
@@ -413,14 +413,7 @@ BgImage* func_80096A74(PolygonType1* polygon1, PlayState* play) {
|
|||||||
|
|
||||||
camera = GET_ACTIVE_CAM(play);
|
camera = GET_ACTIVE_CAM(play);
|
||||||
camId = camera->camDataIdx;
|
camId = camera->camDataIdx;
|
||||||
if (camId == -1 && (CVarGetInteger(CVAR_CHEAT("NoRestrictItems"), 0) ||
|
if (GameInteractor_Should(VB_SHOULD_LOAD_BG_IMAGE, true, &camId)) {
|
||||||
(CVarGetInteger(CVAR_REMOTE_CROWD_CONTROL("Enabled"), 0)))) {
|
|
||||||
// This prevents a crash when using items that change the
|
|
||||||
// camera (such as din's fire), voiding out or dying on
|
|
||||||
// scenes with prerendered backgrounds.
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// jfifid
|
// jfifid
|
||||||
camId2 = func_80041C10(&play->colCtx, camId, BGCHECK_SCENE)[2].y;
|
camId2 = func_80041C10(&play->colCtx, camId, BGCHECK_SCENE)[2].y;
|
||||||
if (camId2 >= 0) {
|
if (camId2 >= 0) {
|
||||||
@@ -441,6 +434,7 @@ BgImage* func_80096A74(PolygonType1* polygon1, PlayState* play) {
|
|||||||
// "z_room.c: Data consistent with camera id does not exist camid=%d"
|
// "z_room.c: Data consistent with camera id does not exist camid=%d"
|
||||||
osSyncPrintf(VT_COL(RED, WHITE) "z_room.c:カメラIDに一致するデータが存在しません camid=%d\n" VT_RST, camId);
|
osSyncPrintf(VT_COL(RED, WHITE) "z_room.c:カメラIDに一致するデータが存在しません camid=%d\n" VT_RST, camId);
|
||||||
LOG_HUNGUP_THREAD();
|
LOG_HUNGUP_THREAD();
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user