/*
* Main.h - Has basic info and structs nearly all files will need
*
* By: Odis
*/
#ifndef INC_MAIN_H
#define INC_MAIN_H
#include <windows.h>
#if !defined(TRUE)
#define TRUE 1
#endif
#if !defined(FALSE)
#define FALSE 0
#endif
#define MIL 1024
#define MSL 5120
#define T_ID 400 /* timer ID */
#define MAIN_WINDOW_CLASS "campaign-dev"
//#define LOG 1 /* yes we want to log */
//#define LOG_DICE 1 /* log dice rolling? */
//#define LOG_XLOG 1 /* create xlog? */
//#define LOG_CAMPAIGN 1 /* log campaign functions? */
//#define LOG_MDI 1 /* log MDI stuff */
typedef unsigned char bool; /* gotta have'em! */
typedef struct cp CAMP;
/************************/
/* globals */
extern HWND hWindow; /* main/frame window */
extern HINSTANCE hInstance;
extern HWND hClient; /* client window :P */
extern LONG PRG_WIDTH;
extern LONG PRG_HEIGHT;
extern CAMP * cc; /* current campaign */
/* end globals */
/************************/
#define CHECK_STR(str) ((str) == NULL || (str[0]) == '\0')
/* those ever important macro's */
/* thanks to SMAUG for the macro's */
#define CREATE(result, type, number) \
do \
{ \
if (!((result) = (type *) calloc ((number), sizeof(type)))) \
{ \
perror("malloc failure"); \
abort(); \
} \
} while(0)
#define DISPOSE(point) \
do \
{ \
if((point)) \
{ \
free((point)); \
(point) = NULL; \
} \
} while(0)
/* doublely-linked list handling */
#define LINK(link, first, last, next, prev) \
do \
{ \
if ( !(first) ) \
{ \
(first) = (link); \
(last) = (link); \
} \
else \
(last)->next = (link); \
(link)->next = NULL; \
if (first == link) \
(link)->prev = NULL; \
else \
(link)->prev = (last); \
(last) = (link); \
} while(0)
#define INSERT(link, insert, first, next, prev) \
do \
{ \
(link)->prev = (insert)->prev; \
if ( !(insert)->prev ) \
(first) = (link); \
else \
(insert)->prev->next = (link); \
(insert)->prev = (link); \
(link)->next = (insert); \
} while(0)
#define UNLINK(link, first, last, next, prev) \
do \
{ \
if ( !(link)->prev ) \
{ \
(first) = (link)->next; \
if ((first)) \
(first)->prev = NULL; \
} \
else \
{ \
(link)->prev->next = (link)->next; \
} \
if ( !(link)->next ) \
{ \
(last) = (link)->prev; \
if ((last)) \
(last)->next = NULL; \
} \
else \
{ \
(link)->next->prev = (link)->prev; \
} \
} while(0)
/* give every file access to random functions */
/* function prototypes */
int random_range ( int a, int b );
int random_percent ( void );
int roll_dice ( int amount, int size );
void init_dice ( void );
#ifndef LOG
int exists_file( char *filen );
#endif
/* campaign struct */
struct cp
{
char *filename;
char *author;
char *name;
char *world_name;
int level_range[2]; /* 0 = low, 1 = high */
bool modified; /* TRUE if it has been modified without being saved */
};
#endif /* INC_MAIN_H */