diff --git a/src/file_io.c b/src/file_io.c index d6efb2a..0f8de36 100644 --- a/src/file_io.c +++ b/src/file_io.c @@ -25,15 +25,15 @@ char* io_file_read(const char* path, const char* mode, long* file_size) int rc = fseek(file, 0, SEEK_END); if(rc == 0) { - long size = (size_t)ftell(file); - if(file_size) *file_size = size; + long length = (size_t)ftell(file); + if(file_size) *file_size = length; rewind(file); - data = malloc(sizeof(char) * size + 1); + data = calloc(1, (sizeof(char) * length) + 1); if(data) { - if(fread(data, size, 1, file) > 0) + if(fread(data, length, 1, file) > 0) { - if(data[size] != '\0') data[size] = '\0'; + if(data[length] != '\0') data[length] = '\0'; } else { diff --git a/src/game.c b/src/game.c index 3c5e13d..5b4ec55 100644 --- a/src/game.c +++ b/src/game.c @@ -36,7 +36,7 @@ #define LEN(a) (sizeof(a)/sizeof(a)[0]) -#define MAX_FRAME_TIME 1.f +#define MAX_FRAME_TIME 0.5f static void run(void); static void update(float dt, int* window_should_close); @@ -131,7 +131,7 @@ void scene_setup(void) struct Transform* tran = entity_component_get(new_ent, C_TRANSFORM); vec3 position = {0, 0, -5}; transform_translate(tran, &position, TS_WORLD); - struct Model* box_model = entity_component_add(new_ent, C_MODEL, "torus.pamesh", "Blinn_Phong"); + struct Model* box_model = entity_component_add(new_ent, C_MODEL, "default.pamesh", "Blinn_Phong"); model_set_material_param(box_model, "diffuse_color", &color); int tex = texture_create_from_file("white.tga", TU_DIFFUSE); model_set_material_param(box_model, "diffuse_texture", &tex); @@ -149,7 +149,7 @@ void scene_setup(void) } int parent_node = new_ent->node; - int num_suz = 100; + int num_suz = 1; srand(time(NULL)); for(int i = 0; i < num_suz; i++) { @@ -159,7 +159,7 @@ void scene_setup(void) x++; y++; z++; struct Entity* suz = scene_add_as_child("Suzanne", NULL, parent_node); //struct Entity* suz = scene_add_new("Suzanne", NULL); - struct Model* suz_model = entity_component_add(suz, C_MODEL, "suzanne.pamesh", "Blinn_Phong"); + struct Model* suz_model = entity_component_add(suz, C_MODEL, "default.pamesh", "Blinn_Phong"); model_set_material_param(suz_model, "diffuse_color", &color); float spec_str = 80.f; model_set_material_param(suz_model, "specular_strength", &spec_str); @@ -216,7 +216,7 @@ void scene_setup(void) /* sun_light->intensity = 0.8f; */ struct Hashmap* cvars = config_vars_get(); - hashmap_int_set(cvars, "My_Int", 20); + hashmap_int_set(cvars, "My_Int", 20); hashmap_str_set(cvars, "My_String", "This is my string"); hashmap_float_set(cvars, "Some_FLOAT", 42.222f); hashmap_double_set(cvars, "Some_Double", 99.999); diff --git a/src/hashmap.c b/src/hashmap.c index 3ec526d..b1f71a5 100644 --- a/src/hashmap.c +++ b/src/hashmap.c @@ -39,6 +39,8 @@ static struct Hashmap_Entry* hashmap_entry_new(struct Hashmap* hashmap, const ch } if(!new_entry) new_entry = array_grow(hashmap->buckets[index], struct Hashmap_Entry); new_entry->key = str_new(key); + new_entry->value.type = VT_NONE; + variant_free(&new_entry->value); return new_entry; }