/* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * * Functions to load & save player games * */ #ifdef RCS #pragma off (unreferenced) static char rcsid[] = "$Id: playsave.c,v 1.1.1.1 2006/03/17 19:42:10 zicodxx Exp $"; #pragma on (unreferenced) #endif #include #include #include #include #include "error.h" #include "gameseq.h" #include "player.h" #include "playsave.h" #include "joy.h" #include "kconfig.h" #include "digi.h" #include "newmenu.h" #include "joydefs.h" #include "palette.h" #include "multi.h" #include "menu.h" #include "config.h" #include "text.h" #include "mono.h" #include "state.h" #include "reorder.h" #include "d_io.h" //added on 9/16/98 by adb to add memory tracking for this module #include "u_mem.h" //end additions - adb //added on 11/12/98 by Victor Rachels to add networkrejoin thing #include "network.h" //end this section addition - VR //added 6/15/99 - Owen Evans #include "strutil.h" //end added #include "strio.h" #include "vers_id.h" #ifndef PATH_MAX #define PATH_MAX 255 #endif #define SAVE_FILE_ID 0x44504c52 /* 'DPLR' */ //this is for version 5 and below typedef struct save_info_v5 { int id; short saved_game_version,player_struct_version; int highest_level; int default_difficulty_level; int default_leveling_on; } __pack__ save_info_v5; //this is for version 6 and above typedef struct save_info { int id; short saved_game_version,player_struct_version; int n_highest_levels; //how many highest levels are saved int default_difficulty_level; int default_leveling_on; } __pack__ save_info; typedef struct hli { char shortname[9]; ubyte level_num; } __pack__ hli; int n_highest_levels; hli highest_levels[MAX_MISSIONS]; #define SAVED_GAME_VERSION 8 //increment this every time saved_game struct changes //version 5 -> 6: added new highest level information //version 6 -> 7: stripped out the old saved_game array. //version 7 -> 8: readded the old saved_game array since this is needed // for shareware saved games //the shareware is level 4 #define COMPATIBLE_SAVED_GAME_VERSION 4 #define COMPATIBLE_PLAYER_STRUCT_VERSION 16 #define ADV_WEAPON_ORDER 1 #define NEW_KEYS 2 #define WEAPON_KEYS 4 #define JOYSTICK 8 #define NEWER_KEYS 16 #define WEAPON_ORDER 32 #define WINDOWSIZE 64 #define RESOLUTION 128 #define MOUSE_SENSITIVITY 256 typedef struct saved_game { char name[GAME_NAME_LEN+1]; //extra char for terminating zero player player; int difficulty_level; //which level game is played at int primary_weapon; //which weapon selected int secondary_weapon; //which weapon selected int cockpit_mode; //which cockpit mode selected int window_w,window_h; //size of player's window int next_level_num; //which level we're going to int auto_leveling_on; //does player have autoleveling on? } __pack__ saved_game; saved_game saved_games[N_SAVE_SLOTS]; int Default_leveling_on=1; static int Player_Game_window_w = 0; static int Player_Game_window_h = 0; static int Player_render_width = 0; static int Player_render_height = 0; void init_game_list() { int i; for (i=0;i0) && (Config_control_type<5)) { joydefs_calibrate(); } Player_default_difficulty = 1; Auto_leveling_on = Default_leveling_on = 1; n_highest_levels = 1; highest_levels[0].shortname[0] = 0; //no name for mission 0 highest_levels[0].level_num = 1; //was highest level in old struct Config_joystick_sensitivity = 8; Config_mouse_sensitivity = 8; memcpy(primary_order, default_primary_order, sizeof(primary_order)); memcpy(secondary_order, default_secondary_order, sizeof(secondary_order)); // Default taunt macros #ifdef NETWORK strcpy(Network_message_macro[0], TXT_DEF_MACRO_1); strcpy(Network_message_macro[1], TXT_DEF_MACRO_2); strcpy(Network_message_macro[2], TXT_DEF_MACRO_3); strcpy(Network_message_macro[3], TXT_DEF_MACRO_4); #endif return 1; } int read_player_d1x(const char *filename) { FILE *f; int rc = 0; char *line,*word; int Stop=0; int i; char plxver[6]; sprintf(plxver,"v0.00"); //added on 10/15/98 by Victor Rachels for effeciency stuff plyr_read_stats(); //end this section addition - Victor Rachels // set defaults for when nothing is specified memcpy(primary_order, default_primary_order, sizeof(primary_order)); memcpy(secondary_order, default_secondary_order, sizeof(secondary_order)); //added/killed on 2/4/99 by Victor Rachels for new keys //-killed- kconfig_settings[0][46]=255; //-killed- kconfig_settings[0][47]=255; //-killed- kconfig_settings[0][48]=255; //-killed- kconfig_settings[0][49]=255; //-killed- kconfig_settings[0][50]=255; //-killed- kconfig_settings[0][51]=255; for(i=0;i='a'){ neg=1;I=p[0]-'a'; }else{ neg=0;I=p[0]-'A'; } i=0;*v=0; p++; while (p[i*2] && p[i*2+1] && p[i*2]!=' '){ c=(p[i*2]-33)+((p[i*2+1]-33)<<4); c^=effcode[i+neg]; *v+=c << (i*8); i++; } if (neg) *v *= -1; // printf("decode_stat: i=%i neg=%i v=%i\n",i,neg,*v); if (!p[i*2])return NULL; return p+(i*2); } void plyr_read_stats_v(int *k, int *d){ char filename[14]; int k1=-1,k2=0,d1=-1,d2=0; FILE *f; *k=0;*d=0;//in case the file doesn't exist. sprintf(filename,"%s.eff",Players[Player_num].callsign); strlwr(filename); f=fopen(filename, "rt"); if(f && isatty(fileno(f))) { fclose(f); sprintf(filename,"$%.7s.pl$",Players[Player_num].callsign); strlwr(filename); f=fopen(filename,"rt"); } if(f) { char *line,*word; if(!feof(f)) { line=fsplitword(f,'\n'); word=splitword(line,':'); if(!strcmp(word,"kills")) *k=atoi(line); free(line); free(word); } if(!feof(f)) { line=fsplitword(f,'\n'); word=splitword(line,':'); if(!strcmp(word,"deaths")) *d=atoi(line); free(line); free(word); } if(!feof(f)) { line=fsplitword(f,'\n'); word=splitword(line,':'); if(!strcmp(word,"key") && strlen(line)>10){ unsigned char *p; if (line[0]=='0' && line[1]=='1'){ if ((p=decode_stat((unsigned char*)line+3,&k1,effcode1))&& (p=decode_stat(p+1,&k2,effcode2))&& (p=decode_stat(p+1,&d1,effcode3))){ decode_stat(p+1,&d2,effcode4); } } } free(line); free(word); } if (k1!=k2 || k1!=*k || d1!=d2 || d1!=*d){ *k=0;*d=0;//printf("cheater!\n"); } } if(f) fclose(f); } //end addition -MM int multi_kills_stat=0; int multi_deaths_stat=0; //edited 11/11/98 by Matthew Mueller - some stuff cut out, some moved into above function //added on 10/15/98 by Victor Rachels for effeciency stuff void plyr_read_stats() { plyr_read_stats_v(&multi_kills_stat,&multi_deaths_stat); } //end this section addition - Victor Rachels //added on 10/15/98 by Victor Rachels to add player stats void plyr_save_stats() { int kills,deaths,neg; char filename[14]; unsigned char buf[16],buf2[16],a; int i; FILE *f; kills=0; deaths=0; //added/edited on 11/12/98 by Victor Rachels to fix kills=multi_kills_stat; deaths=multi_deaths_stat; //end this section addition - VR sprintf(filename,"%s.eff",Players[Player_num].callsign); strlwr(filename); f=fopen(filename, "rt"); if(f && isatty(fileno(f))) { fclose(f); sprintf(filename,"$%.7s.pl$",Players[Player_num].callsign); strlwr(filename); f=fopen(filename,"rt"); } f=fopen(filename, "wt"); if(!f) return; //broken! fprintf(f,"kills:%i\n",kills); fprintf(f,"deaths:%i\n",deaths); fprintf(f,"key:01 "); if (kills<0){ neg=1; kills*=-1; }else neg=0; for (i=0;kills;i++){ a=(kills & 0xFF) ^ effcode1[i+neg]; buf[i*2]=(a&0xF)+33; buf[i*2+1]=(a>>4)+33; a=(kills & 0xFF) ^ effcode2[i+neg]; buf2[i*2]=(a&0xF)+33; buf2[i*2+1]=(a>>4)+33; kills>>=8; } buf[i*2]=0; buf2[i*2]=0; if (neg)i+='a'; else i+='A'; fprintf(f,"%c%s %c%s ",i,buf,i,buf2); if (deaths<0){ neg=1; deaths*=-1; }else neg=0; for (i=0;deaths;i++){ a=(deaths & 0xFF) ^ effcode3[i+neg]; buf[i*2]=(a&0xF)+33; buf[i*2+1]=(a>>4)+33; a=(deaths & 0xFF) ^ effcode4[i+neg]; buf2[i*2]=(a&0xF)+33; buf2[i*2+1]=(a>>4)+33; deaths>>=8; } buf[i*2]=0; buf2[i*2]=0; if (neg)i+='a'; else i+='A'; fprintf(f,"%c%s %c%s\n",i,buf,i,buf2); fclose(f); } //end this section addition - Victor Rachels //end edit -MM // this mess tries to preserve unknown settings in the file... int write_player_d1x(const char *filename) { FILE *fin, *fout; int rc=0; int Stop=0; char *line; char tempfile[PATH_MAX]; strcpy(tempfile,filename); tempfile[strlen(tempfile)-4]=0; strcat(tempfile,".pl$"); fout=fopen(tempfile,"wt"); if (fout && isatty(fileno(fout))) { //if the callsign is the name of a tty device, prepend a char fclose(fout); sprintf(tempfile,"$%.7s.pl$",Players[Player_num].callsign); strlwr(tempfile); fout = fopen(tempfile,"wt"); } if(fout) { fin=fopen(filename,"rt"); if(!fin) { fprintf(fout,"[D1X Options]\n"); fprintf(fout,"[new keys]\n"); //added/changed on 2/5/99 by Victor Rachels for d1x new keys fprintf(fout,"cycle primary=0x%x,0xff,0x%x\n",kconfig_d1x_settings[20],kconfig_d1x_settings[21]); fprintf(fout,"cycle secondary=0x%x,0xff,0x%x\n",kconfig_d1x_settings[22],kconfig_d1x_settings[23]); fprintf(fout,"autoselect toggle=0x%x,0xff,0x%x\n",kconfig_d1x_settings[24],kconfig_d1x_settings[25]); // fprintf(fout,"cycle primary=0x%x,0x%x,0x%x\n",kconfig_settings[0][46],kconfig_settings[0][47],kconfig_settings[Config_control_type][27]); // fprintf(fout,"cycle secondary=0x%x,0x%x,0x%x\n",kconfig_settings[0][48],kconfig_settings[0][49],kconfig_settings[Config_control_type][28]); // fprintf(fout,"autoselect toggle=0x%x,0x%x,0x%x\n",kconfig_settings[0][50],kconfig_settings[0][51],kconfig_settings[Config_control_type][29]); //end this section change - VR fprintf(fout,"[end]\n"); fprintf(fout,"[joystick]\n"); fprintf(fout,"deadzone=%i\n",joy_deadzone); fprintf(fout,"[end]\n"); fprintf(fout,"[weapon order]\n"); fprintf(fout,"primary=1,2,3,4,5\n"); fprintf(fout,"secondary=%d,%d,%d,%d,%d\n",secondary_order[0], secondary_order[1], secondary_order[2],secondary_order[3], secondary_order[4]); fprintf(fout,"[end]\n"); fprintf(fout,"[advanced ordering]\n"); fprintf(fout,"primary=%d,%d,%d,%d,%d\n",primary_order[0], primary_order[1], primary_order[2],primary_order[3], primary_order[4]); fprintf(fout,"primary+=%d,%d,%d,%d,%d,%d,%d,%d\n",primary_order[5],primary_order[6],primary_order[7],primary_order[8],primary_order[9],primary_order[10],primary_order[11],primary_order[12]); fprintf(fout,"secondary=%d,%d,%d,%d,%d\n",secondary_order[0], secondary_order[1], secondary_order[2],secondary_order[3], secondary_order[4]); fprintf(fout,"[end]\n"); fprintf(fout,"[newer keys]\n"); //added/changed on 2/5/99 by Victor Rachels for d1x new keys fprintf(fout,"primary autoselect toggle=0x%x,0xff,0x%x\n",kconfig_d1x_settings[24],kconfig_d1x_settings[25]); fprintf(fout,"secondary autoselect toggle=0x%x,0xff,0x%x\n",kconfig_d1x_settings[26],kconfig_d1x_settings[27]); // fprintf(fout,"primary autoselect toggle=0x%x,0x%x,0x%x\n",kconfig_settings[0][50],kconfig_settings[0][51],kconfig_settings[Config_control_type][29]); // fprintf(fout,"secondary autoselect toggle=0x%x,0x%x,0x%x\n",kconfig_settings[0][52],kconfig_settings[0][53],kconfig_settings[Config_control_type][30]); //end this section change - VR fprintf(fout,"[end]\n"); //added on 2/5/99 by Victor Rachels for d1x new keys fprintf(fout,"[weapon keys]\n"); fprintf(fout,"1=0x%x,0x%x\n",kconfig_d1x_settings[0],kconfig_d1x_settings[1]); fprintf(fout,"2=0x%x,0x%x\n",kconfig_d1x_settings[2],kconfig_d1x_settings[3]); fprintf(fout,"3=0x%x,0x%x\n",kconfig_d1x_settings[4],kconfig_d1x_settings[5]); fprintf(fout,"4=0x%x,0x%x\n",kconfig_d1x_settings[6],kconfig_d1x_settings[7]); fprintf(fout,"5=0x%x,0x%x\n",kconfig_d1x_settings[8],kconfig_d1x_settings[9]); fprintf(fout,"6=0x%x,0x%x\n",kconfig_d1x_settings[10],kconfig_d1x_settings[11]); fprintf(fout,"7=0x%x,0x%x\n",kconfig_d1x_settings[12],kconfig_d1x_settings[13]); fprintf(fout,"8=0x%x,0x%x\n",kconfig_d1x_settings[14],kconfig_d1x_settings[15]); fprintf(fout,"9=0x%x,0x%x\n",kconfig_d1x_settings[16],kconfig_d1x_settings[17]); fprintf(fout,"0=0x%x,0x%x\n",kconfig_d1x_settings[18],kconfig_d1x_settings[19]); fprintf(fout,"[end]\n"); //end this section change - VR fprintf(fout,"[windowsize]\n"); fprintf(fout,"width=%d\n", Game_window_w); fprintf(fout,"height=%d\n", Game_window_h); fprintf(fout,"[end]\n"); fprintf(fout,"[resolution]\n"); fprintf(fout,"width=%d\n", VR_render_width); fprintf(fout,"height=%d\n", VR_render_height); fprintf(fout,"[end]\n"); fprintf(fout,"[mouse]\n"); fprintf(fout,"sensitivity=%d\n",Config_mouse_sensitivity); fprintf(fout,"[end]\n"); fprintf(fout,"[plx version]\n"); fprintf(fout,"plx version=%s\n",D1X_VERSION); fprintf(fout,"[end]\n"); fprintf(fout,"[end]\n"); } else { int printed=0; while(!Stop && !feof(fin)) { line=fsplitword(fin,'\n'); strupr(line); if (strstr(line,"PLX VERSION")) // we don't want to keep this { while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); } else if (strstr(line,"WEAPON ORDER")) { fprintf(fout,"[weapon order]\n"); fprintf(fout,"primary=1,2,3,4,5\n"); fprintf(fout,"secondary=%d,%d,%d,%d,%d\n",secondary_order[0], secondary_order[1], secondary_order[2],secondary_order[3], secondary_order[4]); fprintf(fout,"[end]\n"); while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); printed |= WEAPON_ORDER; } //added on 2/5/99 by Victor Rachels for d1x new keys else if (strstr(line,"WEAPON KEYS")) { fprintf(fout,"[weapon keys]\n"); fprintf(fout,"1=0x%x,0x%x\n",kconfig_d1x_settings[0],kconfig_d1x_settings[1]); fprintf(fout,"2=0x%x,0x%x\n",kconfig_d1x_settings[2],kconfig_d1x_settings[3]); fprintf(fout,"3=0x%x,0x%x\n",kconfig_d1x_settings[4],kconfig_d1x_settings[5]); fprintf(fout,"4=0x%x,0x%x\n",kconfig_d1x_settings[6],kconfig_d1x_settings[7]); fprintf(fout,"5=0x%x,0x%x\n",kconfig_d1x_settings[8],kconfig_d1x_settings[9]); fprintf(fout,"6=0x%x,0x%x\n",kconfig_d1x_settings[10],kconfig_d1x_settings[11]); fprintf(fout,"7=0x%x,0x%x\n",kconfig_d1x_settings[12],kconfig_d1x_settings[13]); fprintf(fout,"8=0x%x,0x%x\n",kconfig_d1x_settings[14],kconfig_d1x_settings[15]); fprintf(fout,"9=0x%x,0x%x\n",kconfig_d1x_settings[16],kconfig_d1x_settings[17]); fprintf(fout,"0=0x%x,0x%x\n",kconfig_d1x_settings[18],kconfig_d1x_settings[19]); fprintf(fout,"[end]\n"); while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); printed |= WEAPON_KEYS; } //end this section addition - VR else if (strstr(line,"ADVANCED ORDERING")) { fprintf(fout,"[advanced ordering]\n"); fprintf(fout,"primary=%d,%d,%d,%d,%d\n",primary_order[0], primary_order[1], primary_order[2],primary_order[3], primary_order[4]); fprintf(fout,"primary+=%d,%d,%d,%d,%d,%d,%d,%d\n",primary_order[5],primary_order[6],primary_order[7],primary_order[8],primary_order[9],primary_order[10],primary_order[11],primary_order[12]); fprintf(fout,"secondary=%d,%d,%d,%d,%d\n",secondary_order[0], secondary_order[1], secondary_order[2],secondary_order[3], secondary_order[4]); fprintf(fout,"[end]\n"); while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); printed |= ADV_WEAPON_ORDER; } else if (strstr(line,"CYCLE KEYS")||strstr(line,"NEW KEYS")) { fprintf(fout,"[new keys]\n"); //added/changed on 2/5/99 by Victor Rachels for d1x new keys fprintf(fout,"cycle primary=0x%x,0xff,0x%x\n",kconfig_d1x_settings[20],kconfig_d1x_settings[21]); fprintf(fout,"cycle secondary=0x%x,0xff,0x%x\n",kconfig_d1x_settings[22],kconfig_d1x_settings[23]); fprintf(fout,"autoselect toggle=0x%x,0xff,0x%x\n",kconfig_d1x_settings[24],kconfig_d1x_settings[25]); // fprintf(fout,"cycle primary=0x%x,0x%x,0x%0x\n",kconfig_settings[0][46],kconfig_settings[0][47],kconfig_settings[Config_control_type][27]); // fprintf(fout,"cycle secondary=0x%x,0x%x,0x%x\n",kconfig_settings[0][48],kconfig_settings[0][49],kconfig_settings[Config_control_type][28]); // fprintf(fout,"autoselect toggle=0x%x,0x%x,0x%x\n",kconfig_settings[0][50],kconfig_settings[0][51],kconfig_settings[Config_control_type][29]); //end this section addition - VR fprintf(fout,"[end]\n"); while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); printed |= NEW_KEYS; } else if (strstr(line,"NEWER KEYS")) { fprintf(fout,"[newer keys]\n"); //added/changed on 2/5/99 by Victor Rachels for d1x new keys fprintf(fout,"primary autoselect toggle=0x%x,0xff,0x%x\n",kconfig_d1x_settings[24],kconfig_d1x_settings[25]); fprintf(fout,"secondary autoselect toggle=0x%x,0xff,0x%x\n",kconfig_d1x_settings[26],kconfig_d1x_settings[27]); // fprintf(fout,"primary autoselect toggle=0x%x,0x%x,0x%x\n",kconfig_settings[0][50],kconfig_settings[0][51],kconfig_settings[Config_control_type][29]); // fprintf(fout,"secondary autoselect toggle=0x%x,0x%x,0x%x\n",kconfig_settings[0][52],kconfig_settings[0][53],kconfig_settings[Config_control_type][30]); //end this section addition - VR fprintf(fout,"[end]\n"); while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); printed |= NEWER_KEYS; } else if (strstr(line,"JOYSTICK")) { fprintf(fout,"[joystick]\n"); fprintf(fout,"deadzone=%i\n",joy_deadzone); fprintf(fout,"[end]\n"); while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); printed |= JOYSTICK; } else if (strstr(line,"WINDOWSIZE")) { fprintf(fout,"[windowsize]\n"); fprintf(fout,"width=%d\n", Game_window_w); fprintf(fout,"height=%d\n", Game_window_h); fprintf(fout,"[end]\n"); while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); printed |= WINDOWSIZE; } else if (strstr(line,"RESOLUTION")) { fprintf(fout,"[resolution]\n"); fprintf(fout,"width=%d\n", VR_render_width); fprintf(fout,"height=%d\n", VR_render_height); fprintf(fout,"[end]\n"); while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); printed |= RESOLUTION; } else if (strstr(line,"MOUSE")) { fprintf(fout,"[mouse]\n"); fprintf(fout,"sensitivity=%d\n",Config_mouse_sensitivity); fprintf(fout,"[end]\n"); while(!strstr(line,"END")&&!feof(fin)) { free(line); line=fsplitword(fin,'\n'); strupr(line); } free(line); printed |= MOUSE_SENSITIVITY; } else if (strstr(line,"END")) { Stop=1; free(line); } else { if(line[0]=='['&&!strstr(line,"D1X OPTIONS")) while(!strstr(line,"END") && !feof(fin)) { fprintf(fout,"%s\n",line); free(line); line=fsplitword(fin,'\n'); strupr(line); } fprintf(fout,"%s\n",line); free(line); } if(!Stop&&feof(fin)) Stop=1; } if(!(printed&NEW_KEYS)) { fprintf(fout,"[new keys]\n"); //added/changed on 2/5/99 by Victor Rachels for d1x new keys fprintf(fout,"cycle primary=0x%x,0xff,0x%x\n",kconfig_d1x_settings[20],kconfig_d1x_settings[21]); fprintf(fout,"cycle secondary=0x%x,0xff,0x%x\n",kconfig_d1x_settings[22],kconfig_d1x_settings[23]); fprintf(fout,"autoselect toggle=0x%x,0xff,0x%x\n",kconfig_d1x_settings[24],kconfig_d1x_settings[25]); // fprintf(fout,"cycle primary=0x%x,0x%x,0x%x\n",kconfig_settings[0][46],kconfig_settings[0][47],kconfig_settings[Config_control_type][27]); // fprintf(fout,"cycle secondary=0x%x,0x%x,0x%x\n",kconfig_settings[0][48],kconfig_settings[0][49],kconfig_settings[Config_control_type][28]); // fprintf(fout,"autoselect toggle=0x%x,0x%x,0x%x\n",kconfig_settings[0][50],kconfig_settings[0][51],kconfig_settings[Config_control_type][29]); //end this section addition - VR fprintf(fout,"[end]\n"); } if(!(printed&JOYSTICK)) { fprintf(fout,"[joystick]\n"); fprintf(fout,"deadzone=%i\n",joy_deadzone); fprintf(fout,"[end]\n"); } if(!(printed&WEAPON_ORDER)) { fprintf(fout,"[weapon order]\n"); fprintf(fout,"secondary=%d,%d,%d,%d,%d\n",secondary_order[0], secondary_order[1], secondary_order[2],secondary_order[3], secondary_order[4]); fprintf(fout,"[end]\n"); } if(!(printed&ADV_WEAPON_ORDER)) { fprintf(fout,"[advanced ordering]\n"); fprintf(fout,"primary=%d,%d,%d,%d,%d\n",primary_order[0], primary_order[1], primary_order[2],primary_order[3],primary_order[4]); fprintf(fout,"primary+=%d,%d,%d,%d,%d,%d,%d,%d\n",primary_order[5],primary_order[6],primary_order[7],primary_order[8],primary_order[9],primary_order[10],primary_order[11],primary_order[12]); fprintf(fout,"secondary=%d,%d,%d,%d,%d\n",secondary_order[0], secondary_order[1], secondary_order[2],secondary_order[3], secondary_order[4]); fprintf(fout,"[end]\n"); } if(!(printed&NEWER_KEYS)) { fprintf(fout,"[newer keys]\n"); //added/changed on 2/5/99 by Victor Rachels for d1x new keys fprintf(fout,"primary autoselect toggle=0x%x,0xff,0x%x\n",kconfig_d1x_settings[24],kconfig_d1x_settings[25]); fprintf(fout,"secondary autoselect toggle=0x%x,0xff,0x%x\n",kconfig_d1x_settings[26],kconfig_d1x_settings[27]); // fprintf(fout,"primary autoselect toggle=0x%x,0x%x,0x%x\n",kconfig_settings[0][50],kconfig_settings[0][51],kconfig_settings[Config_control_type][29]); // fprintf(fout,"secondary autoselect toggle=0x%x,0x%x,0x%x\n",kconfig_settings[0][52],kconfig_settings[0][53],kconfig_settings[Config_control_type][30]); //end this section addition - VR fprintf(fout,"[end]\n"); } //added on 2/5/99 by Victor Rachels for d1x new keys if(!(printed&WEAPON_KEYS)) { fprintf(fout,"[weapon keys]\n"); fprintf(fout,"1=0x%x,0x%x\n",kconfig_d1x_settings[0],kconfig_d1x_settings[1]); fprintf(fout,"2=0x%x,0x%x\n",kconfig_d1x_settings[2],kconfig_d1x_settings[3]); fprintf(fout,"3=0x%x,0x%x\n",kconfig_d1x_settings[4],kconfig_d1x_settings[5]); fprintf(fout,"4=0x%x,0x%x\n",kconfig_d1x_settings[6],kconfig_d1x_settings[7]); fprintf(fout,"5=0x%x,0x%x\n",kconfig_d1x_settings[8],kconfig_d1x_settings[9]); fprintf(fout,"6=0x%x,0x%x\n",kconfig_d1x_settings[10],kconfig_d1x_settings[11]); fprintf(fout,"7=0x%x,0x%x\n",kconfig_d1x_settings[12],kconfig_d1x_settings[13]); fprintf(fout,"8=0x%x,0x%x\n",kconfig_d1x_settings[14],kconfig_d1x_settings[15]); fprintf(fout,"9=0x%x,0x%x\n",kconfig_d1x_settings[16],kconfig_d1x_settings[17]); fprintf(fout,"0=0x%x,0x%x\n",kconfig_d1x_settings[18],kconfig_d1x_settings[19]); fprintf(fout,"[end]\n"); } //end this section addition - VR if(!(printed&WINDOWSIZE)) { fprintf(fout,"[windowsize]\n"); fprintf(fout,"width=%d\n", Game_window_w); fprintf(fout,"height=%d\n", Game_window_h); fprintf(fout,"[end]\n"); } if(!(printed&RESOLUTION)) { fprintf(fout,"[resolution]\n"); fprintf(fout,"width=%d\n", VR_render_width); fprintf(fout,"height=%d\n", VR_render_height); fprintf(fout,"[end]\n"); } if(!(printed&MOUSE_SENSITIVITY)) { fprintf(fout,"[mouse]\n"); fprintf(fout,"sensitivity=%d\n",Config_mouse_sensitivity); fprintf(fout,"[end]\n"); } fprintf(fout,"[plx version]\n"); fprintf(fout,"plx version=%s\n",D1X_VERSION); fprintf(fout,"[end]\n"); fprintf(fout,"[end]\n"); fclose(fin); } if (ferror(fout)) rc = errno; fclose(fout); if(rc==0) { unlink(filename); rc = rename(tempfile,filename); } return rc; } else return errno; } extern int screen_width; extern int screen_height; //read in the player's saved games. returns errno (0 == no error) int read_player_file() { char filename[13]; FILE *file; save_info info; int errno_ret = EZERO; int player_file_size; int shareware_file = -1; Assert(Player_num>=0 && Player_num0) highest_primary++; for(i=0; i0) highest_secondary++; } if (errno_ret==EZERO) { kc_set_controls(); } if (Player_render_width && Player_render_height && Game_screen_mode != SM(Player_render_width, Player_render_height)) { Game_screen_mode = SM(Player_render_width,Player_render_height); game_init_render_buffers( SM(Player_render_width,Player_render_height), Player_render_width, Player_render_height, VR_NONE); } Game_window_w = Player_Game_window_w; Game_window_h = Player_Game_window_h; return errno_ret; } //finds entry for this level in table. if not found, returns ptr to //empty entry. If no empty entries, takes over last one int find_hli_entry() { #ifdef SHAREWARE return 0; #else int i; for (i=0;i highest_levels[i].level_num) highest_levels[i].level_num = levelnum; write_player_file(); } //gets the player's highest level from the file for this mission int get_highest_level(void) { int i; int highest_saturn_level = 0; read_player_file(); #ifndef SHAREWARE #ifndef DEST_SAT if (strlen(Mission_list[Current_mission_num].filename)==0 ) { for (i=0;i i ) i = highest_saturn_level; return i; } //write out player's saved games. returns errno (0 == no error) int write_player_file() { char filename[13]; FILE *file; save_info info; int errno_ret; errno_ret = WriteConfigFile(); info.id = SAVE_FILE_ID; info.saved_game_version = SAVED_GAME_VERSION; info.player_struct_version = PLAYER_STRUCT_VERSION; info.default_difficulty_level = Player_default_difficulty; info.default_leveling_on = Auto_leveling_on; info.n_highest_levels = n_highest_levels; sprintf(filename,"%s.plx",Players[Player_num].callsign); strlwr(filename); write_player_d1x(filename); sprintf(filename,"%s.plr",Players[Player_num].callsign); strlwr(filename); file = fopen(filename,"wb"); //check filename if (file && isatty(fileno(file))) { //if the callsign is the name of a tty device, prepend a char fclose(file); sprintf(filename,"$%.7s.plr",Players[Player_num].callsign); strlwr(filename); file = fopen(filename,"wb"); } if (!file) return errno; errno_ret = EZERO; if (fwrite(&info,sizeof(info),1,file) != 1) { errno_ret = errno; fclose(file); return errno_ret; } //write higest level info if ((fwrite(highest_levels, sizeof(hli), n_highest_levels, file) != n_highest_levels)) { errno_ret = errno; fclose(file); return errno_ret; } if (fwrite(saved_games,sizeof(saved_games),1,file) != 1) { errno_ret = errno; fclose(file); return errno_ret; } #ifdef NETWORK if ((fwrite(Network_message_macro, MAX_MESSAGE_LEN, 4, file) != 4)) { errno_ret = errno; fclose(file); return errno_ret; } #else fseek( file, MAX_MESSAGE_LEN * 4, SEEK_CUR ); #endif //write kconfig info { // if (fwrite( kconfig_settings, MAX_CONTROLS*CONTROL_MAX_TYPES, 1, file )!=1) // errno_ret=errno; int i,j; for(i=0;i