diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index d7fc692b..4dcb0ad2 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -106,7 +106,7 @@ static void closest_point_to_triangle(struct Surface* surf, Vec3f src, Vec3f out static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode, struct WallCollisionData *data) { register struct Surface *surf; - register f32 offset; + register f32 offset = 0; register f32 radius = data->radius; register f32 x = data->x; register f32 y = data->y + data->offsetY; diff --git a/src/game/behaviors/enemy_lakitu.inc.c b/src/game/behaviors/enemy_lakitu.inc.c index f59e15bd..0f5a1171 100644 --- a/src/game/behaviors/enemy_lakitu.inc.c +++ b/src/game/behaviors/enemy_lakitu.inc.c @@ -69,8 +69,8 @@ static void enemy_lakitu_update_speed_and_angle(void) { s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000; s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0; - f32 minSpeed; - s16 turnSpeed; + f32 minSpeed = 0; + s16 turnSpeed = 0; f32 distToMario = distanceToPlayer; if (distToMario > 500.0f) { diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index a64d60f4..ee04a5a3 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -704,8 +704,8 @@ void anim_and_audio_for_heavy_walk(struct MarioState *m) { void push_or_sidle_wall(struct MarioState *m, Vec3f startPos) { if (!m) { return; } - s16 wallAngle; - s16 dWallAngle; + s16 wallAngle = 0; + s16 dWallAngle = 0; f32 dx = m->pos[0] - startPos[0]; f32 dz = m->pos[2] - startPos[2]; f32 movedDistance = sqrtf(dx * dx + dz * dz); diff --git a/src/game/obj_behaviors_2.c b/src/game/obj_behaviors_2.c index 36530cdd..3e0dd0a4 100644 --- a/src/game/obj_behaviors_2.c +++ b/src/game/obj_behaviors_2.c @@ -162,7 +162,7 @@ void platform_on_track_update_pos_or_spawn_ball(s32 ballIndex, f32 x, f32 y, f32 f32 dx; f32 dy; f32 dz; - f32 distToNextWaypoint; + f32 distToNextWaypoint = 100; if (ballIndex == 0 || ((u16)(o->oBehParams >> 16) & 0x0080)) { initialPrevWaypoint = o->oPlatformOnTrackPrevWaypoint; diff --git a/src/pc/djui/djui_base.c b/src/pc/djui/djui_base.c index 35114e38..f0b98fd7 100644 --- a/src/pc/djui/djui_base.c +++ b/src/pc/djui/djui_base.c @@ -131,31 +131,31 @@ void djui_base_compute(struct DjuiBase* base) { struct DjuiBase* parent = base->parent; struct DjuiBaseRect* comp = &base->comp; - f32 x = (base->x.type == DJUI_SVT_RELATIVE) ? parent->comp.width * base->x.value : base->x.value; - f32 y = (base->y.type == DJUI_SVT_RELATIVE) ? parent->comp.height * base->y.value : base->y.value; + f32 x = (parent && base->x.type == DJUI_SVT_RELATIVE) ? parent->comp.width * base->x.value : base->x.value; + f32 y = (parent && base->y.type == DJUI_SVT_RELATIVE) ? parent->comp.height * base->y.value : base->y.value; - f32 width = (base->width.type == DJUI_SVT_RELATIVE) ? parent->comp.width * base->width.value : base->width.value; - f32 height = (base->height.type == DJUI_SVT_RELATIVE) ? parent->comp.height * base->height.value : base->height.value; + f32 width = (parent && base->width.type == DJUI_SVT_RELATIVE) ? parent->comp.width * base->width.value : base->width.value; + f32 height = (parent && base->height.type == DJUI_SVT_RELATIVE) ? parent->comp.height * base->height.value : base->height.value; width = (base->width.type == DJUI_SVT_ASPECT_RATIO) ? height * base->width.value : width; height = (base->height.type == DJUI_SVT_ASPECT_RATIO) ? width * base->height.value : height; - // horizontal alignment - if (base->hAlign == DJUI_HALIGN_CENTER) { - x += (parent->comp.width - width) / 2.0f; - } else if (base->hAlign == DJUI_HALIGN_RIGHT) { - x = parent->comp.width - width - x; - } + if (parent != NULL) { + // horizontal alignment + if (base->hAlign == DJUI_HALIGN_CENTER) { + x += (parent->comp.width - width) / 2.0f; + } else if (base->hAlign == DJUI_HALIGN_RIGHT) { + x = parent->comp.width - width - x; + } - // vertical alignment - if (base->vAlign == DJUI_VALIGN_CENTER) { - y += (parent->comp.height - height) / 2.0f; - } else if (base->vAlign == DJUI_VALIGN_BOTTOM) { - y = parent->comp.height - height - y; - } + // vertical alignment + if (base->vAlign == DJUI_VALIGN_CENTER) { + y += (parent->comp.height - height) / 2.0f; + } else if (base->vAlign == DJUI_VALIGN_BOTTOM) { + y = parent->comp.height - height - y; + } - // offset comp on parent's location - if (base->parent != NULL) { + // offset comp on parent's location x += parent->comp.x; y += parent->comp.y; } diff --git a/src/pc/mods/mod_cache.c b/src/pc/mods/mod_cache.c index 36eeee17..87a1329b 100644 --- a/src/pc/mods/mod_cache.c +++ b/src/pc/mods/mod_cache.c @@ -94,6 +94,7 @@ struct ModCacheEntry* mod_cache_get_from_hash(u8* dataHash) { return node; } else { mod_cache_remove_node(node, prev); + node = prev; } } prev = node; @@ -115,6 +116,7 @@ struct ModCacheEntry* mod_cache_get_from_path(const char* path, bool validate) { return node; } else { mod_cache_remove_node(node, prev); + node = prev; } } prev = node; @@ -278,8 +280,8 @@ void mod_cache_load(void) { fread(&lastLoaded, sizeof(u64), 1, fp); fread(&pathLen, sizeof(u16), 1, fp); - const char* path = calloc(pathLen + 1, sizeof(u8)); - fread((char*)path, sizeof(u8), pathLen + 1, fp); + const char* path = calloc(pathLen + 1, sizeof(char*)); + fread((char*)path, sizeof(char*), pathLen + 1, fp); mod_cache_add_internal(dataHash, lastLoaded, path); count++; diff --git a/src/pc/mods/mod_import.c b/src/pc/mods/mod_import.c index e57097da..b751b0da 100644 --- a/src/pc/mods/mod_import.c +++ b/src/pc/mods/mod_import.c @@ -25,6 +25,7 @@ static bool mod_import_lua(char* src) { FILE* fout = fopen(dst, "wb"); if (fout == NULL) { LOG_ERROR("Failed to open dst path for lua mod import"); + fclose(fin); return false; }