Skip to content

Commit 4bd6e77

Browse files
committed
Merge branch 'master' of github.com:gta-reversed/gta-reversed-modern into reverse/CAECollisionAudioEntity
2 parents 3f22f3a + 57e4df0 commit 4bd6e77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2602
-1419
lines changed

source/InjectHooksMain.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,9 @@ void InjectHooksMain() {
14431443
Vehicle();
14441444
Interior();
14451445
Scripts();
1446+
#if _DEBUG
1447+
CCurves::TestCurves();
1448+
#endif
14461449
}
14471450

14481451
void InjectHooksMain(HMODULE hThisDLL) {

source/game_sa/3dMarkers.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include "3dMarkers.h"
44
#include "PostEffects.h"
55

6+
// RwIm3DVertex StreakVertices[4];
7+
RxObjSpace3DVertex* aRenderVertices = (RxObjSpace3DVertex*)0xC278F8;
8+
69
void C3dMarkers::InjectHooks() {
710
RH_ScopedClass(C3dMarkers);
811
RH_ScopedCategoryGlobal();

source/game_sa/Audio/entities/AEDoorAudioEntity.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,31 @@ void CAEDoorAudioEntity::AddAudioEvent(eAudioEvents event, CVector& posn, float
8383

8484
// 0x4DC6D0
8585
void CAEDoorAudioEntity::PlayDoorSound(int16 sfxId, eAudioEvents event, CVector& posn, float volumeDelta, float speed) {
86-
if (AEAudioHardware.IsSoundBankLoaded(SND_BANK_GENRL_DOORS, SND_BANK_SLOT_DOORS)) {
87-
CVector position;
88-
bool enabled = false;
89-
if (posn.x == -1000.0f && posn.y == -1000.0f && posn.z == -1000.0f || posn.x == 0.0f && posn.y == 0.0f && posn.z == 0.0f) {
90-
position.Set(0.0f, 1.0f, 0.0f);
91-
enabled = true;
92-
} else {
93-
position = posn;
94-
}
95-
96-
const float eventVolume = GetDefaultVolume(event);
97-
const float volume = eventVolume + volumeDelta;
98-
CAESound sound;
99-
sound.Initialise(SND_BANK_SLOT_DOORS, sfxId, this, position, volume, 2.0f, speed, 1.0f, 0, SOUND_REQUEST_UPDATES, 0.0f, 0);
100-
sound.SetFlags(SOUND_FRONT_END, enabled);
101-
sound.m_Event = event;
102-
AESoundManager.RequestNewSound(&sound);
103-
} else {
86+
if (!AEAudioHardware.IsSoundBankLoaded(SND_BANK_GENRL_DOORS, SND_BANK_SLOT_DOORS)) {
10487
StaticInitialise();
88+
return;
89+
}
90+
const auto PlaySound = [&](CVector pos, bool isFrontEnd) {
91+
AESoundManager.PlaySound({
92+
.BankSlotID = SND_BANK_SLOT_DOORS,
93+
.SoundID = sfxId,
94+
.AudioEntity = this,
95+
.Pos = pos,
96+
.Volume = GetDefaultVolume(event) + volumeDelta,
97+
.RollOffFactor = 2.0f,
98+
.Speed = speed,
99+
.Doppler = 1.0f,
100+
.FrameDelay = 0,
101+
.Flags = SOUND_REQUEST_UPDATES | (isFrontEnd ? SOUND_FRONT_END : 0u),
102+
.FrequencyVariance = 0.0f,
103+
.PlayTime = 0,
104+
.EventID = event
105+
});
106+
};
107+
if (posn.x == -1000.0f && posn.y == -1000.0f && posn.z == -1000.0f || posn.IsZero()) {
108+
PlaySound({ 0.0f, 1.0f, 0.0f }, true);
109+
} else {
110+
PlaySound(posn, false);
105111
}
106112
}
107113

source/game_sa/Audio/entities/AEExplosionAudioEntity.cpp

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ void CAEExplosionAudioEntity::StaticInitialise() {
1919

2020
// 0x4DCBE0
2121
void CAEExplosionAudioEntity::AddAudioEvent(eAudioEvents audioEvent, CVector& posn, float volume) {
22+
volume += GetDefaultVolume(AE_EXPLOSION);
23+
2224
if (audioEvent != AE_EXPLOSION) {
2325
return;
2426
}
@@ -27,37 +29,47 @@ void CAEExplosionAudioEntity::AddAudioEvent(eAudioEvents audioEvent, CVector& po
2729
return;
2830
}
2931

30-
float vol0 = GetDefaultVolume(AE_EXPLOSION) + volume;
31-
m_Speed = (m_Speed + 1) % NUM_VARIATIONS;
32-
33-
CAESound sound;
34-
35-
sound.Initialise(SND_BANK_SLOT_EXPLOSIONS, 4, this, posn, vol0, 2.0f, gfExplosionFrequencyVariations[m_Speed], 1.0f, 0, SOUND_REQUEST_UPDATES, 0.06f, 0);
36-
AESoundManager.RequestNewSound(&sound);
37-
38-
sound.Initialise(SND_BANK_SLOT_EXPLOSIONS, 3, this, posn, vol0, 4.0f, gfExplosionFrequencyVariations[m_Speed], 1.0f, 0, SOUND_REQUEST_UPDATES, 0.06f, 0);
39-
AESoundManager.RequestNewSound(&sound);
40-
41-
sound.Initialise(SND_BANK_SLOT_EXPLOSIONS, 2, this, posn, vol0, 7.5f, gfExplosionFrequencyVariations[m_Speed], 1.0f, 0, SOUND_REQUEST_UPDATES, 0.06f, 0);
42-
AESoundManager.RequestNewSound(&sound);
43-
44-
float speed_a, speed_b;
45-
if (CAEAudioUtility::ResolveProbability(0.5f)) {
46-
speed_a = gfExplosionFrequencyVariations[m_Speed] * sqrt(sqrt(2.0f));
47-
speed_b = gfExplosionFrequencyVariations[m_Speed];
48-
} else {
49-
speed_a = gfExplosionFrequencyVariations[m_Speed];
50-
speed_b = gfExplosionFrequencyVariations[m_Speed] * sqrt(sqrt(2.0f));
32+
{ // 0x4DCC93
33+
m_Speed = (m_Speed + 1) % NUM_VARIATIONS;
34+
const auto PlayExplosionSound = [&](eSoundID soundID, float rollOff) {
35+
AESoundManager.PlaySound({
36+
.BankSlotID = SND_BANK_SLOT_EXPLOSIONS,
37+
.SoundID = soundID,
38+
.AudioEntity = this,
39+
.Pos = posn,
40+
.Volume = volume,
41+
.RollOffFactor = rollOff,
42+
.Speed = gfExplosionFrequencyVariations[m_Speed],
43+
.Flags = SOUND_REQUEST_UPDATES,
44+
.FrequencyVariance = 0.06f,
45+
});
46+
};
47+
PlayExplosionSound(4, 2.f);
48+
PlayExplosionSound(3, 4.f);
49+
PlayExplosionSound(2, 7.5f);
50+
}
51+
{ // 0x4DCE79
52+
const auto PlayExplosionSound = [&](CVector frontEndPos, bool variance) {
53+
auto speed = gfExplosionFrequencyVariations[m_Speed];
54+
if (variance) {
55+
speed *= sqrt(sqrt(2.0f));
56+
}
57+
AESoundManager.PlaySound({
58+
.BankSlotID = SND_BANK_SLOT_EXPLOSIONS,
59+
.SoundID = 1,
60+
.AudioEntity = this,
61+
.Pos = frontEndPos,
62+
.Volume = volume + CAEAudioEnvironment::GetDistanceAttenuation(CAEAudioEnvironment::GetPositionRelativeToCamera(posn).Magnitude() / 12.0f) - 3.0f,
63+
.RollOffFactor = 12.f,
64+
.Speed = speed,
65+
.Flags = SOUND_FORCED_FRONT | SOUND_ROLLED_OFF | SOUND_REQUEST_UPDATES | SOUND_FRONT_END,
66+
.FrequencyVariance = 0.06f,
67+
});
68+
};
69+
const auto variance = CAEAudioUtility::ResolveProbability(0.5f);
70+
PlayExplosionSound({ -1.0f, 0.0f, 0.0f }, variance);
71+
PlayExplosionSound({ 1.0f, 0.0f, 0.0f }, !variance);
5172
}
52-
53-
auto vol1 = CAEAudioEnvironment::GetDistanceAttenuation(CAEAudioEnvironment::GetPositionRelativeToCamera(posn).Magnitude() / 12.0f) + vol0 - 3.0f;
54-
auto flags = static_cast<eSoundEnvironment>(SOUND_FORCED_FRONT | SOUND_ROLLED_OFF | SOUND_REQUEST_UPDATES | SOUND_FRONT_END);
55-
56-
sound.Initialise(SND_BANK_SLOT_EXPLOSIONS, 1, this, { -1.0f, 0.0f, 0.0f }, vol1, 12.0f, speed_a, 1.0f, 0, flags, 0.0f, 0);
57-
AESoundManager.RequestNewSound(&sound);
58-
59-
sound.Initialise(SND_BANK_SLOT_EXPLOSIONS, 1, this, { 1.0f, 0.0f, 0.0f }, vol1, 12.0f, speed_b, 1.0f, 0, flags, 0.0f, 0);
60-
AESoundManager.RequestNewSound(&sound);
6173
}
6274

6375
// 0x4DCB90

source/game_sa/Audio/entities/AEExplosionAudioEntity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class NOTSA_EXPORT_VTABLE CAEExplosionAudioEntity : public CAEAudioEntity {
1212
public:
13-
uint32 m_Speed;
13+
uint32 m_Speed{};
1414

1515
public:
1616
static void InjectHooks();

source/game_sa/Audio/entities/AEFireAudioEntity.cpp

Lines changed: 56 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -41,58 +41,71 @@ void CAEFireAudioEntity::PlayFireSounds(eAudioEvents audioId, CVector& posn) {
4141
m_snLastFireFrequencyIndex = (m_snLastFireFrequencyIndex + 1) % 5;
4242
const float volume = GetDefaultVolume(audioId);
4343

44-
CAESound sound;
45-
sound.Initialise(
46-
SND_BANK_SLOT_EXPLOSIONS,
47-
0,
48-
this,
49-
posn,
50-
volume,
51-
2.0f,
52-
gfFireFrequencyVariations[m_snLastFireFrequencyIndex],
53-
1.0f,
54-
0,
55-
SOUND_REQUEST_UPDATES,
56-
0.0f,
57-
0
58-
);
59-
m_SoundLeft = AESoundManager.RequestNewSound(&sound);
44+
m_SoundLeft = AESoundManager.PlaySound({
45+
.BankSlotID = SND_BANK_SLOT_EXPLOSIONS,
46+
.SoundID = 0,
47+
.AudioEntity = this,
48+
.Pos = posn,
49+
.Volume = volume,
50+
.RollOffFactor = 2.0f,
51+
.Speed = gfFireFrequencyVariations[m_snLastFireFrequencyIndex],
52+
.Flags = SOUND_REQUEST_UPDATES,
53+
});
6054

6155
if (!AEAudioHardware.EnsureSoundBankIsLoaded(SND_BANK_GENRL_VEHICLE_GEN, SND_BANK_SLOT_VEHICLE_GEN)) {
6256
return;
6357
}
6458

65-
sound.Initialise(
66-
SND_BANK_SLOT_VEHICLE_GEN,
67-
26,
68-
this,
69-
posn,
70-
volume - 17.0f,
71-
2.0f,
72-
gfFireFrequencyVariations[m_snLastFireFrequencyIndex] * 0.6f,
73-
1.0f,
74-
0,
75-
SOUND_REQUEST_UPDATES,
76-
0.0f,
77-
0
78-
);
79-
sound.m_ClientVariable = volume + 3.0f;
80-
sound.m_Event = AE_FRONTEND_SELECT;
81-
AESoundManager.RequestNewSound(&sound);
59+
AESoundManager.PlaySound({
60+
.BankSlotID = SND_BANK_SLOT_VEHICLE_GEN,
61+
.SoundID = 26,
62+
.AudioEntity = this,
63+
.Pos = posn,
64+
.Volume = volume - 17.0f,
65+
.RollOffFactor = 2.0f,
66+
.Speed = gfFireFrequencyVariations[m_snLastFireFrequencyIndex] * 0.6f,
67+
.Doppler = 1.0f,
68+
.FrameDelay = 0,
69+
.Flags = SOUND_REQUEST_UPDATES,
70+
.FrequencyVariance = 0.0f,
71+
.PlayTime = 0,
72+
.EventID = AE_FRONTEND_SELECT,
73+
.ClientVariable = volume + 3.0f,
74+
});
8275
}
8376

8477
// 0x4DD270
8578
void CAEFireAudioEntity::PlayWaterSounds(eAudioEvents audioId, CVector& posn) {
86-
CAESound sound;
87-
sound.Initialise(SND_BANK_SLOT_COLLISIONS, 3, this, posn, GetDefaultVolume(audioId), 2.0f, 0.75f, 0.6f, 0, SOUND_REQUEST_UPDATES, 0.0f, 0);
88-
sound.m_Event = AE_FRONTEND_HIGHLIGHT;
89-
sound.m_SpeedVariance = 0.06f;
90-
m_SoundLeft = AESoundManager.RequestNewSound(&sound);
91-
92-
sound.Initialise(SND_BANK_SLOT_FRONTEND_GAME, 0, this, posn, GetDefaultVolume(audioId) + 20.0f, 2.0f, 1.78f, 0.6f, 0, SOUND_REQUEST_UPDATES, 0.0f, 0);
93-
sound.m_SpeedVariance = 0.06f;
94-
sound.m_Event = AE_FRONTEND_ERROR;
95-
m_SoundRight = AESoundManager.RequestNewSound(&sound);
79+
m_SoundLeft = AESoundManager.PlaySound({
80+
.BankSlotID = SND_BANK_SLOT_COLLISIONS,
81+
.SoundID = 3,
82+
.AudioEntity = this,
83+
.Pos = posn,
84+
.Volume = GetDefaultVolume(audioId),
85+
.RollOffFactor = 2.0f,
86+
.Speed = 0.75f,
87+
.Doppler = 0.6f,
88+
.FrameDelay = 0,
89+
.Flags = SOUND_REQUEST_UPDATES,
90+
.FrequencyVariance = 0.06f,
91+
.PlayTime = 0,
92+
.EventID = AE_FRONTEND_HIGHLIGHT,
93+
});
94+
m_SoundRight = AESoundManager.PlaySound({
95+
.BankSlotID = SND_BANK_SLOT_FRONTEND_GAME,
96+
.SoundID = 0,
97+
.AudioEntity = this,
98+
.Pos = posn,
99+
.Volume = GetDefaultVolume(audioId) + 20.0f,
100+
.RollOffFactor = 2.0f,
101+
.Speed = 1.78f,
102+
.Doppler = 0.6f,
103+
.FrameDelay = 0,
104+
.Flags = SOUND_REQUEST_UPDATES,
105+
.FrequencyVariance = 0.06f,
106+
.PlayTime = 0,
107+
.EventID = AE_FRONTEND_ERROR,
108+
});
96109
}
97110

98111
// 0x4DCF60

0 commit comments

Comments
 (0)