-/* file identifier strings */
-#define LEVEL_COOKIE "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_2.0"
-#define SCORE_COOKIE "ROCKSNDIAMONDS_SCORE_FILE_VERSION_1.2"
-#define TAPE_COOKIE "ROCKSNDIAMONDS_TAPE_FILE_VERSION_2.0"
-#define SETUP_COOKIE "ROCKSNDIAMONDS_SETUP_FILE_VERSION_1.2"
-#define LEVELSETUP_COOKIE "ROCKSNDIAMONDS_LEVELSETUP_FILE_VERSION_1.2"
-#define LEVELINFO_COOKIE "ROCKSNDIAMONDS_LEVELINFO_FILE_VERSION_1.2"
-/* old file identifiers for backward compatibility */
-#define LEVEL_COOKIE_10 "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_1.0"
-#define LEVEL_COOKIE_12 "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_1.2"
-#define LEVEL_COOKIE_14 "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_1.4"
-#define TAPE_COOKIE_10 "ROCKSNDIAMONDS_LEVELREC_FILE_VERSION_1.0"
-#define TAPE_COOKIE_12 "ROCKSNDIAMONDS_TAPE_FILE_VERSION_1.2"
-
-/* file names and filename extensions */
-#if !defined(PLATFORM_MSDOS)
-#define LEVELSETUP_DIRECTORY "levelsetup"
-#define SETUP_FILENAME "setup.conf"
-#define LEVELSETUP_FILENAME "levelsetup.conf"
-#define LEVELINFO_FILENAME "levelinfo.conf"
-#define LEVELFILE_EXTENSION "level"
-#define TAPEFILE_EXTENSION "tape"
-#define SCOREFILE_EXTENSION "score"
-#else
-#define LEVELSETUP_DIRECTORY "lvlsetup"
-#define SETUP_FILENAME "setup.cnf"
-#define LEVELSETUP_FILENAME "lvlsetup.cnf"
-#define LEVELINFO_FILENAME "lvlinfo.cnf"
-#define LEVELFILE_EXTENSION "lvl"
-#define TAPEFILE_EXTENSION "tap"
-#define SCOREFILE_EXTENSION "sco"
-#endif
-
-#if defined(PLATFORM_WIN32)
-#ifndef S_IRGRP
-#define S_IRGRP S_IRUSR
-#endif
-#ifndef S_IROTH
-#define S_IROTH S_IRUSR
-#endif
-#ifndef S_IWGRP
-#define S_IWGRP S_IWUSR
-#endif
-#ifndef S_IWOTH
-#define S_IWOTH S_IWUSR
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP S_IXUSR
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH S_IXUSR
-#endif
-#endif /* PLATFORM_WIN32 */
-
-/* file permissions for newly written files */
-#define MODE_R_ALL (S_IRUSR | S_IRGRP | S_IROTH)
-#define MODE_W_ALL (S_IWUSR | S_IWGRP | S_IWOTH)
-#define MODE_X_ALL (S_IXUSR | S_IXGRP | S_IXOTH)
-#define LEVEL_PERMS (MODE_R_ALL | MODE_W_ALL)
-#define SCORE_PERMS LEVEL_PERMS
-#define TAPE_PERMS LEVEL_PERMS
-#define SETUP_PERMS LEVEL_PERMS
-
-/* sort priorities of level series (also used as level series classes) */
-#define LEVELCLASS_TUTORIAL_START 10
-#define LEVELCLASS_TUTORIAL_END 99
-#define LEVELCLASS_CLASSICS_START 100
-#define LEVELCLASS_CLASSICS_END 199
-#define LEVELCLASS_CONTRIBUTION_START 200
-#define LEVELCLASS_CONTRIBUTION_END 299
-#define LEVELCLASS_USER_START 300
-#define LEVELCLASS_USER_END 399
-#define LEVELCLASS_BD_START 400
-#define LEVELCLASS_BD_END 499
-#define LEVELCLASS_EM_START 500
-#define LEVELCLASS_EM_END 599
-#define LEVELCLASS_SP_START 600
-#define LEVELCLASS_SP_END 699
-#define LEVELCLASS_DX_START 700
-#define LEVELCLASS_DX_END 799
-
-#define LEVELCLASS_TUTORIAL LEVELCLASS_TUTORIAL_START
-#define LEVELCLASS_CLASSICS LEVELCLASS_CLASSICS_START
-#define LEVELCLASS_CONTRIBUTION LEVELCLASS_CONTRIBUTION_START
-#define LEVELCLASS_USER LEVELCLASS_USER_START
-#define LEVELCLASS_BD LEVELCLASS_BD_START
-#define LEVELCLASS_EM LEVELCLASS_EM_START
-#define LEVELCLASS_SP LEVELCLASS_SP_START
-#define LEVELCLASS_DX LEVELCLASS_DX_START
-
-#define LEVELCLASS_UNDEFINED 999
-
-#define NUM_LEVELCLASS_DESC 8
-char *levelclass_desc[NUM_LEVELCLASS_DESC] =
-{
- "Tutorial Levels",
- "Classic Originals",
- "Contributions",
- "Private Levels",
- "Boulderdash",
- "Emerald Mine",
- "Supaplex",
- "DX Boulderdash"
-};
-
-#define IS_LEVELCLASS_TUTORIAL(p) \
- ((p)->sort_priority >= LEVELCLASS_TUTORIAL_START && \
- (p)->sort_priority <= LEVELCLASS_TUTORIAL_END)
-#define IS_LEVELCLASS_CLASSICS(p) \
- ((p)->sort_priority >= LEVELCLASS_CLASSICS_START && \
- (p)->sort_priority <= LEVELCLASS_CLASSICS_END)
-#define IS_LEVELCLASS_CONTRIBUTION(p) \
- ((p)->sort_priority >= LEVELCLASS_CONTRIBUTION_START && \
- (p)->sort_priority <= LEVELCLASS_CONTRIBUTION_END)
-#define IS_LEVELCLASS_USER(p) \
- ((p)->sort_priority >= LEVELCLASS_USER_START && \
- (p)->sort_priority <= LEVELCLASS_USER_END)
-#define IS_LEVELCLASS_BD(p) \
- ((p)->sort_priority >= LEVELCLASS_BD_START && \
- (p)->sort_priority <= LEVELCLASS_BD_END)
-#define IS_LEVELCLASS_EM(p) \
- ((p)->sort_priority >= LEVELCLASS_EM_START && \
- (p)->sort_priority <= LEVELCLASS_EM_END)
-#define IS_LEVELCLASS_SP(p) \
- ((p)->sort_priority >= LEVELCLASS_SP_START && \
- (p)->sort_priority <= LEVELCLASS_SP_END)
-#define IS_LEVELCLASS_DX(p) \
- ((p)->sort_priority >= LEVELCLASS_DX_START && \
- (p)->sort_priority <= LEVELCLASS_DX_END)
-
-#define LEVELCLASS(n) (IS_LEVELCLASS_TUTORIAL(n) ? LEVELCLASS_TUTORIAL : \
- IS_LEVELCLASS_CLASSICS(n) ? LEVELCLASS_CLASSICS : \
- IS_LEVELCLASS_CONTRIBUTION(n) ? LEVELCLASS_CONTRIBUTION : \
- IS_LEVELCLASS_USER(n) ? LEVELCLASS_USER : \
- IS_LEVELCLASS_BD(n) ? LEVELCLASS_BD : \
- IS_LEVELCLASS_EM(n) ? LEVELCLASS_EM : \
- IS_LEVELCLASS_SP(n) ? LEVELCLASS_SP : \
- IS_LEVELCLASS_DX(n) ? LEVELCLASS_DX : \
- LEVELCLASS_UNDEFINED)
-
-#define LEVELCOLOR(n) (IS_LEVELCLASS_TUTORIAL(n) ? FC_BLUE : \
- IS_LEVELCLASS_CLASSICS(n) ? FC_RED : \
- IS_LEVELCLASS_BD(n) ? FC_GREEN : \
- IS_LEVELCLASS_EM(n) ? FC_YELLOW : \
- IS_LEVELCLASS_SP(n) ? FC_GREEN : \
- IS_LEVELCLASS_DX(n) ? FC_YELLOW : \
- IS_LEVELCLASS_CONTRIBUTION(n) ? FC_GREEN : \
- IS_LEVELCLASS_USER(n) ? FC_RED : \
- FC_BLUE)
-
-#define LEVELSORTING(n) (IS_LEVELCLASS_TUTORIAL(n) ? 0 : \
- IS_LEVELCLASS_CLASSICS(n) ? 1 : \
- IS_LEVELCLASS_BD(n) ? 2 : \
- IS_LEVELCLASS_EM(n) ? 3 : \
- IS_LEVELCLASS_SP(n) ? 4 : \
- IS_LEVELCLASS_DX(n) ? 5 : \
- IS_LEVELCLASS_CONTRIBUTION(n) ? 6 : \
- IS_LEVELCLASS_USER(n) ? 7 : \
- 9)
-
-static int getFileVersionFromCookieString(const char *cookie)
-{
- const char *ptr_cookie1, *ptr_cookie2;
- const char *pattern1 = "_FILE_VERSION_";
- const char *pattern2 = "?.?";
- const int len_cookie = strlen(cookie);
- const int len_pattern1 = strlen(pattern1);
- const int len_pattern2 = strlen(pattern2);
- const int len_pattern = len_pattern1 + len_pattern2;
- int version_major, version_minor;
-
- if (len_cookie <= len_pattern)
- return -1;
-
- ptr_cookie1 = &cookie[len_cookie - len_pattern];
- ptr_cookie2 = &cookie[len_cookie - len_pattern2];
-
- if (strncmp(ptr_cookie1, pattern1, len_pattern1) != 0)
- return -1;
-
- if (ptr_cookie2[0] < '0' || ptr_cookie2[0] > '9' ||
- ptr_cookie2[1] != '.' ||
- ptr_cookie2[2] < '0' || ptr_cookie2[2] > '9')
- return -1;
-
- version_major = ptr_cookie2[0] - '0';
- version_minor = ptr_cookie2[2] - '0';
-
- return (version_major * 10 + version_minor);
-}
-
-boolean checkCookieString(const char *cookie, const char *template)
-{
- const char *pattern = "_FILE_VERSION_?.?";
- const int len_cookie = strlen(cookie);
- const int len_template = strlen(template);
- const int len_pattern = strlen(pattern);
-
- if (len_cookie != len_template)
- return FALSE;
-
- if (strncmp(cookie, template, len_cookie - len_pattern) != 0)
- return FALSE;
-
- return TRUE;
-}
-
-char *getLevelClassDescription(struct LevelDirInfo *ldi)
-{
- int position = ldi->sort_priority / 100;
-
- if (position >= 0 && position < NUM_LEVELCLASS_DESC)
- return levelclass_desc[position];
- else
- return "Unknown Level Class";
-}