diff --git a/src/game/area.c b/src/game/area.c index cb3d4c6e..dff96955 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -58,8 +58,10 @@ u32 gSpawnedStarDefault[8] = { 0 }; u8 gSpawnedStarDefaultCount = 0; u32 gSpawnedStarNLE[8] = { 0 }; u8 gSpawnedStarNLECount = 0; -u8 gSpawnedStarRedCoin = 0; -u8 gSpawnedStarHidden = 0; +u32 gSpawnedStarRed[8] = { 0 }; +u8 gSpawnedStarRedCount = 0; +u32 gSpawnedStarHidden[8] = { 0 }; +u8 gSpawnedStarHiddenCount = 0; /* * The following two tables are used in get_mario_spawn_type() to determine spawn type diff --git a/src/game/area.h b/src/game/area.h index 4e5aeefb..be036965 100644 --- a/src/game/area.h +++ b/src/game/area.h @@ -142,8 +142,10 @@ extern u32 gSpawnedStarDefault[]; extern u8 gSpawnedStarDefaultCount; extern u32 gSpawnedStarNLE[]; extern u8 gSpawnedStarNLECount; -extern u8 gSpawnedStarRedCoin; -extern u8 gSpawnedStarHidden; +extern u32 gSpawnedStarRed[]; +extern u8 gSpawnedStarRedCount; +extern u32 gSpawnedStarHidden[]; +extern u8 gSpawnedStarHiddenCount; void override_viewport_and_clip(Vp *a, Vp *b, u8 c, u8 d, u8 e); void print_intro_text(void); diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index ffffc59a..7dd93982 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -125,16 +125,25 @@ struct Object *spawn_star(struct Object *sp30, f32 sp34, f32 sp38, f32 sp3C) { return sp30; } +static u8 spawn_star_deduplication(u32* array, u8* count, u32 behParams) { + for (int i = 0; i < *count; i++) { + if (array[i] == behParams) { return TRUE; } + } + if (*count < 8) { + array[*count] = behParams; + *count = *count + 1; + return FALSE; + } + return TRUE; +} + struct Object* spawn_default_star(f32 x, f32 y, f32 z) { if (sCurrPlayMode != PLAY_MODE_NORMAL && sCurrPlayMode != PLAY_MODE_PAUSED) { return NULL; } u32 behParams = o->oBehParams; // de-duplication checking - for (int i = 0; i < gSpawnedStarDefaultCount; i++) { - if (gSpawnedStarDefault[i] == behParams) { return NULL; } - } - if (gSpawnedStarDefaultCount < 8) { - gSpawnedStarDefault[gSpawnedStarDefaultCount++] = behParams; + if (spawn_star_deduplication(gSpawnedStarDefault, &gSpawnedStarDefaultCount, behParams)) { + return NULL; } struct Object *star; @@ -145,24 +154,32 @@ struct Object* spawn_default_star(f32 x, f32 y, f32 z) { } struct Object* spawn_red_coin_cutscene_star(f32 x, f32 y, f32 z) { - if (gSpawnedStarRedCoin) { return NULL; } - struct Object * star; u32 behParams = o->oBehParams; + + // de-duplication checking + if (spawn_star_deduplication(gSpawnedStarRed, &gSpawnedStarRedCount, behParams)) { + return NULL; + } + + struct Object * star; star = spawn_star(star, x, y, z); star->oBehParams2ndByte = 1; - gSpawnedStarRedCoin = TRUE; network_send_spawn_star(star, 1, x, y, z, behParams); return star; } struct Object* spawn_no_exit_star(f32 x, f32 y, f32 z) { - if (gSpawnedStarHidden) { return NULL; } - struct Object * star; u32 behParams = o->oBehParams; + + // de-duplication checking + if (spawn_star_deduplication(gSpawnedStarHidden, &gSpawnedStarHiddenCount, behParams)) { + return NULL; + } + + struct Object * star; star = spawn_star(star, x, y, z); star->oBehParams2ndByte = 1; star->oInteractionSubtype |= INT_SUBTYPE_NO_EXIT; - gSpawnedStarHidden = TRUE; network_send_spawn_star(star, 2, x, y, z, behParams); return star; } diff --git a/src/game/level_update.c b/src/game/level_update.c index 069bfaaa..f566f370 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1315,11 +1315,14 @@ s32 init_level(void) { for (int i = 0; i < 8; i++) { gSpawnedStarDefault[i] = 0; gSpawnedStarNLE[i] = 0; + gSpawnedStarRed[i] = 0; + gSpawnedStarHidden[i] = 0; } + gSpawnedStarDefaultCount = 0; gSpawnedStarNLECount = 0; - gSpawnedStarRedCoin = 0; - gSpawnedStarHidden = 0; + gSpawnedStarRedCount = 0; + gSpawnedStarHiddenCount = 0; if (gCurrCreditsEntry == NULL) { gHudDisplay.flags = HUD_DISPLAY_DEFAULT; diff --git a/src/pc/controller/controller_keyboard_debug.c b/src/pc/controller/controller_keyboard_debug.c index 3484b46e..cf738863 100644 --- a/src/pc/controller/controller_keyboard_debug.c +++ b/src/pc/controller/controller_keyboard_debug.c @@ -7,7 +7,7 @@ #ifdef DEBUG -static u8 warpToLevel = LEVEL_WF; +static u8 warpToLevel = LEVEL_BOB; #define SCANCODE_0 0x0B #define SCANCODE_1 0x02