Synchronized purple switch

Started working toward synchronizing star spawning, not quite there yet
This commit is contained in:
MysterD 2020-08-07 19:37:19 -07:00
parent 444c1fdd3b
commit 8b24d364bb
8 changed files with 68 additions and 15 deletions

26
gdb.exe.stackdump Normal file
View file

@ -0,0 +1,26 @@
Exception: STATUS_ACCESS_VIOLATION at rip=005E6C11480
rax=0000000000000001 rbx=00000001008F5600 rcx=0000000000000000
rdx=0000000100512B00 rsi=0000000000000000 rdi=0000000000000000
r8 =0000000000000002 r9 =0000000000000018 r10=0000000100000000
r11=0000000100518F91 r12=0000000000000000 r13=00000000FFFFC7A0
r14=00000000FFFFCA18 r15=00000000FFFFCA60
rbp=0000000180239D70 rsp=00000000FFFFC680
program=C:\msys64\usr\bin\gdb.exe, pid 10125, thread main
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame Function Args
00180239D70 005E6C11480 (001008D6FB8, 001008F5600, 00000000000, 00800236BC0)
00180239D70 00100518EB4 (0018013E3AB, 0000000000B, 0018013E3AB, 00000000008)
00180239D70 00100518FB0 (00100580D4F, 00000000006, 00000000008, 00800181D48)
00180239D70 0010060568C (00800235610, 000FFFFCC20, 001005B2E8D, 008002353C0)
00180239D70 001005F0B81 (001005DF3A6, 001005DEA00, 0010092039D, 000000000B0)
00180239D70 0010056D17E (001005DFA1B, 00000000000, 00000000000, 00100BA1220)
00180239D70 0010056D9BC (001008D6FB8, 000FFFFCAA0, 0000000000E, 00000000040)
00180239D70 001006A5F75 (001008D6FB8, 000FFFFCAA0, 00100BBCD88, 000FFFFCA80)
00180239D70 0010059BE9D (00000000000, 00000000000, 001801B5F02, 000FFFFCC20)
000FFFFCCE0 0010059CE6D (0018013E3AB, 00000000001, 00180239780, 0000000000E)
000FFFFCCE0 0010082DCA7 (00180355C78, 00000000000, 00180058D61, 001802EE100)
000FFFFCCE0 0018004AEAA (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0 00180048846 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0 001800488F4 (00000000000, 00000000000, 00000000000, 00000000000)
End of stack trace

View file

@ -2,7 +2,7 @@
#define BEHAVIOR_ACTIONS_H
void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size);
void bhv_spawn_star_no_level_exit(u32);
void bhv_spawn_star_no_level_exit(struct Object*,u32);
void bhv_star_door_loop_2(void);
void spawn_triangle_break_particles(s16 numTris, s16 triModel, f32 triSize, s16 triAnimState);

View file

@ -188,7 +188,7 @@ void bhv_mips_act_idle(void) {
// Spawn a star if he was just picked up for the first time.
if (o->oMipsStarStatus == MIPS_STAR_STATUS_SHOULD_SPAWN_STAR) {
bhv_spawn_star_no_level_exit(o->oBehParams2ndByte + 3);
bhv_spawn_star_no_level_exit(o, o->oBehParams2ndByte + 3);
o->oMipsStarStatus = MIPS_STAR_STATUS_ALREADY_SPAWNED_STAR;
}
}

View file

