void MisCheck(char plr, char mpad) { int tomflag = 0; // toms checking flag int val, safety, save, PROBLEM, i, lc, durxx; struct XFails Now; unsigned char gork = 0; lc = 0; /* XXX check uninitialized */ STEPnum = STEP; FINAL = STEP = MFlag = 0; // Clear Everything Unm = MANNED[0] + MANNED[1]; Dock_Skip = 0; // used for mission branching MPad = mpad; SCRUBS = noDock = InSpace = 0; if (!AI[plr] && !fullscreenMissionPlayback) { //FadeOut(1,pal,100,128,1); if (plr == 1) { fill_rectangle(189, 173, 249, 196, 55); for (i = 190; i < 250; i += 2) { display::graphics.legacyScreen()->setPixel(i, 178, 61); display::graphics.legacyScreen()->setPixel(i, 184, 61); display::graphics.legacyScreen()->setPixel(i, 190, 61); } lc = 191; } else if (plr == 0) { fill_rectangle(73, 173, 133, 196, 55); for (i = 73; i < 133; i += 2) { display::graphics.legacyScreen()->setPixel(i, 178, 61); display::graphics.legacyScreen()->setPixel(i, 184, 61); display::graphics.legacyScreen()->setPixel(i, 190, 61); } lc = 76; } } // END if (!AI[plr]) if (!AI[plr] && !fullscreenMissionPlayback) { Tick(2); } Mev[0].trace = 0; death = 0; durxx = durx = -1; if (Data->P[plr].Mission[mpad].Duration > 0) { durxx = Data->P[plr].Mission[mpad].Duration - 1; Data->P[plr].Mission[mpad].Duration = 0; } if (JOINT == 1) { durxx = MAX(durxx, Data->P[plr].Mission[mpad + 1].Duration - 1); Data->P[plr].Mission[mpad + 1].Duration = 0; } do { if (STEP > 30 || STEP < 0) { delay(20); } if (Dock_Skip == 1) { if (Mev[Mev[STEP].trace].loc == 8) { Mev[STEP].trace++; // skip over docking. } } if (Mev[STEP].loc == 16 && Mis.PCat[4] == 22) { FirstManOnMoon(plr, 0, Mis.Index); } // Duration Hack Part 1 of 3 (during the Duration stuff) if ((Mev[STEP].loc == 27 || Mev[STEP].loc == 28) && durx > 0) { if (Mev[STEP].StepInfo != 1) { Data->P[plr].Mission[MPad + Mev[STEP].pad].Duration = 1; //Original code would also return 1 durx = -1; // end durations } else { Data->P[plr].Mission[MPad + Mev[STEP].pad].Duration++; durx--; if ((Data->Def.Lev1 == 0 && plr == 0) || (Data->Def.Lev2 == 0 && plr == 1)) { Mev[STEP].dice = MisRandom(); } else { Mev[STEP].dice = brandom(100) + 1; } Mev[STEP].rnum = brandom(10000); // reroll failure type Mev[STEP].trace = STEP; } } if (Mev[STEP].Name[0] == 'A' || Mev[STEP].StepInfo == 9 || Mev[STEP].StepInfo == 19) { STEP = Mev[STEP].trace; } else { if (Mev[STEP].trace != 0) { STEP = Mev[STEP].trace; } else { Mev[STEP].trace = STEP + 1; STEP++; } } // Duration Hack Part 2 of 3 (set up durx for duration use) if ((Mev[STEP].loc == 27 || Mev[STEP].loc == 28) && durx == -1) { durx = durxx - 1; Data->P[plr].Mission[MPad + Mev[STEP].pad].Duration = 2; } if (Mev[STEP].Name[0] == 'A') { display::graphics.setForegroundColor(11); if (!AI[plr] && !fullscreenMissionPlayback) { if (plr == 0) { x = 5; y = 112; fill_rectangle(2, 107, 140, 115, 3); } else { x = 82, y = 8; fill_rectangle(78, 2, 241, 10, 3); } draw_string(x, y, "COUNTDOWN"); if (plr == 0) { fill_rectangle(188, 107, 294, 113, 3); display::graphics.setForegroundColor(1); draw_string(190, 112, (Mev[STEP].pad == 0) ? "PRIMARY LAUNCH" : "SECOND LAUNCH"); } else { fill_rectangle(244, 56, 314, 62, 3); display::graphics.setForegroundColor(1); draw_string(246, 61, (Mev[STEP].pad == 0) ? "PRIMARY PAD" : "SECOND PAD"); } } memset(Name, 0x00, sizeof Name); strcpy(Name, Mev[STEP].Name); Name[0] = '#'; // Launch Code PlaySequence(plr, STEP, Name, 0); // Special Case #47236 }; // Necessary to keep code from crashing on bogus mission step while (Mev[STEP].E == NULL) { STEP++; } // Draw Mission Step Name if (!AI[plr] && !fullscreenMissionPlayback) { if (!(fEarly && STEP != 0)) { if (plr == 0) { x = 5; y = 112; fill_rectangle(2, 107, 140, 115, 3); } else { x = 82, y = 8; fill_rectangle(78, 2, 241, 10, 3); } display::graphics.setForegroundColor(11); MisStep(x, y, Mev[STEP].loc); if (plr == 0) { fill_rectangle(188, 107, 294, 113, 3); display::graphics.setForegroundColor(1); draw_string(190, 112, (Mev[STEP].pad == 0) ? "PRIMARY LAUNCH" : "SECOND LAUNCH"); } else { fill_rectangle(244, 56, 314, 62, 3); display::graphics.setForegroundColor(1); draw_string(246, 61, (Mev[STEP].pad == 0) ? "PRIMARY PAD" : "SECOND PAD"); } } } // SAFETY FACTOR STUFF safety = Mev[STEP].E->MisSaf; if ((Mev[STEP].Name[0] == 'A') && MH[Mev[STEP].pad][7] != NULL) { // boosters involved safety = RocketBoosterSafety(safety, MH[Mev[STEP].pad][7]->Safety); } // Duration Hack Part 3 of 3 if (Mev[STEP].loc == 28 || Mev[STEP].loc == 27) { safety = Mev[STEP].E->MisSaf; // needs to be for both if (InSpace == 2) { safety = (MH[0][0]->MisSaf + MH[1][0]->MisSaf) / 2; //joints } } if (strncmp(Mev[STEP].E->Name, "DO", 2) == 0) { if (Mev[STEP].loc == 1 || Mev[STEP].loc == 2) { safety = Mev[STEP].E->MSF; } } val = Mev[STEP].dice; safety += Mev[STEP].asf; if (safety >= 100) { safety = 99; } save = (Mev[STEP].E->SaveCard == 1) ? 1 : 0; PROBLEM = val > safety; if (!AI[plr] && options.want_cheats) { PROBLEM = 0; } DEBUG6("step %c:%s safety %d rolled %d%s", Mev[STEP].Name[0], S_Name[Mev[STEP].loc], safety, val, PROBLEM ? " problem" : (options.want_cheats ? " cheating" : "")); if (!AI[plr] && !fullscreenMissionPlayback) if (!(fEarly && STEP != 0)) { lc = MCGraph(plr, lc, MAX(0, safety), MAX(0, val), PROBLEM); // Graph Chart } if (PROBLEM && save == 1) { // Failure Saved Mev[STEP].E->SaveCard--; // Deduct SCard PROBLEM = 0; // Fix problem } // Fix wrong anim thing for the Jt Durations if (Mev[STEP].loc == 28 || Mev[STEP].loc == 27) { strcpy(Mev[STEP].Name, (plr == 0) ? "_BUSC0\0" : "_BSVC0"); Mev[STEP].Name[5] = Mev[STEP].E->ID[1]; } if (PROBLEM == 1) { //Step Problem // for the unmanned mission if (MANNED[Mev[STEP].pad] == 0 && MANNED[other(Mev[STEP].pad)] == 0) { Mev[STEP].rnum = (-1) * (brandom(5) + 1); } // Unmanned also if (MANNED[Mev[STEP].pad] == 0 && noDock == 0) { Mev[STEP].rnum = (-1) * (brandom(5) + 1); } memset(&Now, 0x00, sizeof Now); //***************TC Special little HMOON EVA FAILURE FIX tomflag = 0; if (Mev[STEP].Name[0] == 'H' && Mev[STEP].Name[1] == 'M') { gork = Data->P[plr].Mission[mpad].Prog; if (gork == 2) { strcpy(Mev[STEP].Name, (plr == 0) ? "HUM3C1" : "HSM3C1"); } else if (gork == 3) { strcpy(Mev[STEP].Name, (plr == 0) ? "HUM3C2" : "HSM3C2"); } else { strcpy(Mev[STEP].Name, (plr == 0) ? "HUM3C3" : "HSM3C3"); } tomflag = 1; }; //:::::: Failure docking klugge if (Mev[STEP].Name[0] == 'I') { gork = Data->P[plr].Mission[mpad].Prog; if (gork == 2) { strcpy(Mev[STEP].Name, (plr == 0) ? "IUM4C1" : "ISM4C1"); } else if (gork == 3) { strcpy(Mev[STEP].Name, (plr == 0) ? "IUM4C2" : "ISM4C2"); } else { strcpy(Mev[STEP].Name, (plr == 0) ? "IUM4C3" : "ISM4C3"); } }; // *********** TOM's FAIL HMOON KLUDGE // if HMOON FAILURE if (tomflag) { GetFailStat(&Now, Mev[STEP].FName, 7595); } else { DEBUG3("Failing !tomflag - calling GetFailStat(&Now, Mev[STEP].FName %s, MEV[STEP].rnum %d))", Mev[STEP].FName, Mev[STEP].rnum); GetFailStat(&Now, Mev[STEP].FName, Mev[STEP].rnum); // all others } memset(Name, 0x00, sizeof Name); memcpy(Name, Mev[STEP].Name, strlen(Mev[STEP].Name)); // copy orig failure Name[strlen(Name)] = 0x30 + (Now.fail / 10); Name[strlen(Name)] = 0x30 + Now.fail % 10; Name[strlen(Name)] = 0x00; //:::::: STEP FAILURE ::::::::: //::::::::::::::::::::::::::::: PlaySequence(plr, STEP, Name, 1); if (!AI[plr]) { Tick(2); //reset dials } FailEval(plr, Now.code, Now.text, Now.val, Now.xtra); } else { // Step Success if (Mev[STEP].loc == 28 || Mev[STEP].loc == 27) { strcpy(Mev[STEP].Name, (plr == 0) ? "bUC0" : "bSC0"); Mev[STEP].Name[5] = Mev[STEP].E->ID[1]; } if (strncmp(Mev[STEP].E->Name, "DO", 2) == 0) { if (Mev[STEP].loc == 2) { Data->P[plr].DockingModuleInOrbit = 2; } } //:::::::::::::::::::::::::::::::::: //::: SUCCESS: Docking klugge :::::: //:::::::::::::::::::::::::::::::::: if (Mev[STEP].Name[0] == 'I') { gork = Data->P[plr].Mission[mpad].Prog; if (gork == 2) { strcpy(Mev[STEP].Name, (plr == 0) ? "IUM4C1" : "ISM4C1"); } else if (gork == 3) { strcpy(Mev[STEP].Name, (plr == 0) ? "IUM4C2" : "ISM4C2"); } else { strcpy(Mev[STEP].Name, (plr == 0) ? "IUM4C3" : "ISM4C3"); } }; if (Mev[STEP].Name[0] == 'e' && Data->P[plr].Mission[mpad].MissionCode == Mission_LunarFlyby) { strcpy(Mev[STEP].Name, (plr == 0) ? "VUP1" : "VSP1"); } //:::::: STEP SUCCESS ::::::::: //::::::::::::::::::::::::::::: // FemaleAstronautsAllowed step klugge // third parameter (0 -> MALE) (2 -> FEMALE) //::::::::::::::::::::::::::::: gork = ((MA[0][0].A != NULL && MA[0][0].A->Sex && EVA[0] == 0) || (MA[0][1].A != NULL && MA[0][1].A->Sex && EVA[0] == 1) || (MA[0][2].A != NULL && MA[0][2].A->Sex && EVA[0] == 2) || (MA[0][3].A != NULL && MA[0][3].A->Sex && EVA[0] == 3) || (MA[1][0].A != NULL && MA[1][0].A->Sex && EVA[1] == 0) || (MA[1][1].A != NULL && MA[1][1].A->Sex && EVA[1] == 1) || (MA[1][2].A != NULL && MA[1][2].A->Sex && EVA[1] == 2) || (MA[1][3].A != NULL && MA[1][3].A->Sex && EVA[1] == 3)); //if (!((mcc==9 || mcc==11) && (Mev[STEP].Name[0]=='W'))) PlaySequence(plr, STEP, Mev[STEP].Name, (gork == 1) ? 2 : 0); // Play Animations if (Mev[STEP].sgoto == 100) { Mev[STEP].trace = 0x7F; } else if (Mev[STEP].sgoto != 0) { Mev[STEP].trace = Mev[STEP].sgoto; } else { Mev[STEP].trace = STEP + 1; } if (!(strncmp(Mev[STEP].E->Name, "DO", 2) == 0 && Mev[STEP].loc == 0x02)) { Mev[STEP].E->MisSucc++; // set for all but docking power on } Mev[STEP].StepInfo = 1; // Bottom of success statement } if (Mev[STEP].loc == 0x7f || Mev[STEP].sgoto == 100) { // force mission end Mev[STEP].trace = 0x7f; } if ((mcc == 10 || mcc == 12 || mcc == 13) && STEP == 2) { Mev[STEP].trace = 0x7f; } if (STEP > 30 || STEP < 0) { delay(20); } if (Mev[STEP].Prest != 0) { pAry[pCnt++] = STEP; } if (Mev[STEP].sgoto == Mev[STEP].fgoto && Mev[STEP].trace != 0x7f) { Mev[STEP].trace = Mev[STEP].sgoto; } if (Mev[STEP].loc == 8 && Mev[STEP].StepInfo == 1) { noDock = 1; } if (Mev[STEP].loc == 0 && MANNED[Mev[STEP].pad] > 0) { InSpace++; } if (Mev[STEP].loc == 4 && MANNED[Mev[STEP].pad] > 0) { InSpace--; } // these two lines fix a problem with Lab Missions failing on launch and // ending the mission. // Yet another in the ongoing series of special cases. // if (Mev[STEP].trace == 0x7f && STEP == 3) { switch (Mis.Index) { case 19: case 22: case 23: case 30: case 32: case 35: case 36: case 37: InSpace = 1; Mev[STEP].trace = Mev[STEP].dgoto; default: break; } } // if (Mev[STEP].trace==0x7f && InSpace>0) Mev[STEP].trace=STEP+1; } while (Mev[STEP].trace != 0x7f); // End mission //end do if (!AI[plr] && death == 0) { delay(1000); } if ((MA[0][0].A != NULL && MA[0][0].A->Status == AST_ST_DEAD) || (MA[0][1].A != NULL && MA[0][1].A->Status == AST_ST_DEAD) || (MA[0][2].A != NULL && MA[0][2].A->Status == AST_ST_DEAD) || (MA[0][3].A != NULL && MA[0][3].A->Status == AST_ST_DEAD) || (MA[1][0].A != NULL && MA[1][0].A->Status == AST_ST_DEAD) || (MA[1][1].A != NULL && MA[1][1].A->Status == AST_ST_DEAD) || (MA[1][2].A != NULL && MA[1][2].A->Status == AST_ST_DEAD) || (MA[1][3].A != NULL && MA[1][3].A->Status == AST_ST_DEAD)) { // Mission Death if (!AI[plr]) { if (!fullscreenMissionPlayback) { display::AutoPal p(display::graphics.legacyScreen()); memset(&p.pal[64 * 3], 0x00, 64 * 3); //Specs: 0x08 if (plr == 0) { fill_rectangle(2, 107, 140, 115, 3); } else { fill_rectangle(78, 2, 241, 10, 3); } if (plr == 0) { fill_rectangle(188, 107, 294, 113, 3); } else { fill_rectangle(244, 56, 314, 62, 3); } } PlaySequence(plr, STEP, (plr == 0) ? "UFUN" : "SFUN", 0); } if (!AI[plr]) { delay(1000); } death = 1; } else { death = 0; }; return; }
void Future(char plr) { /** \todo the whole Future()-function is 500 >lines and unreadable */ TRACE1("->Future(plr)"); int MisNum = 0, DuraType = 0, MaxDur = 6, i, ii; int setting = -1, prev_setting = -1; int Ok, NewType; GXHEADER local, local2; GV(&local, 166, 9); GV(&local2, 177, 197); GV(&vh,240,90); /* global variable */ begfut: MisNum = FutureCheck(plr, 0); if (MisNum == 5) { DV(&local); DV(&local2); DV(&vh); return; } F1 = F2 = F3 = F4 = FMen = F5 = 0; // memset(buffer, 0x00, 20000); for (i = 0; i < 5; i++) lck[i] = status[i] = 0; SetParameters(); strcpy(IDT, "i011"); Pad = MisNum; DuraType = FMen = MisType = 0; ClrFut(plr, MisNum); DrawFuture(plr, MisType, MisNum); begfut_noredraw: // for (i=0;i<5;i++) ClearRX(i+1); while (1) { GetMouse(); if (mousebuttons == 0) break; } while (1) { GetMouse(); prev_setting = setting; setting = -1; if (key == '-' && SEG > 1) SEG--; if (key == '+' && SEG < 500) SEG++; if (key >= 65 && key < Bub_Count + 65) setting = key - 65; for (ii = 0; ii < Bub_Count; ii++) { if (x >= StepBub[ii].x_cor && x <= StepBub[ii].x_cor + 7 && y >= StepBub[ii].y_cor && y <= StepBub[ii].y_cor + 7) setting = ii; } if (setting >= 0) { if (prev_setting < 0) gxGetImage(&local, 18, 186, 183, 194, 0); if (prev_setting != setting) { ShBox(18, 186, 183, 194); grSetColor(1); MisStep(21, 192, Mev[setting].loc); } } else if (setting < 0 && prev_setting >= 0) { gxPutImage(&local, gxSET, 18, 186, 0); } if (Mis.Dur <= V[MisType].E && ((x >= 244 && y >= 5 && x <= 313 && y <= 17 && mousebuttons > 0) || key == K_ENTER)) { InBox(244, 5, 313, 17); WaitForMouseUp(); if (key > 0) delay(300); key = 0; OutBox(244, 5, 313, 17); gxGetImage(&local2, 74, 3, 250, 199, 0); NewType = V[MisType].X; Data->P[plr].Future[MisNum].Duration = DuraType; Ok = HardCrewAssign(plr, Pad, MisType, NewType); gxPutImage(&local2, gxSET, 74, 3, 0); // DV(&local2); if (Ok == 1) { Data->P[plr].Future[MisNum].Duration = DuraType; goto begfut; // return to loop } else { ClrFut(plr, MisNum); // DuraType = FMen = MisType = 0; key = 0; goto begfut_noredraw; // DrawFuture(plr, MisType, MisNum); } key = 0; }; // continue if ((((x >= 5 && y >= 49 && x <= 53 && y <= 72) || (x >= 43 && y >= 74 && x <= 53 && y <= 82)) && mousebuttons > 0) || (key == '!' || key == '1')) { if ((x >= 43 && y >= 74 && x <= 53 && y <= 82) || key == '!') { lck[0] = abs(lck[0] - 1); if (lck[0] == 1) InBox(43, 74, 53, 82); else OutBox(43, 74, 53, 82); if (lck[0] == 1) F5 = (status[0] == 0) ? -1 : status[0]; if (lck[0] == 1) PlaceRX(1); else ClearRX(1); if (lck[0] == 0) { F5 = 0; status[0] = 0; } while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[0] != 1) { InBox(5, 49, 53, 72); if (DuraType == MaxDur) DuraType = 0; else DuraType++; Data->P[plr].Future[MisNum].Duration = DuraType; if (DuraType == 0) Toggle(5, 0); else if (DuraType == 1) Toggle(5, 1); if (DuraType != 0) draw_Pie(DuraType); status[0] = DuraType; while (1) { GetMouse(); if (mousebuttons == 0) break; } grSetColor(34); OutBox(5, 49, 53, 72); }; key = 0; /* Duration */ }; if ((x >= 5 && y >= 74 && x <= 41 && y <= 82 && mousebuttons > 0) || (key == K_ESCAPE)) { InBox(5, 74, 41, 82); while (1) { GetMouse(); if (mousebuttons == 0) break; } MisType = 0; if (DuraType != 0) Toggle(5, 0); FMen = DuraType = F1 = F2 = F3 = F4 = F5 = 0; for (i = 1; i < 4; i++) if (status[i] != 0) Toggle(i, 1); if (JointFlag == 0) { F4 = 2; lck[4] = 1; Toggle(4, 1); InBox(191, 74, 201, 82); PlaceRX(5); TogBox(166, 49, 1); } else { F4 = 0; lck[4] = 0; status[4] = 0; Toggle(4, 1); OutBox(191, 74, 201, 82); ClearRX(5); TogBox(166, 49, 0); }; for (i = 0; i < 4; i++) { lck[i] = status[i] = 0; } OutBox(5, 49, 53, 72); OutBox(43, 74, 53, 82); TogBox(55, 49, 0); OutBox(80, 74, 90, 82); TogBox(92, 49, 0); OutBox(117, 74, 127, 82); TogBox(129, 49, 0); OutBox(154, 74, 164, 82); ClrFut(plr, MisNum); Data->P[plr].Future[MisNum].Duration = 0; Missions(plr, 8, 37, MisType, 1); GetMinus(plr); OutBox(5, 74, 41, 82); key = 0; /* Reset */ }; if ((x >= 55 && y >= 49 && x <= 90 && y <= 82 && mousebuttons > 0) || (key == '2' || key == '@')) { if ((x >= 80 && y >= 74 && x <= 90 && y <= 82) || (key == '@')) { if (lck[1] == 0) InBox(80, 74, 90, 82); else OutBox(80, 74, 90, 82); lck[1] = abs(lck[1] - 1); if (lck[1] == 1) PlaceRX(2); else ClearRX(2); if ((status[1] == 0) && (lck[1] == 1)) F1 = 2; else if ((status[1] == 1) && (lck[1] == 1)) F1 = 1; else F1 = 0; while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[1] != 1) { TogBox(55, 49, 1); if (status[1] == 0) Toggle(1, 1); else Toggle(1, 0); status[1] = abs(status[1] - 1); while (1) { GetMouse(); if (mousebuttons == 0) break; } TogBox(55, 49, 0); }; /* Docking */ key = 0; }; if ((x >= 92 && y >= 49 && x <= 127 && y <= 82 && mousebuttons > 0) || (key == '3' || key == '#')) { if ((x >= 117 && y >= 74 && x <= 127 && y <= 82) || (key == '#')) { if (lck[2] == 0) InBox(117, 74, 127, 82); else OutBox(117, 74, 127, 82); lck[2] = abs(lck[2] - 1); if (lck[2] == 1) PlaceRX(3); else ClearRX(3); if ((status[2] == 0) && (lck[2] == 1)) F2 = 2; else if ((status[2] == 1) && (lck[2] == 1)) F2 = 1; else F2 = 0; while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[2] != 1) { TogBox(92, 49, 1); if (status[2] == 0) Toggle(2, 1); else { Toggle(2, 0); }; status[2] = abs(status[2] - 1); while (1) { GetMouse(); if (mousebuttons == 0) break; } TogBox(92, 49, 0); }; /* EVA */ key = 0; }; if ((x >= 129 && y >= 49 && x <= 164 && y <= 82 && mousebuttons > 0) || (key == '4' || key == '$')) { if ((x >= 154 && y >= 74 && x <= 164 && y <= 82) || (key == '$')) { if (lck[3] == 0) InBox(154, 74, 164, 82); else OutBox(154, 74, 164, 82); lck[3] = abs(lck[3] - 1); // F3=lck[3]; if (lck[3] == 1) PlaceRX(4); else ClearRX(4); if ((status[3] == 0) && (lck[3] == 1)) F3 = 2; else if ((status[3] == 1) && (lck[3] == 1)) F3 = 1; else F3 = 0; while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[3] != 1) { TogBox(129, 49, 1); if (status[3] == 0) Toggle(3, 1); else { Toggle(3, 0); }; status[3] = abs(status[3] - 1); while (1) { GetMouse(); if (mousebuttons == 0) break; } TogBox(129, 49, 0); }; /* LEM */ key = 0; }; if (((x >= 166 && y >= 49 && x <= 201 && y <= 82 && mousebuttons > 0) || (key == '5' || key == '%')) && (JointFlag == 1)) { if ((x > 191 && y >= 74 && x <= 201 && y <= 82) || (key == '%')) { if (lck[4] == 0) InBox(191, 74, 201, 82); else OutBox(191, 74, 201, 82); lck[4] = abs(lck[4] - 1); if (lck[4] == 1) PlaceRX(5); else ClearRX(5); if ((status[4] == 0) && (lck[4] == 1)) F4 = 2; else if ((status[4] == 1) && (lck[4] == 1)) F4 = 1; else F4 = 0; while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[4] != 1) { TogBox(166, 49, 1); status[4] = abs(status[4] - 1); if (status[4] == 0) { Toggle(4, 1); } else { Toggle(4, 0); } while (1) { GetMouse(); if (mousebuttons == 0) break; } TogBox(166, 49, 0); }; /* Joint Launch */ key = 0; }; if ((x >= 5 && y >= 84 && x <= 16 && y <= 130 && mousebuttons > 0) || (key == UP_ARROW)) { InBox(5, 84, 16, 130); for (i = 0; i < 50; i++) { key = 0; GetMouse(); delay(10); if (mousebuttons == 0) { MisType = UpSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; i = 51; } } while (mousebuttons == 1 || key == UP_ARROW) { MisType = UpSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; delay(100); key = 0; GetMouse(); } Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; OutBox(5, 84, 16, 130); key = 0; /* Mission Type plus */ }; if ((x >= 5 && y >= 132 && x < 16 && y <= 146 && mousebuttons > 0) || (key == K_SPACE)) { InBox(5, 132, 16, 146); WaitForMouseUp(); delay(50); MisType = Data->P[plr].Future[MisNum].MissionCode; assert(0 <= MisType); if (MisType != 0){ Missions(plr, 8, 37, MisType, 1); } else{ Missions(plr, 8, 37, MisType, 3); } OutBox(5, 132, 16, 146); key = 0; } if ((x >= 5 && y >= 148 && x <= 16 && y <= 194 && mousebuttons > 0) || (key == DN_ARROW)) { InBox(5, 148, 16, 194); for (i = 0; i < 50; i++) { key = 0; GetMouse(); delay(10); if (mousebuttons == 0) { MisType = DownSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; i = 51; } key = 0; } while (mousebuttons == 1 || key == DN_ARROW) { MisType = DownSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; delay(100); key = 0; GetMouse(); } Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; OutBox(5, 148, 16, 194); key = 0; /* Mission Type minus */ }; } // while TRACE1("<-Future()"); }
/* The main control loop for the Future Missions feature. */ void Future(char plr) { /** \todo the whole Future()-function is 500 >lines and unreadable */ TRACE1("->Future(plr)"); int MisNum = 0, DuraType = 0, MaxDur = 6; int setting = -1, prev_setting = -1; display::LegacySurface local(166, 9); display::LegacySurface local2(177, 197); vh = new display::LegacySurface(240, 90); unsigned int year = Data->Year; unsigned int season = Data->Season; TRACE3("--- Setting year=Year (%d), season=Season (%d)", year, season); SetParameters(); MarsFlag = MarsInRange(year, season); JupiterFlag = JupiterInRange(year, season); SaturnFlag = SaturnInRange(year, season); while ((MisNum = FutureCheck(plr, 0)) != 5) { F1 = F2 = F3 = F4 = F5 = 0; for (int i = 0; i < 5; i++) { lock[i] = false; status[i] = 0; } keyHelpText = "k011"; helpText = "i011"; Pad = MisNum; DuraType = 0; MisType = 0; ClrFut(plr, MisNum); JointFlag = JointMissionOK(plr, MisNum); // initialize joint flag if (JointFlag == false) { F4 = 2; lock[4] = true; status[4] = 0; } DrawFuture(plr, MisType, MisNum); while (1) { key = 0; GetMouse(); prev_setting = setting; setting = -1; // SEG determines the number of control points used in creating // the B-splines for drawing the mission flight path. // The more control points, the smoother the path should // appear. if (key == '-' && SEG > 1) { SEG--; } else if (key == '+' && SEG < 500) { SEG++; } else if (key >= 65 && key < Bub_Count + 65) { setting = key - 65; } // If the mouse is over one of the Mission Step bubbles, // display the step information. for (int i = 0; i < Bub_Count; i++) { if (x >= StepBub[i].x_cor && x <= StepBub[i].x_cor + 7 && y >= StepBub[i].y_cor && y <= StepBub[i].y_cor + 7) { setting = i; break; } } if (setting >= 0) { if (prev_setting < 0) { local.copyFrom(display::graphics.legacyScreen(), 18, 186, 183, 194); } if (prev_setting != setting) { ShBox(18, 186, 183, 194); display::graphics.setForegroundColor(1); MisStep(21, 192, Mev[setting].loc); } } else if (setting < 0 && prev_setting >= 0) { local.copyTo(display::graphics.legacyScreen(), 18, 186); } if (Mis.Dur <= V[MisType].E && ((x >= 244 && y >= 5 && x <= 313 && y <= 17 && mousebuttons > 0) || key == K_ENTER)) { InBox(244, 5, 313, 17); WaitForMouseUp(); if (key > 0) { delay(300); } key = 0; OutBox(244, 5, 313, 17); // Copy the screen contents to a buffer. If the mission // requires a capsule to be assigned, a pop-up will be // created listing the options. Once the pop-up is // dismissed the screen may be redrawn from the buffer. local2.copyFrom(display::graphics.legacyScreen(), 74, 3, 250, 199); int NewType = V[MisType].X; Data->P[plr].Future[MisNum].Duration = DuraType; int Ok = HardCrewAssign(plr, MisNum, MisType, NewType); local2.copyTo(display::graphics.legacyScreen(), 74, 3); if (Ok == 1) { Data->P[plr].Future[MisNum].Duration = DuraType; break; // return to launchpad loop } else { ClrFut(plr, MisNum); continue; } } else if ((x >= 43 && y >= 74 && x <= 53 && y <= 82 && mousebuttons > 0) || key == '!') { // Duration restriction lock lock[0] = (! lock[0]); if (lock[0] == true) { InBox(43, 74, 53, 82); PlaceRX(1); F5 = (status[0] == 0) ? -1 : status[0]; } else { OutBox(43, 74, 53, 82); ClearRX(1); F5 = status[0] = 0; } WaitForMouseUp(); } else if (lock[0] != true && ((x >= 5 && y >= 49 && x <= 53 && y <= 72 && mousebuttons > 0) || key == '1')) { // Duration toggle InBox(5, 49, 53, 72); if (DuraType == MaxDur) { DuraType = 0; } else { DuraType++; } Data->P[plr].Future[MisNum].Duration = DuraType; if (DuraType == 0) { Toggle(5, 0); } else if (DuraType == 1) { Toggle(5, 1); } if (DuraType != 0) { draw_Pie(DuraType); } status[0] = DuraType; WaitForMouseUp(); display::graphics.setForegroundColor(34); OutBox(5, 49, 53, 72); } else if ((x >= 5 && y >= 74 && x <= 41 && y <= 82 && mousebuttons > 0) || (key == K_ESCAPE)) { // Reset mission selection InBox(5, 74, 41, 82); WaitForMouseUp(); MisType = 0; DuraType = F1 = F2 = F3 = F4 = F5 = 0; for (int i = 0; i < 5; i++) { lock[i] = false; status[i] = 0; } if (JointFlag == false) { F4 = 2; lock[4] = true; InBox(191, 74, 201, 82); TogBox(166, 49, 1); } else { OutBox(191, 74, 201, 82); } OutBox(5, 49, 53, 72); OutBox(43, 74, 53, 82); OutBox(80, 74, 90, 82); OutBox(117, 74, 127, 82); OutBox(154, 74, 164, 82); ClrFut(plr, MisNum); Missions(plr, 8, 37, MisType, 1); GetMinus(plr); OutBox(5, 74, 41, 82); } else if ((x >= 80 && y >= 74 && x <= 90 && y <= 82 && mousebuttons > 0) || key == '@') { // Docking restriction lock lock[1] = (! lock[1]); if (lock[1] == true) { InBox(80, 74, 90, 82); PlaceRX(2); } else { OutBox(80, 74, 90, 82); ClearRX(2); } if ((status[1] == 0) && (lock[1] == true)) { F1 = 2; } else if ((status[1] == 1) && (lock[1] == true)) { F1 = 1; } else { F1 = 0; } WaitForMouseUp(); } else if (lock[1] == false && (((x >= 55 && y >= 49 && x <= 90 && y <= 82) && mousebuttons > 0) || key == '2')) { // Docking toggle TogBox(55, 49, 1); if (status[1] == 0) { Toggle(1, 1); } else { Toggle(1, 0); } status[1] = abs(status[1] - 1); WaitForMouseUp(); TogBox(55, 49, 0); } else if ((x >= 117 && y >= 74 && x <= 127 && y <= 82 && mousebuttons > 0) || key == '#') { // EVA Restriction button lock[2] = (! lock[2]); if (lock[2] == true) { InBox(117, 74, 127, 82); PlaceRX(3); } else { OutBox(117, 74, 127, 82); ClearRX(3); } if ((status[2] == 0) && (lock[2] == true)) { F2 = 2; } else if ((status[2] == 1) && (lock[2] == true)) { F2 = 1; } else { F2 = 0; } WaitForMouseUp(); } else if (lock[2] == false && ((x >= 92 && y >= 49 && x <= 127 && y <= 82 && mousebuttons > 0) || key == '3')) { // EVA toggle TogBox(92, 49, 1); if (status[2] == 0) { Toggle(2, 1); } else { Toggle(2, 0); } status[2] = abs(status[2] - 1); WaitForMouseUp(); TogBox(92, 49, 0); } else if ((x >= 154 && y >= 74 && x <= 164 && y <= 82 && mousebuttons > 0) || key == '$') { // Lunar Module Restriction button lock[3] = (! lock[3]); if (lock[3] == true) { InBox(154, 74, 164, 82); PlaceRX(4); } else { OutBox(154, 74, 164, 82); ClearRX(4); } if ((status[3] == 0) && (lock[3] == true)) { F3 = 2; } else if ((status[3] == 1) && (lock[3] == true)) { F3 = 1; } else { F3 = 0; } WaitForMouseUp(); } else if (lock[3] == false && ((x >= 129 && y >= 49 && x <= 164 && y <= 82 && mousebuttons > 0) || key == '4')) { // LEM toggle TogBox(129, 49, 1); if (status[3] == 0) { Toggle(3, 1); } else { Toggle(3, 0); } status[3] = abs(status[3] - 1); WaitForMouseUp(); TogBox(129, 49, 0); } else if (JointFlag == true && ((x > 191 && y >= 74 && x <= 201 && y <= 82 && mousebuttons > 0) || key == '%')) { // Joint Mission Restriction button lock[4] = (! lock[4]); if (lock[4] == true) { InBox(191, 74, 201, 82); PlaceRX(5); } else { OutBox(191, 74, 201, 82); ClearRX(5); } if ((status[4] == 0) && (lock[4] == true)) { F4 = 2; } else if ((status[4] == 1) && (lock[4] == true)) { F4 = 1; } else { F4 = 0; } WaitForMouseUp(); } else if (lock[4] == false && JointFlag == true && ((x >= 166 && y >= 49 && x <= 201 && y <= 82 && mousebuttons > 0) || key == '5')) { // Joint Mission TogBox(166, 49, 1); status[4] = abs(status[4] - 1); if (status[4] == 0) { Toggle(4, 1); } else { Toggle(4, 0); } WaitForMouseUp(); TogBox(166, 49, 0); } else if ((x >= 5 && y >= 84 && x <= 16 && y <= 130 && mousebuttons > 0) || (key == UP_ARROW)) { // Scroll up among Mission Types InBox(5, 84, 16, 130); for (int i = 0; i < 50; i++) { key = 0; GetMouse(); delay(10); if (mousebuttons == 0) { MisType = UpSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; i = 51; } } // Keep scrolling while mouse/key is held down. while (mousebuttons == 1 || key == UP_ARROW) { MisType = UpSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; Missions(plr, 8, 37, MisType, 3); delay(100); key = 0; GetMouse(); } Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; OutBox(5, 84, 16, 130); } else if ((x >= 5 && y >= 132 && x < 16 && y <= 146 && mousebuttons > 0) || (key == K_SPACE)) { // Turn on Mission Steps display InBox(5, 132, 16, 146); WaitForMouseUp(); delay(50); MisType = Data->P[plr].Future[MisNum].MissionCode; assert(0 <= MisType); if (MisType != 0) { Missions(plr, 8, 37, MisType, 1); } else { Missions(plr, 8, 37, MisType, 3); } OutBox(5, 132, 16, 146); } else if ((x >= 5 && y >= 148 && x <= 16 && y <= 194 && mousebuttons > 0) || (key == DN_ARROW)) { // Scroll down among Mission Types InBox(5, 148, 16, 194); for (int i = 0; i < 50; i++) { key = 0; GetMouse(); delay(10); if (mousebuttons == 0) { MisType = DownSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; i = 51; } } // Keep scrolling while mouse/key is held down. while (mousebuttons == 1 || key == DN_ARROW) { MisType = DownSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; Missions(plr, 8, 37, MisType, 3); delay(100); key = 0; GetMouse(); } Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; OutBox(5, 148, 16, 194); } } // Input while loop } // Launch pad selection loop delete vh; vh = NULL; TRACE1("<-Future()"); }