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:
parent
d4d650c2c7
commit
fd0183d34a
|
@ -10,16 +10,16 @@ static asset_id _next_id = 0;
|
||||||
|
|
||||||
static
|
static
|
||||||
size_t file_length(FILE* fp) {
|
size_t file_length(FILE* fp) {
|
||||||
size_t start = ftell(fp);
|
long start = ftell(fp);
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
size_t r = ftell(fp);
|
long r = ftell(fp);
|
||||||
fseek(fp, start, SEEK_SET);
|
fseek(fp, start, SEEK_SET);
|
||||||
return r;
|
return (size_t)r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void read_file(FILE* fp, char* out_buffer, size_t out_size) {
|
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);
|
fread(out_buffer, 1, out_size, fp);
|
||||||
fseek(fp, start, SEEK_SET);
|
fseek(fp, start, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
@ -88,15 +88,13 @@ asset_id get_asset_id(void* asset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_asset(asset_id id) {
|
void free_asset(asset_id id) {
|
||||||
Asset* found;
|
Asset* found = NULL;
|
||||||
size_t found_index;
|
size_t found_index = _assets.len;
|
||||||
for(size_t i = 0; i < _assets.len; ++i) {
|
for(size_t i = 0; i < _assets.len; ++i) {
|
||||||
found = list_at_as(Asset, &_assets, i);
|
found = list_at_as(Asset, &_assets, i);
|
||||||
if(found->tc->get_id(found->data) == id) {
|
if(found->tc->get_id(found->data) == id) {
|
||||||
found_index = i;
|
found_index = i;
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
found = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT_RETURN(found != NULL,, "Attempt to free nonexistent asset.");
|
ASSERT_RETURN(found != NULL,, "Attempt to free nonexistent asset.");
|
||||||
|
|
|
@ -31,8 +31,8 @@ size_t json_array_len(cJSON* array);
|
||||||
static inline
|
static inline
|
||||||
Vector json_array_to_vector(cJSON* array) {
|
Vector json_array_to_vector(cJSON* array) {
|
||||||
return (Vector) {
|
return (Vector) {
|
||||||
cJSON_GetArrayItem(array, 0)->valuedouble,
|
(float)cJSON_GetArrayItem(array, 0)->valuedouble,
|
||||||
cJSON_GetArrayItem(array, 1)->valuedouble,
|
(float)cJSON_GetArrayItem(array, 1)->valuedouble,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
static inline
|
static inline
|
||||||
|
|
|
@ -21,7 +21,7 @@ SDL_FRect camera_world_to_pixel_rect(Camera* self, SDL_FRect* world_space) {
|
||||||
t.scale = OneVector;
|
t.scale = OneVector;
|
||||||
t = transform_invert(t);
|
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};
|
Vector size = {world_space->w, world_space->h};
|
||||||
|
|
||||||
tl = vmulff(transform_point(&t, tl), g_render_resolution.x / self->fov);
|
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.scale = OneVector;
|
||||||
t = transform_invert(t);
|
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);
|
return vmulff(transform_point(&t, point), g_render_resolution.x / self->fov);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ double tstos(struct timespec ts) {
|
||||||
|
|
||||||
struct timespec get_time() {
|
struct timespec get_time() {
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
timespec_get(&ts, TIME_UTC);
|
(void)timespec_get(&ts, TIME_UTC);
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,10 +132,10 @@ void program_handle_windowevent(SDL_WindowEvent* event) {
|
||||||
|
|
||||||
inline
|
inline
|
||||||
float delta_time() {
|
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
|
inline
|
||||||
float game_time() {
|
float game_time() {
|
||||||
return get_time_s() - _game_start_time;
|
return (float)(get_time_s() - _game_start_time);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ float vsqrmagnitudef(Vector a) {
|
||||||
static inline
|
static inline
|
||||||
Vector vnormalizedf(Vector a) {
|
Vector vnormalizedf(Vector a) {
|
||||||
if(veqf(a, ZeroVector)) return ZeroVector;
|
if(veqf(a, ZeroVector)) return ZeroVector;
|
||||||
return vmulff(a, 1.0/vmagnitudef(a));
|
return vmulff(a, 1.0f/vmagnitudef(a));
|
||||||
}
|
}
|
||||||
static inline
|
static inline
|
||||||
float vdotf(Vector a, Vector b) {
|
float vdotf(Vector a, Vector b) {
|
||||||
|
@ -122,7 +122,7 @@ float vsqrdistf(Vector a, Vector b) {
|
||||||
}
|
}
|
||||||
static inline
|
static inline
|
||||||
Vector vreciprocalf(Vector a) {
|
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
|
static inline
|
||||||
Vector vrotatef(Vector a, float t) {
|
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) {
|
for(size_t i = 0; i < count; ++i) {
|
||||||
acc = vaddf(acc, array[i]);
|
acc = vaddf(acc, array[i]);
|
||||||
}
|
}
|
||||||
return vmulff(acc, 1.0/(float)count);
|
return vmulff(acc, 1.0f/(float)count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
|
|
Loading…
Reference in a new issue