mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 11:29:59 +00:00
Merge pull request #508 from Nick007J/master
Scripts compatible saving + CCarCtrl bug + crusher coach bug
This commit is contained in:
commit
131e8af174
|
@ -422,8 +422,11 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
/* Casting timer to float is very unwanted. In this case it's not awful */
|
/* Casting timer to float is very unwanted. In this case it's not awful */
|
||||||
/* but in CAutoPilot::ModifySpeed it can even cause crashes (see SilentPatch). */
|
/* but in CAutoPilot::ModifySpeed it can even cause crashes (see SilentPatch). */
|
||||||
|
|
||||||
|
/* Second fix: adding 0.5f is a mistake. It should be between 0 and 1. It was fixed in SA.*/
|
||||||
|
/* It is also correct in CAutoPilot::ModifySpeed. */
|
||||||
pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
|
pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
|
||||||
(uint32)((0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve);
|
(uint32)(positionBetweenNodes * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve);
|
||||||
#else
|
#else
|
||||||
pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
|
pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
|
||||||
(0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve;
|
(0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve;
|
||||||
|
|
|
@ -128,6 +128,14 @@ uint16 CTheScripts::CommandsExecuted;
|
||||||
uint16 CTheScripts::ScriptsUpdated;
|
uint16 CTheScripts::ScriptsUpdated;
|
||||||
int32 ScriptParams[32];
|
int32 ScriptParams[32];
|
||||||
|
|
||||||
|
|
||||||
|
const uint32 CRunningScript::nSaveStructSize =
|
||||||
|
#ifdef COMPATIBLE_SAVES
|
||||||
|
136;
|
||||||
|
#else
|
||||||
|
sizeof(CRunningScript);
|
||||||
|
#endif
|
||||||
|
|
||||||
CMissionCleanup::CMissionCleanup()
|
CMissionCleanup::CMissionCleanup()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
@ -11192,7 +11200,7 @@ INITSAVEBUF
|
||||||
uint32 runningScripts = 0;
|
uint32 runningScripts = 0;
|
||||||
for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext())
|
for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext())
|
||||||
runningScripts++;
|
runningScripts++;
|
||||||
*size = sizeof(CRunningScript) * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 3 * sizeof(uint32);
|
*size = CRunningScript::nSaveStructSize * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 3 * sizeof(uint32);
|
||||||
WriteSaveHeader(buf, 'S', 'C', 'R', '\0', *size - SAVE_HEADER_SIZE);
|
WriteSaveHeader(buf, 'S', 'C', 'R', '\0', *size - SAVE_HEADER_SIZE);
|
||||||
WriteSaveBuf(buf, varSpace);
|
WriteSaveBuf(buf, varSpace);
|
||||||
for (uint32 i = 0; i < varSpace; i++)
|
for (uint32 i = 0; i < varSpace; i++)
|
||||||
|
@ -11264,7 +11272,7 @@ INITSAVEBUF
|
||||||
WriteSaveBuf(buf, (uint16)0);
|
WriteSaveBuf(buf, (uint16)0);
|
||||||
WriteSaveBuf(buf, runningScripts);
|
WriteSaveBuf(buf, runningScripts);
|
||||||
for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext())
|
for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext())
|
||||||
WriteSaveBuf(buf, *pScript);
|
pScript->Save(buf);
|
||||||
VALIDATESAVEBUF(*size)
|
VALIDATESAVEBUF(*size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11340,7 +11348,7 @@ INITSAVEBUF
|
||||||
ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf<uint16>(buf);
|
||||||
uint32 runningScripts = ReadSaveBuf<uint32>(buf);
|
uint32 runningScripts = ReadSaveBuf<uint32>(buf);
|
||||||
for (uint32 i = 0; i < runningScripts; i++)
|
for (uint32 i = 0; i < runningScripts; i++)
|
||||||
StartNewScript(0)->BuildFromSaved(ReadSaveBuf<CRunningScript>(buf));
|
StartNewScript(0)->Load(buf);
|
||||||
VALIDATESAVEBUF(size)
|
VALIDATESAVEBUF(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11615,3 +11623,69 @@ void CTheScripts::ReadMultiScriptFileOffsetsFromScript()
|
||||||
MultiScriptArray[i] = Read4BytesFromScript(&ip);
|
MultiScriptArray[i] = Read4BytesFromScript(&ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CRunningScript::Save(uint8*& buf)
|
||||||
|
{
|
||||||
|
#ifdef COMPATIBLE_SAVES
|
||||||
|
SkipSaveBuf(buf, 8);
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
WriteSaveBuf<char>(buf, m_abScriptName[i]);
|
||||||
|
WriteSaveBuf<uint32>(buf, m_nIp);
|
||||||
|
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
|
||||||
|
for (int i = 0; i < MAX_STACK_DEPTH; i++)
|
||||||
|
WriteSaveBuf<uint32>(buf, m_anStack[i]);
|
||||||
|
WriteSaveBuf<uint16>(buf, m_nStackPointer);
|
||||||
|
SkipSaveBuf(buf, 2);
|
||||||
|
static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
|
||||||
|
for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
|
||||||
|
WriteSaveBuf<int32>(buf, m_anLocalVariables[i]);
|
||||||
|
WriteSaveBuf<bool>(buf, m_bCondResult);
|
||||||
|
WriteSaveBuf<bool>(buf, m_bIsMissionScript);
|
||||||
|
WriteSaveBuf<bool>(buf, m_bSkipWakeTime);
|
||||||
|
SkipSaveBuf(buf, 1);
|
||||||
|
WriteSaveBuf<uint32>(buf, m_nWakeTime);
|
||||||
|
WriteSaveBuf<uint16>(buf, m_nAndOrState);
|
||||||
|
WriteSaveBuf<bool>(buf, m_bNotFlag);
|
||||||
|
WriteSaveBuf<bool>(buf, m_bDeatharrestEnabled);
|
||||||
|
WriteSaveBuf<bool>(buf, m_bDeatharrestExecuted);
|
||||||
|
WriteSaveBuf<bool>(buf, m_bMissionFlag);
|
||||||
|
SkipSaveBuf(buf, 2);
|
||||||
|
#else
|
||||||
|
WriteSaveBuf(buf, *this);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRunningScript::Load(uint8*& buf)
|
||||||
|
{
|
||||||
|
#ifdef COMPATIBLE_SAVES
|
||||||
|
SkipSaveBuf(buf, 8);
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
m_abScriptName[i] = ReadSaveBuf<char>(buf);
|
||||||
|
m_nIp = ReadSaveBuf<uint32>(buf);
|
||||||
|
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
|
||||||
|
for (int i = 0; i < MAX_STACK_DEPTH; i++)
|
||||||
|
m_anStack[i] = ReadSaveBuf<uint32>(buf);
|
||||||
|
m_nStackPointer = ReadSaveBuf<uint16>(buf);
|
||||||
|
SkipSaveBuf(buf, 2);
|
||||||
|
static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
|
||||||
|
for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
|
||||||
|
m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
|
||||||
|
m_bCondResult = ReadSaveBuf<bool>(buf);
|
||||||
|
m_bIsMissionScript = ReadSaveBuf<bool>(buf);
|
||||||
|
m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
|
||||||
|
SkipSaveBuf(buf, 1);
|
||||||
|
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);
|
||||||
|
SkipSaveBuf(buf, 2);
|
||||||
|
#else
|
||||||
|
CRunningScript* n = next;
|
||||||
|
CRunningScript* p = prev;
|
||||||
|
*this = ReadSaveBuf<CRunningScript>(buf);
|
||||||
|
next = n;
|
||||||
|
prev = p;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -423,14 +423,10 @@ class CRunningScript
|
||||||
public:
|
public:
|
||||||
void SetIP(uint32 ip) { m_nIp = ip; }
|
void SetIP(uint32 ip) { m_nIp = ip; }
|
||||||
CRunningScript* GetNext() const { return next; }
|
CRunningScript* GetNext() const { return next; }
|
||||||
void BuildFromSaved(const CRunningScript& pSaved)
|
|
||||||
{
|
void Save(uint8*& buf);
|
||||||
CRunningScript* n = next;
|
void Load(uint8*& buf);
|
||||||
CRunningScript* p = prev;
|
|
||||||
*this = pSaved;
|
|
||||||
next = n;
|
|
||||||
prev = p;
|
|
||||||
}
|
|
||||||
void UpdateTimers(float timeStep) {
|
void UpdateTimers(float timeStep) {
|
||||||
m_anLocalVariables[NUM_LOCAL_VARS] += timeStep;
|
m_anLocalVariables[NUM_LOCAL_VARS] += timeStep;
|
||||||
m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep;
|
m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep;
|
||||||
|
@ -442,6 +438,8 @@ public:
|
||||||
void RemoveScriptFromList(CRunningScript**);
|
void RemoveScriptFromList(CRunningScript**);
|
||||||
void AddScriptToList(CRunningScript**);
|
void AddScriptToList(CRunningScript**);
|
||||||
|
|
||||||
|
static const uint32 nSaveStructSize;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CollectParameters(uint32*, int16);
|
void CollectParameters(uint32*, int16);
|
||||||
int32 CollectNextParameterWithoutIncreasingPC(uint32);
|
int32 CollectNextParameterWithoutIncreasingPC(uint32);
|
||||||
|
|
|
@ -443,7 +443,9 @@ bool CCrane::DoesCranePickUpThisCarType(uint32 mi)
|
||||||
if (m_bIsCrusher) {
|
if (m_bIsCrusher) {
|
||||||
return mi != MI_FIRETRUCK &&
|
return mi != MI_FIRETRUCK &&
|
||||||
mi != MI_TRASH &&
|
mi != MI_TRASH &&
|
||||||
#ifndef FIX_BUGS // why
|
#ifdef FIX_BUGS
|
||||||
|
mi != MI_COACH &&
|
||||||
|
#else
|
||||||
mi != MI_BLISTA &&
|
mi != MI_BLISTA &&
|
||||||
#endif
|
#endif
|
||||||
mi != MI_SECURICA &&
|
mi != MI_SECURICA &&
|
||||||
|
|
Loading…
Reference in a new issue