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
91 changes: 62 additions & 29 deletions src/game/admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,17 +673,17 @@ void FileAccess(char mode)
}

} else if (key == K_PGDN) { // Page Down

if (now < savegames.size()) {
now += 8;
}

if (savegames.size() < 8) { // user only has a few saves
now = savegames.size() - 1;
BarB = savegames.size() - 1;
} else {
if (now < (savegames.size() - 8)) {

if (now > (savegames.size() - 1)) {
now = savegames.size();
BarB = 8;
Expand All @@ -699,13 +699,15 @@ void FileAccess(char mode)
} else {
draw_up_arrow(194, 55);
}

if (now >= (savegames.size() - 1)) {
draw_down_arrow(194, 94);
}
} else {
BarB = 8;
if (now >= (savegames.size() - 1)) {
now = savegames.size() - 1;

if (now >= (savegames.size() - 1)) {
now = savegames.size() - 1;
draw_down_arrow(194, 94);
} else {
draw_down_arrow_highlight(194, 94);
Expand Down Expand Up @@ -939,8 +941,8 @@ void autosave_game(const char *name)
write_save_file(name, hdr);

// Repair data modified by save
Data->plr[0] = Data->Def.Plr1 = plr[0] = 2*AI[0];
Data->plr[1] = Data->Def.Plr2 = plr[1] = 1 + 2*AI[1];
Data->plr[0] = Data->Def.Plr1 = plr[0] = 2 * AI[0];
Data->plr[1] = Data->Def.Plr2 = plr[1] = 1 + 2 * AI[1];

}

Expand Down Expand Up @@ -1238,11 +1240,13 @@ int FutureCheck(char plr, char type)
draw_string(111, 52 + i * 51, "IT WILL COST ");
draw_number(0, 0, abs(p[i]));
draw_string(0, 0, "MB TO REPAIR.");

if (Data->P[plr].Cash >= abs(p[i])) {
display::graphics.setForegroundColor(11);
} else {
display::graphics.setForegroundColor(9);
}

draw_string(113, 60 + i * 51, "(OF ");
draw_number(0, 0, Data->P[plr].Cash);
draw_string(0, 0, "MB)");
Expand Down Expand Up @@ -1277,11 +1281,14 @@ int FutureCheck(char plr, char type)
draw_string(111, 61 + i * 51, "PRIMARY MISSION PART");
draw_string(111, 61 + (i + 1) * 51, "SECONDARY MISSION PART");
}

// Show (RE)ASSEMBLE HARDWARE in other color if missing requirement penalties
int penalty = AchievementPenalty(plr, plan);

if (penalty > 2 && type != 0) {
display::graphics.setForegroundColor(11);
}

if (penalty > 8 && type != 0) {
display::graphics.setForegroundColor(8);
}
Expand Down Expand Up @@ -1313,15 +1320,17 @@ int FutureCheck(char plr, char type)
if (type == 0) { // Future Missions
display::graphics.setForegroundColor(1);

// Show (RE)ASSIGN FUTURE MISSION in other color if missing requirement penalties
const struct mStr plan = GetMissionPlan(Data->P[plr].Future[i].MissionCode);
int penalty = AchievementPenalty(plr, plan);
if (penalty > 2) {
display::graphics.setForegroundColor(11);
}
if (penalty > 8) {
display::graphics.setForegroundColor(8);
}
// Show (RE)ASSIGN FUTURE MISSION in other color if missing requirement penalties
const struct mStr plan = GetMissionPlan(Data->P[plr].Future[i].MissionCode);
int penalty = AchievementPenalty(plr, plan);

if (penalty > 2) {
display::graphics.setForegroundColor(11);
}

if (penalty > 8) {
display::graphics.setForegroundColor(8);
}

if (Data->P[plr].Future[i].part == 0) {
if (m[i] == 0) {
Expand Down Expand Up @@ -1355,9 +1364,11 @@ int FutureCheck(char plr, char type)
if (type == 0) {
draw_string(111, 49 + i * 51, "PURCHASE LAUNCH FACILITY");
draw_string(111, 57 + i * 51, "FOR: 20 MB'S ");

if (Data->P[plr].Cash > 19) {
display::graphics.setForegroundColor(11);
}

draw_string(0, 0, "(OF ");
draw_number(0, 0, Data->P[plr].Cash);
draw_string(0, 0, ")");
Expand Down Expand Up @@ -1426,15 +1437,23 @@ int FutureCheck(char plr, char type)
// Missions(plr, 111, 41 + i * 51, m[i], 0);
MissionName(m[i], 111, 41 + i * 51, 24);
draw_string(113, 75 + i * 51, "ASSIGN FUTURE MISSION");

// Update player's cash shown on other pads
for (ii = 0; ii < 3; ii++) {
display::graphics.setForegroundColor(9);

if (ii != i && p[ii] > 1) {
if (Data->P[plr].Cash >= abs(p[ii])) { display::graphics.setForegroundColor(11); }
if (Data->P[plr].Cash >= abs(p[ii])) {
display::graphics.setForegroundColor(11);
}
}

if (ii != i && p[ii] == -1) {
if (Data->P[plr].Cash > 19) { display::graphics.setForegroundColor(11); }
if (Data->P[plr].Cash > 19) {
display::graphics.setForegroundColor(11);
}
}

if (p[ii] == -1 || p[ii] > 1) {
if (p[ii] > 1) {
xx = 113;
Expand All @@ -1443,6 +1462,7 @@ int FutureCheck(char plr, char type)
xx = 171;
yy = 53 + ii * 51;
}

fill_rectangle(xx, yy, xx + 44, yy + 4, 3);
draw_string(xx, yy + 4, "(OF ");
draw_number(0, 0, Data->P[plr].Cash);
Expand All @@ -1469,15 +1489,23 @@ int FutureCheck(char plr, char type)
// Missions(plr, 111, 41 + i * 51, m[i], 0);
MissionName(m[i], 111, 41 + i * 51, 24);
draw_string(113, 75 + i * 51, "ASSIGN FUTURE MISSION");

// Update player's cash shown on other pads
for (ii = 0; ii < 3; ii++) {
display::graphics.setForegroundColor(9);

if (ii != i && p[ii] > 1) {
if (Data->P[plr].Cash >= abs(p[ii])) { display::graphics.setForegroundColor(11); }
if (Data->P[plr].Cash >= abs(p[ii])) {
display::graphics.setForegroundColor(11);
}
}

if (ii != i && p[ii] == -1) {
if (Data->P[plr].Cash > 19) { display::graphics.setForegroundColor(11); }
if (Data->P[plr].Cash > 19) {
display::graphics.setForegroundColor(11);
}
}

if (p[ii] == -1 || p[ii] > 1) {
if (p[ii] > 1) {
xx = 113;
Expand All @@ -1486,6 +1514,7 @@ int FutureCheck(char plr, char type)
xx = 171;
yy = 53 + ii * 51;
}

fill_rectangle(xx, yy, xx + 44, yy + 4, 3);
draw_string(xx, yy + 4, "(OF ");
draw_number(0, 0, Data->P[plr].Cash);
Expand Down Expand Up @@ -1594,8 +1623,7 @@ void LoadGame(const char *filename)
} else { // Not zlib compressed data
if (Help("i174") == 1) {
LegacyLoad(header, fin, fileLength);
}
else {
} else {
return;
}
}
Expand Down Expand Up @@ -1699,22 +1727,25 @@ void LegacyLoad(SaveFileHdr header, FILE *fin, size_t fileLength)
for (j = 0; j < 7; j++) {
p = Data->P[i].Probe[j].MisFail;
// Shift the remaining bytes of the struct by 2
std::memmove(p+2, p, (int8_t *) Data + legacySize - p);
std::memmove(p + 2, p, (int8_t *) Data + legacySize - p);
}

for (j = 0; j < 7; j++) {
p = Data->P[i].Rocket[j].MisFail;
// Shift the remaining bytes of the struct by 2
std::memmove(p+2, p, (int8_t *) Data + legacySize - p);
std::memmove(p + 2, p, (int8_t *) Data + legacySize - p);
}

for (j = 0; j < 7; j++) {
p = Data->P[i].Manned[j].MisFail;
// Shift the remaining bytes of the struct by 2
std::memmove(p+2, p, (int8_t *) Data + legacySize - p);
std::memmove(p + 2, p, (int8_t *) Data + legacySize - p);
}

for (j = 0; j < 7; j++) {
p = Data->P[i].Misc[j].MisFail;
// Shift the remaining bytes of the struct by 2
std::memmove(p+2, p, (int8_t *) Data + legacySize - p);
std::memmove(p + 2, p, (int8_t *) Data + legacySize - p);
}
}

Expand Down Expand Up @@ -1747,6 +1778,7 @@ void LegacyLoad(SaveFileHdr header, FILE *fin, size_t fileLength)
for (i = 0; i < MAX_REPLAY_ITEMS; i++) {
interimData.tempReplay.at(i).clear();
assert(load_buffer[i].Qty <= 35);

for (int j = 0; j < load_buffer[i].Qty; j++) {

int code = load_buffer[i].Off[j];
Expand All @@ -1756,7 +1788,7 @@ void LegacyLoad(SaveFileHdr header, FILE *fin, size_t fileLength)
} else {
interimData.tempReplay.at(i).push_back({true, fseq.at(code)});
}

}
}

Expand Down Expand Up @@ -1908,8 +1940,7 @@ void write_save_file(const char *Name, SaveFileHdr header)
else if ((MAIL_PLAYER == 1)) {
Data->Def.Plr1 = 0;
Data->Def.Plr2 = 9;
}
else {
} else {
Data->Def.Plr1 = plr[0];
Data->Def.Plr2 = plr[1];
}
Expand Down Expand Up @@ -2014,12 +2045,14 @@ int SaveGame(const std::vector<SFInfo> savegames)
// The field savegames[i].Name is a filename provided by
// the file system, so it already includes the .SAV extension.
strncpy(header.Name, title.c_str(), sizeof(header.Name) - 1);

if (temp == NOTSAME) {
std::string filename = title + ".SAV";
write_save_file(filename.c_str(), header);
} else {
write_save_file(savegames[i].Name, header);
}

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/ast3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ TrainText(char plr, int astro, int cnt)
case 3:
draw_string(0, 0, "IV");
break;

default:
draw_string(0, 0, "A.F.");
break;
Expand Down
4 changes: 3 additions & 1 deletion src/game/ast4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,16 @@ void DrawProgs(char plr, char prog)
draw_string(0, 0, "REW SELECTION");
display::graphics.setForegroundColor(7);
draw_string(152, 35, &Data->P[plr].Manned[prog - 1].Name[0]);

for (i = 0; i < 8; i++) {
if (prog == 1 && Data->P[plr].Pool[i].Assign == 1 && Data->P[plr].Pool[i].Moved >= 5) {
// If Mercury/Vostok, mark as obsolete if crew(s) are about to start losing morale for staying here too long
display::graphics.setForegroundColor(5);
draw_string(0, 0, " (OBSOLETE)");
break;
}
}
}

display::graphics.setForegroundColor(9);

if (prog == 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/game/crew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ void FutAstList(char plr, char men, int M1, int M2, int M3, int M4)

// Highlight EVA for EVA Specialist, if the mission...
if (men == 1 || ((men == 2 || men == 3) && i == 1) ||
(men == 4 && i > 1)) {
(men == 4 && i > 1)) {
if (IsEVA(mType)) {
// ...will include an EVA...
display::graphics.setForegroundColor(11);
Expand Down
22 changes: 12 additions & 10 deletions src/game/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ struct MissionType {
for (int i = 0; i < Mission_PrimaryBooster; i++) {
ASSERT(Hard[i] >= -1 && Hard[i] < 7);
}

// Saturn V / N1 with boosters has a hardware index of 7
ASSERT(Hard[Mission_PrimaryBooster] >= -1
&& Hard[Mission_PrimaryBooster] < 8);
Expand Down Expand Up @@ -876,9 +877,11 @@ struct Players {
ar(CEREAL_NVP(Count));
ar(CEREAL_NVP(PD));
ar(CEREAL_NVP(Mile));

if (version > 0) {
ar(CEREAL_NVP(Mail));
}

ar(CEREAL_NVP(Mev));
ar(CEREAL_NVP(Step));

Expand Down Expand Up @@ -912,10 +915,10 @@ struct XFails {
ar(CEREAL_NVP(val));
ar(CEREAL_NVP(xtra));
ar(CEREAL_NVP(fail));

ARCHIVE_STRING(text);
}

};

struct AnimType {
Expand Down Expand Up @@ -1181,7 +1184,7 @@ struct MissionSequenceKey {
ar(CEREAL_NVP(MissionStep));
} catch (...) { // No MissionStep in seq.json
}

ar(CEREAL_NVP(MissionIdSequence));
ar(CEREAL_NVP(video));
ar(CEREAL_NVP(audio));
Expand Down Expand Up @@ -1271,8 +1274,7 @@ struct INTERIMDATA {
if (version == 1) {
ARCHIVE_ARRAY(tempReplay, std::vector <REPLAY>);
ARCHIVE_ARRAY(tempEvents, std::string);
}
else if (version == 0) {
} else if (version == 0) {
// Legacy replay format
ARCHIVE_ARRAY(tempEvents, std::string);

Expand All @@ -1288,6 +1290,7 @@ struct INTERIMDATA {
for (int i = 0; i < legacyReplay.size(); i++) {
tempReplay.at(i).clear();
assert(legacyReplay.at(i).Qty <= 35);

for (int j = 0; j < legacyReplay.at(i).Qty; j++) {

int code = legacyReplay.at(i).Off[j];
Expand All @@ -1297,13 +1300,12 @@ struct INTERIMDATA {
} else {
tempReplay.at(i).push_back({true, fseq.at(code)});
}

}
}

}
else {
throw(std::invalid_argument("Invalid INTERIMDATA version number"));

} else {
throw (std::invalid_argument("Invalid INTERIMDATA version number"));
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/game/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,9 @@ PhysFsEnumerator::enumerate()
}

PHYSFS_EnumerateCallbackResult
PhysFsEnumerator::enumerate_callback(void* data, const char* origdir, const char* fname)
PhysFsEnumerator::enumerate_callback(void *data, const char *origdir, const char *fname)
{
PhysFsEnumerator* self = static_cast<PhysFsEnumerator*>(data);
PhysFsEnumerator *self = static_cast<PhysFsEnumerator *>(data);
return self->onItem(origdir, fname);
}

Expand Down
Loading