void toggle_cockpit() { int new_mode=CM_FULL_SCREEN; if (Rear_view || Player_is_dead) // jinx 01-25-13 spec return; switch (PlayerCfg.CockpitMode[1]) { case CM_FULL_COCKPIT: new_mode = CM_STATUS_BAR; break; case CM_STATUS_BAR: new_mode = CM_FULL_SCREEN; break; case CM_FULL_SCREEN: new_mode = CM_FULL_COCKPIT; break; } select_cockpit(new_mode); HUD_clear_messages(); PlayerCfg.CockpitMode[0] = new_mode; write_player_file(); }
int do_difficulty_menu() { int s; newmenu_item m[5]; m[0].type=NM_TYPE_MENU; m[0].text=MENU_DIFFICULTY_TEXT(0); m[1].type=NM_TYPE_MENU; m[1].text=MENU_DIFFICULTY_TEXT(1); m[2].type=NM_TYPE_MENU; m[2].text=MENU_DIFFICULTY_TEXT(2); m[3].type=NM_TYPE_MENU; m[3].text=MENU_DIFFICULTY_TEXT(3); m[4].type=NM_TYPE_MENU; m[4].text=MENU_DIFFICULTY_TEXT(4); s = newmenu_do1( NULL, TXT_DIFFICULTY_LEVEL, NDL, m, NULL, Difficulty_level); if (s > -1 ) { if (s != Difficulty_level) { Player_default_difficulty = s; write_player_file(); } Difficulty_level = s; mprintf((0, "%s %s %i\n", TXT_DIFFICULTY_LEVEL, TXT_SET_TO, Difficulty_level)); return 1; } return 0; }
int HandleGameKey(int key) { switch (key) { case KEY_ALTED+KEY_F7: KEY_MAC(case KEY_COMMAND+KEY_ALTED+KEY_7:) PlayerCfg.HudMode=(PlayerCfg.HudMode+1)%GAUGE_HUD_NUMMODES; write_player_file(); switch (PlayerCfg.HudMode) { case 0: HUD_init_message_literal(HM_DEFAULT, "Standard HUD"); break; case 1: HUD_init_message_literal(HM_DEFAULT, "Alternative HUD #1"); break; case 2: HUD_init_message_literal(HM_DEFAULT, "Alternative HUD #2"); break; case 3: HUD_init_message_literal(HM_DEFAULT, "No HUD"); break; } break; #ifdef NETWORK KEY_MAC(case KEY_COMMAND+KEY_6:) case KEY_F6: if (Netgame.RefusePlayers && WaitForRefuseAnswer) { RefuseThisPlayer=1; HUD_init_message_literal(HM_MULTI, "Player accepted!"); } else { Show_network_stats = ! Show_network_stats; } break; case KEY_ALTED + KEY_1: if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM)) { RefuseThisPlayer=1; HUD_init_message_literal(HM_MULTI, "Player accepted!"); RefuseTeam=1; game_flush_inputs(); } break; case KEY_ALTED + KEY_2: if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM)) { RefuseThisPlayer=1; HUD_init_message_literal(HM_MULTI, "Player accepted!"); RefuseTeam=2; game_flush_inputs(); } break; #endif default: return 0; break; } //switch (key) return 1; }
int MakeNewPlayerFile(int allow_abort) { int x; char filename[14]; newmenu_item m; char text[CALLSIGN_LEN+1]=""; FILE *fp; strncpy(text, Players[Player_num].callsign,CALLSIGN_LEN); try_again: m.type=NM_TYPE_INPUT; m.text_len = 8; m.text = text; Newmenu_allowed_chars = playername_allowed_chars; x = newmenu_do( NULL, TXT_ENTER_PILOT_NAME, 1, &m, NULL ); Newmenu_allowed_chars = NULL; if ( x < 0 ) { if ( allow_abort ) return 0; goto try_again; } if (text[0]==0) //null string goto try_again; sprintf( filename, "%s.plr", text ); fp = fopen( filename, "rb" ); //if the callsign is the name of a tty device, prepend a char if (fp && isatty(fileno(fp))) { fclose(fp); sprintf(filename,"$%.7s.plr",text); fp = fopen(filename,"rb"); } if ( fp ) { nm_messagebox(NULL, 1, TXT_OK, "%s '%s' %s", TXT_PLAYER, text, TXT_ALREADY_EXISTS ); fclose(fp); goto try_again; } if ( !new_player_config() ) goto try_again; // They hit Esc during New player config strncpy(Players[Player_num].callsign, text, CALLSIGN_LEN); init_game_list(); //init to defaults write_player_file(); return 1; }
void do_options_menu() { // newmenu_item m[14]; newmenu_item m[14]; int i = 0; do { m[0].type = NM_TYPE_SLIDER; m[0].text=TXT_FX_VOLUME; m[0].value=Config_digi_volume;m[0].min_value=0; m[0].max_value=8; m[1].type = NM_TYPE_SLIDER; m[1].text=TXT_MUSIC_VOLUME; m[1].value=Config_midi_volume;m[1].min_value=0; m[1].max_value=8; m[2].type = NM_TYPE_CHECK; m[2].text=TXT_REVERSE_STEREO; m[2].value=Config_channels_reversed; m[3].type = NM_TYPE_TEXT; m[3].text=""; //added/changed on 10/27/98 by Victor Rachels to increase brightness range m[4].type = NM_TYPE_SLIDER; m[4].text=TXT_BRIGHTNESS; m[4].value=gr_palette_get_gamma();m[4].min_value=0; m[4].max_value=16; //end this section addition - Victor Rachels m[5].type = NM_TYPE_TEXT; m[5].text=""; m[6].type = NM_TYPE_MENU; m[6].text=TXT_CONTROLS_; m[7].type = NM_TYPE_MENU; m[7].text=TXT_DETAIL_LEVELS; m[8].type = NM_TYPE_MENU; m[8].text=TXT_CAL_JOYSTICK; //added/changed on 10/27/98 by Victor Rachels to increase sensitivity range m[9].type = NM_TYPE_SLIDER; m[9].text=TXT_JOYS_SENSITIVITY; m[9].value=Config_joystick_sensitivity; m[9].min_value =0; m[9].max_value = 8; //end this section addition - Victor Rachels //added on 4/13/99 by Victor Rachels to add joystick deadzone option m[10].type = NM_TYPE_SLIDER; m[10].text="Joystick Deadzone"; m[10].value=joy_deadzone; m[10].min_value=0; m[10].max_value=16; //end this section addition - VR m[11].type = NM_TYPE_TEXT; m[11].text=""; m[12].type = NM_TYPE_CHECK; m[12].text="Ship auto-leveling"; m[12].value=Auto_leveling_on; m[13].type = NM_TYPE_MENU; m[13].text="D1X options..."; i = newmenu_do1( NULL, TXT_OPTIONS, 14, m, joydef_menuset, i ); switch(i) { case 6: joydefs_config(); break; case 7: do_detail_level_menu(); break; case 8: joydefs_calibrate(); break; case 13: d1x_options_menu(); break; } Config_channels_reversed = m[2].value; Config_joystick_sensitivity = m[9].value; joy_deadzone = m[10].value; Auto_leveling_on = m[12].value; } while( i>-1 ); if ( Config_midi_volume < 1 ) { digi_play_midi_song( NULL, NULL, NULL, 0 ); } write_player_file(); }
//set a new highest level for player for this mission void set_highest_level(int levelnum) { int ret,i; if ((ret=read_player_file()) != EZERO) if (ret != ENOENT) //if file doesn't exist, that's ok return; i = find_hli_entry(); if (levelnum > PlayerCfg.HighestLevels[i].LevelNum) PlayerCfg.HighestLevels[i].LevelNum = levelnum; write_player_file(); }
void do_options_menu() { newmenu_item m[13]; int i = 0; do { // m[0].type = NM_TYPE_SLIDER; m[0].text=TXT_FX_VOLUME; m[0].value=Config_digi_volume;m[0].min_value=0; m[0].max_value=8; // m[1].type = NM_TYPE_SLIDER; m[1].text=TXT_MUSIC_VOLUME; m[1].value=Config_midi_volume;m[1].min_value=0; m[1].max_value=8; // m[2].type = NM_TYPE_CHECK; m[2].text=TXT_REVERSE_STEREO; m[2].value=Config_channels_reversed; m[0].type = NM_TYPE_MENU; m[0].text="Sound/Music Controls..."; m[1].type = NM_TYPE_TEXT; m[1].text=""; m[2].type = NM_TYPE_SLIDER; m[2].text=TXT_BRIGHTNESS; m[2].value=gr_palette_get_gamma();m[2].min_value=0; m[2].max_value=8; m[3].type = NM_TYPE_TEXT; m[3].text=""; #ifndef APPLE_OEM m[4].type = NM_TYPE_MENU; m[4].text=TXT_CONTROLS_; #else m[4].type = NM_TYPE_TEXT; m[4].text = ""; #endif m[5].type = NM_TYPE_MENU; m[5].text=TXT_DETAIL_LEVELS; m[6].type = NM_TYPE_MENU; m[6].text=TXT_CAL_JOYSTICK; m[7].type = NM_TYPE_TEXT; m[7].text=""; m[8].type = NM_TYPE_SLIDER; m[8].text=TXT_JOYS_SENSITIVITY; m[8].value=Config_joystick_sensitivity; m[8].min_value =0; m[8].max_value = 8; m[9].type = NM_TYPE_TEXT; m[9].text=""; m[10].type = NM_TYPE_CHECK; m[10].text="Pixel Double"; m[10].value=Scanline_double; m[11].type = NM_TYPE_CHECK; m[11].text="Ship auto-leveling"; m[11].value=Auto_leveling_on; i = newmenu_do4( NULL, TXT_OPTIONS, 12, m, joydef_menuset, i, NULL, -1, -1, 1 ); switch(i) { case 0: do_sound_menu(); break; case 4: joydefs_config(); break; case 5: do_detail_level_menu(); break; case 6: joydefs_calibrate(); break; } // Config_channels_reversed = m[2].value; Config_joystick_sensitivity = m[8].value; Auto_leveling_on = m[11].value; Scanline_double = m[10].value; } while( i>-1 ); // if ( Config_midi_volume < 1 ) { // digi_play_midi_song( NULL, NULL, NULL, 0 ); // } write_player_file(); }
int MakeNewPlayerFile(int allow_abort) { int x; char filename[14]; newmenu_item m; char text[CALLSIGN_LEN+1]=""; strncpy(text, Players[Player_num].callsign,CALLSIGN_LEN); try_again: m.type=NM_TYPE_INPUT; m.text_len = 8; m.text = text; Newmenu_allowed_chars = playername_allowed_chars; x = newmenu_do( NULL, TXT_ENTER_PILOT_NAME, 1, &m, NULL ); Newmenu_allowed_chars = NULL; if ( x < 0 ) { if ( allow_abort ) return 0; goto try_again; } if (text[0]==0) //null string goto try_again; strlwr(text); sprintf( filename, GameArg.SysUsePlayersDir? "Players/%s.plr" : "%s.plr", text ); if (PHYSFS_exists(filename)) { nm_messagebox(NULL, 1, TXT_OK, "%s '%s' %s", TXT_PLAYER, text, TXT_ALREADY_EXISTS ); goto try_again; } if ( !new_player_config() ) goto try_again; // They hit Esc during New player config strncpy(Players[Player_num].callsign, text, CALLSIGN_LEN); strlwr(Players[Player_num].callsign); write_player_file(); return 1; }
void d1x_options_menu() { newmenu_item m[14]; int i=0; int opt=0; int inputs,checks,commands; char smaxfps[4]; char shudmaxnumdisp[4]; char thogdir[64]; extern int gr_message_color_level; sprintf(thogdir,AltHogDir); sprintf(smaxfps,"%d",maxfps); sprintf(shudmaxnumdisp,"%d",HUD_max_num_disp); m[opt].type = NM_TYPE_MENU; m[opt].text = "Primary autoselect ordering..."; opt++; m[opt].type = NM_TYPE_MENU; m[opt].text = "Secondary autoselect ordering..."; opt++; //added on 2/4/99 by Victor Rachels for new key menu m[opt].type = NM_TYPE_MENU; m[opt].text = "D1X Keys"; opt++; //end this section addition - VR //enabled 3/24/99 - Owen Evans m[opt].type = NM_TYPE_MENU; m[opt].text = "Change Screen Resolution"; opt++; //end enabled stuff - OE commands=opt; //added on 2/2/99 by Victor Rachels for bans #ifdef NETWORK m[opt].type = NM_TYPE_MENU; m[opt].text = "Save bans now"; opt++; #endif //end this section addition - VR m[opt].type = NM_TYPE_TEXT; m[opt].text = "Maximum Framerate (1-80):"; opt++; inputs=opt; m[opt].type = NM_TYPE_INPUT; m[opt].text = smaxfps; m[opt].text_len=3; opt++; m[opt].type = NM_TYPE_TEXT; m[opt].text = "Mission Directory"; opt++; m[opt].type = NM_TYPE_INPUT; m[opt].text = thogdir; m[opt].text_len=64; opt++; m[opt].type = NM_TYPE_TEXT; m[opt].text = "Hud Messages lines (1-80):"; opt++; m[opt].type = NM_TYPE_INPUT; m[opt].text = shudmaxnumdisp; m[opt].text_len=3; opt++; m[opt].type = NM_TYPE_SLIDER; m[opt].text = "Message colorization level"; m[opt].value=gr_message_color_level;m[opt].min_value=0;m[opt].max_value=3; opt++; checks=opt; #ifdef __MSDOS__ m[opt].type = NM_TYPE_CHECK; m[opt].text = "Joy is sidewinder"; m[opt].value=Joy_is_Sidewinder; opt++; #endif #ifdef SUPPORTS_NICEFPS m[opt].type = NM_TYPE_CHECK; m[opt].text = "Nice FPS (free cpu cycles)"; m[opt].value = use_nice_fps; opt++; #endif for(;;) { i=newmenu_do1( NULL, "D1X options", opt, m, &d1x_options_menu_poll, i); if(i>-1) { if(i<commands) { switch(i) { case 0: reorder_primary(); break; case 1: reorder_secondary(); break; //added on 2/4/99 by Victor Rachels for new key menu case 2: kconfig(3,"D1X Keys"); break; //end this section addition - VR //enabled 3/24/99 - Owen Evans case 3: change_res(); break; //end enabled stuff - OE } } //added on 2/4/99 by Victor Rachels for bans #ifdef NETWORK if(i==commands+0) { nm_messagebox(NULL,1,TXT_OK, "%i Bans saved",writebans()); } #endif //end this section addition - VR if(i==inputs+0) { maxfps = atoi(smaxfps); if(maxfps < 1||maxfps>80) { nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for maximum framerate"); maxfps=80; i=(inputs+0); } } else if(i==inputs+2) cfile_use_alternate_hogdir(thogdir); else if(i==inputs+4) { HUD_max_num_disp = atoi(shudmaxnumdisp); if(HUD_max_num_disp < 1||HUD_max_num_disp>HUD_MAX_NUM) { nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for hud lines"); HUD_max_num_disp=4; // i=(inputs+4);//??? } } gr_message_color_level=m[inputs+5].value; sprintf(shudmaxnumdisp,"%d",HUD_max_num_disp); sprintf(smaxfps,"%d",maxfps); // m[inputs+0].text=smaxfps;//redundant.. its not going anywhere sprintf(thogdir,AltHogDir); // m[inputs+2].text=thogdir;//redundant } else break; } write_player_file(); #ifdef __MSDOS__ Joy_is_Sidewinder=m[(checks+0)].value; #endif #ifdef __LINUX__ Joy_is_Sidewinder=0; #endif #ifdef SUPPORTS_NICEFPS use_nice_fps=m[(checks+0)].value; #else use_nice_fps=0; #endif }
//switch a cockpit window to the next function int select_next_window_function(int w) { Assert(w==0 || w==1); switch (PlayerCfg.Cockpit3DView[w]) { case CV_NONE: PlayerCfg.Cockpit3DView[w] = CV_REAR; break; case CV_REAR: if (find_escort()) { PlayerCfg.Cockpit3DView[w] = CV_ESCORT; break; } //if no ecort, fall through case CV_ESCORT: Coop_view_player[w] = -1; //force first player #ifdef NETWORK //fall through case CV_COOP: Marker_viewer_num[w] = -1; if ((Game_mode & GM_MULTI_COOP) || (Game_mode & GM_TEAM)) { PlayerCfg.Cockpit3DView[w] = CV_COOP; while (1) { Coop_view_player[w]++; if (Coop_view_player[w] == (MAX_PLAYERS-1)) { PlayerCfg.Cockpit3DView[w] = CV_MARKER; goto case_marker; } if (Players[Coop_view_player[w]].connected != CONNECT_PLAYING) continue; if (Coop_view_player[w]==Player_num) continue; if (Game_mode & GM_MULTI_COOP) break; else if (get_team(Coop_view_player[w]) == get_team(Player_num)) break; } break; } //if not multi, fall through case CV_MARKER: case_marker:; if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) && Netgame.Allow_marker_view) { //anarchy only PlayerCfg.Cockpit3DView[w] = CV_MARKER; if (Marker_viewer_num[w] == -1) Marker_viewer_num[w] = Player_num * 2; else if (Marker_viewer_num[w] == Player_num * 2) Marker_viewer_num[w]++; else PlayerCfg.Cockpit3DView[w] = CV_NONE; } else #endif PlayerCfg.Cockpit3DView[w] = CV_NONE; break; } write_player_file(); return 1; //screen_changed }
int HandleGameKey(int key) { switch (key) { case KEY_1 + KEY_SHIFTED: case KEY_2 + KEY_SHIFTED: case KEY_3 + KEY_SHIFTED: case KEY_4 + KEY_SHIFTED: case KEY_5 + KEY_SHIFTED: case KEY_6 + KEY_SHIFTED: case KEY_7 + KEY_SHIFTED: case KEY_8 + KEY_SHIFTED: case KEY_9 + KEY_SHIFTED: case KEY_0 + KEY_SHIFTED: if (PlayerCfg.EscortHotKeys) { if (!(Game_mode & GM_MULTI)) set_escort_special_goal(key); else HUD_init_message_literal(HM_DEFAULT, "No Guide-Bot in Multiplayer!"); game_flush_inputs(); return 1; } else return 0; case KEY_ALTED+KEY_F7: KEY_MAC(case KEY_COMMAND+KEY_ALTED+KEY_7:) PlayerCfg.HudMode=(PlayerCfg.HudMode+1)%GAUGE_HUD_NUMMODES; write_player_file(); switch (PlayerCfg.HudMode) { case 0: HUD_init_message_literal(HM_DEFAULT, "Standard HUD"); break; case 1: HUD_init_message_literal(HM_DEFAULT, "Alternative HUD #1"); break; case 2: HUD_init_message_literal(HM_DEFAULT, "Alternative HUD #2"); break; case 3: HUD_init_message_literal(HM_DEFAULT, "No HUD"); break; } return 1; #ifdef NETWORK KEY_MAC(case KEY_COMMAND+KEY_6:) case KEY_F6: if (Netgame.RefusePlayers && WaitForRefuseAnswer && !(Game_mode & GM_TEAM)) { RefuseThisPlayer=1; HUD_init_message_literal(HM_MULTI, "Player accepted!"); } else { Show_network_stats = ! Show_network_stats; } return 1; case KEY_ALTED + KEY_1: if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM)) { RefuseThisPlayer=1; HUD_init_message_literal(HM_MULTI, "Player accepted!"); RefuseTeam=1; game_flush_inputs(); } return 1; case KEY_ALTED + KEY_2: if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM)) { RefuseThisPlayer=1; HUD_init_message_literal(HM_MULTI, "Player accepted!"); RefuseTeam=2; game_flush_inputs(); } return 1; #endif default: break; } //switch (key) if (!Player_is_dead) switch (key) { #if 0 // weapon selection handled in kconfig_read_controls, d1x-style // MWA changed the weapon select cases to have each case call // do_weapon_select the macintosh keycodes aren't consecutive from 1 // -- 0 on the keyboard -- boy is that STUPID!!!! // Select primary or secondary weapon. case KEY_1: do_weapon_select(0 , 0); break; case KEY_2: do_weapon_select(1 , 0); break; case KEY_3: do_weapon_select(2 , 0); break; case KEY_4: do_weapon_select(3 , 0); break; case KEY_5: do_weapon_select(4 , 0); break; case KEY_6: do_weapon_select(0 , 1); break; case KEY_7: do_weapon_select(1 , 1); break; case KEY_8: do_weapon_select(2 , 1); break; case KEY_9: do_weapon_select(3 , 1); break; case KEY_0: do_weapon_select(4 , 1); break; #endif KEY_MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_5:) case KEY_F5 + KEY_SHIFTED: DropCurrentWeapon(); break; KEY_MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_6:) case KEY_F6 + KEY_SHIFTED: DropSecondaryWeapon(); break; #ifdef NETWORK case KEY_0 + KEY_ALTED: DropFlag (); game_flush_inputs(); break; #endif KEY_MAC(case KEY_COMMAND+KEY_4:) case KEY_F4: if (!DefiningMarkerMessage) InitMarkerInput(); break; default: return 0; } else return 0;
//read in the player's saved games. returns errno (0 == no error) int read_player_file() { char filename[PATH_MAX]; PHYSFS_file *file; int player_file_size, shareware_file = -1, id = 0; short saved_game_version, player_struct_version; Assert(Player_num>=0 && Player_num<MAX_PLAYERS); memset(filename, '\0', PATH_MAX); snprintf(filename, PATH_MAX, GameArg.SysUsePlayersDir? "Players/%.8s.plr" : "%.8s.plr", Players[Player_num].callsign); if (!PHYSFSX_exists(filename,0)) return ENOENT; file = PHYSFSX_openReadBuffered(filename); if (!file) goto read_player_file_failed; new_player_config(); // Set defaults! // Unfortunatly d1x has been writing both shareware and registered // player files with a saved_game_version of 7 and 8, whereas the // original decent used 4 for shareware games and 7 for registered // games. Because of this the player files didn't get properly read // when reading d1x shareware player files in d1x registered or // vica versa. The problem is that the sizeof of the taunt macros // differ between the share and registered versions, causing the // reading of the player file to go wrong. Thus we now determine the // sizeof the player file to determine what kinda player file we are // dealing with so that we can do the right thing PHYSFS_seek(file, 0); player_file_size = PHYSFS_fileLength(file); PHYSFS_readSLE32(file, &id); saved_game_version = PHYSFSX_readShort(file); player_struct_version = PHYSFSX_readShort(file); PlayerCfg.NHighestLevels = PHYSFSX_readInt(file); PlayerCfg.DefaultDifficulty = PHYSFSX_readInt(file); PlayerCfg.AutoLeveling = PHYSFSX_readInt(file); if (id!=SAVE_FILE_ID) { nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid player file"); PHYSFS_close(file); return -1; } if (saved_game_version<COMPATIBLE_SAVED_GAME_VERSION || player_struct_version<COMPATIBLE_PLAYER_STRUCT_VERSION) { nm_messagebox(TXT_ERROR, 1, TXT_OK, TXT_ERROR_PLR_VERSION); PHYSFS_close(file); return -1; } /* determine if we're dealing with a shareware or registered playerfile */ switch (saved_game_version) { case 4: shareware_file = 1; break; case 5: case 6: shareware_file = 0; break; case 7: /* version 7 doesn't have the saved games array */ if ((player_file_size - (sizeof(hli)*PlayerCfg.NHighestLevels)) == (2212 - sizeof(saved_games))) shareware_file = 1; if ((player_file_size - (sizeof(hli)*PlayerCfg.NHighestLevels)) == (2252 - sizeof(saved_games))) shareware_file = 0; break; case 8: if ((player_file_size - (sizeof(hli)*PlayerCfg.NHighestLevels)) == 2212) shareware_file = 1; if ((player_file_size - (sizeof(hli)*PlayerCfg.NHighestLevels)) == 2252) shareware_file = 0; /* d1x-rebirth v0.31 to v0.42 broke things by adding stuff to the player struct without thinking (sigh) */ if ((player_file_size - (sizeof(hli)*PlayerCfg.NHighestLevels)) == (2212 + 2*sizeof(int))) { shareware_file = 1; /* skip the cruft added to the player_info struct */ PHYSFS_seek(file, PHYSFS_tell(file)+2*sizeof(int)); } if ((player_file_size - (sizeof(hli)*PlayerCfg.NHighestLevels)) == (2252 + 2*sizeof(int))) { shareware_file = 0; /* skip the cruft added to the player_info struct */ PHYSFS_seek(file, PHYSFS_tell(file)+2*sizeof(int)); } } if (shareware_file == -1) { nm_messagebox(TXT_ERROR, 1, TXT_OK, "Error invalid or unknown\nplayerfile-size"); PHYSFS_close(file); return -1; } if (saved_game_version <= 5) { //deal with old-style highest level info PlayerCfg.HighestLevels[0].Shortname[0] = 0; //no name for mission 0 PlayerCfg.HighestLevels[0].LevelNum = PlayerCfg.NHighestLevels; //was highest level in old struct //This hack allows the player to start on level 8 if he's made it to //level 7 on the shareware. We do this because the shareware didn't //save the information that the player finished level 7, so the most //we know is that he made it to level 7. if (PlayerCfg.NHighestLevels==7) PlayerCfg.HighestLevels[0].LevelNum = 8; } else { //read new highest level info if (PHYSFS_read(file,PlayerCfg.HighestLevels,sizeof(hli),PlayerCfg.NHighestLevels) != PlayerCfg.NHighestLevels) goto read_player_file_failed; } if ( saved_game_version != 7 ) { // Read old & SW saved games. if (PHYSFS_read(file,saved_games,sizeof(saved_games),1) != 1) goto read_player_file_failed; } //read taunt macros { int i; int len = shareware_file? 25:35; #ifdef NETWORK for (i = 0; i < 4; i++) if (PHYSFS_read(file, PlayerCfg.NetworkMessageMacro[i], len, 1) != 1) goto read_player_file_failed; #else i = 0; PHYSFS_seek( file, PHYSFS_tell(file)+4*len ); #endif } //read kconfig data { ubyte dummy_joy_sens; if (PHYSFS_read(file, &PlayerCfg.KeySettings[0], sizeof(PlayerCfg.KeySettings[0]),1)!=1) goto read_player_file_failed; if (PHYSFS_read(file, &PlayerCfg.KeySettings[1], sizeof(PlayerCfg.KeySettings[1]),1)!=1) goto read_player_file_failed; PHYSFS_seek( file, PHYSFS_tell(file)+(sizeof(ubyte)*MAX_CONTROLS*3) ); // Skip obsolete Flightstick/Thrustmaster/Gravis map fields if (PHYSFS_read(file, &PlayerCfg.KeySettings[2], sizeof(PlayerCfg.KeySettings[2]),1)!=1) goto read_player_file_failed; PHYSFS_seek( file, PHYSFS_tell(file)+(sizeof(ubyte)*MAX_CONTROLS) ); // Skip obsolete Cyberman map field if (PHYSFS_read(file, &PlayerCfg.ControlType, sizeof(ubyte), 1 )!=1) goto read_player_file_failed; else if (PHYSFS_read(file, &dummy_joy_sens, sizeof(ubyte), 1 )!=1) goto read_player_file_failed; } if ( saved_game_version != 7 ) { int i, found=0; Assert( N_SAVE_SLOTS == 10 ); for (i=0; i<N_SAVE_SLOTS; i++ ) { if ( saved_games[i].name[0] ) { state_save_old_game(i, saved_games[i].name, &saved_games[i].sg_player, saved_games[i].difficulty_level, saved_games[i].primary_weapon, saved_games[i].secondary_weapon, saved_games[i].next_level_num ); // make sure we do not do this again, which would possibly overwrite // a new newstyle savegame saved_games[i].name[0] = 0; found++; } } if (found) write_player_file(); } if (!PHYSFS_close(file)) goto read_player_file_failed; filename[strlen(filename) - 4] = 0; strcat(filename, ".plx"); read_player_d1x(filename); kc_set_controls(); return EZERO; read_player_file_failed: nm_messagebox(TXT_ERROR, 1, TXT_OK, "%s\n\n%s", "Error reading PLR file", PHYSFS_getLastError()); if (file) PHYSFS_close(file); return -1; }