X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.h;h=244a3992d2e02b725dd6cc0be3d17db758c865ce;hb=7ecf99096c7c23909ada034e05d971464f66552f;hp=12c28c3264c8a0b69fd79f77cb1c8c3735419e6a;hpb=297ee9b33dab3bca9433befc81d7c7ce91450dd0;p=rocksndiamonds.git diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 12c28c32..244a3992 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -37,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 @@ -78,25 +85,37 @@ /* structure definitions */ -struct DirectoryEntry +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; -struct Directory +typedef struct { char *filename; DIR *dir; - struct DirectoryEntry *dir_entry; + DirectoryEntry *dir_entry; #if defined(PLATFORM_ANDROID) boolean directory_is_asset; SDL_RWops *asset_toc_file; char *current_entry; #endif -}; +} Directory; /* function definitions */ @@ -212,11 +231,17 @@ void deleteNodeFromList(ListNode **, char *, void (*function)(void *)); ListNode *getNodeFromKey(ListNode *, char *); int getNumNodes(ListNode *); -struct Directory *openDirectory(char *); -int closeDirectory(struct Directory *); -struct DirectoryEntry *readDirectory(struct Directory *); -void freeDirectoryEntry(struct DirectoryEntry *); +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 *); @@ -243,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 */