finished save/load

This commit is contained in:
Nikolay Korolev 2020-10-17 20:45:07 +03:00
parent cae3990eac
commit 720abca826
8 changed files with 45 additions and 37 deletions

View File

@ -345,8 +345,9 @@ INITSAVEBUF
++nObjects;
}
*size = nObjects * (sizeof(int16) + sizeof(int) + sizeof(CCompressedMatrix) +
sizeof(float) + sizeof(CCompressedMatrix) + sizeof(int8) + 7 * sizeof(bool) + sizeof(float) +
sizeof(int8) + sizeof(int8) + sizeof(uint32) + 2 * sizeof(uint32)) + sizeof(int);
sizeof(float) + sizeof(CCompressedMatrix) + sizeof(int8) + 7 * sizeof(bool) + sizeof(int16) +
+ sizeof(int8) * 2 + sizeof(float) + sizeof(int8) + sizeof(int8) +
sizeof(uint32) + 2 * sizeof(uint32)) + sizeof(int);
CopyToBuf(buf, nObjects);
for (int i = 0; i < nPoolSize; i++) {
CObject* pObject = GetObjectPool()->GetSlot(i);
@ -370,7 +371,6 @@ INITSAVEBUF
tmp.CompressFromFullMatrix(pObject->m_objectMatrix);
CopyToBuf(buf, tmp);
CopyToBuf(buf, pObject->ObjectCreatedBy);
SkipSaveBuf(buf, 1);
CopyToBuf(buf, bIsPickup);
CopyToBuf(buf, bPickupObjWithMessage);
CopyToBuf(buf, bOutOfStock);
@ -380,6 +380,7 @@ INITSAVEBUF
CopyToBuf(buf, bUseVehicleColours);
CopyToBuf(buf, pObject->m_unk);
CopyToBuf(buf, pObject->m_nBonusValue);
SkipSaveBuf(buf, 1);
CopyToBuf(buf, pObject->m_fCollisionDamageMultiplier);
CopyToBuf(buf, pObject->m_nCollisionDamageEffect);
CopyToBuf(buf, pObject->m_nSpecialCollisionResponseCases);

View File

@ -924,6 +924,7 @@ INITSAVEBUF
for (int i = 0; i < NUMRADARBLIPS; i++) {
ms_RadarTrace[i].m_nColor = ReadSaveBuf<uint32>(buf);
ms_RadarTrace[i].m_Radius = ReadSaveBuf<float>(buf);
ms_RadarTrace[i].m_eBlipType = ReadSaveBuf<uint32>(buf);
ms_RadarTrace[i].m_nEntityHandle = ReadSaveBuf<int32>(buf);
ms_RadarTrace[i].m_vec2DPos.x = ReadSaveBuf<float>(buf); // CVector2D
@ -934,7 +935,6 @@ INITSAVEBUF
ms_RadarTrace[i].m_bInUse = ReadSaveBuf<bool>(buf);
ms_RadarTrace[i].m_bShortRange = ReadSaveBuf<bool>(buf);
ms_RadarTrace[i].m_unused = ReadSaveBuf<bool>(buf);
ms_RadarTrace[i].m_Radius = ReadSaveBuf<float>(buf);
ms_RadarTrace[i].m_wScale = ReadSaveBuf<int16>(buf);
ms_RadarTrace[i].m_eBlipDisplay = ReadSaveBuf<uint16>(buf);
ms_RadarTrace[i].m_eRadarSprite = ReadSaveBuf<uint16>(buf);
@ -961,6 +961,7 @@ INITSAVEBUF
sRadarTraceSave *saveStruct = (sRadarTraceSave*) buf;
saveStruct->m_nColor = ms_RadarTrace[i].m_nColor;
saveStruct->m_Radius = ms_RadarTrace[i].m_Radius;
saveStruct->m_eBlipType = ms_RadarTrace[i].m_eBlipType;
saveStruct->m_nEntityHandle = ms_RadarTrace[i].m_nEntityHandle;
saveStruct->m_vec2DPos = ms_RadarTrace[i].m_vec2DPos;
@ -970,7 +971,6 @@ INITSAVEBUF
saveStruct->m_bInUse = ms_RadarTrace[i].m_bInUse;
saveStruct->m_bShortRange = ms_RadarTrace[i].m_bShortRange;
saveStruct->m_unused = ms_RadarTrace[i].m_unused;
saveStruct->m_Radius = ms_RadarTrace[i].m_Radius;
saveStruct->m_wScale = ms_RadarTrace[i].m_wScale;
saveStruct->m_eBlipDisplay = ms_RadarTrace[i].m_eBlipDisplay;
saveStruct->m_eRadarSprite = ms_RadarTrace[i].m_eRadarSprite;

View File

@ -137,6 +137,7 @@ struct sRadarTrace
struct sRadarTraceSave
{
uint32 m_nColor;
float m_Radius;
uint32 m_eBlipType; // eBlipType
int32 m_nEntityHandle;
CVector2D m_vec2DPos;
@ -146,7 +147,6 @@ struct sRadarTraceSave
bool m_bInUse;
bool m_bShortRange;
bool m_unused;
float m_Radius;
int16 m_wScale;
uint16 m_eBlipDisplay; // eBlipDisplay
uint16 m_eRadarSprite; // eRadarSprite

View File

@ -1935,7 +1935,7 @@ CPlayerPed::Save(uint8*& buf)
CopyToBuf(buf, m_nTargettableObjects[1]);
CopyToBuf(buf, m_nTargettableObjects[2]);
CopyToBuf(buf, m_nTargettableObjects[3]);
SkipSaveBuf(buf, 116);
SkipSaveBuf(buf, 164);
}
void

View File

@ -583,7 +583,7 @@ void CHud::Draw()
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint);
if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 1) {
if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 4) {
// CFont::SetColor(ARMOUR_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f + 52.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon);
}

