1 /*
2  * Triplane Classic - a side-scrolling dogfighting game.
3  * Copyright (C) 1996,1997,2009  Dodekaedron Software Creations Oy
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 as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
17  *
18  * tjt@users.sourceforge.net
19  */
20 
21 /* Triplane Turmoil menusystem */
22 
23 #include "io/trip_io.h"
24 #include "triplane.h"
25 #include "tripmenu.h"
26 #include <SDL.h>
27 #include <time.h>
28 #include <string.h>
29 #include "io/joystick.h"
30 #include "io/sdl_compat.h"
31 #include "util/wutil.h"
32 #include "world/plane.h"
33 #include "world/tripaudio.h"
34 #include "settings.h"
35 
36 extern int miss_pl_x[16];
37 extern int miss_pl_y[16];
38 
39 char mission_description[80 * 16];
40 char mission_lines[16][80];
41 int mission_pixels[16];
42 int mission_headline_pixels;
43 
44 int aces_number_of_entries;
45 int aces_score[MAX_PLAYERS_IN_ROSTER];
46 
47 
48 #define CHARS_PER_LINE 70
49 #define LINELENGHT 100
50 
51 sb_mod_file *national_mod = NULL;
52 
53 char rank_names[6][10] = {
54     "2nd Lt.",
55     "1st Lt.",
56     "Capt.",
57     "Major",
58     "Lt Col.",
59     "Colonel"
60 };
61 
62 /**************************** Functions ***************************************/
63 
show_feat5(void)64 void show_feat5(void) {
65     Bitmap *feat5;
66     feat5 = new Bitmap("FEAT5");
67     int n1 = 0, n2 = 0;
68     int x, y;
69 
70     wait_mouse_relase();
71 
72     feat5->info(&x, &y);
73 
74     feat5->blit((320 - x) >> 1, (200 - y) >> 1);
75     do_all();
76 
77     while (!(n1 || n2)) {
78         koords(&x, &y, &n1, &n2);
79 
80     }
81 
82 
83     wait_mouse_relase();
84 
85 
86 }
87 
get_rank(int player)88 int get_rank(int player) {
89     int l, l2, l3;
90 
91     l = roster[player].solo_mis_flown + roster[player].multi_mis_flown;
92 
93     for (l2 = 0; l2 < 4; l2++)
94         for (l3 = 0; l3 < 6; l3++)
95             l += roster[player].solo_mis_scores[l2][l3];
96 
97     l += roster[player].solo_mis_totals >> 2;
98     l += roster[player].multi_mis_success * 3;
99     l += roster[player].multi_mis_drops * 5;
100 
101     if (l < 1000)
102         return 0;
103     if (l < 5000)
104         return 1;
105     if (l < 10000)
106         return 2;
107     if (l < 20000)
108         return 3;
109     if (l < 50000)
110         return 4;
111 
112     return 5;
113 
114 
115 }
116 
calculate_multitotal(int player)117 int calculate_multitotal(int player) {
118     int ts = 0;
119 
120     if (!roster[player].pilotname[0])
121         return 0;
122 
123     ts += roster[player].multi_mis_flown;
124     ts += roster[player].multi_mis_success * 10;
125     ts += roster[player].multi_mis_drops * 4;
126     ts -= roster[player].multi_mis_dropped;
127     ts -= roster[player].multi_mis_shotsf / 128;
128     ts += roster[player].multi_mis_shotshit / 60;
129     ts -= roster[player].multi_mis_bombs / 12;
130     ts += roster[player].multi_mis_bombshit / 6;
131 
132     return ts;
133 }
134 
sort_and_show(int percent)135 void sort_and_show(int percent) {
136     int alkuosa, loppuosa;
137     int flag = 1;
138     int aces_number[MAX_PLAYERS_IN_ROSTER];
139     int c;
140     int temp;
141 
142     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++)
143         aces_number[c] = c;
144 
145 
146     while (flag) {
147         flag = 0;
148 
149         for (c = 0; c < (aces_number_of_entries - 1); c++) {
150             if (aces_score[c] < aces_score[c + 1]) {
151                 flag = 1;
152 
153                 temp = aces_score[c];
154                 aces_score[c] = aces_score[c + 1];
155                 aces_score[c + 1] = temp;
156 
157                 temp = aces_number[c];
158                 aces_number[c] = aces_number[c + 1];
159                 aces_number[c + 1] = temp;
160 
161             }
162         }
163     }
164 
165     if (aces_number_of_entries > 10)
166         aces_number_of_entries = 10;
167 
168     int c2 = 0;
169     for (c = 0; c < aces_number_of_entries; c++) {
170         if (!aces_score[c])
171             continue;
172 
173         frost->printf(85, 90 + c2 * 9, "%2d.", c2 + 1);
174         frost->printf(95, 90 + c2 * 9, "%-35s", roster[aces_number[c]].pilotname);
175         frost->unscale();
176         if (!percent)
177             frost->printf(190, 90 + c2 * 9, "%6d", aces_score[c]);
178         else {
179             alkuosa = aces_score[c] / 100;
180             loppuosa = aces_score[c] - alkuosa * 100;
181             loppuosa /= 10;
182             frost->printf(190, 90 + c2 * 9, "%d.%d%%", alkuosa, loppuosa);
183         }
184         frost->scale();
185         c2++;
186     }
187 }
188 
aces_grand_total(void)189 void aces_grand_total(void) {
190     int c;
191 
192 
193     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
194         if (!roster[c].pilotname[0])
195             break;
196 
197         aces_score[c] = calculate_multitotal(c) + roster[c].solo_mis_totals;
198 
199     }
200 
201     if (!c) {
202         frost->printf(100, 100, "No active pilots present.");
203 
204     } else {
205         aces_number_of_entries = c;
206         sort_and_show();
207 
208     }
209 
210 }
211 
aces_multi_total(void)212 void aces_multi_total(void) {
213     int c;
214 
215     frost->printf(90, 45, "Multiplayer TOP10");
216 
217     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
218         if (!roster[c].pilotname[0])
219             break;
220 
221         aces_score[c] = calculate_multitotal(c);
222 
223     }
224 
225     if (!c) {
226         frost->printf(100, 100, "No active pilots present.");
227 
228     } else {
229         aces_number_of_entries = c;
230         sort_and_show();
231 
232     }
233 
234 }
235 
aces_solo_total(void)236 void aces_solo_total(void) {
237     int c;
238 
239     frost->printf(90, 45, "Sologame TOP10");
240 
241     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
242         if (!roster[c].pilotname[0])
243             break;
244 
245         aces_score[c] = roster[c].solo_mis_totals;
246 
247     }
248 
249     if (!c) {
250         frost->printf(100, 100, "No active pilots present.");
251 
252     } else {
253         aces_number_of_entries = c;
254         sort_and_show();
255 
256     }
257 
258 }
259 
aces_triggerhappy(void)260 void aces_triggerhappy(void) {
261     int c;
262 
263     frost->printf(90, 45, "The most triggerhappy pilots");
264 
265     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
266         if (!roster[c].pilotname[0])
267             break;
268 
269         aces_score[c] = roster[c].solo_mis_shotsf + roster[c].multi_mis_shotsf;
270 
271     }
272 
273     if (!c) {
274         frost->printf(100, 100, "No active pilots present.");
275 
276     } else {
277         aces_number_of_entries = c;
278         sort_and_show();
279 
280     }
281 
282 }
283 
aces_bombdropper(void)284 void aces_bombdropper(void) {
285     int c;
286 
287     frost->printf(90, 45, "Bombusers TOP10");
288 
289     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
290         if (!roster[c].pilotname[0])
291             break;
292 
293         aces_score[c] = roster[c].solo_mis_bombs + roster[c].multi_mis_bombs;
294 
295     }
296 
297     if (!c) {
298         frost->printf(100, 100, "No active pilots present.");
299 
300     } else {
301         aces_number_of_entries = c;
302         sort_and_show();
303 
304     }
305 
306 }
307 
aces_shotaccuracy(void)308 void aces_shotaccuracy(void) {
309     int c;
310 
311     frost->printf(90, 45, "The most accurate shooters");
312 
313     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
314         if (!roster[c].pilotname[0])
315             break;
316 
317         if ((roster[c].solo_mis_shotsf + roster[c].multi_mis_shotsf) < 1000)
318             aces_score[c] = 0;
319         else
320             aces_score[c] = (roster[c].solo_mis_shotshit + roster[c].multi_mis_shotshit) * 10000 / (roster[c].solo_mis_shotsf + roster[c].multi_mis_shotsf);
321 
322     }
323 
324     if (!c) {
325         frost->printf(100, 100, "No active pilots present.");
326 
327     } else {
328         aces_number_of_entries = c;
329         sort_and_show(1);
330 
331     }
332 
333 }
334 
aces_bombaccuracy(void)335 void aces_bombaccuracy(void) {
336     int c;
337 
338     frost->printf(90, 45, "The most accurate bombers");
339 
340     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
341         if (!roster[c].pilotname[0])
342             break;
343 
344         if ((roster[c].solo_mis_bombs + roster[c].multi_mis_bombs) < 100)
345             aces_score[c] = 0;
346         else
347             aces_score[c] = (roster[c].solo_mis_bombshit + roster[c].multi_mis_bombshit) * 10000 / (roster[c].solo_mis_bombs + roster[c].multi_mis_bombs);
348 
349     }
350 
351     if (!c) {
352         frost->printf(100, 100, "No active pilots present.");
353 
354     } else {
355         aces_number_of_entries = c;
356         sort_and_show(1);
357 
358     }
359 
360 }
361 
aces_mostkills(void)362 void aces_mostkills(void) {
363     int c;
364 
365     frost->printf(90, 45, "Drops TOP10");
366 
367     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
368         if (!roster[c].pilotname[0])
369             break;
370 
371         aces_score[c] = roster[c].solo_mis_drops + roster[c].multi_mis_drops;
372 
373     }
374 
375     if (!c) {
376         frost->printf(100, 100, "No active pilots present.");
377 
378     } else {
379         aces_number_of_entries = c;
380         sort_and_show();
381 
382     }
383 
384 }
385 
aces_decoy(void)386 void aces_decoy(void) {
387     int c;
388 
389     frost->printf(90, 45, "The most active decoys");
390 
391     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
392         if (!roster[c].pilotname[0])
393             break;
394 
395         aces_score[c] = roster[c].solo_mis_dropped + roster[c].multi_mis_dropped;
396 
397     }
398 
399     if (!c) {
400         frost->printf(100, 100, "No active pilots present.");
401 
402     } else {
403         aces_number_of_entries = c;
404         sort_and_show();
405 
406     }
407 
408 }
409 
aces_totalmissions(void)410 void aces_totalmissions(void) {
411     int c;
412 
413     frost->printf(90, 45, "The most missions flown");
414 
415     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
416         if (!roster[c].pilotname[0])
417             break;
418 
419         aces_score[c] = roster[c].solo_mis_flown + roster[c].multi_mis_flown;
420 
421     }
422 
423     if (!c) {
424         frost->printf(100, 100, "No active pilots present.");
425 
426     } else {
427         aces_number_of_entries = c;
428         sort_and_show();
429 
430     }
431 
432 }
433 
434 
aces_one_solo(int country,int mission)435 void aces_one_solo(int country, int mission) {
436     char country_names_genetive[4][15] = {
437         "German", "Finnish", "English", "Japanese"
438     };
439 
440     int c;
441 
442     frost->printf(82, 45, "%d. %s mission (%s)", mission + 1, country_names_genetive[country], mission_names[country * 6 + mission]);
443 
444     for (c = 0; c < MAX_PLAYERS_IN_ROSTER; c++) {
445         if (!roster[c].pilotname[0])
446             break;
447 
448         aces_score[c] = roster[c].solo_mis_scores[country][mission];
449 
450     }
451 
452     if (!c) {
453         frost->printf(100, 100, "No active pilots present.");
454 
455     } else {
456         aces_number_of_entries = c;
457         sort_and_show();
458 
459     }
460 
461 
462 }
463 
464 
show_descriptions(int number)465 void show_descriptions(int number) {
466     int c;
467 
468     frost->printf((320 - mission_headline_pixels) >> 1, 24, "%s", mission_names[number]);
469 
470     for (c = 0; c < 16; c++) {
471         if (!mission_lines[c][0])
472             break;
473         frost->printf((320 - mission_pixels[c]) >> 1, 40 + c * 10, "%s", mission_lines[c]);
474 
475     }
476 
477 }
478 
load_descriptions(int number)479 void load_descriptions(int number) {
480     char *temp_storage;
481     int c;
482     int locator = 0;
483     int index = 0;
484     char ch;
485     int desclenght;
486     int wordcount;
487 
488 
489     if (!dksopen("midesc")) {
490         printf("Unable to locate data midesc\n");
491         exit(1);
492 
493     }
494 
495     temp_storage = (char *) walloc(dkssize());
496     dksread(temp_storage, dkssize());
497 
498     for (c = 0; c <= number; c++) {
499 
500         while (temp_storage[locator] != '#')
501             locator++;
502 
503         locator++;
504     }
505 
506     while (temp_storage[locator] != '#' && locator < dkssize()) {
507         ch = temp_storage[locator];
508 
509         if (ch == 0xa) {
510             mission_description[index] = ' ';
511             index++;
512 
513         } else {
514             if (ch != 0xd) {
515                 mission_description[index] = temp_storage[locator];
516                 index++;
517             }
518 
519         }
520 
521         locator++;
522     }
523 
524     mission_description[index] = 0;
525     desclenght = index + 1;
526 
527     dksclose();
528 
529     locator = 0;
530     int line_going = 0;
531     int chars_to_copy;
532 
533     while (locator < desclenght) {
534         wordcount = 0;
535 
536         for (index = 0; index < CHARS_PER_LINE; index++) {
537             if (index + locator >= desclenght) {
538                 wordcount = index - 1;
539 
540             } else {
541                 if (mission_description[index + locator] == ' ') {
542                     wordcount = index;
543                 }
544 
545             }
546 
547         }
548 
549         chars_to_copy = wordcount;
550 
551         for (index = 0; index < chars_to_copy; index++) {
552             mission_lines[line_going][index] = mission_description[index + locator];
553 
554         }
555 
556         mission_lines[line_going][index] = 0;
557 
558         locator += chars_to_copy;
559         line_going++;
560     }
561 
562     for (index = line_going; index < 16; index++) {
563         mission_lines[line_going][0] = 0;
564         mission_pixels[line_going] = 0;
565     }
566 
567     for (index = 0; index < line_going; index++) {
568         mission_pixels[index] = frost->printf(0, 0, "%s", mission_lines[index]);
569 
570 
571     }
572 
573     mission_headline_pixels = frost->printf(0, 0, "%s", mission_names[number]);
574 
575     tyhjaa_vircr();
576 
577     wfree(temp_storage);
578 
579 
580 }
581 
solo_player_menu(void)582 int solo_player_menu(void) {
583     char facenames[4][7] = { "GERFAC", "FINFAC", "ENGFAC", "JAPFAC" };
584     char missionnames[4][7] = { "MISSI0", "MISSI1", "MISSI2", "MISSI3" };
585     char modnames[4][7] = { "mgerma", "mfinla", "mengla", "mjapan" };
586 
587     Bitmap *misboa = 0;
588     Bitmap *misbak = 0;
589     Bitmap *face = 0;
590     Bitmap *mission = 0;
591     int flag = 0;
592     int l;
593     int x, y, n1, n2;
594 
595     int highest_mission = 0;
596 
597     if (findparameter("-solomenumission")) {
598         sscanf(parametrit[findparameter("-solomenumission") + 1], "%d", &mission_re_fly);
599     }
600 
601     if (mission_re_fly == 999) {
602         mission_re_fly = -1;
603 
604     }
605 
606     for (l = 0; l < 5; l++) {
607         if (roster[config.player_number[solo_country]].solo_mis_scores[solo_country][l])
608             highest_mission = l + 1;
609 
610     }
611 
612     if (mission_re_fly != -1) {
613         solo_mission = mission_re_fly;
614         flag = 3;
615 
616     } else {
617         misboa = new Bitmap("MISBOA");
618         misbak = new Bitmap("MISBAK", 0);
619 
620         face = new Bitmap(facenames[solo_country]);
621         mission = new Bitmap(missionnames[solo_country]);
622 
623         misbak->blit(0, 0);
624         misboa->blit(9, 4);
625         face->blit(0, 0);
626         mission->blit(22, 19, 0, 0, 319, 46 + highest_mission * 27);
627 
628         standard_background = new Bitmap(0, 0, 320, 200);
629         do_all_clear();
630     }
631 
632     if ((mission_re_fly == -1) && is_there_sound && config.music_on && !findparameter("-nomusic")) {
633         sdl_stop_music();
634         national_mod = sdl_load_mod_file(modnames[solo_country]);
635         if (national_mod == NULL) {
636             printf("Error locating music.\n");
637             exit(1);
638 
639         }
640 
641         sdl_play_music(national_mod);
642 
643     }
644 
645     while (flag == 0) {
646         if (kbhit() && getch() == SDLK_ESCAPE) {
647             flag = 2;
648         }
649 
650         koords(&x, &y, &n1, &n2);
651 
652         cursor->blit(x - 10, y - 10);
653         do_all_clear();
654 
655         if (n1 || n2) {
656             for (l = 0; l <= highest_mission; l++) {
657                 if (x >= 23 && x <= 125 && y > (20 + 27 * l) && y < (45 + 27 * l)) {
658                     solo_mission = l;
659                     if (n1)
660                         flag = 1;
661                     else
662                         flag = 3;
663                 }
664 
665 
666             }
667 
668             if (x >= 140) {
669                 flag = 2;
670 
671             }
672 
673 
674         }
675 
676 
677     }
678 
679     if (mission_re_fly == -1) {
680         delete misboa;
681         delete misbak;
682         delete face;
683         delete mission;
684         delete standard_background;
685         standard_background = NULL;
686     }
687 
688     if (flag == 1)
689         random_fade_out();
690     else {
691         tyhjaa_vircr();
692         do_all();
693 
694     }
695 
696     wait_mouse_relase(1);
697     switch (flag) {
698 
699     case 1:
700 
701         return 1;
702 
703     case 3:
704         if ((mission_re_fly == -1) && is_there_sound && config.music_on && !findparameter("-nomusic")) {
705             sdl_stop_music();
706             sdl_free_mod_file(national_mod);
707 
708         }
709         return 2;
710 
711     case 2:
712         if (is_there_sound && config.music_on && !findparameter("-nomusic")) {
713             sdl_stop_music();
714             sdl_free_mod_file(national_mod);
715 
716         }
717 
718         return 0;
719 
720     default:
721 
722         return 0;
723 
724     }
725 
726 
727 }
728 
roster_menu(void)729 void roster_menu(void) {
730     int exit_flag = 0;
731     int x, y, n1, n2;
732     int menuselect;
733     static int number = -1;
734     int keysetmode = 0;
735     int help_on = 0;
736     char ch;
737     Bitmap *help;
738     Bitmap *rosteri;
739     Bitmap *buttl, *buttr;
740     Bitmap *setk1, *setk2;
741     Bitmap *medal2[4];
742     Bitmap *medal3;
743     Bitmap *medal5;
744     Bitmap *temp;
745     Bitmap *ribbon[6];
746     int l, l2, l3, l4;
747     int rank;
748 
749     if (number == -1 && roster[0].pilotname[0])
750         number = 0;
751 
752     rosteri = new Bitmap("ROSTER");
753     buttl = new Bitmap("BUTTL");        // 187,174
754     buttr = new Bitmap("BUTTR");        // 205,174
755     setk1 = new Bitmap("SETK1");
756     setk2 = new Bitmap("SETK2");
757     help = new Bitmap("HELP2");
758     temp = new Bitmap("MEDAL2");
759     medal3 = new Bitmap("MEDAL3");
760 
761     for (l = 0; l < 4; l++) {
762         medal2[l] = new Bitmap(1 + l * 17, 1, 16, 28, temp);
763 
764     }
765 
766     medal5 = new Bitmap(1 + 4 * 17, 1, 16, 28, temp);
767 
768     delete temp;
769 
770     temp = new Bitmap("RIBBON");
771 
772     for (l = 0; l < 6; l++)
773         ribbon[l] = new Bitmap(36 * l, 0, 35, 8, temp);
774 
775     delete temp;
776 
777     hiiri_to(264, 109);
778 
779     while (!exit_flag) {
780         if (kbhit()) {
781             if (!(ch = getch())) {
782                 ch = getch();
783                 if (ch == 59)
784                     wtoggle(&help_on);
785 
786             } else {
787                 if (ch == 27)
788                     exit_flag = 1;
789             }
790 
791         }
792 
793         koords(&x, &y, &n1, &n2);
794 
795         if (number != -1) {
796             if (!keysetmode) {
797                 print_clear_roster(rosteri);
798                 print_filled_roster(number);
799                 setk1->blit(286, 190);
800 
801             } else {
802                 rosteri->blit(0, 0);
803                 grid2->printf(125, 50, "%s %s", rank_names[get_rank(number)], roster[number].pilotname);
804                 grid2->printf(152, 40, "Keys Info");
805                 setk2->blit(286, 190);
806                 setk1->blit(125, 172);
807 
808                 frost->printf(125, 93, "Up [%s]\nDown [%s]\nRoll [%s]",
809                               SDL_GetKeyName((SDLKey) roster[number].up), SDL_GetKeyName((SDLKey) roster[number].down),
810                               SDL_GetKeyName((SDLKey) roster[number].roll));
811                 frost->printf(170, 114, "Power [%s]\nBombs [%s]\nGuns [%s]\n", SDL_GetKeyName((SDLKey) roster[number].power),
812                               SDL_GetKeyName((SDLKey) roster[number].bombs), SDL_GetKeyName((SDLKey) roster[number].guns));
813 
814             }
815         } else {
816             rosteri->blit(0, 0);
817 
818         }
819 
820         if (number != -1)
821             for (l = 0; l < 4; l++)
822                 if (roster[number].solo_mis_scores[l][5])
823                     medal2[l]->blit(127 + l * 20, 5);
824 
825 
826         if (number != -1 && roster[number].solo_mis_drops + roster[number].multi_mis_drops) {
827             l4 = 1;
828             l3 = roster[number].solo_mis_drops * 2 - roster[number].solo_mis_dropped;
829             l3 += roster[number].multi_mis_drops * 3 - roster[number].multi_mis_dropped * 2;
830 
831             for (l = 0; l < MAX_PLAYERS_IN_ROSTER; l++) {
832                 if (!roster[l].pilotname[0])
833                     break;
834 
835                 if (l == number)
836                     continue;
837 
838                 if (!(roster[l].solo_mis_drops + roster[l].multi_mis_drops))
839                     continue;
840 
841                 l2 = roster[l].solo_mis_drops * 2 - roster[l].solo_mis_dropped;
842                 l2 += roster[l].multi_mis_drops * 3 - roster[l].multi_mis_dropped * 2;
843 
844                 if (l2 >= l3) {
845                     l4 = 0;
846                     break;
847                 }
848             }
849 
850             if (l4 && l3 > 0) {
851                 medal3->blit(207, 5);
852 
853             }
854         }
855 
856 
857         if (number != -1 && (roster[number].multi_mis_flown + roster[number].solo_mis_flown) >= 1000)
858             medal5->blit(227, 5);
859 
860         if (number != -1) {
861             rank = get_rank(number);
862 
863             for (l = 0; l <= rank; l++) {
864                 ribbon[l]->blit(283, 80 + l * 9);
865 
866             }
867 
868 
869         }
870 
871         menuselect = 0;
872 
873         if (!keysetmode)
874             if (x >= 257 && x <= 272 && y >= 53 && y <= 173) {
875                 frost->printf(15, 24, "Create new\n pilot");
876                 menuselect = 1;
877             }
878 
879         if (x >= 36 && x <= 80 && y >= 118 && y <= 177) {
880             frost->printf(15, 24, "Back to\n main menu");
881             menuselect = 2;
882         }
883 
884         if (x >= 205 && x <= 221 && y >= 174 && y <= 182) {
885             frost->printf(15, 24, "Next pilot");
886             menuselect = 3;
887         }
888 
889         if (x >= 187 && x <= 203 && y >= 174 && y <= 182) {
890             frost->printf(15, 24, "Previous pilot");
891             menuselect = 4;
892         }
893 
894         if (!keysetmode)
895             if (x >= 263 && x <= 301 && y >= 8 && y <= 55) {
896                 frost->printf(15, 24, "Erase pilot");
897                 menuselect = 5;
898             }
899 
900         if (x >= 286 && x <= 318 && y >= 190 && y <= 198) {
901             frost->printf(15, 24, "Toggle setkeys\n mode");
902             menuselect = 6;
903         }
904 
905         if (keysetmode && x >= 125 && x <= 157 && y >= 172 && y <= 180) {
906             frost->printf(15, 24, "Set Sologame\n Keys");
907             menuselect = 7;
908         }
909 
910         if (help_on)
911             help->blit(0, 0);
912 
913         cursor->blit(x - 10, y - 10);
914         do_all();
915 
916         if ((n1 || n2) && menuselect) {
917             switch (menuselect) {
918             case 1:
919                 for (number = 0; number < MAX_PLAYERS_IN_ROSTER; number++)
920                     if (!roster[number].pilotname[0])
921                         break;
922 
923                 if (number == MAX_PLAYERS_IN_ROSTER) {
924                     number = 99;
925                     break;
926                 }
927 
928                 print_clear_roster(rosteri);
929                 frost->printf(15, 24, "Type name of\nthe pilot\nand press\nenter.");
930 
931                 roster[number].solo_mis_flown = 0;
932                 roster[number].solo_mis_success = 0;
933                 roster[number].solo_mis_drops = 0;
934                 roster[number].solo_mis_shotsf = 0;
935                 roster[number].solo_mis_shotshit = 0;
936                 roster[number].solo_mis_bombs = 0;
937                 roster[number].solo_mis_bombshit = 0;
938                 roster[number].solo_mis_dropped = 0;
939                 roster[number].solo_mis_totals = 0;
940 
941                 roster[number].multi_mis_flown = 0;
942                 roster[number].multi_mis_success = 0;
943                 roster[number].multi_mis_drops = 0;
944                 roster[number].multi_mis_shotsf = 0;
945                 roster[number].multi_mis_shotshit = 0;
946                 roster[number].multi_mis_bombs = 0;
947                 roster[number].multi_mis_bombshit = 0;
948                 roster[number].multi_mis_dropped = 0;
949                 roster[number].multi_mis_totals = 0;
950 
951                 for (l = 0; l < 4; l++)
952                     for (l2 = 0; l2 < 6; l2++)
953                         roster[number].solo_mis_scores[l][l2] = 0;
954 
955                 roster[number].up = SDLK_x;
956                 roster[number].down = SDLK_w;
957                 roster[number].roll = SDLK_s;
958                 roster[number].power = SDLK_TAB;
959                 roster[number].guns = SDLK_2;
960                 roster[number].bombs = SDLK_1;
961 
962                 grid2->scanf(125, 50, roster[number].pilotname, 21);
963                 if (!roster[number].pilotname[0]) {
964                     number--;
965                     break;
966                 }
967 
968                 break;
969 
970             case 2:
971                 if (n1)
972                     random_fade_out();
973                 else {
974                     tyhjaa_vircr();
975                     do_all();
976                 }
977 
978                 exit_flag = 1;
979                 break;
980 
981             case 4:
982                 buttl->blit(187, 174);
983                 cursor->blit(x - 10, y - 10);
984                 do_all();
985                 wait_mouse_relase();
986                 if (number <= 0)
987                     break;
988                 number--;
989                 break;
990 
991             case 3:
992                 buttr->blit(205, 174);
993                 cursor->blit(x - 10, y - 10);
994                 do_all();
995                 wait_mouse_relase();
996                 number++;
997                 if ((number == MAX_PLAYERS_IN_ROSTER) | (roster[number].pilotname[0] == 0))
998                     number--;
999                 break;
1000 
1001             case 6:
1002                 setk2->blit(286, 190);
1003                 cursor->blit(x - 10, y - 10);
1004                 do_all();
1005                 wait_mouse_relase();
1006                 wtoggle(&keysetmode);
1007                 break;
1008 
1009             case 7:
1010                 setk2->blit(125, 172);
1011                 cursor->blit(x - 10, y - 10);
1012                 do_all();
1013                 wait_mouse_relase();
1014 
1015                 rosteri->blit(0, 0);
1016 
1017                 frost->printf(125, 100, "Key for upward turn [%s]", SDL_GetKeyName((SDLKey) roster[number].up));
1018                 do_all();
1019 
1020                 roster[number].up = select_key(number, roster[number].up);
1021 
1022                 rosteri->blit(0, 0);
1023                 frost->printf(125, 100, "Key for downward turn [%s]", SDL_GetKeyName((SDLKey) roster[number].down));
1024                 do_all();
1025 
1026                 roster[number].down = select_key(number, roster[number].down);
1027 
1028                 rosteri->blit(0, 0);
1029                 frost->printf(125, 100, "Key for roll [%s]", SDL_GetKeyName((SDLKey) roster[number].roll));
1030                 do_all();
1031 
1032                 roster[number].roll = select_key(number, roster[number].roll);
1033 
1034                 rosteri->blit(0, 0);
1035 
1036                 frost->printf(125, 100, "Key for engine power [%s]", SDL_GetKeyName((SDLKey) roster[number].power));
1037                 do_all();
1038 
1039                 roster[number].power = select_key(number, roster[number].power);
1040 
1041                 rosteri->blit(0, 0);
1042 
1043                 frost->printf(125, 100, "Key for bomb drop [%s]", SDL_GetKeyName((SDLKey) roster[number].bombs));
1044                 do_all();
1045 
1046                 roster[number].bombs = select_key(number, roster[number].bombs);
1047 
1048                 rosteri->blit(0, 0);
1049 
1050                 frost->printf(125, 100, "Key for guns [%s]", SDL_GetKeyName((SDLKey) roster[number].guns));
1051                 do_all();
1052 
1053                 roster[number].guns = select_key(number, roster[number].guns);
1054                 break;
1055 
1056             case 5:
1057                 if (number == -1)
1058                     break;
1059 
1060                 if (!small_warning(" You are about to permanently\n" " remove this pilot.\n" "\n" "       Are you sure?"))
1061                     break;
1062 
1063                 for (l = 0; l < 4; l++) {
1064                     if (config.player_number[l] == number) {
1065                         config.player_number[l] = -1;
1066                         config.player_type[l] = 0;
1067 
1068                     }
1069 
1070                 }
1071 
1072                 l = number + 1;
1073                 while (roster[l].pilotname[0]) {
1074                     strcpy(roster[l - 1].pilotname, roster[l].pilotname);
1075                     roster[l - 1].solo_mis_flown = roster[l].solo_mis_flown;
1076                     roster[l - 1].solo_mis_success = roster[l].solo_mis_success;
1077                     roster[l - 1].solo_mis_drops = roster[l].solo_mis_drops;
1078                     roster[l - 1].solo_mis_shotsf = roster[l].solo_mis_shotsf;
1079                     roster[l - 1].solo_mis_shotshit = roster[l].solo_mis_shotshit;
1080                     roster[l - 1].solo_mis_bombs = roster[l].solo_mis_bombs;
1081                     roster[l - 1].solo_mis_bombshit = roster[l].solo_mis_bombshit;
1082                     roster[l - 1].solo_mis_dropped = roster[l].solo_mis_dropped;
1083                     roster[l - 1].solo_mis_totals = roster[l].solo_mis_totals;
1084 
1085 
1086                     for (l3 = 0; l3 < 4; l3++)
1087                         for (l2 = 0; l2 < 6; l2++)
1088                             roster[l - 1].solo_mis_scores[l3][l2] = roster[l].solo_mis_scores[l3][l2];
1089 
1090                     roster[l - 1].multi_mis_flown = roster[l].multi_mis_flown;
1091                     roster[l - 1].multi_mis_success = roster[l].multi_mis_success;
1092                     roster[l - 1].multi_mis_drops = roster[l].multi_mis_drops;
1093                     roster[l - 1].multi_mis_shotsf = roster[l].multi_mis_shotsf;
1094                     roster[l - 1].multi_mis_shotshit = roster[l].multi_mis_shotshit;
1095                     roster[l - 1].multi_mis_bombs = roster[l].multi_mis_bombs;
1096                     roster[l - 1].multi_mis_bombshit = roster[l].multi_mis_bombshit;
1097                     roster[l - 1].multi_mis_dropped = roster[l].multi_mis_dropped;
1098                     roster[l - 1].multi_mis_totals = roster[l].multi_mis_totals;
1099 
1100                     roster[l - 1].up = roster[l].up;
1101                     roster[l - 1].down = roster[l].down;
1102                     roster[l - 1].roll = roster[l].roll;
1103                     roster[l - 1].power = roster[l].power;
1104                     roster[l - 1].guns = roster[l].guns;
1105                     roster[l - 1].bombs = roster[l].bombs;
1106 
1107 
1108                     l++;
1109                 }
1110                 roster[l - 1].pilotname[0] = 0;
1111                 number--;
1112                 if (roster[0].pilotname[0] && number == -1)
1113                     number = 0;
1114 
1115                 wait_mouse_relase();
1116                 break;
1117 
1118 
1119 
1120             }
1121         }
1122     }
1123 
1124     delete help;
1125     delete buttl;
1126     delete buttr;
1127     delete setk1;
1128     delete setk2;
1129     delete rosteri;
1130     for (l = 0; l < 4; l++)
1131         delete medal2[l];
1132     delete medal3;
1133     delete medal5;
1134 
1135     for (l = 0; l < 6; l++)
1136         delete ribbon[l];
1137 
1138     wait_mouse_relase();
1139 
1140 
1141 }
1142 
options_menu(void)1143 void options_menu(void) {
1144     int exit_flag = 0;
1145     int x, y, n1, n2;
1146     int menuselect;
1147     int menusubselect = 0;
1148     Bitmap *optionme;
1149     Bitmap *kohta[4];
1150     Bitmap *right, *wrong;
1151     Bitmap *opt1, *opt2;
1152     int optimode = 0;
1153     int l;
1154 
1155     char selitykset[4][80] = {
1156         "This form has questions about your vision.",
1157         "This form has questions about your hearing.",
1158         "Phychological questions about flying.",
1159         "Questions about hostile environments."
1160     };
1161 
1162     optionme = new Bitmap("OPTION");
1163     right = new Bitmap("RIGHT");
1164     wrong = new Bitmap("WRONG");
1165     kohta[3] = new Bitmap("OPTI1");
1166     kohta[2] = new Bitmap("OPTI2");
1167     kohta[1] = new Bitmap("OPTI3");
1168     kohta[0] = new Bitmap("OPTI4");
1169     opt1 = new Bitmap("OPT1");
1170     opt2 = new Bitmap("OPT2");
1171 
1172     while (!exit_flag) {
1173         if (kbhit())
1174             if (getch() == 27)
1175                 exit_flag = 1;
1176 
1177         koords(&x, &y, &n1, &n2);
1178         optionme->blit(0, 0);
1179         kohta[3 - optimode]->blit(248, 13);
1180         frost->printf(73, 43, "%s", selitykset[optimode]);
1181 
1182         switch (optimode) {
1183         case 0:
1184             frost->printf(73, 60, "Shots visible?");
1185             frost->printf(73, 70, "AAA shots visible?");
1186             frost->printf(73, 80, "AA-MG shots visible?");
1187             frost->printf(73, 90, "Flags?");
1188             frost->printf(73, 100, "Structure flames?");
1189             frost->printf(73, 110, "Use 800x600 window\nin multiplayergame?");
1190             frost->printf(73, 130, "Structure smoke?");
1191 
1192             for (l = 0; l < 6; l++) {
1193                 boxi(214, 60 + l * 10, 221, 68 + l * 10, 0);
1194                 boxi(224, 60 + l * 10, 231, 68 + l * 10, 0);
1195             }
1196 
1197             boxi(214, 130, 221, 138, 0);
1198             boxi(224, 130, 231, 138, 0);
1199 
1200             if (config.shots_visible)
1201                 right->blit(215, 60);
1202             else
1203                 wrong->blit(225, 60);
1204 
1205             if (config.it_shots_visible)
1206                 right->blit(215, 70);
1207             else
1208                 wrong->blit(225, 70);
1209 
1210             if (config.aa_mg_shots_visible)
1211                 right->blit(215, 80);
1212             else
1213                 wrong->blit(225, 80);
1214 
1215             if (config.flags)
1216                 right->blit(215, 90);
1217             else
1218                 wrong->blit(225, 90);
1219 
1220             if (config.flames)
1221                 right->blit(215, 100);
1222             else
1223                 wrong->blit(225, 100);
1224 
1225             if (config.structure_smoke)
1226                 right->blit(215, 130);
1227             else
1228                 wrong->blit(225, 130);
1229 
1230 
1231             if (config.svga)
1232                 right->blit(215, 110);
1233             else
1234                 wrong->blit(225, 110);
1235 
1236             break;
1237 
1238         case 1:
1239 
1240             frost->printf(73, 60, "Sounds on?");
1241             frost->printf(73, 70, "Musics on?");
1242             frost->printf(73, 80, "SFX on?");
1243             frost->printf(73, 90, "Explosion sounds?");
1244             frost->printf(73, 100, "Gunfire sounds?");
1245             frost->printf(73, 110, "AAA-fire sounds?");
1246             frost->printf(73, 120, "Water splash sound?");
1247             frost->printf(73, 130, "Infantry sounds?");
1248 
1249             for (l = 0; l < 8; l++) {
1250                 boxi(214, 60 + l * 10, 221, 68 + l * 10, 0);
1251                 boxi(224, 60 + l * 10, 231, 68 + l * 10, 0);
1252             }
1253 
1254             if (config.sound_on)
1255                 right->blit(215, 60);
1256             else
1257                 wrong->blit(225, 60);
1258 
1259             if (config.music_on)
1260                 right->blit(215, 70);
1261             else
1262                 wrong->blit(225, 70);
1263 
1264             if (config.sfx_on)
1265                 right->blit(215, 80);
1266             else
1267                 wrong->blit(225, 80);
1268 
1269             if (config.explosion_sounds)
1270                 right->blit(215, 90);
1271             else
1272                 wrong->blit(225, 90);
1273 
1274             if (config.gunshot_sounds)
1275                 right->blit(215, 100);
1276             else
1277                 wrong->blit(225, 100);
1278 
1279             if (config.ground_i_sounds)
1280                 right->blit(215, 110);
1281             else
1282                 wrong->blit(225, 110);
1283 
1284             if (config.splash)
1285                 right->blit(215, 120);
1286             else
1287                 wrong->blit(225, 120);
1288 
1289             if (config.infantry_sounds)
1290                 right->blit(215, 130);
1291             else
1292                 wrong->blit(225, 130);
1293 
1294 
1295             break;
1296 
1297         case 2:
1298 
1299             frost->printf(73, 60, "Do you want on/off power?");
1300             frost->printf(73, 70, "Do you want a reversed\n  powerswitch?");
1301 
1302             for (l = 0; l < 2; l++) {
1303                 boxi(214, 60 + l * 10, 221, 68 + l * 10, 0);
1304                 boxi(224, 60 + l * 10, 231, 68 + l * 10, 0);
1305             }
1306 
1307             if (config.poweronoff)
1308                 right->blit(215, 60);
1309             else
1310                 wrong->blit(225, 60);
1311 
1312             if (config.powerrev)
1313                 right->blit(215, 70);
1314             else
1315                 wrong->blit(225, 70);
1316 
1317             break;
1318 
1319         case 3:
1320 
1321             frost->printf(73, 60, "Are all planes the same?");
1322             frost->printf(73, 70, "Collisions on?");
1323             frost->printf(73, 80, "Flying parts hit plane?");
1324             frost->printf(73, 90, "Battle ends after n points");
1325             frost->printf(73, 100, "Alliances enabled?");
1326             frost->printf(73, 110, "AA-MGs?");
1327             frost->printf(73, 120, "AAAs?");
1328             frost->printf(73, 130, "Infantry?");
1329             frost->printf(73, 140, "Unlimited ammo?");
1330             frost->printf(73, 150, "Unlimited gas?");
1331 
1332             for (l = 0; l < 10; l++) {
1333                 if (l == 3)
1334                     continue;
1335                 boxi(214, 60 + l * 10, 221, 68 + l * 10, 0);
1336                 boxi(224, 60 + l * 10, 231, 68 + l * 10, 0);
1337             }
1338 
1339             if (config.all_planes_are) {
1340                 right->blit(215, 60);
1341                 opt1->blit(1, 1);
1342                 boxi(34, 10, 41, 18, 0);
1343                 boxi(34, 31, 41, 39, 0);
1344                 boxi(34, 52, 41, 60, 0);
1345                 boxi(34, 73, 41, 81, 0);
1346 
1347                 right->blit(35, config.all_planes_are * 21 - 11);
1348             } else
1349                 wrong->blit(225, 60);
1350 
1351             if (config.nocollision)
1352                 right->blit(215, 70);
1353             else
1354                 wrong->blit(225, 70);
1355 
1356             if (config.partcollision)
1357                 right->blit(215, 80);
1358             else
1359                 wrong->blit(225, 80);
1360 
1361             /*
1362                if(config.stop)
1363                right->blit(215,90);
1364                else
1365                wrong->blit(225,90);
1366              */
1367 
1368             if (config.stop)
1369                 frost->printf(216, 91, "%d", config.stop);
1370             else
1371                 frost->printf(216, 91, "UnLtd");
1372 
1373             if (config.alliance) {
1374                 right->blit(215, 100);
1375                 opt2->blit(1, 92);
1376                 boxi(5, 92 + config.alliance * 32 - 28, 53, 92 + config.alliance * 32 + 4, 38);
1377             } else
1378                 wrong->blit(225, 100);
1379 
1380             if (config.aa_mgs)
1381                 right->blit(215, 110);
1382             else
1383                 wrong->blit(225, 110);
1384 
1385             if (config.it_guns)
1386                 right->blit(215, 120);
1387             else
1388                 wrong->blit(225, 120);
1389 
1390             if (config.infantry)
1391                 right->blit(215, 130);
1392             else
1393                 wrong->blit(225, 130);
1394 
1395             if (config.unlimited_ammo)
1396                 right->blit(215, 140);
1397             else
1398                 wrong->blit(225, 140);
1399 
1400             if (config.unlimited_gas)
1401                 right->blit(215, 150);
1402             else
1403                 wrong->blit(225, 150);
1404 
1405             break;
1406         }
1407 
1408         menuselect = 0;
1409         /*if(x>=257 && x<=272 && y>=53 && y<=173)
1410            {
1411            frost->printf(15,24,"Create new\n pilot");
1412            menuselect=1;
1413            } */
1414 
1415         if (x >= 267 && x <= 301 && y >= 155 && y <= 190) {
1416             frost->printf(102, 26, "Back to main menu");
1417             menuselect = 2;
1418         }
1419 
1420         if (x >= 248 && x <= 260 && y >= 117 && y <= 145) {
1421             frost->printf(102, 26, "Change to visual settings");
1422             menuselect = 3;
1423 
1424         }
1425 
1426         if (x >= 248 && x <= 260 && y >= 80 && y <= 116) {
1427             frost->printf(102, 26, "Change to audio settings");
1428             menuselect = 4;
1429 
1430         }
1431 
1432         if (x >= 248 && x <= 260 && y >= 47 && y <= 79) {
1433             frost->printf(102, 26, "Change to general flying settings");
1434             menuselect = 5;
1435 
1436         }
1437 
1438         if (x >= 248 && x <= 260 && y >= 13 && y <= 46) {
1439             frost->printf(102, 26, "Change to multiplayer settings");
1440             menuselect = 6;
1441 
1442         }
1443 
1444         if (optimode == 0)
1445             if ((x >= 214 && x <= 221) || (x >= 224 && x <= 231)) {
1446                 if (x <= 221)
1447                     menusubselect = 1;
1448                 else
1449                     menusubselect = 0;
1450 
1451                 if (y >= 60 && y <= 68) {
1452                     // shots_visible
1453                     menuselect = 10;
1454 
1455                 }
1456 
1457                 if (y >= 70 && y <= 78) {
1458                     // it_shots_visible
1459                     menuselect = 11;
1460 
1461                 }
1462 
1463                 if (y >= 80 && y <= 88) {
1464                     // aa_mg_shots_visible
1465                     menuselect = 12;
1466 
1467                 }
1468 
1469                 if (y >= 90 && y <= 98) {
1470                     // flags
1471                     menuselect = 13;
1472 
1473                 }
1474 
1475                 if (y >= 100 && y <= 108) {
1476                     // flames
1477                     menuselect = 14;
1478 
1479                 }
1480 
1481                 if (y >= 130 && y <= 138) {
1482                     // structure_smoke
1483                     menuselect = 64;
1484 
1485                 }
1486 
1487                 if (y >= 110 && y <= 118) {
1488                     // svga
1489                     menuselect = 15;
1490 
1491                 }
1492 
1493 
1494             }
1495 
1496         if (optimode == 1)
1497             if ((x >= 214 && x <= 221) || (x >= 224 && x <= 231)) {
1498                 if (x <= 221)
1499                     menusubselect = 1;
1500                 else
1501                     menusubselect = 0;
1502 
1503                 if (y >= 60 && y <= 68) {
1504                     // sounds_on
1505                     menuselect = 16;
1506 
1507                 }
1508 
1509                 if (y >= 70 && y <= 78) {
1510                     // music_on
1511                     menuselect = 17;
1512 
1513                 }
1514 
1515                 if (y >= 80 && y <= 88) {
1516                     // sfx_on
1517                     menuselect = 18;
1518 
1519                 }
1520 
1521                 if (y >= 90 && y <= 98) {
1522                     // explosion_sounds
1523                     menuselect = 19;
1524 
1525                 }
1526 
1527                 if (y >= 100 && y <= 108) {
1528                     // gunshot_sounds
1529                     menuselect = 20;
1530 
1531                 }
1532 
1533                 if (y >= 110 && y <= 118) {
1534                     // ground_i_sounds
1535                     menuselect = 21;
1536 
1537                 }
1538 
1539                 if (y >= 120 && y <= 128) {
1540                     // splash
1541                     menuselect = 22;
1542 
1543                 }
1544 
1545                 if (y >= 130 && y <= 138) {
1546                     // infantry_sounds
1547                     menuselect = 50;
1548 
1549                 }
1550 
1551 
1552             }
1553 
1554         if (optimode == 2)
1555             if ((x >= 214 && x <= 221) || (x >= 224 && x <= 231)) {
1556                 if (x <= 221)
1557                     menusubselect = 1;
1558                 else
1559                     menusubselect = 0;
1560 
1561                 if (y >= 60 && y <= 68) {
1562                     // poweronoff
1563                     menuselect = 23;
1564 
1565                 }
1566 
1567                 if (y >= 70 && y <= 78) {
1568                     // powerrev
1569                     menuselect = 24;
1570 
1571                 }
1572 
1573 
1574             }
1575 
1576         if (optimode == 3) {
1577             if (x >= 214 && x <= 231 && y >= 90 && y <= 98)
1578                 menuselect = 28;
1579 
1580             if ((x >= 214 && x <= 221) || (x >= 224 && x <= 231)) {
1581                 if (x <= 221)
1582                     menusubselect = 1;
1583                 else
1584                     menusubselect = 0;
1585 
1586                 if (y >= 60 && y <= 68) {
1587                     // all_planes_are
1588                     menuselect = 25;
1589 
1590                 }
1591 
1592                 if (y >= 70 && y <= 78) {
1593                     // nocollision
1594                     menuselect = 26;
1595 
1596                 }
1597 
1598                 if (y >= 80 && y <= 88) {
1599                     // partcollision
1600                     menuselect = 27;
1601 
1602                 }
1603 
1604                 if (y >= 90 && y <= 98) {
1605                     // stop
1606                     menuselect = 28;
1607 
1608                 }
1609 
1610                 if (y >= 100 && y <= 108) {
1611                     // alliance
1612                     menuselect = 29;
1613 
1614                 }
1615 
1616                 if (y >= 110 && y <= 118) {
1617                     // aa_mgs
1618                     menuselect = 30;
1619 
1620                 }
1621 
1622                 if (y >= 120 && y <= 128) {
1623                     // it_gungs
1624                     menuselect = 31;
1625 
1626                 }
1627 
1628                 if (y >= 130 && y <= 138) {
1629                     // infantry
1630                     menuselect = 32;
1631 
1632                 }
1633 
1634                 if (y >= 140 && y <= 148) {
1635                     // unlimited_ammo
1636                     menuselect = 33;
1637 
1638                 }
1639 
1640                 if (y >= 150 && y <= 158) {
1641                     // unlimited_gas
1642                     menuselect = 34;
1643 
1644                 }
1645 
1646 
1647 
1648 
1649             }
1650 
1651             if (config.all_planes_are && x >= 34 && y >= 10 && x <= 41 && y <= 18) {
1652                 menuselect = 51;
1653 
1654             }
1655 
1656             if (config.all_planes_are && x >= 34 && y >= 31 && x <= 41 && y <= 39) {
1657                 menuselect = 52;
1658 
1659             }
1660 
1661             if (config.all_planes_are && x >= 34 && y >= 52 && x <= 41 && y <= 60) {
1662                 menuselect = 53;
1663 
1664             }
1665 
1666             if (config.all_planes_are && x >= 34 && y >= 73 && x <= 41 && y <= 81) {
1667                 menuselect = 54;
1668 
1669             }
1670 
1671             if (config.alliance && x >= 5 && y >= 96 && x <= 53 && y <= 128) {
1672                 menuselect = 55;
1673 
1674             }
1675 
1676             if (config.alliance && x >= 5 && y >= 129 && x <= 53 && y <= 160) {
1677                 menuselect = 56;
1678 
1679             }
1680 
1681             if (config.alliance && x >= 5 && y >= 161 && x <= 53 && y <= 182) {
1682                 menuselect = 57;
1683 
1684             }
1685         }
1686 
1687 
1688 
1689         cursor->blit(x - 10, y - 10);
1690         do_all(1);
1691 
1692         if ((n1 || n2) && menuselect) {
1693             switch (menuselect) {
1694 
1695             case 2:
1696                 if (n1)
1697                     random_fade_out();
1698                 else {
1699                     tyhjaa_vircr();
1700                     do_all();
1701                 }
1702                 exit_flag = 1;
1703                 break;
1704 
1705             case 10:
1706                 config.shots_visible = menusubselect;
1707                 break;
1708 
1709             case 11:
1710                 config.it_shots_visible = menusubselect;
1711                 break;
1712 
1713             case 12:
1714                 config.aa_mg_shots_visible = menusubselect;
1715                 break;
1716 
1717             case 13:
1718                 config.flags = menusubselect;
1719                 break;
1720 
1721             case 14:
1722                 config.flames = menusubselect;
1723                 break;
1724 
1725             case 64:
1726                 config.structure_smoke = menusubselect;
1727                 break;
1728 
1729 
1730             case 15:
1731                 config.svga = menusubselect;
1732                 break;
1733 
1734             case 16:
1735                 config.sound_on = menusubselect;
1736                 break;
1737 
1738             case 17:
1739                 config.music_on = menusubselect;
1740                 break;
1741 
1742             case 18:
1743                 config.sfx_on = menusubselect;
1744                 break;
1745 
1746             case 19:
1747                 config.explosion_sounds = menusubselect;
1748                 break;
1749 
1750             case 20:
1751                 config.gunshot_sounds = menusubselect;
1752                 break;
1753 
1754             case 21:
1755                 config.ground_i_sounds = menusubselect;
1756                 break;
1757 
1758             case 22:
1759                 config.splash = menusubselect;
1760                 break;
1761 
1762             case 50:
1763                 config.infantry_sounds = menusubselect;
1764                 break;
1765 
1766             case 23:
1767                 config.poweronoff = menusubselect;
1768                 break;
1769 
1770             case 24:
1771                 config.powerrev = menusubselect;
1772                 break;
1773 
1774             case 25:
1775                 config.all_planes_are = menusubselect;
1776                 break;
1777 
1778             case 26:
1779                 config.nocollision = menusubselect;
1780                 break;
1781 
1782             case 27:
1783                 config.partcollision = menusubselect;
1784                 break;
1785 
1786             case 28:
1787                 if (n1) {
1788                     if (++config.stop > 999)
1789                         config.stop = 999;
1790 
1791                 } else {
1792                     if (--config.stop < 0)
1793                         config.stop = 0;
1794 
1795                 }
1796 
1797                 break;
1798 
1799             case 29:
1800                 config.alliance = menusubselect;
1801                 break;
1802 
1803             case 30:
1804                 config.aa_mgs = menusubselect;
1805                 break;
1806 
1807             case 31:
1808                 config.it_guns = menusubselect;
1809                 break;
1810 
1811             case 32:
1812                 config.infantry = menusubselect;
1813                 break;
1814 
1815             case 33:
1816                 config.unlimited_ammo = menusubselect;
1817                 break;
1818 
1819             case 34:
1820                 config.unlimited_gas = menusubselect;
1821                 break;
1822 
1823 
1824             }
1825 
1826             if (menuselect >= 3 && menuselect <= 6)
1827                 optimode = menuselect - 3;
1828 
1829             if (menuselect >= 51 && menuselect <= 54) {
1830                 config.all_planes_are = menuselect - 50;
1831 
1832             }
1833 
1834             if (menuselect >= 55 && menuselect <= 57) {
1835                 config.alliance = menuselect - 54;
1836 
1837             }
1838 
1839         }
1840     }
1841 
1842     delete kohta[0];
1843     delete kohta[1];
1844     delete kohta[2];
1845     delete kohta[3];
1846     delete optionme;
1847     delete right;
1848     delete wrong;
1849     delete opt1;
1850     delete opt2;
1851 
1852 
1853     if (config.sound_on && (is_there_sound == 0))
1854         init_sounds();
1855 
1856     if (is_there_sound && config.music_on && (!music_loaded)) {
1857 
1858         load_music();
1859         sdl_play_music(triplane_mod);
1860 
1861 
1862     }
1863 
1864     if (music_loaded && (!is_there_sound || !config.music_on)) {
1865         sdl_stop_music();
1866         clear_music();
1867     }
1868 
1869     if (is_there_sound && config.sfx_on && (!sfx_loaded))
1870         load_sfx();
1871 
1872     if (sfx_loaded && (!is_there_sound || !config.sfx_on))
1873         clear_sfx();
1874 
1875     if (!config.sound_on && (is_there_sound == 1))
1876         uninit_sounds();
1877 
1878     wait_mouse_relase();
1879 
1880 }
1881 
transfer_menu(void)1882 void transfer_menu(void) {
1883     int exit_flag = 0;
1884     int x, y, n1, n2;
1885     int menuselect;
1886     Bitmap *optionme;
1887     Bitmap *color_bites[6];
1888     Bitmap *descs[6];
1889     int l;
1890 
1891     optionme = new Bitmap("TRANS2");
1892 
1893     color_bites[0] = new Bitmap(39, 46, 80, 50, optionme);
1894     color_bites[1] = new Bitmap(119, 46, 80, 50, optionme);
1895     color_bites[2] = new Bitmap(199, 46, 80, 50, optionme);
1896     color_bites[3] = new Bitmap(39, 96, 80, 50, optionme);
1897     color_bites[4] = new Bitmap(119, 96, 80, 50, optionme);
1898     color_bites[5] = new Bitmap(199, 96, 80, 50, optionme);
1899 
1900     descs[0] = new Bitmap("DESC1");
1901     descs[1] = new Bitmap("DESC2");
1902     descs[2] = new Bitmap("DESC3");
1903     descs[3] = new Bitmap("DESC4");
1904     descs[4] = new Bitmap("DESC5");
1905     descs[5] = new Bitmap("DESC6");
1906 
1907 
1908     delete optionme;
1909 
1910     optionme = new Bitmap("TRANSF");
1911 
1912     while (!exit_flag) {
1913         if (kbhit())
1914             if (getch() == 27)
1915                 exit_flag = 1;
1916 
1917         koords(&x, &y, &n1, &n2);
1918         optionme->blit(0, 0);
1919 
1920         color_bites[config.current_multilevel]->blit(39 + config.current_multilevel * 80 - (config.current_multilevel / 3) * 240,
1921                                                      46 + (config.current_multilevel / 3) * 50);
1922 
1923         descs[config.current_multilevel]->blit(0, 154);
1924 
1925         menuselect = 0;
1926 
1927         if ((x >= 0 && x <= 319 && y >= 0 && y <= 41)
1928             || (x >= 0 && x <= 319 && y >= 151 && y <= 199)
1929             || (x >= 0 && x <= 32 && y >= 0 && y <= 199)
1930             || (x >= 282 && x <= 319 && y >= 0 && y <= 199)) {
1931             //frost->printf(25,180,"Back to main menu");
1932             menuselect = 2;
1933         }
1934 
1935         for (l = 0; l < 6; l++)
1936             if (x >= (39 + l * 80 - (l / 3) * 240) && x <= (118 + l * 80 - (l / 3) * 240) && y >= (46 + (l / 3) * 50) && y <= (95 + (l / 3) * 50)) {
1937                 //frost->printf(25,180,"Select level %d",l+1);
1938                 menuselect = 3 + l;
1939             }
1940 
1941         cursor->blit(x - 10, y - 10);
1942         do_all();
1943 
1944         if ((n1 || n2) && menuselect) {
1945             switch (menuselect) {
1946 
1947             case 2:
1948                 if (n1)
1949                     random_fade_out();
1950                 else {
1951                     tyhjaa_vircr();
1952                     do_all();
1953                 }
1954                 exit_flag = 1;
1955                 break;
1956 
1957 
1958             }
1959 
1960             if (menuselect >= 3 && menuselect <= 8) {
1961                 config.current_multilevel = menuselect - 3;
1962             }
1963         }
1964     }
1965 
1966     for (x = 0; x < 6; x++) {
1967         delete color_bites[x];
1968         delete descs[x];
1969     }
1970 
1971     delete optionme;
1972 
1973 
1974     wait_mouse_relase();
1975 }
1976 
joystick_setup(int joy,Bitmap * controlme)1977 static void joystick_setup(int joy, Bitmap * controlme) {
1978     Sint16 *idle, *current;
1979     int i, c;
1980     struct {
1981         const char *prompt;
1982         joystick_action *act;
1983     } acts[] = {
1984         {
1985         "Up", &joystick_config[joy].up}, {
1986         "Down", &joystick_config[joy].down}, {
1987         "Roll", &joystick_config[joy].roll}, {
1988         "Power", &joystick_config[joy].power}, {
1989         "Guns", &joystick_config[joy].guns}, {
1990         "Bombs", &joystick_config[joy].bombs}, {
1991         "Brake", &joystick_config[joy].brake}, {
1992         NULL, NULL}
1993     };
1994 
1995     if (joy == 0)
1996         open_close_joysticks(1, 0);
1997     else
1998         open_close_joysticks(0, 1);
1999 
2000     idle = allocate_axis_state(joy);
2001     current = allocate_axis_state(joy);
2002 
2003     controlme->blit(0, 0);
2004     frost->printf(54, 93, "Keep joystick idle and press");
2005     frost->printf(54, 100, "Space (Esc=use old settings)");
2006     do_all();
2007     do {
2008         c = getch();
2009     } while (c != 27 && c != ' ');
2010     if (c == 27)
2011         goto joystick_setup_exit;
2012 
2013     save_axis_state(idle, joy);
2014 
2015     for (i = 0; acts[i].prompt != NULL; i++) {
2016         controlme->blit(0, 0);
2017         frost->printf(54, 93, "Do '%s' on joystick and", acts[i].prompt);
2018         frost->printf(54, 100, "press Space or D=disable this");
2019         do_all();
2020         do {
2021             c = getch();
2022         } while (c != 27 && c != ' ' && c != 'd' && c != 'D');
2023         if (c == 27) {
2024             goto joystick_setup_exit;
2025         } else if (c == 'd' || c == 'D') {
2026             set_disabled_action(acts[i].act);
2027         } else {
2028             if (!find_changed_button(acts[i].act, joy)) {
2029                 save_axis_state(current, joy);
2030                 find_changed_axis(acts[i].act, idle, current, joy);
2031             }
2032         }
2033     }
2034 
2035   joystick_setup_exit:
2036     wfree(idle);
2037     wfree(current);
2038 
2039     open_close_joysticks(0, 0);
2040 }
2041 
controls_menu(void)2042 void controls_menu(void) {
2043     char ch;
2044     int help_on = 0;
2045     int exit_flag = 0;
2046     int x, y, n1, n2;
2047     int menuselect;
2048     Bitmap *controlme;
2049     Bitmap *napp[4];
2050     Bitmap *help;
2051     int active = 0;
2052 
2053     controlme = new Bitmap("NAPPIS");
2054     napp[0] = new Bitmap("NAPPRE");
2055     napp[1] = new Bitmap("NAPPBL");
2056     napp[2] = new Bitmap("NAPPGR");
2057     napp[3] = new Bitmap("NAPPYL");
2058     help = new Bitmap("HELP4");
2059 
2060 
2061 
2062     while (!exit_flag) {
2063         if (kbhit()) {
2064             if (!(ch = getch())) {
2065                 ch = getch();
2066                 if (ch == 59)
2067                     wtoggle(&help_on);
2068 
2069             } else {
2070                 if (ch == 27)
2071                     exit_flag = 1;
2072             }
2073 
2074         }
2075 
2076         koords(&x, &y, &n1, &n2);
2077         controlme->blit(0, 0);
2078 
2079         napp[active]->blit((active % 2) * 27 + 10, (active / 2) * 23 + 22);
2080 
2081         if (help_on)
2082             help->blit(0, 0);
2083 
2084         menuselect = 0;
2085 
2086         if ((x >= 0 && x <= 106 && y >= 73 && y <= 107)
2087             || (x >= 68 && x <= 106 && y >= 0 && y <= 73)
2088             || (x >= 108 && x <= 319 && y >= 88 && y <= 109)
2089             || (x >= 301 && x <= 319 && y >= 111 && y <= 199)
2090             || (x >= 0 && x <= 7 && y >= 114 && y <= 199)) {
2091             frost->printf(61, 97, "Back to main menu");
2092             menuselect = 2;
2093         }
2094 
2095         if ((x >= 11 && x <= 296 && y >= 112 && y <= 195)) {
2096             frost->printf(61, 97, "Set keys");
2097             menuselect = 3;
2098         }
2099 
2100         if ((x >= 10 && x <= 24 && y >= 22 && y <= 35)) {
2101             frost->printf(61, 97, "Select Red Plane");
2102             menuselect = 4;
2103         }
2104 
2105         if ((x >= 37 && x <= 51 && y >= 22 && y <= 35)) {
2106             frost->printf(61, 97, "Select Blue Plane");
2107             menuselect = 5;
2108         }
2109 
2110         if ((x >= 10 && x <= 24 && y >= 45 && y <= 58)) {
2111             frost->printf(61, 97, "Select Green Plane");
2112             menuselect = 6;
2113         }
2114 
2115         if ((x >= 37 && x <= 51 && y >= 45 && y <= 58)) {
2116             frost->printf(61, 97, "Select Yellow Plane");
2117             menuselect = 7;
2118         }
2119 
2120         if ((x >= 108 && x <= 212 && y >= 0 && y <= 87)) {
2121             frost->printf(61, 97, "Select Joystick 1");
2122             menuselect = 8;
2123         }
2124 
2125         if ((x >= 214 && x <= 318 && y >= 0 && y <= 87)) {
2126             frost->printf(61, 97, "Select Joystick 2");
2127             menuselect = 9;
2128         }
2129 
2130 
2131         if (config.joystick[0] != active && config.joystick[1] != active) {
2132             frost->printf(170, 93, "Up [%s] Down [%s] Roll [%s]",
2133                           SDL_GetKeyName((SDLKey) player_keys[active].up), SDL_GetKeyName((SDLKey) player_keys[active].down),
2134                           SDL_GetKeyName((SDLKey) player_keys[active].roll));
2135             frost->printf(170, 100, "Power [%s] Bombs [%s] Guns [%s]", SDL_GetKeyName((SDLKey) player_keys[active].power),
2136                           SDL_GetKeyName((SDLKey) player_keys[active].bombs), SDL_GetKeyName((SDLKey) player_keys[active].guns));
2137         } else {
2138             int joy = (config.joystick[0] == active) ? 0 : 1;
2139             char *ups = get_joy_action_string(&joystick_config[joy].up);
2140             char *downs = get_joy_action_string(&joystick_config[joy].down);
2141             char *rolls = get_joy_action_string(&joystick_config[joy].roll);
2142             char *powers = get_joy_action_string(&joystick_config[joy].power);
2143             char *gunss = get_joy_action_string(&joystick_config[joy].guns);
2144             char *bombss = get_joy_action_string(&joystick_config[joy].bombs);
2145             char *brakes = get_joy_action_string(&joystick_config[joy].brake);
2146 
2147             frost->printf(170, 93, "J%d: Up [%s] Down [%s] Roll [%s]", joy + 1, ups, downs, rolls);
2148             frost->printf(170, 100, "Pwr [%s] Bmb [%s] Gun [%s] Brk [%s]", powers, bombss, gunss, brakes);
2149 
2150             wfree(ups);
2151             wfree(downs);
2152             wfree(rolls);
2153             wfree(powers);
2154             wfree(gunss);
2155             wfree(bombss);
2156             wfree(brakes);
2157         }
2158 
2159         cursor->blit(x - 10, y - 10);
2160         do_all();
2161 
2162         if ((n1 || n2) && menuselect) {
2163             switch (menuselect) {
2164 
2165             case 2:
2166                 if (n1)
2167                     random_fade_out();
2168                 exit_flag = 1;
2169                 break;
2170 
2171             case 3:
2172                 if (config.joystick[0] == active)
2173                     config.joystick[0] = -1;
2174 
2175                 if (config.joystick[1] == active)
2176                     config.joystick[1] = -1;
2177 
2178 
2179                 controlme->blit(0, 0);
2180                 napp[active]->blit((active % 2) * 27 + 10, (active / 2) * 23 + 22);
2181                 frost->printf(56, 97, "Key for upward turn [%s]", SDL_GetKeyName((SDLKey) player_keys[active].up));
2182                 do_all();
2183 
2184                 player_keys[active].up = select_key(active, player_keys[active].up);
2185 
2186                 controlme->blit(0, 0);
2187                 napp[active]->blit((active % 2) * 27 + 10, (active / 2) * 23 + 22);
2188                 frost->printf(56, 97, "Key for downward turn [%s]", SDL_GetKeyName((SDLKey) player_keys[active].down));
2189                 do_all();
2190 
2191                 player_keys[active].down = select_key(active, player_keys[active].down);
2192 
2193                 controlme->blit(0, 0);
2194                 napp[active]->blit((active % 2) * 27 + 10, (active / 2) * 23 + 22);
2195                 frost->printf(56, 97, "Key for roll [%s]", SDL_GetKeyName((SDLKey) player_keys[active].roll));
2196                 do_all();
2197 
2198                 player_keys[active].roll = select_key(active, player_keys[active].roll);
2199 
2200                 controlme->blit(0, 0);
2201                 napp[active]->blit((active % 2) * 27 + 10, (active / 2) * 23 + 22);
2202                 frost->printf(56, 97, "Key for engine power [%s]", SDL_GetKeyName((SDLKey) player_keys[active].power));
2203                 do_all();
2204 
2205                 player_keys[active].power = select_key(active, player_keys[active].power);
2206 
2207                 controlme->blit(0, 0);
2208                 napp[active]->blit((active % 2) * 27 + 10, (active / 2) * 23 + 22);
2209                 frost->printf(56, 97, "Key for bomb drop [%s]", SDL_GetKeyName((SDLKey) player_keys[active].bombs));
2210                 do_all();
2211 
2212                 player_keys[active].bombs = select_key(active, player_keys[active].bombs);
2213 
2214                 controlme->blit(0, 0);
2215                 napp[active]->blit((active % 2) * 27 + 10, (active / 2) * 23 + 22);
2216                 frost->printf(56, 97, "Key for guns [%s]", SDL_GetKeyName((SDLKey) player_keys[active].guns));
2217                 do_all();
2218 
2219                 player_keys[active].guns = select_key(active, player_keys[active].guns);
2220 
2221                 save_keyset();
2222                 break;
2223 
2224             case 8:
2225                 if (joystick_exists & (JOY1X + JOY1Y)) {
2226                     config.joystick[0] = active;
2227                     if (config.joystick[1] == active)
2228                         config.joystick[1] = -1;
2229                     joystick_setup(0, controlme);
2230                     save_joysticks_data(CALIBRATION_FILENAME);
2231                     config.joystick_calibrated[0] = 1;
2232                 }
2233                 break;
2234 
2235             case 9:
2236                 if (joystick_exists & (JOY2X + JOY2Y)) {
2237                     config.joystick[1] = active;
2238                     if (config.joystick[0] == active)
2239                         config.joystick[0] = -1;
2240                     joystick_setup(1, controlme);
2241                     save_joysticks_data(CALIBRATION_FILENAME);
2242                     config.joystick_calibrated[1] = 1;
2243                 }
2244                 break;
2245             }
2246 
2247             if (menuselect >= 4 && menuselect <= 7) {
2248                 active = menuselect - 4;
2249 
2250             }
2251         }
2252     }
2253 
2254     delete napp[0];
2255     delete napp[1];
2256     delete napp[2];
2257     delete napp[3];
2258     delete controlme;
2259     delete help;
2260 
2261     wait_mouse_relase();
2262 
2263 }
2264 
2265 
assign_menu(void)2266 void assign_menu(void) {
2267     int exit_flag = 0;
2268     int x, y, n1, n2;
2269     int menuselect;
2270     int menusubselect1 = 0, menusubselect2 = 0;
2271     Bitmap *acesme;
2272     Bitmap *ruksi;
2273     Bitmap *help;
2274     int l, lx, ly;
2275     int l2, l3;
2276     int lym[4] = { 0, 11, 24, 36 };
2277     int response;
2278     int help_on = 0;
2279     char ch;
2280 
2281     if (!roster[0].pilotname[0]) {
2282         response = small_warning("You have no pilots in the roster and\n"
2283                                  "therefore you can't assign players\n" "You will be automaticly transfered to\n" "roster menu to create a pilot.\n");
2284 
2285         if (response) {
2286             roster_menu();
2287 
2288         } else
2289             return;
2290 
2291     }
2292 
2293     acesme = new Bitmap("ASSIGN");
2294 
2295     ruksi = new Bitmap("RUKSI");
2296     help = new Bitmap("HELP5");
2297 
2298 
2299     while (!exit_flag) {
2300         if (kbhit()) {
2301             if (!(ch = getch())) {
2302                 ch = getch();
2303                 if (ch == 59)
2304                     wtoggle(&help_on);
2305 
2306             } else {
2307                 if (ch == 27)
2308                     exit_flag = 1;
2309             }
2310 
2311         }
2312 
2313         koords(&x, &y, &n1, &n2);
2314         acesme->blit(0, 0);
2315 
2316 
2317         menuselect = 0;
2318 
2319         if ((x >= 0 && x <= 8 && y >= 0 && y <= 199) ||
2320             (x >= 308 && x <= 319 && y >= 0 && y <= 199) || (x >= 0 && x <= 319 && y >= 0 && y <= 28) || (x >= 0 && x <= 319 && y >= 168 && y <= 199)) {
2321             //frost->printf(82,177,"Back to main menu");
2322             menuselect = 2;
2323         }
2324 
2325         for (l = 0; l < 4; l++) {
2326             ly = (l / 2) * 73;
2327             lx = (l % 2) ? 153 : 0;
2328 
2329             ruksi->blit(28 + lx, 45 + ly + lym[config.player_type[l]]);
2330 
2331             if (config.player_number[l] != -1) {
2332                 frost->printf(46 + lx, 82 + ly, roster[config.player_number[l]].pilotname);
2333 
2334             }
2335 
2336             for (l2 = 0; l2 < 4; l2++) {
2337                 if (x >= (28 + lx) && x <= (35 + lx) && y >= (45 + lym[l2] + ly) && y <= (49 + lym[l2] + ly)) {
2338                     menusubselect1 = l;
2339                     menusubselect2 = l2;
2340                     menuselect = 1;
2341 
2342                 }
2343             }
2344 
2345             if (x >= (134 + lx) && x < (143 + lx) && y >= (79 + ly) && y <= (89 + ly)) {
2346                 menusubselect1 = l;
2347                 menuselect = 3;
2348                 //frost->printf(82,177,"Select next pilot");
2349 
2350             }
2351 
2352             if (x >= (143 + lx) && x <= (151 + lx) && y >= (79 + ly) && y <= (89 + ly)) {
2353                 menusubselect1 = l;
2354                 menuselect = 4;
2355                 //frost->printf(82,177,"Select previous pilot");
2356 
2357             }
2358         }
2359 
2360         cursor->blit(x - 10, y - 10);
2361         if (help_on)
2362             help->blit(0, 0);
2363         do_all();
2364 
2365         if ((n1 || n2) && menuselect) {
2366             switch (menuselect) {
2367 
2368             case 1:
2369                 config.player_type[menusubselect1] = menusubselect2;
2370 
2371                 if (menusubselect2 == 1) {
2372                     for (l = 0; l < 4; l++) {
2373                         if (l == menusubselect1)
2374                             continue;
2375 
2376                         config.player_type[l] = 0;
2377                         config.player_number[l] = -1;
2378                     }
2379                 } else {
2380                     for (l = 0; l < 4; l++) {
2381                         if (l == menusubselect1)
2382                             continue;
2383 
2384                         if (config.player_type[l] == 1) {
2385                             config.player_type[l] = 0;
2386                             config.player_number[l] = -1;
2387                         }
2388                     }
2389                 }
2390 
2391                 if (menusubselect2 == 0 || menusubselect2 == 2)
2392                     config.player_number[menusubselect1] = -1;
2393                 else {
2394                     if (config.player_number[menusubselect1] == -1) {
2395 
2396                         for (l = 0; l < MAX_PLAYERS_IN_ROSTER; l++) {
2397                             if (!roster[l].pilotname[0]) {
2398                                 config.player_type[menusubselect1] = 0;
2399                                 config.player_number[menusubselect1] = -1;
2400                                 break;
2401                             } else {
2402                                 for (l3 = 0; l3 < 4; l3++) {
2403                                     if (l3 == menusubselect1 || config.player_number[l3] == -1)
2404                                         continue;
2405 
2406                                     if (config.player_number[l3] == l)
2407                                         break;
2408 
2409                                 }
2410                                 if (l3 == 4) {
2411                                     config.player_number[menusubselect1] = l;
2412                                     break;
2413 
2414                                 }
2415 
2416                             }
2417 
2418                         }
2419                         if (l == MAX_PLAYERS_IN_ROSTER) {
2420                             config.player_type[menusubselect1] = 0;
2421                             config.player_number[menusubselect1] = -1;
2422 
2423                         }
2424 
2425                     }
2426                 }
2427 
2428 
2429 
2430                 break;
2431 
2432             case 2:
2433                 if (n1)
2434                     random_fade_out();
2435                 exit_flag = 1;
2436                 break;
2437 
2438             case 3:
2439                 ly = 0;
2440                 lx = config.player_number[menusubselect1];
2441                 l2 = lx + 1;
2442 
2443                 while (!ly) {
2444                     ly = 1;
2445 
2446                     if (lx == l2) {
2447                         l2 = -1;
2448                         break;
2449                     }
2450 
2451                     if (l2 != -1) {
2452                         if (!roster[l2].pilotname[0]) {
2453                             ly = 0;
2454                             l2 = -1;
2455                             continue;
2456                         }
2457 
2458 
2459                         for (l = 0; l < 4; l++) {
2460                             if (l == menusubselect1)
2461                                 continue;
2462 
2463                             if (config.player_number[l] == l2) {
2464                                 l2++;
2465                                 ly = 0;
2466                                 continue;
2467                             }
2468 
2469 
2470                         }
2471 
2472                     } else {
2473 
2474                         l2 = -1;
2475                         break;
2476                     }
2477                 }
2478 
2479                 config.player_number[menusubselect1] = l2;
2480 
2481                 break;
2482 
2483             case 4:
2484                 ly = 0;
2485                 lx = config.player_number[menusubselect1];
2486                 l2 = lx - 1;
2487                 if (l2 < -1)
2488                     l2 = -1;
2489 
2490 
2491 
2492                 while (!ly) {
2493                     ly = 1;
2494 
2495                     if (l2 != -1) {
2496 
2497                         for (l = 0; l < 4; l++) {
2498                             if (l == menusubselect1)
2499                                 continue;
2500 
2501                             if (config.player_number[l] == l2) {
2502                                 l2--;
2503                                 ly = 0;
2504                                 break;
2505                             }
2506 
2507 
2508                         }
2509 
2510                     } else {
2511 
2512                         l2 = -1;
2513                         break;
2514                     }
2515                 }
2516 
2517                 if (l2 == -1) {
2518                     for (l2 = MAX_PLAYERS_IN_ROSTER - 1; l2 >= 0; l2--) {
2519                         if (roster[l2].pilotname[0]) {
2520                             for (l = 0; l < 4; l++) {
2521                                 if (l == menusubselect1)
2522                                     continue;
2523 
2524                                 if (config.player_number[l] == l2) {
2525                                     break;
2526 
2527                                 }
2528                             }
2529 
2530                             if (l == 4)
2531                                 break;
2532 
2533                         }
2534                     }
2535 
2536 
2537                     config.player_number[menusubselect1] = l2;
2538                     break;
2539                 }
2540 
2541                 config.player_number[menusubselect1] = l2;
2542 
2543 
2544 
2545                 break;
2546 
2547 
2548             }
2549         }
2550 
2551         if (n1 || n2)
2552             wait_mouse_relase();
2553 
2554     }
2555 
2556     for (l = 0; l < 4; l++) {
2557         if (config.player_number[l] == -1 && (config.player_type[l] == 1 || config.player_type[l] == 3)) {
2558             config.player_type[l] = 0;
2559             config.player_number[l] = -1;
2560         }
2561     }
2562 
2563     delete acesme;
2564     delete ruksi;
2565     delete help;
2566 
2567     wait_mouse_relase();
2568 
2569 }
2570 
2571 
aces_menu(void)2572 void aces_menu(void) {
2573     int exit_flag = 0;
2574     int x, y, n1, n2;
2575     int menuselect;
2576     int current_page = 0;
2577     int help_on = 0;
2578     char ch;
2579     Bitmap *acesme;
2580     Bitmap *firstpage;
2581     Bitmap *buttl;
2582     Bitmap *buttr;
2583     Bitmap *help;
2584 
2585 
2586     if (is_there_sound && config.music_on) {
2587         sdl_stop_music();
2588         sdl_play_music(aces_mod);
2589 
2590     }
2591 
2592 
2593     acesme = new Bitmap("ACESA");
2594     firstpage = new Bitmap("ACESB");
2595     buttl = new Bitmap("BUTTL");
2596     buttr = new Bitmap("BUTTR");
2597     help = new Bitmap("HELP3");
2598 
2599     acesme->blit(0, 0);
2600     standard_background = new Bitmap(0, 0, 320, 200);
2601     do_all_clear();
2602 
2603     while (!exit_flag) {
2604 
2605         if (kbhit()) {
2606             if (!(ch = getch())) {
2607                 ch = getch();
2608                 if (ch == 59)
2609                     wtoggle(&help_on);
2610 
2611             } else {
2612                 if (ch == 27)
2613                     exit_flag = 1;
2614             }
2615 
2616         }
2617 
2618         koords(&x, &y, &n1, &n2);
2619 
2620         if (!current_page)
2621             firstpage->blit(75, 34);
2622 
2623         menuselect = 0;
2624 
2625         if ((x >= 0 && x <= 66 && y >= 0 && y <= 199) ||
2626             (x >= 269 && x <= 319 && y >= 0 && y <= 199) || (x >= 0 && x <= 319 && y >= 0 && y <= 11) || (x >= 0 && x <= 319 && y >= 189 && y <= 199)) {
2627             // main menu
2628             menuselect = 2;
2629         }
2630 
2631         if (x >= 231 && x <= 247 && y >= 177 && y <= 185) {
2632             //prev. page
2633             menuselect = 3;
2634 
2635         }
2636 
2637         if (x >= 249 && x <= 265 && y >= 177 && y <= 185) {
2638             //next page
2639             menuselect = 4;
2640 
2641         }
2642 
2643         if (help_on)
2644             help->blit(0, 0);
2645 
2646         if (!current_page)
2647             aces_grand_total();
2648         if (current_page == 1)
2649             aces_multi_total();
2650         if (current_page == 2)
2651             aces_solo_total();
2652         if (current_page > 2 && current_page <= 26)
2653             aces_one_solo((current_page - 3) / 6, (current_page - 3) - ((current_page - 3) / 6) * 6);
2654 
2655         switch (current_page) {
2656         case 27:
2657             aces_triggerhappy();
2658             break;
2659 
2660         case 28:
2661             aces_bombdropper();
2662             break;
2663 
2664         case 29:
2665             aces_shotaccuracy();
2666             break;
2667 
2668         case 30:
2669             aces_bombaccuracy();
2670             break;
2671 
2672         case 31:
2673             aces_mostkills();
2674             break;
2675 
2676         case 32:
2677             aces_decoy();
2678             break;
2679 
2680         case 33:
2681             aces_totalmissions();
2682             break;
2683 
2684 
2685         }
2686 
2687         if ((n1 || n2) && menuselect) {
2688             switch (menuselect) {
2689 
2690             case 2:
2691 
2692                 exit_flag = 1;
2693                 break;
2694             case 3:
2695                 buttl->blit(231, 177);
2696                 if ((--current_page) < 0)
2697                     current_page = 33;
2698                 break;
2699             case 4:
2700                 buttr->blit(249, 177);
2701                 if ((++current_page) > 33)
2702                     current_page = 0;
2703                 break;
2704 
2705 
2706             }
2707         }
2708 
2709         cursor->blit(x - 10, y - 10);
2710         do_all_clear();
2711         if (n1 || n2)
2712             wait_mouse_relase();
2713     }
2714 
2715 
2716     if (is_there_sound && config.music_on) {
2717         sdl_stop_music();
2718         sdl_play_music(triplane_mod);
2719 
2720     }
2721 
2722     delete standard_background;
2723     standard_background = NULL;
2724     if (n1)
2725         random_fade_out();
2726     delete help;
2727     delete acesme;
2728     delete firstpage;
2729     delete buttl;
2730     delete buttr;
2731 
2732     wait_mouse_relase();
2733 
2734 }
2735 
kangas_menu(void)2736 int kangas_menu(void) {
2737     int exit_flag = 0;
2738     int x, y, n1, n2;
2739     int menuselect;
2740     int place_x = -2079;
2741     int showing_texts = 1;
2742 
2743     Bitmap *kangas = new Bitmap("KANGAS", 0);
2744     Bitmap *buttr = new Bitmap("BUTTR");
2745     Bitmap *buttl = new Bitmap("BUTTL");
2746     Bitmap *fly = new Bitmap("FLY");
2747     Bitmap *exit = new Bitmap("EXIT");
2748 
2749     init_vga("PALET3");
2750 
2751     if (is_there_sound && config.sfx_on) {
2752         if (soundcard_type != SOUNDCARD_GUS) {
2753             sample_hurr->left_volume = SAMPLE_VOLUME - 5;
2754             sample_hurr->right_volume = SAMPLE_VOLUME - 5;
2755             sdl_stop_music();
2756             sdl_play_sample(sample_hurr, 1);
2757         }
2758     }
2759 
2760 
2761     hiiri_to(80, 195);
2762 
2763     if (miss_pl_x[solo_country]) {
2764         place_x = -(miss_pl_x[solo_country] - 160);
2765 
2766     } else {
2767         place_x = -(leveldata.airfield_x[solo_country] - 160);
2768 
2769     }
2770 
2771     load_descriptions(solo_mission + solo_country * 6);
2772 
2773     if (is_there_sound && config.sfx_on) {
2774         //sb_mix_sample(sample_hurr);
2775 
2776     }
2777 
2778     while (!exit_flag) {
2779         if (kbhit() && getch() == SDLK_ESCAPE) {
2780             exit_flag = 1;
2781         }
2782 
2783         koords(&x, &y, &n1, &n2);
2784         kangas->blit_fullscreen();
2785         kangas_terrain_to_screen(place_x);
2786 
2787         if (showing_texts)
2788             show_descriptions(solo_mission + solo_country * 6);
2789 
2790         menuselect = 0;
2791         if (x >= 72 && x <= 88 && y >= 191 && y <= 199) {
2792             //frost->printf(150,188,"Fly mission");
2793             menuselect = 1;
2794 
2795         }
2796 
2797         if (x >= 54 && x <= 70 && y >= 191 && y <= 199) {
2798             //frost->printf(150,188,"Back to mission menu");
2799             menuselect = 2;
2800         }
2801 
2802         if (x >= 0 && x <= 16 && y >= 191 && y <= 199) {
2803             //frost->printf(150,188,"Scroll map leftwards");
2804             menuselect = 3;
2805         }
2806 
2807         if (x >= 18 && x <= 34 && y >= 191 && y <= 199) {
2808             //frost->printf(150,188,"Scroll map rightwards");
2809             menuselect = 4;
2810         }
2811 
2812         if (x >= 5 && x <= 315 && y >= 8 && y <= 178) {
2813             //frost->printf(150,188,"Texts on/off");
2814             menuselect = 5;
2815         }
2816 
2817         cursor->blit(x - 10, y - 10);
2818         do_all(1);
2819 
2820         if ((n1 || n2) && menuselect) {
2821             switch (menuselect) {
2822 
2823             case 1:            // fly mission
2824                 fly->blit(72, 191);
2825                 do_all();
2826                 exit_flag = 2;
2827                 break;
2828 
2829             case 2:
2830 
2831                 exit->blit(54, 191);
2832                 do_all();
2833                 if (n1)
2834                     random_fade_out();
2835                 exit_flag = 1;
2836                 break;
2837 
2838             case 3:
2839 
2840                 place_x += 12;
2841                 buttl->blit(0, 191);
2842                 do_all();
2843                 break;
2844 
2845             case 4:
2846 
2847                 place_x -= 12;
2848                 buttr->blit(18, 191);
2849                 do_all();
2850                 break;
2851 
2852             case 5:
2853                 wait_mouse_relase();
2854                 wtoggle(&showing_texts);
2855             }
2856         }
2857 
2858         if (place_x > 0)
2859             place_x = 0;
2860         if (place_x < -2079)
2861             place_x = -2079;
2862     }
2863 
2864 
2865 
2866     delete kangas;
2867     delete buttr;
2868     delete buttl;
2869     delete fly;
2870     delete exit;
2871 
2872     if (is_there_sound && config.sfx_on) {
2873         if (soundcard_type != SOUNDCARD_GUS) {
2874             sdl_stop_all_samples();     /* stop hurr sound */
2875         }
2876     }
2877 
2878     if ((mission_re_fly == -1) && is_there_sound && config.music_on && !findparameter("-nomusic")) {
2879         sdl_stop_music();
2880         sdl_free_mod_file(national_mod);
2881     }
2882 
2883 
2884     wait_mouse_relase();
2885 
2886     init_vga("PALET5");
2887 
2888     if (exit_flag == 2)
2889         return 1;
2890     else
2891         return 0;
2892 }
2893 
2894 
credits_menu(void)2895 void credits_menu(void) {
2896     int exit_flag = 0;
2897     int x, y, n1, n2;
2898     int kohta1, kohta2;
2899 
2900     Font *grid3;
2901     Bitmap *credi1;
2902 
2903     grid3 = new Font("G3FONT");
2904     grid3->scale();
2905 
2906     credi1 = new Bitmap("CREDI1");
2907 
2908     kohta1 = 160 - (grid3->printf(0, 25, "Triplane Turmoil Crew") >> 1);
2909     kohta2 = 160 - (grid3->printf(0, 25, "Special Thanks:") >> 1);
2910 
2911     if (!findparameter("-debugnographics"))
2912         init_vga("PALET7");
2913 
2914     while (!exit_flag) {
2915         if (kbhit()) {
2916             getch();
2917             exit_flag = 1;
2918         }
2919 
2920         koords(&x, &y, &n1, &n2);
2921         credi1->blit(0, 0);
2922 
2923 
2924         grid3->printf(kohta1, 25, "Triplane Turmoil Crew");
2925 
2926         grid3->printf(45, 50, "Original idea:\nMarkku Rankala");
2927         grid3->printf(45, 80, "Graphics:\nHenrikki Merikallio\nMarkku Rankala\nRisto Puhakka");
2928         grid3->printf(205, 50, "Music & Sound:\nMarkku Rankala");
2929         grid3->printf(205, 80, "Sologame levels:\nMarkku Rankala");
2930         grid3->printf(205, 110, "Code & Project management:\nTeemu J. Takanen");
2931         grid3->printf(kohta2, 140, "Special Thanks:");
2932         grid3->printf(45, 160, "Mikko Kinnunen\nNiko Salminen\nPekka Pulli");
2933         grid3->printf(205, 160, "Antti Lehtoranta\nJuha Rytk�nen\nJoonas Joensuu");
2934 
2935 
2936 
2937         do_all();
2938 
2939         if (n1 || n2) {
2940 
2941             if (n1)
2942                 random_fade_out();
2943             exit_flag = 1;
2944             break;
2945 
2946 
2947 
2948 
2949         }
2950     }
2951 
2952     tyhjaa_vircr();
2953     do_all();
2954     if (!findparameter("-debugnographics"))
2955         init_vga("PALET5");
2956 
2957     delete credi1;
2958     delete grid3;
2959 
2960     wait_mouse_relase();
2961 
2962 }
2963 
letter_menu(void)2964 void letter_menu(void) {
2965     int exit_flag = 0;
2966     int x, y, n1, n2;
2967     char country_names[4][10] = { "German", "Finnish", "English", "Japanese" };
2968     char modnames[4][7] = { "mgerma", "mfinla", "mengla", "mjapan" };
2969 
2970     Bitmap *letter;
2971     Bitmap *temp;
2972     Bitmap *medal1;
2973 
2974     temp = new Bitmap("MEDAL1");
2975     medal1 = new Bitmap(1 + 32 * solo_country, 1, 31, 57, temp);
2976     delete temp;
2977 
2978     if (is_there_sound && config.music_on && !findparameter("-nomusic")) {
2979         national_mod = sdl_load_mod_file(modnames[solo_country]);
2980         if (national_mod == NULL) {
2981             printf("Error locating music.\n");
2982             exit(1);
2983 
2984         }
2985         sdl_play_music(national_mod);
2986 
2987     }
2988 
2989 
2990     letter = new Bitmap("LETTER");
2991 
2992     while (!exit_flag) {
2993         if (kbhit()) {
2994             getch();
2995             exit_flag = 1;
2996         }
2997 
2998         koords(&x, &y, &n1, &n2);
2999         letter->blit(0, 0);
3000         medal1->blit(15, 80);
3001         frost->printf(145, 104, "From: %s central command headquaters.", country_names[solo_country]);
3002         frost->printf(145, 114, "To: %s %s", rank_names[get_rank(config.player_number[solo_country])], roster[config.player_number[solo_country]].pilotname);
3003         frost->printf(180, 134, "Congratulations");
3004         frost->printf(119, 160,
3005                       "You have done outstanding work defending our country\n"
3006                       "and therefore the central command wants formally\n"
3007                       "express its feelings by giving you the Best Pilot in\n" "the Country medal. We wish you luck for your future\n" "career.\n");
3008         do_all();
3009 
3010         if (n1 || n2) {
3011 
3012             if (n1)
3013                 random_fade_out();
3014             exit_flag = 1;
3015             break;
3016 
3017 
3018 
3019         }
3020     }
3021 
3022     tyhjaa_vircr();
3023     do_all();
3024 
3025     delete letter;
3026     delete medal1;
3027 
3028 
3029 
3030     wait_mouse_relase();
3031 
3032     if (is_there_sound && config.music_on && !findparameter("-nomusic")) {
3033         sdl_stop_music();
3034         sdl_free_mod_file(national_mod);
3035     }
3036 }
3037 
3038 
3039 
main_menu(void)3040 void main_menu(void) {
3041     int exit_flag = 0;
3042     int x, y, n1, n2;
3043     int menuselect;
3044     int l, l2, l3;
3045     int help_on = 0;
3046     int ch;
3047     Bitmap *help;
3048 
3049     help = new Bitmap("HELP1");
3050 
3051     if (is_there_sound && config.music_on) {
3052 
3053         sdl_play_music(triplane_mod);
3054 
3055     }
3056 
3057 
3058     hiiri_to(254, 120);
3059 
3060     while (!exit_flag) {
3061         if (kbhit()) {
3062             ch = getch();
3063             if (ch == SDLK_F1) {
3064                 wtoggle(&help_on);
3065             } else {
3066                 if (ch == SDLK_ESCAPE)
3067                     exit_flag = 1;
3068             }
3069         }
3070 
3071         koords(&x, &y, &n1, &n2);
3072         menu1->blit(0, 0);      // 0,0,799,599
3073         grid2->printf(34, 156, "Press F1\nfor Help");
3074 
3075         for (l = 0; l < 4; l++)
3076             if (config.player_type[l] == 1)
3077                 break;
3078 
3079         if (l == 4) {
3080             for (l = 0; l < 4; l++)
3081                 if (config.player_type[l] == 3)
3082                     break;
3083 
3084             if (l == 4) {
3085                 frost->printf(100, 100, "No assigned pilots");
3086 
3087             } else {
3088                 frost->printf(100, 85, "Multiplayergame active");
3089                 frost->printf(100, 95, "%d. theater", config.current_multilevel + 1);
3090 
3091                 if (config.stop) {
3092                     frost->printf(100, 105, "Game ends with %d pts.", config.stop);
3093 
3094                 } else {
3095                     frost->printf(100, 105, "Unlimited game");
3096 
3097                 }
3098 
3099                 if (config.alliance) {
3100                     switch (config.alliance) {
3101                     case 1:
3102                         frost->printf(100, 115, "Alliance: 1&2 vs. 3&4");
3103                         break;
3104 
3105                     case 2:
3106                         frost->printf(100, 115, "Alliance: 1&3 vs. 2&4");
3107                         break;
3108 
3109                     case 3:
3110                         frost->printf(100, 115, "Alliance: 1&4 vs. 2&3");
3111                         break;
3112                     }
3113 
3114                 }
3115 
3116                 for (l = 0; l < 4; l++) {
3117                     if (config.player_type[l] == 3) {
3118                         frost->printf(110, 130 + l * 11, "%d. %s", l + 1, roster[config.player_number[l]].pilotname);
3119 
3120                     }
3121 
3122                     if (config.player_type[l] == 2) {
3123                         frost->printf(110, 130 + l * 11, "%d. Computer pilot", l + 1);
3124 
3125                     }
3126 
3127                     if (config.player_type[l] == 0) {
3128                         frost->printf(110, 130 + l * 11, "%d. Not active", l + 1);
3129 
3130 
3131                     }
3132 
3133 
3134 
3135                 }
3136 
3137             }
3138 
3139         } else {
3140             frost->printf(100, 100, "Sologame active");
3141             frost->printf(100, 110, "%s selected", plane_name[l]);
3142 
3143             frost->printf(110, 130, "%s flying", roster[config.player_number[l]].pilotname);
3144 
3145         }
3146 
3147         if (help_on)
3148             help->blit(0, 0);
3149 
3150         menuselect = 0;
3151         if (x >= 223 && x <= 283 && y >= 101 && y <= 139) {
3152             frost->printf(247, 32, "Start Game");
3153             menuselect = 1;
3154         }
3155 
3156         if (x >= 253 && x <= 279 && y >= 154 && y <= 184) {
3157             frost->printf(247, 32, "Quit to OS");
3158             menuselect = 2;
3159         }
3160 
3161         if (x >= 193 && x <= 236 && y >= 27 && y <= 69) {
3162             frost->printf(247, 32, "Edit\n Pilotroster");
3163             menuselect = 3;
3164         }
3165 
3166         if (x >= 131 && x <= 182 && y >= 26 && y <= 77) {
3167             frost->printf(247, 32, "List of Aces");
3168             menuselect = 4;
3169         }
3170 
3171         if (x >= 81 && x <= 125 && y >= 27 && y <= 67) {
3172             frost->printf(247, 32, "Set Controls");
3173             menuselect = 5;
3174         }
3175 
3176         if (x >= 30 && x <= 73 && y >= 27 && y <= 54) {
3177             frost->printf(247, 32, "Game Options");
3178             menuselect = 6;
3179         }
3180 
3181         if (x >= 30 && x <= 73 && y >= 57 && y <= 97) {
3182             frost->printf(247, 32, "Select Level");
3183             menuselect = 7;
3184         }
3185 
3186         if (x >= 30 && x <= 73 && y >= 101 && y <= 141) {
3187             frost->printf(247, 32, "Assign\n players");
3188             menuselect = 8;
3189         }
3190 
3191         if (x >= 242 && x <= 295 && y >= 27 && y <= 53) {
3192             frost->printf(247, 32, "Credits");
3193             menuselect = 9;
3194         }
3195 
3196         cursor->blit(x - 10, y - 10);
3197 
3198 
3199 
3200         if (mission_re_fly != -1) {
3201             n2 = 1;
3202             do_all();
3203         } else
3204             do_all();
3205 
3206         if (findparameter("-autostart")) {
3207             n1 = 1;
3208             menuselect = 1;
3209         }
3210 
3211         if ((n1 || n2) && menuselect) {
3212             help_on = 0;
3213 
3214             switch (menuselect) {
3215 
3216 
3217             case 1:
3218                 int full_seed;
3219                 int mc_c;
3220 
3221                 for (mc_c = 0; mc_c < 16; mc_c++) {
3222                     mc_up[mc_c] = 0;
3223                     mc_down[mc_c] = 0;
3224                     mc_roll[mc_c] = 0;
3225                     mc_power[mc_c] = 0;
3226                     mc_bomb[mc_c] = 0;
3227                     mc_guns[mc_c] = 0;
3228                 }
3229 
3230                 full_seed = time(0);
3231 
3232                 //// Record
3233 
3234                 FILE *rfile;
3235 
3236                 if (findparameter("-record")) {
3237                     rfile = settings_open("record.ran", "wb");
3238                     fwrite(&full_seed, sizeof(full_seed), 1, rfile);
3239 
3240                     fclose(rfile);
3241 
3242 
3243 
3244                 }
3245 
3246                 if (findparameter("-playback")) {
3247                     rfile = settings_open("record.ran", "rb");
3248                     fread(&full_seed, sizeof(full_seed), 1, rfile);
3249 
3250                     fclose(rfile);
3251 
3252 
3253 
3254                 }
3255 
3256                 main_engine_random_seed = full_seed;
3257                 ////
3258 
3259                 init_vga("PALET5");
3260 
3261                 for (l = 0; l < 16; l++) {
3262                     player_exists[l] = 0;
3263                     plane_present[l] = 0;
3264                 }
3265                 for (l = 0; l < 4; l++) {
3266                     if (config.player_type[l] == 1 || config.player_type[l] == 3) {
3267                         if (config.player_number[l] != -1) {
3268                             break;
3269 
3270                         }
3271                     }
3272 
3273                 }
3274                 if (l == 4) {
3275                     small_warning("You haven't selected any players.\n\n" "Please move on to the\n assignment menu\n");
3276                     break;
3277                 }
3278 
3279                 playing_solo = 0;
3280                 solo_mode = -1;
3281 
3282                 for (l = 0; l < 4; l++) {
3283                     switch (config.player_type[l]) {
3284                     case 0:
3285                         player_exists[l] = 0;
3286                         break;
3287 
3288                     case 1:
3289                         player_exists[l] = 1;
3290                         computer_active[l] = 0;
3291                         playing_solo = 1;
3292                         solo_country = l;
3293                         solo_mode = l;
3294                         break;
3295 
3296                     case 2:
3297                         if ((l == 1 || l == 2) && config.current_multilevel == 5) {
3298                             player_exists[l] = 0;
3299                             computer_active[l] = 0;
3300                             config.player_type[l] = 0;
3301 
3302                         } else {
3303                             player_exists[l] = 1;
3304                             computer_active[l] = 1;
3305                         }
3306                         break;
3307 
3308                     case 3:
3309                         player_exists[l] = 1;
3310                         computer_active[l] = 0;
3311                         break;
3312 
3313 
3314                     }
3315 
3316                 }
3317 
3318 
3319 
3320 
3321 
3322                 if (is_there_sound && (!findparameter("-nomusic"))) {
3323 
3324                     sdl_stop_music();
3325 
3326                 }
3327                 if (n1)
3328                     random_fade_out();
3329 
3330                 wait_mouse_relase();
3331 
3332                 if (config.svga && solo_mode == -1)
3333                     if (!findparameter("-debugnographics")) {
3334                         if (findparameter("-black"))
3335                             init_vesa("PALET3");
3336                         else
3337                             init_vesa("PALET5");
3338                     }
3339 
3340                 main_engine();
3341 
3342 
3343                 if (config.svga) {
3344                     if (!findparameter("-debugnographics")) {
3345 
3346                         init_vga("PALET5");
3347                     }
3348                     tyhjaa_vircr();
3349                     do_all();
3350                 }
3351 
3352                 if (findparameter("-autoquit")) {
3353                     exit(1);
3354                 }
3355 
3356                 if (!findparameter("-debugnoaftermath")) {
3357                     if (aftermath && !findparameter("-playback")) {
3358                         if (!(playing_solo && !mission_duration)) {
3359                             if (playing_solo) {
3360                                 do_aftermath(1);
3361 
3362                             } else {
3363                                 l3 = 0;
3364                                 for (l = 0; l < 4; l++)
3365                                     for (l2 = 0; l2 < 4; l2++)
3366                                         if (player_shots_down[l][l2])
3367                                             l3 = 1;
3368 
3369                                 if (l3) {
3370                                     do_aftermath(1);
3371 
3372                                 }
3373 
3374                             }
3375                         }
3376                     }
3377 
3378 
3379 
3380                 }
3381 
3382                 if (level_loaded) {
3383                     clear_level();
3384                     level_loaded = 0;
3385                 }
3386 
3387                 if (is_there_sound && config.music_on) {
3388 
3389                     sdl_play_music(triplane_mod);
3390 
3391                 }
3392 
3393                 hiiri_to(254, 120);
3394                 break;
3395 
3396             case 2:
3397                 if (n1)
3398                     random_fade_out();
3399                 exit_flag = 1;
3400                 break;
3401 
3402             case 3:
3403                 if (n1)
3404                     random_fade_out();
3405                 wait_mouse_relase();
3406                 roster_menu();
3407 
3408                 break;
3409 
3410             case 4:
3411                 if (n1)
3412                     random_fade_out();
3413                 wait_mouse_relase();
3414                 aces_menu();
3415 
3416                 break;
3417 
3418             case 5:
3419                 if (n1)
3420                     random_fade_out();
3421                 wait_mouse_relase();
3422                 controls_menu();
3423 
3424                 break;
3425 
3426             case 6:
3427                 if (n1)
3428                     random_fade_out();
3429                 wait_mouse_relase();
3430                 options_menu();
3431 
3432                 break;
3433 
3434             case 7:
3435                 if (n1)
3436                     random_fade_out();
3437                 wait_mouse_relase();
3438                 transfer_menu();
3439 
3440                 break;
3441 
3442             case 8:
3443                 if (n1)
3444                     random_fade_out();
3445                 wait_mouse_relase();
3446                 assign_menu();
3447                 hiiri_to(254, 120);
3448                 break;
3449 
3450             case 9:
3451                 if (n1)
3452                     random_fade_out();
3453                 wait_mouse_relase();
3454                 credits_menu();
3455 
3456                 break;
3457 
3458 
3459             }
3460         }
3461     }
3462 
3463     delete help;
3464 }
3465 
print_clear_roster(Bitmap * rosteri)3466 void print_clear_roster(Bitmap * rosteri) {
3467     rosteri->blit(0, 0);
3468     grid2->printf(152, 40, "Pilot Info");
3469 
3470 
3471 }
3472 
print_filled_roster(int number)3473 void print_filled_roster(int number) {
3474     int ts = 0;
3475 
3476     if (number == -1)
3477         return;
3478 
3479 
3480     grid2->printf(125, 50, "%s %s", rank_names[get_rank(number)], roster[number].pilotname);
3481 
3482     frost->printf(122, 65, "Solo Mission Totals:");
3483     frost->printf(122, 75, "Missions flown: %d (%d%% Suc.)", roster[number].solo_mis_flown,
3484                   (roster[number].solo_mis_flown ? roster[number].solo_mis_success * 100 / roster[number].solo_mis_flown : 0));
3485     frost->printf(122, 83, "Kills : %d, Died : %d times", roster[number].solo_mis_drops, roster[number].solo_mis_dropped);
3486     frost->printf(122, 91, "Shots used : %d (%d%% Ac.)", roster[number].solo_mis_shotsf,
3487                   (roster[number].solo_mis_shotsf ? roster[number].solo_mis_shotshit * 100 / roster[number].solo_mis_shotsf : 0));
3488     frost->printf(122, 99, "Bombs drop : %d (%d%% Ac.)", roster[number].solo_mis_bombs,
3489                   (roster[number].solo_mis_bombs ? roster[number].solo_mis_bombshit * 100 / roster[number].solo_mis_bombs : 0));
3490     frost->printf(122, 107, "- Solo total score: %d", roster[number].solo_mis_totals);
3491 
3492     frost->printf(122, 125, "Multiplayer Game Totals:");
3493     frost->printf(122, 135, "Missions flown: %d (%d%% Won)", roster[number].multi_mis_flown,
3494                   (roster[number].multi_mis_flown ? roster[number].multi_mis_success * 100 / roster[number].multi_mis_flown : 0));
3495     frost->printf(122, 143, "Kills : %d, Died : %d times", roster[number].multi_mis_drops, roster[number].multi_mis_dropped);
3496     frost->printf(122, 151, "Shots used : %d (%d%% Ac.)", roster[number].multi_mis_shotsf,
3497                   (roster[number].multi_mis_shotsf ? roster[number].multi_mis_shotshit * 100 / roster[number].multi_mis_shotsf : 0));
3498     frost->printf(122, 159, "Bombs drop : %d (%d%% Ac.)", roster[number].multi_mis_bombs,
3499                   (roster[number].multi_mis_bombs ? roster[number].multi_mis_bombshit * 100 / roster[number].multi_mis_bombs : 0));
3500 
3501     ts += roster[number].multi_mis_flown;
3502     ts += roster[number].multi_mis_success * 10;
3503     ts += roster[number].multi_mis_drops * 4;
3504     ts -= roster[number].multi_mis_dropped;
3505     ts -= roster[number].multi_mis_shotsf / 128;
3506     ts += roster[number].multi_mis_shotshit / 60;
3507     ts -= roster[number].multi_mis_bombs / 12;
3508     ts += roster[number].multi_mis_bombshit / 6;
3509 
3510     frost->printf(122, 167, "- Multiplayer score: %d", ts);
3511 
3512     frost->printf(122, 177, "Total: %d", ts + roster[number].solo_mis_totals);
3513 
3514 }
3515 
wait_mouse_relase(int nokb)3516 void wait_mouse_relase(int nokb) {
3517     int n1 = 1, n2 = 1, x, y;
3518 
3519     while (n1 || n2) {
3520         koords(&x, &y, &n1, &n2);
3521 
3522         if (!nokb)
3523             while (kbhit())
3524                 getch();
3525     }
3526 }
3527