00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "records.h"
00019 #include "externs.h"
00020 #include "logging.h"
00021
00022 LOG_DEFAULT_CATEGORY(LOG_ROOT_CAT);
00023
00024 #define MLL(a,b) (Data->P[a].History[b].MissionCode>=53 && Data->P[a].History[b].MissionCode<=56)
00025
00026 void RecChange(int i,int j,int k,int temp,int max,char Rec_Change,char hold);
00027 int ISDOCK(int a);
00028
00029 extern struct mStr Mis;
00030 extern char AI[2];
00031 char NREC[56][3];
00032
00033 int ISDOCK(int a)
00034 {
00035 if ((a>=14 && a<=24) || (a>=27 && a<=41) || a==44 ||
00036 a==47 || (a>=48 && a<=52) || a==53 || a==55 || a==56)
00037 return 1; else return 0;
00038 }
00039
00040 void MakeRecords(void)
00041 {
00042 FILE *file;
00043 int i,j;
00044
00045 if ((file = sOpen("RECORDS.DAT","rb",1))==NULL)
00046 {
00047 file=sOpen("RECORDS.DAT","wb",1);
00048 if (file == NULL) {
00049
00050 CRITICAL1("can't create required file RECORDS.DAT");
00051 exit(EXIT_FAILURE);
00052 }
00053 for (i=0;i<56;i++)
00054 {
00055 for(j=0;j<3;j++)
00056 {
00057 rec[i][j].country=-1;
00058 rec[i][j].tag=rec[i][j].month=rec[i][j].yr=rec[i][j].program=rec[i][j].type=0;
00059 rec[i][j].place=0;
00060 }
00061 }
00062 fwrite(rec,sizeof rec,1,file);
00063 }
00064 fclose(file);
00065 }
00066
00067 void Records(char plr)
00068 {
00069 FILE *file;
00070 char pos=0,pos2=0;
00071 file = sOpen("RECORDS.DAT","rb",1);
00072 fread(rec,sizeof rec,1,file);
00073 fclose(file);
00074
00075 FadeOut(2,pal,5,0,0);
00076 PortPal(plr);
00077 gxClearDisplay(0,0);
00078 ShBox(0,0,319,22);
00079 ShBox(0,24,319,199);
00080 InBox(4,27,315,196);
00081 RectFill(5,28,314,195,0);
00082
00083 ShBox(23,29,228,52);
00084 ShBox(23,54,228,77);
00085 ShBox(23,79,228,102);
00086
00087 IOBox(243,3,316,19);
00088 ShBox(6,104,313,194);InBox(10,127,309,191);RectFill(11,128,308,190,0);
00089 ShBox(297,129,307,158);ShBox(297,160,307,189);
00090 grSetColor(1);PrintAt(258,13,"CONTINUE");
00091 DispBig(42,5,"MISSION RECORDS",0,-1);
00092 UPArrow(299,131);DNArrow(299,162);
00093 ShBox(6,29,21,102);
00094 ShBox(230,29,313,102);
00095 grSetColor(1);DispNum(12,42,1);DispNum(12,66,2);DispNum(12,90,3);
00096 RectFill(70,109,266,121,4);RectFill(72,111,264,119,0);
00097 IOBox(234,84,309,99);grSetColor(1);PrintAt(238,94,"CLEAR RECORD");
00098 InBox(237,34,306,81);
00099 Drec(&pos,&pos2,0);
00100 FadeIn(2,pal,10,0,0);
00101
00102 WaitForMouseUp();
00103 while(1)
00104 {
00105 GetMouse();
00106
00107 if ((x>=245 && y>=5 && x<=314 && y<=17 && mousebuttons>0) || key==K_ENTER) {
00108 InBox(245,5,314,17);
00109 if (key>0) {delay(300);key=0;};
00110 WaitForMouseUp();
00111 OutBox(245,5,314,17); key=0;
00112 return;
00113 }
00114 pButton(297,129,307,158,Back1rec(&pos,&pos2),key>>8,72);
00115 pButton(297,160,307,189,For1rec(&pos,&pos2),key>>8,80);
00116 pButton(236,86,307,97,ClearRecord(&pos2),key,'C');
00117 Button2(15,129,160,133,Move2rec(&pos,&pos2,0),key,49);
00118 Button2(15,136,160,140,Move2rec(&pos,&pos2,1),key,50);
00119 Button2(15,143,160,147,Move2rec(&pos,&pos2,2),key,51);
00120 Button2(15,150,160,154,Move2rec(&pos,&pos2,3),key,52);
00121 Button2(15,157,160,161,Move2rec(&pos,&pos2,4),key,53);
00122 Button2(15,164,160,168,Move2rec(&pos,&pos2,5),key,54);
00123 Button2(15,171,160,175,Move2rec(&pos,&pos2,6),key,55);
00124 Button2(15,178,160,182,Move2rec(&pos,&pos2,7),key,56);
00125 Button2(15,185,160,189,Move2rec(&pos,&pos2,8),key,57);
00126 key=0;
00127 };
00128 }
00129
00130 void Move2rec(char *pos, char *pos2, char val )
00131 {
00132 *pos2 = *pos + val;
00133 Drec(pos,pos2,1);
00134 }
00135
00136 void ClearRecord(char *pos2)
00137 {
00138 int j;
00139 FILE *file;
00140 j=Help("i125");
00141 if (j==-1) return;
00142 file = sOpen("RECORDS.DAT","rb",1);
00143 fread(rec,sizeof rec,1,file);
00144 fclose(file);
00145
00146 for(j=0;j<3;j++)
00147 {
00148 NREC[*pos2][j]=0x00;
00149 rec[*pos2][j].country=-1;
00150 rec[*pos2][j].tag=rec[*pos2][j].month=rec[*pos2][j].yr=rec[*pos2][j].program=0;
00151 rec[*pos2][j].place=0;
00152 }
00153
00154 ShBox(23,29,228,52);
00155 ShBox(23,54,228,77);
00156 ShBox(23,79,228,102);
00157 RectFill(24,30,227,51,3);
00158 RectFill(24,55,227,76,3);
00159 RectFill(24,80,227,101,3);
00160 grSetColor(1);DispNum(12,42,1);DispNum(12,66,2);DispNum(12,90,3);
00161
00162 file = sOpen("RECORDS.DAT","wb",1);
00163 fwrite(rec,sizeof rec,1,file);
00164 fclose(file);
00165 return;
00166 }
00167
00168 void Back1rec(char *pos,char *pos2)
00169 {
00170 if (*pos2== 0) return;
00171 *pos2-=1;
00172 if(*pos2 < *pos) *pos -=1;
00173 Drec(pos,pos2,1);
00174 return;
00175 }
00176
00177 void For1rec(char *pos,char *pos2)
00178 {
00179 if (*pos2==55) return;
00180 *pos2+=1;
00181 if(*pos > 47) ;
00182 else if (*pos2 > *pos+8) *pos+=1;
00183 Drec(pos,pos2,1);
00184 return;
00185 }
00186
00187
00188 void Drec(char *pos,char *pos2,char mde)
00189 {
00190 char i,j=0,Digit[10];
00191
00192
00193 memset(Digit,0x00,sizeof(Digit));
00194 grSetColor(1);DispNum(12,42,1);DispNum(12,66,2);DispNum(12,90,3);
00195 RectFill(238,35,305,80,0);
00196 if (Pict[*pos2]!=0) DispBaby(238,35,Pict[*pos2],mde);
00197 RectFill(12,129,295,190,0);
00198
00199 if (NREC[*pos2][0]==0) {ShBox(23,29,228,52);RectFill(24,30,227,51,3);}
00200 else {grSetColor(8);DispNum(12,42,1);InBox(23,29,228,52);RectFill(24,30,227,51,3);}
00201 if (NREC[*pos2][1]==0) {ShBox(23,54,228,77);RectFill(24,55,227,76,3);}
00202 else {grSetColor(8);DispNum(12,66,2);InBox(23,54,228,77);RectFill(24,55,227,76,3);}
00203 if (NREC[*pos2][2]==0) {ShBox(23,79,228,102);RectFill(24,80,227,101,3);}
00204 else {grSetColor(8);DispNum(12,90,3);InBox(23,79,228,102);RectFill(24,80,227,101,3);}
00205
00206 grSetColor(2);
00207 for(i=*pos;i<*pos+9;i++,j++) {
00208 if(i==*pos2) grSetColor(11);
00209 PrintAt(15,133+7*j,Record_Names[i]);
00210 if(i==*pos2) grSetColor(11); else grSetColor(12);
00211 grSetColor(2);
00212 }
00213 RectFill(72,111,264,119,0);grSetColor(1);
00214 PrintAt(83,117,Record_Names[*pos2]);
00215 for (i=0;i<3;i++)
00216 {
00217 if(rec[*pos2][i].country==NOT_SET)
00218 {
00219
00220 return;
00221 }
00222 if (*pos2<52)
00223 {
00224 RectFill(27,33+(i*24),54,49+(i*24),4);
00225 FlagSm(rec[*pos2][i].country,28,34+(i*24));
00226 if (*pos2==50 || *pos2==51)
00227 {
00228 RectFill(196,33+(i*24),223,49+(i*24),4);
00229 FlagSm(rec[*pos2][i].country,197,34+(i*24));
00230 }
00231 }
00232 else
00233 {
00234 RectFill(27,33+(i*24),54,49+(i*24),4);FlagSm(0,28,34+(i*24));
00235 RectFill(196,33+(i*24),223,49+(i*24),4);FlagSm(1,197,34+(i*24));
00236 }
00237 if (*pos2<50)
00238 {
00239 grSetColor(9);PrintAt(61,48+(i*24),"DIR: ");grSetColor(1);PrintAt(0,0,rec[*pos2][i].name);
00240 }
00241 switch(rec[*pos2][i].type)
00242 {
00243 case 1:grSetColor(9);PrintAt(61,38+(i*24),"DATE: ");
00244 grSetColor(1);PrintAt(0,0,Months[rec[*pos2][i].month]);PrintAt(0,0," ");
00245 sprintf(&Digit[0],"%d",rec[*pos2][i].yr+1900);PrintAt(0,0,&Digit[0]);
00246 if (*pos2==29)
00247 {
00248 grSetColor(6);PrintAt(143,38+(i*24),"DURATION: ");grSetColor(1);
00249 switch(rec[*pos2][i].tag)
00250 {
00251 case 1:PrintAt(0,0,"A");break;
00252 case 2:PrintAt(0,0,"B");break;
00253 case 3:PrintAt(0,0,"C");break;
00254 case 4:PrintAt(0,0,"D");break;
00255 case 5:PrintAt(0,0,"E");break;
00256 case 6:PrintAt(0,0,"F");break;
00257 default:break;
00258 }
00259 }
00260 break;
00261 case 2:grSetColor(9);
00262 if (rec[*pos2][i].country==1) PrintAt(61,38+(i*24),"COSMONAUT: ");
00263 else PrintAt(61,38+(i*24),"ASTRONAUT: ");grSetColor(1);PrintAt(0,0,rec[*pos2][i].astro);
00264 switch(*pos2)
00265 {
00266 case 1:case 2:case 3:case 4:case 5:case 6:
00267 grSetColor(6);PrintAt(143,48+(i*24),"DATE: ");
00268 grSetColor(1);PrintAt(0,0,Months[rec[*pos2][i].month]);PrintAt(0,0," ");
00269 sprintf(&Digit[0],"%d",rec[*pos2][i].yr+1900);PrintAt(0,0,&Digit[0]);
00270 break;
00271 case 35:case 36:grSetColor(6);PrintAt(143,48+(i*24),"MISSIONS: ");
00272 grSetColor(1);sprintf(&Digit[0],"%d",rec[*pos2][i].tag);
00273 PrintAt(0,0,&Digit[0]);
00274 break;
00275 case 37:case 38:grSetColor(6);PrintAt(143,48+(i*24),"PRESTIGE: ");
00276 grSetColor(1);sprintf(&Digit[0],"%d",rec[*pos2][i].tag);
00277 PrintAt(0,0,&Digit[0]);
00278 break;
00279 case 39:case 40:grSetColor(6);PrintAt(143,48+(i*24),"DAYS: ");
00280 grSetColor(1);sprintf(&Digit[0],"%d",rec[*pos2][i].tag);
00281 PrintAt(0,0,&Digit[0]);
00282 break;
00283 case 41:grSetColor(6);PrintAt(143,48+(i*24),"SEASONS: ");
00284 grSetColor(1);sprintf(&Digit[0],"%d",rec[*pos2][i].tag);
00285 PrintAt(0,0,&Digit[0]);
00286 break;
00287 default:break;
00288 }
00289 break;
00290 case 3:grSetColor(9);PrintAt(61,38+(i*24),"RECORD: ");grSetColor(1);
00291 if (*pos2==18)
00292 {
00293 grSetColor(1);PrintAt(0,0,&Data->P[rec[*pos2][i].country].Manned[rec[*pos2][i].program].Name[0]);
00294 grSetColor(6);PrintAt(143,48+(i*24),"PRESTIGE: ");
00295 grSetColor(1);sprintf(&Digit[0],"%d",rec[*pos2][i].tag);
00296 PrintAt(0,0,&Digit[0]);
00297 }
00298 else
00299 {
00300 sprintf(&Digit[0],"%d",rec[*pos2][i].tag);PrintAt(101,38+(i*24),&Digit[0]);
00301 switch(*pos2)
00302 {
00303 case 22:case 23:PrintAt(0,0," CASUALTIES");break;
00304 case 24:case 25:PrintAt(0,0," PERCENT");break;
00305 case 31:case 32:PrintAt(0,0," MISSIONS");break;
00306 case 33:case 34:PrintAt(0,0," MISSIONS");break;
00307 case 42:PrintAt(0,0," POINTS");break;
00308 case 43:case 44:PrintAt(0,0," M.B.");break;
00309 case 50:case 51:case 52:case 53:case 54:case 55:PrintAt(0,0," TIMES");break;
00310 default:break;
00311 }
00312 }
00313 break;
00314 default:break;
00315 }
00316 }
00317
00318 return;
00319 }
00320
00321 void WriteRecord(int i,int j,int k,int temp)
00322 {
00323 char t;
00324 t=rec[k][0].place;
00325 NREC[k][t]=1;
00326 ++rec[k][0].place;
00327 switch(rec[k][t].type)
00328 {
00329 case 1:rec[k][t].yr=Data->P[i].History[j].MissionYear;rec[k][t].month=Data->P[i].History[j].Month;
00330 rec[k][t].program=Data->P[i].History[j].MissionCode;
00331 if (k==29 || k==30) rec[k][t].tag=temp;
00332 break;
00333 case 2:if (k>=35 && k<=41)
00334 {
00335 rec[k][t].tag=temp;strcpy(&rec[k][t].astro[0],&Data->P[i].Pool[j].Name[0]);
00336 }
00337 else
00338 {
00339 rec[k][t].yr=Data->P[i].History[j].MissionYear;rec[k][t].month=Data->P[i].History[j].Month;
00340 strcpy(&rec[k][t].astro[0],&Data->P[i].Pool[temp].Name[0]);
00341 }
00342 break;
00343 case 3:rec[k][t].tag=temp;
00344 if (k==18) rec[k][t].program=j;
00345 break;
00346 default:break;
00347 }
00348 strcpy(&rec[k][t].name[0],&Data->P[i].Name[0]);
00349 rec[k][t].country=i;
00350 return;
00351 }
00352
00353 void SwapRec(int Rc,int pl1,int pl2)
00354 {
00355 int temp;char Tmp[20];
00356
00357 temp=NREC[Rc][pl1];NREC[Rc][pl1]=NREC[Rc][pl2];NREC[Rc][pl2]=temp;
00358
00359 temp=rec[Rc][pl1].country;rec[Rc][pl1].country=rec[Rc][pl2].country;rec[Rc][pl2].country=temp;
00360 temp=rec[Rc][pl1].yr;rec[Rc][pl1].yr=rec[Rc][pl2].yr;rec[Rc][pl2].yr=temp;
00361 temp=rec[Rc][pl1].month;rec[Rc][pl1].month=rec[Rc][pl2].month=temp;
00362 temp=rec[Rc][pl1].program;rec[Rc][pl1].program=rec[Rc][pl2].program;rec[Rc][pl2].program=temp;
00363 temp=rec[Rc][pl1].tag;rec[Rc][pl1].tag=rec[Rc][pl2].tag; rec[Rc][pl2].tag=temp;
00364
00365 strcpy(&Tmp[0],&rec[Rc][pl1].astro[0]);
00366 strcpy(&rec[Rc][pl1].astro[0],&rec[Rc][pl2].astro[0]);
00367 strcpy(&rec[Rc][pl2].astro[0],&Tmp[0]);
00368
00369 strcpy(&Tmp[0],&rec[Rc][pl1].name[0]);
00370 strcpy(&rec[Rc][pl1].name[0],&rec[Rc][pl2].name[0]);
00371 strcpy(&rec[Rc][pl2].name[0],&Tmp[0]);
00372 return;
00373 }
00374
00375
00376 char CheckSucess(int i,int j)
00377 {
00378 if (Data->P[i].History[j].Duration!=0)
00379 {
00380 if (Data->P[i].History[j].spResult<500 || Data->P[i].History[j].spResult>=5000) return(1); else return(0);
00381 }
00382 else if (Data->P[i].History[j].spResult==1 && Data->P[i].History[j].Event==0) return(1); else return(0);
00383 }
00384
00385 void SafetyRecords(char plr,int temp)
00386 {
00387 int j,k;
00388 FILE *fin,*bo;
00389 fin = sOpen("RECORDS.DAT","rb",1);
00390 fread(rec,sizeof rec,1,fin);
00391 fclose(fin);
00392
00393 rec[24][0].type=3;rec[24][1].type=3;rec[24][2].type=3;
00394 rec[25][0].type=3;rec[25][1].type=3;rec[25][2].type=3;
00395 k=24;j=0;
00396 while(k!=-1)
00397 {
00398 switch(rec[k][0].place)
00399 {
00400 case 0:WriteRecord(plr,j,k,temp);break;
00401 case 1:if ((k==24 && rec[k][0].tag<=temp) || (k==25 && rec[k][0].tag>temp))
00402 {
00403 WriteRecord(plr,j,k,temp);SwapRec(k,1,0);
00404 }
00405 else WriteRecord(plr,j,k,temp);
00406 break;
00407 case 2:if ((k==24 && rec[k][1].tag<=temp) || (k==25 && rec[k][1].tag>temp))
00408 {
00409 WriteRecord(plr,j,k,temp);SwapRec(k,2,1);
00410 if ((k==24 && rec[k][0].tag<=temp) || (k==25 && rec[k][0].tag>temp)) SwapRec(k,1,0);
00411 }
00412 else WriteRecord(plr,j,k,temp);
00413 break;
00414 case 3:if ((k==24 && rec[k][2].tag<=temp) || (k==25 && rec[k][2].tag>temp))
00415 {
00416 --rec[k][0].place;WriteRecord(plr,j,k,temp);
00417 if ((k==24 && rec[k][1].tag<=temp) || (k==25 && rec[k][1].tag>temp))
00418 {
00419 SwapRec(k,2,1);
00420 if ((k==24 && rec[k][0].tag<=temp) || (k==25 && rec[k][0].tag>temp)) SwapRec(k,1,0);
00421 }
00422 }
00423 break;
00424 default:break;
00425 }
00426 if (k==24) k=25;
00427 else if (k==25) k=-1;
00428 };
00429 bo=sOpen("RECORDS.DAT","wb",1);
00430 fwrite(rec,sizeof rec,1,bo);
00431 fclose(bo);
00432 return;
00433 }
00434
00435 void UpdateRecords(char Ty)
00436 {
00437 int i,j,k,m,loop,temp,max;
00438
00439 struct mStr *Miss;
00440 char Rec_Change,hold,craft;
00441 FILE *file;
00442
00443 hold = 0;
00444
00445 Miss=(struct mStr *)buffer;
00446
00447 for(j=0;j<56;j++)
00448 for(i=0;i<3;i++)
00449 NREC[j][i]=0x00;
00450
00451 file = sOpen("MISSION.DAT","rb",0);
00452 fread(Miss,60*(sizeof (struct mStr)),1,file);
00453 fclose(file);
00454
00455 file = sOpen("RECORDS.DAT","rb",1);
00456 fread(rec,sizeof rec,1,file);
00457 fclose(file);
00458 for(i=0;i<NUM_PLAYERS;i++)
00459 {
00460 if (!AI[i])
00461 for(j=0;j<Data->P[i].PastMis;j++)
00462 {
00463 if (CheckSucess(i,j)==1)
00464 for(k=0;k<56;k++)
00465 {
00466 Rec_Change=-1;temp=0;max=0;
00467
00468 switch(k)
00469 {
00470 case 0:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00471 if (rec[k][0].place==0)
00472 {
00473 if (Data->P[i].History[j].MissionCode==1) Rec_Change=0;
00474 }
00475 else
00476 {
00477 if (Data->P[i].History[j].MissionCode==1) Rec_Change=1;
00478 }
00479 break;
00480 case 1:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00481 if (Data->P[i].History[j].Duration>0)
00482 {
00483 for(m=0;m<4;m++)
00484 if (Data->P[i].History[j].Man[0][m]!=-1)
00485 if (Data->P[i].Pool[Data->P[i].History[j].Man[0][m]].Sex==0)
00486 {
00487 temp=Data->P[i].History[j].Man[0][m];
00488 if (rec[k][0].place==0) Rec_Change=0;
00489 else Rec_Change=2;
00490 RecChange(i,j,k,temp,m,Rec_Change,hold);
00491 }
00492 }
00493 Rec_Change=-1;
00494 break;
00495 case 2:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00496 if (Data->P[i].History[j].Duration>0)
00497 {
00498 for(m=0;m<4;m++)
00499 if (Data->P[i].History[j].Man[0][m]!=-1)
00500 if (Data->P[i].Pool[Data->P[i].History[j].Man[0][m]].Sex==1)
00501 {
00502 temp=Data->P[i].History[j].Man[0][m];
00503 if (rec[k][0].place==0) Rec_Change=0;
00504 else Rec_Change=2;
00505 RecChange(i,j,k,temp,m,Rec_Change,hold);
00506 }
00507 }
00508 Rec_Change=-1;
00509 break;
00510 case 3:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00511 if (Data->P[i].History[j].Duration>0)
00512 {
00513 for(m=0;m<4;m++)
00514 if (Data->P[i].History[j].Man[0][m]!=-1)
00515 {
00516 temp=Data->P[i].History[j].Man[0][m];
00517 if (rec[k][0].place==0) Rec_Change=0;
00518 else Rec_Change=2;
00519 RecChange(i,j,k,temp,m,Rec_Change,hold);
00520 }
00521 }
00522 Rec_Change=-1;
00523 break;
00524 case 4:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00525
00526 switch(Data->P[i].History[j].Hard[0][0])
00527 {
00528 case 0:m=0;break;
00529 case 1:case 2:case 3:m=1;break;
00530 case 4:m=2;break;
00531 default:m=0;break;
00532 }
00533 if (Miss[Data->P[i].History[j].MissionCode].EVA)
00534 {
00535 if (Data->P[i].History[j].Man[0][m]!=-1)
00536 if (Data->P[i].Pool[Data->P[i].History[j].Man[0][m]].Sex==0)
00537 {
00538 temp=Data->P[i].History[j].Man[0][m];
00539 if (rec[k][0].place==0) Rec_Change=0;
00540 else Rec_Change=2;
00541 RecChange(i,j,k,temp,m,Rec_Change,hold);
00542 }
00543 }
00544 Rec_Change=-1;
00545 break;
00546 case 5:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00547
00548 switch(Data->P[i].History[j].Hard[0][0])
00549 {
00550 case 0:m=0;break;
00551 case 1:case 2:case 3:m=1;break;
00552 case 4:m=2;break;
00553 default:m=0;break;
00554 }
00555 if (Miss[Data->P[i].History[j].MissionCode].EVA)
00556 {
00557 if (Data->P[i].History[j].Man[0][m]!=-1)
00558 if (Data->P[i].Pool[Data->P[i].History[j].Man[0][m]].Sex==1)
00559 {
00560 temp=Data->P[i].History[j].Man[0][m];
00561 if (rec[k][0].place==0) Rec_Change=0;
00562 else Rec_Change=2;
00563 RecChange(i,j,k,temp,m,Rec_Change,hold);
00564 }
00565 }
00566 Rec_Change=-1;
00567 break;
00568 case 6:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00569 if (rec[k][0].place==0)
00570 {
00571 if (Data->P[i].History[j].MissionCode==7) Rec_Change=0;
00572 }
00573 else if (Data->P[i].History[j].MissionCode==7) Rec_Change=1;
00574 break;
00575 case 7:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00576 if (rec[k][0].place==0)
00577 {
00578 if (Data->P[i].History[j].MissionCode==11) Rec_Change=0;
00579 }
00580 else if (Data->P[i].History[j].MissionCode==11) Rec_Change=1;
00581 break;
00582 case 8:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00583 if (rec[k][0].place==0)
00584 {
00585 if (Data->P[i].History[j].MissionCode==9) Rec_Change=0;
00586 }
00587 else if (Data->P[i].History[j].MissionCode==9) Rec_Change=1;
00588 break;
00589 case 9:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00590 if (rec[k][0].place==0)
00591 {
00592 if (Data->P[i].History[j].MissionCode==10) Rec_Change=0;
00593 }
00594 else if (Data->P[i].History[j].MissionCode==10) Rec_Change=1;
00595 break;
00596 case 10:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00597 if (rec[k][0].place==0)
00598 {
00599 if (Data->P[i].History[j].MissionCode==12) Rec_Change=0;
00600 }
00601 else if (Data->P[i].History[j].MissionCode==12) Rec_Change=1;
00602 break;
00603 case 11:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00604 if (rec[k][0].place==0)
00605 {
00606 if (Data->P[i].History[j].MissionCode==13) Rec_Change=0;
00607 }
00608 else if (Data->P[i].History[j].MissionCode==13) Rec_Change=1;
00609 break;
00610 case 12:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00611 if (rec[k][0].place==0)
00612 {
00613 if (Data->P[i].History[j].MissionCode==8) Rec_Change=0;
00614 }
00615 else if (Data->P[i].History[j].MissionCode==8) Rec_Change=1;
00616 break;
00617 case 13:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00618 if (rec[k][0].place==0)
00619 {
00620 if (Data->P[i].History[j].Hard[0][0]==0 && Data->P[i].History[j].Man[0][0]!=-1) Rec_Change=0;
00621 }
00622 else if (Data->P[i].History[j].Hard[0][0]==0 && Data->P[i].History[j].Man[0][0]!=-1) Rec_Change=1;
00623 break;
00624 case 14:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00625 if (rec[k][0].place==0)
00626 {
00627 if (Data->P[i].History[j].Hard[0][0]==1 && Data->P[i].History[j].Man[0][0]!=-1) Rec_Change=0;
00628 }
00629 else if (Data->P[i].History[j].Hard[0][0]==1 && Data->P[i].History[j].Man[0][0]!=-1) Rec_Change=1;
00630 break;
00631 case 15:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00632 if (rec[k][0].place==0)
00633 {
00634 if (Data->P[i].History[j].Hard[0][0]==2 && Data->P[i].History[j].Man[0][0]!=-1) WriteRecord(i,j,k,0);
00635 }
00636 else if (Data->P[i].History[j].Hard[0][0]==2 && Data->P[i].History[j].Man[0][0]!=-1) Rec_Change=1;
00637 break;
00638 case 16:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00639 if (rec[k][0].place==0)
00640 {
00641 if (Data->P[i].History[j].Hard[0][0]==3 && Data->P[i].History[j].Man[0][0]!=-1) Rec_Change=0;
00642 }
00643 else if (Data->P[i].History[j].Hard[0][0]==3 && Data->P[i].History[j].Man[0][0]!=-1) Rec_Change=1;
00644 break;
00645 case 17:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00646 if (rec[k][0].place==0)
00647 {
00648 if (Data->P[i].History[j].Hard[0][0]==4 && Data->P[i].History[j].Man[0][0]!=-1) Rec_Change=0;
00649 }
00650 else if (Data->P[i].History[j].Hard[0][0]==4 && Data->P[i].History[j].Man[0][0]!=-1) Rec_Change=1;
00651 break;
00652 case 18:rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00653 if (Ty==1)
00654 {
00655 for(craft=0;craft<5;craft++)
00656 {
00657 max=temp=0;Rec_Change=-1;
00658 for(loop=0;loop<Data->P[i].PastMis;loop++)
00659 {
00660 if (Data->P[i].History[loop].Prestige>0)
00661 {
00662 max=Data->P[i].History[loop].Prestige;
00663 if (Data->P[i].History[loop].Hard[0][0]==craft)
00664 {
00665 temp+=max;
00666 Rec_Change=1;
00667 }
00668 }
00669 }
00670 hold=j;j=craft;
00671 for(loop=0;loop<3;loop++)
00672 {
00673 if (rec[k][loop].program==j && rec[k][loop].tag==temp) Rec_Change=-1;
00674 }
00675 if (Rec_Change==1)
00676 switch(rec[k][0].place)
00677 {
00678 case 0:WriteRecord(i,j,k,temp);break;
00679 case 1:if (rec[k][0].tag<=temp)
00680 {
00681 WriteRecord(i,j,k,temp);SwapRec(k,1,0);
00682 }
00683 else WriteRecord(i,j,k,temp);
00684 break;
00685 case 2:if (rec[k][1].tag<=temp)
00686 {
00687 WriteRecord(i,j,k,temp);SwapRec(k,2,1);
00688 if (rec[k][0].tag<=temp) SwapRec(k,1,0);
00689 }
00690 else WriteRecord(i,j,k,temp);
00691 break;
00692 case 3:if (rec[k][2].tag<=temp)
00693 {
00694 --rec[k][0].place;WriteRecord(i,j,k,temp);
00695 if (rec[k][1].tag<=temp)
00696 {
00697 SwapRec(k,2,1);
00698 if (rec[k][0].tag<=temp) SwapRec(k,1,0);
00699 }
00700 }
00701 break;
00702 default:break;
00703 }
00704 j=hold;
00705 }
00706 }
00707 Rec_Change=-1;
00708 break;
00709 case 19:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00710 if (rec[k][0].place==0)
00711 {
00712 if (Data->P[i].History[j].MissionCode==43) Rec_Change=0;
00713 }
00714 else
00715 {
00716 if (Data->P[i].History[j].MissionCode==43) Rec_Change=1;
00717 }
00718 break;
00719 case 20:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00720 if (rec[k][0].place==0)
00721 {
00722 if (Data->P[i].History[j].MissionCode==46 ||
00723 Data->P[i].History[j].MissionCode==48) Rec_Change=0;
00724 }
00725 else
00726 {
00727 if (Data->P[i].History[j].MissionCode==46 ||
00728 Data->P[i].History[j].MissionCode==48) Rec_Change=1;
00729 }
00730 break;
00731 case 21:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00732 if (rec[k][0].place==0)
00733 {
00734 if (MLL(i,j)==1 || (i==1 && Data->P[i].History[j].MissionCode==57)) Rec_Change=0;
00735 }
00736 else
00737 {
00738 if (MLL(i,j)==1 || (i==1 && Data->P[i].History[j].MissionCode==57)) Rec_Change=1;
00739 }
00740 break;
00741 case 22:rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00742 if (Ty==1)
00743 {
00744 temp=0;
00745 for(loop=0;loop<Data->P[i].AstroCount;loop++)
00746 {
00747 if (Data->P[i].Pool[loop].Status==1) ++temp;
00748 }
00749 if (rec[k][0].place==0) Rec_Change=0;
00750 else Rec_Change=4;
00751 }
00752 break;
00753 case 23:rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00754 if (Ty==1)
00755 {
00756 temp=0;
00757 for(loop=0;loop<Data->P[i].AstroCount;loop++)
00758 {
00759 if (Data->P[i].Pool[loop].Status==1) ++temp;
00760 if (rec[k][0].place==0) Rec_Change=0;
00761 else Rec_Change=3;
00762 }
00763 };
00764 break;
00765 case 24:break;
00766 case 25:break;
00767 case 26:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00768 if (rec[k][0].place==0)
00769 {
00770 if (ISDOCK(Data->P[i].History[j].MissionCode)==1) Rec_Change=0;
00771 }
00772 else if (ISDOCK(Data->P[i].History[j].MissionCode)==1) Rec_Change=1;
00773 break;
00774 case 27:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00775 if (rec[k][0].place==0)
00776 {
00777 if (Data->P[i].History[j].MissionCode!=15 && Data->P[i].History[j].MissionCode!=18 &&
00778 ISDOCK(Data->P[i].History[j].MissionCode)==1) Rec_Change=0;
00779 }
00780 else if (Data->P[i].History[j].MissionCode!=15 && Data->P[i].History[j].MissionCode!=18 &&
00781 ISDOCK(Data->P[i].History[j].MissionCode)==1) Rec_Change=1;
00782 break;
00783 case 28:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00784 if (rec[k][0].place==0)
00785 {
00786 if (Data->P[i].History[j].MissionCode==32 || Data->P[i].History[j].MissionCode==36)
00787 Rec_Change=0;
00788 }
00789 else if (Data->P[i].History[j].MissionCode==32 || Data->P[i].History[j].MissionCode==36) Rec_Change=1;
00790 break;
00791 case 29:temp=0;rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
00792 temp=Data->P[i].History[j].Duration;
00793 if (rec[k][0].place==0)
00794 {
00795 if (temp>0) Rec_Change=0;
00796 }
00797 else if (temp>0) Rec_Change=5;
00798 else Rec_Change=-1;
00799 break;
00800 case 30:rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00801 temp=Data->P[i].History[j].Prestige;
00802 if (rec[k][0].place==0)
00803 {
00804 if (temp>0) Rec_Change=0;
00805 }
00806 else if (temp>0) Rec_Change=3;
00807 else Rec_Change=-1;
00808 break;
00809 case 31:rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00810 if (Ty==1)
00811 {
00812 temp=Data->P[i].PastMis;
00813 if (rec[k][0].place==0)
00814 {
00815 if (temp>0) Rec_Change=0;
00816 }
00817 else if (temp>0) Rec_Change=4;
00818 else Rec_Change=-1;
00819 };
00820 break;
00821 case 32:rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00822 if (Ty==1)
00823 {
00824 temp=Data->P[i].PastMis;
00825 if (rec[k][0].place==0)
00826 {
00827 if (temp>0) Rec_Change=0;
00828 }
00829 else if (temp>0) Rec_Change=3;
00830 };
00831 break;
00832 case 33:rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00833 if (Ty==1)
00834 {
00835 temp=0;
00836 for(loop=0;loop<Data->P[i].PastMis;loop++)
00837 {
00838 if (Data->P[i].History[loop].Duration>0)
00839 ++temp;
00840 };
00841 if (rec[k][0].place==0) Rec_Change=0;
00842 else Rec_Change=3;
00843 }
00844 break;
00845 case 34:rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00846 if (Ty==1)
00847 {
00848 temp=0;
00849 for(loop=0;loop<Data->P[i].PastMis;loop++)
00850 {
00851 if (Data->P[i].History[loop].Duration>0 && CheckSucess(i,loop)==1)
00852 ++temp;
00853 }
00854 if (rec[k][0].place==0) Rec_Change=0;
00855 else Rec_Change=3;
00856 }
00857 break;
00858 case 35:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;max=0;
00859 if (Ty==1)
00860 {
00861 temp=0;max=1;
00862 for(loop=0;loop<Data->P[i].AstroCount;loop++)
00863 {
00864 max=1;
00865 if (Data->P[i].Pool[loop].Missions>=max && Data->P[i].Pool[loop].Sex==0)
00866 {
00867 max=Data->P[i].Pool[loop].Missions;
00868 if (rec[k][0].place==0) Rec_Change=0;
00869 else Rec_Change=3;
00870 RecChange(i,j,k,loop,max,Rec_Change,hold);
00871 }
00872 }
00873 }
00874 Rec_Change=-1;
00875 break;
00876 case 36:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00877 if (Ty==1)
00878 {
00879 temp=0;max=1;
00880 for(loop=0;loop<Data->P[i].AstroCount;loop++)
00881 {
00882 max=1;
00883 if (Data->P[i].Pool[loop].Missions>=max && Data->P[i].Pool[loop].Sex==1)
00884 {
00885 max=Data->P[i].Pool[loop].Missions;
00886 if (rec[k][0].place==0) Rec_Change=0;
00887 else Rec_Change=3;
00888 RecChange(i,j,k,loop,max,Rec_Change,hold);
00889 }
00890 }
00891 }
00892 Rec_Change=-1;
00893 break;
00894 case 37:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00895 if (Ty==1)
00896 {
00897 temp=0;max=1;
00898 for(loop=0;loop<Data->P[i].AstroCount;loop++)
00899 {
00900 max=1;
00901 if (Data->P[i].Pool[loop].Prestige>=max && Data->P[i].Pool[loop].Sex==0)
00902 {
00903 max=Data->P[i].Pool[loop].Prestige;
00904 if (rec[k][0].place==0) Rec_Change=0;
00905 else Rec_Change=3;
00906 RecChange(i,j,k,loop,max,Rec_Change,hold);
00907 }
00908 }
00909 };
00910 Rec_Change=-1;
00911 break;
00912 case 38:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00913 if (Ty==1)
00914 {
00915 temp=0;max=1;
00916 for(loop=0;loop<Data->P[i].AstroCount;loop++)
00917 {
00918 max=1;
00919 if (Data->P[i].Pool[loop].Prestige>=max && Data->P[i].Pool[loop].Sex==1)
00920 {
00921 max=Data->P[i].Pool[loop].Prestige;
00922 if (rec[k][0].place==0) Rec_Change=0;
00923 else Rec_Change=3;
00924 RecChange(i,j,k,loop,max,Rec_Change,hold);
00925 }
00926 }
00927 };
00928 Rec_Change=-1;
00929 break;
00930 case 39:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00931 if (Ty==1)
00932 {
00933 temp=0;max=1;
00934 for(loop=0;loop<Data->P[i].AstroCount;loop++)
00935 {
00936 max=1;
00937 if (Data->P[i].Pool[loop].Days>=max && Data->P[i].Pool[loop].Sex==0)
00938 {
00939 max=Data->P[i].Pool[loop].Days;
00940 if (rec[k][0].place==0) Rec_Change=0;
00941 else Rec_Change=3;
00942 RecChange(i,j,k,loop,max,Rec_Change,hold);
00943 }
00944 }
00945 };
00946 Rec_Change=-1;
00947 break;
00948 case 40:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00949 if (Ty==1)
00950 {
00951 temp=0;max=1;
00952 for(loop=0;loop<Data->P[i].AstroCount;loop++)
00953 {
00954 max=1;
00955 if (Data->P[i].Pool[loop].Days>=max && Data->P[i].Pool[loop].Sex==1)
00956 {
00957 max=Data->P[i].Pool[loop].Days;
00958 if (rec[k][0].place==0) Rec_Change=0;
00959 else Rec_Change=3;
00960 RecChange(i,j,k,loop,max,Rec_Change,hold);
00961 }
00962 }
00963 };
00964 Rec_Change=-1;
00965 break;
00966 case 41:rec[k][0].type=2;rec[k][1].type=2;rec[k][2].type=2;
00967 if (Ty==1)
00968 {
00969 temp=0;max=1;
00970 for(loop=0;loop<Data->P[i].AstroCount;loop++)
00971 {
00972 max=1;
00973 if (Data->P[i].Pool[loop].Active>=max)
00974 {
00975 max=Data->P[i].Pool[loop].Active;
00976 if (rec[k][0].place==0) Rec_Change=0;
00977 else Rec_Change=3;
00978 RecChange(i,j,k,loop,max,Rec_Change,hold);
00979 }
00980 }
00981 };
00982 Rec_Change=-1;
00983 break;
00984 case 42:rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00985 temp=max=0;
00986 if (Ty==1)
00987 {
00988 if (i==0) temp=(unsigned)CalcScore(0,Data->Def.Lev1,Data->Def.Lev2);
00989 else if (i==1) temp=(unsigned)CalcScore(1,Data->Def.Lev2,Data->Def.Lev1);
00990 if (rec[k][0].place==0) Rec_Change=0;
00991 else Rec_Change=3;
00992 }
00993 break;
00994 case 43:temp=max=0;rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
00995 if (Ty==1)
00996 {
00997 for(loop=0;loop<40;++loop)
00998 if (Data->P[i].BudgetHistory[loop]!=0)
00999 temp+=Data->P[i].BudgetHistory[loop];
01000 else if (loop>=6 && max==0) max=loop-1;
01001 temp=(int)temp/(int)max;
01002 if (rec[k][0].place==0) Rec_Change=0;
01003 else Rec_Change=3;
01004 }
01005 break;
01006 case 44:temp=max=0;rec[k][0].type=3;rec[k][1].type=3;rec[k][2].type=3;
01007 if (Ty==1)
01008 {
01009 for(loop=0;loop<40;++loop)
01010 if (Data->P[i].BudgetHistory[loop]!=0)
01011 temp+=Data->P[i].BudgetHistory[loop];
01012 else if (loop>=6 && max==0) max=loop-1;
01013 temp=(int)temp/(int)max;
01014 if (rec[k][0].place==0) Rec_Change=0;
01015 else Rec_Change=4;
01016 }
01017 break;
01018 case 45:rec[k][0].type=3;temp=0;rec[k][1].type=3;rec[k][2].type=3;
01019 if (Ty==1)
01020 {
01021 for(loop=0;loop<Data->P[i].PastMis;loop++)
01022 temp+=Data->P[i].History[loop].Prestige;
01023 if (rec[k][0].place==0) Rec_Change=0;
01024 else Rec_Change=3;
01025 }
01026 break;
01027 case 46:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
01028 if (rec[k][0].place==0)
01029 {
01030 if (Data->P[i].History[j].MissionCode==56) Rec_Change=0;
01031 }
01032 else
01033 {
01034 if (Data->P[i].History[j].MissionCode==56) Rec_Change=1;
01035 }
01036 break;
01037 case 47:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
01038 if (rec[k][0].place==0)
01039 {
01040 if (Data->P[i].History[j].MissionCode==55) Rec_Change=0;
01041 }
01042 else
01043 {
01044 if (Data->P[i].History[j].MissionCode==55) Rec_Change=1;
01045 }
01046 break;
01047 case 48:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
01048 if (rec[k][0].place==0)
01049 {
01050 if (Data->P[i].History[j].MissionCode==54) Rec_Change=0;
01051 }
01052 else
01053 {
01054 if (Data->P[i].History[j].MissionCode==54) Rec_Change=1;
01055 }
01056 break;
01057 case 49:rec[k][0].type=1;rec[k][1].type=1;rec[k][2].type=1;
01058 if (rec[k][0].place==0)
01059 {
01060 if (Data->P[i].History[j].MissionCode==53) Rec_Change=0;
01061 }
01062 else
01063 {
01064 if (Data->P[i].History[j].MissionCode==53) Rec_Change=1;
01065 }
01066 break;
01067 case 50:if (Ty==1) {
01068 if (MLL(i,j)==1 && Data->Prestige[22].Place==0)
01069 {
01070 ++rec[k][0].tag;rec[k][0].place=1;
01071 rec[k][0].type=3;rec[k][0].country=0;
01072 Rec_Change=-1;
01073 }}
01074 break;
01075 case 51:if (Ty==1) {
01076 if ((MLL(i,j)==1 || (i==1 && Data->P[i].History[j].MissionCode==57)) && Data->Prestige[22].Place==1)
01077 {
01078 ++rec[k][0].tag;rec[k][0].place=1;
01079 rec[k][0].type=3;rec[k][0].country=1;
01080 Rec_Change=-1;
01081 }}
01082 break;
01083 case 52:if (Ty==1) {
01084 if (Data->P[i].History[j].MissionCode==55 && CheckSucess(i,j)==1)
01085 {
01086 ++rec[k][0].tag;rec[k][0].country=2;
01087 rec[k][0].type=3;Rec_Change=-1;
01088 }}
01089 break;
01090 case 53:if (Ty==1) {
01091 if (Data->P[i].History[j].MissionCode==56 && CheckSucess(i,j)==1)
01092 {
01093 ++rec[k][0].tag;rec[k][0].country=2;
01094 rec[k][0].type=3;Rec_Change=-1;
01095 }}
01096 break;
01097 case 54:if (Ty==1) {
01098 if (Data->P[i].History[j].MissionCode==54 && CheckSucess(i,j)==1)
01099 {
01100 ++rec[k][0].tag;rec[k][0].country=2;
01101 rec[k][0].type=3;Rec_Change=-1;
01102 }}
01103 break;
01104 case 55:if (Ty==1) {
01105 if (Data->P[i].History[j].MissionCode==53 && CheckSucess(i,j)==1)
01106 {
01107 ++rec[k][0].tag;rec[k][0].country=2;
01108 rec[k][0].type=3;Rec_Change=-1;
01109 }}
01110 break;
01111 default:break;
01112 }
01113
01114 if ((k<35 || k>41) && k!=18) RecChange(i,j,k,temp,max,Rec_Change,hold);
01115 }
01116 }
01117 }
01118
01119
01120 file = sOpen("RECORDS.DAT","wb",1);
01121 fwrite(rec,sizeof rec,1,file);
01122 fclose(file);
01123 return;
01124 }
01125
01126 void RecChange(int i,int j,int k,int temp,int max,char Rec_Change,char hold)
01127 {
01128 int loop;
01129
01130
01131
01132 if (Rec_Change!=0)
01133 for(loop=0;loop<3;loop++)
01134 {
01135 if (rec[k][loop].type==3 && rec[k][loop].tag==temp && (rec[k][loop].country==i))
01136 Rec_Change=-1;
01137 if (rec[k][loop].type==2 && strcmp(&rec[k][loop].astro[0],&Data->P[rec[k][loop].country].Pool[temp].Name[0])==0)
01138 Rec_Change=-1;
01139 }
01140
01141 switch(Rec_Change)
01142 {
01143 case 0:hold=j;
01144 if (k>=35 && k<=41)
01145 {
01146 j=temp;
01147 temp=max;
01148 }
01149 WriteRecord(i,j,k,temp);
01150 j=hold;
01151 break;
01152 case 1:case 2:
01153 if (Rec_Change==2) temp=Data->P[i].History[j].Man[0][max];
01154 else temp=Data->P[i].History[j].Man[0][0];
01155 switch(rec[k][0].place)
01156 {
01157 case 1:if ((rec[k][0].yr>Data->P[i].History[j].MissionYear) ||
01158 (rec[k][0].yr==Data->P[i].History[j].MissionYear &&
01159 rec[k][0].month>=Data->P[i].History[j].Month))
01160 {WriteRecord(i,j,k,temp);SwapRec(k,1,0);}else WriteRecord(i,j,k,temp);
01161 break;
01162 case 2:if ((rec[k][1].yr>Data->P[i].History[j].MissionYear) ||
01163 (rec[k][1].yr==Data->P[i].History[j].MissionYear &&
01164 rec[k][1].month>=Data->P[i].History[j].Month))
01165 {
01166 WriteRecord(i,j,k,temp);
01167 SwapRec(k,2,1);
01168 if ((rec[k][0].yr>Data->P[i].History[j].MissionYear) ||
01169 (rec[k][0].yr==Data->P[i].History[j].MissionYear &&
01170 rec[k][0].month>=Data->P[i].History[j].Month))
01171 SwapRec(k,1,0);
01172 }
01173 else WriteRecord(i,j,k,temp);
01174 break;
01175 case 3:if ((rec[k][2].yr>Data->P[i].History[j].MissionYear) ||
01176 (rec[k][2].yr==Data->P[i].History[j].MissionYear &&
01177 rec[k][2].month>=Data->P[i].History[j].Month))
01178 {
01179 --rec[k][0].place;WriteRecord(i,j,k,temp);
01180 if ((rec[k][1].yr>Data->P[i].History[j].MissionYear) ||
01181 (rec[k][1].yr==Data->P[i].History[j].MissionYear &&
01182 rec[k][1].month>=Data->P[i].History[j].Month))
01183 {
01184 SwapRec(k,2,1);
01185 if ((rec[k][0].yr>Data->P[i].History[j].MissionYear) ||
01186 (rec[k][0].yr==Data->P[i].History[j].MissionYear &&
01187 rec[k][0].month>=Data->P[i].History[j].Month))
01188 SwapRec(k,1,0);
01189 }
01190 }
01191 break;
01192 default:break;
01193 }
01194 break;
01195 case 3:hold=j;
01196 if (k>=35 && k<=41)
01197 {
01198 j=temp;
01199 temp=max;
01200 }
01201 switch(rec[k][0].place)
01202 {
01203 case 1:if (rec[k][0].tag<=temp)
01204 {
01205 WriteRecord(i,j,k,temp);SwapRec(k,1,0);
01206 }
01207 else WriteRecord(i,j,k,temp);
01208 break;
01209 case 2:if (rec[k][1].tag<=temp)
01210 {
01211 WriteRecord(i,j,k,temp);SwapRec(k,2,1);
01212 if (rec[k][0].tag<=temp) SwapRec(k,1,0);
01213 }
01214 else WriteRecord(i,j,k,temp);
01215 break;
01216 case 3:if (rec[k][2].tag<=temp)
01217 {
01218 --rec[k][0].place;WriteRecord(i,j,k,temp);
01219 if (rec[k][1].tag<=temp)
01220 {
01221 SwapRec(k,2,1);
01222 if (rec[k][0].tag<=temp) SwapRec(k,1,0);
01223 }
01224 }
01225 break;
01226 default:break;
01227 }
01228 j=hold;
01229 break;
01230 case 4:switch(rec[k][0].place)
01231 {
01232 case 1:if (rec[k][0].tag>temp)
01233 {
01234 WriteRecord(i,j,k,temp);SwapRec(k,1,0);
01235 }
01236 else WriteRecord(i,j,k,temp);
01237 break;
01238 case 2:
01239 if (rec[k][1].tag>temp)
01240 {
01241 WriteRecord(i,j,k,temp);SwapRec(k,2,1);
01242 if (rec[k][0].tag>temp) SwapRec(k,1,0);
01243 }
01244 else WriteRecord(i,j,k,temp);
01245 break;
01246 case 3:if (rec[k][2].tag>temp)
01247 {
01248 --rec[k][0].place;WriteRecord(i,j,k,temp);
01249 if (rec[k][1].tag>temp)
01250 {
01251 SwapRec(k,2,1);
01252 if (rec[k][0].tag>temp) SwapRec(k,1,0);
01253 }
01254 }
01255 break;
01256 default:break;
01257 }
01258 break;
01259 case 5:hold=0;
01260 switch(rec[k][0].place)
01261 {
01262 case 1:if (rec[k][0].tag==temp)
01263 if ((rec[k][0].yr>Data->P[i].History[j].MissionYear) ||
01264 (rec[k][0].yr==Data->P[i].History[j].MissionYear &&
01265 rec[k][0].month>=Data->P[i].History[j].Month)) hold=1;
01266 if (rec[k][0].tag<temp) hold=1;
01267 if (hold==1)
01268 {
01269 WriteRecord(i,j,k,temp);SwapRec(k,1,0);
01270 }
01271 else WriteRecord(i,j,k,temp);
01272 break;
01273 case 2:if (rec[k][1].tag==temp)
01274 if ((rec[k][1].yr>Data->P[i].History[j].MissionYear) ||
01275 (rec[k][1].yr==Data->P[i].History[j].MissionYear &&
01276 rec[k][1].month>=Data->P[i].History[j].Month)) hold=1;
01277 if (rec[k][1].tag<temp) hold=1;
01278 if (hold==1)
01279 {
01280 hold=0;
01281 WriteRecord(i,j,k,temp);
01282 SwapRec(k,2,1);
01283 if (rec[k][0].tag==temp)
01284 if ((rec[k][0].yr>Data->P[i].History[j].MissionYear) ||
01285 (rec[k][0].yr==Data->P[i].History[j].MissionYear &&
01286 rec[k][0].month>=Data->P[i].History[j].Month)) hold=1;
01287 if (rec[k][0].tag<temp) hold=1;
01288 if (hold==1) SwapRec(k,1,0);
01289 }
01290 else WriteRecord(i,j,k,temp);
01291 break;
01292 case 3:if (rec[k][2].tag==temp)
01293 if ((rec[k][2].yr>Data->P[i].History[j].MissionYear) ||
01294 (rec[k][2].yr==Data->P[i].History[j].MissionYear &&
01295 rec[k][2].month>=Data->P[i].History[j].Month)) hold=1;
01296 if (rec[k][2].tag<temp) hold=1;
01297 if (hold==1)
01298 {
01299 hold=0;
01300 --rec[k][0].place;WriteRecord(i,j,k,temp);
01301 if (rec[k][1].tag==temp)
01302 if ((rec[k][1].yr>Data->P[i].History[j].MissionYear) ||
01303 (rec[k][1].yr==Data->P[i].History[j].MissionYear &&
01304 rec[k][1].month>=Data->P[i].History[j].Month)) hold=1;
01305 if (rec[k][1].tag<temp) hold=1;
01306 if (hold==1)
01307 {
01308 hold=0;
01309 SwapRec(k,2,1);
01310 if (rec[k][0].tag==temp)
01311 if ((rec[k][0].yr>Data->P[i].History[j].MissionYear) ||
01312 (rec[k][0].yr==Data->P[i].History[j].MissionYear &&
01313 rec[k][0].month>=Data->P[i].History[j].Month)) hold=1;
01314 if (rec[k][0].tag<temp) hold=1;
01315 if (hold==1) SwapRec(k,1,0);
01316 }
01317 }
01318 break;
01319 default:break;
01320 }
01321 break;
01322 default:break;
01323 }
01324 return;
01325 }
01326