Merge pull request #772 from Nick007J/miami

Original save/load support + bugfixes
This commit is contained in:
erorcun 2020-10-18 19:37:49 +03:00 committed by GitHub
commit 497c179245
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 157 additions and 92 deletions

View file

@ -2,6 +2,7 @@
#include "Pools.h"
#include "Bike.h"
#include "Boat.h"
#include "CarCtrl.h"
#ifdef MISSION_REPLAY
@ -13,6 +14,8 @@
#include "Wanted.h"
#include "World.h"
//--MIAMI: file done
CCPtrNodePool *CPools::ms_pPtrNodePool;
CEntryInfoNodePool *CPools::ms_pEntryInfoNodePool;
CPedPool *CPools::ms_pPedPool;
@ -24,7 +27,6 @@ CDummyPool *CPools::ms_pDummyPool;
CAudioScriptObjectPool *CPools::ms_pAudioScriptObjectPool;
CColModelPool *CPools::ms_pColModelPool;
//--MIAMI: done
void
CPools::Initialise(void)
{
@ -40,7 +42,6 @@ CPools::Initialise(void)
ms_pColModelPool = new CColModelPool(NUMCOLMODELS, "ColModel");
}
//--MIAMI: done
void
CPools::ShutDown(void)
{
@ -119,7 +120,8 @@ void CPools::LoadVehiclePool(uint8* buf, uint32 size)
INITSAVEBUF
int nNumCars = ReadSaveBuf<int>(buf);
int nNumBoats = ReadSaveBuf<int>(buf);
for (int i = 0; i < nNumCars + nNumBoats; i++) {
int nNumBikes = ReadSaveBuf<int>(buf);
for (int i = 0; i < nNumCars + nNumBoats + nNumBikes; i++) {
uint32 type = ReadSaveBuf<uint32>(buf);
int16 model = ReadSaveBuf<int16>(buf);
CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY);
@ -131,13 +133,15 @@ INITSAVEBUF
pVehicle = new(slot) CBoat(model, RANDOM_VEHICLE);
else if (type == VEHICLE_TYPE_CAR)
pVehicle = new(slot) CAutomobile(model, RANDOM_VEHICLE);
else if (type == VEHICLE_TYPE_BIKE)
pVehicle = new(slot) CBike(model, RANDOM_VEHICLE);
else
assert(0);
--CCarCtrl::NumRandomCars;
pVehicle->Load(buf);
CWorld::Add(pVehicle);
#else
char* vbuf = new char[Max(CAutomobile::nSaveStructSize, CBoat::nSaveStructSize)];
char* vbuf = new char[Max(CBike::nSaveStructSize, Max(CAutomobile::nSaveStructSize, CBoat::nSaveStructSize))];
if (type == VEHICLE_TYPE_BOAT) {
memcpy(vbuf, buf, sizeof(CBoat));
SkipSaveBuf(buf, sizeof(CBoat));
@ -156,6 +160,17 @@ INITSAVEBUF
pAutomobile->Damage = ((CAutomobile*)vbuf)->Damage;
pAutomobile->SetupDamageAfterLoad();
}
else if (type == VEHICLE_TYPE_BIKE) {
#ifdef FIX_BUGS
memcpy(vbuf, buf, sizeof(CBike));
#else
memcpy(vbuf, buf, sizeof(CAutomobile));
#endif
SkipSaveBuf(buf, sizeof(CBike));
CBike* pBike = new(slot) CBike(model, RANDOM_VEHICLE);
pVehicle = pBike;
--CCarCtrl::NumRandomCars;
}
else
assert(0);
CVehicle* pBufferVehicle = (CVehicle*)vbuf;
@ -193,6 +208,7 @@ INITSAVEBUF
(pVehicle->GetAddressOfEntityProperties())[0] = (pBufferVehicle->GetAddressOfEntityProperties())[0];
(pVehicle->GetAddressOfEntityProperties())[1] = (pBufferVehicle->GetAddressOfEntityProperties())[1];
pVehicle->AutoPilot = pBufferVehicle->AutoPilot;
CCarCtrl::UpdateCarCount(pVehicle, false);
CWorld::Add(pVehicle);
delete[] vbuf;
#endif
@ -205,6 +221,7 @@ void CPools::SaveVehiclePool(uint8* buf, uint32* size)
INITSAVEBUF
int nNumCars = 0;
int nNumBoats = 0;
int nNumBikes = 0;
int nPoolSize = GetVehiclePool()->GetSize();
for (int i = 0; i < nPoolSize; i++) {
CVehicle* pVehicle = GetVehiclePool()->GetSlot(i);
@ -226,19 +243,25 @@ INITSAVEBUF
++nNumCars;
if (pVehicle->IsBoat() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving))
++nNumBoats;
if (pVehicle->IsBike() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving))
++nNumBoats;
#else
if (!pVehicle->pDriver && !bHasPassenger) {
if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE)
++nNumCars;
if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE)
++nNumBoats;
if (pVehicle->IsBike() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE)
++nNumBoats;
#endif
}
}
*size = nNumCars * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CAutomobile::nSaveStructSize) + sizeof(int) +
nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBoat::nSaveStructSize) + sizeof(int);
nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBoat::nSaveStructSize) + sizeof(int) +
nNumBikes * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBike::nSaveStructSize) + sizeof(int);
WriteSaveBuf(buf, nNumCars);
WriteSaveBuf(buf, nNumBoats);
WriteSaveBuf(buf, nNumBikes);
for (int i = 0; i < nPoolSize; i++) {
CVehicle* pVehicle = GetVehiclePool()->GetSlot(i);
if (!pVehicle)
@ -258,9 +281,9 @@ INITSAVEBUF
#endif
#ifdef COMPATIBLE_SAVES
#ifdef MISSION_REPLAY
if ((pVehicle->IsCar() || pVehicle->IsBoat()) && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) {
if ((pVehicle->IsCar() || pVehicle->IsBoat() || pVehicle->IsBike()) && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) {
#else
if ((pVehicle->IsCar() || pVehicle->IsBoat()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
if ((pVehicle->IsCar() || pVehicle->IsBoat() || pVehicle->IsBike()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
#endif
WriteSaveBuf<uint32>(buf, pVehicle->m_vehType);
WriteSaveBuf<int16>(buf, pVehicle->GetModelIndex());
@ -290,6 +313,17 @@ INITSAVEBUF
memcpy(buf, pVehicle, sizeof(CBoat));
SkipSaveBuf(buf, sizeof(CBoat));
}
#ifdef MISSION_REPLAY
if (pVehicle->IsBike() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) {
#else
if (pVehicle->IsBike() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
#endif
WriteSaveBuf(buf, (uint32)pVehicle->m_vehType);
WriteSaveBuf(buf, pVehicle->GetModelIndex());
WriteSaveBuf(buf, GetVehicleRef(pVehicle));
memcpy(buf, pVehicle, sizeof(CBike));
SkipSaveBuf(buf, sizeof(CBike));
}
#endif
}
}
@ -311,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);
@ -343,6 +378,9 @@ INITSAVEBUF
CopyToBuf(buf, bGlassBroken);
CopyToBuf(buf, bHasBeenDamaged);
CopyToBuf(buf, bUseVehicleColours);
CopyToBuf(buf, pObject->m_nCostValue);
CopyToBuf(buf, pObject->m_nBonusValue);
SkipSaveBuf(buf, 1);
CopyToBuf(buf, pObject->m_fCollisionDamageMultiplier);
CopyToBuf(buf, pObject->m_nCollisionDamageEffect);
CopyToBuf(buf, pObject->m_nSpecialCollisionResponseCases);
@ -392,6 +430,9 @@ INITSAVEBUF
pBufferObject->bHasBeenDamaged = bitFlag;
CopyFromBuf(buf, bitFlag);
pBufferObject->bUseVehicleColours = bitFlag;
CopyFromBuf(buf, pBufferObject->m_nCostValue);
CopyFromBuf(buf, pBufferObject->m_nBonusValue);
SkipSaveBuf(buf, 1);
CopyFromBuf(buf, pBufferObject->m_fCollisionDamageMultiplier);
CopyFromBuf(buf, pBufferObject->m_nCollisionDamageEffect);
CopyFromBuf(buf, pBufferObject->m_nSpecialCollisionResponseCases);
@ -426,6 +467,8 @@ INITSAVEBUF
(pObject->GetAddressOfEntityProperties())[1] = (pBufferObject->GetAddressOfEntityProperties())[1];
#endif
pObject->bHasCollided = false;
pObject->m_nCostValue = pBufferObject->m_nCostValue;
pObject->m_nBonusValue = pBufferObject->m_nBonusValue;
CWorld::Add(pObject);
delete[] obuf;
}

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

@ -70,7 +70,8 @@ public:
uint8 bUseVehicleColours : 1;
uint8 bIsWeapon : 1;
uint8 bIsStreetLight : 1;
int8 m_nBonusValue;
int8 m_nBonusValue;
uint16 m_nCostValue;
float m_fCollisionDamageMultiplier;
uint8 m_nCollisionDamageEffect;
uint8 m_nSpecialCollisionResponseCases;

View file

@ -20040,15 +20040,13 @@ CPed::Save(uint8*& buf)
CopyToBuf(buf, GetPosition().z);
SkipSaveBuf(buf, 288);
CopyToBuf(buf, CharCreatedBy);
SkipSaveBuf(buf, 351);
SkipSaveBuf(buf, 499);
CopyToBuf(buf, m_fHealth);
CopyToBuf(buf, m_fArmour);
SkipSaveBuf(buf, 148);
for (int i = 0; i < 13; i++) // has to be hardcoded
SkipSaveBuf(buf, 172);
for (int i = 0; i < 10; i++) // has to be hardcoded
m_weapons[i].Save(buf);
SkipSaveBuf(buf, 5);
CopyToBuf(buf, m_maxWeaponTypeAllowed);
SkipSaveBuf(buf, 162);
SkipSaveBuf(buf, 252);
}
void
@ -20060,16 +20058,15 @@ CPed::Load(uint8*& buf)
CopyFromBuf(buf, GetMatrix().GetPosition().z);
SkipSaveBuf(buf, 288);
CopyFromBuf(buf, CharCreatedBy);
SkipSaveBuf(buf, 351);
SkipSaveBuf(buf, 499);
CopyFromBuf(buf, m_fHealth);
CopyFromBuf(buf, m_fArmour);
SkipSaveBuf(buf, 148);
SkipSaveBuf(buf, 172);
m_currentWeapon = WEAPONTYPE_UNARMED;
CWeapon bufWeapon;
for (int i = 0; i < 13; i++) { // has to be hardcoded
for (int i = 0; i < 10; i++) { // has to be hardcoded
bufWeapon.Load(buf);
if (i >= 10)
continue; // tmp hack before we fix save/load
if (bufWeapon.m_eWeaponType != WEAPONTYPE_UNARMED) {
int modelId = CWeaponInfo::GetWeaponInfo(bufWeapon.m_eWeaponType)->m_nModelId;
@ -20084,9 +20081,7 @@ CPed::Load(uint8*& buf)
GiveWeapon(bufWeapon.m_eWeaponType, bufWeapon.m_nAmmoTotal);
}
}
SkipSaveBuf(buf, 5);
CopyFromBuf(buf, m_maxWeaponTypeAllowed);
SkipSaveBuf(buf, 162);
SkipSaveBuf(buf, 252);
}
#undef CopyFromBuf
#undef CopyToBuf

View file

@ -135,8 +135,10 @@ void CPedAttractorManager::RemoveIceCreamVanEffects(C2dEffect* pEffect)
if (vVehicleToEffect.empty())
return;
for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend();) {
if (assoc->GetVehicle() != pVehicle)
return;
if (assoc->GetVehicle() != pVehicle) {
assoc++;
continue;
}
uint32 total = 0;
for (uint32 j = 0; j < NUM_ATTRACTORS_FOR_ICECREAM_VAN; j++) {
if (FindAssociatedAttractor(assoc->GetEffect(j), vIceCreamAttractors))

View file

@ -23,7 +23,7 @@
const uint32 CPlayerPed::nSaveStructSize =
#ifdef COMPATIBLE_SAVES
1520;
1752;
#else
sizeof(CPlayerPed);
#endif
@ -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
@ -1949,7 +1949,7 @@ CPlayerPed::Load(uint8*& buf)
CopyFromBuf(buf, m_nTargettableObjects[1]);
CopyFromBuf(buf, m_nTargettableObjects[2]);
CopyFromBuf(buf, m_nTargettableObjects[3]);
SkipSaveBuf(buf, 116);
SkipSaveBuf(buf, 164);
}
#undef CopyFromBuf
#undef CopyToBuf

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,8 +41,10 @@
#include "Timecycle.h"
#include "Fluff.h"
#define BLOCK_COUNT 20
#define SIZE_OF_SIMPLEVARS 0xFC
// --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);
@ -194,12 +197,6 @@ GenericSave(int file)
WriteDataToBufferPointer(buf, CWeather::NewWeatherType);
WriteDataToBufferPointer(buf, CWeather::ForcedWeatherType);
WriteDataToBufferPointer(buf, CWeather::InterpolationValue);
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nSecond);
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMinute);
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nHour);
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nDay);
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMonth);
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nYear);
WriteDataToBufferPointer(buf, CWeather::WeatherTypeInList);
#ifdef COMPATIBLE_SAVES
// converted to float for compatibility with original format
@ -227,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;
@ -234,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++) {
@ -331,12 +329,6 @@ GenericLoad()
ReadDataFromBufferPointer(buf, CWeather::NewWeatherType);
ReadDataFromBufferPointer(buf, CWeather::ForcedWeatherType);
ReadDataFromBufferPointer(buf, CWeather::InterpolationValue);
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nSecond);
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nMinute);
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nHour);
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nDay);
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nMonth);
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nYear);
ReadDataFromBufferPointer(buf, CWeather::WeatherTypeInList);
#ifdef COMPATIBLE_SAVES
// converted to float for compatibility with original format
@ -470,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

