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
Binary file modified data/gamedata/urast.dat
Binary file not shown.
1 change: 1 addition & 0 deletions src/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ set(game_sources
news_suq.cpp
options.cpp
pace.cpp
pbm.cpp
place.cpp
port.cpp
prefs.cpp
Expand Down
191 changes: 109 additions & 82 deletions src/game/admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,10 @@ void FileAccess(char mode)
Data->Year = SaveHdr->Year;

if (SaveHdr->Country[0] == 8) {
MAIL = plr[0] = 0;
MAIL = plr[0] = 0; // U.S. turn coming up
plr[1] = 1;
} else {
MAIL = plr[1] = 1;
MAIL = plr[1] = 1; // Soviet turn coming up
plr[0] = 0;
}

Expand Down Expand Up @@ -827,89 +827,12 @@ void FileAccess(char mode)
key = 0;
} else if (sc == 1 && mode == 0 && ((x >= 209 && y >= 78 && x <= 278 && y <= 86 && mousebuttons > 0)
|| (key == 'M'))) { // PLAY-BY-MAIL SAVE GAME
InBox(209, 78, 278, 86);
delay(250);
WaitForMouseUp();
memset(SaveHdr->Name, 0x00, 23);
done = GetBlockName(SaveHdr->Name); // Checks Free Space
SaveHdr->ID = RaceIntoSpace_Signature;
SaveHdr->Name[22] = 0x1A;
temp = NOTSAME;

for (i = 0; (i < tFiles && temp == 2); i++) {
if (strcmp(SaveHdr->Name, FList[i].Title) == 0) {
temp = RequestX("REPLACE FILE", 1);

if (temp == SAME_ABORT) {
done = 0;
}
}
}

if (done == YES) {
i--; // decrement to correct for the FOR loop
strcpy(SaveHdr->PName[0], Data->P[plr[0] % 2].Name);
strcpy(SaveHdr->PName[1], Data->P[plr[1] % 2].Name);

// Play-By-Mail save game hack
// starts US side
plr[0] = 0;
plr[1] = 9;
MAIL = -1;
Data->Def.Plr1 = plr[0];
Data->Def.Plr2 = plr[1];
Data->plr[0] = Data->Def.Plr1;
Data->plr[1] = Data->Def.Plr2;
AI[0] = 0;
AI[1] = 0;

SaveHdr->Country[0] = Data->plr[0];
SaveHdr->Country[1] = Data->plr[1];
SaveHdr->Season = Data->Season;
SaveHdr->Year = Data->Year;
SaveHdr->dataSize = sizeof(struct Players);

EndOfTurnSave((char *) Data, sizeof(struct Players));
SaveHdr->compSize = interimData.endTurnSaveSize;

if (temp == NOTSAME) {
i = 0;
fin = NULL;

do {
i++;

if (fin) {
fclose(fin);
}

sprintf(Name, "BUZZ%d.SAV", i);
fin = sOpen(Name, "rb", 1);
} while (fin != NULL); // Find unique name

fin = sOpen(Name, "wb", 1);
} else {
fin = sOpen(FList[i].Name, "wb", 1);
}

// Write the Save Game Header
fwrite(SaveHdr, sizeof(SaveFileHdr), 1, fin);

// Save End of Turn Data
fwrite(interimData.endTurnBuffer, interimData.endTurnSaveSize, 1, fin);

// Save Replay Data
interimData.replaySize = sizeof(REPLAY) * MAX_REPLAY_ITEMS;
fwrite(interimData.tempReplay, interimData.replaySize, 1, fin);

// Save Event Data
fwrite(interimData.eventBuffer, interimData.eventSize, 1, fin);

fclose(fin);
}
MailSave();

OutBox(209, 78, 278, 86);
key = 0;
QUIT = 1;
return;
} else if (tFiles > 0 && ((x >= 209 && y >= 92 && x <= 278 && y <= 100 && mousebuttons > 0)
|| (key == 'D'))) {
InBox(209, 92, 278, 100);
Expand Down Expand Up @@ -1743,4 +1666,108 @@ int32_t EndOfTurnSave(char *inData, int dataLen)
return interimData.endTurnSaveSize;
}

