1 /* 2 * XFrisk - The classic board game for X 3 * Copyright (C) 1993-1999 Elan Feingold (elan@aetherworks.com) 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * 19 * $Id: network.h,v 1.4 1999/11/27 18:19:33 tony Exp $ 20 */ 21 22 #ifndef _NETWORK 23 #define _NETWORK 24 25 #include <sys/types.h> 26 27 #include "types.h" 28 29 /****************/ 30 /* The Messages */ 31 /****************/ 32 33 #define MSG_NOMESSAGE 0xDead 34 35 #define MSG_OLDREGISTERCLIENT 0x01 36 typedef struct _msgOldRegisterClient 37 { 38 CString strClientAddress; 39 } MsgOldRegisterClient; 40 41 #define MSG_REGISTERCLIENT 0x99 42 typedef struct _msgRegisterClient 43 { 44 CString strClientAddress; 45 Int32 iClientType; /* Flags */ 46 } MsgRegisterClient; 47 48 /* Types of clients to connect */ 49 #define CLIENT_NORMAL 0 50 #define CLIENT_AI 1 51 #define CLIENT_STRICTOBSERVER 2 /* TBD, for regression testing */ 52 53 #define MSG_EXCHANGECARDS 0x03 54 typedef struct _msgExchangeCards 55 { 56 Int32 piCards[3]; 57 } MsgExchangeCards; 58 59 #define MSG_REQUESTCARD 0x04 60 typedef struct _msgRequestCard 61 { 62 Int32 iPlayer; 63 } MsgRequestCard; 64 65 #define MSG_CARDPACKET 0x05 66 typedef struct _msgCardPacket 67 { 68 Int32 iPlayer; 69 Int32 cdCard; 70 } MsgCardPacket; 71 72 #define MSG_REPLYPACKET 0x06 73 typedef struct _msgReplyPacket 74 { 75 Int32 iReply; 76 } MsgReplyPacket; 77 78 #define MSG_SENDMESSAGE 0x07 79 typedef struct _msgSendMessage 80 { 81 CString strMessage; 82 CString strDestination; 83 } MsgSendMessage; 84 85 86 #define MSG_MESSAGEPACKET 0x08 87 typedef struct _msgMessagePacket 88 { 89 CString strMessage; 90 Int32 iFrom; 91 Int32 iTo; 92 } MsgMessagePacket; 93 94 #define FROM_SERVER -1 95 #define FROM_UNKNOW -2 96 #define DST_ALLPLAYERS -1 97 #define DST_ALLBUTME -2 98 #define DST_OTHER -3 99 100 #define MSG_EXIT 0x09 101 #define MSG_STARTGAME 0x0A 102 103 #define MSG_TURNNOTIFY 0x0B 104 typedef struct _msgTurnNotify 105 { 106 Int32 iPlayer; 107 Int32 iClient; 108 } MsgTurnNotify; 109 110 #define MSG_ENDTURN 0x0C 111 112 #define MSG_CLIENTIDENT 0x0D 113 typedef struct _msgClientIdent 114 { 115 Int32 iClientID; 116 } MsgClientIdent; 117 118 #define MSG_ENTERSTATE 0x0E 119 typedef struct _msgEnterState 120 { 121 Int32 iState; 122 } MsgEnterState; 123 124 #define MSG_ENDOFGAME 0x10 125 126 #define MSG_OBJSTRUPDATE 0x11 127 typedef struct _msgObjStrUpdate 128 { 129 Int32 iField; 130 Int32 iIndex1, iIndex2; 131 CString strNewValue; 132 } MsgObjStrUpdate; 133 134 #define MSG_OBJINTUPDATE 0x12 135 typedef struct _msgObjIntUpdate 136 { 137 Int32 iField; 138 Int32 iIndex1, iIndex2; 139 Int32 iNewValue; 140 } MsgObjIntUpdate; 141 142 #define MSG_DEREGISTERCLIENT 0x16 143 #define MSG_ALLOCPLAYER 0x19 144 145 #define MSG_FREEPLAYER 0x20 146 typedef struct _msgFreePlayer 147 { 148 Int32 iPlayer; 149 } MsgFreePlayer; 150 151 #define MSG_NETMESSAGE 0x21 152 typedef struct _msgNetMessage 153 { 154 CString strMessage; 155 } MsgNetMessage; 156 157 #define MSG_NETPOPUP 0x22 158 typedef struct _msgNetPopup 159 { 160 CString strMessage; 161 } MsgNetPopup; 162 163 #define MSG_POPUPREGISTERBOX 0x23 164 165 #define MSG_DICEROLL 0x24 166 typedef struct _msgDiceRoll 167 { 168 Int32 iDefendingPlayer; 169 Int32 pAttackDice[3]; 170 Int32 pDefendDice[3]; 171 } MsgDiceRoll; 172 173 #define MSG_PLACENOTIFY 0x25 174 typedef struct _msgPlaceNotify 175 { 176 Int32 iCountry; 177 } MsgPlaceNotify; 178 179 #define MSG_ATTACKNOTIFY 0x26 180 typedef struct _msgAttackNotify 181 { 182 Int32 iSrcCountry; 183 Int32 iDstCountry; 184 } MsgAttackNotify; 185 186 #define MSG_MOVENOTIFY 0x27 187 typedef struct _msgMoveNotify 188 { 189 Int32 iSrcCountry; 190 Int32 iDstCountry; 191 } MsgMoveNotify; 192 193 #define MSG_POLLCLIENTS 0x28 194 typedef struct _msgPollClients 195 { 196 CString strPollQuestion; 197 } MsgPollClients; 198 199 #define MSG_HELLO 0x2a 200 201 #define MSG_VERSION 0x2b 202 typedef struct _msgVersion 203 { 204 CString strVersion; 205 } MsgVersion; 206 207 #define MSG_SPECIESIDENT 0x2c 208 typedef struct _msgSpeciesIdent 209 { 210 Int32 iSpeciesID; 211 } MsgSpeciesIdent; 212 213 #define MSG_MISSION 0x2d 214 215 #define MSG_ENDOFMISSION 0x2e 216 typedef struct _msgEndOfMission 217 { 218 Int32 iWinner; 219 Int32 iTyp; 220 Int32 iNum1; 221 Int32 iNum2; 222 } MsgEndOfMission; 223 224 #define MSG_VICTORY 0x2f 225 typedef struct _msgVictory 226 { 227 Int32 iWinner; 228 } MsgVictory; 229 230 #define MSG_FORCEEXCHANGECARDS 0x30 231 typedef struct _msgForceExchangeCards 232 { 233 Int32 iPlayer; 234 } MsgForceExchangeCards; 235 236 237 Int32 NET_SendMessage(Int32 iSocket, Int32 iMessType, void *pvMessage); 238 Int32 NET_RecvMessage(Int32 iSocket, Int32 *piMessType, void **pvMessage); 239 void NET_DeleteMessage(Int32 iMessType, void *pvMessage); 240 void NET_SetCommLinkOptions(Int32 iSocket); 241 CString NET_MessageToString(Int32 iMessType, void *pvMessage); 242 #endif 243 244 245