1 /* $Id: gamecntl.c,v 1.21 2003-10-10 09:36:35 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
25 //#define DOOR_DEBUGGING
102 #include "multibot.h"
109 # include "poly_acc.h"
112 //#define TEST_TIMER 1 //if this is set, do checking on timer
114 #define SHOW_EXIT_PATH 1
116 #define Arcade_mode 0
120 #include "editor/editor.h"
125 #if __WATCOMC__ < 1000
126 #include <wsample.h> //should come after inferno.h to get mark setting
134 extern void full_palette_save(void);
135 extern void object_goto_prev_viewer(void);
137 // Global Variables -----------------------------------------------------------
139 int redbook_volume = 255;
142 // External Variables ---------------------------------------------------------
144 extern int Speedtest_on; // Speedtest global adapted from game.c
145 extern int Guided_in_big_window;
146 extern char WaitForRefuseAnswer,RefuseThisPlayer,RefuseTeam;
149 extern int Mark_count;
150 extern int Speedtest_start_time;
151 extern int Speedtest_segnum;
152 extern int Speedtest_sidenum;
153 extern int Speedtest_frame_start;
154 extern int Speedtest_count;
157 extern int Global_missile_firing_count;
158 extern int Automap_flag;
159 extern int Config_menu_flag;
160 extern int EscortHotKeys;
163 extern int Game_aborted;
164 extern int *Toggle_var;
166 extern int Physics_cheat_flag;
168 extern int last_drawn_cockpit[2];
170 extern int Debug_spew;
171 extern int Debug_pause;
172 extern cvar_t r_framerate;
174 extern fix Show_view_text_timer;
176 extern ubyte DefiningMarkerMessage;
178 // Function prototypes --------------------------------------------------------
181 extern void CyclePrimary();
182 extern void CycleSecondary();
183 extern void InitMarkerInput();
184 extern void MarkerInputMessage (int);
185 extern void grow_window(void);
186 extern void shrink_window(void);
187 extern int allowed_to_fire_missile(void);
188 extern int allowed_to_fire_flare(void);
189 extern void check_rear_view(void);
190 extern int create_special_path(void);
191 extern void move_player_2_segment(segment *seg, int side);
192 extern void kconfig_center_headset(void);
193 extern void game_render_frame_mono(void);
194 extern void newdemo_strip_frames(char *, int);
195 extern void toggle_cockpit(void);
196 extern int dump_used_textures_all(void);
197 extern void DropMarker();
198 extern void DropSecondaryWeapon();
199 extern void DropCurrentWeapon();
201 void FinalCheats(int key);
204 void do_cheat_menu(void);
207 void HandleGameKey(int key);
208 int HandleSystemKey(int key);
209 void HandleTestKey(int key);
210 void HandleVRKey(int key);
212 void speedtest_init(void);
213 void speedtest_frame(void);
214 void advance_sound(void);
215 void play_test_sound(void);
218 extern void macintosh_quit(void); // dialog-style quit function
221 #define key_isfunc(k) (((k&0xff)>=KEY_F1 && (k&0xff)<=KEY_F10) || (k&0xff)==KEY_F11 || (k&0xff)==KEY_F12)
222 #define key_ismod(k) ((k&0xff)==KEY_LALT || (k&0xff)==KEY_RALT || (k&0xff)==KEY_LSHIFT || (k&0xff)==KEY_RSHIFT || (k&0xff)==KEY_LCTRL || (k&0xff)==KEY_RCTRL)
224 // Functions ------------------------------------------------------------------
226 #define CONVERTER_RATE 20 //10 units per second xfer rate
227 #define CONVERTER_SCALE 2 //2 units energy -> 1 unit shields
229 #define CONVERTER_SOUND_DELAY (f1_0/2) //play every half second
231 void transfer_energy_to_shield(fix time)
233 fix e; //how much energy gets transfered
234 static fix last_play_time=0;
236 e = min(min(time*CONVERTER_RATE,Players[Player_num].energy - INITIAL_ENERGY),(MAX_SHIELDS-Players[Player_num].shields)*CONVERTER_SCALE);
240 if (Players[Player_num].energy <= INITIAL_ENERGY)
241 HUD_init_message("Need more than %i energy to enable transfer", f2i(INITIAL_ENERGY));
243 HUD_init_message("No transfer: Shields already at max");
247 Players[Player_num].energy -= e;
248 Players[Player_num].shields += e/CONVERTER_SCALE;
250 if (last_play_time > GameTime)
253 if (GameTime > last_play_time+CONVERTER_SOUND_DELAY) {
254 digi_play_sample_once(SOUND_CONVERT_ENERGY, F1_0);
255 last_play_time = GameTime;
260 void update_vcr_state();
261 void do_weapon_stuff(void);
266 fix newdemo_single_frame_time;
268 void update_vcr_state(void)
270 if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_RIGHT])
271 Newdemo_vcr_state = ND_STATE_FASTFORWARD;
272 else if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_LEFT])
273 Newdemo_vcr_state = ND_STATE_REWINDING;
274 else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_RIGHT] && ((timer_get_fixed_seconds() - newdemo_single_frame_time) >= F1_0))
275 Newdemo_vcr_state = ND_STATE_ONEFRAMEFORWARD;
276 else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_LEFT] && ((timer_get_fixed_seconds() - newdemo_single_frame_time) >= F1_0))
277 Newdemo_vcr_state = ND_STATE_ONEFRAMEBACKWARD;
278 else if ((Newdemo_vcr_state == ND_STATE_FASTFORWARD) || (Newdemo_vcr_state == ND_STATE_REWINDING))
279 Newdemo_vcr_state = ND_STATE_PLAYBACK;
282 //returns which bomb will be dropped next time the bomb key is pressed
287 //use the last one selected, unless there aren't any, in which case use
288 //the other if there are any
291 // If hoard game, only let the player drop smart mines
292 if (Game_mode & GM_HOARD)
293 return SMART_MINE_INDEX;
295 bomb = Secondary_last_was_super[PROXIMITY_INDEX]?SMART_MINE_INDEX:PROXIMITY_INDEX;
297 if (Players[Player_num].secondary_ammo[bomb] == 0 &&
298 Players[Player_num].secondary_ammo[SMART_MINE_INDEX+PROXIMITY_INDEX-bomb] != 0) {
299 bomb = SMART_MINE_INDEX+PROXIMITY_INDEX-bomb;
300 Secondary_last_was_super[bomb%SUPER_WEAPON] = (bomb == SMART_MINE_INDEX);
309 void do_weapon_stuff(void)
313 if (Controls.fire_flare_down_count)
314 if (allowed_to_fire_flare())
315 Flare_create(ConsoleObject);
317 if (allowed_to_fire_missile())
318 Global_missile_firing_count += Weapon_info[Secondary_weapon_to_weapon_info[Secondary_weapon]].fire_count * (Controls.fire_secondary_state || Controls.fire_secondary_down_count);
320 if (Global_missile_firing_count) {
321 do_missile_firing(1); //always enable autoselect for normal missile firing
322 Global_missile_firing_count--;
325 if (Controls.cycle_primary_count)
327 for (i=0;i<Controls.cycle_primary_count;i++)
330 if (Controls.cycle_secondary_count)
332 for (i=0;i<Controls.cycle_secondary_count;i++)
335 if (Controls.headlight_count)
337 for (i=0;i<Controls.headlight_count;i++)
338 toggle_headlight_active ();
341 if (Global_missile_firing_count < 0)
342 Global_missile_firing_count = 0;
344 // Drop proximity bombs.
345 if (Controls.drop_bomb_down_count) {
346 int ssw_save = Secondary_weapon;
348 while (Controls.drop_bomb_down_count--) {
351 ssw_save2 = Secondary_weapon = which_bomb();
353 do_missile_firing(Secondary_weapon == ssw_save); //only allow autoselect if bomb is actually selected
355 if (Secondary_weapon != ssw_save2 && ssw_save == ssw_save2)
356 ssw_save = Secondary_weapon; //if bomb was selected, and we ran out & autoselect, then stick with new selection
359 Secondary_weapon = ssw_save;
367 extern void game_render_frame();
368 extern void show_extra_views();
369 extern fix Flash_effect;
371 void apply_modified_palette(void)
374 //@@ grs_bitmap *sbp;
375 //@@ grs_canvas *save_canv;
376 //@@ int color_xlate[256];
379 //@@ if (!Flash_effect && ((PaletteRedAdd < 10) || (PaletteRedAdd < (PaletteGreenAdd + PaletteBlueAdd))))
382 //@@ reset_cockpit();
384 //@@ save_canv = grd_curcanv;
385 //@@ gr_set_current_canvas(&grd_curscreen->sc_canvas);
387 //@@ sbp = &grd_curscreen->sc_canvas.cv_bitmap;
389 //@@ for (x=0; x<256; x++)
390 //@@ color_xlate[x] = -1;
392 //@@ for (k=0; k<4; k++) {
393 //@@ for (y=0; y<grd_curscreen->sc_h; y+= 4) {
394 //@@ for (x=0; x<grd_curscreen->sc_w; x++) {
395 //@@ int color, new_color;
402 //@@ color = gr_ugpixel(sbp, xcrd, ycrd);
404 //@@ if (color_xlate[color] == -1) {
405 //@@ r = gr_palette[color*3+0];
406 //@@ g = gr_palette[color*3+1];
407 //@@ b = gr_palette[color*3+2];
409 //@@ r += PaletteRedAdd; if (r > 63) r = 63;
410 //@@ g += PaletteGreenAdd; if (g > 63) g = 63;
411 //@@ b += PaletteBlueAdd; if (b > 63) b = 63;
413 //@@ color_xlate[color] = gr_find_closest_color_current(r, g, b);
417 //@@ new_color = color_xlate[color];
419 //@@ gr_setcolor(new_color);
420 //@@ gr_upixel(xcrd, ycrd);
426 void format_time(char *str, int secs_int)
434 sprintf(str, "%1d:%02d:%02d", h, m, s );
437 extern int Redbook_playing;
438 void do_show_netgame_help();
440 //Process selected keys until game unpaused. returns key that left pause (p or esc)
445 char total_time[9],level_time[9];
449 if (Game_paused) { //unpause!
451 #if defined (TACTILE)
459 if (Game_mode & GM_NETWORK)
461 do_show_netgame_help();
464 else if (Game_mode & GM_MULTI)
466 HUD_init_message ("You cannot pause in a modem/serial game!");
476 apply_modified_palette();
479 // -- Matt: This is a hacked-in test for the stupid menu/flash problem.
480 // We need a new brightening primitive if we want to make this not horribly ugly.
481 // Gr_scanline_darkening_level = 2;
482 // gr_rect(0, 0, 319, 199);
488 #if defined (TACTILE)
494 // set_screen_mode( SCREEN_MENU );
496 gr_palette_load( gr_palette );
498 format_time(total_time, f2i(Players[Player_num].time_total) + Players[Player_num].hours_total*3600);
499 format_time(level_time, f2i(Players[Player_num].time_level) + Players[Player_num].hours_level*3600);
501 if (Newdemo_state!=ND_STATE_PLAYBACK)
502 sprintf(msg,"PAUSE\n\nSkill level: %s\nHostages on board: %d\nTime on level: %s\nTotal time in game: %s",(*(&TXT_DIFFICULTY_1 + (Difficulty_level))),Players[Player_num].hostages_on_board,level_time,total_time);
504 sprintf(msg,"PAUSE\n\nSkill level: %s\nHostages on board: %d\n",(*(&TXT_DIFFICULTY_1 + (Difficulty_level))),Players[Player_num].hostages_on_board);
506 show_boxed_message(Pause_msg=msg); //TXT_PAUSE);
510 /* give control back to the WM */
511 if (FindArg("-grabmouse"))
512 SDL_WM_GrabInput(SDL_GRAB_OFF);
519 #if defined (WINDOWS)
521 if (!(VR_screen_flags & VRF_COMPATIBLE_MENUS)) {
522 show_boxed_message(msg);
527 while (!(key = key_inkey()))
530 DoMessageStuff(&wmsg);
532 mprintf((0, "Redrawing paused screen.\n"));
533 _RedrawScreen = FALSE;
534 if (VR_screen_flags & VRF_COMPATIBLE_MENUS)
538 gr_palette_load(gr_palette);
539 show_boxed_message(msg);
540 if (Cockpit_mode==CM_FULL_COCKPIT || Cockpit_mode==CM_STATUS_BAR)
541 if (!GRMODEINFO(modex)) render_gauges();
553 screen_changed = HandleSystemKey(key);
556 if (screen_changed == -1) {
557 nm_messagebox(NULL,1, TXT_OK, "Unable to do this\noperation while paused under\n320x200 mode");
564 if (screen_changed) {
565 // game_render_frame();
566 WIN(set_popup_screen());
567 show_boxed_message(msg);
568 //show_extra_views();
569 if (Cockpit_mode==CM_FULL_COCKPIT || Cockpit_mode==CM_STATUS_BAR)
575 /* keep the mouse from wandering in SDL */
576 if (FindArg("-grabmouse"))
577 SDL_WM_GrabInput(SDL_GRAB_ON);
580 if (VR_screen_flags & VRF_COMPATIBLE_MENUS) {
581 clear_boxed_message();
596 MAC(delay(500);) // delay 1/2 second because of dumb redbook problem
601 extern int newmenu_dotiny2( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem) );
602 extern int network_who_is_master(),network_how_many_connected(),GetMyNetRanking();
603 extern int TotalMissedPackets,TotalPacketsGot;
604 extern char Pauseable_menu;
605 char *NetworkModeNames[]={"Anarchy","Team Anarchy","Robo Anarchy","Cooperative","Capture the Flag","Hoard","Team Hoard","Unknown"};
606 extern char *RankStrings[];
607 extern int PhallicLimit,PhallicMan;
610 void do_show_netgame_help()
618 char *eff_strings[]={"trashing","really hurting","seriously effecting","hurting",
619 "effecting","tarnishing"};
623 m[i].text=(char *)&mtext[i];
624 m[i].type=NM_TYPE_TEXT;
627 sprintf (mtext[num],"Game: %s",Netgame.game_name); num++;
628 sprintf (mtext[num],"Mission: %s",Netgame.mission_title); num++;
629 sprintf (mtext[num],"Current Level: %d",Netgame.levelnum); num++;
630 sprintf (mtext[num],"Difficulty: %s",MENU_DIFFICULTY_TEXT(Netgame.difficulty)); num++;
631 sprintf (mtext[num],"Game Mode: %s",NetworkModeNames[Netgame.gamemode]); num++;
632 sprintf (mtext[num],"Game Master: %s",Players[network_who_is_master()].callsign); num++;
633 sprintf (mtext[num],"Number of players: %d/%d",network_how_many_connected(),Netgame.max_numplayers); num++;
634 sprintf (mtext[num],"Packets per second: %d",Netgame.PacketsPerSec); num++;
635 sprintf (mtext[num],"Short Packets: %s",Netgame.ShortPackets?"Yes":"No"); num++;
638 pl=(int)(((float)TotalMissedPackets/(float)TotalPacketsGot)*100.0);
641 sprintf (mtext[num],"Packets lost: %d (%d%%)",TotalMissedPackets,pl); num++;
644 if (Netgame.KillGoal)
645 { sprintf (mtext[num],"Kill goal: %d",Netgame.KillGoal*5); num++; }
647 sprintf (mtext[num]," "); num++;
648 sprintf (mtext[num],"Connected players:"); num++;
650 NetPlayers.players[Player_num].rank=GetMyNetRanking();
652 for (i=0;i<N_players;i++)
653 if (Players[i].connected)
655 if (!FindArg ("-norankings"))
658 sprintf (mtext[num],"%s%s (%d/%d)",RankStrings[NetPlayers.players[i].rank],Players[i].callsign,Netlife_kills,Netlife_killed);
660 sprintf (mtext[num],"%s%s %d/%d",RankStrings[NetPlayers.players[i].rank],Players[i].callsign,kill_matrix[Player_num][i],
661 kill_matrix[i][Player_num]);
665 sprintf (mtext[num++],"%s",Players[i].callsign);
669 sprintf (mtext[num]," "); num++;
671 eff=(int)((float)((float)Netlife_kills/((float)Netlife_killed+(float)Netlife_kills))*100.0);
676 if (Game_mode & GM_HOARD)
679 sprintf (mtext[num],"There is no record yet for this level.");
681 sprintf (mtext[num],"%s has the record at %d points.",Players[PhallicMan].callsign,PhallicLimit);
684 else if (!FindArg ("-norankings"))
688 sprintf (mtext[num],"Your lifetime efficiency of %d%%",eff); num++;
689 sprintf (mtext[num],"is %s your ranking.",eff_strings[eff/10]); num++;
693 sprintf (mtext[num],"Your lifetime efficiency of %d%%",eff); num++;
694 sprintf (mtext[num],"is serving you well."); num++;
702 newmenu_dotiny2( NULL, "Netgame Information", num, m, NULL);
708 void HandleEndlevelKey(int key)
712 if ( key == (KEY_COMMAND + KEY_SHIFTED + KEY_3) )
715 if ( key == KEY_COMMAND+KEY_Q && !(Game_mode & GM_MULTI) )
719 if (key==KEY_PRINT_SCREEN)
723 if ( key == (KEY_COMMAND+KEY_P) )
724 key = do_game_pause();
726 if (key == KEY_PAUSE)
727 key = do_game_pause(); //so esc from pause will end level
729 if (key == KEY_ESC) {
730 stop_endlevel_sequence();
731 last_drawn_cockpit[0]=-1;
732 last_drawn_cockpit[1]=-1;
736 if (key == KEY_BACKSP)
740 void HandleDeathKey(int key)
743 Commented out redundant calls because the key used here typically
744 will be passed to HandleSystemKey later. Note that I do this to pause
745 which is supposed to pass the ESC key to leave the level. This
746 doesn't work in the DOS version anyway. -Samir
749 if (Player_exploded && !key_isfunc(key) && !key_ismod(key))
750 Death_sequence_aborted = 1; //Any key but func or modifier aborts
753 if ( key == (KEY_COMMAND + KEY_SHIFTED + KEY_3) ) {
754 // save_screen_shot(0);
755 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
758 if ( key == KEY_COMMAND+KEY_Q && !(Game_mode & GM_MULTI) )
762 if (key==KEY_PRINT_SCREEN) {
763 // save_screen_shot(0);
764 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
768 if ( key == (KEY_COMMAND+KEY_P) ) {
769 // key = do_game_pause();
770 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
774 if (key == KEY_PAUSE) {
775 // key = do_game_pause(); //so esc from pause will end level
776 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
779 if (key == KEY_ESC) {
780 if (ConsoleObject->flags & OF_EXPLODING)
781 Death_sequence_aborted = 1;
784 if (key == KEY_BACKSP) {
785 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
789 //don't abort death sequence for netgame join/refuse keys
790 if ( (key == KEY_ALTED + KEY_1) ||
791 (key == KEY_ALTED + KEY_2))
792 Death_sequence_aborted = 0;
794 if (Death_sequence_aborted)
799 void HandleDemoKey(int key)
809 HUD_init_message("Cockpit not available while using QuickDraw 3D.");
815 PA_DFX (HUD_init_message ("Cockpit not available in 3dfx version."));
817 if (!(Guided_missile[Player_num] && Guided_missile[Player_num]->type==OBJ_WEAPON && Guided_missile[Player_num]->id==GUIDEDMISS_ID && Guided_missile[Player_num]->signature==Guided_missile_sig[Player_num] && Guided_in_big_window))
821 case KEY_SHIFTED+KEY_MINUS:
822 case KEY_MINUS: shrink_window(); break;
824 case KEY_SHIFTED+KEY_EQUAL:
825 case KEY_EQUAL: grow_window(); break;
827 MAC(case KEY_COMMAND+KEY_2:)
828 case KEY_F2: Config_menu_flag = 1; break;
830 MAC(case KEY_COMMAND+KEY_7:)
833 Show_kill_list = (Show_kill_list+1) % ((Newdemo_game_mode & GM_TEAM) ? 4 : 3);
837 Function_mode = FMODE_MENU;
840 Newdemo_vcr_state = ND_STATE_PLAYBACK;
843 Newdemo_vcr_state = ND_STATE_PAUSED;
846 newdemo_single_frame_time = timer_get_fixed_seconds();
847 Newdemo_vcr_state = ND_STATE_ONEFRAMEBACKWARD;
850 newdemo_single_frame_time = timer_get_fixed_seconds();
851 Newdemo_vcr_state = ND_STATE_ONEFRAMEFORWARD;
853 case KEY_CTRLED + KEY_RIGHT:
856 case KEY_CTRLED + KEY_LEFT:
857 newdemo_goto_beginning();
860 MAC(case KEY_COMMAND+KEY_P:)
865 MAC(case KEY_COMMAND + KEY_SHIFTED + KEY_3:)
866 case KEY_PRINT_SCREEN: {
869 old_state = Newdemo_vcr_state;
870 Newdemo_vcr_state = ND_STATE_PRINTSCREEN;
871 game_render_frame_mono();
873 Newdemo_vcr_state = old_state;
878 case KEY_COMMAND+KEY_Q:
879 if ( !(Game_mode & GM_MULTI) )
888 case KEY_DEBUGGED + KEY_I:
889 Newdemo_do_interpolate = !Newdemo_do_interpolate;
890 if (Newdemo_do_interpolate)
891 mprintf ((0, "demo playback interpolation now on\n"));
893 mprintf ((0, "demo playback interpolation now off\n"));
895 case KEY_DEBUGGED + KEY_K: {
897 char filename[FILENAME_LEN], num[16];
901 m[ 0].type = NM_TYPE_TEXT; m[ 0].text = "output file name";
902 m[ 1].type = NM_TYPE_INPUT;m[ 1].text_len = 8; m[1].text = filename;
903 c = newmenu_do( NULL, NULL, 2, m, NULL );
906 strcat(filename, ".dem");
908 m[ 0].type = NM_TYPE_TEXT; m[ 0].text = "strip how many bytes";
909 m[ 1].type = NM_TYPE_INPUT;m[ 1].text_len = 16; m[1].text = num;
910 c = newmenu_do( NULL, NULL, 2, m, NULL );
913 how_many = atoi(num);
916 newdemo_strip_frames(filename, how_many);
925 //switch a cockpit window to the next function
926 int select_next_window_function(int w)
928 Assert(w==0 || w==1);
930 switch (Cockpit_3d_view[w]) {
932 Cockpit_3d_view[w] = CV_REAR;
936 Cockpit_3d_view[w] = CV_ESCORT;
939 //if no ecort, fall through
941 Coop_view_player[w] = -1; //force first player
945 Marker_viewer_num[w] = -1;
946 if ((Game_mode & GM_MULTI_COOP) || (Game_mode & GM_TEAM)) {
947 Cockpit_3d_view[w] = CV_COOP;
949 Coop_view_player[w]++;
950 if (Coop_view_player[w] == N_players) {
951 Cockpit_3d_view[w] = CV_MARKER;
954 if (Coop_view_player[w]==Player_num)
957 if (Game_mode & GM_MULTI_COOP)
959 else if (get_team(Coop_view_player[w]) == get_team(Player_num))
964 //if not multi, fall through
967 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) && Netgame.Allow_marker_view) { //anarchy only
968 Cockpit_3d_view[w] = CV_MARKER;
969 if (Marker_viewer_num[w] == -1)
970 Marker_viewer_num[w] = Player_num * 2;
971 else if (Marker_viewer_num[w] == Player_num * 2)
972 Marker_viewer_num[w]++;
974 Cockpit_3d_view[w] = CV_NONE;
978 Cockpit_3d_view[w] = CV_NONE;
983 return 1; //screen_changed
986 extern int Game_paused;
988 void songs_goto_next_song();
989 void songs_goto_prev_song();
991 #ifdef DOOR_DEBUGGING
992 dump_door_debugging_info()
1002 obj = &Objects[Players[Player_num].objnum];
1003 vm_vec_scale_add(&new_pos,&obj->pos,&obj->orient.fvec,i2f(100));
1006 fq.startseg = obj->segnum;
1009 fq.thisobjnum = Players[Player_num].objnum;
1010 fq.ignore_obj_list = NULL;
1013 fate = find_vector_intersection(&fq,&hit_info);
1015 dfile = fopen("door.out","at");
1017 fprintf(dfile,"FVI hit_type = %d\n",fate);
1018 fprintf(dfile," hit_seg = %d\n",hit_info.hit_seg);
1019 fprintf(dfile," hit_side = %d\n",hit_info.hit_side);
1020 fprintf(dfile," hit_side_seg = %d\n",hit_info.hit_side_seg);
1021 fprintf(dfile,"\n");
1023 if (fate == HIT_WALL) {
1025 wall_num = Segments[hit_info.hit_seg].sides[hit_info.hit_side].wall_num;
1026 fprintf(dfile,"wall_num = %d\n",wall_num);
1028 if (wall_num != -1) {
1029 wall *wall = &Walls[wall_num];
1033 fprintf(dfile," segnum = %d\n",wall->segnum);
1034 fprintf(dfile," sidenum = %d\n",wall->sidenum);
1035 fprintf(dfile," hps = %x\n",wall->hps);
1036 fprintf(dfile," linked_wall = %d\n",wall->linked_wall);
1037 fprintf(dfile," type = %d\n",wall->type);
1038 fprintf(dfile," flags = %x\n",wall->flags);
1039 fprintf(dfile," state = %d\n",wall->state);
1040 fprintf(dfile," trigger = %d\n",wall->trigger);
1041 fprintf(dfile," clip_num = %d\n",wall->clip_num);
1042 fprintf(dfile," keys = %x\n",wall->keys);
1043 fprintf(dfile," controlling_trigger = %d\n",wall->controlling_trigger);
1044 fprintf(dfile," cloak_value = %d\n",wall->cloak_value);
1045 fprintf(dfile,"\n");
1048 for (i=0;i<Num_open_doors;i++) { //find door
1049 d = &ActiveDoors[i];
1050 if (d->front_wallnum[0]==wall-Walls || d->back_wallnum[0]==wall-Walls || (d->n_parts==2 && (d->front_wallnum[1]==wall-Walls || d->back_wallnum[1]==wall-Walls)))
1054 if (i>=Num_open_doors)
1055 fprintf(dfile,"No active door.\n");
1057 fprintf(dfile,"Active door %d:\n",i);
1058 fprintf(dfile," n_parts = %d\n",d->n_parts);
1059 fprintf(dfile," front_wallnum = %d,%d\n",d->front_wallnum[0],d->front_wallnum[1]);
1060 fprintf(dfile," back_wallnum = %d,%d\n",d->back_wallnum[0],d->back_wallnum[1]);
1061 fprintf(dfile," time = %x\n",d->time);
1067 fprintf(dfile,"\n");
1068 fprintf(dfile,"\n");
1076 //this is for system-level keys, such as help, etc.
1077 //returns 1 if screen changed
1078 int HandleSystemKey(int key)
1080 int screen_changed=0;
1082 if (!Player_is_dead)
1085 #ifdef DOOR_DEBUGGING
1086 case KEY_LAPOSTRO+KEY_SHIFTED:
1087 dump_door_debugging_info();
1096 Function_mode = FMODE_MENU;
1100 // fleshed these out because F1 and F2 aren't sequenctial keycodes on mac -- MWA
1102 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_1:)
1103 case KEY_SHIFTED+KEY_F1:
1104 screen_changed = select_next_window_function(0);
1106 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_2:)
1107 case KEY_SHIFTED+KEY_F2:
1108 screen_changed = select_next_window_function(1);
1115 case KEY_SHIFTED + KEY_ESC:
1120 case KEY_SHIFTED + KEY_ESC: //quick exit
1122 if (! SafetyCheck()) break;
1123 close_editor_screen();
1127 Function_mode=FMODE_EXIT;
1131 MAC( case KEY_COMMAND+KEY_P: )
1133 do_game_pause(); break;
1136 case KEY_COMMAND + KEY_D:
1137 Scanline_double = !Scanline_double;
1142 MAC(case KEY_COMMAND + KEY_SHIFTED + KEY_3:)
1143 case KEY_PRINT_SCREEN: save_screen_shot(0); break;
1145 MAC(case KEY_COMMAND+KEY_1:)
1146 case KEY_F1: do_show_help(); break;
1148 MAC(case KEY_COMMAND+KEY_2:)
1149 case KEY_F2: //Config_menu_flag = 1; break;
1151 int scanline_save = Scanline_double;
1153 if (!(Game_mode&GM_MULTI)) {palette_save(); apply_modified_palette(); reset_palette_add(); gr_palette_load(gr_palette); }
1155 if (!(Game_mode&GM_MULTI)) palette_restore();
1156 if (scanline_save != Scanline_double) init_cockpit(); // reset the cockpit after changing...
1157 PA_DFX (init_cockpit());
1162 MAC(case KEY_COMMAND+KEY_3:)
1165 #ifdef WINDOWS // HACK! these shouldn't work in 320x200 pause or in letterbox.
1166 if (Player_is_dead) break;
1167 if (!(VR_screen_flags&VRF_COMPATIBLE_MENUS) && Game_paused) {
1168 screen_changed = -1;
1177 HUD_init_message("Cockpit not available while using QuickDraw 3D.");
1183 PA_DFX (HUD_init_message ("Cockpit not available in 3dfx version."));
1186 if (!(Guided_missile[Player_num] && Guided_missile[Player_num]->type==OBJ_WEAPON && Guided_missile[Player_num]->id==GUIDEDMISS_ID && Guided_missile[Player_num]->signature==Guided_missile_sig[Player_num] && Guided_in_big_window))
1188 toggle_cockpit(); screen_changed=1;
1192 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_7:)
1193 case KEY_F7+KEY_SHIFTED: palette_save(); joydefs_calibrate(); palette_restore(); break;
1195 case KEY_SHIFTED+KEY_MINUS:
1198 if (Player_is_dead) break;
1199 if (!(VR_screen_flags&VRF_COMPATIBLE_MENUS) && Game_paused) {
1200 screen_changed = -1;
1209 case KEY_SHIFTED+KEY_EQUAL:
1212 if (Player_is_dead) break;
1213 if (!(VR_screen_flags&VRF_COMPATIBLE_MENUS) && Game_paused) {
1214 screen_changed = -1;
1223 MAC(case KEY_COMMAND+KEY_5:)
1225 if ( Newdemo_state == ND_STATE_RECORDING )
1226 newdemo_stop_recording();
1227 else if ( Newdemo_state == ND_STATE_NORMAL )
1228 if (!Game_paused) //can't start demo while paused
1229 newdemo_start_recording();
1232 MAC(case KEY_COMMAND+KEY_ALTED+KEY_4:)
1233 case KEY_ALTED+KEY_F4:
1235 Show_reticle_name = (Show_reticle_name+1)%2;
1239 MAC(case KEY_COMMAND+KEY_7:)
1242 Show_kill_list = (Show_kill_list+1) % ((Game_mode & GM_TEAM) ? 4 : 3);
1243 if (Game_mode & GM_MULTI)
1244 multi_sort_kill_list();
1248 MAC(case KEY_COMMAND+KEY_8:)
1251 multi_send_message_start();
1260 multi_send_macro(key);
1262 break; // send taunt macros
1265 case KEY_9 + KEY_COMMAND:
1266 multi_send_macro(KEY_F9);
1268 case KEY_0 + KEY_COMMAND:
1269 multi_send_macro(KEY_F10);
1271 case KEY_1 + KEY_COMMAND + KEY_CTRLED:
1272 multi_send_macro(KEY_F11);
1274 case KEY_2 + KEY_COMMAND + KEY_CTRLED:
1275 multi_send_macro(KEY_F12);
1279 case KEY_SHIFTED + KEY_F9:
1280 case KEY_SHIFTED + KEY_F10:
1281 case KEY_SHIFTED + KEY_F11:
1282 case KEY_SHIFTED + KEY_F12:
1284 multi_define_macro(key);
1286 break; // redefine taunt macros
1289 case KEY_9 + KEY_SHIFTED + KEY_COMMAND:
1290 multi_define_macro(KEY_F9);
1292 case KEY_0 + KEY_SHIFTED + KEY_COMMAND:
1293 multi_define_macro(KEY_F10);
1295 case KEY_1 + KEY_SHIFTED + KEY_COMMAND + KEY_CTRLED:
1296 multi_define_macro(KEY_F11);
1298 case KEY_2 + KEY_SHIFTED + KEY_COMMAND + KEY_CTRLED:
1299 multi_define_macro(KEY_F12);
1303 #if defined(MACINTOSH) && defined(POLY_ACC)
1304 case KEY_COMMAND+KEY_ALTED+KEY_1:
1306 { // hackish, to enable RAVE filtering hotkey,
1307 // not widely publicized
1308 pa_toggle_filtering();
1314 MAC(case KEY_COMMAND+KEY_S:)
1315 MAC(case KEY_COMMAND+KEY_ALTED+KEY_2:)
1316 case KEY_ALTED+KEY_F2:
1317 if (!Player_is_dead && !((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))) {
1318 int rsave, gsave, bsave;
1319 rsave = PaletteRedAdd;
1320 gsave = PaletteGreenAdd;
1321 bsave = PaletteBlueAdd;
1323 full_palette_save();
1324 PaletteRedAdd = rsave;
1325 PaletteGreenAdd = gsave;
1326 PaletteBlueAdd = bsave;
1327 state_save_all( 0, 0, NULL );
1330 break; // 0 means not between levels.
1332 MAC(case KEY_COMMAND+KEY_O:)
1333 MAC(case KEY_COMMAND+KEY_ALTED+KEY_3:)
1334 case KEY_ALTED+KEY_F3:
1335 if (!Player_is_dead && !((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))) {
1336 full_palette_save();
1337 state_restore_all(1, 0, NULL);
1344 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_4:)
1345 case KEY_F4 + KEY_SHIFTED:
1350 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_ALTED+KEY_4:)
1351 case KEY_F4 + KEY_SHIFTED + KEY_ALTED:
1352 change_guidebot_name();
1355 case KEY_MINUS + KEY_ALTED: songs_goto_prev_song(); break;
1356 case KEY_EQUAL + KEY_ALTED: songs_goto_next_song(); break;
1360 case KEY_COMMAND+KEY_M:
1361 #if !defined(SHAREWARE) || defined(APPLE_DEMO)
1362 if ( (Game_mode & GM_MULTI) ) // don't process in multiplayer games
1365 key_close(); // no processing of keys with keyboard handler.. jeez
1367 show_boxed_message ("Mounting CD\nESC to quit");
1368 RBAMountDisk(); // OS has totaly control of the CD.
1369 if (Function_mode == FMODE_MENU)
1370 songs_play_song(SONG_TITLE,1);
1371 else if (Function_mode == FMODE_GAME)
1372 songs_play_level_song( Current_level_num );
1373 clear_boxed_message();
1380 case KEY_COMMAND+KEY_E:
1381 songs_stop_redbook();
1385 case KEY_COMMAND+KEY_RIGHT:
1386 songs_goto_next_song();
1388 case KEY_COMMAND+KEY_LEFT:
1389 songs_goto_prev_song();
1391 case KEY_COMMAND+KEY_UP:
1392 songs_play_level_song(1);
1394 case KEY_COMMAND+KEY_DOWN:
1395 songs_stop_redbook();
1398 case KEY_COMMAND+KEY_Q:
1399 if ( !(Game_mode & GM_MULTI) )
1404 //added 8/23/99 by Matt Mueller for hot key res/fullscreen changing, and menu access
1405 case KEY_CTRLED+KEY_SHIFTED+KEY_PADDIVIDE:
1406 case KEY_ALTED+KEY_CTRLED+KEY_PADDIVIDE:
1407 case KEY_ALTED+KEY_SHIFTED+KEY_PADDIVIDE:
1411 case KEY_CTRLED+KEY_SHIFTED+KEY_PADMULTIPLY:
1412 case KEY_ALTED+KEY_CTRLED+KEY_PADMULTIPLY:
1413 case KEY_ALTED+KEY_SHIFTED+KEY_PADMULTIPLY:
1416 case KEY_CTRLED+KEY_SHIFTED+KEY_PADMINUS:
1417 case KEY_ALTED+KEY_CTRLED+KEY_PADMINUS:
1418 case KEY_ALTED+KEY_SHIFTED+KEY_PADMINUS:
1420 //should we just cycle through the list that is displayed in the res change menu?
1421 // what if their card/X/etc can't handle that mode? hrm.
1422 //well, the quick access to the menu is good enough for now.
1424 case KEY_CTRLED+KEY_SHIFTED+KEY_PADPLUS:
1425 case KEY_ALTED+KEY_CTRLED+KEY_PADPLUS:
1426 case KEY_ALTED+KEY_SHIFTED+KEY_PADPLUS:
1430 case KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER:
1431 case KEY_ALTED+KEY_CTRLED+KEY_PADENTER:
1432 case KEY_ALTED+KEY_SHIFTED+KEY_PADENTER:
1433 gr_toggle_fullscreen_game();
1437 //added 11/01/98 Matt Mueller
1439 case KEY_CTRLED+KEY_ALTED+KEY_LAPOSTRO:
1450 return screen_changed;
1454 void HandleVRKey(int key)
1458 case KEY_ALTED+KEY_F5:
1459 if ( VR_render_mode != VR_NONE ) {
1461 HUD_init_message( "-Stereoscopic Parameters Reset-" );
1462 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1463 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1467 case KEY_ALTED+KEY_F6:
1468 if ( VR_render_mode != VR_NONE ) {
1470 if ( VR_low_res > 3 ) VR_low_res = 0;
1471 switch( VR_low_res ) {
1472 case 0: HUD_init_message( "Normal Resolution" ); break;
1473 case 1: HUD_init_message( "Low Vertical Resolution" ); break;
1474 case 2: HUD_init_message( "Low Horizontal Resolution" ); break;
1475 case 3: HUD_init_message( "Low Resolution" ); break;
1480 case KEY_ALTED+KEY_F7:
1481 if ( VR_render_mode != VR_NONE ) {
1482 VR_eye_switch = !VR_eye_switch;
1483 HUD_init_message( "-Eyes toggled-" );
1484 if ( VR_eye_switch )
1485 HUD_init_message( "Right Eye -- Left Eye" );
1487 HUD_init_message( "Left Eye -- Right Eye" );
1491 case KEY_ALTED+KEY_F8:
1492 if ( VR_render_mode != VR_NONE ) {
1494 if (VR_sensitivity > 2 )
1496 HUD_init_message( "Head tracking sensitivy = %d", VR_sensitivity );
1499 case KEY_ALTED+KEY_F9:
1500 if ( VR_render_mode != VR_NONE ) {
1501 VR_eye_width -= F1_0/10;
1502 if ( VR_eye_width < 0 ) VR_eye_width = 0;
1503 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1504 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1507 case KEY_ALTED+KEY_F10:
1508 if ( VR_render_mode != VR_NONE ) {
1509 VR_eye_width += F1_0/10;
1510 if ( VR_eye_width > F1_0*4 ) VR_eye_width = F1_0*4;
1511 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1512 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1516 case KEY_ALTED+KEY_F11:
1517 if ( VR_render_mode != VR_NONE ) {
1519 if ( VR_eye_offset < -30 ) VR_eye_offset = -30;
1520 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1521 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1522 VR_eye_offset_changed = 2;
1525 case KEY_ALTED+KEY_F12:
1526 if ( VR_render_mode != VR_NONE ) {
1528 if ( VR_eye_offset > 30 ) VR_eye_offset = 30;
1529 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1530 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1531 VR_eye_offset_changed = 2;
1538 extern void DropFlag();
1540 void HandleGameKey(int key)
1544 #if defined(MACINTOSH) && !defined(RELEASE)
1545 case KEY_COMMAND+KEY_F: r_framerate.value = !r_framerate.value; break;
1548 #ifndef D2X_KEYS // weapon selection handled in controls_read_all, d1x-style
1549 // MWA changed the weapon select cases to have each case call
1550 // do_weapon_select the macintosh keycodes aren't consecutive from 1
1551 // -- 0 on the keyboard -- boy is that STUPID!!!!
1553 // Select primary or secondary weapon.
1555 do_weapon_select(0 , 0);
1558 do_weapon_select(1 , 0);
1561 do_weapon_select(2 , 0);
1564 do_weapon_select(3 , 0);
1567 do_weapon_select(4 , 0);
1571 do_weapon_select(0 , 1);
1574 do_weapon_select(1 , 1);
1577 do_weapon_select(2 , 1);
1580 do_weapon_select(3 , 1);
1583 do_weapon_select(4 , 1);
1587 case KEY_1 + KEY_SHIFTED:
1588 case KEY_2 + KEY_SHIFTED:
1589 case KEY_3 + KEY_SHIFTED:
1590 case KEY_4 + KEY_SHIFTED:
1591 case KEY_5 + KEY_SHIFTED:
1592 case KEY_6 + KEY_SHIFTED:
1593 case KEY_7 + KEY_SHIFTED:
1594 case KEY_8 + KEY_SHIFTED:
1595 case KEY_9 + KEY_SHIFTED:
1596 case KEY_0 + KEY_SHIFTED:
1599 if (!(Game_mode & GM_MULTI))
1600 set_escort_special_goal(key);
1602 HUD_init_message ("No Guide-Bot in Multiplayer!");
1606 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_5:)
1607 case KEY_F5 + KEY_SHIFTED:
1608 DropCurrentWeapon();
1611 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_6:)
1612 case KEY_F6 + KEY_SHIFTED:
1613 DropSecondaryWeapon();
1617 case KEY_0 + KEY_ALTED:
1622 MAC(case KEY_COMMAND+KEY_4:)
1624 if (!DefiningMarkerMessage)
1629 MAC(case KEY_COMMAND+KEY_6:)
1631 if (Netgame.RefusePlayers && WaitForRefuseAnswer && !(Game_mode & GM_TEAM))
1634 HUD_init_message ("Player accepted!");
1637 case KEY_ALTED + KEY_1:
1638 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1641 HUD_init_message ("Player accepted!");
1645 case KEY_ALTED + KEY_2:
1646 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1649 HUD_init_message ("Player accepted!");
1661 void kill_all_robots(void)
1663 int i, dead_count=0;
1664 //int boss_index = -1;
1666 // Kill all bots except for Buddy bot and boss. However, if only boss and buddy left, kill boss.
1667 for (i=0; i<=Highest_object_index; i++)
1668 if (Objects[i].type == OBJ_ROBOT) {
1669 if (!Robot_info[Objects[i].id].companion && !Robot_info[Objects[i].id].boss_flag) {
1671 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1675 // -- // Now, if more than boss and buddy left, un-kill boss.
1676 // -- if ((dead_count > 2) && (boss_index != -1)) {
1677 // -- Objects[boss_index].flags &= ~(OF_EXPLODING|OF_SHOULD_BE_DEAD);
1679 // -- } else if (boss_index != -1)
1680 // -- HUD_init_message("Toasted the BOSS!");
1682 // Toast the buddy if nothing else toasted!
1683 if (dead_count == 0)
1684 for (i=0; i<=Highest_object_index; i++)
1685 if (Objects[i].type == OBJ_ROBOT)
1686 if (Robot_info[Objects[i].id].companion) {
1687 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1688 HUD_init_message("Toasted the Buddy! *sniff*");
1692 HUD_init_message("%i robots toasted!", dead_count);
1695 // --------------------------------------------------------------------------
1696 // Detonate reactor.
1697 // Award player all powerups in mine.
1698 // Place player just outside exit.
1699 // Kill all bots in mine.
1701 void kill_and_so_forth(void)
1705 HUD_init_message("Killing, awarding, etc.!");
1707 for (i=0; i<=Highest_object_index; i++) {
1708 switch (Objects[i].type) {
1710 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1713 do_powerup(&Objects[i]);
1718 do_controlcen_destroyed_stuff(NULL);
1720 for (i=0; i<Num_triggers; i++) {
1721 if (Triggers[i].type == TT_EXIT) {
1722 for (j=0; j<Num_walls; j++) {
1723 if (Walls[j].trigger == i) {
1724 compute_segment_center(&ConsoleObject->pos, &Segments[Walls[j].segnum]);
1725 obj_relink(ConsoleObject-Objects,Walls[j].segnum);
1738 void kill_all_snipers(void)
1740 int i, dead_count=0;
1742 // Kill all snipers.
1743 for (i=0; i<=Highest_object_index; i++)
1744 if (Objects[i].type == OBJ_ROBOT)
1745 if (Objects[i].ctype.ai_info.behavior == AIB_SNIPE) {
1747 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1750 HUD_init_message("%i robots toasted!", dead_count);
1753 void kill_thief(void)
1758 for (i=0; i<=Highest_object_index; i++)
1759 if (Objects[i].type == OBJ_ROBOT)
1760 if (Robot_info[Objects[i].id].thief) {
1761 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1762 HUD_init_message("Thief toasted!");
1766 void kill_buddy(void)
1771 for (i=0; i<=Highest_object_index; i++)
1772 if (Objects[i].type == OBJ_ROBOT)
1773 if (Robot_info[Objects[i].id].companion) {
1774 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1775 HUD_init_message("Buddy toasted!");
1779 void toggle_movie_saving(void);
1780 extern char Language[];
1782 void HandleTestKey(int key)
1786 case KEY_DEBUGGED+KEY_0: show_weapon_status(); break;
1788 #ifdef SHOW_EXIT_PATH
1789 case KEY_DEBUGGED+KEY_1: create_special_path(); break;
1792 case KEY_DEBUGGED+KEY_Y:
1793 do_controlcen_destroyed_stuff(NULL);
1797 case KEY_DEBUGGED+KEY_ALTED+KEY_D:
1798 Netlife_kills=4000; Netlife_killed=5;
1799 multi_add_lifetime_kills();
1804 case KEY_CTRLED+KEY_BACKSP:
1805 case KEY_ALTED+KEY_BACKSP:
1806 case KEY_SHIFTED+KEY_BACKSP:
1807 case KEY_SHIFTED+KEY_ALTED+KEY_BACKSP:
1808 case KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1809 case KEY_SHIFTED+KEY_CTRLED+KEY_BACKSP:
1810 case KEY_SHIFTED+KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1814 case KEY_DEBUGGED+KEY_S: digi_reset(); break;
1816 case KEY_DEBUGGED+KEY_P:
1817 if (Game_suspended & SUSP_ROBOTS)
1818 Game_suspended &= ~SUSP_ROBOTS; //robots move
1820 Game_suspended |= SUSP_ROBOTS; //robots don't move
1825 case KEY_DEBUGGED+KEY_K: Players[Player_num].shields = 1; break; // a virtual kill
1826 case KEY_DEBUGGED+KEY_SHIFTED + KEY_K: Players[Player_num].shields = -1; break; // an actual kill
1827 case KEY_DEBUGGED+KEY_X: Players[Player_num].lives++; break; // Extra life cheat key.
1828 case KEY_DEBUGGED+KEY_H:
1829 // if (!(Game_mode & GM_MULTI) ) {
1830 Players[Player_num].flags ^= PLAYER_FLAGS_CLOAKED;
1831 if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
1833 if (Game_mode & GM_MULTI)
1836 ai_do_cloak_stuff();
1837 Players[Player_num].cloak_time = GameTime;
1838 mprintf((0, "You are cloaked!\n"));
1840 mprintf((0, "You are DE-cloaked!\n"));
1845 case KEY_DEBUGGED+KEY_R:
1846 Robot_firing_enabled = !Robot_firing_enabled;
1849 case KEY_DEBUGGED+KEY_R+KEY_SHIFTED:
1853 #ifdef EDITOR //editor-specific functions
1855 case KEY_E + KEY_DEBUGGED:
1857 network_leave_game();
1859 Function_mode = FMODE_EDITOR;
1861 case KEY_Q + KEY_SHIFTED + KEY_DEBUGGED:
1864 memcpy(pal_save,gr_palette,768);
1865 init_subtitles("end.tex"); //ingore errors
1866 PlayMovie ("end.mve",MOVIE_ABORT_ON);
1869 set_screen_mode(SCREEN_GAME);
1871 memcpy(gr_palette,pal_save,768);
1872 gr_palette_load(gr_palette);
1875 case KEY_C + KEY_SHIFTED + KEY_DEBUGGED:
1876 if (!( Game_mode & GM_MULTI ))
1877 move_player_2_segment(Cursegp,Curside);
1878 break; //move eye to curseg
1881 case KEY_DEBUGGED+KEY_W: draw_world_from_game(); break;
1883 #endif //#ifdef EDITOR
1886 // case KEY_DEBUGGED+KEY_SHIFTED+KEY_F: toggle_flythrough(); break;
1887 // case KEY_LEFT: ft_preference=FP_LEFT; break;
1888 // case KEY_RIGHT: ft_preference=FP_RIGHT; break;
1889 // case KEY_UP: ft_preference=FP_UP; break;
1890 // case KEY_DOWN: ft_preference=FP_DOWN; break;
1893 case KEY_DEBUGGED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_next_viewer(); break;
1894 case KEY_DEBUGGED+KEY_CTRLED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_prev_viewer(); break;
1896 case KEY_DEBUGGED+KEY_SHIFTED+KEY_LAPOSTRO: Viewer=ConsoleObject; break;
1899 case KEY_DEBUGGED+KEY_O: toggle_outline_mode(); break;
1901 case KEY_DEBUGGED+KEY_T:
1902 *Toggle_var = !*Toggle_var;
1903 mprintf((0, "Variable at %08x set to %i\n", Toggle_var, *Toggle_var));
1905 case KEY_DEBUGGED + KEY_L:
1906 if (++Lighting_on >= 2) Lighting_on = 0; break;
1907 case KEY_DEBUGGED + KEY_SHIFTED + KEY_L:
1908 Beam_brightness=0x38000-Beam_brightness; break;
1909 case KEY_PAD5: slew_stop(); break;
1912 case KEY_DEBUGGED + KEY_F11: play_test_sound(); break;
1913 case KEY_DEBUGGED + KEY_SHIFTED+KEY_F11: advance_sound(); play_test_sound(); break;
1916 case KEY_DEBUGGED +KEY_F4: {
1917 //fvi_info hit_data;
1918 //vms_vector p0 = {-0x1d99a7,-0x1b20000,0x186ab7f};
1919 //vms_vector p1 = {-0x217865,-0x1b20000,0x187de3e};
1920 //find_vector_intersection(&hit_data,&p0,0x1b9,&p1,0x40000,0x0,NULL,-1);
1924 case KEY_DEBUGGED + KEY_M:
1925 Debug_spew = !Debug_spew;
1927 mopen( 0, 8, 1, 78, 16, "Debug Spew");
1928 HUD_init_message( "Debug Spew: ON" );
1931 HUD_init_message( "Debug Spew: OFF" );
1935 case KEY_DEBUGGED + KEY_C:
1937 full_palette_save();
1941 case KEY_DEBUGGED + KEY_SHIFTED + KEY_A:
1942 do_megawow_powerup(10);
1944 case KEY_DEBUGGED + KEY_A: {
1945 do_megawow_powerup(200);
1946 // if ( Game_mode & GM_MULTI ) {
1947 // nm_messagebox( NULL, 1, "Damn", "CHEATER!\nYou cannot use the\nmega-thing in network mode." );
1948 // Network_message_reciever = 100; // Send to everyone...
1949 // sprintf( Network_message, "%s cheated!", Players[Player_num].callsign);
1951 // do_megawow_powerup();
1956 case KEY_DEBUGGED+KEY_F: r_framerate.value = !r_framerate.value; break;
1958 case KEY_DEBUGGED+KEY_SPACEBAR: //KEY_F7: // Toggle physics flying
1960 game_flush_inputs();
1961 if ( ConsoleObject->control_type != CT_FLYING ) {
1962 fly_init(ConsoleObject);
1963 Game_suspended &= ~SUSP_ROBOTS; //robots move
1965 slew_init(ConsoleObject); //start player slewing
1966 Game_suspended |= SUSP_ROBOTS; //robots don't move
1970 case KEY_DEBUGGED+KEY_COMMA: Render_zoom = fixmul(Render_zoom,62259); break;
1971 case KEY_DEBUGGED+KEY_PERIOD: Render_zoom = fixmul(Render_zoom,68985); break;
1973 case KEY_DEBUGGED+KEY_P+KEY_SHIFTED: Debug_pause = 1; break;
1977 // sprintf(mystr,"mark %i start",Mark_count);
1981 //case KEY_SHIFTED+KEY_F7: {
1983 // sprintf(mystr,"mark %i end",Mark_count);
1991 case KEY_DEBUGGED+KEY_F8: speedtest_init(); Speedtest_count = 1; break;
1992 case KEY_DEBUGGED+KEY_F9: speedtest_init(); Speedtest_count = 10; break;
1994 case KEY_DEBUGGED+KEY_D:
1995 if ((Game_double_buffer = !Game_double_buffer)!=0)
2001 case KEY_DEBUGGED+KEY_Q:
2003 dump_used_textures_all();
2008 case KEY_DEBUGGED+KEY_B: {
2010 char text[FILENAME_LEN]="";
2012 m.type=NM_TYPE_INPUT; m.text_len = FILENAME_LEN; m.text = text;
2013 item = newmenu_do( NULL, "Briefing to play?", 1, &m, NULL );
2015 do_briefing_screens(text,1);
2021 case KEY_DEBUGGED+KEY_F5:
2022 toggle_movie_saving();
2025 case KEY_DEBUGGED+KEY_SHIFTED+KEY_F5: {
2026 extern int Movie_fixed_frametime;
2027 Movie_fixed_frametime = !Movie_fixed_frametime;
2031 case KEY_DEBUGGED+KEY_ALTED+KEY_F5:
2032 GameTime = i2f(0x7fff - 840); //will overflow in 14 minutes
2033 mprintf((0,"GameTime bashed to %d secs\n",f2i(GameTime)));
2036 case KEY_DEBUGGED+KEY_SHIFTED+KEY_B:
2037 kill_and_so_forth();
2041 #endif //#ifndef RELEASE
2043 // Cheat functions ------------------------------------------------------------
2044 extern char *jcrypt (char *);
2046 char *LamerCheats[]={ "!UyN#E$I", // gabba-gabbahey
2047 "ei5cQ-ZQ", // mo-therlode
2048 "q^EpZxs8", // c-urrygoat
2049 "mxk(DyyP", // zi-ngermans
2050 "cBo#@y@P", // ea-tangelos
2051 "CLygLBGQ", // e-ricaanne
2052 "xAnHQxZX", // jos-huaakira
2053 "cKc[KUWo", // wh-ammazoom
2056 #define N_LAMER_CHEATS (sizeof(LamerCheats) / sizeof(*LamerCheats))
2058 char *WowieCheat ="F_JMO3CV"; //only Matt knows / h-onestbob
2059 char *AllKeysCheat ="%v%MrgbU"; //only Matt knows / or-algroove
2060 char *InvulCheat ="Wv_\\JJ\\Z"; //only Matt knows / almighty
2061 char *HomingCheatString ="t\\LIhSB["; //only Matt knows / l-pnlizard
2062 char *BouncyCheat ="bGbiChQJ"; //only Matt knows / duddaboo
2063 char *FullMapCheat ="PI<XQHRI"; //only Matt knows / rockrgrl
2064 char *LevelWarpCheat ="ZQHtqbb\""; //only Matt knows / f-reespace
2065 char *MonsterCheat ="nfpEfRQp"; //only Matt knows / godzilla
2066 char *BuddyLifeCheat ="%A-BECuY"; //only Matt knows / he-lpvishnu
2067 char *BuddyDudeCheat ="u#uzIr%e"; //only Matt knows / g-owingnut
2068 char *KillRobotsCheat ="&wxbs:5O"; //only Matt knows / spaniard
2069 char *FinishLevelCheat ="%bG_bZ<D"; //only Matt knows / d-elshiftb
2070 char *RapidFireCheat ="*jLgHi'J"; //only Matt knows / wildfire
2072 char *RobotsKillRobotsCheat ="rT6xD__S"; // New for 1.1 / silkwing
2073 char *AhimsaCheat ="!Uscq_yc"; // New for 1.1 / im-agespace
2075 char *AccessoryCheat ="dWdz[kCK"; // al-ifalafel
2076 char *JohnHeadCheat ="ou]];H:%"; // p-igfarmer
2077 char *AcidCheat ="qPmwxz\"S"; // bit-tersweet
2078 char *FramerateCheat ="rQ60#ZBN"; // f-rametime
2080 char CheatBuffer[]="AAAAAAAAAAAAAAA";
2082 #define CHEATSPOT 14
2085 void do_cheat_penalty ()
2087 digi_play_sample( SOUND_CHEATER, F1_0);
2089 Players[Player_num].score=0;
2093 // Main Cheat function
2097 char john_head_on=0;
2100 char OldHomingState[20];
2101 extern char Monster_mode;
2103 void fill_background();
2104 void load_background_bitmap();
2106 extern int Robots_kill_robots_cheat;
2108 void FinalCheats(int key)
2113 key=key_to_ascii(key);
2116 CheatBuffer[i]=CheatBuffer[i+1];
2118 CheatBuffer[CHEATSPOT]=key;
2120 cryptstring=jcrypt(&CheatBuffer[7]);
2122 for (i=0;i<N_LAMER_CHEATS;i++)
2123 if (!(strcmp (cryptstring,LamerCheats[i])))
2126 Players[Player_num].shields=i2f(1);
2127 Players[Player_num].energy=i2f(1);
2129 if (Game_mode & GM_MULTI)
2131 Network_message_reciever = 100; // Send to everyone...
2132 sprintf( Network_message, "%s is crippled...get him!",Players[Player_num].callsign);
2135 HUD_init_message ("Take that...cheater!");
2138 if (!(strcmp (cryptstring,JohnHeadCheat)))
2140 john_head_on = !john_head_on;
2141 load_background_bitmap();
2143 HUD_init_message (john_head_on?"Hi John!!":"Bye John!!");
2145 if (!(strcmp (cryptstring,AcidCheat)))
2150 Interpolation_method=old_IntMethod;
2151 HUD_init_message ("Coming down...");
2156 old_IntMethod=Interpolation_method;
2157 Interpolation_method=1;
2158 HUD_init_message ("Going up!");
2163 if (!(strcmp (cryptstring,FramerateCheat)))
2165 r_framerate.value = !r_framerate.value;
2168 if (Game_mode & GM_MULTI)
2171 if (!(strcmp (&CheatBuffer[8],"blueorb")))
2173 if (Players[Player_num].shields < MAX_SHIELDS) {
2174 fix boost = 3*F1_0 + 3*F1_0*(NDL - Difficulty_level);
2175 if (Difficulty_level == 0)
2177 Players[Player_num].shields += boost;
2178 if (Players[Player_num].shields > MAX_SHIELDS)
2179 Players[Player_num].shields = MAX_SHIELDS;
2180 powerup_basic(0, 0, 15, SHIELD_SCORE, "%s %s %d",TXT_SHIELD,TXT_BOOSTED_TO,f2ir(Players[Player_num].shields));
2183 HUD_init_message(TXT_MAXED_OUT,TXT_SHIELD);
2186 if (!(strcmp(cryptstring,BuddyLifeCheat)))
2189 HUD_init_message ("What's this? Another buddy bot!");
2194 if (!(strcmp(cryptstring,BuddyDudeCheat)))
2197 Buddy_dude_cheat = !Buddy_dude_cheat;
2198 if (Buddy_dude_cheat) {
2199 HUD_init_message ("%s gets angry!",guidebot_name);
2200 strcpy(guidebot_name,"Wingnut");
2203 strcpy(guidebot_name,real_guidebot_name);
2204 HUD_init_message ("%s calms down",guidebot_name);
2209 if (!(strcmp(cryptstring,MonsterCheat)))
2211 Monster_mode=1-Monster_mode;
2213 HUD_init_message (Monster_mode?"Oh no, there goes Tokyo!":"What have you done, I'm shrinking!!");
2217 if (!(strcmp (cryptstring,BouncyCheat)))
2220 HUD_init_message ("Bouncing weapons!");
2224 if (!(strcmp(cryptstring,LevelWarpCheat)))
2230 //digi_play_sample( SOUND_CHEATER, F1_0);
2231 m.type=NM_TYPE_INPUT; m.text_len = 10; m.text = text;
2232 item = newmenu_do( NULL, TXT_WARP_TO_LEVEL, 1, &m, NULL );
2234 new_level_num = atoi(m.text);
2235 if (new_level_num!=0 && new_level_num>=0 && new_level_num<=Last_level) {
2236 StartNewLevel(new_level_num, 0);
2242 if (!(strcmp (cryptstring,WowieCheat)))
2245 HUD_init_message(TXT_WOWIE_ZOWIE);
2249 Players[Player_num].primary_weapon_flags = ~((1<<PHOENIX_INDEX) | (1<<OMEGA_INDEX) | (1<<FUSION_INDEX) | HAS_FLAG(SUPER_LASER_INDEX));
2250 Players[Player_num].secondary_weapon_flags = ~((1<<SMISSILE4_INDEX) | (1<<MEGA_INDEX) | (1<<SMISSILE5_INDEX));
2252 Players[Player_num].primary_weapon_flags = 0xffff ^ HAS_FLAG(SUPER_LASER_INDEX); //no super laser
2253 Players[Player_num].secondary_weapon_flags = 0xffff;
2256 for (i=0; i<MAX_PRIMARY_WEAPONS; i++)
2257 Players[Player_num].primary_ammo[i] = Primary_ammo_max[i];
2259 for (i=0; i<MAX_SECONDARY_WEAPONS; i++)
2260 Players[Player_num].secondary_ammo[i] = Secondary_ammo_max[i];
2263 Players[Player_num].secondary_ammo[SMISSILE4_INDEX] = 0;
2264 Players[Player_num].secondary_ammo[SMISSILE5_INDEX] = 0;
2265 Players[Player_num].secondary_ammo[MEGA_INDEX] = 0;
2268 if (Game_mode & GM_HOARD)
2269 Players[Player_num].secondary_ammo[PROXIMITY_INDEX] = 12;
2271 if (Newdemo_state == ND_STATE_RECORDING)
2272 newdemo_record_laser_level(Players[Player_num].laser_level, MAX_LASER_LEVEL);
2274 Players[Player_num].energy = MAX_ENERGY;
2275 Players[Player_num].laser_level = MAX_SUPER_LASER_LEVEL;
2276 Players[Player_num].flags |= PLAYER_FLAGS_QUAD_LASERS;
2277 update_laser_weapon_info();
2281 if (!(strcmp (cryptstring,AllKeysCheat)))
2284 HUD_init_message(TXT_ALL_KEYS);
2285 Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2289 if (!(strcmp (cryptstring,InvulCheat)))
2292 Players[Player_num].flags ^= PLAYER_FLAGS_INVULNERABLE;
2293 HUD_init_message("%s %s!", TXT_INVULNERABILITY, (Players[Player_num].flags&PLAYER_FLAGS_INVULNERABLE)?TXT_ON:TXT_OFF);
2294 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2296 if (!(strcmp (cryptstring,AccessoryCheat)))
2299 Players[Player_num].flags |=PLAYER_FLAGS_HEADLIGHT;
2300 Players[Player_num].flags |=PLAYER_FLAGS_AFTERBURNER;
2301 Players[Player_num].flags |=PLAYER_FLAGS_AMMO_RACK;
2302 Players[Player_num].flags |=PLAYER_FLAGS_CONVERTER;
2304 HUD_init_message ("Accessories!!");
2306 if (!(strcmp (cryptstring,FullMapCheat)))
2309 Players[Player_num].flags |=PLAYER_FLAGS_MAP_ALL;
2311 HUD_init_message ("Full Map!!");
2315 if (!(strcmp (cryptstring,HomingCheatString)))
2322 OldHomingState[i]=Weapon_info[i].homing_flag;
2323 Weapon_info[i].homing_flag=1;
2325 HUD_init_message ("Homing weapons!");
2329 if (!(strcmp (cryptstring,KillRobotsCheat)))
2335 if (!(strcmp (cryptstring,FinishLevelCheat)))
2338 kill_and_so_forth();
2341 if (!(strcmp (cryptstring,RobotsKillRobotsCheat))) {
2342 Robots_kill_robots_cheat = !Robots_kill_robots_cheat;
2343 if (Robots_kill_robots_cheat) {
2344 HUD_init_message ("Rabid robots!");
2348 HUD_init_message ("Kill the player!");
2351 if (!(strcmp (cryptstring,AhimsaCheat))) {
2352 Robot_firing_enabled = !Robot_firing_enabled;
2353 if (!Robot_firing_enabled) {
2354 HUD_init_message("%s", "Robot firing OFF!");
2358 HUD_init_message("%s", "Robot firing ON!");
2361 if (!(strcmp (cryptstring,RapidFireCheat))) {
2362 if (Laser_rapid_fire) {
2363 Laser_rapid_fire = 0;
2364 HUD_init_message("%s", "Rapid fire OFF!");
2367 Laser_rapid_fire = 0xbada55;
2369 HUD_init_message("%s", "Rapid fire ON!");
2376 // Internal Cheat Menu
2378 void do_cheat_menu()
2381 newmenu_item mm[16];
2382 char score_text[21];
2384 sprintf( score_text, "%d", Players[Player_num].score );
2386 mm[0].type=NM_TYPE_CHECK; mm[0].value=Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE; mm[0].text="Invulnerability";
2387 mm[1].type=NM_TYPE_CHECK; mm[1].value=Players[Player_num].flags & PLAYER_FLAGS_CLOAKED; mm[1].text="Cloaked";
2388 mm[2].type=NM_TYPE_CHECK; mm[2].value=0; mm[2].text="All keys";
2389 mm[3].type=NM_TYPE_NUMBER; mm[3].value=f2i(Players[Player_num].energy); mm[3].text="% Energy"; mm[3].min_value=0; mm[3].max_value=200;
2390 mm[4].type=NM_TYPE_NUMBER; mm[4].value=f2i(Players[Player_num].shields); mm[4].text="% Shields"; mm[4].min_value=0; mm[4].max_value=200;
2391 mm[5].type=NM_TYPE_TEXT; mm[5].text = "Score:";
2392 mm[6].type=NM_TYPE_INPUT; mm[6].text_len = 10; mm[6].text = score_text;
2393 //mm[7].type=NM_TYPE_RADIO; mm[7].value=(Players[Player_num].laser_level==0); mm[7].group=0; mm[7].text="Laser level 1";
2394 //mm[8].type=NM_TYPE_RADIO; mm[8].value=(Players[Player_num].laser_level==1); mm[8].group=0; mm[8].text="Laser level 2";
2395 //mm[9].type=NM_TYPE_RADIO; mm[9].value=(Players[Player_num].laser_level==2); mm[9].group=0; mm[9].text="Laser level 3";
2396 //mm[10].type=NM_TYPE_RADIO; mm[10].value=(Players[Player_num].laser_level==3); mm[10].group=0; mm[10].text="Laser level 4";
2398 mm[7].type=NM_TYPE_NUMBER; mm[7].value=Players[Player_num].laser_level+1; mm[7].text="Laser Level"; mm[7].min_value=0; mm[7].max_value=MAX_SUPER_LASER_LEVEL+1;
2399 mm[8].type=NM_TYPE_NUMBER; mm[8].value=Players[Player_num].secondary_ammo[CONCUSSION_INDEX]; mm[8].text="Missiles"; mm[8].min_value=0; mm[8].max_value=200;
2401 mmn = newmenu_do("Wimp Menu",NULL,9, mm, NULL );
2404 if ( mm[0].value ) {
2405 Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
2406 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2408 Players[Player_num].flags &= ~PLAYER_FLAGS_INVULNERABLE;
2409 if ( mm[1].value ) {
2410 Players[Player_num].flags |= PLAYER_FLAGS_CLOAKED;
2412 if (Game_mode & GM_MULTI)
2415 ai_do_cloak_stuff();
2416 Players[Player_num].cloak_time = GameTime;
2419 Players[Player_num].flags &= ~PLAYER_FLAGS_CLOAKED;
2421 if (mm[2].value) Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2422 Players[Player_num].energy=i2f(mm[3].value);
2423 Players[Player_num].shields=i2f(mm[4].value);
2424 Players[Player_num].score = atoi(mm[6].text);
2425 //if (mm[7].value) Players[Player_num].laser_level=0;
2426 //if (mm[8].value) Players[Player_num].laser_level=1;
2427 //if (mm[9].value) Players[Player_num].laser_level=2;
2428 //if (mm[10].value) Players[Player_num].laser_level=3;
2429 Players[Player_num].laser_level = mm[7].value-1;
2430 Players[Player_num].secondary_ammo[CONCUSSION_INDEX] = mm[8].value;
2438 // Testing functions ----------------------------------------------------------
2441 void speedtest_init(void)
2443 Speedtest_start_time = timer_get_fixed_seconds();
2445 Speedtest_segnum = 0;
2446 Speedtest_sidenum = 0;
2447 Speedtest_frame_start = FrameCount;
2449 mprintf((0, "Starting speedtest. Will be %i frames. Each . = 10 frames.\n", Highest_segment_index+1));
2452 void speedtest_frame(void)
2454 vms_vector view_dir, center_point;
2456 Speedtest_sidenum=Speedtest_segnum % MAX_SIDES_PER_SEGMENT;
2458 compute_segment_center(&Viewer->pos, &Segments[Speedtest_segnum]);
2459 Viewer->pos.x += 0x10; Viewer->pos.y -= 0x10; Viewer->pos.z += 0x17;
2461 obj_relink(Viewer-Objects, Speedtest_segnum);
2462 compute_center_point_on_side(¢er_point, &Segments[Speedtest_segnum], Speedtest_sidenum);
2463 vm_vec_normalized_dir_quick(&view_dir, ¢er_point, &Viewer->pos);
2464 vm_vector_2_matrix(&Viewer->orient, &view_dir, NULL, NULL);
2466 if (((FrameCount - Speedtest_frame_start) % 10) == 0)
2471 if (Speedtest_segnum > Highest_segment_index) {
2474 sprintf(msg, "\nSpeedtest done: %i frames, %7.3f seconds, %7.3f frames/second.\n",
2475 FrameCount-Speedtest_frame_start,
2476 f2fl(timer_get_fixed_seconds() - Speedtest_start_time),
2477 (float) (FrameCount-Speedtest_frame_start) / f2fl(timer_get_fixed_seconds() - Speedtest_start_time));
2479 mprintf((0, "%s", msg));
2480 HUD_init_message(msg);
2483 if (Speedtest_count == 0)
2492 // Sounds for testing
2494 int test_sound_num = 0;
2495 int sound_nums[] = {10,11,20,21,30,31,32,33,40,41,50,51,60,61,62,70,80,81,82,83,90,91};
2497 #define N_TEST_SOUNDS (sizeof(sound_nums) / sizeof(*sound_nums))
2500 void advance_sound()
2502 if (++test_sound_num == N_TEST_SOUNDS)
2508 int Test_sound = 251;
2510 void play_test_sound()
2513 // -- digi_play_sample(sound_nums[test_sound_num], F1_0);
2514 digi_play_sample(Test_sound, F1_0);
2517 #endif //ifndef NDEBUG
2527 static ubyte exploding_flag=0;
2529 Player_fired_laser_this_frame=-1;
2531 if (!Endlevel_sequence && !Player_is_dead) {
2533 if ( (Newdemo_state == ND_STATE_PLAYBACK) || (DefiningMarkerMessage)
2535 || multi_sending_message || multi_defining_message
2537 ) // WATCH OUT!!! WEIRD CODE ABOVE!!!
2538 memset( &Controls, 0, sizeof(control_info) );
2541 controls_read_all_win();
2543 controls_read_all(); //NOTE LINK TO ABOVE!!!
2548 // If automap key pressed, enable automap unless you are in network mode, control center destroyed and < 10 seconds left
2549 if ( Controls.automap_down_count && !((Game_mode & GM_MULTI) && Control_center_destroyed && (Countdown_seconds_left < 10)))
2556 if (Player_exploded) { //Player_is_dead && (ConsoleObject->flags & OF_EXPLODING) ) {
2558 if (exploding_flag==0) {
2559 exploding_flag = 1; // When player starts exploding, clear all input devices...
2560 game_flush_inputs();
2563 //if (key_down_count(KEY_BACKSP))
2565 //if (key_down_count(KEY_PRINT_SCREEN))
2566 // save_screen_shot(0);
2569 for (i=0; i<4; i++ )
2570 if (joy_get_button_down_cnt(i)>0) Death_sequence_aborted = 1;
2572 if ( joy_get_any_button_down_cnt()>0 ) Death_sequence_aborted = 1;
2574 for (i=0; i<3; i++ )
2575 if (mouse_button_down_count(i)>0) Death_sequence_aborted = 1;
2577 //for (i=0; i<256; i++ )
2578 // if (!key_isfunc(i) && !key_ismod(i) && key_down_count(i)>0) Death_sequence_aborted = 1;
2580 if (Death_sequence_aborted)
2581 game_flush_inputs();
2587 if (Newdemo_state == ND_STATE_PLAYBACK )
2590 while ((key=key_inkey_time(&key_time)) != 0) {
2592 if (DefiningMarkerMessage)
2594 MarkerInputMessage (key);
2599 if ( (Game_mode&GM_MULTI) && (multi_sending_message || multi_defining_message )) {
2600 multi_message_input_sub( key );
2601 continue; //get next key
2607 if ((key&KEY_DEBUGGED)&&(Game_mode&GM_MULTI)) {
2608 Network_message_reciever = 100; // Send to everyone...
2609 sprintf( Network_message, "%s %s", TXT_I_AM_A, TXT_CHEATER);
2615 if(!con_events(key))
2620 HandleDeathKey(key);
2622 if (Endlevel_sequence)
2623 HandleEndlevelKey(key);
2624 else if (Newdemo_state == ND_STATE_PLAYBACK ) {
2633 HandleSystemKey(key);
2644 // if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[KEY_F8] && (keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT]))
2645 // transfer_energy_to_shield(key_down_time(KEY_F8));