Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions src/game/mis_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "utils.h"
#include "game_main.h"
#include "mc.h"
#include "mis_m.h"
#include "sdlhelper.h"
#include "newmis.h"
#include "gr.h"
Expand Down Expand Up @@ -1097,22 +1098,9 @@ char FailureMode(char plr, int prelim, char *text)
draw_string(0, 0, " CHECK");
draw_number(9, 55, Mev[STEP].dice);
draw_string(0, 0, " VS. ");

int xloc = (Mev[STEP].dice > 99) ? 62 : 57;

if (strncmp(e->Name, "DO", 2) == 0) {
if (Mev[STEP].loc == 1 || Mev[STEP].loc == 2) {
draw_number(0, 0, e->MSF);
} else {
draw_number(0, 0, e->MisSaf);
}
} else {
draw_number(0, 0, e->MisSaf);
}

draw_number(0, 0, StepSafety(Mev[STEP]));
// draw_string(0, 0, "%");


draw_heading(45, 5, "STEP FAILURE", 0, -1);

// InRFBox(4,61,153,109,0); // Image, Small Left Side
Expand Down Expand Up @@ -1224,6 +1212,7 @@ char FailureMode(char plr, int prelim, char *text)

if (MANNED[Mev[STEP].pad] > 0) {
display::graphics.setForegroundColor(1);
int xloc = (Mev[STEP].dice > 99) ? 62 : 57;

switch (Mev[STEP].ast) {
case 0:
Expand Down
75 changes: 40 additions & 35 deletions src/game/mis_m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void GetFailStat(struct XFails *Now, char *FName, int rnum)
void MisCheck(char plr, char mpad)
{
int tomflag = 0; // Tom's checking flag
int val, safety, save, PROBLEM, i, lc, durxx;
int save, PROBLEM, i, lc, durxx;
struct XFails Now;
unsigned char gork = 0;

Expand Down Expand Up @@ -362,43 +362,11 @@ void MisCheck(char plr, char mpad)
}
}


// SAFETY FACTOR STUFF

safety = GetEquipment(Mev[STEP])->MisSaf;

if ((Mev[STEP].Name[0] == 'A') &&
MH[Mev[STEP].pad][Mission_SecondaryBooster] != NULL) {
// boosters involved
safety = RocketBoosterSafety(safety, MH[Mev[STEP].pad][Mission_SecondaryBooster]->Safety);
}

// Duration Hack Part 3 of 3
if (Mev[STEP].loc == 28 || Mev[STEP].loc == 27) {
safety = GetEquipment(Mev[STEP])->MisSaf; // needs to be for both

// Use average of capsule ratings for Joint duration
if (InSpace == 2) {
safety = (MH[0][Mission_Capsule]->MisSaf +
MH[1][Mission_Capsule]->MisSaf) / 2;
}
}

if (strncmp(GetEquipment(Mev[STEP])->Name, "DO", 2) == 0) {
if (Mev[STEP].loc == 1 || Mev[STEP].loc == 2) {
safety = GetEquipment(Mev[STEP])->MSF;
}
}

val = Mev[STEP].dice;
safety += Mev[STEP].asf;

if (safety >= 100) {
safety = 99;
}
int val = Mev[STEP].dice;
int safety = StepSafety(Mev[STEP]);

save = (GetEquipment(Mev[STEP])->SaveCard == 1) ? 1 : 0;

PROBLEM = val > safety;

if (!AI[plr] && options.want_cheats) {
Expand Down Expand Up @@ -675,6 +643,43 @@ void MisCheck(char plr, char mpad)
return;
}


/**
* Calculate the safety factor to test against for a mission step.
*
* Relies upon the global values MH and InSpace. Because of this, the
* function IS NOT guaranteed to give the correct value for any steps
* but the current one.
*
* TODO: Eliminate the use of global variables.
*
* \param step the current mission step.
*/
int StepSafety(const struct MisEval &step)
{
int safety = GetEquipment(step)->MisSaf;

if ((step.Name[0] == 'A') && MH[step.pad][Mission_SecondaryBooster]) {
// Account for Boosters - if used - on launch steps
safety = RocketBoosterSafety(
safety,
MH[step.pad][Mission_SecondaryBooster]->Safety);
} else if ((step.loc == 28 || step.loc == 27) && InSpace == 2) {
// For joint duration tests, use the average capsule safety
safety = (MH[0][Mission_Capsule]->MisSaf +
MH[1][Mission_Capsule]->MisSaf) / 2;
} else if (strncmp(GetEquipment(step)->Name, "DO", 2) == 0) {
if (step.loc == 1 || step.loc == 2) {
safety = GetEquipment(step)->MSF;
}
}

safety += step.asf;

return MIN(safety, 99);
}


/** Draw mission step rectangle
*
* The rectangle represents the success or failure rate.
Expand Down
2 changes: 2 additions & 0 deletions src/game/mis_m.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef MIS_M_H
#define MIS_M_H


void MisCheck(char plr, char mpad);
int StepSafety(const struct MisEval &step);

extern char death;

Expand Down