mc2.c

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005 Michael K. McCarty & Fritz Bronner
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 // Interplay's BUZZ ALDRIN's RACE into SPACE
00019 //
00020 // Formerly -=> LiftOff : Race to the Moon :: IBM version MCGA
00021 // Copyright 1991 by Strategic Visions, Inc.
00022 // Designed by Fritz Bronner
00023 // Programmed by Michael K McCarty
00024 //
00025 
00026 #include "Buzz_inc.h"
00027 #include "externs.h"
00028 #include "macros.h"
00029 
00030   extern Equipment *MH[2][8];   // Pointer to the main
00031   //struct MisHard *MH; //[2][7]
00032   extern struct MisAst MA[2][4];  //[2][4]
00033   extern struct MisEval Mev[60];  // was *Mev;
00034   extern struct mStr Mis;
00035   extern struct MXM *AList;
00036   extern REPLAY Rep;
00037   extern char MANNED[2],CAP[2],LM[2],DOC[2],EVA[2],STEP,FINAL,JOINT,pal2[768],PastBANG;
00038   extern char STEPnum,AI[2];
00039 
00040   extern char DMFake;
00041 
00042 //********************************************************************
00043 // Set up for the Mission
00044 // Routines used by MControl and Future Missions
00045 
00046 void MissionCodes(char plr,char val,char pad)
00047 {
00048   GetMisType(val);
00049   MissionParse(plr,Mis.Code,Mis.Alt,pad);
00050   return;
00051 }
00052 
00053 void
00054 MissionParse(char plr, char *MCode, char *LCode, char pad)
00055 {
00056     int i, loc, j;
00057 
00058     STEP = 0;
00059     loc = pad;
00060     for (i = 0; MCode[i] != '|'; ++i)
00061     {
00062         switch (MCode[i])
00063         {
00064             case '@':
00065                 i++;
00066                 MCode[i] = 'b';    // duration step
00067                 MissionSteps(plr, MCode[i], LCode[STEP], STEP, loc - pad);
00068                 break;
00069             case '~':              //printf("      :Delay of %d seasons\n",MCode[i+1]-0x30);
00070                 for (j = 0; j < (MCode[i + 1] - 0x30); j++)
00071                     MissionSteps(plr, MCode[i + 2], LCode[STEP], STEP,
00072                         loc - pad);
00073                 i += 2;
00074                 break;
00075             case '+':
00076                 i++;
00077                 loc = MCode[i] - 0x30 + pad - 1;
00078                 break;
00079             case '^':
00080                 loc = pad + 1;
00081                 break;
00082             case '&':
00083                 loc = pad;
00084                 break;
00085             case '%':
00086                 i++;
00087                 MCode[i] = 'c';
00088                 MissionSteps(plr, MCode[i], LCode[STEP], STEP, loc - pad);
00089                 break;
00090             case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
00091             case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
00092             case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
00093             case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'a': case 'b':
00094             case 'c': case 'd': case 'e': case 'f': case 'g': case '!':
00095                 if (MCode[i] == 'I')
00096                     loc = pad;
00097                 MissionSteps(plr, MCode[i], LCode[STEP], STEP, loc - pad);
00098                 break;
00099             default:
00100                 break;
00101         };                         /* End of Switch */
00102     };
00103     return;
00104 }
00105 
00106 
00107 char WhichPart(char plr,int which)
00108 {
00109    int val=0;
00110    if (Data->Prestige[abs(which)].Place==-1) val=1;
00111    else if (Data->Prestige[abs(which)].mPlace==-1
00112      && Data->Prestige[abs(which)].Place!=plr)
00113       val=2;
00114    else val=3;
00115    return val;
00116 }
00117 
00118 void MissionSteps(char plr,int mcode,int Mgoto,int step,int pad)
00119 {
00120   switch(mcode) {
00121      // Booster Programs    :: VAB order for the class
00122     case 'A':
00123           Mev[step].Class=4;
00124           break;
00125      // Manned Programs : Capsule
00126     case 'D': case 'E': case 'F': case 'G': case 'K':
00127     case 'M': case 'N': case 'O': case 'X': case 'Y':
00128     case 'f': case 'g':
00129         if (MH[pad][1] && MH[pad][1]->ID[1]==0x32) Mev[step].Class=1;       // Kicker-C
00130           else Mev[step].Class=0;
00131           break;
00132     case 'b': case 'c':   // Duration Step
00133               Mev[step].Class=10;
00134               break;
00135      // Manned Programs : LM
00136     case 'a':
00137           Mev[step].Class=2;                                 // LM
00138           break;
00139      // Unmanned Programs
00140     case 'C':
00141          if (MH[pad][1] && MH[pad][1]->ID[1]==0x32) Mev[step].Class=1;       // Kicker-C
00142          else if (MH[pad][2] && MH[pad][2]!=NULL) Mev[step].Class=2;
00143          else Mev[step].Class=3;
00144           break;
00145     case 'V': case 'W': case 'Z': case 'e':
00146           Mev[step].Class=3;                                 // Satellite
00147           break;
00148      // Misc Programs
00149     case 'H': case 'P': 
00150           Mev[step].Class=5;                                 // EVA Suits
00151           break;
00152      // Photo Recon
00153     case 'U': Mev[step].Class=6;                            // Photo Recon
00154           break;
00155      // Special Cases (when is there not one?)
00156     case 'B': case 'J': case 'L':
00157           if (MH[pad][1]!=NULL) Mev[step].Class=1;      // Kicker
00158           else if (MH[pad][0]!=NULL) Mev[step].Class=0;   // Cap
00159          else if (MH[pad][2]!=NULL) Mev[step].Class=2; // LM
00160            else Mev[step].Class=3;                            // Satelite
00161          if (step>11 && MH[pad][0]!=NULL) Mev[step].Class=0; // Cap L->E
00162           break;
00163     case 'Q': case 'R': case 'S': case 'T':
00164          if (MH[pad][1] && MH[pad][1]->ID[1]==0x32) Mev[step].Class=1;       // Kicker-C
00165          else if (MH[pad][2]!=NULL) Mev[step].Class=2; // LM
00166          else if (MH[pad][0]!=NULL) Mev[step].Class=0; // Capsule
00167          else Mev[step].Class=3;                            // Satellite
00168          break;
00169     case 'I':
00170          if (MH[pad][3]!=NULL) Mev[step].Class=3;      // DM
00171           else Mev[step].Class=2;                            // Satellite
00172           break;
00173     case 'd': //Special
00174     default: break;
00175   };
00176 
00177   Mev[step].Prest=-100;
00178   
00179   switch(mcode) {
00180    case 'B': if (MH[pad][0]!=NULL) 
00181                Mev[step].PComp=WhichPart(plr,Mev[step].Prest=-18);  // CAP
00182              else Mev[step].Prest=-100;Mev[step].PComp=0;
00183              break;
00184    case 'C': if (MH[pad][3] && MH[pad][3]->ID[1]==0x30) Mev[step].Prest=0;
00185              else Mev[step].Prest=-100;
00186              break;
00187    case 'E': Mev[step].PComp=WhichPart(plr,Mev[step].Prest=-27); break;
00188    case 'H': Mev[step].PComp=WhichPart(plr,Mev[step].Prest=26); break;
00189    case 'I': if ((MANNED[0]+MANNED[1])>0) Mev[step].PComp=WhichPart(plr,Mev[step].Prest=24); break;
00190    case 'M': Mev[step].PComp=WhichPart(plr,Mev[step].Prest=-20); break;
00191    case 'O': Mev[step].PComp=WhichPart(plr,Mev[step].Prest=-19); break;
00192    case 'P': Mev[step].PComp=WhichPart(plr,Mev[step].Prest=26); break;
00193    case 'S': if (MH[pad][3] && MH[pad][3]->ID[1]==0x32)
00194                Mev[step].PComp=WhichPart(plr,Mev[step].Prest=-7);
00195              break;
00196    case 'T': // Done on lunar launch for good reason
00197              Mev[step].PComp=WhichPart(plr,Mev[step].Prest=-22);
00198              break;
00199    case 'W':
00200              switch(Data->P[plr].Mission[pad].MissionCode) {
00201                case  7: Mev[step].PComp=WhichPart(plr,Mev[step].Prest=-1);break;
00202                case 11: Mev[step].PComp=WhichPart(plr,Mev[step].Prest=2);break;
00203                case  9: Mev[step].PComp=WhichPart(plr,Mev[step].Prest=3);break;
00204                case 10: Mev[step].PComp=WhichPart(plr,Mev[step].Prest=4);break;
00205                case 12: Mev[step].PComp=WhichPart(plr,Mev[step].Prest=5);break;
00206                case 13: Mev[step].PComp=WhichPart(plr,Mev[step].Prest=6);break;
00207                }
00208              break;
00209    default:  Mev[step].Prest=-100;Mev[step].PComp=0;break;
00210    }
00211 
00212    if (Mev[step].Prest!=-100) Mev[step].PComp=WhichPart(plr,Mev[step].Prest);
00213 
00214    if (PastBANG==1 && Mev[step].PComp>0) Mev[step].PComp=5;
00215 
00216    if (mcode=='d') {
00217      if (Mgoto==0) Mev[step-1].sgoto=Mev[step-1].fgoto=100;
00218      else Mev[step-1].sgoto=Mev[step-1].fgoto=Mgoto;
00219    }
00220    else {
00221       Mev[step].asf=0;
00222       if (MANNED[pad]>0)
00223           switch(Mev[step].Class) {
00224              case 0:  // capsule
00225                  Mev[step].ast=CAP[pad]; // index into MA
00226                  if (Mev[step].ast >= 0)
00227                      Mev[step].asf=MA[pad][Mev[step].ast].A->Cap;
00228                 break;
00229              case 2:  // lm
00230                   Mev[step].ast=LM[pad]; // index into MA
00231                   if (Mev[step].ast >= 0)
00232                       Mev[step].asf=MA[pad][Mev[step].ast].A->LM;
00233                break;
00234              case 3:  // docking
00235                   Mev[step].ast=DOC[pad]; // index into MA
00236                   if (Mev[step].ast >= 0)
00237                       Mev[step].asf=MA[pad][Mev[step].ast].A->Docking;
00238                break;
00239              case 5:  // eva
00240                   Mev[step].ast=EVA[pad]; // index into MA
00241                   if (Mev[step].ast >= 0)
00242                       Mev[step].asf=MA[pad][Mev[step].ast].A->EVA;
00243                break;
00244              case 7:  // covers power on for docking module
00245                Mev[step].ast=-1;
00246                Mev[step].asf=0;
00247                break;
00248              case 10: // durations
00249                Mev[step].Class=0;
00250                 Mev[step].ast=-1;
00251                Mev[step].asf=0;
00252                 break;
00253              default: // remaining
00254                Mev[step].ast=-1;
00255                Mev[step].asf=0;
00256                break;
00257          };
00258 
00259 
00260 //      if (step==0 && Data->P[plr].TurnOnly==5)
00261 //         *Mev[step].sf=minn(*Mev[step].sf,50);
00262 
00263       Mev[step].step=step;
00264 
00265       if ((Data->Def.Lev1==0 && plr==0) || (Data->Def.Lev2==0 && plr==1))
00266         Mev[STEP].dice=MisRandom();
00267       else Mev[STEP].dice=random((AI[plr])?98:100)+1;
00268 
00269       Mev[step].rnum=random(10000)+1;
00270       Mev[step].sgoto=0;
00271 
00272       Mev[step].fgoto=(Mgoto==-2) ? step+1 : Mgoto;  // prevents mission looping
00273       Mev[step].dgoto=Mis.AltD[STEP];  // death branching (tm)
00274       Mev[step].E=MH[pad][Mev[step].Class];
00275 
00276       Mev[step].pad=pad;
00277 
00278       memset(&Mev[step].Name[0],0x00,sizeof(Mev[step].Name));
00279 
00280       if (mcode=='Q' && Mev[step-1].loc==18) {
00281          Mev[step].Name[0]='h';
00282          }
00283       else {
00284          if (mcode>='a' && mcode<'z') {
00285             Mev[step].Name[0]=mcode;
00286             }
00287          else Mev[step].Name[strlen(Mev[step].Name)]=mcode;
00288          }
00289 
00290       VerifyData();
00291       if (plr==0) strcat(Mev[step].Name,"U\0");
00292       else strcat(Mev[step].Name,"S\0");
00293 
00294       if (MH[pad][Mev[step].Class])
00295           strncat(Mev[step].Name,MH[pad][Mev[step].Class]->ID,2);
00296 
00297      /////////////////////////////////////////////////
00298      // Fix for BARIS CD-ROM Planetary Steps (Step W)
00299      // E=moon ; M= mars ;S = saturn; V=venus; J= jupiter  R= Mercury
00300      // Must be at .Name[2]
00301      //
00302 
00303      if (Mev[step].Name[0]=='W') Mev[step].Name[2]='*';  // Placeholder
00304 
00305 #if 0
00306         Mev[step].Name[2]='R';  // Mercury
00307         Mev[step].Name[2]='V';  // Venus
00308         Mev[step].Name[2]='E';  // Earth
00309         Mev[step].Name[2]='M';  // Mars
00310         Mev[step].Name[2]='J';  // Juptier
00311         Mev[step].Name[2]='S';  // Saturn
00312 #endif
00313 
00314 
00315       if (Mev[step].Class==5) {
00316          if (MH[0][1] && MH[0][1]->ID[1]==0x32) strncat(Mev[step].Name,"M2",2); //Kicker C
00317          else if (MH[pad][0] && MH[pad][0]->ID[1]==0x34) strncat(Mev[step].Name,"C4",2); // FourMan
00318          else {  // standard LMs
00319             if (mcode=='P') {
00320                if (MH[pad][2]!=NULL) strncat(Mev[step].Name,MH[pad][2]->ID,2);
00321                else if(MH[1][2]) strncat(Mev[step].Name,MH[1][2]->ID,2);
00322                }
00323             else {
00324                if (MH[pad][0]!=NULL) strncat(Mev[step].Name,MH[pad][0]->ID,2);
00325                else if(MH[1][0]) strncat(Mev[step].Name,MH[1][0]->ID,2);
00326                }
00327             }
00328          }
00329     if (Mev[step].Name[0]=='A' && MH[pad][7]!=NULL) Mev[step].Name[3]+=4;
00330 
00331     // Special Cases #54753 and #54754
00332 
00333     if (mcode=='H'&& Data->P[plr].Mission[pad].MissionCode==50 ) strcpy(Mev[step].Name,"HMOON\0");
00334     if (mcode=='H'&& PastBANG==1) strcpy(Mev[step].Name,"HMOON\0");
00335 
00336     if (mcode == '!' || mcode == '|')
00337     {
00338         Mev[step].loc = 0x7f;
00339         if (step > 0)
00340             Mev[step - 1].sgoto = 100;
00341         PastBANG = 1;
00342     }
00343     else
00344     {
00345         Mev[step].loc = mcode - 65;
00346         if (Mev[step].loc > 25)
00347             Mev[step].loc -= 6;
00348     }
00349   }
00350 
00351   // name the mission step for failures.
00352 
00353   strcpy(Mev[step].FName,"F000\0");
00354 
00355   Mev[step].FName[3]=(char) 0x30+(Mev[step].loc%10);
00356   if (Mev[step].loc>=10) Mev[step].FName[2]='1';
00357   if (Mev[step].loc>=20) Mev[step].FName[2]='2';
00358   if (Mev[step].loc>=30) Mev[step].FName[2]='3';
00359   
00360   if (Mev[step].loc==32) {  // Fix _g special case #48010
00361    Mev[step].FName[2]='0';
00362    Mev[step].FName[3]='1';
00363    }
00364 
00365   // Special Cases for the Failure Mode Charts
00366    if ((Mev[step].loc==0) &&  // MS Failure Launch
00367      MH[pad][Mev[step].Class] &&
00368      strncmp(Data->P[plr].Manned[3].Name,MH[pad][Mev[step].Class]->Name,5)==0)
00369       Mev[step].FName[1]='1';
00370    else if (Mev[step].loc==4 &&   // MS Failure Landing
00371      MH[pad][Mev[step].Class] &&
00372      strncmp(Data->P[plr].Manned[3].Name,MH[pad][Mev[step].Class]->Name,5)==0)
00373       Mev[step].FName[1]='3';
00374    else if (plr==1 && Mev[step].loc==4) {
00375       if ((Mev[step].loc==4) &&  // Soviet Capsules : Vostok
00376        MH[pad][Mev[step].Class] &&
00377        strncmp(Data->P[plr].Manned[0].Name,MH[pad][Mev[step].Class]->Name,5)==0)
00378          Mev[step].FName[1]='1';
00379       else Mev[step].FName[1]='2'; // Other Capsules
00380       }
00381 
00382 
00383    // New expanded cases for failure mode charts
00384    if (Mev[step].Name[3]=='C' && Mev[step].loc==2) Mev[step].FName[1]='1';
00385 
00386    if (strncmp(&Mev[step].Name[2],"M3C0",4)==0)
00387      Mev[step].FName[1]='1';
00388 
00389   if (Mev[step].FName[3]!='P') {   // exclude any probe's
00390    if (Mev[step].loc==15 && Mev[step].Name[6]==0x36) Mev[step].FName[1]='1';
00391 
00392    if (Mev[step].loc==16 && STEP>8) {
00393      if (Mev[step-1].loc==18 && Mev[step].Name[4]>=0x35) Mev[step].FName[1]='2';
00394      else if (Mev[step-1].loc==18 && Mev[step].Name[4]<=0x34) Mev[step].FName[1]='3';
00395      else Mev[step].FName[1]='1';
00396    }
00397 
00398    if ((Mev[step].loc>=17 && Mev[step].loc<=19) && (Mev[step].Name[4]<=0x34))
00399      Mev[step].FName[1]='1';
00400 
00401    //if (Mev[step].loc==18 && Mev[step].Name[3]=='P') Mev[step].FName[1]='0';
00402 
00403    if (Mev[step].loc==18 && (Mev[step].Name[3]!='4' && Mev[step].Name[2]!='M')) Mev[step].FName[1]='0';
00404 
00405 
00406    if (Mev[step].loc==20 && (Mev[step].Name[4]==0x34 || Mev[step].Name[4]==0x33))
00407      Mev[step].FName[1]='1';  
00408 
00409    Mev[step].StepInfo=0;
00410 
00411   }
00412   //if (mcode!='d') 
00413   STEP++;
00414   return;
00415 };
00416 
00417 void MisPrt(void)
00418 {
00419   int i;
00420   for (i=0;i<STEP-1;i++) { Mev[i].dice=100;
00421     Mev[0].E->MisSaf=5;
00422     Mev[0].rnum=9999;
00423   } 
00424   return;
00425 };
00426 
00427 void MissionSetup(char plr,char mis)
00428 {
00429 char i,j,t;
00430   DMFake=0;
00431   GetMisType(Data->P[plr].Mission[mis].MissionCode);
00432 
00433   for(j=0;j<(1+Data->P[plr].Mission[mis].Joint);j++) {
00434 
00435     if ((Mis.mVab[j] & 0x10)>0 && Data->P[plr].DMod>0) { // DMO
00436       Data->P[plr].Mission[mis+j].Hard[Mission_Probe_DM]=4;
00437       DMFake=1;
00438       }
00439     if (j==0) {   // Apollo (1)  + LM (1)
00440       if (Data->P[plr].Mission[mis].Hard[Mission_Capsule]==2 && Data->P[plr].Mission[mis].Hard[Mission_LM]>=0) {
00441          Data->P[plr].Mission[mis].Hard[Mission_Probe_DM]=4;
00442          DMFake=1;
00443          }
00444       }
00445     if (j==1) {   // Apollo (2)  + LM (1)
00446       if (Data->P[plr].Mission[mis+j].Hard[Mission_Capsule]==2 && Data->P[plr].Mission[mis].Hard[Mission_LM]>=0) {
00447          Data->P[plr].Mission[mis].Hard[Mission_Probe_DM]=4;
00448          DMFake=1;
00449          }
00450       }
00451     if (Data->P[plr].Mission[mis].MissionCode==57) { // Soyuz Kicker C
00452       Data->P[plr].Mission[mis].Hard[Mission_Probe_DM]=4;
00453       DMFake=1;
00454       }
00455 
00456     if (Data->P[plr].Mission[mis].Hard[Mission_Capsule]==2) {  // Apollo #1
00457          Data->P[plr].Mission[mis].Hard[Mission_Probe_DM]=4;
00458          DMFake=1;
00459     }
00460 
00461 
00462     // this code is to buffer any difficulties when a mission gets through
00463     // all the checks to this point without having a docking module assigned
00464 #if 0
00465     if ((Mis.mVab[j] & 0x10)>0 && Data->P[plr].DMod==0) { // DMO Patch
00466       Data->P[plr].Mission[mis+j].Hard[Mission_Probe_DM]=4;
00467       DMFake=1;
00468       }
00469 #endif
00470 
00471     for (i=Mission_Capsule; i <= Mission_PhotoRecon; i++) {
00472       t = Data->P[plr].Mission[mis+j].Hard[i];
00473       MH[j][i]=NULL;  // Clear Pointers
00474       if (t>=0) {
00475           switch(i) {
00476              case Mission_Capsule: 
00477                      case Mission_LM:   // Cap - LM
00478                 MH[j][i]=&Data->P[plr].Manned[t];
00479                if (MH[j][i]->Num && t!=3) MH[j][i]->Num--;
00480                 MH[j][i]->Used++;
00481                 break;
00482 
00483             case Mission_Kicker:           // Kicker
00484                MH[j][i]=&Data->P[plr].Misc[t];
00485                if (MH[j][i]->Num) MH[j][i]->Num--;
00486                MH[j][i]->Used++;
00487                break;
00488 
00489             case Mission_Probe_DM:           // Secondary Equipment
00490                if (t!=4) {
00491                   MH[j][i]=&Data->P[plr].Probe[t];
00492                   MH[j][i]->Used++;
00493                   if (Data->P[plr].Probe[t].Num>0) Data->P[plr].Probe[t].Num-=1;
00494                }
00495                else {
00496                   MH[j][i]=&Data->P[plr].Misc[4];
00497                   if (DMFake==0) {
00498                      if (MH[j][i]->Num>0) MH[j][i]->Num--;
00499                      MH[j][i]->Used++;
00500                      }
00501                   };
00502                break;
00503 
00504             case Mission_PrimaryBooster:            // Rocket XX
00505                t--;
00506                if (t<4) {
00507                   MH[j][i]=&Data->P[plr].Rocket[t];
00508                   if (MH[j][i]->Num>0) MH[j][i]->Num--;
00509                   MH[j][i]->Used++;
00510                   }
00511                else {
00512                   MH[j][i]=&Data->P[plr].Rocket[t-4];
00513                   MH[j][7]=&Data->P[plr].Rocket[4];
00514                   MH[j][i]->Used++;
00515                   MH[j][7]->Used++;
00516                   if (MH[j][i]->Num>0) MH[j][i]->Num--;
00517                   if (MH[j][7]->Num>0) MH[j][7]->Num--;
00518                   };
00519                break;
00520 
00521             case Mission_EVA:  // EVA
00522                MH[j][i] = &Data->P[plr].Misc[3];
00523                break;
00524 
00525             case Mission_PhotoRecon:  // Photo Recon
00526                MH[j][i] = &Data->P[plr].Misc[5];
00527                break;
00528 
00529             default: break;
00530             };
00531 
00532          if (MH[j][i]!=NULL) {
00533             MH[j][i]->MisSaf=MH[j][i]->Safety+MH[j][i]->SMods;
00534             if (MH[j][i]->ID[1]>=0x35 && i==2 && Data->P[plr].Mission[mis].MissionCode>=53)
00535               switch(Data->P[plr].LMpts) {
00536                  case 0: MH[j][i]->MisSaf-=9;break;
00537                  case 1: MH[j][i]->MisSaf-=6;break;
00538                  case 2: MH[j][i]->MisSaf-=3;break;
00539               }
00540             }
00541          }; // if t>=0
00542       }; // for (0<7)
00543    }; // for (0<2)
00544 
00545   if (DMFake==1) Data->P[plr].Mission[mis].Hard[Mission_Probe_DM]=-1;
00546  
00547   return;
00548 }
00549 
00550 
00551 // Update the Current Hardware for the Mission
00552 void MissionSetDown(char plr,char mis)
00553 {
00554   char i,j;
00555   for (j=0;j<(Data->P[plr].Mission[mis].Joint+1);j++) {
00556       for (i=0;i<7;i++) {   // Ignore Boosters
00557           if (MH[j][i]!=NULL && (MH[j][i]->MisSucc>0 || MH[j][i]->MisFail>0)) {
00558 
00559               MH[j][i]->SMods=MH[j][i]->Damage=MH[j][i]->DCost=0;
00560            
00561               if (strncmp(MH[j][i]->Name,(i==3)?"DOC":"PHO",3)!=0 && MH[j][i]->MisSucc>0)
00562                   MH[j][i]->Safety++;
00563               if (strncmp(MH[j][i]->Name,"DOC",3)==0 && (MH[j][i]->MisFail+MH[j][i]->MisSucc)==0)
00564                  MH[j][i]->MisFail=1;
00565 
00566               if ((MH[j][i]->MisFail+MH[j][i]->MisSucc)==0 && (strncmp(MH[j][i]->ID,"M3",2)!=0))
00567                 MH[j][i]->MisFail++;
00568 
00569               if ((MH[j][i]->MisFail+MH[j][i]->MisSucc)==0 && MH[j][i]->ID[0]=='P')
00570                 MH[j][i]->MisFail++;
00571 
00572 
00573               MH[j][i]->Failures+=MH[j][i]->MisFail;
00574 
00575               MH[j][i]->Steps+=(MH[j][i]->MisFail+MH[j][i]->MisSucc);
00576 
00577               if (i==4 && MH[j][7]!=NULL) {  // Boosters
00578                 if (MH[j][4]->MisSucc>0) MH[j][7]->Safety++;
00579                 MH[j][7]->SMods=MH[j][7]->Damage=MH[j][7]->DCost=0;
00580 
00581                 MH[j][7]->Failures+=MH[j][4]->MisFail;
00582                 MH[j][7]->Steps+=(MH[j][4]->MisFail+MH[j][4]->MisSucc);
00583                 MH[j][7]->MisSucc=MH[j][7]->MisFail=0;
00584               }
00585               MH[j][i]->MisSucc=MH[j][i]->MisFail=0;
00586           } // if
00587       } // for i
00588      VerifySF(j);
00589   } // for j
00590   return;
00591 }
00592 
00593 
00594 /* Add Duration Negs to All Mission Steps - struct Mis needs to be filled */
00595 void
00596 MisDur(char plr, char dur)
00597 {
00598     int i, j, diff;
00599     int manned = 0;
00600 
00601     diff = dur - Data->P[plr].DurLevel;
00602     if (Data->P[plr].DurLevel == 0)
00603         diff--;
00604     if (diff <= 0)
00605         return;
00606     diff = 5 * diff;
00607     if ((MH[0][0] && MH[0][0]->ID[0] == 'C')
00608         || (MH[1][0] && MH[1][0]->ID[0] == 'C'))
00609         manned = 1;
00610     if (!manned)
00611         return;                    /* Don't give negs to unmanned */
00612     if (Mis.Dur == 0)
00613     {
00614         for (i = 0; i < (int) ARRAY_LENGTH(MH); i++)
00615             for (j = 0; j < (int) ARRAY_LENGTH(MH[0]); j++)
00616                 if (MH[i][j] != NULL)
00617                     MH[i][j]->MisSaf -= (char) diff;
00618     }
00619     /* will handle individual durations later */
00620     return;
00621 }
00622 
00623 
00624 #define Coml(a,b) (!(Data->Prestige[b].Place==(a) || Data->Prestige[b].mPlace==(a)))
00625 
00626 // Add SkipNegs to All Mission Steps
00627 void MisSkip(char plr,char ms)
00628 {
00629   int i,j,diff;
00630 
00631   diff=PrestMin(plr);
00632 #if 0
00633   nv=ms;
00634 
00635   if (nv==22 && Coml(plr,nv)) {diff=3;nv=20;}
00636   else diff=0;
00637   if (nv==20 && Coml(plr,nv)) {diff+=3;nv=19;}
00638   if (nv==19 && Coml(plr,nv)) {diff+=3;nv=7;}
00639   if (nv==7  && Coml(plr,nv)) {diff+=3;nv=1;}
00640   if (nv==1  && Coml(plr,nv)) {diff+=3;nv=18;}
00641   if (nv==18 && Coml(plr,nv)) {diff+=3;nv=27;}
00642   if (nv==27 && Coml(plr,nv)) {diff+=3;nv=0;}
00643   if (nv==0  && Coml(plr,nv)) {diff+=3;}
00644   if (diff>3 && AI[plr]) diff-=3;
00645   else if (diff>3) diff-=(2-((plr==0)?Data->Def.Lev1:Data->Def.Lev2));  // fixed addition problem
00646 #endif 
00647 
00648   diff=maxx(diff,0);
00649 
00650   if (diff!=0)
00651      for (i=0;i<2;i++)
00652         for (j=0;j<8;j++)
00653            if (MH[i][j]!=NULL) MH[i][j]->MisSaf-=(char) diff;
00654   return;
00655 }
00656 
00657 void MisRush(char ms)
00658 {
00659   int i,j,diff;
00660 
00661   if (ms==0) return;
00662   else diff=3*ms;
00663 
00664   if (diff!=0)
00665      for (i=0;i<2;i++)
00666         for (j=0;j<8;j++)
00667            if (MH[i][j]!=NULL) MH[i][j]->MisSaf-=(char) diff;
00668   return;
00669 }
00670 
00671 /* vim: set noet ts=4 sw=4 tw=77: */

Generated on Fri Sep 28 00:35:45 2007 for raceintospace by  doxygen 1.5.3