Render both sides of open doors

This commit is contained in:
MysterD 2020-09-24 23:45:28 -07:00
parent 7869473e95
commit 4d938e635d
3 changed files with 30 additions and 4 deletions

View File

@ -188,7 +188,6 @@ Gfx *geo_switch_area(s32 callContext, struct GraphNode *node) {
gFindFloorIncludeSurfaceIntangible = TRUE; gFindFloorIncludeSurfaceIntangible = TRUE;
find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &sp20); find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &sp20);
if (sp20) { if (sp20) {
gMarioCurrentRoom = sp20->room; gMarioCurrentRoom = sp20->room;
gMarioStates[0].currentRoom = gMarioCurrentRoom; gMarioStates[0].currentRoom = gMarioCurrentRoom;
@ -199,6 +198,29 @@ Gfx *geo_switch_area(s32 callContext, struct GraphNode *node) {
switchCase->selectedCase = sp26; switchCase->selectedCase = sp26;
} }
} }
// display both sides of door
gDoorCurrentRoom = 0;
for (int i = 0; i < MAX_PLAYERS; i++) {
struct MarioState* m = &gMarioStates[i];
if (!is_player_active(m)) { continue; }
struct Object* door = m->interactObj;
if (door == NULL) { continue; }
if (door->oInteractType != INTERACT_DOOR) { continue; }
if (door->oAction == 0) { continue; }
if (gDoorAdjacentRooms[door->oDoorUnkF8][0] != gMarioCurrentRoom && gDoorAdjacentRooms[door->oDoorUnkF8][1] != gMarioCurrentRoom) { continue; }
find_floor(door->oHomeX, door->oHomeY, door->oHomeZ, &sp20);
if (!sp20) { continue; }
sp26 = sp20->room - 1;
if (sp26 == 0) { continue; }
gDoorCurrentRoom = sp20->room;
switchCase->selectedCase = sp26;
break;
}
} }
} else { } else {
switchCase->selectedCase = 0; switchCase->selectedCase = 0;
@ -2541,12 +2563,14 @@ void cur_obj_enable_rendering_if_mario_in_room(void) {
} }
} }
if (marioInRoom) { u8 inViewOfOpenDoor = (gDoorCurrentRoom != 0)
&& (gDoorAdjacentRooms[gDoorCurrentRoom][0] == o->oRoom || gDoorAdjacentRooms[gDoorCurrentRoom][1] == o->oRoom);
if (marioInRoom || inViewOfOpenDoor) {
cur_obj_enable_rendering(); cur_obj_enable_rendering();
o->activeFlags &= ~ACTIVE_FLAG_IN_DIFFERENT_ROOM; o->activeFlags &= ~ACTIVE_FLAG_IN_DIFFERENT_ROOM;
gNumRoomedObjectsInMarioRoom++; gNumRoomedObjectsInMarioRoom++;
} } else {
else {
cur_obj_disable_rendering(); cur_obj_disable_rendering();
o->activeFlags |= ACTIVE_FLAG_IN_DIFFERENT_ROOM; o->activeFlags |= ACTIVE_FLAG_IN_DIFFERENT_ROOM;
gNumRoomedObjectsNotInMarioRoom++; gNumRoomedObjectsNotInMarioRoom++;

View File

@ -151,6 +151,7 @@ s16 *gEnvironmentRegions;
s32 gEnvironmentLevels[20]; s32 gEnvironmentLevels[20];
s8 gDoorAdjacentRooms[60][2]; s8 gDoorAdjacentRooms[60][2];
s16 gMarioCurrentRoom; s16 gMarioCurrentRoom;
s16 gDoorCurrentRoom;
s16 D_8035FEE2; s16 D_8035FEE2;
s16 D_8035FEE4; s16 D_8035FEE4;
s16 gTHIWaterDrained; s16 gTHIWaterDrained;

View File

@ -109,6 +109,7 @@ extern s16 *gEnvironmentRegions;
extern s32 gEnvironmentLevels[20]; extern s32 gEnvironmentLevels[20];
extern s8 gDoorAdjacentRooms[60][2]; extern s8 gDoorAdjacentRooms[60][2];
extern s16 gMarioCurrentRoom; extern s16 gMarioCurrentRoom;
extern s16 gDoorCurrentRoom;
extern s16 D_8035FEE2; extern s16 D_8035FEE2;
extern s16 D_8035FEE4; extern s16 D_8035FEE4;
extern s16 gTHIWaterDrained; extern s16 gTHIWaterDrained;