X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.h;h=244a3992d2e02b725dd6cc0be3d17db758c865ce;hb=7ecf99096c7c23909ada034e05d971464f66552f;hp=b8cdbbdb2d9717764b9613fd2277aefa3d988e3e;hpb=61c3da024802ecc0268bab42d7499fc0346e4fd3;p=rocksndiamonds.git diff --git a/src/libgame/misc.h b/src/libgame/misc.h index b8cdbbdb..244a3992 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -16,6 +16,7 @@ #include #include +#include #include "system.h" @@ -36,19 +37,26 @@ #define GetSimpleRandom(max) get_random_number(RANDOM_SIMPLE, max) /* values for Error() */ -#define ERR_INFO 0 -#define ERR_INFO_LINE (1 << 0) -#define ERR_WARN (1 << 1) -#define ERR_EXIT (1 << 2) -#define ERR_HELP (1 << 3) -#define ERR_SOUND_SERVER (1 << 4) -#define ERR_NETWORK_SERVER (1 << 5) -#define ERR_NETWORK_CLIENT (1 << 6) +#define ERR_UNKNOWN 0 +#define ERR_DEBUG (1 << 0) +#define ERR_INFO (1 << 1) +#define ERR_INFO_LINE (1 << 2) +#define ERR_WARN (1 << 3) +#define ERR_EXIT (1 << 4) +#define ERR_HELP (1 << 5) +#define ERR_SOUND_SERVER (1 << 6) +#define ERR_NETWORK_SERVER (1 << 7) +#define ERR_NETWORK_CLIENT (1 << 8) #define ERR_FROM_SERVER (ERR_SOUND_SERVER | ERR_NETWORK_SERVER) #define ERR_EXIT_HELP (ERR_EXIT | ERR_HELP) #define ERR_EXIT_SOUND_SERVER (ERR_EXIT | ERR_SOUND_SERVER) #define ERR_EXIT_NETWORK_SERVER (ERR_EXIT | ERR_NETWORK_SERVER) #define ERR_EXIT_NETWORK_CLIENT (ERR_EXIT | ERR_NETWORK_CLIENT) +#if 0 +#define ERR_ERROR (ERR_UNKNOWN) +#define ERR_FATAL (ERR_EXIT) +#define ERR_VERBOSE (ERR_INFO) +#endif /* values for getFile...() and putFile...() */ #define BYTE_ORDER_BIG_ENDIAN 0 @@ -69,6 +77,48 @@ /* values for general username handling stuff */ #define MAX_USERNAME_LEN 1024 +#if defined(PLATFORM_ANDROID) +/* values for Android asset handling */ +#define ASSET_TOC_BASENAME ".toc" +#endif + + +/* structure definitions */ + +typedef struct +{ + char *filename; + FILE *file; + boolean end_of_file; + +#if defined(PLATFORM_ANDROID) + boolean file_is_asset; + SDL_RWops *asset_file; +#endif +} File; + +typedef struct +{ + boolean is_directory; + char *basename; + char *filename; +} DirectoryEntry; + +typedef struct +{ + char *filename; + DIR *dir; + DirectoryEntry *dir_entry; + +#if defined(PLATFORM_ANDROID) + boolean directory_is_asset; + SDL_RWops *asset_toc_file; + char *current_entry; +#endif +} Directory; + + +/* function definitions */ void fprintf_line(FILE *, char *, int); void printf_line(char *, int); @@ -181,6 +231,17 @@ void deleteNodeFromList(ListNode **, char *, void (*function)(void *)); ListNode *getNodeFromKey(ListNode *, char *); int getNumNodes(ListNode *); +File *openFile(char *, char *); +int closeFile(File *); +int checkEndOfFile(File *); +char *getStringFromFile(File *, char *, int); + +Directory *openDirectory(char *); +int closeDirectory(Directory *); +DirectoryEntry *readDirectory(Directory *); +void freeDirectoryEntry(DirectoryEntry *); + +boolean directoryExists(char *); boolean fileExists(char *); boolean FileIsGraphic(char *); boolean FileIsSound(char *); @@ -207,6 +268,13 @@ void closeErrorFile(); void dumpErrorFile(); void NotifyUserAboutErrorFile(); +#if DEBUG void debug_print_timestamp(int, char *); +void print_timestamp_init(char *); +void print_timestamp_time(char *); +void print_timestamp_done(char *); +#endif /* DEBUG */ + + #endif /* MISC_H */