View File

@ -41,7 +41,9 @@
#include "Timecycle.h"
#include "Fluff.h"
#define BLOCK_COUNT 20
// --MIAMI: file done
#define BLOCK_COUNT 22
#define SIZE_OF_SIMPLEVARS 0xE4
const uint32 SIZE_OF_ONE_GAME_IN_BYTES = 201729;
@ -60,7 +62,6 @@ int CheckSum;
eLevelName m_LevelToLoad;
char SaveFileNameJustSaved[260];
int Slots[SLOT_COUNT];
CDate CompileDateAndTime;
bool b_FoundRecentSavedGameWantToLoad;
bool JustLoadedDontFadeInYet;
@ -112,13 +113,14 @@ do {\
buf += size;\
} while (0)
#define WriteSaveDataBlock(save_func)\
#define WriteSaveDataBlock(save_func, msg)\
do {\
size = 0;\
buf = work_buff;\
reserved = 0;\
MakeSpaceForSizeInBufferPointer(presize, buf, postsize);\
save_func(buf, &size);\
debug(msg"== %i \n", size);\
CopySizeAndPreparePointer(presize, buf, postsize, reserved, size);\
if (!PcSaveHelper.PcClassSaveRoutine(file, work_buff, buf - work_buff))\
return false;\
@ -145,9 +147,10 @@ GenericSave(int file)
reserved = 0;
// Save simple vars
lastMissionPassed = TheText.Get(CStats::LastMissionPassedName);
lastMissionPassed = TheText.Get(CStats::LastMissionPassedName[0] ? CStats::LastMissionPassedName : "ITBEG");
if (lastMissionPassed[0] != '\0') {
AsciiToUnicode("...'", suffix);
suffix[3] = L'\0';
#ifdef FIX_BUGS
// fix buffer overflow
int len = UnicodeStrlen(lastMissionPassed);
@ -221,6 +224,7 @@ GenericSave(int file)
buf += 4;
postsize = buf;
CTheScripts::SaveAllScripts(buf, &size);
debug("ScriptSize== %i \n", size);
CopySizeAndPreparePointer(presize, buf, postsize, reserved, size);
if (!PcSaveHelper.PcClassSaveRoutine(file, work_buff, buf - work_buff))
return false;
@ -228,28 +232,28 @@ GenericSave(int file)
totalSize = buf - work_buff;
// Save the rest
WriteSaveDataBlock(CPools::SavePedPool);
WriteSaveDataBlock(CGarages::Save);
WriteSaveDataBlock(CGameLogic::Save);
WriteSaveDataBlock(CPools::SaveVehiclePool);
WriteSaveDataBlock(CPools::SaveObjectPool);
WriteSaveDataBlock(ThePaths.Save);
WriteSaveDataBlock(CCranes::Save);
WriteSaveDataBlock(CPickups::Save);
WriteSaveDataBlock(gPhoneInfo.Save);
WriteSaveDataBlock(CRestart::SaveAllRestartPoints);
WriteSaveDataBlock(CRadar::SaveAllRadarBlips);
WriteSaveDataBlock(CTheZones::SaveAllZones);
WriteSaveDataBlock(CGangs::SaveAllGangData);
WriteSaveDataBlock(CTheCarGenerators::SaveAllCarGenerators);
WriteSaveDataBlock(CParticleObject::SaveParticle);
WriteSaveDataBlock(cAudioScriptObject::SaveAllAudioScriptObjects);
WriteSaveDataBlock(CScriptPaths::Save);
WriteSaveDataBlock(CWorld::Players[CWorld::PlayerInFocus].SavePlayerInfo);
WriteSaveDataBlock(CStats::SaveStats);
WriteSaveDataBlock(CSetPieces::Save);
WriteSaveDataBlock(CStreaming::MemoryCardSave);
WriteSaveDataBlock(CPedType::Save);
WriteSaveDataBlock(CPools::SavePedPool, "PedPoolSize");
WriteSaveDataBlock(CGarages::Save, "GaragesSize");
WriteSaveDataBlock(CGameLogic::Save, "GameLogicSize");
WriteSaveDataBlock(CPools::SaveVehiclePool, "VehPoolSize");
WriteSaveDataBlock(CPools::SaveObjectPool, "ObjectPoolSize");
WriteSaveDataBlock(ThePaths.Save, "ThePathsSize");
WriteSaveDataBlock(CCranes::Save, "CranesSize");
WriteSaveDataBlock(CPickups::Save, "PickUpsSize");
WriteSaveDataBlock(gPhoneInfo.Save, "PhoneInfoSize");
WriteSaveDataBlock(CRestart::SaveAllRestartPoints, "RestartPointsBufferSize");
WriteSaveDataBlock(CRadar::SaveAllRadarBlips, "RadarBlipsBufferSize");
WriteSaveDataBlock(CTheZones::SaveAllZones, "AllZonesBufferSize");
WriteSaveDataBlock(CGangs::SaveAllGangData, "AllGangDataSize");
WriteSaveDataBlock(CTheCarGenerators::SaveAllCarGenerators, "AllCarGeneratorsSize");
WriteSaveDataBlock(CParticleObject::SaveParticle, "ParticlesSize");
WriteSaveDataBlock(cAudioScriptObject::SaveAllAudioScriptObjects, "AllAudioScriptObjectsSize");
WriteSaveDataBlock(CScriptPaths::Save, "ScriptPathsSize");
WriteSaveDataBlock(CWorld::Players[CWorld::PlayerInFocus].SavePlayerInfo, "PlayerInfoSize");
WriteSaveDataBlock(CStats::SaveStats, "StatsSize");
WriteSaveDataBlock(CSetPieces::Save, "SetPiecesSize");
WriteSaveDataBlock(CStreaming::MemoryCardSave, "StreamingSize");
WriteSaveDataBlock(CPedType::Save, "PedTypeSize");
// Write padding
for (int i = 0; i < 4; i++) {
@ -458,8 +462,13 @@ CloseFile(int32 file)
void
DoGameSpecificStuffAfterSucessLoad()
{
CCollision::SortOutCollisionAfterLoad();
CStreaming::LoadSceneCollision(TheCamera.GetPosition());
CStreaming::LoadScene(TheCamera.GetPosition());
CGame::TidyUpMemory(true, false);
StillToFadeOut = true;
JustLoadedDontFadeInYet = true;
TheCamera.Fade(0.0f, 0);
CTheScripts::Process();
}

View File

@ -25,8 +25,6 @@ bool CheckDataNotCorrupt(int32 slot, char *name);
bool RestoreForStartLoad();
int align4bytes(int32 size);
extern class CDate CompileDateAndTime;
extern char DefaultPCSaveFileName[260];
extern char ValidSaveName[260];
extern char LoadFileName[256];

View File

@ -91,7 +91,7 @@ void CCarGenerator::DoInternalProcessing()
pVehicle = pBoat;
if (pos.z <= -100.0f)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pBoat->bExtendedRange = false;
pBoat->bExtendedRange = true;
}else{
bool groundFound;
pos = m_vecPos;