diff options
author | Sergeanur <s.anureev@yandex.ua> | 2020-06-06 07:42:58 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2020-06-06 07:42:58 +0200 |
commit | afa4fa65102360a157b500e2771c1c350fd6e1e0 (patch) | |
tree | bcf6a3b841c22a7c46b4a6bcb61cc079887905bb /src/vehicles | |
parent | Merge pull request #617 from majesticCoding/miami (diff) | |
parent | ps2 audio banks (diff) | |
download | re3-afa4fa65102360a157b500e2771c1c350fd6e1e0.tar re3-afa4fa65102360a157b500e2771c1c350fd6e1e0.tar.gz re3-afa4fa65102360a157b500e2771c1c350fd6e1e0.tar.bz2 re3-afa4fa65102360a157b500e2771c1c350fd6e1e0.tar.lz re3-afa4fa65102360a157b500e2771c1c350fd6e1e0.tar.xz re3-afa4fa65102360a157b500e2771c1c350fd6e1e0.tar.zst re3-afa4fa65102360a157b500e2771c1c350fd6e1e0.zip |
Diffstat (limited to 'src/vehicles')
-rw-r--r-- | src/vehicles/Train.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp index 550c02a5..e3bc8a9f 100644 --- a/src/vehicles/Train.cpp +++ b/src/vehicles/Train.cpp @@ -13,6 +13,7 @@ #include "DMAudio.h" #include "HandlingMgr.h" #include "Train.h" +#include "AudioScriptObject.h" static CTrainNode* pTrackNodes; static int16 NumTrackNodes; @@ -35,6 +36,8 @@ static float EngineTrackSpeed_S[4]; CVector CTrain::aStationCoors[3]; CVector CTrain::aStationCoors_S[4]; +static bool bTrainArrivalAnnounced[3] = {false, false, false}; + CTrain::CTrain(int32 id, uint8 CreatedBy) : CVehicle(CreatedBy) { @@ -643,9 +646,47 @@ CTrain::ReadAndInterpretTrackFile(Const char *filename, CTrainNode **nodes, int1 } void +PlayAnnouncement(uint8 sound, uint8 station) +{ + // this was gone in a PC version but inlined on PS2 + cAudioScriptObject *obj = new cAudioScriptObject; + obj->AudioId = sound; + obj->Posn = CTrain::aStationCoors[station]; + obj->AudioEntity = AEHANDLE_NONE; + DMAudio.CreateOneShotScriptObject(obj); +} + +void ProcessTrainAnnouncements(void) { - // TODO but unused + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + if (!bTrainArrivalAnnounced[i]) { + float preDist = StationDist[i] - 100.0f; + if (preDist < 0.0f) + preDist += TotalLengthOfTrack; + if (EngineTrackPosition[j] > preDist && EngineTrackPosition[j] < StationDist[i]) { + bTrainArrivalAnnounced[i] = true; + PlayAnnouncement(SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_1, i); + break; + } + } else { + float postDist = StationDist[i] + 10.0f; +#ifdef FIX_BUGS + if (postDist > TotalLengthOfTrack) + postDist -= TotalLengthOfTrack; +#else + if (postDist < 0.0f) // does this even make sense here? + postDist += TotalLengthOfTrack; +#endif + if (EngineTrackPosition[j] > StationDist[i] && EngineTrackPosition[j] < postDist) { + bTrainArrivalAnnounced[i] = false; + PlayAnnouncement(SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_2, i); + break; + } + } + } + } } void |