@ -59,7 +59,7 @@ bool CAutomobile::m_sAllTaxiLights;
const uint32 CAutomobile::nSaveStructSize =
#ifdef COMPATIBLE_SAVES
1448;
1500;
#else
sizeof(CAutomobile);
#endif
@ -5713,7 +5713,7 @@ CAutomobile::Save(uint8*& buf)
{
CVehicle::Save(buf);
WriteSaveBuf<CDamageManager>(buf, Damage);
SkipSaveBuf(buf, 800 - sizeof(CDamageManager));
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
}
void
@ -5721,7 +5721,7 @@ CAutomobile::Load(uint8*& buf)
{
CVehicle::Load(buf);
Damage = ReadSaveBuf<CDamageManager>(buf);
SkipSaveBuf(buf, 800 - sizeof(CDamageManager));
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
SetupDamageAfterLoad();
}
#endif

View file

@ -39,6 +39,14 @@
//--MIAMI: file done
const uint32 CBike::nSaveStructSize =
#ifdef COMPATIBLE_SAVES
1260;
#else
sizeof(CBoat);
#endif
// TODO: maybe put this somewhere else
inline void
GetRelativeMatrix(RwMatrix *mat, RwFrame *frm, RwFrame *end)
@ -2922,3 +2930,19 @@ CBike::ReduceHornCounter(void)
if(m_nCarHornTimer != 0)
m_nCarHornTimer--;
}
#ifdef COMPATIBLE_SAVES
void
CBike::Save(uint8*& buf)
{
CVehicle::Save(buf);
SkipSaveBuf(buf, 1260 - 672);
}
void
CBike::Load(uint8*& buf)
{
CVehicle::Load(buf);
SkipSaveBuf(buf, 1260 - 672);
}
#endif

View file

@ -132,6 +132,12 @@ public:
void Fix(void);
void SetupModelNodes(void);
void ReduceHornCounter(void);
#ifdef COMPATIBLE_SAVES
virtual void Save(uint8*& buf);
virtual void Load(uint8*& buf);
#endif
static const uint32 nSaveStructSize;
};
// These functions and function names are made up

View file

@ -43,7 +43,7 @@ CBoat *CBoat::apFrameWakeGeneratingBoats[4];
const uint32 CBoat::nSaveStructSize =
#ifdef COMPATIBLE_SAVES
1156;
1216;
#else
sizeof(CBoat);
#endif
@ -1449,13 +1449,13 @@ void
CBoat::Save(uint8*& buf)
{
CVehicle::Save(buf);
SkipSaveBuf(buf, 1156 - 648);
SkipSaveBuf(buf, 1216 - 672);
}
void
CBoat::Load(uint8*& buf)
{
CVehicle::Load(buf);
SkipSaveBuf(buf, 1156 - 648);
SkipSaveBuf(buf, 1216 - 672);
}
#endif

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;

View file

@ -26,7 +26,6 @@ public:
};
CBuilding *m_pCraneEntity;
CObject *m_pHook;
int32 m_nAudioEntity;
float m_fPickupX1;
float m_fPickupX2;
float m_fPickupY1;

