#include "nsc.h"
+/* Default econfig file */
+extern char dflt_econfig[];
+
struct option_list {
char *opt_key;
int *opt_valuep;
int errors = 0;
int i;
- if (file == NULL) {
- fixup_files();
- return 0;
+ if (!file) {
+ if (!*dflt_econfig) {
+ /* No default econfig, use compiled in configuration */
+ fixup_files();
+ return 0;
+ }
+ file = dflt_econfig;
}
if ((fp = fopen(file, "r")) == NULL) {
fprintf(stderr, "Can't open %s for reading (%s)\n",
*/
#include "gamesdef.h"
-#include "misc.h"
+
+char dflt_econfig[] = EMPDIR "/data/econfig";
char *infodir = EMPDIR "/info.nr";
char *datadir = EMPDIR "/data";
* Doug Hay, 1998
*/
-#if defined(aix) || defined(linux)
-#include <unistd.h>
-#endif /* aix or linux */
-
#include <signal.h>
#if !defined(_WIN32)
#include <sys/ioctl.h>
return remove_service(service_name);
#endif /* _WIN32 */
- if (config_file == NULL) {
- sprintf(tbuf, "%s/econfig", datadir);
- config_file = tbuf;
- }
- emp_config(config_file);
+ if (emp_config(config_file) < 0)
+ exit(EXIT_FAILURE);
#if defined(_WIN32)
if (install_service_set)
{
int opt;
char *config_file = NULL;
- char tbuf[512];
int i = 0;
rnd_seed = time(NULL);
}
}
srandom(rnd_seed);
- if (config_file == NULL) {
- sprintf(tbuf, "%s/econfig", datadir);
- config_file = tbuf;
- }
- emp_config(config_file);
+ if (emp_config(config_file))
+ exit(1);
parse_args(argc - optind, argv + optind);
if (allocate_memory() == -1)
main(int argc, char *argv[])
{
s_char buf[255];
- s_char tbuf[512];
s_char *filename;
int x, y;
struct natstr nat;
}
}
- /* Try to use the existing data directory */
- if (config_file == NULL) {
- sprintf(tbuf, "%s/econfig", datadir);
- config_file = tbuf;
- }
- emp_config(config_file);
+ if (emp_config(config_file) < 0)
+ exit(1);
+
empfile[EF_MAP].size = (WORLD_X * WORLD_Y) / 2;
empfile[EF_BMAP].size = (WORLD_X * WORLD_Y) / 2;
* Julian Onions
*/
-#include <gamesdef.h>
#include <stdio.h>
+#include "optlist.h"
#include "prototypes.h"
int
main(int argc, char **argv)
{
- if (argc > 1)
- emp_config(argv[1]);
- else
- emp_config(NULL);
-
+ *dflt_econfig = 0; /* don't read default econfig */
+ if (emp_config(argc > 1 ? argv[1] : NULL) < 0)
+ exit(1);
print_config(stdout);
exit(0);
}