diff options
author | aap <aap@papnet.eu> | 2019-07-29 19:18:03 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2019-07-31 14:33:27 +0200 |
commit | 5f6b235301f734b73f8307cf3e29997e7f76eac8 (patch) | |
tree | 73037842a302ae6e888e365b32e8ce74287e3f8d /src/vehicles/Door.cpp | |
parent | Merge pull request #175 from erorcun/erorcun (diff) | |
parent | restore original shadows fading (diff) | |
download | re3-5f6b235301f734b73f8307cf3e29997e7f76eac8.tar re3-5f6b235301f734b73f8307cf3e29997e7f76eac8.tar.gz re3-5f6b235301f734b73f8307cf3e29997e7f76eac8.tar.bz2 re3-5f6b235301f734b73f8307cf3e29997e7f76eac8.tar.lz re3-5f6b235301f734b73f8307cf3e29997e7f76eac8.tar.xz re3-5f6b235301f734b73f8307cf3e29997e7f76eac8.tar.zst re3-5f6b235301f734b73f8307cf3e29997e7f76eac8.zip |
Diffstat (limited to 'src/vehicles/Door.cpp')
-rw-r--r-- | src/vehicles/Door.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/vehicles/Door.cpp b/src/vehicles/Door.cpp index 25e87504..2d47b3e9 100644 --- a/src/vehicles/Door.cpp +++ b/src/vehicles/Door.cpp @@ -115,6 +115,60 @@ CDoor::IsClosed(void) return m_fAngle == RetAngleWhenClosed(); } + +CTrainDoor::CTrainDoor(void) +{ + memset(this, 0, sizeof(*this)); +} + +void +CTrainDoor::Open(float ratio) +{ + float open; + + m_fPrevPosn = m_fPosn; + open = RetTranslationWhenOpen(); + if(ratio < 1.0f){ + m_fPosn = open*ratio; + }else{ + m_nDoorState = DOORST_OPEN; + m_fPosn = open; + } +} + +float +CTrainDoor::RetTranslationWhenClosed(void) +{ + if(Abs(m_fClosedPosn) < Abs(m_fOpenPosn)) + return m_fClosedPosn; + else + return m_fOpenPosn; +} + +float +CTrainDoor::RetTranslationWhenOpen(void) +{ + if(Abs(m_fClosedPosn) < Abs(m_fOpenPosn)) + return m_fOpenPosn; + else + return m_fClosedPosn; +} + +bool +CTrainDoor::IsFullyOpen(void) +{ + // 0.5f again... + if(Abs(m_fPosn) < Abs(RetTranslationWhenOpen()) - 0.5f) + return false; + return true; +} + +bool +CTrainDoor::IsClosed(void) +{ + return m_fPosn == RetTranslationWhenClosed(); +} + STARTPATCHES InjectHook(0x545EF0, &CDoor::Open, PATCH_JUMP); InjectHook(0x545BD0, &CDoor::Process, PATCH_JUMP); @@ -123,4 +177,10 @@ STARTPATCHES InjectHook(0x545F80, &CDoor::GetAngleOpenRatio, PATCH_JUMP); InjectHook(0x546090, &CDoor::IsFullyOpen, PATCH_JUMP); InjectHook(0x546060, &CDoor::IsClosed, PATCH_JUMP); + + InjectHook(0x546200, &CTrainDoor::Open, PATCH_JUMP); + InjectHook(0x546180, &CTrainDoor::RetTranslationWhenClosed, PATCH_JUMP); + InjectHook(0x5461C0, &CTrainDoor::RetTranslationWhenOpen, PATCH_JUMP); + InjectHook(0x546120, &CTrainDoor::IsFullyOpen, PATCH_JUMP); + InjectHook(0x5460F0, &CTrainDoor::IsClosed, PATCH_JUMP); ENDPATCHES |