1 /***************************************************************************** 2 ** This is part of the SpaceZero program 3 ** Copyright (C) 2006-2013 MRevenga 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 (version 3), or 7 ** (at your option) any later version, as published by the Free Software 8 ** Foundation. 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 20 /************* SpaceZero M.R.H. 2006-2013 ****************** 21 Author: MRevenga 22 E-mail: mrevenga at users.sourceforge.net 23 version 0.86 December 2013 24 **************************************************************/ 25 26 #ifndef _GENERAL_ 27 #define _GENERAL_ 28 29 #ifndef TRUE 30 #define FALSE 0 31 #define TRUE 1 32 #endif 33 34 /* #define GDK_DISABLE_DEPRECATED */ 35 36 /* compile options: */ 37 #define SOUND 1 /* compile with sound */ 38 /* --compile options: */ 39 40 #define MODI(a) ((a) > 0 ? (a) : (-a)) 41 #define PI 3.14159265 42 43 44 #define MINORSAVEVERSION "0.85.12" /* the save file version must be greater than this.*/ 45 #define MINOROPTIONSVERSION "0.85.01" /* the options file must be greater than this.*/ 46 47 #define MAXTEXTLEN 128 48 49 /* window properties */ 50 #define DEFAULTWIDTH 1024 /* 900 1024 800 1024 1152 */ 51 #define DEFAULTHEIGHT 550 /* 600 500 550 700 768 */ 52 #define LXFACTOR 1024 /* normalization factor for surface planets */ 53 #define LYFACTOR 550 /* normalization factor for surface planets */ 54 #define PANEL_HEIGHT 20 55 56 /* game */ 57 #define CLOSEDUNIVERSE 0 58 #define NUMSTARS 200 59 #define GRAVITATION_RANGE2 4000000 /* max. gravity reach */ 60 #define G .1 /* gravitation constant */ 61 #define DT .42 /* .35 .42 .35 .42 */ 62 #define RESOURCEFACTOR 1.2 /* velocity factor for getting resource from planets */ 63 #define COSTFACTOR 1.0 /* multiplicative factor to ships cost */ 64 #define DAMAGEFACTOR .7 /* (0.9) multiplicative factor to weapon damage */ 65 #define COSTINC 1.8 /* increment of ships cost when level up */ 66 #define MINLEVELPILOT 1 /* min level of a ship to have a survival pod, (only fighters)*/ 67 68 #define PLANETSKNOWN 0 69 #define SLOWMACHINE 0 70 71 72 /* default options */ 73 #define MAPAUTOCENTER 1 74 #define NUMPLAYERS 2 75 #define NUMGALAXIES 1 76 #define NUMPLANETS 30 /* num. planets in galaxy */ 77 #define ULX 80000 /* default universe size */ 78 #define ULY 80000 /* default universe size */ 79 #define PLAYERNAME "player" 80 81 /* max and min option values */ 82 #define MAXNUMPLAYERS 8 83 #define MINNUMPLAYERS 2 84 #define MAXNUMGALAXIES 10 85 #define MINNUMGALAXIES 1 86 #define MAXNUMPLANETS 200 /* num. planets in galaxy */ 87 #define MINNUMPLANETS 2 /* num. planets in galaxy */ 88 #define MAXULX 1000000 /* max. universe size */ 89 #define MINULX 10000 /* min. universe size */ 90 #define MAXNUMTEAMS MAXNUMPLAYERS 91 92 93 /* player control */ 94 #define HUMAN 0 95 #define COMPUTER 1 96 97 98 /* mode games*/ 99 #define LOCAL 0 100 #define SERVER 1 101 #define CLIENT 2 102 103 /* navigation modes */ 104 #define ABSOLUTE 0 105 #define RELATIVE 1 106 107 108 #define RADAR_RANGE 2000 109 #define RADAR_RANGE2 4000000 110 #define SECTORSIZE 1410 /* sqrt(RADAR_RANGE2/2) */ 111 #define MAXASTEROIDDISTANCE2 784000000 /* max distance2 an asteroid can be seen (20 sectors )*/ 112 113 /* FILES */ 114 #define SAVEDIR ".spacezero" 115 #define SAVETMPFILE "/tmp/tmpspacezero" 116 #define SAVEFILE0 "save" 117 #define SAVEFILE1 "savecl" 118 #define SAVEFILENET "saven" 119 #define SAVEFILESINGLE SAVEFILE0 120 #define RECORDFILE "record" 121 #define OPTIONSFILE "options" 122 #define KEYBOARDFILE "keymap" 123 #define LETTERFREQUENCYFILE "letterfrequencytable" 124 125 126 /* planet properties */ 127 #define MINPLANETMASS 35000 128 #define MAXPLANETMASS 160000 129 #define MINPLANETGOLD 2000 130 #define MAXPLANETGOLD 8000 131 #define MAXPLANETHEIGHT 0.3*DEFAULTHEIGHT 132 #define FACTORLANDZONESIZE 0.2*DEFAULTWIDTH 133 #define LANDZONEMINSIZE 120 134 #define LANDZONEMINX 175 135 136 /* miscelanea */ 137 #define MINTTL -256 /* with less value ships are forgotten*/ 138 139 /* Game parametres */ 140 141 #define DEFAULT 0 142 #define GULX 1 /* universe size */ 143 #define GULY 2 /* universe size */ 144 #define GWIDTH 3 /* window size */ 145 #define GHEIGHT 4 /* window size */ 146 #define GPANEL 5 /* shell panel size */ 147 #define GNET 6 /* TRUE : NET , FALSE : LOCAL */ 148 #define GMODE 7 /* LOCAL, SERVER, CLIENT */ 149 #define GCOOPERATIVE 8 /* Cooperative mode game */ 150 #define GCOMPCOOPERATIVE 9 /* Computer cooperative mode game */ 151 #define GQUEEN 10 /* Queen mode game */ 152 #define GPIRATES 11 /* Create pirates or not */ 153 #define GENEMYKNOWN 12 /* Enemies are known */ 154 #define GNGALAXIES 13 /* number of galaxies */ 155 #define GNPLAYERS 14 /* number of players */ 156 #define GNPLANETS 15 /* number of planets */ 157 #define GKPLANETS 16 /* TRUE FALSE planets known or unknown */ 158 #define GMUSIC 17 /* TRUE FALSE music */ 159 #define GSOUND 18 /* TRUE FALSE sound */ 160 #define GMUSICVOL 19 /* 0..100 music volume */ 161 #define GSOUNDVOL 20 /* 0..100 sound volume */ 162 #define GPAUSED 21 /* TRUE FALSE game paused */ 163 #define GQUIT 22 /* 0,1,2 really quit? */ 164 165 166 /* Error codes for all functions */ 167 168 enum SZ_Error{ 169 /* Used in Buyship() */ 170 SZ_OK, 171 SZ_OBJNULL, 172 SZ_UNKNOWNERROR, 173 SZ_OBJNOTLANDED, 174 SZ_NOTOWNPLANET , 175 SZ_NOTENOUGHGOLD, 176 SZ_NOTALLOWED, 177 SZ_NOTIMPLEMENTED, 178 SZ_NOTENOUGHROOM 179 }; 180 /* --Error codes for all functions */ 181 182 183 /* messages among players */ 184 185 186 struct TextMessage{ 187 int n; /* size of the message */ 188 int source; /* source player */ 189 int dest; /* dest player */ 190 int id; /* id of the message */ 191 int print; /* it is printed */ 192 int time; /* time of the text */ 193 int value ; /* relevance of the message */ 194 int duration; /* duration of the text*/ 195 char text[MAXTEXTLEN]; /* text */ 196 }; 197 198 struct TextMessageList{ 199 struct TextMessage info; 200 struct TextMessageList *next; 201 }; 202 203 204 struct Game{ /* Game parametres */ 205 int width,height; /* window size */ 206 int panel_height; /* shell height */ 207 int ulx,uly; /* Universe size */ 208 int net; /* TRUE : NET , FALSE : LOCAL */ 209 int mode; /* LOCAL, SERVER, CLIENT */ 210 int cooperative; 211 int compcooperative; 212 int queen; 213 int pirates; 214 int enemyknown; 215 int ngalaxies; /* number of galaxies */ 216 int nplayers; /* number of players */ 217 int nplanets; /* number of planets */ 218 int kplanets; /* TRUE FALSE planets known or unknown */ 219 int paused; /* TRUE FALSE game paused */ 220 int music; /* music ON OFF */ 221 int sound; /* sound ON OFF */ 222 int musicvol; /* music volume */ 223 int soundvol; /* sound volume */ 224 int quit; /* 0,1,2 really quit? */ 225 }; 226 227 228 typedef struct{ 229 float x,y; 230 float mod; 231 float a; 232 }Vector; 233 234 typedef struct{ 235 int x,y; 236 }Point; 237 238 typedef struct{ 239 int x,y; 240 int width,height; 241 }Rectangle; 242 243 typedef struct{ 244 Rectangle rect; 245 int habitat; /* 0 means free space, >0: planetid */ 246 }Space; 247 248 249 250 #endif 251