From: Holger Schemel Date: Wed, 28 Feb 2024 15:08:06 +0000 (+0100) Subject: added loading both level packages and single levels in BDCFF format X-Git-Tag: 4.4.0.0-test-1~265 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=395ed3b7853b446fa77768786eae09b215731570;p=rocksndiamonds.git added loading both level packages and single levels in BDCFF format --- diff --git a/src/files.c b/src/files.c index b1bbc43e..433f6813 100644 --- a/src/files.c +++ b/src/files.c @@ -2067,6 +2067,27 @@ static void ActivateLevelTemplate(void) } } +static boolean checkForPackageFromBasename_BD(char *basename) +{ + // check for native BD level file extensions + if (!strSuffixLower(basename, ".bd") && + !strSuffixLower(basename, ".bdr") && + !strSuffixLower(basename, ".brc") && + !strSuffixLower(basename, ".gds")) + return FALSE; + + // check for standard single-level BD files (like "001.bd") + if (strSuffixLower(basename, ".bd") && + strlen(basename) == 6 && + basename[0] >= '0' && basename[0] <= '9' && + basename[1] >= '0' && basename[1] <= '9' && + basename[2] >= '0' && basename[2] <= '9') + return FALSE; + + // this is a level package in native BD file format + return TRUE; +} + static char *getLevelFilenameFromBasename(char *basename) { static char *filename = NULL; @@ -2102,10 +2123,7 @@ static int getFileTypeFromBasename(char *basename) return LEVEL_FILE_TYPE_SB; // check for typical filename of a Boulder Dash (GDash) level package file - if (strSuffixLower(basename, ".bd") || - strSuffixLower(basename, ".bdr") || - strSuffixLower(basename, ".brc") || - strSuffixLower(basename, ".gds")) + if (checkForPackageFromBasename_BD(basename)) return LEVEL_FILE_TYPE_BD; // ---------- try to determine file type from filesize ---------- @@ -2367,6 +2385,11 @@ static void determineLevelFileInfo_Filename(struct LevelFileInfo *lfi) if (fileExists(lfi->filename)) return; + // check for native Boulder Dash level file + setLevelFileInfo_FormatLevelFilename(lfi, LEVEL_FILE_TYPE_BD, "%03d.bd", nr); + if (fileExists(lfi->filename)) + return; + // check for Emerald Mine level file (V1) setLevelFileInfo_FormatLevelFilename(lfi, LEVEL_FILE_TYPE_EM, "a%c%c", 'a' + (nr / 10) % 26, '0' + nr % 10);