diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-12-15 10:24:49 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-12-15 10:24:49 +0000 |
| commit | a2566b3ebd93e0bbc55a920a7be08054a9377f11 (patch) | |
| tree | 44a4612805d894168fe4b3b4c065fccc1a1686e9 /src/engine/e_engine.c | |
| parent | ac9873056aa1fe529b098f19ff31e9ffa0e016a2 (diff) | |
| download | zcatch-a2566b3ebd93e0bbc55a920a7be08054a9377f11.tar.gz zcatch-a2566b3ebd93e0bbc55a920a7be08054a9377f11.zip | |
cleaned up code structure a bit
Diffstat (limited to 'src/engine/e_engine.c')
| -rw-r--r-- | src/engine/e_engine.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/engine/e_engine.c b/src/engine/e_engine.c new file mode 100644 index 00000000..341bf936 --- /dev/null +++ b/src/engine/e_engine.c @@ -0,0 +1,66 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#include <string.h> +#include <stdio.h> + +#include <engine/e_system.h> +#include <engine/e_interface.h> +#include <engine/e_config.h> + +static char application_save_path[512] = {0}; + +const char *engine_savepath(const char *filename, char *buffer, int max) +{ + sprintf(buffer, "%s/%s", application_save_path, filename); + return buffer; +} + +void engine_init(const char *appname, int argc, char **argv) +{ + /* init the network */ + net_init(); + + /* create storage location */ + { + char path[1024] = {0}; + fs_storage_path(appname, application_save_path, sizeof(application_save_path)); + if(fs_makedir(application_save_path) == 0) + { + strcpy(path, application_save_path); + strcat(path, "/screenshots"); + fs_makedir(path); + } + } + + /* reset the config */ + config_reset(); + + /* load the configuration */ + { + int i; + const char *config_filename = "default.cfg"; + char buf[1024]; + for(i = 1; i < argc; i++) + { + if(argv[i][0] == '-' && argv[i][1] == 'f' && argv[i][2] == 0 && argc - i > 1) + { + config_filename = argv[i+1]; + i++; + } + } + + config_load(engine_savepath(config_filename, buf, sizeof(buf))); + } + + /* search arguments for overrides */ + { + int i; + for(i = 1; i < argc; i++) + config_set(argv[i]); + } +} + +void engine_writeconfig() +{ + char buf[1024]; + config_save(engine_savepath("default.cfg", buf, sizeof(buf))); +} |