aboutsummaryrefslogtreecommitdiffstats
path: root/src/save/GenericGameStorage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/save/GenericGameStorage.cpp')
-rw-r--r--src/save/GenericGameStorage.cpp52
1 files changed, 50 insertions, 2 deletions
diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp
index 8aae4011..1e2d5da7 100644
--- a/src/save/GenericGameStorage.cpp
+++ b/src/save/GenericGameStorage.cpp
@@ -42,6 +42,11 @@
const uint32 SIZE_OF_ONE_GAME_IN_BYTES = 201729;
+#ifdef MISSION_REPLAY
+int8 IsQuickSave;
+const int PAUSE_SAVE_SLOT = SLOT_COUNT;
+#endif
+
char DefaultPCSaveFileName[260];
char ValidSaveName[260];
char LoadFileName[256];
@@ -134,7 +139,12 @@ GenericSave(int file)
WriteDataToBufferPointer(buf, saveName);
GetLocalTime(&saveTime);
WriteDataToBufferPointer(buf, saveTime);
+#ifdef MISSION_REPLAY
+ int32 data = IsQuickSave << 24 | SIZE_OF_ONE_GAME_IN_BYTES;
+ WriteDataToBufferPointer(buf, data);
+#else
WriteDataToBufferPointer(buf, SIZE_OF_ONE_GAME_IN_BYTES);
+#endif
WriteDataToBufferPointer(buf, CGame::currLevel);
WriteDataToBufferPointer(buf, TheCamera.GetPosition().x);
WriteDataToBufferPointer(buf, TheCamera.GetPosition().y);
@@ -240,6 +250,9 @@ GenericLoad()
uint8 *buf;
int32 file;
uint32 size;
+#ifdef MISSION_REPLAY
+ int8 qs;
+#endif
int32 saveSize;
CPad *currPad;
@@ -254,6 +267,9 @@ GenericLoad()
ReadDataFromFile(file, work_buff, size);
buf = (work_buff + 0x40);
ReadDataFromBufferPointer(buf, saveSize);
+#ifdef MISSION_REPLAY // a hack to keep compatibility but get new data from save
+ qs = saveSize >> 24;
+#endif
ReadDataFromBufferPointer(buf, CGame::currLevel);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().x);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().y);
@@ -296,6 +312,11 @@ GenericLoad()
ReadDataFromBufferPointer(buf, TheCamera.PedZoomIndicator);
#endif
assert(buf - work_buff == SIZE_OF_SIMPLEVARS);
+#ifdef MISSION_REPLAY
+ WaitForSave = 0;
+ if (FrontEndMenuManager.m_nCurrSaveSlot == PAUSE_SAVE_SLOT && qs == 3)
+ WaitForMissionActivate = CTimer::GetTimeInMilliseconds() + 2000;
+#endif
ReadDataFromBlock("Loading Scripts \n", CTheScripts::LoadAllScripts);
// Load the rest
@@ -468,7 +489,7 @@ CheckDataNotCorrupt(int32 slot, char *name)
char filename[100];
int32 blocknum = 0;
- eLevelName level = LEVEL_NONE;
+ eLevelName level = LEVEL_GENERIC;
CheckSum = 0;
uint32 bytes_processed = 0;
sprintf(filename, "%s%i%s", DefaultPCSaveFileName, slot + 1, ".b");
@@ -541,14 +562,17 @@ RestoreForStartLoad()
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().x);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().y);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().z);
+#ifndef NO_ISLAND_LOADING
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel);
+#endif
CCollision::SortOutCollisionAfterLoad();
+#ifndef NO_ISLAND_LOADING
CStreaming::RequestBigBuildings(CGame::currLevel);
CStreaming::LoadAllRequestedModels(false);
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
CGame::TidyUpMemory(true, false);
-
+#endif
if (CloseFile(file)) {
return true;
} else {
@@ -563,3 +587,27 @@ align4bytes(int32 size)
{
return (size + 3) & 0xFFFFFFFC;
}
+
+#ifdef MISSION_REPLAY
+
+void DisplaySaveResult(int unk, char* name)
+{}
+
+bool SaveGameForPause(int type)
+{
+ if (AllowMissionReplay != 0 || type != 3 && WaitForSave > CTimer::GetTimeInMilliseconds())
+ return false;
+ WaitForSave = 0;
+ if (gGameState != GS_PLAYING_GAME || CTheScripts::IsPlayerOnAMission() || CStats::LastMissionPassedName[0] == '\0') {
+ DisplaySaveResult(3, CStats::LastMissionPassedName);
+ return false;
+ }
+ IsQuickSave = type;
+ MissionStartTime = 0;
+ int res = PcSaveHelper.SaveSlot(PAUSE_SAVE_SLOT);
+ PcSaveHelper.PopulateSlotInfo();
+ IsQuickSave = 0;
+ DisplaySaveResult(res, CStats::LastMissionPassedName);
+ return true;
+}
+#endif