00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "gamedata.h"
00031 #include "Buzz_inc.h"
00032 #include "externs.h"
00033 #include "utils.h"
00034 #include "logging.h"
00035
00036 extern char AI[2];
00037
00038 struct VInfo VAS[7][4];
00039 char VASqty,CV;
00040 extern struct mStr Mis;
00041 extern char Vab_Spot;
00042
00043
00044
00045 struct MDA {
00046 i16 x1,y1,x2,y2,o;
00047 } *MI;
00048 #if 0
00049 104,1,119,55,0,
00050 143,1,153,67,0,
00051 177,1,217,133,0,
00052 219,1,262,139,0,
00053 121,1,141,53,0,
00054 155,1,175,67,0,
00055 177,1,217,133,0,
00056 83,1,102,57,0,
00057 264,1,318,145,0,
00058 59,48,75,67,0,
00059 59,69,73,84,0,
00060 59,86,72,100,0,
00061 130,55,141,59,0,
00062 2,1,18,39,13,
00063 79,69,111,117,2,
00064 20,1,57,59,12,
00065 59,1,81,46,7,
00066 137,69,175,139,7,
00067 223,141,262,178,0,
00068 188,141,221,177,0,
00069 138,141,160,166,0,
00070 162,141,186,172,0,
00071 0,0,0,0,0,
00072 0,0,0,0,0,
00073 0,0,0,0,0,
00074 20,61,57,141,0,
00075 113,69,132,98,0,
00076 81,119,135,153,0,
00077
00078 86,1,113,74,0,
00079 115,1,137,82,0,
00080 192,1,227,130,0,
00081 229,0,263,131,0,
00082 139,1,166,85,0,
00083 168,1,190,95,0,
00084 192,1,227,130,0,
00085 3,60,22,116,0,
00086 277,1,318,145,0,
00087 5,32,22,51,0,
00088 79,132,89,157,0,
00089 3,1,20,30,0,
00090 5,53,19,58,0,
00091 91,132,118,166,15,
00092 120,132,148,167,15,
00093 176,132,211,194,15,
00094 249,132,275,193,11,
00095 213,132,247,196,11,
00096 25,1,55,36,0,
00097 57,1,84,37,0,
00098 24,39,36,72,0,
00099 38,39,58,75,0,
00100 60,39,84,94,0,
00101 150,132,174,177,22,
00102 0,0,0,0,0,
00103 24,77,48,183,0,
00104 3,118,22,147,0,
00105 149,97,190,124,0
00106 };
00107 #endif
00108
00109 void GradRect2(int x1,int y1,int x2,int y2,char plr)
00110 {
00111 register int i,j,val;
00112
00113 val=3*plr+6;
00114
00115 RectFill(x1,y1,x2,y2,7+3*plr);
00116 for (j=x1;j<=x2;j+=3)
00117 for (i=y1;i<=y2;i+=3)
00118 screen[j+320*i]=val;
00119 return;
00120 }
00121
00122
00123 void DispVAB(char plr,char pad)
00124 {
00125 FILE *fp = NULL;
00126 uint16_t image_len = 0;
00127
00128 strcpy(IDT,"i016");strcpy(IKEY,"k016");
00129
00130 FadeOut(2,pal,10,0,0);
00131
00132 fp = sOpen("VAB.IMG","rb",0);
00133 fread(pal,768,1,fp);
00134 fread_uint16_t(&image_len, 1, fp);
00135 if (plr==1) {
00136 fseek(fp,image_len,SEEK_CUR);
00137 fread(pal,768,1,fp);
00138 fread_uint16_t(&image_len, 1, fp);
00139 }
00140 fread((char *)screen,image_len,1,fp);
00141 fclose(fp);
00142
00143 PCX_D((char *)screen,vhptr.vptr,image_len);
00144
00145 gxClearDisplay(0,0);
00146 ShBox(0,0,319,22);ShBox(0,24,170,99);
00147 ShBox(0,101,170,199);ShBox(172,24,319,199);
00148 InBox(3,3,30,19);
00149 IOBox(243,3,316,19);
00150 IOBox(175,183,244,197);
00151 if (Data->P[plr].Mission[pad].MissionCode!=0) IOBox(247,183,316,197);
00152 else InBox(247,183,316,197);
00153
00154 InBox(4,104,166,123);
00155 IOBox(62,127,163,177); IOBox(62,179,163,193);
00156
00157 InBox(177,28,314,180);
00158 RectFill(178,29,313,179,3);
00159
00160 IOBox(4,84,165,96);
00161
00162 grSetColor(1);
00163 PrintAt(13,92,"AUTO PURCHASE");
00164 PrintAt(198,192,"EXIT");
00165 PrintAt(268,192,"SCRUB");
00166 PrintAt(264,13,"ASSIGN");
00167 PrintAt(16,136,"PRIMARY:");
00168 PrintAt(24,148,"KICKER:");
00169 PrintAt(43,160,"L.M.:");
00170 PrintAt(15,172,"PAYLOAD:");
00171 PrintAt(23,188,"ROCKET: ");
00172
00173 Name[0]='A'+pad; Name[1]=0x00;
00174 InBox(4,27,166,37);RectFill(5,28,165,36,10);
00175 grSetColor(11);
00176 PrintAt(42,34,"LAUNCH FACILITY: ");PrintAt(0,0,Name);
00177 grSetColor(1);
00178 if (plr==0) DispBig(42,4,"VEHICLE ASSEMBLY",0,-1);
00179 else DispBig(37,4,"VEHICLE INTEGRATION",0,-1);
00180
00181 grSetColor(5);
00182 PrintAt(5,45,"MISSION: ");PrintAt(0,0,Data->P[plr].Mission[pad].Name);
00183
00184 grSetColor(1);
00185 PrintAt(5,61,"CREW: ");
00186 switch(Data->P[plr].Mission[pad].Men) {
00187 case 0:PrintAt(0,0,"UNMANNED");break;
00188 case 1:PrintAt(0,0,"ONE PERSON");break;
00189 case 2:PrintAt(0,0,"TWO PEOPLE");break;
00190 case 3:PrintAt(0,0,"THREE PEOPLE");break;
00191 case 4:PrintAt(0,0,"FOUR PEOPLE");break;
00192 }
00193
00194 RectFill(5,105,165,122,7+plr*3);
00195 grSetColor(11);
00196 PrintAt(35,111,"MISSION HARDWARE:");
00197 PrintAt(10,119,"SELECT PAYLOADS AND BOOSTER");
00198
00199 grSetColor(1);
00200
00201 GetMisType(Data->P[plr].Mission[pad].MissionCode);
00202
00203 PrintAt(5,52,Mis.Abbr);
00204
00205 FlagSm(plr,4,4);
00206
00207 return;
00208 }
00209
00210
00211 int FillVab(char plr,char f,char mode)
00212 {
00213 int i,cost;
00214 cost=0;
00215 for (i=0;i<4;i++) {
00216 if ((VAS[f][i].qty-VAS[f][i].ac)<=0 && strncmp(VAS[f][i].name,"NONE",4)!=0) {
00217 switch(i) {
00218 case 0: case 2:
00219 if ((Data->P[plr].Manned[VAS[f][i].dex].Num-Data->P[plr].Manned[VAS[f][i].dex].Spok)==0) {
00220 if (mode==1) {
00221 Data->P[plr].Cash-=maxx(1,Data->P[plr].Manned[VAS[f][i].dex].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Manned[VAS[f][i].dex].UnitCost/2);
00222 Data->P[plr].Manned[VAS[f][i].dex].Num++;
00223 }
00224 else cost+=maxx(1,Data->P[plr].Manned[VAS[f][i].dex].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Manned[VAS[f][i].dex].UnitCost/2);
00225 }
00226 break;
00227 case 1:
00228 if ((Data->P[plr].Misc[VAS[f][i].dex].Num-Data->P[plr].Misc[VAS[f][i].dex].Spok)==0) {
00229 if (mode==1) {
00230 Data->P[plr].Cash-=maxx(1,Data->P[plr].Misc[VAS[f][i].dex].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Misc[VAS[f][i].dex].UnitCost/2);
00231 Data->P[plr].Misc[VAS[f][i].dex].Num++;
00232 }
00233 else cost+=maxx(1,Data->P[plr].Misc[VAS[f][i].dex].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Misc[VAS[f][i].dex].UnitCost/2);
00234 }
00235 break;
00236 case 3:
00237 if (VAS[f][i].dex!=4) {
00238 if ((Data->P[plr].Probe[VAS[f][i].dex].Num-Data->P[plr].Probe[VAS[f][i].dex].Spok)==0) {
00239 if (mode==1) {
00240 Data->P[plr].Cash-=maxx(1,Data->P[plr].Probe[VAS[f][i].dex].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Probe[VAS[f][i].dex].UnitCost/2);
00241 Data->P[plr].Probe[VAS[f][i].dex].Num++;
00242 }
00243 else cost+=maxx(1,Data->P[plr].Probe[VAS[f][i].dex].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Probe[VAS[f][i].dex].UnitCost/2);
00244 }
00245 }
00246 else {
00247 if ((Data->P[plr].Misc[VAS[f][i].dex].Num-Data->P[plr].Misc[VAS[f][i].dex].Spok)==0) {
00248 if (mode==1) {
00249 Data->P[plr].Cash-=maxx(1,Data->P[plr].Misc[VAS[f][i].dex].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Misc[VAS[f][i].dex].UnitCost/2);
00250 Data->P[plr].Misc[VAS[f][i].dex].Num++;
00251 }
00252 else cost+=maxx(1,Data->P[plr].Misc[VAS[f][i].dex].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Misc[VAS[f][i].dex].UnitCost/2);
00253 }
00254 }
00255 break;
00256 }
00257 }
00258 }
00259
00260 return cost;
00261 }
00262
00263
00264 int ChkDelVab(char plr,char f)
00265 {
00266 int i;
00267 for (i=0;i<4;i++) {
00268 if ((VAS[f][i].qty-VAS[f][i].ac)<=0 && strcmp(VAS[f][i].name,"NONE")!=0) {
00269 switch(i) {
00270 case 0: case 2:
00271 if (Data->P[plr].Manned[VAS[f][i].dex].Delay!=0)
00272 return 0;
00273 break;
00274 case 1:
00275 if (Data->P[plr].Misc[VAS[f][i].dex].Delay!=0) return 0;
00276 break;
00277 case 3:
00278 if (VAS[f][i].dex!=4) {
00279 if (Data->P[plr].Probe[VAS[f][i].dex].Delay!=0) return 0;
00280 }
00281 else {
00282 if (Data->P[plr].Misc[VAS[f][i].dex].Delay!=0) return 0;
00283 }
00284 break;
00285 }
00286 }
00287 }
00288 return 1;
00289 }
00290
00291 int BuyVabRkt(char plr,int rk,int *q,char mode)
00292 {
00293 int cost=0;
00294 if ((Data->P[plr].Rocket[rk%4].Num-Data->P[plr].Rocket[rk%4].Spok)==0) {
00295 if (mode==1) {
00296 Data->P[plr].Cash-=maxx(1,Data->P[plr].Rocket[rk%4].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Rocket[rk%4].UnitCost/2);
00297 Data->P[plr].Rocket[rk%4].Num++;
00298 q[rk%4]++;
00299 }
00300 else cost=maxx(1,Data->P[plr].Rocket[rk%4].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Rocket[rk%4].UnitCost/2);
00301 }
00302 if (rk>3 && (Data->P[plr].Rocket[4].Num-Data->P[plr].Rocket[4].Spok)==0)
00303 {
00304 if (mode==1) {
00305 Data->P[plr].Cash-=maxx(1,Data->P[plr].Rocket[4].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Rocket[4].UnitCost/2);
00306 Data->P[plr].Rocket[4].Num++;
00307 q[rk]++;
00308 }
00309 else cost+=maxx(1,Data->P[plr].Rocket[rk%4].UnitCost-(Data->P[plr].TurnOnly==3)*Data->P[plr].Rocket[rk%4].UnitCost/2);
00310
00311 }
00312 return cost;
00313 }
00314
00315 int ChkVabRkt(char plr,int rk,int *q)
00316 {
00317 if (Data->P[plr].Rocket[rk%4].Delay!=0 && q[rk]==0)
00318 return 0;
00319 if (rk>3 && Data->P[plr].Rocket[4].Delay!=0 && q[rk]==0)
00320 return 0;
00321 return 1;
00322 }
00323
00324 void ShowVA(char f)
00325 {
00326 int i;
00327
00328 RectFill(65,130,160,174,3);
00329 grSetColor(1);
00330 for (i=0;i<4;i++) {
00331 if (VAS[f][i].qty<0) grSetColor(9); else grSetColor(1);
00332 PrintAt(67,136+12*i,&VAS[f][i].name[0]);
00333 if ((VAS[f][i].qty-VAS[f][i].ac)<0) {
00334 DispNum(152,136+12*i,0);
00335 DispNum(128,136+12*i,0);
00336 } else {
00337 DispNum(152,136+12*i,VAS[f][i].qty-VAS[f][i].ac);
00338 DispNum(128,136+12*i,VAS[f][i].sf);
00339 };
00340 PrintAt(0,0,"%");
00341 };
00342
00343 return;
00344 }
00345
00346
00347 void ShowRkt(char *Name,int sf,int qty,char mode)
00348 {
00349
00350 RectFill(65,182,160,190,3);
00351 if (qty<0 || mode==1) grSetColor(9); else grSetColor(1);
00352 PrintAt(67,188,&Name[0]);
00353 if (qty<0) {DispNum(152,188,0);DispNum(128,188,0); }
00354 else {
00355 DispNum(152,188,qty);
00356 DispNum(128,188,sf);
00357 };
00358 PrintAt(0,0,"%");
00359
00360 return;
00361 }
00362
00363
00364 void DispVA(char plr,char f)
00365 {
00366 int i, TotY, IncY;
00367 int w, h, x1, y1, x2, y2, w2, h2, cx, off = 0;
00368 unsigned char *spix, *dpix, wh;
00369 GXHEADER local, local2;
00370
00371 cx = 0;
00372 for (i = 0; i < 4; i++)
00373 if (VAS[f][i].img > 0)
00374 cx++;
00375
00376
00377 wh = ((cx == 1 && VAS[f][3].img > 0) || cx == 0) ? 7 : 8;
00378 if (VAS[f][0].img == 13 && plr == 0)
00379 wh = 7;
00380
00381
00382 TotY = 0;
00383 for (i = 0; i < 4; i++)
00384 if (VAS[f][i].img > 1)
00385 TotY +=
00386 MI[plr * 28 + VAS[f][i].img].y2 - MI[plr * 28 +
00387 VAS[f][i].img].y1 + 1;
00388
00389
00390 x1 = MI[plr * 28 + wh].x1;
00391 y1 = MI[plr * 28 + wh].y1;
00392 x2 = MI[plr * 28 + wh].x2;
00393 y2 = MI[plr * 28 + wh].y2;
00394 w = x2 - x1 + 1;
00395 h = y2 - y1 + 1;
00396
00397 if (plr == 0 && VAS[f][0].img == 13)
00398 {
00399 h += 13;
00400 off = 13;
00401 };
00402
00403 GV(&local, w, h);
00404 gxClearVirtual(&local, 0);
00405 gxVirtualVirtual(&vhptr, x1, y1, x2, y2, &local, 0, 0 + off, gxSET);
00406 spix = local.vptr;
00407
00408 GV(&local2, w, h);
00409
00410
00411 RectFill(178, 29, 243, 179, 3);
00412 gxGetImage(&local2, 210 - w / 2, 103 - h / 2, 210 - w / 2 + w - 1,
00413 103 - h / 2 + h - 1, 0);
00414
00415
00416 for (i = 0; i < gxVirtualSize(gxVGA_13, w, h); i++)
00417 {
00418 if (local.vptr[i] == 0x00)
00419 local.vptr[i] = local2.vptr[i];
00420 };
00421
00422
00423
00424
00425
00426
00427 gxClearVirtual(&local2, 0);
00428
00429 cx = 0;
00430 IncY = (h - TotY) / 2;
00431 if (VAS[f][0].img > 0)
00432 {
00433 if (VAS[f][0].img == 13 && plr == 0)
00434 IncY = 0;
00435 else
00436 IncY = MI[plr * 28 + VAS[f][0].img].o;
00437 }
00438
00439 for (i = 0; i < 4; i++)
00440 {
00441 if (VAS[f][i].img > 0)
00442 {
00443 wh = VAS[f][i].img;
00444 x1 = MI[plr * 28 + wh].x1;
00445 y1 = MI[plr * 28 + wh].y1;
00446 x2 = MI[plr * 28 + wh].x2;
00447 y2 = MI[plr * 28 + wh].y2;
00448 w2 = x2 - x1 + 1;
00449 h2 = y2 - y1 + 1;
00450 cx = w / 2 - w2 / 2 - 1;
00451 if (cx + w2 > w || IncY + h2 > h)
00452 {
00453 CWARNING3(graphic, "can't fit %s image into spaceship casing!",
00454 VAS[f][i].name);
00455 continue;
00456 }
00457 else
00458 gxVirtualVirtual(&vhptr, x1, y1, x2, y2,
00459 &local2, cx, IncY, gxSET);
00460 IncY += h2 + 1;
00461 }
00462 }
00463 spix = local.vptr;
00464 dpix = local2.vptr;
00465
00466 for (i = 0; i < gxVirtualSize(gxVGA_13, w, h); i++)
00467 {
00468 if (*dpix != 0x00)
00469 *spix = *dpix;
00470 spix++;
00471 dpix++;
00472 };
00473
00474
00475
00476 cx = 0;
00477 for (i = 0; i < 4; i++)
00478 if (VAS[f][i].img > 0)
00479 cx++;
00480 wh = ((cx == 1 && VAS[f][3].img > 0) || cx == 0) ? 7 : 8;
00481 if (VAS[f][0].img == 13 && plr == 0)
00482 wh = 7;
00483
00484 if (wh == 8)
00485 {
00486 x1 = MI[plr * 28 + 25].x1;
00487 y1 = MI[plr * 28 + 25].y1;
00488 x2 = MI[plr * 28 + 25].x2;
00489 y2 = MI[plr * 28 + 25].y2;
00490 y2 = y1 + TotY - IncY - 1;
00491 w2 = x2 - x1 + 1;
00492 h2 = y2 - y1 + 1;
00493 cx = w / 2 - w2 / 2 - 1;
00494 gxVirtualVirtual(&vhptr, x1, y1, x2, y2, &local2, cx, IncY, gxSET);
00495
00496 spix = local.vptr;
00497 dpix = local2.vptr;
00498 for (i = 0; i < gxVirtualSize(gxVGA_13, w, h); i++)
00499 {
00500 if (*dpix != 0x00)
00501 *spix = *dpix;
00502 spix++;
00503 dpix++;
00504 };
00505
00506 x1 = MI[plr * 28 + 27].x1;
00507 y1 = MI[plr * 28 + 27].y1;
00508 x2 = MI[plr * 28 + 27].x2;
00509 y2 = MI[plr * 28 + 27].y2;
00510 w2 = x2 - x1 + 1;
00511 h2 = y2 - y1 + 1;
00512 gxVirtualVirtual(&vhptr, x1, y1, x2, y2, &local2, 0, h - h2, gxSET);
00513 spix = local.vptr;
00514 dpix = local2.vptr;
00515 for (i = 0; i < gxVirtualSize(gxVGA_13, w, h); i++)
00516 {
00517 if (*dpix != 0x00)
00518 *spix = *dpix;
00519 spix++;
00520 dpix++;
00521 };
00522 }
00523 else
00524 {
00525 x1 = MI[plr * 28 + 26].x1;
00526 y1 = MI[plr * 28 + 26].y1;
00527 x2 = MI[plr * 28 + 26].x2;
00528 y2 = MI[plr * 28 + 26].y2;
00529 w2 = x2 - x1 + 1;
00530 h2 = y2 - y1 + 1;
00531 gxVirtualVirtual(&vhptr, x1, y1, x2, y2, &local2, 0, h - h2, gxSET);
00532 spix = local.vptr;
00533 dpix = local2.vptr;
00534 for (i = 0; i < gxVirtualSize(gxVGA_13, w, h); i++)
00535 {
00536 if (*dpix != 0x00)
00537 *spix = *dpix;
00538 spix++;
00539 dpix++;
00540 };
00541 }
00542
00543 DV(&local2);
00544 gxPutImage(&local,gxSET,210-w/2,103-h/2,0);
00545
00546 DV(&local);
00547 return;
00548 }
00549
00550 void DispRck(char plr,char wh)
00551 {
00552 int i;
00553 int w,h,x1,y1,x2,y2;
00554 GXHEADER local,local2;
00555
00556 x1=MI[plr*28+wh].x1;y1=MI[plr*28+wh].y1;
00557 x2=MI[plr*28+wh].x2;y2=MI[plr*28+wh].y2;
00558 w=x2-x1+1;h=y2-y1+1;
00559 GV(&local,w,h); GV(&local2,w,h);
00560 gxVirtualVirtual(&vhptr,x1,y1,x2,y2,&local,0,0,gxSET);
00561
00562 RectFill(247,29,313,179,3);
00563 gxGetImage(&local2,282-w/2,103-h/2,282-w/2+w-1,103-h/2+h-1,0);
00564
00565 for (i=0;i<gxVirtualSize(gxVGA_13,w,h);i++) {
00566 if (local.vptr[i]==0x00) local.vptr[i]=local2.vptr[i];
00567 };
00568
00569 gxPutImage(&local,gxSET,282-w/2,103-h/2,0);
00570
00571 DV(&local2);DV(&local);
00572 return;
00573 }
00574
00575 void DispWts(int two,int one)
00576 {
00577
00578 RectFill(5,65,140,83,3);
00579
00580 grSetColor(1);
00581 PrintAt(5,77,"MAXIMUM PAYLOAD: ");DispNum(0,0,one);
00582
00583 grSetColor(1);
00584 PrintAt(5,70,"CURRENT PAYLOAD: ");
00585 if (one<two) grSetColor(9);
00586 DispNum(0,0,two);
00587
00588 return;
00589 }
00590
00591 void VAB(char plr)
00592 {
00593 int i,j,j2,mis,sf[8],qty[8],wgt,pay[8],tmp,ccc,rk,cwt,ab,ac;
00594 char Name[8][12],ButOn,temp;
00595 FILE* file;
00596 int MI_size = sizeof (struct MDA) * 28 * 2;
00597
00598 MI = xmalloc(MI_size);
00599 file = sOpen("VTABLE.DAT", "rb", 0);
00600 fread(MI, MI_size, 1, file);
00601 fclose(file);
00602
00603 #ifdef __BIG_ENDIAN__
00604 for (i = 0; i< 2*28; i++)
00605 {
00606 Swap16bit(MI[i].x1);
00607 Swap16bit(MI[i].y1);
00608 Swap16bit(MI[i].x2);
00609 Swap16bit(MI[i].y2);
00610 Swap16bit(MI[i].o);
00611 }
00612 #endif
00613
00614 music_start(M_HARDWARE);
00615 CV=0;
00616 begvab:
00617 mis=FutureCheck(plr,1);
00618 if (mis==5)
00619 {
00620 Vab_Spot = (Data->P[plr].Mission[0].Hard[Mission_PrimaryBooster] > 0) ? 1 : 0;
00621 music_stop();
00622 free(MI);
00623 return;
00624 };
00625
00626 temp=CheckCrewOK(plr,mis);
00627 if (temp==1)
00628 {
00629 ClrMiss(plr,mis+3);
00630 goto begvab;
00631 }
00632
00633 strcpy(IDT,"i016");
00634 if (Data->P[plr].Mission[mis].Hard[Mission_PrimaryBooster] > 0) {
00635 for (i=Mission_Capsule; i<=Mission_Probe_DM; i++) {
00636 switch(i) {
00637 case Mission_Capsule:
00638 case Mission_LM:
00639 Data->P[plr].Manned[Data->P[plr].Mission[mis].Hard[i] ].Spok--;
00640 break;
00641 case Mission_Kicker:
00642 Data->P[plr].Misc[Data->P[plr].Mission[mis].Hard[i]].Spok--;
00643 break;
00644 case Mission_Probe_DM:
00645 if (Data->P[plr].Mission[mis].Hard[i]==4) Data->P[plr].Misc[4].Spok--;
00646 else Data->P[plr].Probe[ Data->P[plr].Mission[mis].Hard[i]].Spok--;
00647 break;
00648 }
00649 }
00650
00651 Data->P[plr].Rocket[(Data->P[plr].Mission[mis].Hard[Mission_PrimaryBooster]-1)%4].Spok--;
00652 if (Data->P[plr].Mission[mis].Hard[Mission_PrimaryBooster]>3) Data->P[plr].Rocket[4].Spok--;
00653
00654 };
00655 BuildVAB(plr,mis,0,0,0);
00656
00657 for (i=0;i<7;i++) {
00658 if (i>3) {
00659 sf[i]=(Data->P[plr].Rocket[i-4].Safety+
00660 Data->P[plr].Rocket[4].Safety)>>1;
00661 strcpy(&Name[i][0],"B/");
00662 strcat(&Name[i][0],&Data->P[plr].Rocket[i-4].Name[0]);
00663 qty[i]=Data->P[plr].Rocket[i-4].Num-Data->P[plr].Rocket[i-4].Spok;
00664 tmp=Data->P[plr].Rocket[4].Num-Data->P[plr].Rocket[4].Spok;
00665 if (tmp<qty[i]) qty[i]=tmp;
00666 pay[i]=(Data->P[plr].Rocket[i-4].MaxPay+Data->P[plr].Rocket[4].MaxPay);
00667 } else {
00668 sf[i]=Data->P[plr].Rocket[i].Safety;
00669 strcpy(&Name[i][0],&Data->P[plr].Rocket[i].Name[0]);
00670 qty[i]=Data->P[plr].Rocket[i].Num-Data->P[plr].Rocket[i].Spok;
00671 pay[i]=Data->P[plr].Rocket[i].MaxPay;
00672 }
00673 }
00674
00675 DispVAB(plr,mis);
00676 if (Data->P[plr].Mission[mis].MissionCode>0) ButOn=1;
00677 else {ButOn=0;InBox(245,5,314,17);};
00678 wgt=0;ccc=(VASqty>0)? 1:0;
00679 for (i=0;i<4;i++) wgt+=VAS[1][i].wt;
00680 rk=0;while(pay[rk]<wgt) rk++;
00681 ccc=1;
00682 ShowVA(ccc);
00683 ShowRkt(&Name[rk][0],sf[rk],qty[rk],pay[rk]<wgt);
00684 DispRck(plr,rk);
00685 DispVA(plr,ccc);
00686 cwt=0;for (i=0;i<4;i++) cwt+=VAS[ccc][i].wt;
00687 DispWts(cwt,pay[rk]);
00688
00689 FadeIn(2,pal,10,0,0);
00690 WaitForMouseUp();
00691 while (1)
00692 {
00693 key=0;GetMouse();
00694 if (mousebuttons > 0 || key>0)
00695 {
00696
00697
00698 if ((x>=6 && y>=86 && x<=163 && y<=94 && mousebuttons>0) || key=='A')
00699 {
00700 InBox(6,86,163,94);
00701 key=0;
00702
00703 ac=0;
00704 ac=ChkDelVab(plr,ccc);
00705 if (ac!=0) ac=ChkVabRkt(plr,rk,&qty[0]);
00706 ab=FillVab(plr,ccc,0);
00707 ab+=BuyVabRkt(plr,rk,&qty[0],0);
00708
00709 if (Data->P[plr].Cash>=ab && ac!=0) {
00710 FillVab(plr,ccc,1);
00711 BuyVabRkt(plr,rk,&qty[0],1);
00712 BuildVAB(plr,mis,0,0,1);
00713
00714
00715 for (i=0;i<7;i++) {
00716 if (i>3) {
00717 sf[i]=(Data->P[plr].Rocket[i-4].Safety+
00718 Data->P[plr].Rocket[4].Safety)>>1;
00719 strcpy(&Name[i][0],"B/");
00720 strcat(&Name[i][0],&Data->P[plr].Rocket[i-4].Name[0]);
00721 qty[i]=Data->P[plr].Rocket[i-4].Num-Data->P[plr].Rocket[i-4].Spok;
00722 tmp=Data->P[plr].Rocket[4].Num-Data->P[plr].Rocket[4].Spok;
00723 if (tmp<qty[i]) qty[i]=tmp;
00724 pay[i]=(Data->P[plr].Rocket[i-4].MaxPay+Data->P[plr].Rocket[4].MaxPay);
00725 } else {
00726 sf[i]=Data->P[plr].Rocket[i].Safety;
00727 strcpy(&Name[i][0],&Data->P[plr].Rocket[i].Name[0]);
00728 qty[i]=Data->P[plr].Rocket[i].Num-Data->P[plr].Rocket[i].Spok;
00729 pay[i]=Data->P[plr].Rocket[i].MaxPay;
00730 }
00731 }
00732 }
00733 else if (ac==0) Help("i135");
00734 else Help("i137");
00735 ShowVA(ccc);ShowRkt(&Name[rk][0],sf[rk],qty[rk],pay[rk]<wgt);
00736 OutBox(6,86,163,94);
00737 }
00738
00739 if ((x>=177 && y>=185 && x<=242 && y<=195 && mousebuttons>0) || (key==K_ESCAPE || key=='E'))
00740 {
00741 InBox(177,185,242,195);
00742 WaitForMouseUp();
00743 if (key>0) delay(150);
00744 OutBox(177,185,242,195);
00745
00746 for (i=Mission_Capsule; i<=Mission_PrimaryBooster; i++)
00747 Data->P[plr].Mission[mis].Hard[i]=0;
00748 goto begvab;
00749 }
00750 else
00751 if (((x>=249 && y>=185 && x<=314 && y<=195 && mousebuttons>0) || key=='S') && Data->P[plr].Mission[mis].MissionCode!=0)
00752 {
00753 InBox(249,185,314,195);
00754 WaitForMouseUp();
00755 if (key>0) delay(100);
00756 OutBox(249,185,314,195);
00757 ClrMiss(plr,mis);
00758 if (Data->P[plr].Mission[mis].MissionCode==0) goto begvab;
00759 }
00760 else
00761 if (((x>=245 && y>=5 && x<=314 && y<=17 && mousebuttons>0) || key==K_ENTER) && ccc!=0 && ButOn==1 && cwt<=pay[rk])
00762 {
00763 j=0;
00764 if (Mis.EVA==1 && Data->P[plr].Misc[3].Num==-1) Help("i118");
00765 else if (Mis.Doc==1 && Data->P[plr].Misc[4].Num==-1) Help("i119");
00766 else
00767 {
00768 if ((Mis.mVab[0]&0x10)==0x10 && Data->P[plr].DMod<=0)
00769 Help("i155");
00770
00771 j=j2=0;
00772 if (strncmp((char *)VAS[ccc][0].name,"NONE",4)!=0) {
00773 j++;
00774 if ((Data->P[plr].Manned[VAS[ccc][0].dex].Num-Data->P[plr].Manned[VAS[ccc][0].dex].Spok)>0) j2++;
00775 }
00776 if (strncmp((char *)VAS[ccc][1].name,"NONE",4)!=0) {
00777 j++;
00778 if ((Data->P[plr].Misc[VAS[ccc][1].dex].Num-Data->P[plr].Misc[VAS[ccc][1].dex].Spok)>0) j2++;
00779 }
00780 if (strncmp((char *)VAS[ccc][2].name,"NONE",4)!=0) {
00781 j++;
00782 if ((Data->P[plr].Manned[VAS[ccc][2].dex].Num-Data->P[plr].Manned[VAS[ccc][2].dex].Spok)>0) j2++;
00783 }
00784 if (strncmp((char *)VAS[ccc][3].name,"NONE",4)!=0) {
00785 j++;
00786 if (((Data->P[plr].Probe[VAS[ccc][3].dex].Num-Data->P[plr].Probe[VAS[ccc][3].dex].Spok)>0)
00787 || ((Data->P[plr].Misc[VAS[ccc][3].dex].Num-Data->P[plr].Misc[VAS[ccc][3].dex].Spok)>0))
00788 j2++;
00789 }
00790 j++;
00791 if (qty[rk]>0) j2++;
00792
00793 if (j==j2) {
00794 InBox(245,5,314,17);
00795 WaitForMouseUp();
00796 if (key>0) delay(150);
00797 OutBox(245,5,314,17);
00798 for (i=Mission_Capsule; i<=Mission_Probe_DM; i++) {
00799 Data->P[plr].Mission[mis].Hard[i]=VAS[ccc][i].dex;
00800 if (VAS[ccc][i].dex>=0) {
00801 switch(i) {
00802 case Mission_Capsule:
00803 case Mission_LM:
00804 Data->P[plr].Manned[VAS[ccc][i].dex].Spok++;
00805 break;
00806 case Mission_Kicker:
00807 Data->P[plr].Misc[VAS[ccc][i].dex].Spok++;
00808 break;
00809 case Mission_Probe_DM:
00810 if (VAS[ccc][i].dex==4) Data->P[plr].Misc[Mission_PrimaryBooster].Spok++;
00811 else Data->P[plr].Probe[VAS[ccc][i].dex].Spok++;
00812 break;
00813 }
00814 }
00815 }
00816 Data->P[plr].Mission[mis].Hard[Mission_PrimaryBooster]=rk+1;
00817 Data->P[plr].Rocket[rk%4].Spok++;
00818 if (rk>3) Data->P[plr].Rocket[4].Spok++;
00819 goto begvab;
00820 }
00821 }
00822 }
00823 else
00824 if ((x>=64 && y>=181 && x<=161 && y<=191 && mousebuttons>0) || key=='R')
00825 {
00826 InBox(64,181,161,191);
00827 #define Misdef(a) Data->P[plr].Mission[(a)].MissionCode
00828 rk++;
00829 if (rk>6) rk=0;
00830 if (((Misdef(mis)>=42 && Misdef(mis)<=57) || (Misdef(mis)>=7 && Misdef(mis)<=13)) && (rk==4 || rk==0))
00831 rk++;
00832
00833 ShowRkt(&Name[rk][0],sf[rk],qty[rk],pay[rk]<wgt);
00834 DispWts(cwt,pay[rk]);
00835 DispRck(plr,rk);
00836 WaitForMouseUp();
00837 if (key>0) delay(100);
00838 OutBox(64,181,161,191);
00839
00840 }
00841 else
00842 if ((x>=64 && y>=129 && x<=161 && y<=175 && mousebuttons>0) || key=='P')
00843 {
00844 InBox(64,129,161,175);
00845 ccc++; if (ccc>VASqty) ccc=0;
00846 cwt=0;for (i=0;i<4;i++) cwt+=VAS[ccc][i].wt;
00847 ShowVA(ccc);DispWts(cwt,pay[rk]);
00848 DispVA(plr,ccc);
00849 WaitForMouseUp();
00850 if (key>0) delay(100);
00851 OutBox(64,129,161,175);
00852
00853 };
00854 }
00855 }
00856 }
00857
00858
00859
00860
00861 void BuildVAB(char plr,char mis,char ty,char pa,char pr)
00862 {
00863 char i,j,part,mcode,prog,ext=0;
00864 unsigned char VX;
00865
00866 memset(VAS,0x00,sizeof VAS);
00867
00868 if (ty==0) {
00869 part=Data->P[plr].Mission[mis].part;
00870 mcode=Data->P[plr].Mission[mis].MissionCode;
00871 prog=Data->P[plr].Mission[mis].Prog-1;
00872
00873 if (part==0) {
00874 if (Data->P[plr].Mission[mis].Joint==1)
00875 ext=Data->P[plr].Mission[mis+1].Prog-1;
00876 }
00877 else ext=prog;
00878 } else {
00879 part=pa;
00880 mcode=mis;
00881 prog=ext=pr;
00882 }
00883
00884 GetMisType(mcode);
00885
00886 VX=Mis.mVab[part];
00887
00888 for (i=0;i<7;i++)
00889 for (j=0;j<5;j++) {
00890 strcpy(&VAS[i][j].name[0],"NONE");
00891 VAS[i][j].qty=VAS[i][j].sf=VAS[i][j].wt=0;
00892 VAS[i][j].dex=VAS[i][j].img=-1;
00893 };
00894 #if 0
00895 if (Mis.EVA==1) {
00896 for (i=1;i<7;i++) {
00897 VAS[i][4].qty=1;
00898 VAS[i][4].dex=Data->P[plr].Misc[3].Num;
00899 VAS[i][4].sf=Data->P[plr].Misc[3].Safety;
00900 }
00901 }
00902 #endif
00903
00904 VASqty=0;
00905 if (VX&0x80) {
00906 j=(part==0) ? prog:ext;
00907 for (i=1;i<6;i++) {
00908 VASqty++;
00909 VVals(plr,0,&Data->P[plr].Manned[j],j,13+j);
00910 };
00911 }
00912
00913 VASqty=0;
00914
00915 if (VX == 0x20 && part==0 && mcode==1) {
00916 VASqty++;
00917 VVals(plr,3,&Data->P[plr].Probe[0],0,9);
00918 }
00919 if (VX == 0x20 && part==0 && mcode!=1) {
00920 VASqty++;
00921 VVals(plr,3,&Data->P[plr].Misc[4],4,12);
00922 }
00923 else if (VX == 0x04 && part==0) {
00924 VASqty++;
00925 VVals(plr,3,&Data->P[plr].Probe[1],1,10);
00926 }
00927 else if (VX == 0x02 && part==0) {
00928 VASqty++;
00929 VVals(plr,3,&Data->P[plr].Probe[2],2,11);
00930 }
00931 else if (VX == 0x60 && part==0) {
00932 LMAdd(plr,ext,-1,1);
00933 }
00934 else if (VX == 0xe8 && part==0) {
00935 LMAdd(plr,prog,-1,1);
00936 }
00937 else if (VX == 0x61 && part==0) {
00938 LMAdd(plr,ext,0,1);
00939 LMAdd(plr,ext,1,1);
00940 }
00941 else if (VX == 0x21 && part==0) {
00942 VASqty++;
00943 VVals(plr,1,&Data->P[plr].Misc[2],2,22);
00944 }
00945
00946 else if (VX == 0x80) VASqty=1;
00947
00948 else if (VX == 0x88) {
00949 VASqty=1;
00950
00951 }
00952
00953 else if (VX == 0xa0 && part==0) {
00954 VASqty++;
00955 VVals(plr,3,&Data->P[plr].Misc[4],4,12);
00956 }
00957
00958 else if (VX == 0x90 && part==0) {
00959 VASqty=1;
00960 }
00961
00962 else if (VX == 0xa8 && part==0) {
00963 VASqty++;
00964 VVals(plr,3,&Data->P[plr].Misc[4],4,12);
00965
00966 }
00967
00968 else if (VX == 0x98 && part==0) {
00969 VASqty=1;
00970
00971
00972 }
00973
00974 else if (VX == 0xe0 && part==0) {
00975 LMAdd(plr,prog,-1,0);
00976 }
00977
00978 else if (VX == 0x81) {
00979 if (prog==1 || prog==3) {
00980 VASqty++;
00981 VVals(plr,1,&Data->P[plr].Misc[0],0,20);
00982 VASqty++;
00983 VVals(plr,1,&Data->P[plr].Misc[1],1,21);
00984 } else VASqty=1;
00985 }
00986
00987 else if (VX == 0xe1 && part==0) {
00988 LMAdd(plr,prog,1,0);
00989 }
00990
00991 else if (VX == 0xe9 && part==0) {
00992 LMAdd(plr,prog,1,0);
00993
00994 }
00995
00996 else if (VX == 0x89 && part==1) {
00997 if (prog!=2) {
00998 VASqty++;
00999 VVals(plr,1,&Data->P[plr].Misc[0],0,20);
01000 VASqty++;
01001 VVals(plr,1,&Data->P[plr].Misc[1],1,21);
01002 } else VASqty=1;
01003
01004 }
01005 return;
01006 };
01007
01008
01009 void LMAdd(char plr,char prog,char kic,char part)
01010 {
01011 if (prog==1) {
01012 VASqty++;
01013 VVals(plr,3,&Data->P[plr].Misc[4],4,12);
01014 VVals(plr,2,&Data->P[plr].Manned[6],6,19);
01015 if (kic>=0) VVals(plr,1,&Data->P[plr].Misc[kic],kic,20+kic);
01016
01017 }
01018
01019 else if (prog==2) {
01020 VASqty++;
01021 VVals(plr,2,&Data->P[plr].Manned[5],5,18);
01022 if (part==1 && kic>=0) VVals(plr,1,&Data->P[plr].Misc[kic],kic,20+kic);
01023
01024 VASqty++;
01025 VVals(plr,2,&Data->P[plr].Manned[6],6,19);
01026 if (part==1 && kic>=0) VVals(plr,1,&Data->P[plr].Misc[kic],kic,20+kic);
01027 }
01028
01029 else if (prog==3) {
01030 VASqty++;
01031 VVals(plr,3,&Data->P[plr].Misc[4],4,12);
01032 VVals(plr,2,&Data->P[plr].Manned[5],5,18);
01033 if (kic>=0) VVals(plr,1,&Data->P[plr].Misc[kic],kic,20+kic);
01034 VASqty++;
01035 VVals(plr,3,&Data->P[plr].Misc[4],4,12);
01036 VVals(plr,2,&Data->P[plr].Manned[6],6,19);
01037 if (kic>=0) VVals(plr,1,&Data->P[plr].Misc[kic],kic,20+kic);
01038 }
01039 return;
01040 }
01041
01042 void VVals(char plr,char tx,Equipment *EQ,char v4,char v5)
01043 {
01044 strcpy(&VAS[VASqty][tx].name[0],&EQ->Name[0]);
01045 VAS[VASqty][tx].qty=EQ->Num;
01046 VAS[VASqty][tx].ac=EQ->Spok;
01047 VAS[VASqty][tx].wt=EQ->UnitWeight;
01048 if (tx==3 && v4==4 && AI[plr]==1) VAS[VASqty][tx].sf=EQ->MSF;
01049 else VAS[VASqty][tx].sf=EQ->Safety;
01050 VAS[VASqty][tx].dex=v4;VAS[VASqty][tx].img=v5;
01051 return;
01052 }
01053
01054