1 /* 2 * cfg_game.h - game configuration data 3 * 4 * $Id: cfg_game.h,v 1.18 2006/02/09 21:21:23 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_CFG_GAME_H 24 #define XBLAST_CFG_GAME_H 25 26 /* player controls */ 27 typedef enum 28 { 29 XBPC_None, 30 XBPC_RightKeyboard, 31 XBPC_LeftKeyboard, 32 XBPC_Joystick1, 33 XBPC_Joystick2, 34 XBPC_Joystick3, 35 XBPC_Joystick4, 36 /* no new elements after this line */ 37 XBPC_NUM 38 } XBPlayerControl; 39 40 /*player hosts */ 41 typedef enum 42 { 43 XBPH_None, 44 XBPH_Demo, /* host watches only */ 45 XBPH_Local, /* local host, either local game or during network game setup */ 46 XBPH_Server, /* server host, in network game only */ 47 XBPH_Client1, /* numbered client host, in network game only */ 48 XBPH_Client2, 49 XBPH_Client3, 50 XBPH_Client4, 51 XBPH_Client5, 52 #ifdef SMPF 53 XBPH_Client6, 54 XBPH_Client7, 55 XBPH_Client8, 56 XBPH_Client9, 57 XBPH_Client10, 58 XBPH_Client11, 59 XBPH_Client12, 60 XBPH_Client13, 61 XBPH_Client14, 62 XBPH_Client15, 63 #endif 64 XBPH_Central, 65 /* no new elements after this line */ 66 XBPH_NUM 67 } XBPlayerHost; 68 69 /* player teams */ 70 typedef enum 71 { 72 XBPT_Invalid, 73 XBPT_None, 74 XBPT_Red, 75 XBPT_Green, 76 XBPT_Blue, 77 /* no new elements after this line */ 78 XBPT_NUM 79 } XBPlayerTeam; 80 81 /* game player config */ 82 typedef struct 83 { 84 int num; /* number of players */ 85 XBAtom player[MAX_PLAYER]; /* section atoms for player graphics */ 86 XBPlayerControl control[MAX_PLAYER]; 87 XBPlayerHost host[MAX_PLAYER]; 88 XBPlayerTeam team[MAX_PLAYER]; 89 XBColor teamColor[MAX_PLAYER]; 90 int PID[MAX_PLAYER]; /* pid's for rated games */ 91 int playerID[MAX_PLAYER]; /* ??? */ 92 } CFGGamePlayers; 93 94 /* team modes */ 95 typedef enum 96 { 97 XBTM_None, /* normal game */ 98 XBTM_Team, /* teams, assignment is random */ 99 XBTM_Hunt, /* all on one (3 to 6 players) */ 100 /* no new elements after this line */ 101 XBTM_NUM 102 } XBTeamMode; 103 104 /* game parameters */ 105 typedef struct 106 { 107 XBBool ifRecLives; /* should recommended lives for levels be used */ 108 int numLives; /* standard number of lives in levels */ 109 int numWins; /* wins necessary for game end */ 110 int frameRate; /* frame rate */ 111 XBBool allLevels; /* use all levels in game */ 112 XBBool randomLevels; /* random level choice */ 113 XBBool randomPlayers; /* random player positions */ 114 int levelOrder; /* how to sort the levels */ 115 int infoTime; /* time for level info */ 116 XBBool recordDemo; /* should game be saved for demo view */ 117 XBTeamMode teamMode; /* initial team mode */ 118 XBBool rated; /* rated game or not */ 119 XBBool bot; /* start in bot mode (all players) */ 120 XBBool beep; /* beep for new connection, game start */ 121 SND_Id Music; /* background music */ 122 int recLives; /* default recommended lives count */ 123 int maskBytes; /* action mask bytes to use */ 124 } CFGGameSetup; 125 126 /* connection to host */ 127 typedef struct 128 { 129 const char *name; /* host name */ 130 int port; /* port number for tcp connection */ 131 XBBool fixedUdpPort; /* use fixed udp ports in game */ 132 XBBool browseLan; /* open socket for la broadcasts */ 133 XBBool allowNat; /* allow clients behind NAT */ 134 XBBool central; /* register game at central */ 135 XBBool beep; /* beep for new clients */ 136 SND_Id Music; /* background music */ 137 const char *game; /* game name */ 138 } CFGGameHost; 139 140 /* host constants */ 141 typedef struct 142 { 143 int maxhosts; /* max number of hosts allowed */ 144 int maxplayers; /* max number of total players allowed */ 145 int maxlocals; /* max number of local players allowed */ 146 int maxbytes; /* max number of mask bytes handled */ 147 XBVersion version; /* version number */ 148 } CFGGameConst; 149 150 /* all in one */ 151 typedef struct 152 { 153 CFGGameSetup setup; 154 CFGGamePlayers players; 155 CFGGameHost host; 156 CFGGameConst constants; 157 } CFGGame; 158 159 /* 160 * global prototypes 161 */ 162 163 /* handle all game configs */ 164 extern void LoadGameConfig (void); 165 extern void SaveGameConfig (void); 166 extern void FinishGameConfig (void); 167 168 /* handle single game config */ 169 extern void AddToGameConfig (CFGType, XBAtom atom, const char *text); 170 extern XBBool SendGameConfig (CFGType, XBSndQueue * sndQueue, XBTeleCOT cot, XBTeleIOB iob, 171 XBAtom atom); 172 extern void DeleteGameConfig (CFGType, XBAtom); 173 174 /* retrieve/store in a single game config */ 175 extern XBBool RetrieveGame (CFGType, XBAtom atom, CFGGame *); 176 extern void StoreGame (CFGType, XBAtom atom, const CFGGame *); 177 178 extern XBBool RetrieveGameHost (CFGType, XBAtom atom, CFGGameHost *); 179 extern const char *GetHostName (CFGType, XBAtom); 180 extern void StoreGameHost (CFGType, XBAtom atom, const CFGGameHost *); 181 182 extern XBBool RetrieveGameSetup (CFGType, XBAtom atom, CFGGameSetup *); 183 extern void StoreGameSetup (CFGType, XBAtom atom, const CFGGameSetup *); 184 185 extern XBBool RetrieveGamePlayers (CFGType, XBAtom atom, CFGGamePlayers *); 186 extern void StoreGamePlayers (CFGType, XBAtom atom, const CFGGamePlayers *); 187 188 extern XBBool RetrieveGameVersion (CFGType cfgType, XBAtom atom, XBVersion * ver); 189 extern void StoreGameVersion (CFGType cfgType, XBAtom atom, const XBVersion * ver); 190 191 extern XBBool RetrieveGameConst (CFGType cfgType, XBAtom atom, CFGGameConst * con); 192 extern void StoreGameConst (CFGType cfgType, XBAtom atom, const CFGGameConst * con); 193 extern void StoreGameConstLocal (CFGType cfgType, XBAtom atom); 194 195 extern XBBool RetrieveIpHistory (CFGGameHost game[10], XBAtom atom); 196 extern void StoreIpHistory (CFGGameHost * host, XBAtom atom); 197 198 #endif 199 /* 200 * end of file cfg_game.h 201 */ 202