From 2f8d119301eaa599fd71bf7ac8cb6d8296f63aac Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 7 Sep 2020 23:56:29 -0700 Subject: [PATCH] Prevent exclamation box from spawning the wrong star on remote --- src/game/behaviors/exclamation_box.inc.c | 24 +++++++++++++++------ src/game/behaviors/sparkle_spawn_star.inc.c | 11 ++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/game/behaviors/exclamation_box.inc.c b/src/game/behaviors/exclamation_box.inc.c index fddf9be2..bf85cb11 100644 --- a/src/game/behaviors/exclamation_box.inc.c +++ b/src/game/behaviors/exclamation_box.inc.c @@ -128,9 +128,13 @@ void exclamation_box_spawn_contents(struct Struct802C0DF0 *a0, u8 a1) { if (a0->model == 122) o->oFlags |= 0x4000; - struct Object* spawn_objects[] = { sp1C }; - u32 models[] = { a0->model }; - network_send_spawn_objects(spawn_objects, models, 1); + // send non-star spawn events + // stars cant be sent here to due jankiness in oBehParams + if (a0->behavior != bhvSpawnedStar) { + struct Object* spawn_objects[] = { sp1C }; + u32 models[] = { a0->model }; + network_send_spawn_objects(spawn_objects, models, 1); + } break; } a0++; @@ -145,18 +149,26 @@ void exclamation_box_act_4(void) { if (o->oBehParams2ndByte < 3) { o->oAction = 5; cur_obj_hide(); - } else - obj_mark_for_deletion(o); + } else { + o->oAction = 6; + cur_obj_become_intangible(); + cur_obj_hide(); + } } void exclamation_box_act_5(void) { if (o->oTimer > 300) o->oAction = 2; } +void exclamation_box_act_6(void) { + if (o->oTimer > 1000) + obj_mark_for_deletion(o); +} void (*sExclamationBoxActions[])(void) = { exclamation_box_act_0, exclamation_box_act_1, exclamation_box_act_2, exclamation_box_act_3, - exclamation_box_act_4, exclamation_box_act_5 }; + exclamation_box_act_4, exclamation_box_act_5, + exclamation_box_act_6 }; void bhv_exclamation_box_loop(void) { if (!network_sync_object_initialized(o)) { diff --git a/src/game/behaviors/sparkle_spawn_star.inc.c b/src/game/behaviors/sparkle_spawn_star.inc.c index 7130fb84..0f7b9907 100644 --- a/src/game/behaviors/sparkle_spawn_star.inc.c +++ b/src/game/behaviors/sparkle_spawn_star.inc.c @@ -20,6 +20,17 @@ void bhv_spawned_star_init(void) { if (bit_shift_left(sp24) & save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1)) cur_obj_set_model(MODEL_TRANSPARENT_STAR); cur_obj_play_sound_2(SOUND_GENERAL2_STAR_APPEARS); + + // exclamation box stars are not sent through the normal exclamation box + // path due to jankiness in oBehParams. Send the spawn event here instead. + u8 spawnedFromExclamationBox = (o->parentObj != NULL && o->parentObj->behavior == bhvExclamationBox); + if (gNetworkLevelLoaded && spawnedFromExclamationBox) { + o->parentObj = o; + struct Object* spawn_objects[] = { o }; + u32 models[] = { MODEL_STAR }; + network_send_spawn_objects(spawn_objects, models, 1); + } + } void set_sparkle_spawn_star_hitbox(void) {