void MailSave()
{
int done, temp, i, tFiles;
FILE *fin;

tFiles = GenerateTables(SAVEGAME_PlayByMail);

display::graphics.screen()->clear();

FadeIn(2, 10, 0, 0);

WaitForMouseUp();
memset(SaveHdr->Name, 0x00, 23);

do {
done = GetBlockName(SaveHdr->Name); // Checks Free Space
SaveHdr->ID = RaceIntoSpace_Signature;
SaveHdr->Name[22] = 0x1A;
temp = NOTSAME;

for (i = 0; (i < tFiles && temp == 2); i++) {
if (strcmp(SaveHdr->Name, FList[i].Title) == 0) {
temp = RequestX("REPLACE FILE", 1);

if (temp == SAME_ABORT) {
done = 0;
}
}
}
} while (done == 0);

if (done == YES) {
i--; // decrement to correct for the FOR loop
strcpy(SaveHdr->PName[0], Data->P[plr[0] % 2].Name);
strcpy(SaveHdr->PName[1], Data->P[plr[1] % 2].Name);

// Play-By-Mail save game hack
//
// If MAIL == 0, we are playing as the U.S. We need to
// save the game such that the U.S. starts again
if (MAIL == 0) {
plr[0] = 8;
plr[1] = 0;
}
// Playing as the Soviets
else if ((MAIL == 1)) {
plr[0] = 0;
plr[1] = 9;
}

Data->Def.Plr1 = plr[0];
Data->Def.Plr2 = plr[1];
Data->plr[0] = Data->Def.Plr1;
Data->plr[1] = Data->Def.Plr2;
AI[0] = 0;
AI[1] = 0;

SaveHdr->Country[0] = Data->plr[0];
SaveHdr->Country[1] = Data->plr[1];
SaveHdr->Season = Data->Season;
SaveHdr->Year = Data->Year;
SaveHdr->dataSize = sizeof(struct Players);

EndOfTurnSave((char *) Data, sizeof(struct Players));
SaveHdr->compSize = interimData.endTurnSaveSize;

if (temp == NOTSAME) {
i = 0;
fin = NULL;

do {
i++;

if (fin) {
fclose(fin);
}

sprintf(Name, "BUZZ%d.SAV", i);
fin = sOpen(Name, "rb", 1);
} while (fin != NULL); // Find unique name

fin = sOpen(Name, "wb", 1);
} else {
fin = sOpen(FList[i].Name, "wb", 1);
}

// Write the Save Game Header
fwrite(SaveHdr, sizeof(SaveFileHdr), 1, fin);

// Save End of Turn Data
fwrite(interimData.endTurnBuffer, interimData.endTurnSaveSize, 1, fin);

// Save Replay Data
interimData.replaySize = sizeof(REPLAY) * MAX_REPLAY_ITEMS;
fwrite(interimData.tempReplay, interimData.replaySize, 1, fin);

// Save Event Data
fwrite(interimData.eventBuffer, interimData.eventSize, 1, fin);

fclose(fin);
}
}


// EOF
2 changes: 1 addition & 1 deletion src/game/admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ int32_t EndOfTurnSave(char *inData, int dataLen); // Create ENDTURN.TMP
void FileAccess(char mode);
int FutureCheck(char plr, char type);
void save_game(char *name);

void MailSave();

#endif // ADMIN_H
49 changes: 26 additions & 23 deletions src/game/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,28 @@ struct BuzzData { // master data list for Buzz Aldrin's
char Port[40]; // Levels for SPort display
};

struct MisEval {
char step; /**< actual step id number */
char loc; /**< Mission Step Name Index */
uint16_t StepInfo; /**< ID of step success 1=succ !1=fail */
Equipment *E; /**< Pointer into equipment */
char Prest; /**< Prestige Step # (-1 for none) */
char PComp; /**< PComp will be set to amt of prest to be awarded. */
char pad; /**< pad location (Index into First Part of MH[x][] */
char Class; /**< VAB Order index into Class types MH[][x] */
char fgoto; /**< goto on failure */
char sgoto; /**< goto on success */
char dgoto; /**< where to branch on deaths */
char trace; /**< allow tracing of mission (for prest) */
char dice; /**< Die roll to check safety against */
int16_t rnum; /**< Random number holder for failure type */
char ast; /**< Astro specialist num */
char asf; /**< Astro specialist safety addition */
char FName[5]; /**< Name of Failure File (without .DAT) */
char Name[10]; /**< Name of Anim Code */
};


