(empfile, teldir, motdfil, downfil, disablefil, telfil, annfil)
(banfil, authfil, timestampfil): Make file names relative to DATADIR. (main): emp_server and files change to the data directory. fairland has to write newcap_script to the initial current directory, so it keeps it and makes file names relative to DATADIR absolute. (fixup_files): Nothing to do, remove. This fixes the following bug: fixup_files() formed file names by appending ep->name instead of the base name of ep->file to datadir. Thus, fixup_files() changed file names even when datadir had the compiled-in value. When emp_config() couldn't open econfig, it failed to call fixup_files(), and different file names got used. Note that with this revision the file names revert to the names used before fixup_files() was introduced. Closes #1146080. (print_config): Printing file names as comments is not really useful, remove. (otherfiles, ofiles): Unused, remove. (emp_config, main): Previously, pconfig had to call emp_config() even when it didn't want to read econfig, just to run fixup_files(). This is no longer necessary. Simplify.
This commit is contained in:
parent
1583d0c6a2
commit
29da4b6cf4
8 changed files with 49 additions and 92 deletions
|
@ -88,14 +88,8 @@ emp_config(char *file)
|
|||
int errors = 0;
|
||||
int i;
|
||||
|
||||
if (!file) {
|
||||
if (!*dflt_econfig) {
|
||||
/* No default econfig, use compiled in configuration */
|
||||
fixup_files();
|
||||
return 0;
|
||||
}
|
||||
if (!file)
|
||||
file = dflt_econfig;
|
||||
}
|
||||
if ((fp = fopen(file, "r")) == NULL) {
|
||||
fprintf(stderr, "Can't open %s for reading (%s)\n",
|
||||
file, strerror(errno));
|
||||
|
@ -163,51 +157,11 @@ emp_config(char *file)
|
|||
}
|
||||
}
|
||||
fclose(fp);
|
||||
fixup_files();
|
||||
WORLD_X &= ~1; /* make even */
|
||||
|
||||
return -errors;
|
||||
}
|
||||
|
||||
struct otherfiles {
|
||||
char **files;
|
||||
char *name;
|
||||
};
|
||||
|
||||
/* list of other well known files... -maybe tailor these oneday
|
||||
* anyway - meantime they are all relative to datadir */
|
||||
static struct otherfiles ofiles[] = {
|
||||
{&motdfil, "motd"},
|
||||
{&downfil, "down"},
|
||||
{&disablefil, "disable"},
|
||||
{&banfil, "ban"},
|
||||
{&authfil, "auth"},
|
||||
{&annfil, "ann"},
|
||||
{×tampfil, "timestamp"},
|
||||
{&teldir, "tel"},
|
||||
{&telfil, "tel/tel"},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/* fix up the empfile struct to reference full path names */
|
||||
static void
|
||||
fixup_files(void)
|
||||
{
|
||||
struct empfile *ep;
|
||||
struct otherfiles *op;
|
||||
s_char buf[1024];
|
||||
|
||||
for (ep = empfile; ep < &empfile[EF_MAX]; ep++) {
|
||||
sprintf(buf, "%s/%s", datadir, ep->name);
|
||||
ep->file = strdup(buf);
|
||||
}
|
||||
|
||||
for (op = ofiles; op->files; op++) {
|
||||
sprintf(buf, "%s/%s", datadir, op->name);
|
||||
*op->files = strdup(buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* find the key in the table */
|
||||
static struct keymatch *
|
||||
keylookup(register s_char *command, struct keymatch *tbl)
|
||||
|
@ -226,9 +180,7 @@ keylookup(register s_char *command, struct keymatch *tbl)
|
|||
void
|
||||
print_config(FILE *fp)
|
||||
{
|
||||
struct empfile *ep;
|
||||
struct option_list *op;
|
||||
struct otherfiles *ofp;
|
||||
struct keymatch *kp;
|
||||
|
||||
fprintf(fp, "# Empire Configuration File:\n");
|
||||
|
@ -267,11 +219,6 @@ print_config(FILE *fp)
|
|||
}
|
||||
|
||||
fprintf(fp, "\n");
|
||||
for (ep = empfile; ep < &empfile[EF_MAX]; ep++)
|
||||
fprintf(fp, "# File %s -> %s\n", ep->name, ep->file);
|
||||
for (ofp = ofiles; ofp->files; ofp++)
|
||||
fprintf(fp, "# File %s -> %s\n", ofp->name, *(ofp->files));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue