1 /* $Id: gamecntl.c,v 1.24 2004-05-21 02:45:34 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_ALTED+KEY_ENTER:
1431 case KEY_ALTED+KEY_PADENTER:
1432 gr_toggle_fullscreen_game();
1436 //added 11/01/98 Matt Mueller
1438 case KEY_CTRLED+KEY_ALTED+KEY_LAPOSTRO:
1449 return screen_changed;
1453 void HandleVRKey(int key)
1457 case KEY_ALTED+KEY_F5:
1458 if ( VR_render_mode != VR_NONE ) {
1460 HUD_init_message( "-Stereoscopic Parameters Reset-" );
1461 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1462 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1466 case KEY_ALTED+KEY_F6:
1467 if ( VR_render_mode != VR_NONE ) {
1469 if ( VR_low_res > 3 ) VR_low_res = 0;
1470 switch( VR_low_res ) {
1471 case 0: HUD_init_message( "Normal Resolution" ); break;
1472 case 1: HUD_init_message( "Low Vertical Resolution" ); break;
1473 case 2: HUD_init_message( "Low Horizontal Resolution" ); break;
1474 case 3: HUD_init_message( "Low Resolution" ); break;
1479 case KEY_ALTED+KEY_F7:
1480 if ( VR_render_mode != VR_NONE ) {
1481 VR_eye_switch = !VR_eye_switch;
1482 HUD_init_message( "-Eyes toggled-" );
1483 if ( VR_eye_switch )
1484 HUD_init_message( "Right Eye -- Left Eye" );
1486 HUD_init_message( "Left Eye -- Right Eye" );
1490 case KEY_ALTED+KEY_F8:
1491 if ( VR_render_mode != VR_NONE ) {
1493 if (VR_sensitivity > 2 )
1495 HUD_init_message( "Head tracking sensitivy = %d", VR_sensitivity );
1498 case KEY_ALTED+KEY_F9:
1499 if ( VR_render_mode != VR_NONE ) {
1500 VR_eye_width -= F1_0/10;
1501 if ( VR_eye_width < 0 ) VR_eye_width = 0;
1502 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1503 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1506 case KEY_ALTED+KEY_F10:
1507 if ( VR_render_mode != VR_NONE ) {
1508 VR_eye_width += F1_0/10;
1509 if ( VR_eye_width > F1_0*4 ) VR_eye_width = F1_0*4;
1510 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1511 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1515 case KEY_ALTED+KEY_F11:
1516 if ( VR_render_mode != VR_NONE ) {
1518 if ( VR_eye_offset < -30 ) VR_eye_offset = -30;
1519 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1520 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1521 VR_eye_offset_changed = 2;
1524 case KEY_ALTED+KEY_F12:
1525 if ( VR_render_mode != VR_NONE ) {
1527 if ( VR_eye_offset > 30 ) VR_eye_offset = 30;
1528 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1529 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1530 VR_eye_offset_changed = 2;
1537 extern void DropFlag();
1539 void HandleGameKey(int key)
1543 #if defined(MACINTOSH) && !defined(RELEASE)
1544 case KEY_COMMAND+KEY_F: r_framerate.value = !r_framerate.value; break;
1547 #ifndef D2X_KEYS // weapon selection handled in controls_read_all, d1x-style
1548 // MWA changed the weapon select cases to have each case call
1549 // do_weapon_select the macintosh keycodes aren't consecutive from 1
1550 // -- 0 on the keyboard -- boy is that STUPID!!!!
1552 // Select primary or secondary weapon.
1554 do_weapon_select(0 , 0);
1557 do_weapon_select(1 , 0);
1560 do_weapon_select(2 , 0);
1563 do_weapon_select(3 , 0);
1566 do_weapon_select(4 , 0);
1570 do_weapon_select(0 , 1);
1573 do_weapon_select(1 , 1);
1576 do_weapon_select(2 , 1);
1579 do_weapon_select(3 , 1);
1582 do_weapon_select(4 , 1);
1586 case KEY_1 + KEY_SHIFTED:
1587 case KEY_2 + KEY_SHIFTED:
1588 case KEY_3 + KEY_SHIFTED:
1589 case KEY_4 + KEY_SHIFTED:
1590 case KEY_5 + KEY_SHIFTED:
1591 case KEY_6 + KEY_SHIFTED:
1592 case KEY_7 + KEY_SHIFTED:
1593 case KEY_8 + KEY_SHIFTED:
1594 case KEY_9 + KEY_SHIFTED:
1595 case KEY_0 + KEY_SHIFTED:
1598 if (!(Game_mode & GM_MULTI))
1599 set_escort_special_goal(key);
1601 HUD_init_message ("No Guide-Bot in Multiplayer!");
1605 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_5:)
1606 case KEY_F5 + KEY_SHIFTED:
1607 DropCurrentWeapon();
1610 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_6:)
1611 case KEY_F6 + KEY_SHIFTED:
1612 DropSecondaryWeapon();
1616 case KEY_0 + KEY_ALTED:
1621 MAC(case KEY_COMMAND+KEY_4:)
1623 if (!DefiningMarkerMessage)
1628 MAC(case KEY_COMMAND+KEY_6:)
1630 if (Netgame.RefusePlayers && WaitForRefuseAnswer && !(Game_mode & GM_TEAM))
1633 HUD_init_message ("Player accepted!");
1636 case KEY_ALTED + KEY_1:
1637 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1640 HUD_init_message ("Player accepted!");
1644 case KEY_ALTED + KEY_2:
1645 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1648 HUD_init_message ("Player accepted!");
1660 void kill_all_robots(void)
1662 int i, dead_count=0;
1663 //int boss_index = -1;
1665 // Kill all bots except for Buddy bot and boss. However, if only boss and buddy left, kill boss.
1666 for (i=0; i<=Highest_object_index; i++)
1667 if (Objects[i].type == OBJ_ROBOT) {
1668 if (!Robot_info[Objects[i].id].companion && !Robot_info[Objects[i].id].boss_flag) {
1670 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1674 // -- // Now, if more than boss and buddy left, un-kill boss.
1675 // -- if ((dead_count > 2) && (boss_index != -1)) {
1676 // -- Objects[boss_index].flags &= ~(OF_EXPLODING|OF_SHOULD_BE_DEAD);
1678 // -- } else if (boss_index != -1)
1679 // -- HUD_init_message("Toasted the BOSS!");
1681 // Toast the buddy if nothing else toasted!
1682 if (dead_count == 0)
1683 for (i=0; i<=Highest_object_index; i++)
1684 if (Objects[i].type == OBJ_ROBOT)
1685 if (Robot_info[Objects[i].id].companion) {
1686 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1687 HUD_init_message("Toasted the Buddy! *sniff*");
1691 HUD_init_message("%i robots toasted!", dead_count);
1694 // --------------------------------------------------------------------------
1695 // Detonate reactor.
1696 // Award player all powerups in mine.
1697 // Place player just outside exit.
1698 // Kill all bots in mine.
1700 void kill_and_so_forth(void)
1704 HUD_init_message("Killing, awarding, etc.!");
1706 for (i=0; i<=Highest_object_index; i++) {
1707 switch (Objects[i].type) {
1709 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1712 do_powerup(&Objects[i]);
1717 do_controlcen_destroyed_stuff(NULL);
1719 for (i=0; i<Num_triggers; i++) {
1720 if (Triggers[i].type == TT_EXIT) {
1721 for (j=0; j<Num_walls; j++) {
1722 if (Walls[j].trigger == i) {
1723 compute_segment_center(&ConsoleObject->pos, &Segments[Walls[j].segnum]);
1724 obj_relink(ConsoleObject-Objects,Walls[j].segnum);
1737 void kill_all_snipers(void)
1739 int i, dead_count=0;
1741 // Kill all snipers.
1742 for (i=0; i<=Highest_object_index; i++)
1743 if (Objects[i].type == OBJ_ROBOT)
1744 if (Objects[i].ctype.ai_info.behavior == AIB_SNIPE) {
1746 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1749 HUD_init_message("%i robots toasted!", dead_count);
1752 void kill_thief(void)
1757 for (i=0; i<=Highest_object_index; i++)
1758 if (Objects[i].type == OBJ_ROBOT)
1759 if (Robot_info[Objects[i].id].thief) {
1760 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1761 HUD_init_message("Thief toasted!");
1765 void kill_buddy(void)
1770 for (i=0; i<=Highest_object_index; i++)
1771 if (Objects[i].type == OBJ_ROBOT)
1772 if (Robot_info[Objects[i].id].companion) {
1773 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1774 HUD_init_message("Buddy toasted!");
1778 void toggle_movie_saving(void);
1779 extern char Language[];
1781 void HandleTestKey(int key)
1785 case KEY_DEBUGGED+KEY_0: show_weapon_status(); break;
1787 #ifdef SHOW_EXIT_PATH
1788 case KEY_DEBUGGED+KEY_1: create_special_path(); break;
1791 case KEY_DEBUGGED+KEY_Y:
1792 do_controlcen_destroyed_stuff(NULL);
1796 case KEY_DEBUGGED+KEY_ALTED+KEY_D:
1797 Netlife_kills=4000; Netlife_killed=5;
1798 multi_add_lifetime_kills();
1803 case KEY_CTRLED+KEY_BACKSP:
1804 case KEY_ALTED+KEY_BACKSP:
1805 case KEY_SHIFTED+KEY_BACKSP:
1806 case KEY_SHIFTED+KEY_ALTED+KEY_BACKSP:
1807 case KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1808 case KEY_SHIFTED+KEY_CTRLED+KEY_BACKSP:
1809 case KEY_SHIFTED+KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1813 case KEY_DEBUGGED+KEY_S: digi_reset(); break;
1815 case KEY_DEBUGGED+KEY_P:
1816 if (Game_suspended & SUSP_ROBOTS)
1817 Game_suspended &= ~SUSP_ROBOTS; //robots move
1819 Game_suspended |= SUSP_ROBOTS; //robots don't move
1824 case KEY_DEBUGGED+KEY_K: Players[Player_num].shields = 1; break; // a virtual kill
1825 case KEY_DEBUGGED+KEY_SHIFTED + KEY_K: Players[Player_num].shields = -1; break; // an actual kill
1826 case KEY_DEBUGGED+KEY_X: Players[Player_num].lives++; break; // Extra life cheat key.
1827 case KEY_DEBUGGED+KEY_H:
1828 // if (!(Game_mode & GM_MULTI) ) {
1829 Players[Player_num].flags ^= PLAYER_FLAGS_CLOAKED;
1830 if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
1832 if (Game_mode & GM_MULTI)
1835 ai_do_cloak_stuff();
1836 Players[Player_num].cloak_time = GameTime;
1837 mprintf((0, "You are cloaked!\n"));
1839 mprintf((0, "You are DE-cloaked!\n"));
1844 case KEY_DEBUGGED+KEY_R:
1845 Robot_firing_enabled = !Robot_firing_enabled;
1848 case KEY_DEBUGGED+KEY_R+KEY_SHIFTED:
1852 #ifdef EDITOR //editor-specific functions
1854 case KEY_E + KEY_DEBUGGED:
1856 network_leave_game();
1858 Function_mode = FMODE_EDITOR;
1860 case KEY_Q + KEY_SHIFTED + KEY_DEBUGGED:
1863 memcpy(pal_save,gr_palette,768);
1864 init_subtitles("end.tex"); //ingore errors
1865 PlayMovie ("end.mve",MOVIE_ABORT_ON);
1868 set_screen_mode(SCREEN_GAME);
1870 memcpy(gr_palette,pal_save,768);
1871 gr_palette_load(gr_palette);
1874 case KEY_C + KEY_SHIFTED + KEY_DEBUGGED:
1875 if (!( Game_mode & GM_MULTI ))
1876 move_player_2_segment(Cursegp,Curside);
1877 break; //move eye to curseg
1880 case KEY_DEBUGGED+KEY_W: draw_world_from_game(); break;
1882 #endif //#ifdef EDITOR
1885 // case KEY_DEBUGGED+KEY_SHIFTED+KEY_F: toggle_flythrough(); break;
1886 // case KEY_LEFT: ft_preference=FP_LEFT; break;
1887 // case KEY_RIGHT: ft_preference=FP_RIGHT; break;
1888 // case KEY_UP: ft_preference=FP_UP; break;
1889 // case KEY_DOWN: ft_preference=FP_DOWN; break;
1892 case KEY_DEBUGGED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_next_viewer(); break;
1893 case KEY_DEBUGGED+KEY_CTRLED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_prev_viewer(); break;
1895 case KEY_DEBUGGED+KEY_SHIFTED+KEY_LAPOSTRO: Viewer=ConsoleObject; break;
1898 case KEY_DEBUGGED+KEY_O: toggle_outline_mode(); break;
1900 case KEY_DEBUGGED+KEY_T:
1901 *Toggle_var = !*Toggle_var;
1902 mprintf((0, "Variable at %08x set to %i\n", Toggle_var, *Toggle_var));
1904 case KEY_DEBUGGED + KEY_L:
1905 if (++Lighting_on >= 2) Lighting_on = 0; break;
1906 case KEY_DEBUGGED + KEY_SHIFTED + KEY_L:
1907 Beam_brightness=0x38000-Beam_brightness; break;
1908 case KEY_PAD5: slew_stop(); break;
1911 case KEY_DEBUGGED + KEY_F11: play_test_sound(); break;
1912 case KEY_DEBUGGED + KEY_SHIFTED+KEY_F11: advance_sound(); play_test_sound(); break;
1915 case KEY_DEBUGGED +KEY_F4: {
1916 //fvi_info hit_data;
1917 //vms_vector p0 = {-0x1d99a7,-0x1b20000,0x186ab7f};
1918 //vms_vector p1 = {-0x217865,-0x1b20000,0x187de3e};
1919 //find_vector_intersection(&hit_data,&p0,0x1b9,&p1,0x40000,0x0,NULL,-1);
1923 case KEY_DEBUGGED + KEY_M:
1924 Debug_spew = !Debug_spew;
1926 mopen( 0, 8, 1, 78, 16, "Debug Spew");
1927 HUD_init_message( "Debug Spew: ON" );
1930 HUD_init_message( "Debug Spew: OFF" );
1934 case KEY_DEBUGGED + KEY_C:
1936 full_palette_save();
1940 case KEY_DEBUGGED + KEY_SHIFTED + KEY_A:
1941 do_megawow_powerup(10);
1943 case KEY_DEBUGGED + KEY_A: {
1944 do_megawow_powerup(200);
1945 // if ( Game_mode & GM_MULTI ) {
1946 // nm_messagebox( NULL, 1, "Damn", "CHEATER!\nYou cannot use the\nmega-thing in network mode." );
1947 // Network_message_reciever = 100; // Send to everyone...
1948 // sprintf( Network_message, "%s cheated!", Players[Player_num].callsign);
1950 // do_megawow_powerup();
1955 case KEY_DEBUGGED+KEY_F: r_framerate.value = !r_framerate.value; break;
1957 case KEY_DEBUGGED+KEY_SPACEBAR: //KEY_F7: // Toggle physics flying
1959 game_flush_inputs();
1960 if ( ConsoleObject->control_type != CT_FLYING ) {
1961 fly_init(ConsoleObject);
1962 Game_suspended &= ~SUSP_ROBOTS; //robots move
1964 slew_init(ConsoleObject); //start player slewing
1965 Game_suspended |= SUSP_ROBOTS; //robots don't move
1969 case KEY_DEBUGGED+KEY_COMMA: Render_zoom = fixmul(Render_zoom,62259); break;
1970 case KEY_DEBUGGED+KEY_PERIOD: Render_zoom = fixmul(Render_zoom,68985); break;
1972 case KEY_DEBUGGED+KEY_P+KEY_SHIFTED: Debug_pause = 1; break;
1976 // sprintf(mystr,"mark %i start",Mark_count);
1980 //case KEY_SHIFTED+KEY_F7: {
1982 // sprintf(mystr,"mark %i end",Mark_count);
1990 case KEY_DEBUGGED+KEY_F8: speedtest_init(); Speedtest_count = 1; break;
1991 case KEY_DEBUGGED+KEY_F9: speedtest_init(); Speedtest_count = 10; break;
1993 case KEY_DEBUGGED+KEY_D:
1994 if ((Game_double_buffer = !Game_double_buffer)!=0)
2000 case KEY_DEBUGGED+KEY_Q:
2002 dump_used_textures_all();
2007 case KEY_DEBUGGED+KEY_B: {
2009 char text[FILENAME_LEN]="";
2011 m.type=NM_TYPE_INPUT; m.text_len = FILENAME_LEN; m.text = text;
2012 item = newmenu_do( NULL, "Briefing to play?", 1, &m, NULL );
2014 do_briefing_screens(text,1);
2020 case KEY_DEBUGGED+KEY_F5:
2021 toggle_movie_saving();
2024 case KEY_DEBUGGED+KEY_SHIFTED+KEY_F5: {
2025 extern int Movie_fixed_frametime;
2026 Movie_fixed_frametime = !Movie_fixed_frametime;
2030 case KEY_DEBUGGED+KEY_ALTED+KEY_F5:
2031 GameTime = i2f(0x7fff - 840); //will overflow in 14 minutes
2032 mprintf((0,"GameTime bashed to %d secs\n",f2i(GameTime)));
2035 case KEY_DEBUGGED+KEY_SHIFTED+KEY_B:
2036 kill_and_so_forth();
2040 #endif //#ifndef RELEASE
2042 // Cheat functions ------------------------------------------------------------
2043 extern char *jcrypt (char *);
2045 char *LamerCheats[]={ "!UyN#E$I", // gabba-gabbahey
2046 "ei5cQ-ZQ", // mo-therlode
2047 "q^EpZxs8", // c-urrygoat
2048 "mxk(DyyP", // zi-ngermans
2049 "cBo#@y@P", // ea-tangelos
2050 "CLygLBGQ", // e-ricaanne
2051 "xAnHQxZX", // jos-huaakira
2052 "cKc[KUWo", // wh-ammazoom
2055 #define N_LAMER_CHEATS (sizeof(LamerCheats) / sizeof(*LamerCheats))
2057 char *WowieCheat ="F_JMO3CV"; //only Matt knows / h-onestbob
2058 char *AllKeysCheat ="%v%MrgbU"; //only Matt knows / or-algroove
2059 char *InvulCheat ="Wv_\\JJ\\Z"; //only Matt knows / almighty
2060 char *HomingCheatString ="t\\LIhSB["; //only Matt knows / l-pnlizard
2061 char *BouncyCheat ="bGbiChQJ"; //only Matt knows / duddaboo
2062 char *FullMapCheat ="PI<XQHRI"; //only Matt knows / rockrgrl
2063 char *LevelWarpCheat ="ZQHtqbb\""; //only Matt knows / f-reespace
2064 char *MonsterCheat ="nfpEfRQp"; //only Matt knows / godzilla
2065 char *BuddyLifeCheat ="%A-BECuY"; //only Matt knows / he-lpvishnu
2066 char *BuddyDudeCheat ="u#uzIr%e"; //only Matt knows / g-owingnut
2067 char *KillRobotsCheat ="&wxbs:5O"; //only Matt knows / spaniard
2068 char *FinishLevelCheat ="%bG_bZ<D"; //only Matt knows / d-elshiftb
2069 char *RapidFireCheat ="*jLgHi'J"; //only Matt knows / wildfire
2071 char *RobotsKillRobotsCheat ="rT6xD__S"; // New for 1.1 / silkwing
2072 char *AhimsaCheat ="!Uscq_yc"; // New for 1.1 / im-agespace
2074 char *AccessoryCheat ="dWdz[kCK"; // al-ifalafel
2075 char *JohnHeadCheat ="ou]];H:%"; // p-igfarmer
2076 char *AcidCheat ="qPmwxz\"S"; // bit-tersweet
2077 char *FramerateCheat ="rQ60#ZBN"; // f-rametime
2079 char CheatBuffer[]="AAAAAAAAAAAAAAA";
2081 #define CHEATSPOT 14
2084 void do_cheat_penalty ()
2086 digi_play_sample( SOUND_CHEATER, F1_0);
2088 Players[Player_num].score=0;
2092 // Main Cheat function
2096 char john_head_on=0;
2099 char OldHomingState[20];
2100 extern char Monster_mode;
2102 void fill_background();
2103 void load_background_bitmap();
2105 extern int Robots_kill_robots_cheat;
2107 void FinalCheats(int key)
2112 key=key_to_ascii(key);
2115 CheatBuffer[i]=CheatBuffer[i+1];
2117 CheatBuffer[CHEATSPOT]=key;
2119 cryptstring=jcrypt(&CheatBuffer[7]);
2121 for (i=0;i<N_LAMER_CHEATS;i++)
2122 if (!(strcmp (cryptstring,LamerCheats[i])))
2125 Players[Player_num].shields=i2f(1);
2126 Players[Player_num].energy=i2f(1);
2128 if (Game_mode & GM_MULTI)
2130 Network_message_reciever = 100; // Send to everyone...
2131 sprintf( Network_message, "%s is crippled...get him!",Players[Player_num].callsign);
2134 HUD_init_message ("Take that...cheater!");
2137 if (!(strcmp (cryptstring,JohnHeadCheat)))
2139 john_head_on = !john_head_on;
2140 load_background_bitmap();
2142 HUD_init_message (john_head_on?"Hi John!!":"Bye John!!");
2144 if (!(strcmp (cryptstring,AcidCheat)))
2149 Interpolation_method=old_IntMethod;
2150 HUD_init_message ("Coming down...");
2155 old_IntMethod=Interpolation_method;
2156 Interpolation_method=1;
2157 HUD_init_message ("Going up!");
2162 if (!(strcmp (cryptstring,FramerateCheat)))
2164 r_framerate.value = !r_framerate.value;
2167 if (Game_mode & GM_MULTI)
2170 if (!(strcmp (&CheatBuffer[8],"blueorb")))
2172 if (Players[Player_num].shields < MAX_SHIELDS) {
2173 fix boost = 3*F1_0 + 3*F1_0*(NDL - Difficulty_level);
2174 if (Difficulty_level == 0)
2176 Players[Player_num].shields += boost;
2177 if (Players[Player_num].shields > MAX_SHIELDS)
2178 Players[Player_num].shields = MAX_SHIELDS;
2179 powerup_basic(0, 0, 15, SHIELD_SCORE, "%s %s %d",TXT_SHIELD,TXT_BOOSTED_TO,f2ir(Players[Player_num].shields));
2182 HUD_init_message(TXT_MAXED_OUT,TXT_SHIELD);
2185 if (!(strcmp(cryptstring,BuddyLifeCheat)))
2188 HUD_init_message ("What's this? Another buddy bot!");
2193 if (!(strcmp(cryptstring,BuddyDudeCheat)))
2196 Buddy_dude_cheat = !Buddy_dude_cheat;
2197 if (Buddy_dude_cheat) {
2198 HUD_init_message ("%s gets angry!",guidebot_name);
2199 strcpy(guidebot_name,"Wingnut");
2202 strcpy(guidebot_name,real_guidebot_name);
2203 HUD_init_message ("%s calms down",guidebot_name);
2208 if (!(strcmp(cryptstring,MonsterCheat)))
2210 Monster_mode=1-Monster_mode;
2212 HUD_init_message (Monster_mode?"Oh no, there goes Tokyo!":"What have you done, I'm shrinking!!");
2216 if (!(strcmp (cryptstring,BouncyCheat)))
2219 HUD_init_message ("Bouncing weapons!");
2223 if (!(strcmp(cryptstring,LevelWarpCheat)))
2229 //digi_play_sample( SOUND_CHEATER, F1_0);
2230 m.type=NM_TYPE_INPUT; m.text_len = 10; m.text = text;
2231 item = newmenu_do( NULL, TXT_WARP_TO_LEVEL, 1, &m, NULL );
2233 new_level_num = atoi(m.text);
2234 if (new_level_num!=0 && new_level_num>=0 && new_level_num<=Last_level) {
2235 StartNewLevel(new_level_num, 0);
2241 if (!(strcmp (cryptstring,WowieCheat)))
2244 HUD_init_message(TXT_WOWIE_ZOWIE);
2247 if (Piggy_hamfile_version < 3) // SHAREWARE
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));
2254 Players[Player_num].primary_weapon_flags = 0xffff ^ HAS_FLAG(SUPER_LASER_INDEX); //no super laser
2255 Players[Player_num].secondary_weapon_flags = 0xffff;
2258 for (i=0; i<MAX_PRIMARY_WEAPONS; i++)
2259 Players[Player_num].primary_ammo[i] = Primary_ammo_max[i];
2261 for (i=0; i<MAX_SECONDARY_WEAPONS; i++)
2262 Players[Player_num].secondary_ammo[i] = Secondary_ammo_max[i];
2264 if (Piggy_hamfile_version < 3) // SHAREWARE
2266 Players[Player_num].secondary_ammo[SMISSILE4_INDEX] = 0;
2267 Players[Player_num].secondary_ammo[SMISSILE5_INDEX] = 0;
2268 Players[Player_num].secondary_ammo[MEGA_INDEX] = 0;
2271 if (Game_mode & GM_HOARD)
2272 Players[Player_num].secondary_ammo[PROXIMITY_INDEX] = 12;
2274 if (Newdemo_state == ND_STATE_RECORDING)
2275 newdemo_record_laser_level(Players[Player_num].laser_level, MAX_LASER_LEVEL);
2277 Players[Player_num].energy = MAX_ENERGY;
2278 Players[Player_num].laser_level = MAX_SUPER_LASER_LEVEL;
2279 Players[Player_num].flags |= PLAYER_FLAGS_QUAD_LASERS;
2280 update_laser_weapon_info();
2284 if (!(strcmp (cryptstring,AllKeysCheat)))
2287 HUD_init_message(TXT_ALL_KEYS);
2288 Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2292 if (!(strcmp (cryptstring,InvulCheat)))
2295 Players[Player_num].flags ^= PLAYER_FLAGS_INVULNERABLE;
2296 HUD_init_message("%s %s!", TXT_INVULNERABILITY, (Players[Player_num].flags&PLAYER_FLAGS_INVULNERABLE)?TXT_ON:TXT_OFF);
2297 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2299 if (!(strcmp (cryptstring,AccessoryCheat)))
2302 Players[Player_num].flags |=PLAYER_FLAGS_HEADLIGHT;
2303 Players[Player_num].flags |=PLAYER_FLAGS_AFTERBURNER;
2304 Players[Player_num].flags |=PLAYER_FLAGS_AMMO_RACK;
2305 Players[Player_num].flags |=PLAYER_FLAGS_CONVERTER;
2307 HUD_init_message ("Accessories!!");
2309 if (!(strcmp (cryptstring,FullMapCheat)))
2312 Players[Player_num].flags |=PLAYER_FLAGS_MAP_ALL;
2314 HUD_init_message ("Full Map!!");
2318 if (!(strcmp (cryptstring,HomingCheatString)))
2325 OldHomingState[i]=Weapon_info[i].homing_flag;
2326 Weapon_info[i].homing_flag=1;
2328 HUD_init_message ("Homing weapons!");
2332 if (!(strcmp (cryptstring,KillRobotsCheat)))
2338 if (!(strcmp (cryptstring,FinishLevelCheat)))
2341 kill_and_so_forth();
2344 if (!(strcmp (cryptstring,RobotsKillRobotsCheat))) {
2345 Robots_kill_robots_cheat = !Robots_kill_robots_cheat;
2346 if (Robots_kill_robots_cheat) {
2347 HUD_init_message ("Rabid robots!");
2351 HUD_init_message ("Kill the player!");
2354 if (!(strcmp (cryptstring,AhimsaCheat))) {
2355 Robot_firing_enabled = !Robot_firing_enabled;
2356 if (!Robot_firing_enabled) {
2357 HUD_init_message("%s", "Robot firing OFF!");
2361 HUD_init_message("%s", "Robot firing ON!");
2364 if (!(strcmp (cryptstring,RapidFireCheat))) {
2365 if (Laser_rapid_fire) {
2366 Laser_rapid_fire = 0;
2367 HUD_init_message("%s", "Rapid fire OFF!");
2370 Laser_rapid_fire = 0xbada55;
2372 HUD_init_message("%s", "Rapid fire ON!");
2379 // Internal Cheat Menu
2381 void do_cheat_menu()
2384 newmenu_item mm[16];
2385 char score_text[21];
2387 sprintf( score_text, "%d", Players[Player_num].score );
2389 mm[0].type=NM_TYPE_CHECK; mm[0].value=Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE; mm[0].text="Invulnerability";
2390 mm[1].type=NM_TYPE_CHECK; mm[1].value=Players[Player_num].flags & PLAYER_FLAGS_CLOAKED; mm[1].text="Cloaked";
2391 mm[2].type=NM_TYPE_CHECK; mm[2].value=0; mm[2].text="All keys";
2392 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;
2393 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;
2394 mm[5].type=NM_TYPE_TEXT; mm[5].text = "Score:";
2395 mm[6].type=NM_TYPE_INPUT; mm[6].text_len = 10; mm[6].text = score_text;
2396 //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";
2397 //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";
2398 //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";
2399 //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";
2401 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;
2402 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;
2404 mmn = newmenu_do("Wimp Menu",NULL,9, mm, NULL );
2407 if ( mm[0].value ) {
2408 Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
2409 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2411 Players[Player_num].flags &= ~PLAYER_FLAGS_INVULNERABLE;
2412 if ( mm[1].value ) {
2413 Players[Player_num].flags |= PLAYER_FLAGS_CLOAKED;
2415 if (Game_mode & GM_MULTI)
2418 ai_do_cloak_stuff();
2419 Players[Player_num].cloak_time = GameTime;
2422 Players[Player_num].flags &= ~PLAYER_FLAGS_CLOAKED;
2424 if (mm[2].value) Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2425 Players[Player_num].energy=i2f(mm[3].value);
2426 Players[Player_num].shields=i2f(mm[4].value);
2427 Players[Player_num].score = atoi(mm[6].text);
2428 //if (mm[7].value) Players[Player_num].laser_level=0;
2429 //if (mm[8].value) Players[Player_num].laser_level=1;
2430 //if (mm[9].value) Players[Player_num].laser_level=2;
2431 //if (mm[10].value) Players[Player_num].laser_level=3;
2432 Players[Player_num].laser_level = mm[7].value-1;
2433 Players[Player_num].secondary_ammo[CONCUSSION_INDEX] = mm[8].value;
2441 // Testing functions ----------------------------------------------------------
2444 void speedtest_init(void)
2446 Speedtest_start_time = timer_get_fixed_seconds();
2448 Speedtest_segnum = 0;
2449 Speedtest_sidenum = 0;
2450 Speedtest_frame_start = FrameCount;
2452 mprintf((0, "Starting speedtest. Will be %i frames. Each . = 10 frames.\n", Highest_segment_index+1));
2455 void speedtest_frame(void)
2457 vms_vector view_dir, center_point;
2459 Speedtest_sidenum=Speedtest_segnum % MAX_SIDES_PER_SEGMENT;
2461 compute_segment_center(&Viewer->pos, &Segments[Speedtest_segnum]);
2462 Viewer->pos.x += 0x10; Viewer->pos.y -= 0x10; Viewer->pos.z += 0x17;
2464 obj_relink(Viewer-Objects, Speedtest_segnum);
2465 compute_center_point_on_side(¢er_point, &Segments[Speedtest_segnum], Speedtest_sidenum);
2466 vm_vec_normalized_dir_quick(&view_dir, ¢er_point, &Viewer->pos);
2467 vm_vector_2_matrix(&Viewer->orient, &view_dir, NULL, NULL);
2469 if (((FrameCount - Speedtest_frame_start) % 10) == 0)
2474 if (Speedtest_segnum > Highest_segment_index) {
2477 sprintf(msg, "\nSpeedtest done: %i frames, %7.3f seconds, %7.3f frames/second.\n",
2478 FrameCount-Speedtest_frame_start,
2479 f2fl(timer_get_fixed_seconds() - Speedtest_start_time),
2480 (float) (FrameCount-Speedtest_frame_start) / f2fl(timer_get_fixed_seconds() - Speedtest_start_time));
2482 mprintf((0, "%s", msg));
2483 HUD_init_message(msg);
2486 if (Speedtest_count == 0)
2495 // Sounds for testing
2497 int test_sound_num = 0;
2498 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};
2500 #define N_TEST_SOUNDS (sizeof(sound_nums) / sizeof(*sound_nums))
2503 void advance_sound()
2505 if (++test_sound_num == N_TEST_SOUNDS)
2511 int Test_sound = 251;
2513 void play_test_sound()
2516 // -- digi_play_sample(sound_nums[test_sound_num], F1_0);
2517 digi_play_sample(Test_sound, F1_0);
2520 #endif //ifndef NDEBUG
2530 static ubyte exploding_flag=0;
2532 Player_fired_laser_this_frame=-1;
2534 if (!Endlevel_sequence) // && !Player_is_dead //this was taken out of the if statement by WraithX
2537 if ( (Newdemo_state == ND_STATE_PLAYBACK) || (DefiningMarkerMessage)
2539 || multi_sending_message || multi_defining_message
2541 ) // WATCH OUT!!! WEIRD CODE ABOVE!!!
2542 memset( &Controls, 0, sizeof(control_info) );
2545 controls_read_all_win();
2547 controls_read_all(); //NOTE LINK TO ABOVE!!!
2552 // If automap key pressed, enable automap unless you are in network mode, control center destroyed and < 10 seconds left
2553 if ( Controls.automap_down_count && !((Game_mode & GM_MULTI) && Control_center_destroyed && (Countdown_seconds_left < 10)))
2560 if (Player_exploded) { //Player_is_dead && (ConsoleObject->flags & OF_EXPLODING) ) {
2562 if (exploding_flag==0) {
2563 exploding_flag = 1; // When player starts exploding, clear all input devices...
2564 game_flush_inputs();
2567 //if (key_down_count(KEY_BACKSP))
2569 //if (key_down_count(KEY_PRINT_SCREEN))
2570 // save_screen_shot(0);
2573 for (i = 0; i < 4; i++)
2574 // the following "if" added by WraithX, 4/17/00
2575 if (isJoyRotationKey(i) != 1)
2577 if (joy_get_button_down_cnt(i) > 0)
2578 Death_sequence_aborted = 1;
2579 }// end "if" added by WraithX
2581 if (joy_get_any_button_down_cnt() > 0)
2582 Death_sequence_aborted = 1;
2584 for (i = 0; i < 3; i++)
2585 // the following "if" added by WraithX, 4/17/00
2586 if (isMouseRotationKey(i) != 1)
2588 if (mouse_button_down_count(i) > 0)
2589 Death_sequence_aborted = 1;
2590 }// end "if" added by WraithX
2592 //for (i = 0; i < 256; i++)
2593 // // the following "if" added by WraithX, 4/17/00
2594 // if (isKeyboardRotationKey(i) != 1)
2596 // if (!key_isfunc(i) && !key_ismod(i) && key_down_count(i) > 0)
2597 // Death_sequence_aborted = 1;
2598 // }// end "if" added by WraithX
2600 if (Death_sequence_aborted)
2601 game_flush_inputs();
2607 if (Newdemo_state == ND_STATE_PLAYBACK )
2610 while ((key=key_inkey_time(&key_time)) != 0) {
2612 if (DefiningMarkerMessage)
2614 MarkerInputMessage (key);
2619 if ( (Game_mode&GM_MULTI) && (multi_sending_message || multi_defining_message )) {
2620 multi_message_input_sub( key );
2621 continue; //get next key
2627 if ((key&KEY_DEBUGGED)&&(Game_mode&GM_MULTI)) {
2628 Network_message_reciever = 100; // Send to everyone...
2629 sprintf( Network_message, "%s %s", TXT_I_AM_A, TXT_CHEATER);
2635 if(!con_events(key))
2640 HandleDeathKey(key);
2642 if (Endlevel_sequence)
2643 HandleEndlevelKey(key);
2644 else if (Newdemo_state == ND_STATE_PLAYBACK ) {
2653 HandleSystemKey(key);
2664 // if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[KEY_F8] && (keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT]))
2665 // transfer_energy_to_shield(key_down_time(KEY_F8));