Fix TTC desync!
This commit is contained in:
parent
e780b74d1b
commit
598db03d80
|
@ -8,7 +8,7 @@
|
|||
/**
|
||||
* Speeds for the hand and the 2D cog, respectively. Negative because clockwise.
|
||||
*/
|
||||
static s16 sTTC2DRotatorSpeeds[] = {
|
||||
s16 gTTC2DRotatorSpeeds[] = {
|
||||
-0x444,
|
||||
-0xCCC,
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ static s16 sTTC2DRotatorSpeeds[] = {
|
|||
* only used for the first turn, after which it is chosen randomly.
|
||||
* These values are for the hand and the 2D cog, respectively.
|
||||
*/
|
||||
static s16 sTTC2DRotatorTimeBetweenTurns[][4] = {
|
||||
s16 gTTC2DRotatorTimeBetweenTurns[][4] = {
|
||||
{
|
||||
/* TTC_SPEED_SLOW */ 40,
|
||||
/* TTC_SPEED_FAST */ 10,
|
||||
|
@ -38,8 +38,8 @@ static s16 sTTC2DRotatorTimeBetweenTurns[][4] = {
|
|||
*/
|
||||
void bhv_ttc_2d_rotator_init(void) {
|
||||
if (o->oBehParams2ndByte >= 0 && o->oBehParams2ndByte < 2 && gTTCSpeedSetting >= 0 && gTTCSpeedSetting < 4) {
|
||||
o->oTTC2DRotatorMinTimeUntilNextTurn = sTTC2DRotatorTimeBetweenTurns[o->oBehParams2ndByte][gTTCSpeedSetting];
|
||||
o->oTTC2DRotatorIncrement = o->oTTC2DRotatorSpeed = sTTC2DRotatorSpeeds[o->oBehParams2ndByte];
|
||||
o->oTTC2DRotatorMinTimeUntilNextTurn = gTTC2DRotatorTimeBetweenTurns[o->oBehParams2ndByte][gTTCSpeedSetting];
|
||||
o->oTTC2DRotatorIncrement = o->oTTC2DRotatorSpeed = gTTC2DRotatorSpeeds[o->oBehParams2ndByte];
|
||||
}
|
||||
|
||||
struct SyncObject* so = sync_object_init(o, 4000.0f);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* The delay before each cycle on each setting. On random setting, this is
|
||||
* overwritten with one of the below delays after the first cycle.
|
||||
*/
|
||||
static s16 sTTCMovingBarDelays[] = {
|
||||
s16 gTTCMovingBarDelays[] = {
|
||||
/* TTC_SPEED_SLOW */ 55,
|
||||
/* TTC_SPEED_FAST */ 30,
|
||||
/* TTC_SPEED_RANDOM */ 55,
|
||||
|
@ -24,7 +24,7 @@ static s8 sTTCMovingBarRandomDelays[] = { 1, 12, 55, 100 };
|
|||
*/
|
||||
void bhv_ttc_moving_bar_init(void) {
|
||||
// If on still setting, then stick out
|
||||
if ((o->oTTCMovingBarDelay = sTTCMovingBarDelays[gTTCSpeedSetting]) == 0) {
|
||||
if ((o->oTTCMovingBarDelay = gTTCMovingBarDelays[gTTCSpeedSetting]) == 0) {
|
||||
o->oTTCMovingBarOffset = 250.0f;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
/**
|
||||
* Initial angle acceleration.
|
||||
*/
|
||||
static f32 sTTCPendulumInitialAccels[] = {
|
||||
f32 gTTCPendulumInitialAccels[] = {
|
||||
/* TTC_SPEED_SLOW */ 13.0f,
|
||||
/* TTC_SPEED_FAST */ 22.0f,
|
||||
/* TTC_SPEED_RANDOM */ 13.0f,
|
||||
|
@ -19,7 +19,7 @@ static f32 sTTCPendulumInitialAccels[] = {
|
|||
*/
|
||||
void bhv_ttc_pendulum_init(void) {
|
||||
if (gTTCSpeedSetting != TTC_SPEED_STOPPED && gTTCSpeedSetting > 0 && gTTCSpeedSetting < 4) {
|
||||
o->oTTCPendulumAngleAccel = sTTCPendulumInitialAccels[gTTCSpeedSetting];
|
||||
o->oTTCPendulumAngleAccel = gTTCPendulumInitialAccels[gTTCSpeedSetting];
|
||||
o->oTTCPendulumAngle = 6500.0f;
|
||||
} else {
|
||||
o->oTTCPendulumAngle = 6371.5557f;
|
||||
|
|
|
@ -15,7 +15,7 @@ static void const *sTTCRotatingSolidCollisionModels[] = {
|
|||
/**
|
||||
* The number of frames to wait before rotating for the first time.
|
||||
*/
|
||||
static u8 sTTCRotatingSolidInitialDelays[] = {
|
||||
u8 gTTCRotatingSolidInitialDelays[] = {
|
||||
/* TTC_SPEED_SLOW */ 120,
|
||||
/* TTC_SPEED_FAST */ 40,
|
||||
/* TTC_SPEED_RANDOM */ 0,
|
||||
|
@ -32,7 +32,7 @@ void bhv_ttc_rotating_solid_init(void) {
|
|||
|
||||
o->oTTCRotatingSolidNumSides = o->oBehParams2ndByte == TTC_ROTATING_SOLID_BP_CUBE ? 4 : 3;
|
||||
|
||||
o->oTTCRotatingSolidRotationDelay = sTTCRotatingSolidInitialDelays[gTTCSpeedSetting];
|
||||
o->oTTCRotatingSolidRotationDelay = gTTCRotatingSolidInitialDelays[gTTCSpeedSetting];
|
||||
|
||||
struct SyncObject* so = sync_object_init(o, 4000.0f);
|
||||
if (so) {
|
||||
|
|
|
@ -14,7 +14,7 @@ static Collision const *sTTCTreadmillCollisionModels[] = {
|
|||
ttc_seg7_collision_070153E0,
|
||||
};
|
||||
|
||||
static s16 sTTCTreadmillSpeeds[] = {
|
||||
s16 gTTCTreadmillSpeeds[] = {
|
||||
/* TTC_SPEED_SLOW */ 50,
|
||||
/* TTC_SPEED_FAST */ 100,
|
||||
/* TTC_SPEED_RANDOM */ 0,
|
||||
|
@ -30,7 +30,7 @@ void bhv_ttc_treadmill_init(void) {
|
|||
o->oTTCTreadmillBigSurface = segmented_to_virtual(ttc_movtex_tris_big_surface_treadmill);
|
||||
o->oTTCTreadmillSmallSurface = segmented_to_virtual(ttc_movtex_tris_small_surface_treadmill);
|
||||
|
||||
*o->oTTCTreadmillBigSurface = *o->oTTCTreadmillSmallSurface = sTTCTreadmillSpeeds[gTTCSpeedSetting];
|
||||
*o->oTTCTreadmillBigSurface = *o->oTTCTreadmillSmallSurface = gTTCTreadmillSpeeds[gTTCSpeedSetting];
|
||||
|
||||
sMasterTreadmill = NULL;
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
#include "object_fields.h"
|
||||
//#define DISABLE_MODULE_LOG 1
|
||||
#include "pc/debuglog.h"
|
||||
#include "pc/lua/smlua.h"
|
||||
#include "pc/lua/smlua_utils.h"
|
||||
#include "pc/lua/utils/smlua_obj_utils.h"
|
||||
|
||||
void network_send_level(struct NetworkPlayer* toNp, bool sendArea) {
|
||||
extern s16 gCurrCourseNum, gCurrActStarNum, gCurrLevelNum;
|
||||
|
@ -50,6 +53,12 @@ void network_send_level(struct NetworkPlayer* toNp, bool sendArea) {
|
|||
LOG_INFO("tx level");
|
||||
}
|
||||
|
||||
extern s16 gTTC2DRotatorSpeeds[];
|
||||
extern s16 gTTC2DRotatorTimeBetweenTurns[][4];
|
||||
extern s16 gTTCMovingBarDelays[];
|
||||
extern f32 gTTCPendulumInitialAccels[];
|
||||
extern u8 gTTCRotatingSolidInitialDelays[];
|
||||
extern s16 gTTCTreadmillSpeeds[];
|
||||
void network_receive_level(struct Packet* p) {
|
||||
LOG_INFO("rx level");
|
||||
|
||||
|
@ -66,8 +75,40 @@ void network_receive_level(struct Packet* p) {
|
|||
}
|
||||
|
||||
// read level variables
|
||||
s16 oldTTCSpeedSetting = gTTCSpeedSetting;
|
||||
packet_read(p, &gMarioStates[0].numCoins, sizeof(s16));
|
||||
packet_read(p, &gPssSlideStarted, sizeof(u8));
|
||||
packet_read(p, &gTTCSpeedSetting, sizeof(s16)); // likely doesn't work after level load.. but it could
|
||||
packet_read(p, &gTTCSpeedSetting, sizeof(s16));
|
||||
gHudDisplay.coins = gMarioStates[0].numCoins;
|
||||
|
||||
// fix TTC objects by reinitializing values pertaining to speed
|
||||
if (levelNum == LEVEL_TTC) {
|
||||
u32 sanityDepth = 0;
|
||||
for (struct Object *obj = obj_get_first(OBJ_LIST_SURFACE); obj != NULL; obj = obj_get_next(obj)) {
|
||||
if (++sanityDepth > 10000) { break; }
|
||||
if (obj_has_behavior_id(obj, id_bhvTTC2DRotator)) {
|
||||
if (obj->oBehParams2ndByte >= 0 && obj->oBehParams2ndByte < 2 && gTTCSpeedSetting >= 0 && gTTCSpeedSetting < 4) {
|
||||
obj->oTTC2DRotatorMinTimeUntilNextTurn = gTTC2DRotatorTimeBetweenTurns[obj->oBehParams2ndByte][gTTCSpeedSetting];
|
||||
obj->oTTC2DRotatorIncrement = obj->oTTC2DRotatorSpeed = gTTC2DRotatorSpeeds[obj->oBehParams2ndByte];
|
||||
}
|
||||
} else if (obj_has_behavior_id(obj, id_bhvTTCMovingBar)) {
|
||||
if ((obj->oTTCMovingBarDelay = gTTCMovingBarDelays[gTTCSpeedSetting]) == 0) {
|
||||
obj->oTTCMovingBarOffset = 250.0f;
|
||||
}
|
||||
} else if (obj_has_behavior_id(obj, id_bhvTTCPendulum)) {
|
||||
if (gTTCSpeedSetting != TTC_SPEED_STOPPED && gTTCSpeedSetting > 0 && gTTCSpeedSetting < 4) {
|
||||
obj->oTTCPendulumAngleAccel = gTTCPendulumInitialAccels[gTTCSpeedSetting];
|
||||
obj->oTTCPendulumAngle = 6500.0f;
|
||||
} else {
|
||||
obj->oTTCPendulumAngle = 6371.5557f;
|
||||
}
|
||||
} else if (obj_has_behavior_id(obj, id_bhvTTCPitBlock) && oldTTCSpeedSetting == TTC_SPEED_STOPPED && gTTCSpeedSetting != TTC_SPEED_STOPPED) {
|
||||
obj->oPosY -= 330.0f;
|
||||
} else if (obj_has_behavior_id(obj, id_bhvTTCRotatingSolid)) {
|
||||
obj->oTTCRotatingSolidRotationDelay = gTTCRotatingSolidInitialDelays[gTTCSpeedSetting];
|
||||
} else if (obj_has_behavior_id(obj, id_bhvTTCTreadmill)) {
|
||||
*obj->oTTCTreadmillBigSurface = *obj->oTTCTreadmillSmallSurface = gTTCTreadmillSpeeds[gTTCSpeedSetting];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue