1 /* 2 * file client.h - communication interface for clients 3 * 4 * $Id: client.h,v 1.29 2006/02/10 15:07:42 fzago Exp $ 5 * 6 * Program XBLAST 7 * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net) 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published 11 * by the Free Software Foundation; either version 2; or (at your option) 12 * any later version 13 * 14 * This program is distributed in the hope that it will be entertaining, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 * Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License along 20 * with this program; if not, write to the Free Software Foundation, Inc. 21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 */ 23 #ifndef XBLAST_CLIENT_H 24 #define XBLAST_CLIENT_H 25 26 /* 27 * global types 28 */ 29 typedef struct _xb_network_game 30 { 31 unsigned id; /* interface id */ 32 char *host; /* address of server */ 33 unsigned short port; /* port for game */ 34 int ping; /* ping time */ 35 char *version; /* version string */ 36 char *game; /* name of the game */ 37 int numLives; /* number of lives */ 38 int numWins; /* number of levels to win */ 39 int frameRate; /* frame per second */ 40 } XBNetworkGame; 41 42 typedef enum 43 { 44 XBCC_Loss, /* data loss on dgram */ 45 XBCC_IOError, /* i/o error on stream */ 46 XBCC_WriteError, /* write error on dgram */ 47 XBCC_ConnFailed, /* connection failed on dgram */ 48 XBCC_COTInvalid, /* invalid cot received */ 49 XBCC_IDInvalid, /* invalid id received */ 50 XBCC_DataInvalid, /* invalid data received */ 51 XBCC_ExpectedEOF, /* expected close on stream */ 52 XBCC_UnexpectedEOF, /* unexpected server disconnect */ 53 XBCC_StreamWaiting, /* complete send of queued data */ 54 XBCC_StreamBusy, /* partial send of queued data */ 55 XBCC_StreamClosed, /* stream closed */ 56 XBCC_DgramClosed, /* dgram closed */ 57 } XBClientConstants; 58 /* 59 * global prototypes 60 */ 61 62 /* connecting/disconnecting */ 63 extern XBBool Client_Connect (CFGGameHost *); 64 extern void Client_Disconnect (void); 65 extern void Client_SetDisconnected (XBBool); 66 67 /* error handling */ 68 extern XBBool Client_StreamEvent (XBClientConstants); 69 extern XBBool Client_DgramEvent (XBClientConstants); 70 71 /* receiving data */ 72 extern XBBool Client_ReceiveGameConfig (unsigned, const char *data); 73 extern void Client_ReceivePlayerConfig (unsigned, unsigned, const char *data); 74 extern void Client_ReceiveDgramPort (unsigned id, unsigned short); 75 extern void Client_ReceivePingTime (unsigned clientID, int ping); 76 extern void Client_ReceiveGameConfigReq (unsigned); 77 extern void Client_ReceivePlayerConfigReq (unsigned); 78 extern void Client_ReceiveHostState (unsigned id, unsigned state); 79 extern void Client_ReceiveTeamState (unsigned host, unsigned player, unsigned team); 80 extern void Client_ReceiveHostStateReq (unsigned who, unsigned id, unsigned state); 81 extern void Client_ReceiveTeamStateReq (unsigned who, unsigned host, unsigned player, 82 unsigned team); 83 extern void Client_ReceiveChat (XBChat *); 84 extern void Client_ReceiveStart (unsigned); 85 extern void Client_ReceiveSync (XBNetworkEvent); 86 extern void Client_ReceiveLevelConfig (unsigned, const char *data); 87 extern void Client_ReceiveRandomSeed (unsigned); 88 extern void Client_ReceivePlayerAction (int, const PlayerAction *); 89 extern void Client_ReceiveFinish (void); 90 extern void Client_ReceiveAsync (XBBool as); 91 extern XBBool Client_ReceiveDisconnect (unsigned); 92 93 /* retrieving local data */ 94 extern unsigned Client_GetHostState (unsigned id); 95 extern int Client_GetPingTime (unsigned clientID); 96 extern unsigned Client_GetHostState (unsigned id); 97 extern unsigned *Client_GetHostStateReq (unsigned id); 98 extern unsigned Client_GetTeamState (unsigned id, unsigned pl); 99 extern unsigned *Client_GetTeamStateReq (unsigned id, unsigned pl); 100 extern XBBool Client_RejectsLevel (void); 101 extern XBBool Client_FixedLevel (void); 102 extern void Client_GetPlayerAction (int, PlayerAction *); 103 extern XBBool Client_LevelAsynced (void); 104 105 /* setting local data */ 106 extern void Client_LevelRejection (XBBool); 107 extern void Client_LevelFix (XBBool); 108 extern void Client_ClearPlayerAction (void); 109 extern void Client_ResetPlayerAction (void); 110 extern void Client_ActivateLevel (unsigned); 111 extern void Client_SetLevelAsync (XBBool); 112 113 /* queueing data */ 114 extern void Client_SendDgramPort (XBBool nat); 115 extern void Client_SendGameConfig (void); 116 extern void Client_SendPlayerConfigs (void); 117 extern void Client_SendHostState (unsigned state); 118 extern void Client_SendHostStateReq (unsigned id, unsigned state); 119 extern void Client_SendTeamStateReq (unsigned id, unsigned player, unsigned team); 120 extern void Client_SendChat (XBChat * chat); 121 extern void Client_SendSync (XBNetworkEvent); 122 extern void Client_SendLevelCheck (void); 123 extern void Client_SendPlayerAction (int, const PlayerAction *); 124 extern void Client_FinishPlayerAction (int gameTime); 125 extern XBBool Client_FlushPlayerAction (void); 126 extern void Client_SendWinner (unsigned team); 127 128 /* central queries */ 129 extern void Client_StartQuery (void); 130 extern void Client_StartCentralQuery (void); // XBCC 131 extern void Client_RestartQuery (void); 132 extern void Client_StopQuery (void); 133 extern void Client_ReceiveQueryClose (unsigned); 134 extern void Client_ReceiveReply (unsigned id, const char *host, unsigned short port, int ping, 135 const char *version, const char *game, int numLives, int numWins, 136 int frameRate); 137 extern const XBNetworkGame *Client_NextNetworkGame (void); 138 139 #endif 140 /* 141 * end of file client.h 142 */ 143