Fix some problems found in static analysis
This commit is contained in:
parent
039be71266
commit
82945f9c0f
|
@ -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,
|
static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
|
||||||
struct WallCollisionData *data) {
|
struct WallCollisionData *data) {
|
||||||
register struct Surface *surf;
|
register struct Surface *surf;
|
||||||
register f32 offset;
|
register f32 offset = 0;
|
||||||
register f32 radius = data->radius;
|
register f32 radius = data->radius;
|
||||||
register f32 x = data->x;
|
register f32 x = data->x;
|
||||||
register f32 y = data->y + data->offsetY;
|
register f32 y = data->y + data->offsetY;
|
||||||
|
|
|
@ -69,8 +69,8 @@ static void enemy_lakitu_update_speed_and_angle(void) {
|
||||||
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000;
|
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000;
|
||||||
s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0;
|
s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0;
|
||||||
|
|
||||||
f32 minSpeed;
|
f32 minSpeed = 0;
|
||||||
s16 turnSpeed;
|
s16 turnSpeed = 0;
|
||||||
|
|
||||||
f32 distToMario = distanceToPlayer;
|
f32 distToMario = distanceToPlayer;
|
||||||
if (distToMario > 500.0f) {
|
if (distToMario > 500.0f) {
|
||||||
|
|
|
@ -704,8 +704,8 @@ void anim_and_audio_for_heavy_walk(struct MarioState *m) {
|
||||||
|
|
||||||
void push_or_sidle_wall(struct MarioState *m, Vec3f startPos) {
|
void push_or_sidle_wall(struct MarioState *m, Vec3f startPos) {
|
||||||
if (!m) { return; }
|
if (!m) { return; }
|
||||||
s16 wallAngle;
|
s16 wallAngle = 0;
|
||||||
s16 dWallAngle;
|
s16 dWallAngle = 0;
|
||||||
f32 dx = m->pos[0] - startPos[0];
|
f32 dx = m->pos[0] - startPos[0];
|
||||||
f32 dz = m->pos[2] - startPos[2];
|
f32 dz = m->pos[2] - startPos[2];
|
||||||
f32 movedDistance = sqrtf(dx * dx + dz * dz);
|
f32 movedDistance = sqrtf(dx * dx + dz * dz);
|
||||||
|
|
|
@ -162,7 +162,7 @@ void platform_on_track_update_pos_or_spawn_ball(s32 ballIndex, f32 x, f32 y, f32
|
||||||
f32 dx;
|
f32 dx;
|
||||||
f32 dy;
|
f32 dy;
|
||||||
f32 dz;
|
f32 dz;
|
||||||
f32 distToNextWaypoint;
|
f32 distToNextWaypoint = 100;
|
||||||
|
|
||||||
if (ballIndex == 0 || ((u16)(o->oBehParams >> 16) & 0x0080)) {
|
if (ballIndex == 0 || ((u16)(o->oBehParams >> 16) & 0x0080)) {
|
||||||
initialPrevWaypoint = o->oPlatformOnTrackPrevWaypoint;
|
initialPrevWaypoint = o->oPlatformOnTrackPrevWaypoint;
|
||||||
|
|
|
@ -131,31 +131,31 @@ void djui_base_compute(struct DjuiBase* base) {
|
||||||
struct DjuiBase* parent = base->parent;
|
struct DjuiBase* parent = base->parent;
|
||||||
struct DjuiBaseRect* comp = &base->comp;
|
struct DjuiBaseRect* comp = &base->comp;
|
||||||
|
|
||||||
f32 x = (base->x.type == DJUI_SVT_RELATIVE) ? parent->comp.width * base->x.value : base->x.value;
|
f32 x = (parent && 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 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 width = (parent && 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 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;
|
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;
|
height = (base->height.type == DJUI_SVT_ASPECT_RATIO) ? width * base->height.value : height;
|
||||||
|
|
||||||
// horizontal alignment
|
if (parent != NULL) {
|
||||||
if (base->hAlign == DJUI_HALIGN_CENTER) {
|
// horizontal alignment
|
||||||
x += (parent->comp.width - width) / 2.0f;
|
if (base->hAlign == DJUI_HALIGN_CENTER) {
|
||||||
} else if (base->hAlign == DJUI_HALIGN_RIGHT) {
|
x += (parent->comp.width - width) / 2.0f;
|
||||||
x = parent->comp.width - width - x;
|
} else if (base->hAlign == DJUI_HALIGN_RIGHT) {
|
||||||
}
|
x = parent->comp.width - width - x;
|
||||||
|
}
|
||||||
|
|
||||||
// vertical alignment
|
// vertical alignment
|
||||||
if (base->vAlign == DJUI_VALIGN_CENTER) {
|
if (base->vAlign == DJUI_VALIGN_CENTER) {
|
||||||
y += (parent->comp.height - height) / 2.0f;
|
y += (parent->comp.height - height) / 2.0f;
|
||||||
} else if (base->vAlign == DJUI_VALIGN_BOTTOM) {
|
} else if (base->vAlign == DJUI_VALIGN_BOTTOM) {
|
||||||
y = parent->comp.height - height - y;
|
y = parent->comp.height - height - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// offset comp on parent's location
|
// offset comp on parent's location
|
||||||
if (base->parent != NULL) {
|
|
||||||
x += parent->comp.x;
|
x += parent->comp.x;
|
||||||
y += parent->comp.y;
|
y += parent->comp.y;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ struct ModCacheEntry* mod_cache_get_from_hash(u8* dataHash) {
|
||||||
return node;
|
return node;
|
||||||
} else {
|
} else {
|
||||||
mod_cache_remove_node(node, prev);
|
mod_cache_remove_node(node, prev);
|
||||||
|
node = prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prev = node;
|
prev = node;
|
||||||
|
@ -115,6 +116,7 @@ struct ModCacheEntry* mod_cache_get_from_path(const char* path, bool validate) {
|
||||||
return node;
|
return node;
|
||||||
} else {
|
} else {
|
||||||
mod_cache_remove_node(node, prev);
|
mod_cache_remove_node(node, prev);
|
||||||
|
node = prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prev = node;
|
prev = node;
|
||||||
|
@ -278,8 +280,8 @@ void mod_cache_load(void) {
|
||||||
fread(&lastLoaded, sizeof(u64), 1, fp);
|
fread(&lastLoaded, sizeof(u64), 1, fp);
|
||||||
fread(&pathLen, sizeof(u16), 1, fp);
|
fread(&pathLen, sizeof(u16), 1, fp);
|
||||||
|
|
||||||
const char* path = calloc(pathLen + 1, sizeof(u8));
|
const char* path = calloc(pathLen + 1, sizeof(char*));
|
||||||
fread((char*)path, sizeof(u8), pathLen + 1, fp);
|
fread((char*)path, sizeof(char*), pathLen + 1, fp);
|
||||||
|
|
||||||
mod_cache_add_internal(dataHash, lastLoaded, path);
|
mod_cache_add_internal(dataHash, lastLoaded, path);
|
||||||
count++;
|
count++;
|
||||||
|
|
|
@ -25,6 +25,7 @@ static bool mod_import_lua(char* src) {
|
||||||
FILE* fout = fopen(dst, "wb");
|
FILE* fout = fopen(dst, "wb");
|
||||||
if (fout == NULL) {
|
if (fout == NULL) {
|
||||||
LOG_ERROR("Failed to open dst path for lua mod import");
|
LOG_ERROR("Failed to open dst path for lua mod import");
|
||||||
|
fclose(fin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue