diff options
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 82 |
1 files changed, 5 insertions, 77 deletions
diff --git a/src/config.c b/src/config.c index 9a673ee..6f05e3a 100644 --- a/src/config.c +++ b/src/config.c @@ -9,87 +9,15 @@ Config cfg = {0}; } void -config_init(const char *path) +config_init(void) { - ini_t *ini = NULL; - - ini = ini_load(path); - expect(ini != NULL); - - const char *tileset = ini_get(ini, "tileset", "path"); - if (tileset == NULL) { - pwrn("[tileset] path unspecified, using default"); - tileset = "tileset.png"; - } - cfg.tileset_path = alloc(strlen(tileset) + 1); - expect(cfg.tileset_path != NULL); - strcpy(cfg.tileset_path, tileset); - - const char *world_path = ini_get(ini, "world", "path"); - if (world_path == NULL) { - pwrn("[world] path unspecified, using default"); - world_path = "world.csv"; - } - cfg.world_path = alloc(strlen(world_path) + 1); - expect(cfg.world_path != NULL); - strcpy(cfg.world_path, world_path); - - with (tile_width, ini_get(ini, "tile", "width")) { - cfg.tile_width = atoi(tile_width); - } else { - pwrn("[tile] width unspecified, using default"); - cfg.tile_width = 16; - } - expect(cfg.tile_width > 0); - - with (tile_height, ini_get(ini, "tile", "height")) { - cfg.tile_height = atoi(tile_height); - } else { - pwrn("[tile] height unspecified, using default"); - cfg.tile_height = 16; - } - expect(cfg.tile_height > 0); - - with (cell_width, ini_get(ini, "cell", "width")) { - cfg.cell_width = atoi(cell_width); - } else { - pwrn("[cell] width unspecified, using default"); - cfg.cell_width = 25; - } - expect(cfg.cell_width > 0); - - with (cell_height, ini_get(ini, "cell", "height")) { - cfg.cell_height = atoi(cell_height); - } else { - pwrn("[cell] height unspecified, using default"); - cfg.cell_height = 14; - } - expect(cfg.cell_height > 0); - - with (world_width, ini_get(ini, "world", "width")) { - cfg.world_width = atoi(world_width); - } else { - pwrn("[world] width unspecified, using default"); - cfg.world_width = 16; - } - expect(cfg.world_width > 0); - - with (world_height, ini_get(ini, "world", "height")) { - cfg.world_height = atoi(world_height); - } else { - pwrn("[world] height unspecified, using default"); - cfg.world_height = 16; - } - expect(cfg.world_height > 0); - - ini_free(ini); + cfg.tileset_path = "../tset.bmp"; + cfg.world_path = "world.csv"; + cfg.tile_width = cfg.tile_height = 32; + cfg.cell_width = cfg.cell_height = 20; } void config_deinit(void) { - if (cfg.world_path != NULL) - free(cfg.world_path); - if (cfg.tileset_path != NULL) - free(cfg.tileset_path); } |