Some small fixes

This commit is contained in:
Arceveti
2021-09-22 18:03:54 -07:00
parent 5beba37d0e
commit fba9f665cd
7 changed files with 17 additions and 34 deletions

View File

@@ -27,7 +27,7 @@ const Trajectory ccm_seg7_trajectory_penguin_race[] = {
TRAJECTORY_POS(24, /*pos*/ 1333, 761, -1733),
TRAJECTORY_POS(25, /*pos*/ 2488, 562, -2944),
TRAJECTORY_POS(26, /*pos*/ 2977, 361, -4988),
//! missing ID
TRAJECTORY_POS(27, /*pos*/ 3366, 345, -5339),
TRAJECTORY_POS(28, /*pos*/ 3754, 329, -5689),
TRAJECTORY_POS(29, /*pos*/ 5805, 86, -5980),
TRAJECTORY_POS(30, /*pos*/ 6566, -449, -4133),

View File

@@ -121,12 +121,15 @@ void vec3f_cross(Vec3f dest, Vec3f a, Vec3f b) {
/// Scale vector 'dest' so it has length 1
void vec3f_normalize(Vec3f dest) {
//! Possible division by zero
f32 invsqrt = 1.0f / sqrtf(sqr(dest[0]) + sqr(dest[1]) + sqr(dest[2]));
f32 invsqrt = sqrtf(sqr(dest[0]) + sqr(dest[1]) + sqr(dest[2]));
dest[0] *= invsqrt;
dest[1] *= invsqrt;
dest[2] *= invsqrt;
if (invsqrt != 0.0f) {
invsqrt = 1.0f / invsqrt;
dest[0] *= invsqrt;
dest[1] *= invsqrt;
dest[2] *= invsqrt;
}
}
/// Copy matrix 'src' to 'dest'

View File

@@ -736,10 +736,6 @@ static UNUSED void set_pos_to_mario(Vec3f foc, Vec3f pos, f32 yOff, f32 focYOff,
vec3f_set_dist_and_angle(marioPos, pos, dist, pitch + sLakituPitch, yaw);
vec3f_get_dist_and_angle(pos, sMarioCamState->pos, &posDist, &posPitch, &posYaw);
//! Useless get and set
vec3f_get_dist_and_angle(pos, foc, &focDist, &focPitch, &focYaw);
vec3f_set_dist_and_angle(pos, foc, focDist, focPitch, focYaw);
foc[1] = sMarioCamState->pos[1] + focYOff;
}
@@ -751,8 +747,6 @@ void set_camera_height(struct Camera *c, f32 goalHeight) {
f32 marioFloorHeight;
f32 marioCeilHeight;
f32 camFloorHeight;
UNUSED u8 filler[8];
UNUSED s16 action = sMarioCamState->action;
f32 baseOff = 125.f;
f32 camCeilHeight = find_ceil(c->pos[0], gLakituState.goalPos[1] - 50.f, c->pos[2], &surface);
@@ -10299,12 +10293,6 @@ void cutscene_door_move_behind_mario(struct Camera *c) {
vec3s_set(sCutsceneVars[0].angle, 0, sMarioCamState->faceAngle[1] + doorRotation, 0);
vec3f_set(camOffset, 0.f, 125.f, 250.f);
if (doorRotation == 0) { //! useless code
camOffset[0] = 0.f;
} else {
camOffset[0] = 0.f;
}
offset_rotated(c->pos, sMarioCamState->pos, camOffset, sCutsceneVars[0].angle);
}
@@ -11220,9 +11208,7 @@ void play_cutscene(struct Camera *c) {
#undef CUTSCENE
if ((cutsceneDuration != 0) && !(gCutsceneTimer & CUTSCENE_STOP)) {
//! @bug This should check for 0x7FFF (CUTSCENE_LOOP)
//! instead, cutscenes that last longer than 0x3FFF frames will never end on their own
if (gCutsceneTimer < 0x3FFF) {
if (gCutsceneTimer < CUTSCENE_LOOP) {
gCutsceneTimer += 1;
}
//! Because gCutsceneTimer is often set to 0x7FFF (CUTSCENE_LOOP), this conditional can only

View File

@@ -1959,10 +1959,9 @@ void generate_yellow_sparkles(s16 x, s16 y, s16 z, f32 radius) {
spawn_object_abs_with_rot(gCurrentObject, 0, MODEL_NONE, bhvSparkleSpawn, x + offsetX, y + offsetY,
z + offsetZ, 0, 0, 0);
//! copy paste error
offsetX = offsetX * 4 / 3;
offsetX = offsetY * 4 / 3;
offsetX = offsetZ * 4 / 3;
offsetY = offsetY * 4 / 3;
offsetZ = offsetZ * 4 / 3;
spawn_object_abs_with_rot(gCurrentObject, 0, MODEL_NONE, bhvSparkleSpawn, x - offsetX, y - offsetY,
z - offsetZ, 0, 0, 0);

View File

@@ -566,9 +566,8 @@ void clear_objects(void) {
* Update spawner and surface objects.
*/
void update_terrain_objects(void) {
gObjectCounter = update_objects_in_list(&gObjectLists[OBJ_LIST_SPAWNER]);
//! This was meant to be +=
gObjectCounter = update_objects_in_list(&gObjectLists[OBJ_LIST_SURFACE]);
gObjectCounter = update_objects_in_list(&gObjectLists[OBJ_LIST_SPAWNER]);
gObjectCounter += update_objects_in_list(&gObjectLists[OBJ_LIST_SURFACE]);
}
/**
@@ -576,7 +575,6 @@ void update_terrain_objects(void) {
* the order specified by sObjectListUpdateOrder.
*/
void update_non_terrain_objects(void) {
UNUSED s32 unused;
s32 listIndex;
s32 i = 2;

View File

@@ -212,12 +212,11 @@ void stop_other_paintings(s16 *idptr, struct Painting *paintingGroup[]) {
* @return Mario's y position inside the painting (bounded).
*/
f32 painting_mario_y(struct Painting *painting) {
//! Unnecessary use of double constants
// Add 50 to make the ripple closer to Mario's center of mass.
f32 relY = gPaintingMarioYPos - painting->posY + 50.0;
f32 relY = gPaintingMarioYPos - painting->posY + 50.0f;
if (relY < 0.0) {
relY = 0.0;
if (relY < 0.0f) {
relY = 0.0f;
} else if (relY > painting->size) {
relY = painting->size;
}

View File

@@ -358,7 +358,6 @@ s32 scan_to_next_non_whitespace(void) {
if (curChar == '\x1a') { //'SUB' character: "soft EOF" in older systems
return FALSE;
continue; // unreachable
}
if (is_line_end(curChar)) {
@@ -383,7 +382,6 @@ s32 is_next_buf_word(char *a0) {
for (curChar = get_and_advance_buf(); curChar != '\0'; curChar = get_and_advance_buf()) {
if (is_white_space(curChar) || is_line_end(curChar)) {
break;
continue; // unreachable + nonsensical
}
wordBuf[bufLength] = curChar;
bufLength++;