some nasty FIX_BUGS for SLIDE_OBJECT

This commit is contained in:
Nikolay Korolev 2020-11-28 21:26:38 +03:00
parent b47c505438
commit 8cb3c07151
2 changed files with 26 additions and 5 deletions

View File

@ -40,6 +40,23 @@
#include "Zones.h" #include "Zones.h"
#include "Bike.h" #include "Bike.h"
#ifdef FIX_BUGS
static bool IsSlideObjectUsedWrongByScript(const CVector& posTarget, const CVector& slideBy)
{
if (posTarget == CVector(-559.476f, 784.807f, 23.279f) && slideBy == CVector(0.0f, 10.0f, 0.0f))
return true; // G-Spotlight bottom elevator, east side
if (posTarget == CVector(-559.476f, 779.64f, 23.279f) && slideBy == CVector(0.0f, 10.0f, 0.0f))
return true; // G-Spotlight bottom elevator, west side
if (posTarget == CVector(-553.563f, 790.595f, 97.917f) && slideBy == CVector(0.0f, 10.0f, 0.0f))
return true; // G-Spotlight top elevator, east side
if (posTarget == CVector(-553.563f, 785.427f, 97.917f) && slideBy == CVector(0.0f, 10.0f, 0.0f))
return true; // G-Spotlight top elevator, west side
if (posTarget == CVector(-866.689f, -572.095f, 15.573f) && slideBy == CVector(0.0f, 0.0f, 4.5f))
return true; // Cherry Popper garage door
return false;
}
#endif
int8 CRunningScript::ProcessCommands800To899(int32 command) int8 CRunningScript::ProcessCommands800To899(int32 command)
{ {
CMatrix tmp_matrix; CMatrix tmp_matrix;
@ -514,10 +531,14 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
script_assert(pObject); script_assert(pObject);
CVector pos = pObject->GetPosition(); CVector pos = pObject->GetPosition();
CVector posTarget = *(CVector*)&ScriptParams[1]; CVector posTarget = *(CVector*)&ScriptParams[1];
#ifdef FIX_BUGS
CVector slideBy = *(CVector*)&ScriptParams[4] * CTimer::GetTimeStepFix();
#else
CVector slideBy = *(CVector*)&ScriptParams[4]; CVector slideBy = *(CVector*)&ScriptParams[4];
#ifdef FIX_BUGS
// the check is a hack for original script, where some objects are moved
// via SLIDE_OBJECT instead of SET_OBJECT_POSITION
// assuming the slide will take exactly one frame, which is true
// only without accounting time step (which is a bug)
if (!IsSlideObjectUsedWrongByScript(posTarget, slideBy))
slideBy *= CTimer::GetTimeStepFix();
#endif #endif
if (posTarget == pos) { // using direct comparasion here is fine if (posTarget == pos) { // using direct comparasion here is fine
UpdateCompareFlag(true); UpdateCompareFlag(true);

View File

@ -65,11 +65,11 @@ public:
return CVector(-x, -y, -z); return CVector(-x, -y, -z);
} }
const bool operator==(CVector const &right) { const bool operator==(CVector const &right) const {
return x == right.x && y == right.y && z == right.z; return x == right.x && y == right.y && z == right.z;
} }
const bool operator!=(CVector const &right) { const bool operator!=(CVector const &right) const {
return x != right.x || y != right.y || z != right.z; return x != right.x || y != right.y || z != right.z;
} }