X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Frexit.h;h=1c5c59d17fc0109a8e1cb5e7f6eb8968c8cf8369;hb=e75b508724effaad1bfd6dcf337c34a368855095;hp=d4b19d7e70a7af7ce15d067bf14268f614119552;hpb=a974cdd6664ac23668baf50cdafe80b8c8838b1c;p=plomrogue diff --git a/src/rexit.h b/src/rexit.h index d4b19d7..1c5c59d 100644 --- a/src/rexit.h +++ b/src/rexit.h @@ -7,10 +7,7 @@ #ifndef REXIT_H #define REXIT_H - - -struct World; -struct Map; +#include /* for uint8_t */ @@ -20,25 +17,31 @@ struct Map; */ enum cleanup_flag { - CLEANUP_NCURSES = 0x01, - CLEANUP_MAP = 0x02, - CLEANUP_KEYBINDINGS = 0x04, - CLEANUP_LOG = 0x08 + CLEANUP_LOG = 0x0001, + CLEANUP_COMMAND_DB = 0x0002, + CLEANUP_MAP = 0x0004, + CLEANUP_MAP_OBJECTS = 0x0008, + CLEANUP_MAP_OBJECT_DEFS = 0x0010, + CLEANUP_MAP_OBJECT_ACTS = 0x0020, + CLEANUP_INTERFACE = 0x0040, + CLEANUP_NCURSES = 0x0080 }; extern void set_cleanup_flag(enum cleanup_flag flag); -/* Exit orderly, clean up. */ -extern void exit_game(struct World * world); - +/* Exit orderly, clean up in an order respecting resource dependencies. */ +extern void exit_game(); - -/* If fail != 0, exit with an error message "msg" and clean up. (For "fail", - * pass the result of functions that return non-zero as an error status and - * thereby avoid bloating up the code with if-error-conditionals.) +/* If "err" == 0, do nothing. Else, clean up and exit with an error message that + * consists, first, of "msg" or (if "msg" is a NULL pointer) a generic "Details + * unknown", secondly of "err" as the "internal error code", and thirdly of + * errno if it is non-zero. */ -extern void exit_err(unsigned char fail, struct World * world, char * msg); +extern void exit_err(uint8_t err, char * msg); + +/* Do exit_err() with "msg" as: "Trouble in ".parent." with ".child."." */ +extern void exit_trouble(uint8_t err, char * parent, char * child);