From bf3135eb417120124f93d0b00362232f7bad0ef7 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 8 Jan 2021 18:31:50 +0200 Subject: [PATCH] Enable trains --- src/audio/AudioManager.h | 2 +- src/audio/AudioSamples.h | 4 +++ src/core/config.h | 2 ++ src/vehicles/Train.cpp | 58 ++++------------------------------------ 4 files changed, 12 insertions(+), 54 deletions(-) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 376a7f60..b5e9b499 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -466,7 +466,7 @@ public: void ProcessScriptObject(int32 id); // done void ProcessSpecial(); // done #ifdef GTA_TRAIN - bool ProcessTrainNoise(cVehicleParams *params); //done(bcs not exists in VC) + bool ProcessTrainNoise(cVehicleParams ¶ms); //done(bcs not exists in VC) #endif void ProcessVehicle(CVehicle *vehicle); // done bool ProcessVehicleDoors(cVehicleParams ¶ms); // done diff --git a/src/audio/AudioSamples.h b/src/audio/AudioSamples.h index a68cf768..159809d0 100644 --- a/src/audio/AudioSamples.h +++ b/src/audio/AudioSamples.h @@ -814,4 +814,8 @@ enum eSfxSample SAMPLEBANK_PED_START = SFX_FOOTSTEP_SAND_4 + 1, SAMPLEBANK_PED_END = 9940, SAMPLEBANK_PED_MAX = SAMPLEBANK_PED_END + 1, + + // LCS: TODO + SFX_TRAIN_FAR = NO_SAMPLE, + SFX_TRAIN_NEAR = NO_SAMPLE, }; diff --git a/src/core/config.h b/src/core/config.h index 7dfb5bba..d4da96e6 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -197,6 +197,8 @@ enum Config { //#define COMPRESSED_COL_VECTORS // use compressed vectors for collision vertices //#define ANIM_COMPRESSION // only keep most recently used anims uncompressed +#define GTA_TRAIN + #if defined GTA_PS2 # define GTA_PS2_STUFF # define RANDOMSPLASH diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp index 1a4af307..fefe1781 100644 --- a/src/vehicles/Train.cpp +++ b/src/vehicles/Train.cpp @@ -459,11 +459,11 @@ CTrain::InitTrains(void) CStreaming::LoadAllRequestedModels(false); // El-Train wagons - float wagonPositions[] = { 0.0f, 20.0f, 40.0f, 0.0f, 20.0f }; - int8 firstWagon[] = { 1, 0, 0, 1, 0 }; - int8 lastWagon[] = { 0, 0, 1, 0, 1 }; - int16 wagonGroup[] = { 0, 0, 0, 1, 1 }; - for(i = 0; i < 5; i++){ + float wagonPositions[] = { 0.0f, 20.0f, 0.0f, 20.0f }; + int8 firstWagon[] = { 1, 0, 1, 0 }; + int8 lastWagon[] = { 0, 1, 0, 1 }; + int16 wagonGroup[] = { 0, 0, 1, 1 }; + for(i = 0; i < 4; i++){ train = new CTrain(MI_TRAIN, PERMANENT_VEHICLE); train->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f); train->SetStatus(STATUS_ABANDONED); @@ -649,52 +649,6 @@ CTrain::ReadAndInterpretTrackFile(Const char *filename, CTrainNode **nodes, int1 #endif } -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) -{ -#ifdef GTA_TRAIN - for (int i = 0; i < ARRAY_SIZE(StationDist); i++) { - for (int j = 0; j < ARRAY_SIZE(EngineTrackPosition); 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; - } - } - } - } -#endif -} - void CTrain::UpdateTrains(void) { @@ -732,8 +686,6 @@ CTrain::UpdateTrains(void) // time offset for each train time += 0x20000/2; } - - ProcessTrainAnnouncements(); } // Update Subway