View file

@ -2367,15 +2367,15 @@ CVehicle::Save(uint8*& buf)
WriteSaveBuf<float>(buf, GetPosition().z);
SkipSaveBuf(buf, 16);
SaveEntityFlags(buf);
SkipSaveBuf(buf, 212);
SkipSaveBuf(buf, 208);
AutoPilot.Save(buf);
WriteSaveBuf<int8>(buf, m_currentColour1);
WriteSaveBuf<int8>(buf, m_currentColour2);
SkipSaveBuf(buf, 2);
WriteSaveBuf<int16>(buf, m_nAlarmState);
SkipSaveBuf(buf, 43);
SkipSaveBuf(buf, 42);
WriteSaveBuf<uint8>(buf, m_nNumMaxPassengers);
SkipSaveBuf(buf, 2);
SkipSaveBuf(buf, 3);
WriteSaveBuf<float>(buf, field_1D0[0]);
WriteSaveBuf<float>(buf, field_1D0[1]);
WriteSaveBuf<float>(buf, field_1D0[2]);
@ -2398,13 +2398,13 @@ CVehicle::Save(uint8*& buf)
WriteSaveBuf<uint8>(buf, m_nCurrentGear);
SkipSaveBuf(buf, 3);
WriteSaveBuf<float>(buf, m_fChangeGearTime);
SkipSaveBuf(buf, 4);
SkipSaveBuf(buf, 12);
WriteSaveBuf<uint32>(buf, m_nTimeOfDeath);
SkipSaveBuf(buf, 2);
WriteSaveBuf<int16>(buf, m_nBombTimer);
SkipSaveBuf(buf, 12);
WriteSaveBuf<int8>(buf, m_nDoorLock);
SkipSaveBuf(buf, 99);
SkipSaveBuf(buf, 111);
}
void
@ -2430,15 +2430,15 @@ CVehicle::Load(uint8*& buf)
m_matrix = tmp;
SkipSaveBuf(buf, 16);
LoadEntityFlags(buf);
SkipSaveBuf(buf, 212);
SkipSaveBuf(buf, 208);
AutoPilot.Load(buf);
m_currentColour1 = ReadSaveBuf<int8>(buf);
m_currentColour2 = ReadSaveBuf<int8>(buf);
SkipSaveBuf(buf, 2);
m_nAlarmState = ReadSaveBuf<int16>(buf);
SkipSaveBuf(buf, 43);
SkipSaveBuf(buf, 42);
m_nNumMaxPassengers = ReadSaveBuf<int8>(buf);
SkipSaveBuf(buf, 2);
SkipSaveBuf(buf, 3);
field_1D0[0] = ReadSaveBuf<float>(buf);
field_1D0[1] = ReadSaveBuf<float>(buf);
field_1D0[2] = ReadSaveBuf<float>(buf);
@ -2460,13 +2460,13 @@ CVehicle::Load(uint8*& buf)
m_nCurrentGear = ReadSaveBuf<uint8>(buf);
SkipSaveBuf(buf, 3);
m_fChangeGearTime = ReadSaveBuf<float>(buf);
SkipSaveBuf(buf, 4);
SkipSaveBuf(buf, 12);
m_nTimeOfDeath = ReadSaveBuf<uint32>(buf);
SkipSaveBuf(buf, 2);
m_nBombTimer = ReadSaveBuf<int16>(buf);
SkipSaveBuf(buf, 12);
m_nDoorLock = (eCarLock)ReadSaveBuf<int8>(buf);
SkipSaveBuf(buf, 99);
SkipSaveBuf(buf, 111);
}
#endif