1 /************************************************************ 2 * Network message structures sent between server & client * 3 ************************************************************/ 4 5 /* NETMSG_PROTOCOL_VERSION, checked to make sure that the client and server 6 use the same protocol. CHANGE THIS IF THE NET STRUCT'S CHANGE AT ALL */ 7 8 #define NETMSG_PROTOCOL_VERSION 3 9 10 /* 11 Ver Date (D/M/Y) Comment/Changes. 12 --- ------------ ---------------- 13 1 04/02/2001 Initial version with protocol number. 14 2 04/05/2001 Killme, query_frags/frags messages added. 15 3 30/01/2002 Away 16 */ 17 18 #define NETMSG_STRLEN 32 19 #define TEXTMESSAGE_STRLEN 128 20 21 enum { 22 NETMSG_NONE, /* SERVER <---> CLIENT */ 23 NETMSG_NOOP, /* SERVER <---> CLIENT */ 24 NETMSG_QUERY_VERSION, /* SERVER <---> CLIENT */ 25 NETMSG_VERSION, /* SERVER <---> CLIENT */ 26 NETMSG_TEXTMESSAGE, /* SERVER <---> CLIENT */ 27 NETMSG_QUIT, /* SERVER <---> CLIENT */ 28 NETMSG_REJECTION, /* SERVER ---> CLIENT */ 29 NETMSG_SV_INFO, /* SERVER ---> CLIENT */ 30 NETMSG_CHANGELEVEL, /* SERVER ---> CLIENT */ 31 NETMSG_START_FRAME, /* SERVER ---> CLIENT */ 32 NETMSG_END_FRAME, /* SERVER ---> CLIENT */ 33 NETMSG_ENTITY, /* SERVER ---> CLIENT */ 34 NETMSG_MYENTITY, /* SERVER ---> CLIENT */ 35 NETMSG_PARTICLES, /* SERVER ---> CLIENT */ 36 NETMSG_UPDATE_STATUSBAR, /* SERVER ---> CLIENT */ 37 NETMSG_JOIN, /* CLIENT ---> SERVER */ 38 NETMSG_READY, /* CLIENT ---> SERVER */ 39 NETMSG_QUERY_SV_INFO, /* CLIENT ---> SERVER */ 40 NETMSG_CL_UPDATE, /* CLIENT ---> SERVER */ 41 NETMSG_GAMEMESSAGE, /* SERVER ---> CLIENT */ 42 NETMSG_MAP_TARGET, /* SERVER ---> CLIENT */ 43 NETMSG_OBJECTIVE, /* SERVER ---> CLIENT */ 44 NETMSG_KILLME, /* CLIENT ---> SERVER */ 45 NETMSG_QUERY_FRAGS, /* CLIENT ---> SERVER */ 46 NETMSG_FRAGS, /* SERVER ---> CLIENT */ 47 NETMSG_AWAY, /* CLIENT ---> SERVER */ 48 49 /* Keep this last */ 50 NUM_NETMESSAGES 51 }; 52 53 /******** Message Structures ********/ 54 typedef struct { 55 byte type; 56 } netmsg_none; 57 58 typedef struct { 59 byte type; 60 } netmsg_noop; 61 62 typedef struct { 63 byte type; 64 } netmsg_query_version; 65 66 typedef struct { 67 byte type; 68 byte ver[3]; /* ie '1'.'0'.'0'*/ 69 } netmsg_version; 70 71 typedef struct { 72 byte type; 73 char sender[NETMSG_STRLEN]; 74 char string[TEXTMESSAGE_STRLEN]; 75 } netmsg_textmessage; 76 77 typedef struct { 78 byte type; 79 } netmsg_quit; 80 81 /* SERVER --> CLIENT */ 82 typedef struct { 83 byte type; 84 char reason[NETMSG_STRLEN]; 85 } netmsg_rejection; 86 87 typedef struct { 88 byte type; 89 byte players; 90 byte game_type; 91 byte fps; 92 char sv_name[NETMSG_STRLEN]; 93 char map_name[NETMSG_STRLEN]; 94 } netmsg_sv_info; 95 96 typedef struct { 97 byte type; 98 char map_name[NETMSG_STRLEN]; 99 } netmsg_changelevel; 100 101 typedef struct { 102 byte type; 103 shortpoint_t screenpos; 104 } netmsg_start_frame; 105 106 typedef struct { 107 byte type; 108 } netmsg_end_frame; 109 110 typedef struct { 111 byte type; 112 byte entity_type; 113 byte dir; 114 byte mode; 115 netushort x; 116 netushort y; 117 byte img; 118 byte weapon; 119 } netmsg_entity; 120 121 /* myentity is the same as entity, but with a different type */ 122 123 typedef struct { 124 byte type; 125 byte effect; 126 byte dir; 127 byte color1; 128 byte color2; 129 netushort x; 130 netushort y; 131 netushort length; 132 } netmsg_particles; 133 134 typedef struct { 135 byte type; 136 byte health; 137 byte weapon; 138 netshort frags; 139 netushort ammo; 140 } netmsg_update_statusbar; 141 142 143 /* CLIENT -> SERVER */ 144 typedef struct { 145 byte type; 146 byte gamemode; 147 byte protocol; /* NETMSG_PROTOCOL_VERSION */ 148 char name[NETMSG_STRLEN]; 149 char map_name[NETMSG_STRLEN]; 150 } netmsg_join; 151 152 typedef struct { 153 byte type; 154 byte entity_type; 155 byte color1; 156 byte color2; 157 byte movemode; 158 netushort view_w; 159 netushort view_h; 160 } netmsg_ready; 161 162 typedef struct { 163 byte type; 164 } netmsg_query_sv_info; 165 166 typedef struct { 167 byte type; 168 byte dir; 169 byte keypress; /* Bit array of key presses */ 170 } netmsg_cl_update; 171 172 173 typedef struct { 174 byte type; 175 char string[TEXTMESSAGE_STRLEN]; 176 } netmsg_gamemessage; 177 178 typedef struct { 179 byte type; 180 byte active; 181 shortpoint_t target; 182 } netmsg_map_target; 183 184 typedef struct { 185 byte type; 186 char string[TEXTMESSAGE_STRLEN]; 187 } netmsg_objective; 188 189 typedef struct { 190 byte type; 191 } netmsg_killme; 192 193 typedef struct { 194 byte type; 195 } netmsg_query_frags; 196 197 typedef struct { 198 byte type; 199 netshort frame; 200 netshort frags; 201 char name[NETMSG_STRLEN]; 202 } netmsg_frags; 203 204 typedef struct { 205 byte type; 206 } netmsg_away; 207 208 typedef union { 209 /****************** KEEP THIS FIRST ****************/ 210 byte type; /* Lined up with the msg type's in the various struct's */ 211 netmsg_noop noop; 212 netmsg_query_version query_version; 213 netmsg_version version; 214 netmsg_textmessage textmessage; 215 netmsg_quit quit; 216 netmsg_rejection rejection; 217 netmsg_sv_info sv_info; 218 netmsg_changelevel changelevel; 219 netmsg_start_frame start_frame; 220 netmsg_end_frame end_frame; 221 netmsg_entity entity; 222 netmsg_particles particles; 223 netmsg_update_statusbar update_statusbar; 224 netmsg_gamemessage gamemessage; 225 netmsg_map_target map_target; 226 netmsg_objective objective; 227 netmsg_join join; 228 netmsg_ready ready; 229 netmsg_query_sv_info query_sv_info; 230 netmsg_cl_update cl_update; 231 netmsg_killme killme; 232 netmsg_query_frags query_frags; 233 netmsg_frags frags; 234 netmsg_away away; 235 } netmsg; 236