diff options
author | eray orçunus <erayorcunus@gmail.com> | 2019-07-10 08:06:43 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2019-07-10 14:56:29 +0200 |
commit | 86681c6f18b5741ba25bbbb7319bb832ffa4807a (patch) | |
tree | 0af4b378873305260733777e528fc4b13e530400 /src/control/Phones.cpp | |
parent | One driver owns all the cars fix (diff) | |
download | re3-86681c6f18b5741ba25bbbb7319bb832ffa4807a.tar re3-86681c6f18b5741ba25bbbb7319bb832ffa4807a.tar.gz re3-86681c6f18b5741ba25bbbb7319bb832ffa4807a.tar.bz2 re3-86681c6f18b5741ba25bbbb7319bb832ffa4807a.tar.lz re3-86681c6f18b5741ba25bbbb7319bb832ffa4807a.tar.xz re3-86681c6f18b5741ba25bbbb7319bb832ffa4807a.tar.zst re3-86681c6f18b5741ba25bbbb7319bb832ffa4807a.zip |
Diffstat (limited to 'src/control/Phones.cpp')
-rw-r--r-- | src/control/Phones.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp index fa4f83e5..1d3a9777 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -2,5 +2,42 @@ #include "patcher.h" #include "Phones.h" +CPhoneInfo &gPhoneInfo = * (CPhoneInfo*) * (uintptr*)0x732A20; + +int +CPhoneInfo::FindNearestFreePhone(CVector *pos) +{ + int nearestPhoneId = -1; + float nearestPhoneDist = 60.0f; + + for (int phoneId = 0; phoneId < m_nMax; phoneId++) { + + if (gPhoneInfo.m_aPhones[phoneId].m_nState == 0) { + float phoneDist = (m_aPhones[phoneId].m_vecPos - *pos).Magnitude2D(); + + if (phoneDist < nearestPhoneDist) { + nearestPhoneDist = phoneDist; + nearestPhoneId = phoneId; + } + } + } + return nearestPhoneId; +} + +bool +CPhoneInfo::PhoneAtThisPosition(CVector pos) +{ + for (int phoneId = 0; phoneId < m_nMax; phoneId++) { + if (pos.x == m_aPhones[phoneId].m_vecPos.x && pos.y == m_aPhones[phoneId].m_vecPos.y) + return true; + } + return false; +} + +STARTPATCHES + InjectHook(0x42F720, &CPhoneInfo::FindNearestFreePhone, PATCH_JUMP); + InjectHook(0x42FD50, &CPhoneInfo::PhoneAtThisPosition, PATCH_JUMP); +ENDPATCHES + WRAPPER void PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x42F570); } WRAPPER void PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x42F470); } |