Merge remote-tracking branch 'upstream/lcs' into lcs

This commit is contained in:
Nikolay Korolev
2021-07-02 11:28:46 +03:00
73 changed files with 813 additions and 749 deletions

View File

@ -5,6 +5,7 @@
#include "CarCtrl.h"
#include "Curves.h"
#include "PathFind.h"
#include "SaveBuf.h"
void CAutoPilot::ModifySpeed(float speed)
{
@ -92,43 +93,44 @@ void CAutoPilot::Save(uint8*& buf)
void CAutoPilot::Load(uint8*& buf)
{
m_nCurrentRouteNode = ReadSaveBuf<int32>(buf);
m_nNextRouteNode = ReadSaveBuf<int32>(buf);
m_nPrevRouteNode = ReadSaveBuf<int32>(buf);
m_nTimeEnteredCurve = ReadSaveBuf<int32>(buf);
m_nTimeToSpendOnCurrentCurve = ReadSaveBuf<int32>(buf);
m_nCurrentPathNodeInfo = ReadSaveBuf<uint32>(buf);
m_nNextPathNodeInfo = ReadSaveBuf<uint32>(buf);
m_nPreviousPathNodeInfo = ReadSaveBuf<uint32>(buf);
m_nAntiReverseTimer = ReadSaveBuf<uint32>(buf);
m_nTimeToStartMission = ReadSaveBuf<uint32>(buf);
m_nPreviousDirection = ReadSaveBuf<int8>(buf);
m_nCurrentDirection = ReadSaveBuf<int8>(buf);
m_nNextDirection = ReadSaveBuf<int8>(buf);
m_nCurrentLane = ReadSaveBuf<int8>(buf);
m_nNextLane = ReadSaveBuf<int8>(buf);
m_nDrivingStyle = ReadSaveBuf<uint8>(buf);
m_nCarMission = ReadSaveBuf<uint8>(buf);
m_nTempAction = ReadSaveBuf<uint8>(buf);
m_nTimeTempAction = ReadSaveBuf<uint32>(buf);
m_fMaxTrafficSpeed = ReadSaveBuf<float>(buf);
m_nCruiseSpeed = ReadSaveBuf<uint8>(buf);
m_nCruiseSpeedMultiplierType = ReadSaveBuf<uint8>(buf);
ReadSaveBuf(&m_nCurrentRouteNode, buf);
ReadSaveBuf(&m_nNextRouteNode, buf);
ReadSaveBuf(&m_nPrevRouteNode, buf);
ReadSaveBuf(&m_nTimeEnteredCurve, buf);
ReadSaveBuf(&m_nTimeToSpendOnCurrentCurve, buf);
ReadSaveBuf(&m_nCurrentPathNodeInfo, buf);
ReadSaveBuf(&m_nNextPathNodeInfo, buf);
ReadSaveBuf(&m_nPreviousPathNodeInfo, buf);
ReadSaveBuf(&m_nAntiReverseTimer, buf);
ReadSaveBuf(&m_nTimeToStartMission, buf);
ReadSaveBuf(&m_nPreviousDirection, buf);
ReadSaveBuf(&m_nCurrentDirection, buf);
ReadSaveBuf(&m_nNextDirection, buf);
ReadSaveBuf(&m_nCurrentLane, buf);
ReadSaveBuf(&m_nNextLane, buf);
ReadSaveBuf(&m_nDrivingStyle, buf);
ReadSaveBuf(&m_nCarMission, buf);
ReadSaveBuf(&m_nTempAction, buf);
ReadSaveBuf(&m_nTimeTempAction, buf);
ReadSaveBuf(&m_fMaxTrafficSpeed, buf);
ReadSaveBuf(&m_nCruiseSpeed, buf);
ReadSaveBuf(&m_nCruiseSpeedMultiplierType, buf);
SkipSaveBuf(buf, 2);
m_fCruiseSpeedMultiplier = ReadSaveBuf<float>(buf);
uint8 flags = ReadSaveBuf<uint8>(buf);
ReadSaveBuf(&m_fCruiseSpeedMultiplier, buf);
uint8 flags;
ReadSaveBuf(&flags, buf);
m_bSlowedDownBecauseOfCars = !!(flags & BIT(0));
m_bSlowedDownBecauseOfPeds = !!(flags & BIT(1));
m_bStayInCurrentLevel = !!(flags & BIT(2));
m_bStayInFastLane = !!(flags & BIT(3));
m_bIgnorePathfinding = !!(flags & BIT(4));
m_nSwitchDistance = ReadSaveBuf<uint8>(buf);
ReadSaveBuf(&m_nSwitchDistance, buf);
SkipSaveBuf(buf, 2);
m_vecDestinationCoors.x = ReadSaveBuf<float>(buf);
m_vecDestinationCoors.y = ReadSaveBuf<float>(buf);
m_vecDestinationCoors.z = ReadSaveBuf<float>(buf);
ReadSaveBuf(&m_vecDestinationCoors.x, buf);
ReadSaveBuf(&m_vecDestinationCoors.y, buf);
ReadSaveBuf(&m_vecDestinationCoors.z, buf);
SkipSaveBuf(buf, 32);
m_nPathFindNodesCount = ReadSaveBuf<int16>(buf);
ReadSaveBuf(&m_nPathFindNodesCount, buf);
SkipSaveBuf(buf, 6);
}
#endif

View File

@ -2608,7 +2608,7 @@ void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CVehicle* pVehicle, float
float angleToTarget = GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
float angleForward = GetATanOfXY(forward.x, forward.y);
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
steerAngle = clamp(steerAngle, -DEFAULT_MAX_STEER_ANGLE, DEFAULT_MAX_STEER_ANGLE);
steerAngle = Clamp(steerAngle, -DEFAULT_MAX_STEER_ANGLE, DEFAULT_MAX_STEER_ANGLE);
#ifdef FIX_BUGS
float speedTarget = pVehicle->AutoPilot.GetCruiseSpeed();
#else
@ -2768,7 +2768,7 @@ void CCarCtrl::SteerAIPlaneTowardsTargetCoors(CAutomobile* pPlane)
{
CVector2D vecToTarget = pPlane->AutoPilot.m_vecDestinationCoors - pPlane->GetPosition();
float fForwardZ = (pPlane->AutoPilot.m_vecDestinationCoors.z - pPlane->GetPosition().z) / vecToTarget.Magnitude();
fForwardZ = clamp(fForwardZ, -0.3f, 0.3f);
fForwardZ = Clamp(fForwardZ, -0.3f, 0.3f);
float angle = GetATanOfXY(vecToTarget.x, vecToTarget.y);
while (angle > TWOPI)
angle -= TWOPI;

View File

@ -30,6 +30,7 @@
#include "Automobile.h"
#include "MBlur.h"
#include "screendroplets.h"
#include "SaveBuf.h"
uint8 CGameLogic::ActivePlayers;
uint8 CGameLogic::ShortCutState;
@ -612,12 +613,12 @@ void
CGameLogic::Load(uint8* buf, uint32 size)
{
INITSAVEBUF
NumAfterDeathStartPoints = ReadSaveBuf<uint32>(buf);
ReadSaveBuf(&NumAfterDeathStartPoints, buf);
for (int i = 0; i < NUM_SHORTCUT_START_POINTS; i++) {
AfterDeathStartPoints[i].x = ReadSaveBuf<float>(buf);
AfterDeathStartPoints[i].y = ReadSaveBuf<float>(buf);
AfterDeathStartPoints[i].z = ReadSaveBuf<float>(buf);
AfterDeathStartPointOrientation[i] = ReadSaveBuf<float>(buf);
ReadSaveBuf(&AfterDeathStartPoints[i].x, buf);
ReadSaveBuf(&AfterDeathStartPoints[i].y, buf);
ReadSaveBuf(&AfterDeathStartPoints[i].z, buf);
ReadSaveBuf(&AfterDeathStartPointOrientation[i], buf);
}
VALIDATESAVEBUF(size)
}

View File

@ -27,6 +27,7 @@
#include "Wanted.h"
#include "World.h"
#include "VarConsole.h"
#include "SaveBuf.h"
#define CRUSHER_GARAGE_X1 (1135.5f)
#define CRUSHER_GARAGE_Y1 (57.0f)
@ -2650,22 +2651,25 @@ void CGarages::Load(uint8* buf, uint32 size)
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)));
CloseHideOutGaragesBeforeSave();
NumGarages = ReadSaveBuf<uint32>(buf);
BombsAreFree = ReadSaveBuf<uint32>(buf);
RespraysAreFree = ReadSaveBuf<uint32>(buf);
CarsCollected = ReadSaveBuf<int32>(buf);
BankVansCollected = ReadSaveBuf<int32>(buf);
PoliceCarsCollected = ReadSaveBuf<int32>(buf);
ReadSaveBuf(&NumGarages, buf);
int32 tempInt;
ReadSaveBuf(&tempInt, buf);
BombsAreFree = tempInt ? true : false;
ReadSaveBuf(&tempInt, buf);
RespraysAreFree = tempInt ? true : false;
ReadSaveBuf(&CarsCollected, buf);
ReadSaveBuf(&BankVansCollected, buf);
ReadSaveBuf(&PoliceCarsCollected, buf);
for (int i = 0; i < TOTAL_COLLECTCARS_GARAGES; i++)
CarTypesCollected[i] = ReadSaveBuf<uint32>(buf);
LastTimeHelpMessage = ReadSaveBuf<uint32>(buf);
ReadSaveBuf(&CarTypesCollected[i], buf);
ReadSaveBuf(&LastTimeHelpMessage, buf);
for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++) {
for (int j = 0; j < TOTAL_HIDEOUT_GARAGES; j++) {
aCarsInSafeHouses[j][i] = ReadSaveBuf<CStoredCar>(buf);
ReadSaveBuf(&aCarsInSafeHouses[j][i], buf);
}
}
for (int i = 0; i < NUM_GARAGES; i++) {
aGarages[i] = ReadSaveBuf<CGarage>(buf);
ReadSaveBuf(&aGarages[i], buf);
aGarages[i].m_pDoor1 = nil;
aGarages[i].m_pDoor2 = nil;
aGarages[i].m_pTarget = nil;

View File

@ -13,6 +13,7 @@
#include "RpAnimBlend.h"
#include "AnimBlendAssociation.h"
#include "soundlist.h"
#include "SaveBuf.h"
#ifdef FIX_BUGS
#include "Replay.h"
#endif
@ -197,10 +198,10 @@ void
CPhoneInfo::Load(uint8 *buf, uint32 size)
{
INITSAVEBUF
m_nMax = ReadSaveBuf<int32>(buf);
m_nScriptPhonesMax = ReadSaveBuf<int32>(buf);
ReadSaveBuf(&m_nMax, buf);
ReadSaveBuf(&m_nScriptPhonesMax, buf);
for (int i = 0; i < NUMPHONES; i++) {
m_aPhones[i] = ReadSaveBuf<CPhone>(buf);
ReadSaveBuf(&m_aPhones[i], buf);
// It's saved as building pool index in save file, convert it to true entity
if (m_aPhones[i].m_pEntity) {
m_aPhones[i].m_pEntity = CPools::GetBuildingPool()->GetSlot((uintptr)m_aPhones[i].m_pEntity - 1);

View File

@ -33,6 +33,7 @@
#include "Hud.h"
#include "Messages.h"
#include "Streaming.h"
#include "SaveBuf.h"
CPickup CPickups::aPickUps[NUMPICKUPS];
int16 CPickups::NumMessages;
@ -1441,7 +1442,7 @@ CPickups::Load(uint8 *buf, uint32 size)
INITSAVEBUF
for (int32 i = 0; i < NUMPICKUPS; i++) {
aPickUps[i] = ReadSaveBuf<CPickup>(buf);
ReadSaveBuf(&aPickUps[i], buf);
if (aPickUps[i].m_eType != PICKUP_NONE) {
if (aPickUps[i].m_pObject != nil)
@ -1452,12 +1453,12 @@ INITSAVEBUF
}
CollectedPickUpIndex = ReadSaveBuf<uint16>(buf);
ReadSaveBuf<uint16>(buf);
ReadSaveBuf(&CollectedPickUpIndex, buf);
SkipSaveBuf(buf, 2);
NumMessages = 0;
for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++)
aPickUpsCollected[i] = ReadSaveBuf<int32>(buf);
ReadSaveBuf(&aPickUpsCollected[i], buf);
VALIDATESAVEBUF(size)
}

View File

@ -425,9 +425,9 @@ void CReplay::RecordParticle(tParticleType type, const CVector& vecPos, const CV
pp->pos_x = 4.0f * vecPos.x;
pp->pos_y = 4.0f * vecPos.y;
pp->pos_z = 4.0f * vecPos.z;
pp->dir_x = 120.0f * clamp(vecDir.x, -1.0f, 1.0f);
pp->dir_y = 120.0f * clamp(vecDir.y, -1.0f, 1.0f);
pp->dir_z = 120.0f * clamp(vecDir.z, -1.0f, 1.0f);
pp->dir_x = 120.0f * Clamp(vecDir.x, -1.0f, 1.0f);
pp->dir_y = 120.0f * Clamp(vecDir.y, -1.0f, 1.0f);
pp->dir_z = 120.0f * Clamp(vecDir.z, -1.0f, 1.0f);
pp->size = fSize;
pp->r = color.red;
pp->g = color.green;
@ -463,8 +463,8 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
CAnimBlendAssociation* main = RpAnimBlendClumpGetMainAssociation((RpClump*)ped->m_rwObject, &second, &blend_amount);
if (main){
state->animId = main->animId;
state->time = 255.0f / 4.0f * clamp(main->currentTime, 0.0f, 4.0f);
state->speed = 255.0f / 3.0f * clamp(main->speed, 0.0f, 3.0f);
state->time = 255.0f / 4.0f * Clamp(main->currentTime, 0.0f, 4.0f);
state->speed = 255.0f / 3.0f * Clamp(main->speed, 0.0f, 3.0f);
state->groupId = main->groupId;
}else{
state->animId = 3;
@ -474,9 +474,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
}
if (second) {
state->secAnimId = second->animId;
state->secTime = 255.0f / 4.0f * clamp(second->currentTime, 0.0f, 4.0f);
state->secSpeed = 255.0f / 3.0f * clamp(second->speed, 0.0f, 3.0f);
state->blendAmount = 255.0f / 2.0f * clamp(blend_amount, 0.0f, 2.0f);
state->secTime = 255.0f / 4.0f * Clamp(second->currentTime, 0.0f, 4.0f);
state->secSpeed = 255.0f / 3.0f * Clamp(second->speed, 0.0f, 3.0f);
state->blendAmount = 255.0f / 2.0f * Clamp(blend_amount, 0.0f, 2.0f);
state->secGroupId = second->groupId;
}else{
state->secAnimId = 0;
@ -488,9 +488,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject);
if (partial) {
state->partAnimId = partial->animId;
state->partAnimTime = 255.0f / 4.0f * clamp(partial->currentTime, 0.0f, 4.0f);
state->partAnimSpeed = 255.0f / 3.0f * clamp(partial->speed, 0.0f, 3.0f);
state->partBlendAmount = 255.0f / 2.0f * clamp(partial->blendAmount, 0.0f, 2.0f);
state->partAnimTime = 255.0f / 4.0f * Clamp(partial->currentTime, 0.0f, 4.0f);
state->partAnimSpeed = 255.0f / 3.0f * Clamp(partial->speed, 0.0f, 3.0f);
state->partBlendAmount = 255.0f / 2.0f * Clamp(partial->blendAmount, 0.0f, 2.0f);
state->partGroupId = partial->groupId;
}else{
state->partAnimId = 0;
@ -507,10 +507,10 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainAssociation_N((RpClump*)ped->m_rwObject, i);
if (assoc){
state->aAnimId[i] = assoc->animId;
state->aCurTime[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f);
state->aSpeed[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f);
state->aBlendAmount[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f);
state->aBlendDelta[i] = 127.0f / 32.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
state->aCurTime[i] = 255.0f / 4.0f * Clamp(assoc->currentTime, 0.0f, 4.0f);
state->aSpeed[i] = 255.0f / 3.0f * Clamp(assoc->speed, 0.0f, 3.0f);
state->aBlendAmount[i] = 255.0f / 2.0f * Clamp(assoc->blendAmount, 0.0f, 2.0f);
state->aBlendDelta[i] = 127.0f / 32.0f * Clamp(assoc->blendDelta, -16.0f, 16.0f);
state->aFlags[i] = assoc->flags;
state->aGroupId[i] = assoc->groupId;
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
@ -533,10 +533,10 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainPartialAssociation_N((RpClump*)ped->m_rwObject, i);
if (assoc) {
state->aAnimId2[i] = assoc->animId;
state->aCurTime2[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f);
state->aSpeed2[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f);
state->aBlendAmount2[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f);
state->aBlendDelta2[i] = 127.0f / 16.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
state->aCurTime2[i] = 255.0f / 4.0f * Clamp(assoc->currentTime, 0.0f, 4.0f);
state->aSpeed2[i] = 255.0f / 3.0f * Clamp(assoc->speed, 0.0f, 3.0f);
state->aBlendAmount2[i] = 255.0f / 2.0f * Clamp(assoc->blendAmount, 0.0f, 2.0f);
state->aBlendDelta2[i] = 127.0f / 16.0f * Clamp(assoc->blendDelta, -16.0f, 16.0f);
state->aFlags2[i] = assoc->flags;
state->aGroupId2[i] = assoc->groupId;
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {

View File

@ -3,6 +3,7 @@
#include "Restart.h"
#include "Zones.h"
#include "PathFind.h"
#include "SaveBuf.h"
uint8 CRestart::OverrideHospitalLevel;
uint8 CRestart::OverridePoliceStationLevel;
@ -173,29 +174,28 @@ INITSAVEBUF
CheckSaveHeader(buf, 'R','S','T','\0', size - SAVE_HEADER_SIZE);
for (int i = 0; i < NUM_RESTART_POINTS; i++) {
HospitalRestartPoints[i] = ReadSaveBuf<CVector>(buf);
HospitalRestartHeadings[i] = ReadSaveBuf<float>(buf);
ReadSaveBuf(&HospitalRestartPoints[i], buf);
ReadSaveBuf(&HospitalRestartHeadings[i], buf);
}
for (int i = 0; i < NUM_RESTART_POINTS; i++) {
PoliceRestartPoints[i] = ReadSaveBuf<CVector>(buf);
PoliceRestartHeadings[i] = ReadSaveBuf<float>(buf);
ReadSaveBuf(&PoliceRestartPoints[i], buf);
ReadSaveBuf(&PoliceRestartHeadings[i], buf);
}
NumberOfHospitalRestarts = ReadSaveBuf<uint16>(buf);
NumberOfPoliceRestarts = ReadSaveBuf<uint16>(buf);
bOverrideRestart = ReadSaveBuf<bool>(buf);
ReadSaveBuf(&NumberOfHospitalRestarts, buf);
ReadSaveBuf(&NumberOfPoliceRestarts, buf);
ReadSaveBuf(&bOverrideRestart, buf);
// skip something unused
ReadSaveBuf<uint8>(buf);
ReadSaveBuf<uint16>(buf);
SkipSaveBuf(buf, 3);
OverridePosition = ReadSaveBuf<CVector>(buf);
OverrideHeading = ReadSaveBuf<float>(buf);
bFadeInAfterNextDeath = ReadSaveBuf<bool>(buf);
bFadeInAfterNextArrest = ReadSaveBuf<bool>(buf);
OverrideHospitalLevel = ReadSaveBuf<uint8>(buf);
OverridePoliceStationLevel = ReadSaveBuf<uint8>(buf);
ReadSaveBuf(&OverridePosition, buf);
ReadSaveBuf(&OverrideHeading, buf);
ReadSaveBuf(&bFadeInAfterNextDeath, buf);
ReadSaveBuf(&bFadeInAfterNextArrest, buf);
ReadSaveBuf(&OverrideHospitalLevel, buf);
ReadSaveBuf(&OverridePoliceStationLevel, buf);
VALIDATESAVEBUF(size);
}

View File

@ -744,7 +744,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
CollectParameters(&m_nIp, 2);
CPlayerPed* pPlayerPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
script_assert(pPlayerPed);
pPlayerPed->m_fArmour = clamp(pPlayerPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, CWorld::Players[GET_INTEGER_PARAM(0)].m_nMaxArmour);
pPlayerPed->m_fArmour = Clamp(pPlayerPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, CWorld::Players[GET_INTEGER_PARAM(0)].m_nMaxArmour);
return 0;
}
case COMMAND_ADD_ARMOUR_TO_CHAR:
@ -752,7 +752,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
pPed->m_fArmour = clamp(pPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, 100.0f);
pPed->m_fArmour = Clamp(pPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, 100.0f);
return 0;
}
case COMMAND_OPEN_GARAGE:

View File

@ -16,6 +16,7 @@
#include "SpecialFX.h"
#include "World.h"
#include "main.h"
#include "SaveBuf.h"
// LCS: file done except TODOs
@ -2205,29 +2206,33 @@ 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 = ReadSaveBuf<uint32>(buf);
uint32 varSpace, type, handle;
uint32 tmp;
ReadSaveBuf(&varSpace, buf);
if (*(int32*)&ScriptSpace[0] != *(int32*)&buf[0] || *(int32*)&ScriptSpace[4] != *(int32*)&buf[4]) {
printf("\n===================================================\nSave Game Mismatch!!!\n");
return false;
}
for (uint32 i = 0; i < varSpace; i++) { // this is not exactly what function does
if (i < 8)
ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
ReadSaveBuf(&ScriptSpace[i], buf);
else if (GetSaveVarIndex(i / 4 * 4) != -1)
ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
ReadSaveBuf(&ScriptSpace[i], buf);
else
ReadSaveBuf<uint8>(buf);
SkipSaveBuf(buf, 1);
}
// everything else is... gone? TODO
script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE);
OnAMissionFlag = ReadSaveBuf<uint32>(buf);
LastMissionPassedTime = ReadSaveBuf<uint32>(buf);
ReadSaveBuf(&tmp, buf);
script_assert(tmp == SCRIPT_DATA_SIZE);
ReadSaveBuf(&OnAMissionFlag, buf);
ReadSaveBuf(&LastMissionPassedTime, buf);
for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
CollectiveArray[i] = ReadSaveBuf<tCollectiveData>(buf);
NextFreeCollectiveIndex = ReadSaveBuf<int32>(buf);
ReadSaveBuf(&CollectiveArray[i], buf);
ReadSaveBuf(&NextFreeCollectiveIndex, buf);
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
uint32 type = ReadSaveBuf<uint32>(buf);
uint32 handle = ReadSaveBuf<uint32>(buf);
ReadSaveBuf(&type, buf);
ReadSaveBuf(&handle, buf);
/*
switch (type) {
case 0:
@ -2243,16 +2248,17 @@ INITSAVEBUF
script_assert(false);
}
*/
/*BuildingSwapArray[i].m_nNewModel = */ReadSaveBuf<uint32>(buf);
/*BuildingSwapArray[i].m_nOldModel = */ReadSaveBuf<uint32>(buf);
/*BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf);*/
/*BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf);*/
SkipSaveBuf(buf, 8);
/*
if (BuildingSwapArray[i].m_pBuilding)
BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel);
*/
}
for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
uint32 type = ReadSaveBuf<uint32>(buf);
uint32 handle = ReadSaveBuf<uint32>(buf);
ReadSaveBuf(&type, buf);
ReadSaveBuf(&handle, buf);
/*
switch (type) {
case 0:
@ -2277,14 +2283,25 @@ INITSAVEBUF
InvisibilitySettingArray[i]->bIsVisible = false;
*/
}
script_assert(ReadSaveBuf<bool>(buf) == bUsingAMultiScriptFile);
/*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
ReadSaveBuf<uint16>(buf);
script_assert(ReadSaveBuf<uint32>(buf) == MainScriptSize);
script_assert(ReadSaveBuf<uint32>(buf) == LargestMissionScriptSize);
script_assert(ReadSaveBuf<uint16>(buf) == NumberOfMissionScripts);
script_assert(ReadSaveBuf<uint16>(buf) == NumberOfExclusiveMissionScripts);
uint32 runningScripts = ReadSaveBuf<uint32>(buf);
bool tmpBool;
ReadSaveBuf(&tmpBool, buf);
script_assert(tmpBool == bUsingAMultiScriptFile);
///*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
//ReadSaveBuf<uint16>(buf);
SkipSaveBuf(buf, 3);
ReadSaveBuf(&tmp, buf);
script_assert(tmp == MainScriptSize);
ReadSaveBuf(&tmp, buf);
script_assert(tmp == LargestMissionScriptSize);
uint16 tmp16;
ReadSaveBuf(&tmp16, buf);
script_assert(tmp16 == NumberOfMissionScripts);
ReadSaveBuf(&tmp16, buf);
script_assert(tmp16 == NumberOfExclusiveMissionScripts);
uint32 runningScripts;
ReadSaveBuf(&runningScripts, buf);
for (uint32 i = 0; i < runningScripts; i++)
CRunningScript().Load(buf);
StartTestScript(); // <- tmp hack
@ -2335,38 +2352,38 @@ void CRunningScript::Load(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
m_nId = ReadSaveBuf<int32>(buf);
ReadSaveBuf(&m_nId, buf);
for (int i = 0; i < 8; i++)
m_abScriptName[i] = ReadSaveBuf<char>(buf);
m_nIp = ReadSaveBuf<uint32>(buf);
ReadSaveBuf(&m_abScriptName[i], buf);
ReadSaveBuf(&m_nIp, buf);
#ifdef CHECK_STRUCT_SIZES
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
#endif
for (int i = 0; i < MAX_STACK_DEPTH; i++)
m_anStack[i] = ReadSaveBuf<uint32>(buf);
m_nStackPointer = ReadSaveBuf<uint16>(buf);
ReadSaveBuf(&m_anStack[i], buf);
ReadSaveBuf(&m_nStackPointer, buf);
SkipSaveBuf(buf, 2);
#ifdef CHECK_STRUCT_SIZES
static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + 8 + NUM_TIMERS != 106");
#endif
for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++)
m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
m_nLocalsPointer = ReadSaveBuf<int32>(buf);
m_bIsActive = ReadSaveBuf<bool>(buf);
m_bCondResult = ReadSaveBuf<bool>(buf);
m_bIsMissionScript = ReadSaveBuf<bool>(buf);
m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
m_nWakeTime = ReadSaveBuf<uint32>(buf);
m_nAndOrState = ReadSaveBuf<uint16>(buf);
m_bNotFlag = ReadSaveBuf<bool>(buf);
m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
m_bMissionFlag = ReadSaveBuf<bool>(buf);
ReadSaveBuf(&m_anLocalVariables[i], buf);
ReadSaveBuf(&m_nLocalsPointer, buf);
ReadSaveBuf(&m_bIsActive, buf);
ReadSaveBuf(&m_bCondResult, buf);
ReadSaveBuf(&m_bIsMissionScript, buf);
ReadSaveBuf(&m_bSkipWakeTime, buf);
ReadSaveBuf(&m_nWakeTime, buf);
ReadSaveBuf(&m_nAndOrState, buf);
ReadSaveBuf(&m_bNotFlag, buf);
ReadSaveBuf(&m_bDeatharrestEnabled, buf);
ReadSaveBuf(&m_bDeatharrestExecuted, buf);
ReadSaveBuf(&m_bMissionFlag, buf);
SkipSaveBuf(buf, 2);
#else
CRunningScript* n = next;
CRunningScript* p = prev;
*this = ReadSaveBuf<CRunningScript>(buf);
ReadSaveBuf(this, buf);
next = n;
prev = p;
#endif

View File

@ -11,6 +11,7 @@
#include "Wanted.h"
#include "World.h"
#include "VarConsole.h"
#include "SaveBuf.h"
#define TIME_BETWEEN_SETPIECE_SPAWNS 20000
@ -67,9 +68,9 @@ VALIDATESAVEBUF(*size)
void CSetPieces::Load(uint8* buf, uint32 size)
{
INITSAVEBUF
NumSetPieces = ReadSaveBuf<uint32>(buf);
ReadSaveBuf(&NumSetPieces, buf);
for (int i = 0; i < NUM_SETPIECES; i++)
aSetPieces[i] = ReadSaveBuf<CSetPiece>(buf);
ReadSaveBuf(&aSetPieces[i], buf);
VALIDATESAVEBUF(size)
}