1 /* 2 * XPilot NG, a multiplayer space war game. 3 * 4 * Copyright (C) 2000-2004 Uoti Urpala <uau@users.sourceforge.net> 5 * 6 * Copyright (C) 1991-2001 by 7 * 8 * Bj�rn Stabell <bjoern@xpilot.org> 9 * Ken Ronny Schouten <ken@xpilot.org> 10 * Bert Gijsbers <bert@xpilot.org> 11 * Dick Balaska <dick@xpilot.org> 12 * 13 * This program is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU General Public License as published by 15 * the Free Software Foundation; either version 2 of the License, or 16 * (at your option) any later version. 17 * 18 * This program is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program; if not, write to the Free Software 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 */ 27 28 #ifndef PACK_H 29 #define PACK_H 30 31 #define CAP_LETTER(c) ((c) = ((c)>='a' && (c)<='z') ? (c)-'a'+'A' : (c)) 32 33 #define SERVER_PORT 15345 /* Port which server listens to. */ 34 35 /* 36 * Magic contact word. 37 * The low 16 bits are the real magic word. 38 * Bits 31-28 are the major version number. 39 * Bits 27-24 are the minor version number. 40 * Bits 23-20 are the patchlevel number. 41 * Bits 19-16 are free to mean beta release or so. 42 * These high bits only need to be changed when a new 43 * client can't talk to an old server or vise versa. 44 * Please don't change it more often than strictly necessary. 45 * PLEASE NOTE: if you make your own private incompatible changes 46 * justifying an increment of the version word then please 47 * set the 4th bit. Like 0x3108 and 0x3109 till 0x310F, etc. 48 * This way we can use the lower 8 values for public releases. 49 * 50 * Reasons why it changed in the past: 51 * 3.0.1: rewrite of contact pack protocol, because of 52 * different structure layout rules on different architectures. 53 * 3.0.2: rewrite of setup transmit from server to client to 54 * make it possible for 64-bit machines and 32-bit machines 55 * to join in the same game. This was the last hardcoded 56 * structure that was shared between client and server. 57 * 3.0.3: implemented a version awareness system, so that 58 * newer clients can join older servers and so that 59 * newer servers can support older clients. 60 * The client maintains a 'version' variable indicating 61 * the version of the server it has joined and the server 62 * maintains for each connection a 'connection_t->version' 63 * and a 'player->version' variable. 64 * 3.0.4: the so-called 'pizza-mode' introduced a new packet type. 65 * The score packet now also includes pl->mychar. 66 * 3.0.4.1: new laser weapon introduces another packet change. 67 * Because there is an unofficial (and forbidden) 3.0.4 version floating 68 * around the sub patchlevel number is used to distinguish versions. 69 * A new display packet to tell the server what the view sizes are 70 * and how many different debris intensities the client wants. 71 * 3.0.4.2: new player-self status byte in self packet. 72 * 3.0.4.3: different and incompatible laser packet. 73 * New eyes packet to tell the client through wich players eyes we're 74 * looking through in case the client is in game over move and it is locked 75 * on someone else. 76 * 3.1.0.0: new big patches implementing loads of new incompatible features. 77 * Major cleanup. Old clients (before 310) can't join new servers anymore. 78 * 3.1.0.1: key-change-ids are now send as longs instead of bytes. 79 * 3.1.0.2: different player status byte. 80 * 3.1.0.3: different mine packet. 81 * 3.2.0.0: New ship shape definition and big patches. 82 * 3.2.0.1: Extended buffer for very large ship shape definitions. 83 * 3.2.0.2: New mouse pointer control packet. 84 * 3.2.5.0: Now client must ask for audio packets in order to get them. 85 * 3.2.6.0: New map update packet. 86 * 3.2.6.1: New player timing packet. 87 * 3.2.8.0: New asyn packet. 88 * 3.3.1.0: Different owner-only commands. 89 * 3.3.2.0: Map decorations. 90 * 3.4.0.0: Lose/drop item key. 91 * 3.5.0.0: Player waiting queue. 92 * 3.8.0.0: new items (deflector, hyperjump, phasing), keyboardsize and rounddelay. 93 * 4.1.0.0: new item (mirror). 94 * 4.2.0.0: new power/turnspeed behavior 95 * 4.2.0.1: new item (armor). 96 * 4.2.0.2: highest bit on in wreckagetype when deadly. 97 * 4.2.0.3: different way of sending player item info. 98 * 4.2.1.0: high bit in radar size means player is a teammate. 99 * 4.3.0.0: transmit phasing separately from cloaking 100 * 4.4.0.0: new object (asteroid) 101 * 4.4.0.1: fast radar packet 102 * 4.5.0.0: new team score packet; score packet made larger to send decimals 103 * 4.5.0.1: temporary wormholes 104 105 * Polygon branch 106 * 4.F.0.9: 4.3.0.0 + xp2 map format 107 * 4.F.1.0: Send_player(): Additional %c (1 when sending player's own info). 108 * 4.F.1.1: support for everything in 4.5.0.1 109 * 4.F.1.2: Show ships about to appear on bases, new team change packet. 110 * 4.F.1.3: cumulative turning 111 * 4.F.1.4: balls use polygon styles 112 * 4.F.1.5: Possibility to change polygon styles. 113 */ 114 #define MAGIC_WORD 0xF4ED 115 #define POLYGON_VERSION 0x4F15 116 #define OLD_VERSION 0x4501 117 #ifdef SERVER 118 #define MAGIC (is_polygon_map \ 119 ? VERSION2MAGIC(POLYGON_VERSION) \ 120 : VERSION2MAGIC(OLD_VERSION)) 121 #else 122 #define MAGIC (VERSION2MAGIC(protocolVersion)) 123 #endif 124 125 #define MAGIC2VERSION(M) (((M) >> 16) & 0xFFFF) 126 #define VERSION2MAGIC(V) ((((V) & 0xFFFF) << 16) | MAGIC_WORD) 127 #define MY_VERSION MAGIC2VERSION(MAGIC) 128 129 /* 130 * Which client versions can join this server. 131 */ 132 #ifdef SERVER 133 #define MIN_CLIENT_VERSION 0x4203 134 #define MAX_CLIENT_VERSION MY_VERSION 135 #endif 136 137 /* 138 * Which server versions can this client join. 139 */ 140 #define MIN_SERVER_VERSION 0x4F09 141 #define MAX_SERVER_VERSION MY_VERSION 142 143 /* 144 * We want to keep support for servers using the old map format in the client, 145 * but make incompatible changes while developing the new format. Therefore 146 * there is a separate "old" range of allowed servers. 147 */ 148 #define MIN_OLD_SERVER_VERSION 0x4203 149 #define MAX_OLD_SERVER_VERSION 0x4501 150 /* Which old-style (non-polygon) protocol version we support. */ 151 #define COMPATIBILITY_MAGIC 0x4501F4ED 152 153 #define MAX_STR_LEN 4096 154 #define MAX_DISP_LEN 80 155 #define MAX_NAME_LEN 16 156 #define MAX_HOST_LEN 64 157 158 /* 159 * Different contact pack types. 160 */ 161 #define ENTER_GAME_pack 0x00 162 #define ENTER_QUEUE_pack 0x01 163 #define REPLY_pack 0x10 164 #define REPORT_STATUS_pack 0x21 165 #define OPTION_LIST_pack 0x28 166 /*#define CORE_pack 0x30*/ 167 #define CONTACT_pack 0x31 168 /* The owner-only commands have a common bit high. */ 169 #define PRIVILEGE_PACK_MASK 0x40 170 #define LOCK_GAME_pack 0x62 171 #define MESSAGE_pack 0x63 172 #define SHUTDOWN_pack 0x64 173 #define KICK_PLAYER_pack 0x65 174 /*#define MAX_ROBOT_pack 0x66*/ 175 #define OPTION_TUNE_pack 0x67 176 #define CREDENTIALS_pack 0x69 177 178 /* 179 * Possible error codes returned. 180 */ 181 #define SUCCESS 0x00 /* Operation successful */ 182 #define E_NOT_OWNER 0x01 /* Permission denied, not owner */ 183 #define E_GAME_FULL 0x02 /* Game is full, play denied */ 184 #define E_TEAM_FULL 0x03 /* Team is full, play denied */ 185 #define E_TEAM_NOT_SET 0x04 /* Need to specify a team */ 186 #define E_GAME_LOCKED 0x05 /* Game is locked, entry denied */ 187 #define E_NOT_FOUND 0x07 /* Player was not found */ 188 #define E_IN_USE 0x08 /* Name is already in use */ 189 #define E_SOCKET 0x09 /* Can't setup socket */ 190 #define E_INVAL 0x0A /* Invalid input parameters */ 191 #define E_VERSION 0x0C /* Incompatible version */ 192 #define E_NOENT 0x0D /* No such variable */ 193 #define E_UNDEFINED 0x0E /* Operation undefined */ 194 195 #endif 196