mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-01-30 23:10:14 -05:00
Dodongo's Cavern blue warp crash fix (#622)
* Doodong's Cavern blue warp crash fix * >= not > * Don't waste a line of space
This commit is contained in:
parent
d1a2f98524
commit
89e07f8dbb
@ -89,6 +89,7 @@ typedef struct {
|
|||||||
/* 0x20 */ CamData* cameraDataList;
|
/* 0x20 */ CamData* cameraDataList;
|
||||||
/* 0x24 */ u16 numWaterBoxes;
|
/* 0x24 */ u16 numWaterBoxes;
|
||||||
/* 0x28 */ WaterBox* waterBoxes;
|
/* 0x28 */ WaterBox* waterBoxes;
|
||||||
|
size_t cameraDataListLen; // OTRTODO: Added to allow for bounds checking the cameraDataList.
|
||||||
} CollisionHeader; // original name: BGDataInfo
|
} CollisionHeader; // original name: BGDataInfo
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -158,6 +158,7 @@ bool func_80098674(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
colHeader->cameraDataList = (CamData*)malloc(sizeof(CamData) * colRes->camData->entries.size());
|
colHeader->cameraDataList = (CamData*)malloc(sizeof(CamData) * colRes->camData->entries.size());
|
||||||
|
colHeader->cameraDataListLen = colRes->camData->entries.size();
|
||||||
|
|
||||||
for (int i = 0; i < colRes->camData->entries.size(); i++)
|
for (int i = 0; i < colRes->camData->entries.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -383,6 +383,19 @@ void Gameplay_Init(GameState* thisx) {
|
|||||||
Camera_InitPlayerSettings(&globalCtx->mainCamera, player);
|
Camera_InitPlayerSettings(&globalCtx->mainCamera, player);
|
||||||
Camera_ChangeMode(&globalCtx->mainCamera, CAM_MODE_NORMAL);
|
Camera_ChangeMode(&globalCtx->mainCamera, CAM_MODE_NORMAL);
|
||||||
|
|
||||||
|
// OTRTODO: Bounds check cameraDataList to guard against scenes spawning the player with
|
||||||
|
// an out of bounds background camera index. This requires adding an extra field to the
|
||||||
|
// CollisionHeader struct to save the length of cameraDataList.
|
||||||
|
// Fixes Dodongo's Cavern blue warp crash.
|
||||||
|
{
|
||||||
|
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(&globalCtx->colCtx, BGCHECK_SCENE);
|
||||||
|
|
||||||
|
// If the player's start cam is out of bounds, set it to 0xFF so it isn't used.
|
||||||
|
if (colHeader != NULL && ((player->actor.params & 0xFF) >= colHeader->cameraDataListLen)) {
|
||||||
|
player->actor.params |= 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
playerStartCamId = player->actor.params & 0xFF;
|
playerStartCamId = player->actor.params & 0xFF;
|
||||||
if (playerStartCamId != 0xFF) {
|
if (playerStartCamId != 0xFF) {
|
||||||
osSyncPrintf("player has start camera ID (" VT_FGCOL(BLUE) "%d" VT_RST ")\n", playerStartCamId);
|
osSyncPrintf("player has start camera ID (" VT_FGCOL(BLUE) "%d" VT_RST ")\n", playerStartCamId);
|
||||||
|
Loading…
Reference in New Issue
Block a user