00001
00002 #ifndef PLAY_H
00003 #define PLAY_H
00004
00005 #include "dx.h"
00006 #include "main.h"
00007
00008
00009
00010 #define MAX_HOST_NAME 1024
00011
00012 #define CONNECTION_MAX 16
00013 #define SESSION_MAX 8
00014 #define MAX_SESSION_NAME 34
00015 #define MAX_CONNECTION_NAME 128
00016 #define MAX_LEVEL_DIR_NAME 16
00017
00018 #define MESSAGE_CONTENTS_CAR_TIME 1
00019 #define MESSAGE_CONTENTS_CAR_POS 2
00020 #define MESSAGE_CONTENTS_CAR_QUAT 4
00021 #define MESSAGE_CONTENTS_CAR_VEL 8
00022 #define MESSAGE_CONTENTS_CAR_ANGVEL 16
00023 #define MESSAGE_CONTENTS_CAR_CONTROL 32
00024
00025 #define MESSAGE_PRIORITY_NORMAL 0
00026 #define MESSAGE_PRIORITY_CAR 1
00027
00028 enum {
00029 MESSAGE_GAME_STARTED,
00030 MESSAGE_CAR_DATA,
00031 MESSAGE_PING_REQUEST,
00032 MESSAGE_PING_RETURN,
00033 MESSAGE_PLAYER_READY,
00034 MESSAGE_SYNC_TIMERS1,
00035 MESSAGE_SYNC_TIMERS2,
00036 MESSAGE_SYNC_TIMERS3,
00037 };
00038
00039 typedef struct {
00040 void *Ptr;
00041 char Name[MAX_CONNECTION_NAME];
00042 } DP_CONNECTION;
00043
00044 typedef struct {
00045 GUID Guid;
00046 DWORD Flags;
00047 char Name[MAX_SESSION_NAME];
00048 } DP_SESSION;
00049
00050 typedef struct {
00051 long CarID;
00052 } DP_PLAYER_DATA;
00053
00054 typedef struct {
00055 DPID PlayerID;
00056 DPCAPS Caps;
00057 long Ping;
00058 char Name[MAX_PLAYER_NAME];
00059 DP_PLAYER_DATA Data;
00060 } DP_PLAYER;
00061
00062 typedef struct {
00063 unsigned short Type, Contents;
00064 } MESSAGE_HEADER;
00065
00066 typedef struct {
00067 long GridNum, CarID;
00068 DPID PlayerID;
00069 char Name[MAX_PLAYER_NAME];
00070 } PLAYER_START_DATA;
00071
00072 typedef struct {
00073 long PlayerNum;
00074 char LevelDir[MAX_LEVEL_DIR_NAME];
00075 PLAYER_START_DATA PlayerData[MAX_NUM_PLAYERS];
00076 } START_DATA;
00077
00078 typedef struct {
00079 unsigned char Mask[4], IP[4];
00080 } LEGAL_IP;
00081
00082
00083
00084 extern void LobbyRegister(void);
00085 extern bool InitPlay(void);
00086 extern void KillPlay(void);
00087 extern bool InitConnection(char num);
00088 extern bool CreateSession(char *name);
00089 extern void ListSessions(void);
00090 extern void StopSessionEnum(void);
00091 extern bool JoinSession(char num);
00092 extern bool CreatePlayer(char *name, long server);
00093 extern void ListPlayers(GUID *guid);
00094 extern void DisplayPlayers(void);
00095 extern void TransmitMessage(char *buff, short size, DPID to, long pri);
00096 extern void TransmitMessageGuaranteed(char *buff, short size, DPID to, long pri);
00097 extern void CancelPriority(long pri);
00098 extern char GetRemoteMessages(void);
00099 extern void ProcessCarMessage(void);
00100 extern void ProcessPersonalMessage(void);
00101 extern void ProcessSystemMessage(void);
00102 extern void RequestPings(void);
00103 extern void ProcessPingRequest(void);
00104 extern void ProcessPingReturn(void);
00105 extern void ProcessPlayerReady(void);
00106 extern void ProcessSyncTimers1(void);
00107 extern void ProcessSyncTimers2(void);
00108 extern void ProcessSyncTimers3(void);
00109 extern BOOL FAR PASCAL EnumConnectionsCallback(LPCGUID lpguidSP, LPVOID lpConnection, DWORD dwConnectionSize, LPCDPNAME lpName, DWORD dwFlags, LPVOID lpContext);
00110 extern BOOL FAR PASCAL EnumSessionsCallback(LPCDPSESSIONDESC2 lpSessionDesc, LPDWORD lpdwTimeOut, DWORD dwFlags, LPVOID lpContext);
00111 extern BOOL FAR PASCAL EnumPlayersCallback(DPID dpId, DWORD dwPlayerType, LPCDPNAME lpName, DWORD dwFlags, LPVOID lpContext);
00112 extern void ConnectionMenu(void);
00113 extern void GetSessionName(void);
00114 extern void LookForSessions(void);
00115 extern void HostWait(void);
00116 extern void ClientWait(void);
00117 extern char GetHostDetails(void);
00118 extern char CheckLegalIP(void);
00119 extern void RemoteSync(void);
00120
00121
00122
00123 extern IDirectPlayLobby3 *Lobby;
00124 extern IDirectPlay4A *DP;
00125 extern DPID FromID, ToID, LocalPlayerID, ServerID;
00126 extern DP_PLAYER PlayerList[];
00127 extern long PlayerCount;
00128 extern char ReceiveBuff[], TransmitBuff[];
00129 extern START_DATA StartData;
00130
00131 #endif