1 /*************************************************************************** 2 **************************************************************************** 3 **************************************************************************** 4 * Nighthawk 5 * Copyright (C) 1996-2004 Jason Nunn et al 6 * Developed by Jason Nunn et al (see README for Acknowledgements) 7 * 8 * Project head and maintainer-- 9 * Eric Gillespie (The Viking) 10 * Email: viking667@users.sourceforge.net 11 * http://night-hawk.sourceforge.net 12 * 13 * Original Author-- 14 * Jason Nunn 15 * http://jsno.leal.com.au 16 * 17 * C/- Jason Nunn 18 * PO Box 15 19 * Birdwood SA 5234 20 * Australia 21 * 22 * This software is Open Source GPL. Please read COPYING notice. 23 * 24 **************************************************************************** 25 **************************************************************************** 26 ***************************************************************************/ 27 extern "C" { 28 #include <stdio.h> 29 #include <stdlib.h> 30 #include <unistd.h> 31 #include <string.h> 32 #include <signal.h> 33 #include <pwd.h> 34 #include <time.h> 35 #include <ctype.h> 36 #include <math.h> 37 #include <sys/time.h> 38 #include <sys/types.h> 39 #include <sys/file.h> 40 #include <sys/stat.h> 41 #include <X11/Xlib.h> 42 #include <X11/XKBlib.h> 43 #include <GL/glut.h> 44 #include <GL/glx.h> 45 } 46 #include "../version.h" 47 48 #define PRIVATE static 49 #define PUBLIC 50 51 #define DATED __DATE__ 52 #define WELCOME \ 53 "Nighthawk version " VERSION ", Copyright (C) 1996-2004 Jason Nunn et al\n\n" 54 55 #define STR_LABEL_LEN 40 56 #define STR_LEN 256 57 58 #define UPDATE_SPEED 20 59 60 #define X 0 61 #define Y 1 62 #define Z 2 63 64 #define R 0 65 #define G 1 66 #define B 2 67 #define A 3 68 69 #define FONT_SIZE (128 - 32) 70 71 #define RAD2DEG(x) ((x * 180.0) / M_PI) 72 #define DEG2RAD(x) ((x * M_PI) / 180.0) 73 74 #define MAX_SHIPS 10 75 76 #define SCREEN_SIZE_X 320 77 #define SCREEN_SIZE_Y 200 78 #define SCREEN_HSIZE_X (SCREEN_SIZE_X >> 1) 79 #define SCREEN_HSIZE_Y (SCREEN_SIZE_Y >> 1) 80 #define SPRITE_SIZE_X 32 81 #define SPRITE_SIZE_Y 32 82 #define SPRITE_HSIZE_X (SPRITE_SIZE_X >> 1) 83 #define SPRITE_HSIZE_Y (SPRITE_SIZE_Y >> 1) 84 85 #define MOVE_DRADIUS (MOVE_RADIUS << 1) 86 87 #define MAX_LASERS 24 88 #define MAX_DOORS 24 89 #define MAX_TRANSPORTS 8 90 #define MAX_DROIDS 65 91 #define MAX_MESSAGES 5 92 93 #define GENERAL_SPD 0.5 94 95 #define MAX_SCORE_TABLE 9 96 97 #define KEVENT_SIZE 128 98 #define KEYBOARD_EVENT 0 99 #define SPECIAL_EVENT 1 100 #define MOUSE_EVENT 2 101 102 #define KEY_SELECT ' ' 103 #define KEY_TRANSFER_MODE 't' 104 #define KEY_STATUS 's' 105 #define KEY_PAUSE 'p' 106 #define KEY_QUIT 'q' 107 #define KEY_CASCADE_MODE 'c' 108 #define KEY_FPS 'f' 109 #define KEY_REDUCED 'r' 110 111 typedef struct 112 { 113 void (*bg)(void); 114 void (*fg)(void); 115 } sequence_tab_t; 116 117 typedef struct 118 { 119 char type; 120 int val; 121 int mouse_x; 122 int mouse_y; 123 } tkevent; 124 125 typedef struct 126 { 127 GLfloat r, g, b; 128 } colour_pixel_t; 129 130 typedef struct 131 { 132 unsigned int size_x, 133 size_y; 134 GLuint id; 135 } bm_t; 136 137 typedef struct 138 { 139 char bound; 140 bm_t bm; 141 } tflr_bm; 142 143 typedef struct 144 { 145 char name[9]; 146 char highest_ship[16]; 147 int score; 148 } tscore_table; 149 150 typedef struct 151 { 152 char *type; 153 char *name; 154 int entry; 155 float height; 156 float weight; 157 char *brain; 158 int armament; 159 int shielding; 160 int max_shielding; 161 double speed; 162 double attack_rate; 163 } tdroid_stats; 164 165 #define DROID_002 0 166 #define DROID_108 1 167 #define DROID_176 2 168 #define DROID_261 3 169 #define DROID_275 4 170 #define DROID_355 5 171 #define DROID_368 6 172 #define DROID_423 7 173 #define DROID_467 8 174 #define DROID_489 9 175 #define DROID_513 10 176 #define DROID_520 11 177 #define DROID_599 12 178 #define DROID_606 13 179 #define DROID_691 14 180 #define DROID_693 15 181 #define DROID_719 16 182 #define DROID_720 17 183 #define DROID_766 18 184 #define DROID_799 19 185 #define DROID_805 20 186 #define DROID_810 21 187 #define DROID_820 22 188 #define DROID_899 23 189 #define DROID_933 24 190 #define DROID_949 25 191 #define DROID_999 26 192 193 #define LASER_NONE 0 194 #define LASER_LINARITE 1 195 #define LASER_CROC_BENZ 2 196 #define LASER_UVAROVITE 3 197 #define LASER_TIGER_EYE 4 198 199 #include "tpower_bay.h" 200 #include "tdoor.h" 201 #include "tfloor.h" 202 #include "tentity.h" 203 #include "tlaser.h" 204 #include "tdroid.h" 205 #include "tparadroid.h" 206 #include "tdroid_1xx.h" 207 #include "tdroid_2xx.h" 208 #include "tdroid_3xx.h" 209 #include "tdroid_4xx.h" 210 #include "tdroid_5xx.h" 211 #include "tdroid_6xx.h" 212 #include "tdroid_7xx.h" 213 #include "tdroid_8xx.h" 214 #include "tdroid_9xx.h" 215 #include "tship.h" 216