ref: 078dd1d6d088aab71c37c0e21fea5cebfe1271a8
parent: 7338feb3744ed2f0a63bababbbdf3d55de143bb6
author: Jacob Moody <[email protected]>
date: Sat Feb 4 20:52:12 EST 2023
another iteration on basepath/waddir stuff
--- a/i_system.c
+++ b/i_system.c
@@ -135,22 +135,33 @@
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;
- print("TEST %s %s\n", basePath, waddir);
}