merc.h
mercnet/src/merc.h · 4.4 KB
From the archive mercnet.tgz
Download the archive « Back to the archive contents
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
/*
* Short scalar types.
* Diavolo reports AIX compiler has bugs with short types.
*/
typedef short int sh_int;
/*
* Structure types.
*/
typedef struct char_data CHAR_DATA;
typedef struct descriptor_data DESCRIPTOR_DATA;
/*
* String and memory management parameters.
*/
#define MAX_KEY_HASH 1024
#define MAX_STRING_LENGTH 4096
#define MAX_INPUT_LENGTH 160
/*
* Game parameters.
* Increase the max'es if you add more of something.
* Adjust the pulse numbers to suit yourself.
*/
#define PULSE_PER_SECOND 4
/*
* Connected state for a channel.
*/
#define CON_PLAYING 0
#define CON_GET_NAME 1
#define CON_GET_OLD_PASSWORD 2
#define CON_CONFIRM_NEW_NAME 3
#define CON_GET_NEW_PASSWORD 4
#define CON_CONFIRM_NEW_PASSWORD 5
#define CON_GET_NEW_SEX 6
#define CON_GET_NEW_CLASS 7
#define CON_READ_MOTD 8
/*
* Descriptor (channel) structure.
*/
struct descriptor_data
{
DESCRIPTOR_DATA *next;
DESCRIPTOR_DATA *snoop_by;
CHAR_DATA *character;
CHAR_DATA *original;
char *host;
sh_int descriptor;
sh_int connected;
bool fcommand;
char inbuf[4 * MAX_INPUT_LENGTH];
char incomm[MAX_INPUT_LENGTH];
char inlast[MAX_INPUT_LENGTH];
int repeat;
char *showstr_head;
char *showstr_point;
char *outbuf;
int outsize;
int outtop;
int pagelen;
};
/*
* One character (PC or NPC).
*/
struct char_data
{
CHAR_DATA *next;
DESCRIPTOR_DATA *desc;
char *name;
char *short_descr;
char *long_descr;
char *description;
char *pwd;
};
/*
* Utility macros.
*/
#define UMIN(a, b) ((a) < (b) ? (a) : (b))
#define UMAX(a, b) ((a) > (b) ? (a) : (b))
#define URANGE(a, b, c) ((b) < (a) ? (a) : ((b) > (c) ? (c) : (b)))
#define LOWER(c) ((c) >= 'A' && (c) <= 'Z' ? (c)+'a'-'A' : (c))
#define UPPER(c) ((c) >= 'a' && (c) <= 'z' ? (c)+'A'-'a' : (c))
#define IS_SET(flag, bit) ((flag) & (bit))
#define SET_BIT(var, bit) ((var) |= (bit))
#define REMOVE_BIT(var, bit) ((var) &= ~(bit))
/*
* Global variables.
*/
extern CHAR_DATA *char_list;
extern DESCRIPTOR_DATA *descriptor_list;
extern CHAR_DATA *char_free;
extern DESCRIPTOR_DATA *descriptor_free;
extern time_t current_time;
#define args(args) args
/*
* Our function prototypes.
* One big lump ... this is every function in Merc.
*/
#define CD CHAR_DATA
/* comm.c */
void close_socket args((DESCRIPTOR_DATA * dclose));
void write_to_buffer args((DESCRIPTOR_DATA * d, const char *txt, int length));
void send_to_char args((const char *txt, CHAR_DATA * ch));
void show_string args((DESCRIPTOR_DATA * d, char *input));
void extract_char args((CHAR_DATA * ch, bool fPull));
/* db.c */
void boot_db args((void));
void clear_char args((CHAR_DATA * ch));
void free_char args((CHAR_DATA * ch));
void *alloc_mem args((int sMem));
void *alloc_perm args((int sMem));
void free_mem args((void *pMem, int sMem));
char *str_dup args((const char *str));
void free_string args((char *pstr));
void tail_chain args((void));
bool is_number args((char *arg));
char *one_argument args((char *argument, char *arg_first));
#undef CD