chore(windows port): Cleaned up some msvc warnings

Mainly relating to double -> float casts and some size_t -> long casts
This commit is contained in:
Sara 2023-11-22 13:01:04 +01:00 committed by Scott-G-GD
parent d4d650c2c7
commit fd0183d34a
5 changed files with 16 additions and 18 deletions

View file

@ -10,16 +10,16 @@ static asset_id _next_id = 0;
static
size_t file_length(FILE* fp) {
size_t start = ftell(fp);
long start = ftell(fp);
fseek(fp, 0, SEEK_END);
size_t r = ftell(fp);
long r = ftell(fp);
fseek(fp, start, SEEK_SET);
return r;
return (size_t)r;
}
static
void read_file(FILE* fp, char* out_buffer, size_t out_size) {
size_t start = ftell(fp);
long start = ftell(fp);
fread(out_buffer, 1, out_size, fp);
fseek(fp, start, SEEK_SET);
}
@ -88,15 +88,13 @@ asset_id get_asset_id(void* asset) {
}
void free_asset(asset_id id) {
Asset* found;
size_t found_index;
Asset* found = NULL;
size_t found_index = _assets.len;
for(size_t i = 0; i < _assets.len; ++i) {
found = list_at_as(Asset, &_assets, i);
if(found->tc->get_id(found->data) == id) {
found_index = i;
break;
} else {
found = NULL;
}
}
ASSERT_RETURN(found != NULL,, "Attempt to free nonexistent asset.");

View file

@ -31,8 +31,8 @@ size_t json_array_len(cJSON* array);
static inline
Vector json_array_to_vector(cJSON* array) {
return (Vector) {
cJSON_GetArrayItem(array, 0)->valuedouble,
cJSON_GetArrayItem(array, 1)->valuedouble,
(float)cJSON_GetArrayItem(array, 0)->valuedouble,
(float)cJSON_GetArrayItem(array, 1)->valuedouble,
};
}
static inline

View file

@ -21,7 +21,7 @@ SDL_FRect camera_world_to_pixel_rect(Camera* self, SDL_FRect* world_space) {
t.scale = OneVector;
t = transform_invert(t);
Vector tl = {world_space->x + (self->fov / 2.0), world_space->y + (_camera_height(self) / 2.0)};
Vector tl = {world_space->x + (self->fov / 2.0f), world_space->y + (_camera_height(self) / 2.0f)};
Vector size = {world_space->w, world_space->h};
tl = vmulff(transform_point(&t, tl), g_render_resolution.x / self->fov);
@ -40,7 +40,7 @@ Vector camera_world_to_pixel_point(Camera* self, Vector point) {
t.scale = OneVector;
t = transform_invert(t);
point = (Vector){point.x + (self->fov / 2.0), point.y + (_camera_height(self) / 2.0)};
point = (Vector){point.x + (self->fov / 2.0f), point.y + (_camera_height(self) / 2.0f)};
return vmulff(transform_point(&t, point), g_render_resolution.x / self->fov);
}

View file

@ -25,7 +25,7 @@ double tstos(struct timespec ts) {
struct timespec get_time() {
struct timespec ts;
timespec_get(&ts, TIME_UTC);
(void)timespec_get(&ts, TIME_UTC);
return ts;
}
@ -132,10 +132,10 @@ void program_handle_windowevent(SDL_WindowEvent* event) {
inline
float delta_time() {
return _target_delta_time == 0 ? _delta_time : _target_delta_time;
return (float)(_target_delta_time == 0 ? _delta_time : _target_delta_time);
}
inline
float game_time() {
return get_time_s() - _game_start_time;
return (float)(get_time_s() - _game_start_time);
}

View file

@ -106,7 +106,7 @@ float vsqrmagnitudef(Vector a) {
static inline
Vector vnormalizedf(Vector a) {
if(veqf(a, ZeroVector)) return ZeroVector;
return vmulff(a, 1.0/vmagnitudef(a));
return vmulff(a, 1.0f/vmagnitudef(a));
}
static inline
float vdotf(Vector a, Vector b) {
@ -122,7 +122,7 @@ float vsqrdistf(Vector a, Vector b) {
}
static inline
Vector vreciprocalf(Vector a) {
return (Vector){1.0/a.x, 1.0/a.y};
return (Vector){1.0f/a.x, 1.0f/a.y};
}
static inline
Vector vrotatef(Vector a, float t) {
@ -157,7 +157,7 @@ Vector vaveragef(Vector* array, size_t count) {
for(size_t i = 0; i < count; ++i) {
acc = vaddf(acc, array[i]);
}
return vmulff(acc, 1.0/(float)count);
return vmulff(acc, 1.0f/(float)count);
}
static inline