Various tuxie synchronization fixes
This commit is contained in:
parent
c54063fadd
commit
af117f4647
|
@ -62,7 +62,7 @@ void tuxies_mother_act_1(void) {
|
|||
dialogID = DIALOG_058;
|
||||
else
|
||||
dialogID = DIALOG_059;
|
||||
if (cur_obj_update_dialog_with_cutscene(marioState, 2, 1, CUTSCENE_DIALOG, dialogID, tuxies_mother_act_1_continue_dialog)) {
|
||||
if (nearest_mario_state_to_object(o) == &gMarioStates[0] && cur_obj_update_dialog_with_cutscene(marioState, 2, 1, CUTSCENE_DIALOG, dialogID, tuxies_mother_act_1_continue_dialog)) {
|
||||
if (dialogID == DIALOG_058)
|
||||
o->oSubAction = 1;
|
||||
else
|
||||
|
@ -132,7 +132,7 @@ void tuxies_mother_act_0(void) {
|
|||
o->oSubAction++;
|
||||
break;
|
||||
case 1:
|
||||
if (cur_obj_update_dialog_with_cutscene(marioState, 2, 1, CUTSCENE_DIALOG, DIALOG_057, tuxies_mother_act_0_continue_dialog))
|
||||
if (nearest_mario_state_to_object(o) == &gMarioStates[0] && cur_obj_update_dialog_with_cutscene(marioState, 2, 1, CUTSCENE_DIALOG, DIALOG_057, tuxies_mother_act_0_continue_dialog))
|
||||
o->oSubAction++;
|
||||
break;
|
||||
case 2:
|
||||
|
|
|
@ -2447,16 +2447,14 @@ s32 bit_shift_left(s32 a0) {
|
|||
}
|
||||
|
||||
s32 cur_obj_mario_far_away(void) {
|
||||
f32 dx = o->oHomeX - gMarioObject->oPosX;
|
||||
f32 dy = o->oHomeY - gMarioObject->oPosY;
|
||||
f32 dz = o->oHomeZ - gMarioObject->oPosZ;
|
||||
f32 marioDistToHome = sqrtf(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
if (o->oDistanceToMario > 2000.0f && marioDistToHome > 2000.0f) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||
f32 dx = o->oHomeX - gMarioObject->oPosX;
|
||||
f32 dy = o->oHomeY - gMarioObject->oPosY;
|
||||
f32 dz = o->oHomeZ - gMarioObject->oPosZ;
|
||||
f32 marioDistToHome = sqrtf(dx * dx + dy * dy + dz * dz);
|
||||
if (marioDistToHome <= 2000.0f) { return FALSE; }
|
||||
}
|
||||
return (o->oDistanceToMario > 2000.0f);
|
||||
}
|
||||
|
||||
s32 is_mario_moving_fast_or_in_air(s32 speedThreshold) {
|
||||
|
|
|
@ -103,6 +103,20 @@ static void packet_write_object_header(struct Packet* p, struct Object* o) {
|
|||
packet_write(p, &behaviorId, sizeof(enum BehaviorId));
|
||||
}
|
||||
|
||||
static bool allowable_behavior_change(struct SyncObject* so, struct BehaviorScript* behavior) {
|
||||
struct Object* o = so->o;
|
||||
bool allow = false;
|
||||
|
||||
// bhvPenguinBaby can be set to bhvSmallPenguin
|
||||
allow = allow || ((o->behavior == bhvPenguinBaby || o->behavior == bhvSmallPenguin) && (behavior == bhvPenguinBaby || behavior == bhvSmallPenguin));
|
||||
|
||||
if (!allow) { return false; }
|
||||
|
||||
so->behavior = behavior;
|
||||
so->o->behavior = behavior;
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct SyncObject* packet_read_object_header(struct Packet* p) {
|
||||
// get sync ID, sanity check
|
||||
u32 syncId = 0;
|
||||
|
@ -137,8 +151,8 @@ static struct SyncObject* packet_read_object_header(struct Packet* p) {
|
|||
// make sure the behaviors match
|
||||
enum BehaviorId behaviorId;
|
||||
packet_read(p, &behaviorId, sizeof(enum BehaviorId));
|
||||
so->behavior = get_behavior_from_id(behaviorId);
|
||||
if (o->behavior != so->behavior) {
|
||||
struct BehaviorScript* behavior = get_behavior_from_id(behaviorId);
|
||||
if (o->behavior != behavior && !allowable_behavior_change(so, behavior)) {
|
||||
printf("network_receive_object() behavior mismatch!\n");
|
||||
network_forget_sync_object(so);
|
||||
return NULL;
|
||||
|
@ -268,7 +282,7 @@ void network_send_object(struct Object* o) {
|
|||
if (!network_sync_object_initialized(o)) { return; }
|
||||
struct SyncObject* so = &syncObjects[o->oSyncID];
|
||||
if (so == NULL) { return; }
|
||||
if (o->behavior != so->behavior) {
|
||||
if (o->behavior != so->behavior && !allowable_behavior_change(so, so->behavior)) {
|
||||
printf("network_send_object() BEHAVIOR MISMATCH!\n");
|
||||
network_forget_sync_object(so);
|
||||
return;
|
||||
|
@ -288,7 +302,8 @@ void network_send_object_reliability(struct Object* o, bool reliable) {
|
|||
if (!network_sync_object_initialized(o)) { return; }
|
||||
struct SyncObject* so = &syncObjects[o->oSyncID];
|
||||
if (so == NULL) { return; }
|
||||
if (o->behavior != so->behavior) {
|
||||
|
||||
if (o->behavior != so->behavior && !allowable_behavior_change(so, so->behavior)) {
|
||||
printf("network_send_object() BEHAVIOR MISMATCH!\n");
|
||||
network_forget_sync_object(so);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue