void change_res() { //edited 05/27/99 Matt Mueller - ingame fullscreen changing newmenu_item m[11]; u_int32_t modes[11]; int i=0, mc=0, num_presets=0; char customres[16]; #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE int fullscreenc; #endif //end edit -MM u_int32_t screen_mode = 0; int screen_width = 0; int screen_height = 0; int vr_mode = VR_NONE; int screen_compatible = 0; int use_double_buffer = 0; //changed 6/15/1999 by Owen Evans to fix some platform-related problems #ifdef __MSDOS__ m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x100"; m[mc].value=(Game_screen_mode==SM(320,100)); m[mc].group=0; modes[mc] = SM(320,100); mc++; #endif m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200"; m[mc].value=(Game_screen_mode==SM(320,200)); m[mc].group=0; modes[mc] = SM(320,200); mc++; m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x240"; m[mc].value=(Game_screen_mode==SM(320,240)); m[mc].group=0; modes[mc] = SM(320,240); mc++; m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x400"; m[mc].value=(Game_screen_mode==SM(320,400)); m[mc].group=0; modes[mc] = SM(320,400); mc++; //#ifndef __LINUX__ - heh? 640x400 is perfectly fine on linux m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x400"; m[mc].value=(Game_screen_mode==SM(640,400)); m[mc].group=0; modes[mc] = SM(640,400); mc++; //#endif m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480"; m[mc].value=(Game_screen_mode==SM(640,480)); m[mc].group=0; modes[mc] = SM(640,480); mc++; m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600"; m[mc].value=(Game_screen_mode==SM(800,600)); m[mc].group=0; modes[mc] = SM(800,600); mc++; m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768"; m[mc].value=(Game_screen_mode==SM(1024,768)); m[mc].group=0; modes[mc] = SM(1024,768); mc++; //end section - OE num_presets = mc; for (i=0; i<mc; i++) if (m[mc].value) break; m[mc].type = NM_TYPE_RADIO; m[mc].text = "custom:"; m[mc].value=(i==mc); m[mc].group=0; modes[mc] = 0; mc++; sprintf(customres, "%ix%i", SM_W(Game_screen_mode), SM_H(Game_screen_mode)); m[mc].type = NM_TYPE_INPUT; m[mc].text = customres; m[mc].text_len=11; modes[mc] = 0; mc++; // m[mc].type = NM_TYPE_CHECK; m[mc].text = "No Doublebuffer"; m[mc].value = use_double_buffer; //added 05/27/99 Matt Mueller - ingame fullscreen changing #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE fullscreenc=mc;m[mc].type = NM_TYPE_CHECK; m[mc].text = "Fullscreen"; m[mc].value = gr_check_fullscreen();mc++; #endif //end addition -MM i=newmenu_do1( NULL, "Screen Resolution", mc, m, &change_res_poll, 0); //added 05/27/99 Matt Mueller - ingame fullscreen changing #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE if (m[fullscreenc].value != gr_check_fullscreen()){ gr_toggle_fullscreen(); Game_screen_mode = -1; } #endif //end addition -MM for(i=0;(m[i].value==0)&&(i<num_presets);i++); if (modes[i]==0){ char *h=strchr(customres, 'x'); if (!h) return; screen_mode = SM(atoi(customres), atoi(h+1)); }else{ screen_mode = modes[i]; } screen_width = SM_W(screen_mode); screen_height = SM_H(screen_mode); if (screen_height<=0 || screen_width<=0) return; switch(screen_mode) { case SM(320,100)://19: screen_compatible = 0; use_double_buffer = 0; break; case SM(320,200)://SM_320x200C: screen_compatible = 1; use_double_buffer = 0; break; default: screen_compatible = 0; use_double_buffer = 1; break; } #ifdef __MSDOS__ if ( FindArg( "-nodoublebuffer" ) ) #endif use_double_buffer = 0; //added 6/15/1999 by Owen Evans to eliminate unneccesary mode modification if (Game_screen_mode == screen_mode) return; // gr_set_mode(Game_screen_mode); //end section - OE VR_offscreen_buffer = 0; //Disable VR (so that VR_Screen_mode doesnt mess us up Game_screen_mode = screen_mode; Game_window_w=screen_width; Game_window_h=screen_height; game_init_render_buffers(screen_mode, screen_width, screen_height, use_double_buffer, vr_mode, screen_compatible); mprintf( (0, "\nInitializing palette system..." )); gr_use_palette_table( "PALETTE.256" ); mprintf( (0, "\nInitializing font system..." )); gamefont_init(); // must load after palette data loaded. reset_palette_add(); init_cockpit(); last_drawn_cockpit[0]=-1; last_drawn_cockpit[1]=-1; // init_gauges(); vr_reset_display(); }
//called when the player has died void DoPlayerDead() { int cycle_window_vis = 1; #ifdef NETWORK if ( (Game_mode & GM_MULTI) && (Netgame.SpawnStyle == SPAWN_STYLE_PREVIEW)) { cycle_window_vis = 0; } #endif if (Game_wind && cycle_window_vis) window_set_visible(Game_wind, 0); reset_palette_add(); gr_palette_load (gr_palette); dead_player_end(); //terminate death sequence (if playing) #ifdef EDITOR if (Game_mode == GM_EDITOR) { //test mine, not real level object * player = &Objects[Players[Player_num].objnum]; //nm_messagebox( "You're Dead!", 1, "Continue", "Not a real game, though." ); if (Game_wind) window_set_visible(Game_wind, 1); load_level("gamesave.lvl"); init_player_stats_new_ship(Player_num); player->flags &= ~OF_SHOULD_BE_DEAD; StartLevel(0); return; } #endif #ifdef NETWORK if ( Game_mode&GM_MULTI ) { multi_do_death(Players[Player_num].objnum); } else #endif { //Note link to above else! Players[Player_num].lives--; if (Players[Player_num].lives == 0) { DoGameOver(); return; } } if ( Control_center_destroyed ) { int rval; //clear out stuff so no bonus Players[Player_num].hostages_on_board = 0; Players[Player_num].energy = 0; Players[Player_num].shields = 0; #ifdef NETWORK Players[Player_num].connected = CONNECT_DIED_IN_MINE; #endif do_screen_message(TXT_DIED_IN_MINE); // Give them some indication of what happened if (Current_level_num == Last_level) { #ifdef NETWORK if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) { multi_endlevel_score(); rval = AdvanceLevel(0); //if finished, go on to next level } else #endif { // Note link to above else! rval = AdvanceLevel(0); //if finished, go on to next level DoEndLevelScoreGlitz(0); } init_player_stats_new_ship(Player_num); last_drawn_cockpit = -1; } else { #ifdef NETWORK if (Game_mode & GM_MULTI) multi_endlevel_score(); else #endif DoEndLevelScoreGlitz(0); // Note above link! rval = AdvanceLevel(0); //if finished, go on to next level init_player_stats_new_ship(Player_num); last_drawn_cockpit = -1; } if (rval) { #ifndef SHAREWARE if (PLAYING_BUILTIN_MISSION) #endif scores_maybe_add_player(0); if (Game_wind) window_close(Game_wind); // Exit out of game loop } } else { init_player_stats_new_ship(Player_num); StartLevel(1); } if (Game_wind && cycle_window_vis) window_set_visible(Game_wind, 1); reset_time(); }
//called when the player is starting a new level for normal game mode and restore state void StartNewLevelSub(int level_num, int page_in_textures, int secret_flag) { /* * This flag is present for compatibility with D2X. Set it to zero * so the optimizer deletes all reference to it. */ secret_flag = 0; if (!(Game_mode & GM_MULTI)) { last_drawn_cockpit = -1; } if (Newdemo_state == ND_STATE_PAUSED) Newdemo_state = ND_STATE_RECORDING; if (Newdemo_state == ND_STATE_RECORDING) { newdemo_set_new_level(level_num); newdemo_record_start_frame(FrameTime ); } LoadLevel(level_num, page_in_textures); Assert(Current_level_num == level_num); //make sure level set right gameseq_init_network_players(); // Initialize the Players array for // this level #ifdef NETWORK if (Game_mode & GM_NETWORK) { if(multi_level_sync()) // After calling this, Player_num is set { songs_play_song( SONG_TITLE, 1 ); // level song already plays but we fail to start level... return; } } #endif HUD_clear_messages(); automap_clear_visited(); init_player_stats_level(secret_flag); gr_use_palette_table( "palette.256" ); gr_palette_load(gr_palette); #ifndef SHAREWARE #ifdef NETWORK if ((Game_mode & GM_MULTI_COOP) && Network_rejoined) { int i; for (i = 0; i < N_players; i++) Players[i].flags |= Netgame.player_flags[i]; } #endif #endif Viewer = &Objects[Players[Player_num].objnum]; #ifdef NETWORK if (Game_mode & GM_MULTI) { multi_prep_level(); // Removes robots from level if necessary } #endif gameseq_remove_unused_players(); Game_suspended = 0; Control_center_destroyed = 0; init_cockpit(); init_robots_for_level(); init_ai_objects(); init_morphs(); init_all_matcens(); reset_palette_add(); if (!(Game_mode & GM_MULTI) && !cheats.enabled) set_highest_level(Current_level_num); reset_special_effects(); #ifdef OGL ogl_cache_level_textures(); #endif #ifdef NETWORK if (Network_rejoined == 1) { Network_rejoined = 0; StartLevel(1); } else #endif StartLevel(0); // Note link to above if! copy_defaults_to_robot_all(); init_controlcen_for_level(); // Say player can use FLASH cheat to mark path to exit. Last_level_path_created = -1; // Initialise for palette_restore() if (!((Game_mode & GM_MULTI) && (Newdemo_state != ND_STATE_PLAYBACK))) palette_save(); if (!Game_wind) game(); }
void do_countdown_frame() { fix old_time; int fc, div_scale; if (!Control_center_destroyed) return; // Control center destroyed, rock the player's ship. fc = Countdown_seconds_left; if (fc > 16) fc = 16; // At Trainee, decrease rocking of ship by 4x. div_scale = 1; if (Difficulty_level == 0) div_scale = 4; if (FixedStep & EPS20) { ConsoleObject->mtype.phys_info.rotvel.x += (fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32))/div_scale; ConsoleObject->mtype.phys_info.rotvel.z += (fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32))/div_scale; } // Hook in the rumble sound effect here. old_time = Countdown_timer; Countdown_timer -= FrameTime; Countdown_seconds_left = f2i(Countdown_timer + F1_0*7/8); if ( (old_time > COUNTDOWN_VOICE_TIME ) && (Countdown_timer <= COUNTDOWN_VOICE_TIME) ) { digi_play_sample( SOUND_COUNTDOWN_13_SECS, F3_0 ); } if ( f2i(old_time + F1_0*7/8) != Countdown_seconds_left ) { if ( (Countdown_seconds_left>=0) && (Countdown_seconds_left<10) ) digi_play_sample( SOUND_COUNTDOWN_0_SECS+Countdown_seconds_left, F3_0 ); if ( Countdown_seconds_left==Total_countdown_time-1) digi_play_sample( SOUND_COUNTDOWN_29_SECS, F3_0 ); } if (Countdown_timer > 0) { fix size,old_size; size = (i2f(Total_countdown_time)-Countdown_timer) / fl2f(0.65); old_size = (i2f(Total_countdown_time)-old_time) / fl2f(0.65); if (size != old_size && (Countdown_seconds_left < (Total_countdown_time-5) )) { // Every 2 seconds! //@@if (Dead_controlcen_object_num != -1) { //@@ vms_vector vp; //,v,c; //@@ compute_segment_center(&vp, &Segments[Objects[Dead_controlcen_object_num].segnum]); //@@ object_create_explosion( Objects[Dead_controlcen_object_num].segnum, &vp, size*10, VCLIP_SMALL_EXPLOSION); //@@} digi_play_sample( SOUND_CONTROL_CENTER_WARNING_SIREN, F3_0 ); } } else { int flash_value; if (old_time > 0) digi_play_sample( SOUND_MINE_BLEW_UP, F1_0 ); flash_value = f2i(-Countdown_timer * (64 / 4)); // 4 seconds to total whiteness PALETTE_FLASH_SET(flash_value,flash_value,flash_value); if (PaletteBlueAdd > 64 ) { gr_set_current_canvas( NULL ); gr_clear_canvas(BM_XRGB(31,31,31)); //make screen all white to match palette effect reset_palette_add(); //restore palette for death message //controlcen->MaxCapacity = Fuelcen_max_amount; //gauge_message( "Control Center Reset" ); DoPlayerDead(); //kill_player(); } } }
//called when the player is starting a new level for normal game mode and restore state void StartNewLevelSub(int level_num, int page_in_textures) { if (!(Game_mode & GM_MULTI)) { last_drawn_cockpit = -1; } if (Newdemo_state == ND_STATE_PAUSED) Newdemo_state = ND_STATE_RECORDING; if (Newdemo_state == ND_STATE_RECORDING) { newdemo_set_new_level(level_num); newdemo_record_start_frame(FrameTime ); } if (Game_mode & GM_MULTI) Function_mode = FMODE_MENU; // Cheap fix to prevent problems with errror dialogs in loadlevel. LoadLevel(level_num); if ( page_in_textures ) { piggy_load_level_data(); } Assert(Current_level_num == level_num); //make sure level set right gameseq_init_network_players(); // Initialize the Players array for // this level #ifdef NETWORK if (Game_mode & GM_NETWORK) { if(network_level_sync()) // After calling this, Player_num is set return; } #endif Assert(Function_mode == FMODE_GAME); HUD_clear_messages(); automap_clear_visited(); #ifdef NETWORK if (Network_new_game == 1) { Network_new_game = 0; init_player_stats_new_ship(); } #endif init_player_stats_level(); #ifndef SHAREWARE #ifdef NETWORK if ((Game_mode & GM_MULTI_COOP) && Network_rejoined) { int i; for (i = 0; i < N_players; i++) Players[i].flags |= Netgame.player_flags[i]; } #endif #endif Viewer = &Objects[Players[Player_num].objnum]; #ifdef NETWORK if (Game_mode & GM_MULTI) { multi_prep_level(); // Removes robots from level if necessary } #endif gameseq_remove_unused_players(); count_powerup_start_level(); Game_suspended = 0; Fuelcen_control_center_destroyed = 0; init_cockpit(); init_robots_for_level(); init_ai_objects(); init_morphs(); init_all_matcens(); reset_palette_add(); game_flush_inputs(); // clear out the keyboard if (!(Game_mode & GM_MULTI) && !Cheats_enabled) set_highest_level(Current_level_num); reset_special_effects(); #ifdef OGL ogl_cache_level_textures(); #endif #ifdef NETWORK if (Network_rejoined == 1) { Network_rejoined = 0; StartLevel(1); } else #endif StartLevel(0); // Note link to above if! copy_defaults_to_robot_all(); init_controlcen_for_level(); // Say player can use FLASH cheat to mark path to exit. Last_level_path_created = -1; }
//called when the player has died void DoPlayerDead() { reset_palette_add(); gr_palette_load (gr_palette); dead_player_end(); //terminate death sequence (if playing) #ifdef HOSTAGE_FACES stop_all_hostage_clips(); #endif #ifdef EDITOR if (Game_mode == GM_EDITOR) { //test mine, not real level object * player = &Objects[Players[Player_num].objnum]; //nm_messagebox( "You're Dead!", 1, "Continue", "Not a real game, though." ); load_level("gamesave.lvl"); init_player_stats_new_ship(); player->flags &= ~OF_SHOULD_BE_DEAD; StartLevel(0); return; } #endif #ifdef NETWORK if ( Game_mode&GM_MULTI ) { multi_do_death(Players[Player_num].objnum); } else #endif { //Note link to above else! Players[Player_num].lives--; if (Players[Player_num].lives == 0) { DoGameOver(); return; } } if ( Fuelcen_control_center_destroyed ) { int rval; //clear out stuff so no bonus Players[Player_num].hostages_on_board = 0; Players[Player_num].energy = 0; Players[Player_num].shields = 0; Players[Player_num].connected = 3; died_in_mine_message(); // Give them some indication of what happened if (Current_level_num == Last_level) { #ifdef NETWORK if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) { multi_endlevel_score(); rval = AdvanceLevel(0); //if finished, go on to next level } else #endif { // Note link to above else! rval = AdvanceLevel(0); //if finished, go on to next level DoEndLevelScoreGlitz(0); } init_player_stats_new_ship(); last_drawn_cockpit = -1; } else { #ifdef NETWORK if (Game_mode & GM_MULTI) multi_endlevel_score(); else #endif DoEndLevelScoreGlitz(0); // Note above link! rval = AdvanceLevel(0); //if finished, go on to next level init_player_stats_new_ship(); last_drawn_cockpit = -1; } if (rval) { #ifndef SHAREWARE if (PLAYING_BUILTIN_MISSION) #endif scores_maybe_add_player(0); longjmp( LeaveGame, 1 ); // Exit out of game loop } } else { init_player_stats_new_ship(); StartLevel(1); } }