@ -7,6 +7,18 @@
*/
void bhv_purple_switch_loop(void) {
if (o->oSyncID == 0) {
network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS);
}
u8 anyPlayerOnPlatform = FALSE;
for (int i = 0; i < MAX_PLAYERS; i++) {
if (gMarioState[i].marioObj->platform == o) {
anyPlayerOnPlatform = TRUE;
break;
}
}
UNUSED s32 unused;
switch (o->oAction) {
/**
@ -19,6 +31,7 @@ void bhv_purple_switch_loop(void) {
if (gMarioObject->platform == o && !(gMarioStates->action & MARIO_UNKNOWN_13)) {
if (lateral_dist_between_objects(o, gMarioObject) < 127.5) {
o->oAction = PURPLE_SWITCH_PRESSED;
network_send_object(o);
}
}
break;
@ -41,7 +54,7 @@ void bhv_purple_switch_loop(void) {
*/
case PURPLE_SWITCH_TICKING:
if (o->oBehParams2ndByte != 0) {
if (o->oBehParams2ndByte == 1 && gMarioObject->platform != o) {
if (o->oBehParams2ndByte == 1 && !anyPlayerOnPlatform) {
o->oAction++;
} else {
if (o->oTimer < 360) {
@ -71,7 +84,7 @@ void bhv_purple_switch_loop(void) {
* unpressed state.
*/
case PURPLE_SWITCH_WAIT_FOR_MARIO_TO_GET_OFF:
if (!cur_obj_is_mario_on_platform()) {
if (!anyPlayerOnPlatform) {
o->oAction = PURPLE_SWITCH_UNPRESSED;
}
break;

View file

@ -33,9 +33,23 @@ void set_sparkle_spawn_star_hitbox(void) {
void set_home_to_mario(void) {
f32 sp1C;
f32 sp18;
o->oHomeX = gMarioObject->oPosX;
o->oHomeZ = gMarioObject->oPosZ;
o->oHomeY = gMarioObject->oPosY;
u8 parentIsMario = FALSE;
for (int i = 0; i < MAX_PLAYERS; i++) {
if (o->parentObj == gMarioStates[i].marioObj) {
parentIsMario = TRUE;
break;
}
}
if (parentIsMario) {
o->oHomeX = o->parentObj->oPosX;
o->oHomeZ = o->parentObj->oPosZ;
o->oHomeY = o->parentObj->oPosY;
} else {
o->oHomeX = gMarioObject->oPosX;
o->oHomeZ = gMarioObject->oPosZ;
o->oHomeY = gMarioObject->oPosY;
}
o->oHomeY += 250.0f;
o->oPosY = o->oHomeY;
sp1C = o->oHomeX - o->oPosX;
@ -110,8 +124,8 @@ void bhv_spawned_star_loop(void) {
o->oInteractStatus = 0;
}
void bhv_spawn_star_no_level_exit(u32 sp20) {
struct Object *sp1C = spawn_object(o, MODEL_STAR, bhvSpawnedStarNoLevelExit);
void bhv_spawn_star_no_level_exit(struct Object* object, u32 sp20) {
struct Object *sp1C = spawn_object(object, MODEL_STAR, bhvSpawnedStarNoLevelExit);
sp1C->oBehParams = sp20 << 24;
sp1C->oInteractionSubtype = INT_SUBTYPE_NO_EXIT;
obj_set_angle(sp1C, 0, 0, 0);

View file

@ -760,7 +760,7 @@ u32 interact_coin(struct MarioState *m, UNUSED u32 interactType, struct Object *
if (COURSE_IS_MAIN_COURSE(gCurrCourseNum) && m->numCoins - o->oDamageOrCoinValue < 100
&& m->numCoins >= 100) {
bhv_spawn_star_no_level_exit(6);
bhv_spawn_star_no_level_exit(m->marioObj, 6);
}
if (o->oDamageOrCoinValue >= 2) {

View file

@ -131,15 +131,15 @@ static void toad_message_talking(void) {
switch (gCurrentObject->oToadMessageDialogId) {
case TOAD_STAR_1_DIALOG:
gCurrentObject->oToadMessageDialogId = TOAD_STAR_1_DIALOG_AFTER;
bhv_spawn_star_no_level_exit(0);
bhv_spawn_star_no_level_exit(gMarioStates[0].marioObj, 0);
break;
case TOAD_STAR_2_DIALOG:
gCurrentObject->oToadMessageDialogId = TOAD_STAR_2_DIALOG_AFTER;
bhv_spawn_star_no_level_exit(1);
bhv_spawn_star_no_level_exit(gMarioStates[0].marioObj, 1);
break;
case TOAD_STAR_3_DIALOG:
gCurrentObject->oToadMessageDialogId = TOAD_STAR_3_DIALOG_AFTER;
bhv_spawn_star_no_level_exit(2);
bhv_spawn_star_no_level_exit(gMarioStates[0].marioObj, 2);
break;
}
}

View file

@ -101,7 +101,7 @@ void network_receive_collect_coin(struct Packet* p) {
if (COURSE_IS_MAIN_COURSE(gCurrCourseNum)
&& gMarioStates[0].numCoins - coin->oDamageOrCoinValue < 100
&& gMarioStates[0].numCoins >= 100) {
bhv_spawn_star_no_level_exit(6);
bhv_spawn_star_no_level_exit(gMarioStates[1].marioObj, 6);
}
return;
@ -115,7 +115,7 @@ SANITY_CHECK_COINS:;
if (COURSE_IS_MAIN_COURSE(gCurrCourseNum)
&& oldCoinCount < 100
&& gMarioStates[0].numCoins >= 100) {
bhv_spawn_star_no_level_exit(6);
bhv_spawn_star_no_level_exit(gMarioStates[1].marioObj, 6);
}
}