mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
initGameResourceFromDir: Detect non-{ald,ain} files too
Now BGI, WAI and other files can be used without writing a .gr file.
This commit is contained in:
+13
-2
@@ -75,8 +75,19 @@ boolean initGameResourceFromDir(GameResource *gr, DIR *dir, struct dirent *(*p_r
|
||||
sprintf(path, "%s/%s", cwd, filename);
|
||||
if (strcasecmp(filename, "adisk.ald") == 0) {
|
||||
storeDataName(gr, DRIFILE_SCO, 0, path);
|
||||
} else if (strcasecmp(filename, "system39.ain") == 0) {
|
||||
gr->ain = strdup(filename);
|
||||
} else if (strcasecmp(filename, "System39.ain") == 0) {
|
||||
gr->ain = strdup(path);
|
||||
} else if (strcasecmp(filename, "SACTEFAM.KLD") == 0) {
|
||||
gr->sact01 = strdup(path);
|
||||
} else if (strcasecmp(filename, "System39.ini") == 0) {
|
||||
gr->init = strdup(path);
|
||||
} else if (len >= 4 && strcasecmp(filename + len - 4, ".wai") == 0) {
|
||||
gr->wai = strdup(path);
|
||||
} else if (len >= 4 && strcasecmp(filename + len - 4, ".bgi") == 0) {
|
||||
gr->bgi = strdup(path);
|
||||
} else if (len >= 5 && strcasecmp(filename + len - 4, ".alk") == 0) {
|
||||
if (!isdigit(filename[len - 5])) continue;
|
||||
gr->alk[filename[len - 5] - '0'] = strdup(path);
|
||||
} else if (len >= 6 && strcasecmp(filename + len - 4, ".ald") == 0) {
|
||||
int dno = toupper(filename[len - 5]) - 'A';
|
||||
if (dno < 0 || dno >= DRIFILEMAX) continue;
|
||||
|
||||
+18
-2
@@ -82,13 +82,21 @@ static const char *joinPath(const char *dir, const char *fname) {
|
||||
static void initGameResourceFromDir_test(void) {
|
||||
const char *files[] = {
|
||||
"ADISK.ALD",
|
||||
"SYSTEM39.AIN",
|
||||
"FOOSB.ALD",
|
||||
"foogz.ald",
|
||||
"WA.ALD",
|
||||
"unknownXA.ald",
|
||||
"a.ald",
|
||||
".ald",
|
||||
"a",
|
||||
"SYSTEM39.AIN",
|
||||
"foo_WA.WAI",
|
||||
"foo_BA.BGI",
|
||||
"SACTEFAM.KLD",
|
||||
"System39.ini",
|
||||
"foo1.alk",
|
||||
"0.alk",
|
||||
".alk",
|
||||
NULL
|
||||
};
|
||||
const char **dir = files;
|
||||
@@ -109,7 +117,15 @@ static void initGameResourceFromDir_test(void) {
|
||||
assert(strcmp(gr.save_fname[i], joinPath(cwd, buf)) == 0);
|
||||
}
|
||||
assert(strcmp(gr.save_path, cwd) == 0);
|
||||
assert(strcmp(gr.ain, "SYSTEM39.AIN") == 0);
|
||||
assert(strcmp(gr.ain, joinPath(cwd, "SYSTEM39.AIN")) == 0);
|
||||
assert(strcmp(gr.wai, joinPath(cwd, "foo_WA.WAI")) == 0);
|
||||
assert(strcmp(gr.bgi, joinPath(cwd, "foo_BA.BGI")) == 0);
|
||||
assert(strcmp(gr.sact01, joinPath(cwd, "SACTEFAM.KLD")) == 0);
|
||||
assert(strcmp(gr.init, joinPath(cwd, "System39.ini")) == 0);
|
||||
assert(strcmp(gr.alk[0], joinPath(cwd, "0.alk")) == 0);
|
||||
assert(strcmp(gr.alk[1], joinPath(cwd, "foo1.alk")) == 0);
|
||||
for (int i = 2; i < 10; i++)
|
||||
assert(gr.alk[i] == NULL);
|
||||
}
|
||||
|
||||
void gameresource_test(void) {
|
||||
|
||||
Reference in New Issue
Block a user