home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
games
/
volume15
/
xtb
/
part02
/
comms.h
next >
Wrap
Text File
|
1993-01-27
|
3KB
|
149 lines
/* comms and common data structures */
/*
* $Header: /morpork/home/bmh/xtest2/RCS/comms.h,v 1.18 92/10/19 15:34:38 bmh Exp Locker: bmh $
*
* Bernard Hatt
* Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
* bmh@terminus.ericsson.se
*
*/
/* types of message */
#define T_SIGNON 1 /* signon request to server */
#define T_ACCEPT 2 /* accept of signon from server */
#define T_REJECT 3 /* rejection of signon from server */
#define T_MOVE 4 /* move made sent to server */
#define T_REPLY 5 /* reply from server (once moves have been made) */
#define T_SIGNOFF 6 /* signoff to server */
#define T_FIELDDATA 7 /* battlefield data (from server) */
#define T_DATAREQ 8 /* request for battlefield data (to server) */
#define T_EXPLOSION 9 /* explosion on battlefield */
#define T_MESSAGE 10 /* message from server */
#define T_ALIVE 11 /* check if client is alive */
/* match byte orders of differing machines */
#define INSWAP(x) ((int)(htonl((long)(x))))
#define OUTSWAP(x) ((int)(ntohl((long)(x))))
typedef struct struct_userinfo
{
int id;
char username[NAMELEN];
char hostname[HOSTLEN]; /* sending hostname */
} USER;
typedef struct struct_position
{
int x; /* x position on battlefield */
int y; /* y */
int rot; /* rotation */
int scx; /* x distance scrolled */
int scy; /* y */
} POSITION;
typedef struct signon_struct
{
int port; /* callback port no. */
int version; /* program version */
char hostname[HOSTLEN]; /* sending hostname */
char username[NAMELEN];
} SIGNON;
typedef struct accept_struct
{
int id; /* your player id. */
USER players[MAXUSERS];
int kills[MAXUSERS]; /* no. of kills made */
int killed[MAXUSERS]; /* no of times killed */
} ACCEPT;
typedef struct reject_struct
{
int reason; /* unused */
char text[BUFLEN]; /* textual reason for rejection */
} REJECT;
typedef struct move_struct
{
int rot; /* rotation */
int linear; /* linear movement */
int fire; /* file button */
} MOVE;
typedef struct reply_struct
{
POSITION pos[MAXUSERS]; /* positions of players */
} REPLY;
typedef struct field_struct
{
int lineno; /* line no of field */
char object[OBJECTSIZE]; /* data */
} FIELD;
typedef struct datareq_struct
{
int lineno; /* requested reason */
} DATAREQ;
typedef struct signoff_struct
{
int reason;
} SIGNOFF;
typedef struct explosion_struct
{
int x; /* x and y of explosion */
int y;
int damage[MAXUSERS]; /* damage sustained by players */
} EXPLOSION;
typedef struct message_struct
{
char text[BUFLEN];
} MESSAGE;
typedef union extra_union
{
SIGNON signon;
ACCEPT accept;
REJECT reject;
MOVE move;
REPLY reply;
FIELD field;
DATAREQ datareq;
EXPLOSION explosion;
MESSAGE message;
SIGNOFF signoff;
} EXTRA;
typedef struct data_struct
{
int type; /* type of message */
int id; /* id of sending machine */
EXTRA extra;
} DATA;
typedef struct player_struct
{
int ssd; /* socket descripter */
int t; /* last time a move was made */
int restime; /* time of last response */
int firetime; /* last time the player fired */
int damage; /* damage a player has sustained */
int kills; /* kills made by a player */
int killed; /* times killed */
USER user; /* data about user */
POSITION pos; /* current position */
MOVE move; /* status */
} PLAYER;
typedef struct score_struct
{
int kills; /* kills made by a player */
int killed; /* times killed */
USER user; /* data about user */
} SCORE;