Skip to content

Commit

Permalink
remove config macro
Browse files Browse the repository at this point in the history
  • Loading branch information
julesgrc0 committed Feb 26, 2024
1 parent 86a1502 commit 9cc8627
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
27 changes: 20 additions & 7 deletions src/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,26 @@ w_config *load_config() {
return NULL;
}

load_config_uint(root, cfg, fullscreen);
load_config_uint(root, cfg, msaa4x);
load_config_uint(root, cfg, vsync);
load_config_uint(root, cfg, width);
load_config_uint(root, cfg, height);
load_config_uint(root, cfg, max_fps);

json_object *js_fullscreen = json_object_object_get(root, "fullscreen");
json_object *js_msaa4x = json_object_object_get(root, "msaa4x");
json_object *js_vsync = json_object_object_get(root, "vsync");
json_object *js_width = json_object_object_get(root, "width");
json_object *js_height = json_object_object_get(root, "height");
json_object *js_max_fps = json_object_object_get(root, "max_fps");

cfg->fullscreen = (unsigned int)json_object_get_uint64(js_fullscreen);
cfg->msaa4x = (unsigned int)json_object_get_uint64(js_msaa4x);
cfg->vsync = (unsigned int)json_object_get_uint64(js_vsync);
cfg->width = (unsigned int)json_object_get_uint64(js_width);
cfg->height = (unsigned int)json_object_get_uint64(js_height);
cfg->max_fps = (unsigned int)json_object_get_uint64(js_max_fps);

json_object_put(js_fullscreen);
json_object_put(js_msaa4x);
json_object_put(js_vsync);
json_object_put(js_width);
json_object_put(js_height);
json_object_put(js_max_fps);
json_object_put(root);
free(data);
} else {
Expand Down
5 changes: 0 additions & 5 deletions src/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

#define CONFIG_NAME "config.json"

#define load_config_uint(jsobj, config, name) \
json_object *js_##name = json_object_object_get(jsobj, #name); \
config->##name = (unsigned int)json_object_get_uint64(js_##name); \
json_object_put(js_##name);

typedef struct w_config {
unsigned int fullscreen : 1;
unsigned int msaa4x : 1;
Expand Down

0 comments on commit 9cc8627

Please sign in to comment.