struct Players {
char BUZZ[4]; /**< Save Version Marker */
uint32_t Checksum; /**< Checksum of Data */
Expand All @@ -472,8 +494,10 @@ struct Players {
char unused_EMark[4]; /**< unused - Event Marker */
char Events[MAXIMUM_NEWS_EVENTS]; /**< History of Event Cards */
char Count; /**< Number of Events Picked */
char PD[NUM_PLAYERS][MAXIMUM_PRESTIGE_NUM];
char PD[NUM_PLAYERS][MAXIMUM_PRESTIGE_NUM]; /**< Prestige First Displayed: First Bit: Seen in MisRev, Second Bit: Seen by Opponent */
char Mile[NUM_PLAYERS][10]; /**< MileStone Calcs */
struct MisEval Mev[MAX_LAUNCHPADS][60]; /** < Mission eval for mail games */
char Step[MAX_LAUNCHPADS]; /** Number of mission steps for mail games */
};


Expand Down Expand Up @@ -506,27 +530,6 @@ struct MisAst { // This struct will be -1's if empty
char loc;
};

struct MisEval {
char step; /**< actual step id number */
char loc; /**< Mission Step Name Index */
uint16_t StepInfo; /**< ID of step success 1=succ !1=fail */
Equipment *E; /**< Pointer into equipment */
char Prest; /**< Prestige Step # (-1 for none) */
char PComp; /**< PComp will be set to amt of prest to be awarded. */
char pad; /**< pad location (Index into First Part of MH[x][] */
char Class; /**< VAB Order index into Class types MH[][x] */
char fgoto; /**< goto on failure */
char sgoto; /**< goto on success */
char dgoto; /**< where to branch on deaths */
char trace; /**< allow tracing of mission (for prest) */
char dice; /**< Die roll to check safety against */
int16_t rnum; /**< Random number holder for failure type */
char ast; /**< Astro specialist num */
char asf; /**< Astro specialist safety addition */
char FName[5]; /**< Name of Failure File (without .DAT) */
char Name[10]; /**< Name of Anim Code */
};

struct XFails {
int32_t per; // Failure Key number
int16_t code, val, xtra; // Failure Codes
Expand Down Expand Up @@ -845,7 +848,7 @@ BOOST_STATIC_ASSERT(sizeof(MissionType) == 43);
BOOST_STATIC_ASSERT(sizeof(Astros) == 63);
BOOST_STATIC_ASSERT(sizeof(PastInfo) == 84);
BOOST_STATIC_ASSERT(sizeof(BuzzData) == 15520);
BOOST_STATIC_ASSERT(sizeof(Players) == 31663);
BOOST_STATIC_ASSERT(sizeof(Players) == 38866);

#endif // __DATA_H__

Expand Down
30 changes: 22 additions & 8 deletions src/game/endgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,18 @@ void EndGame(char win, char pad)
MissionName(miss, 80, 50, 24);

if (Option == -1 && MAIL == -1) {
strcpy(capName , Data->P[win].Mission[pad].Name);
strcpy(capName, Data->P[win].Mission[pad].Name);
month = Data->P[win].Mission[pad].Month;
} else {
month = Data->Prestige[Prestige_MannedLunarLanding].Month;

if (MAIL != -1 || Option == win) {
strcpy(capName , Data->P[win].History[Data->Prestige[Prestige_MannedLunarLanding].Index].MissionName[0]);
strcpy(capName, Data->P[win].History[Data->Prestige[Prestige_MannedLunarLanding].Index].MissionName[0]);
} else {
prog = Data->P[win].History[Data->Prestige[Prestige_MannedLunarLanding].Index].Hard[i][0] + 1;
strcpy(capName , &Data->P[win].Manned[prog - 1].Name[0]);
strcat(capName , " ");
strcat(capName , Nums[Data->P[win].Manned[prog - 1].Used]);
strcpy(capName, &Data->P[win].Manned[prog - 1].Name[0]);
strcat(capName, " ");
strcat(capName, Nums[Data->P[win].Manned[prog - 1].Used]);
}
}

Expand Down Expand Up @@ -1145,17 +1145,17 @@ void PlayFirst(char plr, char first)
for (i = first; i < 28; i++) {
display::graphics.setForegroundColor(9);

if (Data->Prestige[i].Place == index && Data->PD[index][i] == 0) {
if (Data->Prestige[i].Place == index && !(Data->PD[plr][i] & 2)) {
if (Option == -1 && MAIL == -1) {
draw_string(84, 148 + w * 8, &PF[i][0]);
++w;
Data->PD[index][i] = 1;
Data->PD[index][i] |= 2;
} else {
//Found prestige first same mission
if (Data->Prestige[i].Index == Check) {
draw_string(84, 148 + w * 8, &PF[i][0]);
++w;
Data->PD[index][i] = 1;
Data->PD[index][i] |= 2;
}
}
}
Expand All @@ -1177,4 +1177,18 @@ void PlayFirst(char plr, char first)
return;
}

/* Play all pending Prestige First videos. */
void PlayAllFirsts(char plr)
{
int i;

for (i = 0; i < 28; i++) {
if (i != 4 && i != 5 && i != 6) {
if (Data->Prestige[i].Place == plr && !(Data->PD[plr][i] & 2)) {
PlayFirst(plr, i);
}
}
}
}

/* vim: set noet ts=4 sw=4 tw=77: */
1 change: 1 addition & 0 deletions src/game/endgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
void FakeWin(char win);
void NewEnd(char win, char loc);
void PlayFirst(char plr, char first);
void PlayAllFirsts(char plr);
void SpecialEnd(void);

extern char PF[29][40];
Expand Down
Loading