/* * (C) COPYRIGHT Vincent S. Cojot and others 1996-1997 * All Rights Reserved * Licensed Materials - Property of Vincent S. Cojot and others. * Use, duplication or disclosure restricted by Vincent S. Cojot. */ #ifndef __DEFINES_H #define __DEFINES_H #ifndef PI #define PI 3.141592653895 #endif /* ------------------------------------------------*/ /* Definitions des variables du jeu */ /* ------------------------------------------------*/ #define TANK_HOME (PREFIX "/share/tank") /* ------------------------------------------------*/ /* Definitions du nombre maximum d'objets */ /* ------------------------------------------------*/ #define MAX_TANKS 20 #define MAX_MISSILES 20 #define MAX_EXPLOSIONS 20 #define MAX_DESTROYED_TANKS 20 /* ------------------------------------------------*/ /* Definitions du nombre de facettes de nos objets */ /* ------------------------------------------------*/ #define CUBE_FACES 4 #define PRISM_FACES 8 #define CYL_FACES 32 /* ------------------------------------------------*/ /* Definitions diverses. */ /* ------------------------------------------------*/ #define FIRE_DELAY 8 #define MAX_MISSILE_AGE 6 #define MAX_MESSAGE_AGE 2 #define MISSILE_SPEED 50 #define MISSILE_SLICE_INTERVALS 5 #define TANK_INERT_FACTOR 3.0 #define SCENE_INERT_FACTOR 10.0 #define DESTRUCTION_DELAY 5 #define RADAR_IDENTIFICATION_DISTANCE 40 #define EXPLOSION_BACKWARD_FACTOR 3 #define STARTUPWIDTH 320 #define STARTUPHEIGHT 240 /* ------------------------------------------------*/ /* Definitions des identificateurs des listes d'objets pre-compilees */ /* On a deux types de listes: */ /* Listes en mode WireFrame et Listes en mode Solide */ /* ------------------------------------------------*/ #define MY_SOLID_PRISM 1000 #define MY_SOLID_CUBE 1010 #define MY_SOLID_CYL 1020 #define MY_SOLID_FLOOR 1110 #define ALL_MY_SOLID_FLOOR 1210 #define ALL_MY_LIGHT_FLOOR 1220 #define ALL_MY_SOLID_TANK 1300 #define ALL_MY_RED_SOLID_TANK 1310 #define SOLID_DESTROYED_TANK 1320 #define MY_SOLID_MISSILE 1400 #define MY_WIRE_PRISM 2000 #define MY_WIRE_CUBE 2010 #define MY_WIRE_CYL 2020 #define MY_WIRE_FLOOR 2110 #define ALL_MY_WIRE_FLOOR 2220 #define ALL_MY_WIRE_TANK 2300 #define ALL_MY_RED_WIRE_TANK 2310 #define WIRE_DESTROYED_TANK 2320 #define MY_WIRE_MISSILE 2400 #define MY_LINES 4100 #define DEEP_BLUE_SKY 4200 #define CONTROL_PANEL 4300 #define CONTROL_PANEL_RADAR 4400 #define RADAR_ITEM 4450 #define RADAR_ITEM_MY_TANK 4460 #define ALL_SOLID_OBSTACLES 4500 #define ALL_WIRE_OBSTACLES 4600 #define ALL_MY_STATIC_HEAD_UP 6000 #define EXPLOSION_BASE 6100 #define EXPLOSION_1 ( EXPLOSION_BASE + 10) #define EXPLOSION_2 ( EXPLOSION_BASE + 20) #define EXPLOSION_3 ( EXPLOSION_BASE + 30) #define EXPLOSION_4 ( EXPLOSION_BASE + 40) #define EXPLOSION_5 ( EXPLOSION_BASE + 50) #define EXPLOSION_6 ( EXPLOSION_BASE + 60) #define EXPLOSION_7 ( EXPLOSION_BASE + 70) #define EXPLOSION_8 ( EXPLOSION_BASE + 80) #define EXPLOSION_9 ( EXPLOSION_BASE + 90) #define EXPL_ALPHA_MULTI_FACTOR 3 #define ALL_MY_AXIS 6200 #define sgn(a) ( (a)>=0?(1):(-1) ) /* -------------------------------------------------- */ /* Definitions necessaires au reseau. */ /* -------------------------------------------------- */ #define NETWORK_REMIND_TIMEOUT 3.0 #define NETWORK_RUN_TIMEOUT 2.0 #define NETWORK_PORT 8123 #define NETWORK_GROUP "127.0.0.0" #define EXAMPLE_TTL 1 /* Time-to-live, 1 == don't forward */ #define PACKET_TANK 1 #define PACKET_OBUS 2 #define PACKET_EXPL 3 #define MAX_MSG_LEN 256 /* Send a message every x micro-seconds (currently: 20 ms)*/ #define INTERVAL 20000 /* les structures des 3 types de paquets possibles */ typedef struct ptank { int type; char nom[10]; float time_stamp; float pos_x, pos_y; float dir_x, dir_y; float vit; float vit_ang; } PTANK; typedef struct pmissile { int type; char nom[10]; float time_stamp; float org_x, org_y; float dir_x, dir_y; } PMISSILE; typedef struct pexplosion { int type; char nom[10]; char nom_detruit[10]; float time_stamp; float pos_x, pos_y; } PEXPLOSION; /* la structure contenant 3 listes de paquets */ typedef struct spmem { PTANK _tank[MAX_TANKS]; PMISSILE _obus[MAX_MISSILES]; PEXPLOSION _expl[MAX_EXPLOSIONS]; } PMEM; /* -------------------------------------------------- */ /* Definitions necessaires aux IPC par shared memory. */ /* -------------------------------------------------- */ #define STATUS_KEY1 100 #define STATUS_KEY2 200 #define STATUS_KEY3 300 #define STATUS_KEY4 400 #define STATUS_KEY5 500 #define TANKS_KEY 1000 #define MISSILES_KEY 1100 #define EXPLOSIONS_KEY 1200 #ifndef SHM_SIZE #define SHM_SIZE 10000 #endif #define SHM_MODE (SHM_R | SHM_W) /* User read-write. */ /* -------------------------------------------------- */ /* Definitions necessaires aux textures et aux images */ /* -------------------------------------------------- */ #define NB_OF_MISSILE_TEXTURES 14 #define MissImageWidth 128 #define MissImageHeight 32 #ifndef MAXWIDTH #define MAXWIDTH 128 #endif #ifndef MAXLENGTH #define MAXLENGTH 32 #endif #define NB_OF_EXPL_TEXTURES 20 #define ExplImageWidth 64 #define ExplImageHeight 64 #ifndef EXPL_MAXWIDTH #define EXPL_MAXWIDTH 64 #endif #ifndef EXPL_MAXLENGTH #define EXPL_MAXLENGTH 64 #endif /* -------------------------------------------------- */ /* Definitions des types d'images pour le jeu. */ /* -------------------------------------------------- */ typedef struct targa { char vide[12]; unsigned short Width; unsigned short Length; unsigned char BitsPerPixel; } TARGA; typedef struct pixel { unsigned char r; unsigned char g; unsigned char b; } PIXEL; typedef struct miss_image { TARGA header; PIXEL img[MAXWIDTH][MAXLENGTH]; } MISS_IMAGE; typedef struct expl_image { TARGA header; PIXEL img[EXPL_MAXWIDTH][EXPL_MAXLENGTH]; } EXPL_IMAGE; /* -------------------------------------------------- */ /* Definitions des types de structures pour le Tank. */ /* -------------------------------------------------- */ typedef struct status_ipc { GLint NetworkEnabled; GLint StatusChanged; GLint GameTerminating; GLfloat StatusLastChangeTime; GLfloat LastTimeNetworkPlayed; GLfloat TheCurrentTime; } STATUS_IPC; /* -------------------------------------------------- */ /* Definitions des types de structures pour le Tank. */ /* -------------------------------------------------- */ typedef struct tank { GLfloat Posx; GLfloat Posz; GLfloat Angle; GLfloat LastSeen; GLint Valid; GLint Destroyed; char Name[10]; } TANK; typedef struct tank_ipc { int mesg_len; long mesg_type; int Modified; GLfloat Posx; GLfloat Posz; GLfloat Angle; } TANK_IPC; /* -------------------------------------------------- */ /* Definitions des types de structures pour le Missile. */ /* -------------------------------------------------- */ typedef struct missile { GLfloat Posx; GLfloat Posz; GLfloat Incx; GLfloat Incz; GLfloat Angle; GLfloat Age; GLint Valid; char Name[10]; } MISSILE; typedef struct missile_ipc { int mesg_len; long mesg_type; int Modified; GLfloat Posx; GLfloat Posz; GLfloat Angle; } MISSILE_IPC; /* -------------------------------------------------- */ /* Definitions des types de structures pour l'Explosion. */ /* -------------------------------------------------- */ typedef struct explosion { GLfloat x; GLfloat y; GLfloat z; GLfloat Angle; GLfloat Age; GLint Valid; char Name[10]; char Destroyed[10]; } EXPLOSION; typedef struct explosion_ipc { int mesg_len; long mesg_type; int Modified; GLfloat Posx; GLfloat Posz; GLfloat Angle; } EXPLOSION_IPC; /* -------------------------------------------------- */ /* Definitions des types de structures pour les messages internes. */ /* -------------------------------------------------- */ typedef struct message { char texta[80]; char textb[80]; char textc[80]; char textd[80]; char texte[80]; char textf[80]; char textg[80]; GLfloat Age; GLint Valid; } MESSAGE; typedef struct message_ipc { int mesg_len; long mesg_type; int Modified; char text[80]; } MESSAGE_IPC; #endif