mirror of
https://github.com/halpz/re3.git
synced 2025-07-10 13:58:54 +00:00
low effort save support
This commit is contained in:
@ -2613,14 +2613,12 @@ void CGarages::SetAllDoorsBackToOriginalHeight()
|
||||
}
|
||||
}
|
||||
|
||||
#define GARAGE_SIZE 208
|
||||
|
||||
void CGarages::Save(uint8 * buf, uint32 * size)
|
||||
{
|
||||
//INITSAVEBUF
|
||||
*size = 10692; // for some reason it's not actual size again
|
||||
//*size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage));
|
||||
#if !defined THIS_IS_STUPID && defined COMPATIBLE_SAVES
|
||||
memset(buf + 7340, 0, *size - 7340); // garbage data is written otherwise
|
||||
#endif
|
||||
INITSAVEBUF
|
||||
*size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * GARAGE_SIZE);
|
||||
CloseHideOutGaragesBeforeSave();
|
||||
WriteSaveBuf(buf, NumGarages);
|
||||
WriteSaveBuf(buf, (uint32)BombsAreFree);
|
||||
@ -2661,12 +2659,16 @@ void CGarages::Save(uint8 * buf, uint32 * size)
|
||||
WriteSaveBuf(buf, aGarages[i].m_vDir1);
|
||||
WriteSaveBuf(buf, aGarages[i].m_vDir2);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fSupZ);
|
||||
WriteSaveBuf(buf, aGarages[i].m_vecSSGaragePos);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fSSGarageAngle);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fDir1Len);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fDir2Len);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fInfX);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fSupX);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fInfY);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fSupY);
|
||||
WriteSaveBuf(buf, aGarages[i].m_nTimeCrusherCraneActivated);
|
||||
ZeroSaveBuf(buf, 4);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fDoorPos);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fDoorHeight);
|
||||
WriteSaveBuf(buf, aGarages[i].m_fDoor1X);
|
||||
@ -2679,18 +2681,26 @@ void CGarages::Save(uint8 * buf, uint32 * size)
|
||||
WriteSaveBuf(buf, aGarages[i].m_bCollectedCarsState);
|
||||
ZeroSaveBuf(buf, 3 + 4);
|
||||
ZeroSaveBuf(buf, sizeof(aGarages[i].m_sStoredCar));
|
||||
WriteSaveBuf(buf, aGarages[i].m_bInitialized);
|
||||
ZeroSaveBuf(buf, 3);
|
||||
#ifdef GTA_NETWORK
|
||||
ZeroSaveBuf(buf, 4);
|
||||
#endif
|
||||
WriteSaveBuf(buf, aGarages[i].m_bSSGarageAcceptedVehicle);
|
||||
WriteSaveBuf(buf, aGarages[i].m_bLocked);
|
||||
WriteSaveBuf(buf, aGarages[i].m_nSSGarageState);
|
||||
WriteSaveBuf(buf, aGarages[i].m_bSSGarageStateChanging);
|
||||
#else
|
||||
WriteSaveBuf(buf, aGarages[i]);
|
||||
#endif
|
||||
}
|
||||
//VALIDATESAVEBUF(*size);
|
||||
VALIDATESAVEBUF(*size);
|
||||
}
|
||||
|
||||
void CGarages::Load(uint8* buf, uint32 size)
|
||||
{
|
||||
//INITSAVEBUF
|
||||
assert(size == 10692);
|
||||
//assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage)));
|
||||
INITSAVEBUF
|
||||
assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * GARAGE_SIZE));
|
||||
CloseHideOutGaragesBeforeSave();
|
||||
ReadSaveBuf(&NumGarages, buf);
|
||||
int32 tempInt;
|
||||
@ -2734,12 +2744,16 @@ void CGarages::Load(uint8* buf, uint32 size)
|
||||
ReadSaveBuf(&aGarages[i].m_vDir1, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_vDir2, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fSupZ, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_vecSSGaragePos, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fSSGarageAngle, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fDir1Len, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fDir2Len, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fInfX, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fSupX, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fInfY, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fSupY, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_nTimeCrusherCraneActivated, buf);
|
||||
SkipSaveBuf(buf, 4);
|
||||
ReadSaveBuf(&aGarages[i].m_fDoorPos, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fDoorHeight, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_fDoor1X, buf);
|
||||
@ -2752,6 +2766,15 @@ void CGarages::Load(uint8* buf, uint32 size)
|
||||
ReadSaveBuf(&aGarages[i].m_bCollectedCarsState, buf);
|
||||
SkipSaveBuf(buf, 3 + 4);
|
||||
SkipSaveBuf(buf, sizeof(aGarages[i].m_sStoredCar));
|
||||
ReadSaveBuf(&aGarages[i].m_bInitialized, buf);
|
||||
SkipSaveBuf(buf, 3);
|
||||
#ifdef GTA_NETWORK
|
||||
SkipSaveBuf(buf, 4);
|
||||
#endif
|
||||
ReadSaveBuf(&aGarages[i].m_bSSGarageAcceptedVehicle, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_bLocked, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_nSSGarageState, buf);
|
||||
ReadSaveBuf(&aGarages[i].m_bSSGarageStateChanging, buf);
|
||||
#else
|
||||
ReadSaveBuf(&aGarages[i], buf);
|
||||
#endif
|
||||
@ -2765,11 +2788,14 @@ void CGarages::Load(uint8* buf, uint32 size)
|
||||
else
|
||||
aGarages[i].UpdateDoorsHeight();
|
||||
}
|
||||
//VALIDATESAVEBUF(size);
|
||||
VALIDATESAVEBUF(size);
|
||||
|
||||
MessageEndTime = 0;
|
||||
bCamShouldBeOutisde = false;
|
||||
MessageStartTime = 0;
|
||||
hGarages = DMAudio.CreateEntity(AUDIOTYPE_GARAGE, (void*)1);
|
||||
if (hGarages >= 0)
|
||||
DMAudio.SetEntityStatus(hGarages, TRUE);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1853,7 +1853,7 @@ void FlushLog()
|
||||
|
||||
const uint32 CRunningScript::nSaveStructSize =
|
||||
#ifdef COMPATIBLE_SAVES
|
||||
136;
|
||||
536;
|
||||
#else
|
||||
sizeof(CRunningScript);
|
||||
#endif
|
||||
@ -2691,7 +2691,7 @@ bool CTheScripts::Init(bool loaddata)
|
||||
InvisibilitySettingArray[i] = nil;
|
||||
if (loaddata) {
|
||||
printf("loaddata = true\n");
|
||||
//retval = GenericLoad(); // TODO
|
||||
retval = GenericLoad();
|
||||
}
|
||||
for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++)
|
||||
AllowedCollision[i] = 0;
|
||||
|
@ -2262,8 +2262,10 @@ void CTheScripts::SwapNearestBuildingModel(float x, float y, float z, float radi
|
||||
}
|
||||
}
|
||||
CBuilding* pReplacedBuilding = ((CBuilding*)pClosestEntity);
|
||||
pReplacedBuilding->ReplaceWithNewModel(mi2);
|
||||
AddToBuildingSwapArray(pReplacedBuilding, mi1, mi2);
|
||||
if (pReplacedBuilding) {
|
||||
pReplacedBuilding->ReplaceWithNewModel(mi2);
|
||||
AddToBuildingSwapArray(pReplacedBuilding, mi1, mi2);
|
||||
}
|
||||
}
|
||||
|
||||
void CTheScripts::AddToBuildingSwapArray(CBuilding* pBuilding, int32 old_model, int32 new_model)
|
||||
|
@ -2114,8 +2114,8 @@ void CTheScripts::RenderTheScriptDebugLines()
|
||||
}
|
||||
*/
|
||||
|
||||
#define SCRIPT_DATA_SIZE sizeof(CTheScripts::OnAMissionFlag) +\
|
||||
4 * sizeof(uint32) * MAX_NUM_BUILDING_SWAPS + 2 * sizeof(uint32) * MAX_NUM_INVISIBILITY_SETTINGS + 5 * sizeof(uint32)
|
||||
#define SCRIPT_DATA_SIZE sizeof(CTheScripts::OnAMissionFlag) + sizeof(tCollectiveData) * MAX_NUM_COLLECTIVES +\
|
||||
4 * sizeof(uint32) * MAX_NUM_BUILDING_SWAPS + 2 * sizeof(uint32) * MAX_NUM_INVISIBILITY_SETTINGS + 4 * sizeof(uint32)
|
||||
|
||||
void CTheScripts::SaveAllScripts(uint8* buf, uint32* size)
|
||||
{
|
||||
@ -2124,7 +2124,7 @@ INITSAVEBUF
|
||||
uint32 runningScripts = 0;
|
||||
for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext())
|
||||
runningScripts++;
|
||||
*size = CRunningScript::nSaveStructSize * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 3 * sizeof(uint32);
|
||||
*size = CRunningScript::nSaveStructSize * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 5 * sizeof(uint32);
|
||||
WriteSaveHeader(buf, 'S', 'C', 'R', '\0', *size - SAVE_HEADER_SIZE);
|
||||
WriteSaveBuf(buf, varSpace);
|
||||
for (uint32 i = 0; i < varSpace; i++)
|
||||
@ -2200,10 +2200,8 @@ INITSAVEBUF
|
||||
VALIDATESAVEBUF(*size)
|
||||
}
|
||||
|
||||
// TODO: I don't really understand how script loading works, so I leave it the VC way for now.
|
||||
bool CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
|
||||
{
|
||||
Init(); // TODO: in LCS CTheScripts::Init call GenericLoad, which then calls LoadAllScripts
|
||||
INITSAVEBUF
|
||||
CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE);
|
||||
uint32 varSpace, type, handle;
|
||||
@ -2222,7 +2220,6 @@ INITSAVEBUF
|
||||
else
|
||||
SkipSaveBuf(buf, 1);
|
||||
}
|
||||
// everything else is... gone? TODO
|
||||
ReadSaveBuf(&tmp, buf);
|
||||
script_assert(tmp == SCRIPT_DATA_SIZE);
|
||||
ReadSaveBuf(&OnAMissionFlag, buf);
|
||||
@ -2304,7 +2301,6 @@ INITSAVEBUF
|
||||
ReadSaveBuf(&runningScripts, buf);
|
||||
for (uint32 i = 0; i < runningScripts; i++)
|
||||
CRunningScript().Load(buf);
|
||||
StartTestScript(); // <- tmp hack
|
||||
return true;
|
||||
VALIDATESAVEBUF(size)
|
||||
}
|
||||
|
Reference in New Issue
Block a user