1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-13 04:39:36 +00:00

waterbox search funcs consistency

This commit is contained in:
Dragorn421 2022-10-10 22:37:52 +02:00
parent 9bf406561f
commit 8f386e038f
No known key found for this signature in database
GPG key ID: 32B53D2D16FC4118

View file

@ -4240,26 +4240,30 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3
WaterBox** outWaterBox) {
CollisionHeader* colHeader = colCtx->colHeader;
s32 room;
WaterBox* curWaterBox;
WaterBox* waterBox;
if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == SEGMENTED_TO_VIRTUAL(NULL)) {
return false;
}
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes;
curWaterBox++) {
room = WATERBOX_ROOM(curWaterBox->properties);
if (room == play->roomCtx.curRoom.num || room == WATERBOX_ROOM_ALL) {
if (!(curWaterBox->properties & WATERBOX_FLAG_19)) {
if (curWaterBox->xMin < x && x < curWaterBox->xMin + curWaterBox->xLength) {
if (curWaterBox->zMin < z && z < curWaterBox->zMin + curWaterBox->zLength) {
*outWaterBox = curWaterBox;
*ySurface = curWaterBox->ySurface;
return true;
}
}
}
for (waterBox = colHeader->waterBoxes; waterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; waterBox++) {
room = WATERBOX_ROOM(waterBox->properties);
if (!(room == play->roomCtx.curRoom.num || room == WATERBOX_ROOM_ALL)) {
continue;
}
if (waterBox->properties & WATERBOX_FLAG_19) {
continue;
}
if (!(waterBox->xMin < x && x < waterBox->xMin + waterBox->xLength)) {
continue;
}
if (!(waterBox->zMin < z && z < waterBox->zMin + waterBox->zLength)) {
continue;
}
*outWaterBox = waterBox;
*ySurface = waterBox->ySurface;
return true;
}
return false;
}
@ -4287,19 +4291,24 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos,
waterBox = &colHeader->waterBoxes[i];
room = WATERBOX_ROOM(waterBox->properties);
if (room == play->roomCtx.curRoom.num || room == WATERBOX_ROOM_ALL) {
if (!(waterBox->properties & WATERBOX_FLAG_19)) {
if (waterBox->xMin < pos->x && pos->x < waterBox->xMin + waterBox->xLength) {
if (waterBox->zMin < pos->z && pos->z < waterBox->zMin + waterBox->zLength) {
if (pos->y - surfaceChkDist < waterBox->ySurface &&
waterBox->ySurface < pos->y + surfaceChkDist) {
*outWaterBox = waterBox;
return i;
}
}
}
}
if (!(room == play->roomCtx.curRoom.num || room == WATERBOX_ROOM_ALL)) {
continue;
}
if (waterBox->properties & WATERBOX_FLAG_19) {
continue;
}
if (!(waterBox->xMin < pos->x && pos->x < waterBox->xMin + waterBox->xLength)) {
continue;
}
if (!(waterBox->zMin < pos->z && pos->z < waterBox->zMin + waterBox->zLength)) {
continue;
}
if (!(pos->y - surfaceChkDist < waterBox->ySurface && waterBox->ySurface < pos->y + surfaceChkDist)) {
continue;
}
*outWaterBox = waterBox;
return i;
}
*outWaterBox = NULL;
@ -4347,26 +4356,30 @@ u32 WaterBox_GetLightIndex(CollisionContext* colCtx, WaterBox* waterBox) {
s32 func_800425B0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) {
CollisionHeader* colHeader = colCtx->colHeader;
s32 room;
WaterBox* curWaterBox;
WaterBox* waterBox;
if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == SEGMENTED_TO_VIRTUAL(NULL)) {
return false;
}
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes;
curWaterBox++) {
room = WATERBOX_ROOM(curWaterBox->properties);
if ((room == play->roomCtx.curRoom.num) || (room == WATERBOX_ROOM_ALL)) {
if (curWaterBox->properties & WATERBOX_FLAG_19) {
if (curWaterBox->xMin < x && x < (curWaterBox->xMin + curWaterBox->xLength)) {
if (curWaterBox->zMin < z && z < (curWaterBox->zMin + curWaterBox->zLength)) {
*outWaterBox = curWaterBox;
*ySurface = curWaterBox->ySurface;
return true;
}
}
}
for (waterBox = colHeader->waterBoxes; waterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; waterBox++) {
room = WATERBOX_ROOM(waterBox->properties);
if (!(room == play->roomCtx.curRoom.num || room == WATERBOX_ROOM_ALL)) {
continue;
}
if (!(waterBox->properties & WATERBOX_FLAG_19)) {
continue;
}
if (!(waterBox->xMin < x && x < waterBox->xMin + waterBox->xLength)) {
continue;
}
if (!(waterBox->zMin < z && z < waterBox->zMin + waterBox->zLength)) {
continue;
}
*outWaterBox = waterBox;
*ySurface = waterBox->ySurface;
return true;
}
return false;
}