diff --git a/include/level_commands.h b/include/level_commands.h index 4df140fd..7ae45dfd 100644 --- a/include/level_commands.h +++ b/include/level_commands.h @@ -82,7 +82,7 @@ enum LevelActs { ACT_4 = (1 << 3), ACT_5 = (1 << 4), ACT_6 = (1 << 5), - ALL_ACTS = (ACT_1 | ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6) + ALL_ACTS = (ACT_1 | ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6), }; enum LevelCommandEvalOperation { @@ -114,13 +114,6 @@ enum WarpCheckpointFlags { WARP_CHECKPOINT = (1 << 7), // 0x80 }; -enum LevelCommandCreateWhirlpoolCondition { - WHIRLPOOL_COND_ALWAYS, - WHIRLPOOL_COND_BOWSER2_NOT_BEATEN, - WHIRLPOOL_COND_BOWSER2_BEATEN, - WHIRLPOOL_COND_AT_LEAST_SECOND_STAR -}; - // Head defines enum GoddardScene { REGULAR_FACE = 0x2, @@ -361,7 +354,7 @@ enum GoddardScene { CMD_W(model) #define OBJECT(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh) \ - OBJECT_WITH_ACTS(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, 0x1F) + OBJECT_WITH_ACTS(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, ALL_ACTS) #define MARIO(model, behArg, beh) \ CMD_BBH(LEVEL_CMD_INIT_MARIO, 0x0C, model), \ @@ -447,8 +440,8 @@ enum GoddardScene { CMD_HH(unk6, unk8), \ CMD_HH(unk10, 0x0000) -#define WHIRLPOOL(index, condition, posX, posY, posZ, strength) \ - CMD_BBBB(LEVEL_CMD_CREATE_WHIRLPOOL, 0x0C, index, condition), \ +#define WHIRLPOOL(index, acts, posX, posY, posZ, strength) \ + CMD_BBBB(LEVEL_CMD_CREATE_WHIRLPOOL, 0x0C, index, acts), \ CMD_HH(posX, posY), \ CMD_HH(posZ, strength) diff --git a/levels/ddd/script.c b/levels/ddd/script.c index 12d839d2..470ae37c 100644 --- a/levels/ddd/script.c +++ b/levels/ddd/script.c @@ -86,7 +86,7 @@ const LevelScript level_ddd_entry[] = { WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_DDD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x35, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x67, /*flags*/ WARP_NO_CHECKPOINT), - WHIRLPOOL(/*unk2*/ 0, /*unk3*/ 0, /*pos*/ -3174, -4915, 102, /*strength*/ 20), + WHIRLPOOL(/*index*/ 0, /*acts*/ ALL_ACTS, /*pos*/ -3174, -4915, 102, /*strength*/ 20), JUMP_LINK(script_func_local_1), JUMP_LINK(script_func_local_2), INSTANT_WARP(/*index*/ 3, /*destArea*/ 2, /*displace*/ -8192, 0, 0), @@ -97,8 +97,8 @@ const LevelScript level_ddd_entry[] = { END_AREA(), AREA(/*index*/ 2, ddd_geo_000570), - WHIRLPOOL(/*unk2*/ 0, /*unk3*/ 0, /*pos*/ 3355, -3575, -515, /*strength*/ -30), - WHIRLPOOL(/*unk2*/ 1, /*unk3*/ 2, /*pos*/ 3917, -2040, -6041, /*strength*/ 50), + WHIRLPOOL(/*index*/ 0, /*acts*/ ALL_ACTS, /*pos*/ 3355, -3575, -515, /*strength*/ -30), + WHIRLPOOL(/*index*/ 1, /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6, /*pos*/ 3917, -2040, -6041, /*strength*/ 50), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x35, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x67, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF3, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x1E, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/jrb/script.c b/levels/jrb/script.c index 57c9d548..76be65b4 100644 --- a/levels/jrb/script.c +++ b/levels/jrb/script.c @@ -146,7 +146,7 @@ const LevelScript level_jrb_entry[] = { WARP_NODE(/*id*/ 0xF3, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x35, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x67, /*flags*/ WARP_NO_CHECKPOINT), - WHIRLPOOL(/*unk2*/ 0, /*unk3*/ 3, /*pos*/ 4979, -5222, 2482, /*strength*/ -30), + WHIRLPOOL(/*index*/ 0, /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6, /*pos*/ 4979, -5222, 2482, /*strength*/ -30), JUMP_LINK(script_func_local_1), JUMP_LINK(script_func_local_2), JUMP_LINK(script_func_local_3), diff --git a/src/engine/level_script.c b/src/engine/level_script.c index bedcf448..9af7c9bb 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -478,7 +478,7 @@ static void level_cmd_init_mario(void) { static void level_cmd_place_object(void) { if ( sCurrAreaIndex != -1 - && ((CMD_GET(u8, 2) & (1 << (gCurrActNum - 1))) || (CMD_GET(u8, 2) == 0x1F)) + && (CMD_GET(u8, 2) & (1 << (gCurrActNum - 1))) ) { ModelID16 model = CMD_GET(u32, 0x18); struct SpawnInfo *spawnInfo = alloc_only_pool_alloc(sLevelPool, sizeof(struct SpawnInfo)); @@ -606,22 +606,19 @@ static void level_cmd_3A(void) { static void level_cmd_create_whirlpool(void) { struct Whirlpool *whirlpool; s32 index = CMD_GET(u8, 2); - s32 beatBowser2 = - (save_file_get_flags() & (SAVE_FLAG_HAVE_KEY_2 | SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR)) != 0; - if (CMD_GET(u8, 3) == WHIRLPOOL_COND_ALWAYS - || (CMD_GET(u8, 3) == WHIRLPOOL_COND_BOWSER2_NOT_BEATEN && !beatBowser2) - || (CMD_GET(u8, 3) == WHIRLPOOL_COND_BOWSER2_BEATEN && beatBowser2) - || (CMD_GET(u8, 3) == WHIRLPOOL_COND_AT_LEAST_SECOND_STAR && gCurrActNum >= 2)) { - if (sCurrAreaIndex != -1 && index < 2) { - if ((whirlpool = gAreas[sCurrAreaIndex].whirlpools[index]) == NULL) { - whirlpool = alloc_only_pool_alloc(sLevelPool, sizeof(struct Whirlpool)); - gAreas[sCurrAreaIndex].whirlpools[index] = whirlpool; - } - - vec3s_set(whirlpool->pos, CMD_GET(s16, 4), CMD_GET(s16, 6), CMD_GET(s16, 8)); - whirlpool->strength = CMD_GET(s16, 10); + if ( + sCurrAreaIndex != -1 + && index < ARRAY_COUNT(gAreas[sCurrAreaIndex].whirlpools) + && (CMD_GET(u8, 3) & (1 << (gCurrActNum - 1))) + ) { + if ((whirlpool = gAreas[sCurrAreaIndex].whirlpools[index]) == NULL) { + whirlpool = alloc_only_pool_alloc(sLevelPool, sizeof(struct Whirlpool)); + gAreas[sCurrAreaIndex].whirlpools[index] = whirlpool; } + + vec3s_set(whirlpool->pos, CMD_GET(s16, 4), CMD_GET(s16, 6), CMD_GET(s16, 8)); + whirlpool->strength = CMD_GET(s16, 10); } sCurrentCmd = CMD_NEXT; diff --git a/src/game/area.c b/src/game/area.c index cd1c9ef2..5d2d7c79 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -34,7 +34,7 @@ struct Area gAreaData[AREA_COUNT]; struct WarpTransition gWarpTransition; s16 gCurrCourseNum; -s16 gCurrActNum; +s16 gCurrActNum = 1; s16 gCurrAreaIndex; s16 gSavedCourseNum; s16 gMenuOptSelectIndex; @@ -177,7 +177,7 @@ void load_obj_warp_nodes(void) { } void clear_areas(void) { - s32 i; + s32 i, j; gCurrentArea = NULL; gWarpTransition.isActive = FALSE; @@ -198,8 +198,9 @@ void clear_areas(void) { gAreaData[i].objectSpawnInfos = NULL; gAreaData[i].camera = NULL; gAreaData[i].unused = NULL; - gAreaData[i].whirlpools[0] = NULL; - gAreaData[i].whirlpools[1] = NULL; + for (j = 0; j < ARRAY_COUNT(gAreaData[i].whirlpools); j++) { + gAreaData[i].whirlpools[j] = NULL; + } gAreaData[i].dialog[0] = DIALOG_NONE; gAreaData[i].dialog[1] = DIALOG_NONE; gAreaData[i].musicParam = 0; diff --git a/src/game/behaviors/ddd_pole.inc.c b/src/game/behaviors/ddd_pole.inc.c index 86e5312a..5800a5ee 100644 --- a/src/game/behaviors/ddd_pole.inc.c +++ b/src/game/behaviors/ddd_pole.inc.c @@ -1,7 +1,7 @@ // ddd_pole.inc.c void bhv_ddd_pole_init(void) { - if (!(save_file_get_flags() & (SAVE_FLAG_HAVE_KEY_2 | SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR))) { + if (gCurrActNum == 1) { obj_mark_for_deletion(o); } else { o->hitboxDownOffset = 100.0f; diff --git a/src/game/behaviors/ddd_sub.inc.c b/src/game/behaviors/ddd_sub.inc.c index 42350138..bd894126 100644 --- a/src/game/behaviors/ddd_sub.inc.c +++ b/src/game/behaviors/ddd_sub.inc.c @@ -1,7 +1,7 @@ // ddd_sub.inc.c void bhv_bowsers_sub_init(void) { - if (save_file_get_flags() & (SAVE_FLAG_HAVE_KEY_2 | SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR)) { + if (gCurrActNum != 1) { obj_mark_for_deletion(o); } else { load_object_static_model(); diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index 2fb2238f..47ebaaac 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -132,7 +132,7 @@ static void apply_water_current(struct MarioState *m, Vec3f step) { step[2] += currentSpeed * coss(currentAngle); } - for (i = 0; i < 2; i++) { + for (i = 0; i < ARRAY_COUNT(gCurrentArea->whirlpools); i++) { struct Whirlpool *whirlpool = gCurrentArea->whirlpools[i]; if (whirlpool != NULL) { strength = 0.0f; diff --git a/src/game/moving_texture.c b/src/game/moving_texture.c index c2e51c34..194037c0 100644 --- a/src/game/moving_texture.c +++ b/src/game/moving_texture.c @@ -598,7 +598,7 @@ Gfx *geo_movtex_draw_water_regions(s32 callContext, struct GraphNode *node, UNUS if (gLakituState.goalPos[1] < 1024.0f) { // if camera under water return NULL; } - if (save_file_get_star_flags((gCurrSaveFileNum - 1), COURSE_NUM_TO_INDEX(COURSE_JRB)) & STAR_FLAG_ACT_1) { // first star in JRB complete + if (gCurrActNum != 1) { return NULL; } } else if (asGenerated->parameter == HMC_MOVTEX_TOXIC_MAZE_MIST) { diff --git a/src/game/skybox.c b/src/game/skybox.c index 39df6b41..490d3257 100644 --- a/src/game/skybox.c +++ b/src/game/skybox.c @@ -293,10 +293,9 @@ Gfx *init_skybox_display_list(s8 player, s8 background, s8 colorIndex) { Gfx *create_skybox_facing_camera(s8 player, s8 background, f32 fov, Vec3f pos, Vec3f focus) { s8 colorIndex = 1; - // If the "Plunder in the Sunken Ship" star in JRB is collected, make the sky darker and slightly green #ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS - if (background == BACKGROUND_ABOVE_CLOUDS - && !(save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_JRB)) & STAR_FLAG_ACT_1)) { + // For the "Plunder in the Sunken Ship" star in JRB, make the sky darker and slightly green. + if (background == BACKGROUND_ABOVE_CLOUDS && gCurrActNum == 1) { colorIndex = 0; } #endif