275 lines
7.3 KiB
C
Executable File
275 lines
7.3 KiB
C
Executable File
//-----
|
|
// Nom du projet : Fly Simulator
|
|
// Version : - dev -
|
|
// Dernière modification le : 19 juillet 2019
|
|
//-----
|
|
|
|
#include <gint/display.h>
|
|
#include <gint/keyboard.h>
|
|
#include <gint/std/string.h>
|
|
|
|
#define C_RED 0xf800
|
|
#define C_GREEN 0x07e0
|
|
#define C_BLUE 0x001f
|
|
|
|
|
|
//communication : gère les communications entre la tour et l'avion
|
|
int communication (int *com_id, int *ligne, int id);
|
|
|
|
//display_comm : affiche les communications
|
|
void display_comm (char *msg, int *ligne, int joueur);
|
|
|
|
//reset_comm : vide l'historique des communications
|
|
void reset_comm (int *ligne);
|
|
|
|
//add : concatène deux chaines de caractère, str >> dest
|
|
char *add (char *dest, const char *src);
|
|
|
|
//fill : initialise une chaine de caractère en écrasant le texte contenu dans dest
|
|
char *fill (char *dest, const char *src);
|
|
|
|
int main (void)
|
|
{
|
|
int com_id = 1, ligne = 0, id = 0;
|
|
//int key = 0;
|
|
|
|
dclear(C_WHITE);
|
|
dupdate();
|
|
|
|
while(com_id < 26)
|
|
{
|
|
id = communication(&com_id, &ligne, id);
|
|
getkey();
|
|
dupdate();
|
|
|
|
}
|
|
getkey();
|
|
return 1;
|
|
}
|
|
|
|
int communication(int *com_id, int *ligne, int id)
|
|
{
|
|
//faire un choix de la langue Français / Anglais
|
|
char avion[] = "Cessna 172 ", immat[] = "F-GUXF ", immat_courte[] = "F-XF ", aipt_depart[] = "Caen ", aipt_arrivee[] = "Le Havre ", freq_cont[] = "117.15 ", freq_arrivee[] = "122.80 ", passagers[] = "4 personnes a bord, ", msg[100] = "";
|
|
|
|
switch (*com_id)
|
|
{
|
|
case 1:
|
|
id = 1;
|
|
fill(msg, aipt_depart);
|
|
add(msg, "tour, ");
|
|
add(msg, immat);
|
|
add(msg, "bonjour.");
|
|
break;
|
|
case 2:
|
|
id = 0;
|
|
fill(msg, immat);
|
|
add(msg, aipt_depart);
|
|
add(msg, "bonjour.");
|
|
break;
|
|
case 3:
|
|
id = 1;
|
|
fill(msg, immat);
|
|
add(msg, avion);
|
|
add(msg, passagers);
|
|
add(msg, "demandons");
|
|
display_comm(msg, &(*ligne), id);
|
|
fill(msg, "vol vers ");
|
|
add(msg, aipt_arrivee);
|
|
break;
|
|
case 4:
|
|
id = 0;
|
|
fill(msg, immat_courte);
|
|
add(msg, "vol autorise. Rappelez pret au depart");
|
|
break;
|
|
case 5:
|
|
id = 1;
|
|
fill(msg, "Rappelons pret au depart, ");
|
|
add(msg, immat_courte);
|
|
break;
|
|
case 6:
|
|
id = 1;
|
|
fill(msg, immat_courte);
|
|
add(msg, "pret au depart");
|
|
break;
|
|
case 7:
|
|
id = 0;
|
|
fill(msg, immat_courte);
|
|
add(msg, "autorise decollage.");
|
|
break;
|
|
case 8:
|
|
id = 1;
|
|
fill(msg, "Autorise decollage, ");
|
|
add(msg, immat_courte);
|
|
break;
|
|
case 9:
|
|
id = 0;
|
|
reset_comm (&(*ligne));
|
|
fill(msg, immat_courte);
|
|
add(msg, "Vous quittez mon espace. Services radar");
|
|
display_comm(msg, &(*ligne), id);
|
|
fill(msg, "et radio termines. Informations de vol avec");
|
|
display_comm(msg, &(*ligne), id);
|
|
fill(msg, "Controle, ");
|
|
add(msg, freq_cont);
|
|
add(msg, "au revoir.");
|
|
break;
|
|
case 10:
|
|
id = 1;
|
|
fill(msg, "Controle ");
|
|
add(msg, freq_cont);
|
|
add(msg, "bonne journee. ");
|
|
add(msg, immat_courte);
|
|
break;
|
|
case 11:
|
|
id = 1;
|
|
fill(msg, "Controle ");
|
|
add(msg, immat);
|
|
add(msg, "bonjour.");
|
|
break;
|
|
case 12:
|
|
id = 0;
|
|
fill(msg, immat_courte);
|
|
add(msg, "Controle, bienvenu.");
|
|
break;
|
|
case 13:
|
|
id = 1;
|
|
fill(msg, immat);
|
|
add(msg, avion);
|
|
add(msg, passagers);
|
|
add(msg, "sortie de ");
|
|
display_comm(msg, &(*ligne), id);
|
|
add(msg, aipt_depart);
|
|
add(msg, "vers ");
|
|
add(msg, aipt_arrivee);
|
|
break;
|
|
case 14:
|
|
id = 0;
|
|
fill(msg, immat_courte);
|
|
add(msg, "identifie radar.");
|
|
break;
|
|
case 15:
|
|
id = 0;
|
|
reset_comm(&(*ligne));
|
|
fill(msg, immat_courte);
|
|
add(msg, "Vous quittez mon espace, contactez ");
|
|
add(msg, aipt_arrivee);
|
|
display_comm(msg, &(*ligne), id);
|
|
fill(msg, freq_arrivee);
|
|
add(msg, "bon vol.");
|
|
break;
|
|
case 16:
|
|
id = 1;
|
|
fill(msg, aipt_arrivee);
|
|
add(msg, freq_arrivee);
|
|
add(msg, "au revoir. ");
|
|
add(msg, immat_courte);
|
|
break;
|
|
case 17:
|
|
id = 1;
|
|
fill(msg, aipt_arrivee);
|
|
add(msg, "tour, ");
|
|
add(msg, immat);
|
|
add(msg, "bonjour.");
|
|
break;
|
|
case 18:
|
|
id = 0;
|
|
fill(msg, immat_courte);
|
|
add(msg, aipt_arrivee);
|
|
add(msg, "bonjour.");
|
|
break;
|
|
case 19:
|
|
id = 1;
|
|
fill(msg, immat);
|
|
add(msg, avion);
|
|
add(msg, passagers);
|
|
add(msg, "demandons");
|
|
display_comm(msg, &(*ligne), id);
|
|
fill(msg, "consignes pour atterrissage sur ");
|
|
add(msg, aipt_arrivee);
|
|
break;
|
|
case 20:
|
|
id = 0;
|
|
fill(msg, immat_courte);
|
|
add(msg, "Commencez votre approche");
|
|
break;
|
|
case 21:
|
|
id = 1;
|
|
fill(msg, "Commencons notre approche ");
|
|
add(msg, immat_courte);
|
|
break;
|
|
case 22:
|
|
id = 1;
|
|
reset_comm(&(*ligne));
|
|
fill(msg, immat_courte);
|
|
add(msg, "en finale, demandons autorisation");
|
|
display_comm(msg, &(*ligne), id);
|
|
fill(msg, "d'atterrissage");
|
|
break;
|
|
case 23:
|
|
id = 0;
|
|
fill(msg, immat_courte);
|
|
add(msg, "autorise aterrissage. Rappelez au sol.");
|
|
break;
|
|
case 24:
|
|
id = 1;
|
|
fill(msg, "Autorise aterrissage, rappelons au sol, ");
|
|
add(msg, immat_courte);
|
|
break;
|
|
case 25:
|
|
id = 1;
|
|
fill(msg, immat_courte);
|
|
add(msg, "au sol, pour quitter, merci.");
|
|
break;
|
|
case 26:
|
|
id = 0;
|
|
fill(msg, immat_courte);
|
|
add(msg, "quittez la frequence, a bientot.");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
display_comm(msg, &(*ligne), id);
|
|
*com_id += 1;
|
|
return id;
|
|
}
|
|
|
|
void display_comm (char *msg, int *ligne, int joueur)
|
|
{
|
|
if (*ligne >= 5) reset_comm(&(*ligne));
|
|
|
|
if (joueur)dtext(1, 1 + (*ligne * 12),msg, C_BLUE, C_NONE);
|
|
else dtext(1, 1 + (*ligne * 12),msg, C_BLACK, C_NONE);
|
|
|
|
*ligne += 1;
|
|
msg[0] = '\0';
|
|
}
|
|
|
|
void reset_comm (int *ligne)
|
|
{
|
|
*ligne = 0;
|
|
dclear(C_WHITE);
|
|
}
|
|
|
|
char *add(char *dest, const char *src)
|
|
{
|
|
unsigned long fin_dest = strlen(dest);
|
|
unsigned int i;
|
|
for (i = 0 ; i <= strlen(src) ; i++) dest[fin_dest + i] = src[i];
|
|
return dest;
|
|
}
|
|
|
|
char *fill(char *dest, const char *src)
|
|
{
|
|
unsigned int i;
|
|
for (i = 0 ; i <= strlen(src) ; i++)
|
|
{
|
|
dest[i] = src[i];
|
|
}
|
|
dest[strlen(dest) + 1] = '\0';
|
|
return dest;
|
|
}
|