ref: 9793deef21fbec91ab405684d478a43b36f8799b
parent: 1b98111171fd71c64c849e1be30ecb8cf9ca76d8
author: Jacob Moody <moody@posixcafe.org>
date: Sat Feb 4 23:21:27 EST 2023
sync better wad/cfg stuff from heretic
--- a/i_system.c
+++ b/i_system.c
@@ -136,20 +136,32 @@
void I_SetupPath(char **wads)
{
char **s;
- char *home;
+ char *tmp;
char *cfg, *data;
char buf[512];
- strcpy(buf, *wads);
- snprint(wd, sizeof wd, "/sys/games/lib/%s/", strip(buf));
-
- for(s = wads; *s; s++)
+ data = cfg = nil;
+ for(s = wads; *s; s++){
+ if(!strstr(*s, ".wad"))
+ continue;
+ if(data == nil)
+ data = *s;
cfg = *s;
+ }
+ strcpy(buf, data);
+ snprint(wd, sizeof wd, "/sys/games/lib/%s/", strip(buf));
+
strcpy(buf, cfg);
- home = getenv("home");
- snprint(bpd, sizeof bpd, "%s/lib/%s/", home, strip(buf));
- free(home);
+ tmp = getenv("home");
+ snprint(bpd, sizeof bpd, "%s/lib/%s/", tmp, strip(buf));
+ free(tmp);
+
+ // would suck if someone only found out after 2 hours
+ // we could default back to cwd, but since this is our
+ // write location, I'd rather not take chances.
+ if(access(bpd, AEXIST) != 0)
+ sysfatal("user directory %s not available %r", bpd);
basePath = bpd;
waddir = wd;