diff --git a/src/game/behaviors/ttc_2d_rotator.inc.c b/src/game/behaviors/ttc_2d_rotator.inc.c index abf61aef..c4b04cc1 100644 --- a/src/game/behaviors/ttc_2d_rotator.inc.c +++ b/src/game/behaviors/ttc_2d_rotator.inc.c @@ -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); diff --git a/src/game/behaviors/ttc_moving_bar.inc.c b/src/game/behaviors/ttc_moving_bar.inc.c index 27cdd868..dbe28eca 100644 --- a/src/game/behaviors/ttc_moving_bar.inc.c +++ b/src/game/behaviors/ttc_moving_bar.inc.c @@ -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; } diff --git a/src/game/behaviors/ttc_pendulum.inc.c b/src/game/behaviors/ttc_pendulum.inc.c index 72286e63..1fd4e0ed 100644 --- a/src/game/behaviors/ttc_pendulum.inc.c +++ b/src/game/behaviors/ttc_pendulum.inc.c @@ -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; diff --git a/src/game/behaviors/ttc_rotating_solid.inc.c b/src/game/behaviors/ttc_rotating_solid.inc.c index 33465e8d..98673092 100644 --- a/src/game/behaviors/ttc_rotating_solid.inc.c +++ b/src/game/behaviors/ttc_rotating_solid.inc.c @@ -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) { diff --git a/src/game/behaviors/ttc_treadmill.inc.c b/src/game/behaviors/ttc_treadmill.inc.c index 9394e7da..e5fe3444 100644 --- a/src/game/behaviors/ttc_treadmill.inc.c +++ b/src/game/behaviors/ttc_treadmill.inc.c @@ -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; diff --git a/src/pc/network/packets/packet_level.c b/src/pc/network/packets/packet_level.c index 896ebeaf..aa636f2d 100644 --- a/src/pc/network/packets/packet_level.c +++ b/src/pc/network/packets/packet_level.c @@ -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]; + } + } + } }