1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 16:00:02 +00:00

More audio (to hook and test)

This commit is contained in:
Filip Gawin 2019-09-24 13:33:16 +02:00
parent 003ac856c6
commit d2941b0368
16 changed files with 574 additions and 75 deletions

View file

@ -6,16 +6,20 @@
#include "Automobile.h" #include "Automobile.h"
#include "Boat.h" #include "Boat.h"
#include "Bridge.h" #include "Bridge.h"
#include "CProjectileInfo.h"
#include "Camera.h" #include "Camera.h"
#include "DMAudio.h" #include "DMAudio.h"
#include "Entity.h"
#include "Explosion.h" #include "Explosion.h"
#include "Garages.h" #include "Garages.h"
#include "HandlingMgr.h"
#include "Heli.h" #include "Heli.h"
#include "ModelIndices.h" #include "ModelIndices.h"
#include "MusicManager.h" #include "MusicManager.h"
#include "Pad.h" #include "Pad.h"
#include "Ped.h" #include "Ped.h"
#include "Physical.h" #include "Physical.h"
#include "Placeable.h"
#include "Plane.h" #include "Plane.h"
#include "PlayerPed.h" #include "PlayerPed.h"
#include "Pools.h" #include "Pools.h"
@ -25,6 +29,7 @@
#include "Train.h" #include "Train.h"
#include "Transmission.h" #include "Transmission.h"
#include "Vehicle.h" #include "Vehicle.h"
#include "WaterCannon.h"
#include "Weather.h" #include "Weather.h"
#include "World.h" #include "World.h"
#include "ZoneCull.h" #include "ZoneCull.h"
@ -41,11 +46,16 @@ bool &bPlayerJustEnteredCar = *(bool *)0x6508C4;
bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E; bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E;
uint32 *gMinTimeToNextReport = (uint32 *)0x8E2828; uint32 *gMinTimeToNextReport = (uint32 *)0x8E2828;
uint8 &gSpecialSuspectLastSeenReport = *(uint8 *)0x95CD4D; uint8 &gSpecialSuspectLastSeenReport = *(uint8 *)0x95CD4D;
uint32 *gOneShotCol = (uint32 *)0x604BD0; //uint32 *gOneShotCol = (uint32 *)0x604BD0;
bool *somethingWithHorns = (bool *)0x606AB8;
constexpr int totalAudioEntitiesSlots = 200; constexpr int totalAudioEntitiesSlots = 200;
constexpr int maxVolume = 127; constexpr int maxVolume = 127;
constexpr int policeChannel = 28; constexpr int policeChannel = 28;
constexpr uint8 panTable[64]{
0, 3, 8, 12, 16, 19, 22, 24, 26, 28, 30, 31, 33, 34, 36, 37, 39, 40, 41, 42, 44, 45,
46, 47, 48, 49, 49, 50, 51, 52, 53, 53, 54, 55, 55, 56, 56, 57, 57, 58, 58, 58, 59, 59,
59, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63};
// TODO: where is this used? Is this the right file? // TODO: where is this used? Is this the right file?
enum eVehicleModel { enum eVehicleModel {
@ -591,11 +601,13 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1,
return newFreq; return newFreq;
} }
WRAPPER
int32 int32
cAudioManager::ComputePan(float, CVector *) cAudioManager::ComputePan(float dist, CVector *vec)
{ {
EAXJMP(0x57AD20); int32 index = min(63, Abs(vec->x / (dist / 64.f)));
if(vec->x > 0.f) return max(20, 63 - panTable[index]);
return min(107, panTable[index] + 63);
} }
uint32 uint32
@ -654,7 +666,10 @@ cAudioManager::DestroyAllGameCreatedEntities()
case AUDIOTYPE_SCRIPTOBJECT: case AUDIOTYPE_SCRIPTOBJECT:
entity = entity =
(cAudioScriptObject *)m_asAudioEntities[i].m_pEntity; (cAudioScriptObject *)m_asAudioEntities[i].m_pEntity;
if(entity) { delete entity; } if(entity) {
delete entity;
m_asAudioEntities[i].m_pEntity = nil;
}
DestroyEntity(i); DestroyEntity(i);
break; break;
default: break; default: break;
@ -3147,11 +3162,94 @@ cAudioManager::InitialisePoliceRadio()
for(int32 i = 0; i < 18; i++) { gMinTimeToNextReport[i] = m_nTimeOfRecentCrime; } for(int32 i = 0; i < 18; i++) { gMinTimeToNextReport[i] = m_nTimeOfRecentCrime; }
} }
WRAPPER struct tPoliceRadioZone
{
char m_aName[8];
uint32 m_nSampleIndex;
int32 field_12;
};
tPoliceRadioZone* ZoneSfx = (tPoliceRadioZone*)0x880240;
char* SubZo2Label = (char*)0x6E9918;
char* SubZo3Label = (char*)0x6E9870;
void void
cAudioManager::InitialisePoliceRadioZones() cAudioManager::InitialisePoliceRadioZones()
{ {
EAXJMP(0x57EAC0); for(int32 i = 0; i < 36; i++) { ZoneSfx[i].m_aName[0] = 0; }
strcpy((char *)ZoneSfx, "HOSPI_2");
ZoneSfx[0].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD;
strcpy((char *)&ZoneSfx[1], "CONSTRU");
ZoneSfx[1].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_FORT_STAUNTON;
strcpy((char *)&ZoneSfx[2], "STADIUM");
ZoneSfx[2].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ASPATRIA;
strcpy((char *)&ZoneSfx[3], "YAKUSA");
ZoneSfx[3].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_TORRINGTON;
strcpy((char *)&ZoneSfx[4], "SHOPING");
ZoneSfx[4].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_BEDFORD_POINT;
strcpy((char *)&ZoneSfx[5], "COM_EAS");
ZoneSfx[5].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_NEWPORT;
strcpy((char *)&ZoneSfx[6], "PARK");
ZoneSfx[6].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_BELLEVILLE;
strcpy((char *)&ZoneSfx[7], "UNIVERS");
ZoneSfx[7].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_LIBERTY_CAMPUS;
strcpy((char *)&ZoneSfx[8], "BIG_DAM");
ZoneSfx[8].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_COCHRANE;
strcpy((char *)&ZoneSfx[9], "SUB_IND");
ZoneSfx[9].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PIKE_CREEK;
strcpy((char *)&ZoneSfx[10], "SWANKS");
ZoneSfx[10].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_CEDAR_GROVE;
strcpy((char *)&ZoneSfx[11], "PROJECT");
ZoneSfx[11].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_WICHITA_GARDEN;
strcpy((char *)&ZoneSfx[12], "AIRPORT");
ZoneSfx[12].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_FRANCIS_INTNL;
strcpy((char *)&ZoneSfx[13], "PORT_W");
ZoneSfx[13].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_CALLAHAN_POINT;
strcpy((char *)&ZoneSfx[14], "PORT_S");
ZoneSfx[14].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ATLANTIC_QUAYS;
strcpy((char *)&ZoneSfx[15], "PORT_E");
ZoneSfx[15].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PORTLAND_HARBOUR;
strcpy((char *)&ZoneSfx[16], "PORT_I");
ZoneSfx[16].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_TRENTON;
strcpy((char *)&ZoneSfx[17], "CHINA");
ZoneSfx[17].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_CHINATOWN;
strcpy((char *)&ZoneSfx[18], "REDLIGH");
ZoneSfx[18].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_REDLIGHT;
strcpy((char *)&ZoneSfx[19], "TOWERS");
ZoneSfx[19].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_HEPBURN_HEIGHTS;
strcpy((char *)&ZoneSfx[20], "LITTLEI");
ZoneSfx[20].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ST_MARKS;
strcpy((char *)&ZoneSfx[21], "HARWOOD");
ZoneSfx[21].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_HARWOOD;
strcpy((char *)&ZoneSfx[22], "EASTBAY");
ZoneSfx[22].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PORTLAND_BEACH;
strcpy((char *)&ZoneSfx[23], "S_VIEW");
ZoneSfx[23].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PORTLAND_VIEW;
strcpy((char *)&ZoneSfx[24], "CITYZON");
ZoneSfx[24].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_LIBERTY_CITY;
strcpy((char *)&ZoneSfx[25], "IND_ZON");
ZoneSfx[25].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PORTLAND;
strcpy((char *)&ZoneSfx[26], "COM_ZON");
ZoneSfx[26].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_STAUNTON;
strcpy((char *)&ZoneSfx[27], "SUB_ZON");
ZoneSfx[27].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_SHORESIDE;
strcpy((char *)&ZoneSfx[28], "SUB_ZO2");
ZoneSfx[28].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_SHORESIDE;
strcpy((char *)&ZoneSfx[29], "SUB_ZO3");
ZoneSfx[29].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_SHORESIDE;
strcpy((char *)&ZoneSfx[30], "A");
ZoneSfx[30].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD;
strcpy((char *)&ZoneSfx[31], "A");
ZoneSfx[31].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD;
strcpy((char *)&ZoneSfx[32], "A");
ZoneSfx[32].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD;
strcpy((char *)&ZoneSfx[33], "A");
ZoneSfx[33].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD;
strcpy((char *)&ZoneSfx[34], "A");
ZoneSfx[34].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD;
strcpy(SubZo2Label, "SUB_ZO2");
strcpy(SubZo3Label, "SUB_ZO3");
} }
void void
@ -3221,6 +3319,65 @@ void
cAudioManager::PlayOneShot(int32 index, int16 sound, float vol) cAudioManager::PlayOneShot(int32 index, int16 sound, float vol)
{ {
EAXJMP(0x57A500); EAXJMP(0x57A500);
/*if(m_bIsInitialised) {
if (index >= 0 && index < totalAudioEntitiesSlots) {
if (m_asAudioEntities[index].m_bIsUsed) {
if (sound < SOUND_TOTAL_SOUNDS) {
if (m_asAudioEntities[index].m_nType ==
AUDIOTYPE_SCRIPTOBJECT) {
if (m_nScriptObjectEntityTotal < 40) {
m_asAudioEntities[index].m_awAudioEvent[0] =
sound;
m_asAudioEntities[index].m_Loops = 1;
m_anScriptObjectEntityIndices
[m_nScriptObjectEntityTotal++] = index;
}
}
else {
int32 i = 0;
while (1) {
if (i >= m_asAudioEntities[index].m_Loops) {
if (m_asAudioEntities[index]
.m_Loops < 4) {
m_asAudioEntities[index / 2]
.m_awAudioEvent[i] =
sound;
m_asAudioEntities[index / 4]
.m_afVolume[i] = vol;
++m_asAudioEntities[index]
.m_Loops;
}
return;
}
if (panTable[m_asAudioEntities[index / 2]
.m_awAudioEvent[i]] >
panTable[sound])
break;
++i;
}
if (i < 3) {
memmove(
&m_asAudioEntities[0]
.m_awAudioEvent[i + 1 + index / 2],
&m_asAudioEntities[0]
.m_awAudioEvent[i + index / 2],
2 * (3 - i));
memmove(&m_asAudioEntities[0]
.m_afVolume[i + 1 + index / 4],
&m_asAudioEntities[0]
.m_afVolume[i + index / 4],
4 * (3 - i));
}
m_asAudioEntities[index / 2].m_awAudioEvent[i] =
sound;
m_asAudioEntities[index / 4].m_afVolume[i] = vol;
if (m_asAudioEntities[index].m_Loops < 4)
++m_asAudioEntities[index].m_Loops;
}
}
}
}
}*/
} }
WRAPPER WRAPPER
@ -3390,7 +3547,6 @@ void
cAudioManager::ProcessAirportScriptObject(uint8 sound) cAudioManager::ProcessAirportScriptObject(uint8 sound)
{ {
float dist; float dist;
float distSquared;
float maxDist; float maxDist;
static uint8 counter = 0; static uint8 counter = 0;
@ -3406,9 +3562,9 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound)
maxDist = 6400.f; maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_fSoundIntensity = 80.0f;
break; break;
default: break; default: return;
} }
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) { if(distSquared < maxDist) {
dist = sqrt(distSquared); dist = sqrt(distSquared);
m_sQueueSample.m_fDistance = dist; m_sQueueSample.m_fDistance = dist;
@ -3827,7 +3983,6 @@ void
cAudioManager::ProcessCinemaScriptObject(uint8 sound) cAudioManager::ProcessCinemaScriptObject(uint8 sound)
{ {
uint8 rand; uint8 rand;
float distSquared;
float maxDist; float maxDist;
static uint8 counter = 0; static uint8 counter = 0;
@ -3843,9 +3998,9 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound)
maxDist = 6400.f; maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_fSoundIntensity = 80.0f;
break; break;
default: break; default: return;
} }
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) { if(distSquared < maxDist) {
m_sQueueSample.m_fDistance = sqrt(distSquared); m_sQueueSample.m_fDistance = sqrt(distSquared);
rand = m_anRandomTable[0] % 90u + 30; rand = m_anRandomTable[0] % 90u + 30;
@ -3904,7 +4059,7 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound)
maxDist = 6400.f; maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_fSoundIntensity = 80.0f;
break; break;
default: break; default: return;
} }
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) { if(distSquared < maxDist) {
@ -4437,7 +4592,7 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound)
maxDist = 6400.f; maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_fSoundIntensity = 80.0f;
break; break;
default: break; default: return;
} }
dist = GetDistanceSquared(&m_sQueueSample.m_vecPos); dist = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(dist < maxDist) { if(dist < maxDist) {
@ -4591,7 +4746,6 @@ void
cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) cAudioManager::ProcessLaunderetteScriptObject(uint8 sound)
{ {
float maxDist; float maxDist;
float distSquared;
switch(sound) { switch(sound) {
case SCRIPT_SOUND_LAUNDERETTE_LOOP_S: case SCRIPT_SOUND_LAUNDERETTE_LOOP_S:
@ -4599,9 +4753,9 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound)
maxDist = 900.f; maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_fSoundIntensity = 30.0f;
break; break;
default: break; default: return;
} }
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) { if(distSquared < maxDist) {
m_sQueueSample.m_fDistance = sqrt(distSquared); m_sQueueSample.m_fDistance = sqrt(distSquared);
m_sQueueSample.m_bVolume = ComputeVolume(45u, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_bVolume = ComputeVolume(45u, m_sQueueSample.m_fSoundIntensity,
@ -6855,7 +7009,7 @@ struct tVehicleSampleData {
}; };
int32 *CSWTCH_554 = (int32 *)0x606A50; int32 *CSWTCH_554 = (int32 *)0x606A50;
tVehicleSampleData *vehicleSampleData = (tVehicleSampleData *)0x606204; tVehicleSampleData *CarSounds = (tVehicleSampleData *)0x606204;
void void
cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile) cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile)
@ -6947,7 +7101,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
} else { } else {
freqModifier = 0; freqModifier = 0;
} }
engineSoundType = vehicleSampleData[params->m_nIndex].m_bEngineSoundType; engineSoundType = CarSounds[params->m_nIndex].m_bEngineSoundType;
soundOffset = 3 * (engineSoundType - 1); soundOffset = 3 * (engineSoundType - 1);
if(accelerateState <= 0) { if(accelerateState <= 0) {
if(params->m_fVelocityChange < -0.001f) { if(params->m_fVelocityChange < -0.001f) {
@ -7163,7 +7317,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound)
maxDist = 6400.f; maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_fSoundIntensity = 80.0f;
break; break;
default: break; default: return;
} }
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) { if(distSquared < maxDist) {
@ -7261,7 +7415,7 @@ cAudioManager::ProcessPornCinema(uint8 sound)
m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_fSoundIntensity = 80.0f;
sample = AUDIO_SAMPLE_PORN_CINEMA_3_SEX_1; sample = AUDIO_SAMPLE_PORN_CINEMA_3_SEX_1;
break; break;
default: break; default: return;
} }
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) { if(distSquared < maxDist) {
@ -7319,11 +7473,68 @@ cAudioManager::ProcessPornCinema(uint8 sound)
} }
} }
WRAPPER
void void
cAudioManager::ProcessProjectiles() cAudioManager::ProcessProjectiles()
{ {
EAXJMP(0x578A80); uint8 emittingVol;
float maxDist;
for(int32 i = 0; i < 32; i++) {
if(CProjectileInfo::GetProjectileInfo(i)->m_bInUse) {
switch(CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) {
case WEAPONTYPE_ROCKETLAUNCHER:
emittingVol = maxVolume;
maxDist = 8100.f;
m_sQueueSample.m_fSoundIntensity = 90.0;
m_sQueueSample.m_nSampleIndex = 81;
m_sQueueSample.m_bBankIndex = 0;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
AUDIO_SAMPLE_WEAPON_ROCKET_PROCESS);
m_sQueueSample.field_16 = 3;
break;
case WEAPONTYPE_MOLOTOV:
emittingVol = 50;
maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0;
m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_FIRE_PED;
m_sQueueSample.m_bBankIndex = 0;
m_sQueueSample.m_nFrequency =
32 *
SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_FIRE_PED) /
25;
m_sQueueSample.field_16 = 7;
break;
default: return;
}
m_sQueueSample.field_48 = 4.0;
m_sQueueSample.field_76 = 3;
m_sQueueSample.m_vecPos =
CProjectileInfo::ms_apProjectile[i].GetPosition();
float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity,
m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_counter = i;
m_sQueueSample.m_bIsDistant = 0;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopStart =
SampleManager.GetSampleLoopStartOffset(
m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd =
SampleManager.GetSampleLoopEndOffset(
m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_56 = 0;
m_sQueueSample.m_bReverbFlag = 1;
m_sQueueSample.m_bRequireReflection = 0;
AddSampleToRequestedQueue();
}
}
}
}
} }
void void
@ -7447,7 +7658,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound)
maxDist = 900.f; maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_fSoundIntensity = 30.0f;
break; break;
default: break; default: return;
} }
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) { if(distSquared < maxDist) {
@ -7527,7 +7738,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound)
maxDist = 900.f; maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_fSoundIntensity = 30.0f;
break; break;
default: break; default: return;
} }
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) { if(distSquared < maxDist) {
@ -7676,21 +7887,101 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params)
return 1; return 1;
} }
#if 1
WRAPPER
void
cAudioManager::ProcessVehicle(CVehicle *)
{
EAXJMP(0x569A00);
}
#else
void void
cAudioManager::ProcessVehicle(CVehicle *) cAudioManager::ProcessVehicle(CVehicle *veh)
{ {
EAXJMP(0x569A00); tHandlingData *handling = veh->pHandling;
float velChange;
cVehicleParams params;
m_sQueueSample.m_vecPos = veh->GetPosition();
params.m_bDistancECalculated = 0;
params.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos);
params.m_pVehicle = veh;
params.m_pTransmission = nil;
params.m_nIndex = 0;
params.m_fVelocityChange = 0.0;
if(handling) params.m_pTransmission = &handling->Transmission;
params.m_nIndex = veh->m_modelIndex - 90;
if(params.m_pVehicle->m_status == STATUS_SIMPLE)
velChange = params.m_pVehicle->AutoPilot.m_fMaxTrafficSpeed * 0.02f;
else
velChange =
DotProduct(params.m_pVehicle->m_vecMoveSpeed, params.m_pVehicle->GetForward());
params.m_fVelocityChange = velChange;
switch(params.m_pVehicle->m_vehType) {
case VEHICLE_TYPE_AUTOMOBILE:
UpdateGasPedalAudio((CAutomobile *)veh);
if(params.m_nIndex == RCBANDIT) {
ProcessModelCarEngine(&params);
ProcessVehicleOneShots(&params);
((CAutomobile *)veh)->m_fVelocityChangeForAudio =
params.m_fVelocityChange;
ProcessRainOnVehicle(&params);
break;
}
if(params.m_nIndex == DODO) {
if(!ProcessVehicleRoadNoise(&params)) {
ProcessVehicleOneShots(&params);
((CAutomobile *)veh)->m_fVelocityChangeForAudio =
params.m_fVelocityChange;
ProcessRainOnVehicle(&params);
break;
}
if(CWeather::WetRoads > 0.f) ProcessWetRoadNoise(&params);
ProcessVehicleSkidding(&params);
} else {
if(!ProcessVehicleRoadNoise(&params)) {
ProcessVehicleOneShots(&params);
((CAutomobile *)veh)->m_fVelocityChangeForAudio =
params.m_fVelocityChange;
ProcessRainOnVehicle(&params);
break;
}
ProcessReverseGear(&params);
if(CWeather::WetRoads > 0.f) ProcessWetRoadNoise(&params);
ProcessVehicleSkidding(&params);
ProcessVehicleHorn(&params);
ProcessVehicleSirenOrAlarm(&params);
if(UsesReverseWarning(params.m_nIndex))
ProcessVehicleReverseWarning(&params);
if(HasAirBrakes(params.m_nIndex)) ProcessAirBrakes(&params);
}
ProcessCarBombTick(&params);
ProcessVehicleEngine(&params);
ProcessEngineDamage(&params);
ProcessVehicleDoors(&params);
ProcessVehicleOneShots(&params);
((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange;
ProcessRainOnVehicle(&params);
break;
case VEHICLE_TYPE_BOAT:
ProcessBoatEngine(&params);
ProcessBoatMovingOverWater(&params);
ProcessVehicleOneShots(&params);
ProcessRainOnVehicle(&params);
break;
case VEHICLE_TYPE_TRAIN:
ProcessTrainNoise(&params);
ProcessVehicleOneShots(&params);
ProcessRainOnVehicle(&params);
break;
case VEHICLE_TYPE_HELI:
ProcessHelicopter(&params);
ProcessVehicleOneShots(&params);
ProcessRainOnVehicle(&params);
break;
case VEHICLE_TYPE_PLANE:
ProcessPlane(&params);
ProcessVehicleOneShots(&params);
ProcessRainOnVehicle(&params);
break;
default: ProcessRainOnVehicle(&params); break;
}
} }
#endif
bool bool
cAudioManager::ProcessVehicleDoors(cVehicleParams *params) cAudioManager::ProcessVehicleDoors(cVehicleParams *params)
@ -7740,7 +8031,103 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params)
} }
} }
} }
return 1; return 1;
}
WRAPPER
bool cAudioManager::ProcessVehicleEngine(cVehicleParams *params)
{
EAXJMP(0x56A610);
}
void
cAudioManager::ProcessVehicleHorn(cVehicleParams *params)
{
CAutomobile *automobile;
if(params->m_fDistance < 1600.f) {
automobile = (CAutomobile *)params->m_pVehicle;
if((!automobile->m_bSirenOrAlarm || !UsesSirenSwitching(params->m_nIndex)) &&
automobile->m_modelIndex != MI_MRWHOOP) {
if(automobile->m_nCarHornTimer) {
if(!params->m_pVehicle->m_status) {
CalculateDistance((bool *)params, params->m_fDistance);
m_sQueueSample.m_bVolume =
ComputeVolume(80, 40.f, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_counter = 4;
m_sQueueSample.m_nSampleIndex =
CarSounds[params->m_nIndex].m_nHornSample;
m_sQueueSample.m_bBankIndex = 0;
m_sQueueSample.m_bIsDistant = 0;
m_sQueueSample.field_16 = 2;
m_sQueueSample.m_nFrequency =
CarSounds[params->m_nIndex].m_nHornFrequency;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bEmittingVolume = 80;
m_sQueueSample.m_nLoopStart =
SampleManager.GetSampleLoopStartOffset(
m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd =
SampleManager.GetSampleLoopEndOffset(
m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 5.0;
m_sQueueSample.m_fSoundIntensity = 40.0;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 3;
m_sQueueSample.m_bReverbFlag = 1;
m_sQueueSample.m_bRequireReflection = 0;
AddSampleToRequestedQueue();
}
return;
}
if(automobile->m_nCarHornTimer > 44)
automobile->m_nCarHornTimer = 44;
if(automobile->m_nCarHornTimer == 44)
automobile->field_22D =
(LOBYTE(m_nTimeOfRecentCrime) +
LOBYTE(m_sQueueSample.m_nEntityIndex)) &
7;
if(somethingWithHorns[44 * automobile->field_22D + 44 -
automobile->m_nCarHornTimer]) {
CalculateDistance((bool *)params, params->m_fDistance);
m_sQueueSample.m_bVolume =
ComputeVolume(80, 40.f, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_counter = 4;
m_sQueueSample.m_nSampleIndex =
CarSounds[params->m_nIndex].m_nHornSample;
m_sQueueSample.m_bBankIndex = 0;
m_sQueueSample.m_bIsDistant = 0;
m_sQueueSample.field_16 = 2;
m_sQueueSample.m_nFrequency =
CarSounds[params->m_nIndex].m_nHornFrequency;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bEmittingVolume = 80;
m_sQueueSample.m_nLoopStart =
SampleManager.GetSampleLoopStartOffset(
m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd =
SampleManager.GetSampleLoopEndOffset(
m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 5.0;
m_sQueueSample.m_fSoundIntensity = 40.0;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 3;
m_sQueueSample.m_bReverbFlag = 1;
m_sQueueSample.m_bRequireReflection = 0;
AddSampleToRequestedQueue();
}
}
}
}
}
}
WRAPPER
void cAudioManager::ProcessVehicleOneShots(void*)
{
EAXJMP(0x56CD40);
} }
bool bool
@ -7845,13 +8232,18 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
return 1; return 1;
} }
WRAPPER
void cAudioManager::ProcessVehicleSirenOrAlarm(void*)
{
EAXJMP(0x56C420);
}
void void
cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
{ {
CAutomobile *automobile; CAutomobile *automobile;
cTransmission *transmission; cTransmission *transmission;
signed int emittingVol; int32 emittingVol;
float newSkidVal = 0.f; float newSkidVal = 0.f;
float skidVal = 0.f; float skidVal = 0.f;
@ -7946,8 +8338,45 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
} }
} }
WRAPPER void cAudioManager::ProcessWaterCannon(int32)
void cAudioManager::ProcessWaterCannon(int32) { EAXJMP(0x575F30); } {
for(int32 i = 0; i < 3u; i++) {
if(aCannons[i].m_nId) {
m_sQueueSample.m_vecPos = aCannons[0].m_avecPos[aCannons[i].m_wIndex];
float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < 900.f) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(50, m_sQueueSample.m_fSoundIntensity,
m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_fSoundIntensity = 900.0f;
m_sQueueSample.m_nSampleIndex =
AUDIO_SAMPLE_JUMBO_TAXI_SOUND;
m_sQueueSample.m_bBankIndex = 0;
m_sQueueSample.m_nFrequency = 15591;
m_sQueueSample.field_16 = 5;
m_sQueueSample.m_counter = i;
m_sQueueSample.field_48 = 2.0f;
m_sQueueSample.field_76 = 8;
m_sQueueSample.m_bIsDistant = 0;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.field_56 = 0;
m_sQueueSample.m_bEmittingVolume = 50;
m_sQueueSample.m_nLoopStart =
SampleManager.GetSampleLoopStartOffset(
m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd =
SampleManager.GetSampleLoopEndOffset(
m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReverbFlag = 1;
m_sQueueSample.m_bRequireReflection = 0;
AddSampleToRequestedQueue();
}
}
}
}
}
void void
cAudioManager::ProcessWeather(int32 id) cAudioManager::ProcessWeather(int32 id)
@ -8074,7 +8503,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound)
maxDist = 400.f; maxDist = 400.f;
m_sQueueSample.m_fSoundIntensity = 20.0f; m_sQueueSample.m_fSoundIntensity = 20.0f;
break; break;
default: break; default: return;
} }
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < maxDist) { if(distSquared < maxDist) {
@ -8634,6 +9063,25 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter)
void void
cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col) cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
{ {
static constexpr int32 gOneShotCol[] = {
AUDIO_SAMPLE_COLLISION_PAVEMENT, AUDIO_SAMPLE_COLLISION_PAVEMENT,
AUDIO_SAMPLE_COLLISION_MUFFLED, AUDIO_SAMPLE_COLLISION_DIRT,
AUDIO_SAMPLE_COLLISION_MUD, AUDIO_SAMPLE_COLLISION_PAVEMENT,
AUDIO_SAMPLE_COLLISION_METAL, AUDIO_SAMPLE_COLLISION_MUFFLED,
AUDIO_SAMPLE_COLLISION_HARD, AUDIO_SAMPLE_COLLISION_METAL_DOOR,
AUDIO_SAMPLE_CAR_DOOR_MOVEMENT_1, AUDIO_SAMPLE_COLLISION_METAL_11,
AUDIO_SAMPLE_COLLISION_HARD, AUDIO_SAMPLE_COLLISION_METAL_13,
AUDIO_SAMPLE_COLLISION_METAL_14, AUDIO_SAMPLE_COLLISION_METAL_14,
AUDIO_SAMPLE_COLLISION_FENCE, AUDIO_SAMPLE_COLLISION_FLESH,
AUDIO_SAMPLE_COLLISION_SAND, AUDIO_SAMPLE_COLLISION_WATER,
AUDIO_SAMPLE_COLLISION_WOOD, AUDIO_SAMPLE_COLLISION_WOOD_BOX,
AUDIO_SAMPLE_COLLISION_WOOD_PLANK, AUDIO_SAMPLE_COLLISION_MUFFLED,
AUDIO_SAMPLE_COLLISION_MUFFLED, AUDIO_SAMPLE_COLLISION_HEDGE,
AUDIO_SAMPLE_COLLISION_PAVEMENT, AUDIO_SAMPLE_COLLISION_METAL_27,
AUDIO_SAMPLE_COLLISION_METAL_28, AUDIO_SAMPLE_COLLISION_RUBBER,
AUDIO_SAMPLE_COLLISION_LOOSE, AUDIO_SAMPLE_COLLISION_PAVEMENT,
AUDIO_SAMPLE_COLLISION_GATE};
int16 s1; int16 s1;
int16 s2; int16 s2;
@ -9151,6 +9599,7 @@ InjectHook(0x57C160, &cAudioManager::ClearActiveSamples, PATCH_JUMP);
InjectHook(0x5796A0, &cAudioManager::ClearMissionAudio, PATCH_JUMP); InjectHook(0x5796A0, &cAudioManager::ClearMissionAudio, PATCH_JUMP);
InjectHook(0x57C120, &cAudioManager::ClearRequestedQueue, PATCH_JUMP); InjectHook(0x57C120, &cAudioManager::ClearRequestedQueue, PATCH_JUMP);
InjectHook(0x57AE00, &cAudioManager::ComputeDopplerEffectedFrequency, PATCH_JUMP); InjectHook(0x57AE00, &cAudioManager::ComputeDopplerEffectedFrequency, PATCH_JUMP);
InjectHook(0x57AD20, &cAudioManager::ComputePan, PATCH_JUMP);
InjectHook(0x57ABB0, &cAudioManager::ComputeVolume, PATCH_JUMP); InjectHook(0x57ABB0, &cAudioManager::ComputeVolume, PATCH_JUMP);
InjectHook(0x57A310, &cAudioManager::CreateEntity, PATCH_JUMP); InjectHook(0x57A310, &cAudioManager::CreateEntity, PATCH_JUMP);
InjectHook(0x57A830, &cAudioManager::DestroyAllGameCreatedEntities, PATCH_JUMP); InjectHook(0x57A830, &cAudioManager::DestroyAllGameCreatedEntities, PATCH_JUMP);
@ -9248,7 +9697,7 @@ InjectHook(0x5719E0, &cAudioManager::GetYardieTalkSfx, PATCH_JUMP);
InjectHook(0x56CAB0, &cAudioManager::HasAirBrakes, PATCH_JUMP); InjectHook(0x56CAB0, &cAudioManager::HasAirBrakes, PATCH_JUMP);
InjectHook(0x57A0E0, &cAudioManager::Initialise, PATCH_JUMP); InjectHook(0x57A0E0, &cAudioManager::Initialise, PATCH_JUMP);
InjectHook(0x57EEC0, &cAudioManager::InitialisePoliceRadio, PATCH_JUMP); InjectHook(0x57EEC0, &cAudioManager::InitialisePoliceRadio, PATCH_JUMP);
// InjectHook(0x57EAC0, &cAudioManager::InitialisePoliceRadioZones, PATCH_JUMP); InjectHook(0x57EAC0, &cAudioManager::InitialisePoliceRadioZones, PATCH_JUMP);
InjectHook(0x57B030, &cAudioManager::InterrogateAudioEntities, PATCH_JUMP); InjectHook(0x57B030, &cAudioManager::InterrogateAudioEntities, PATCH_JUMP);
InjectHook(0x57AA50, &cAudioManager::IsAudioInitialised, PATCH_JUMP); InjectHook(0x57AA50, &cAudioManager::IsAudioInitialised, PATCH_JUMP);
InjectHook(0x579650, &cAudioManager::IsMissionAudioSampleFinished, PATCH_JUMP); InjectHook(0x579650, &cAudioManager::IsMissionAudioSampleFinished, PATCH_JUMP);
@ -9257,6 +9706,7 @@ InjectHook(0x579520, &cAudioManager::MissionScriptAudioUsesPoliceChannel, PATCH_
InjectHook(0x56AD10, &cAudioManager::PlayerJustGotInCar, PATCH_JUMP); InjectHook(0x56AD10, &cAudioManager::PlayerJustGotInCar, PATCH_JUMP);
InjectHook(0x56AD20, &cAudioManager::PlayerJustLeftCar, PATCH_JUMP); InjectHook(0x56AD20, &cAudioManager::PlayerJustLeftCar, PATCH_JUMP);
InjectHook(0x579620, &cAudioManager::PlayLoadedMissionAudio, PATCH_JUMP); InjectHook(0x579620, &cAudioManager::PlayLoadedMissionAudio, PATCH_JUMP);
//InjectHook(0x57A500, &cAudioManager::PlayOneShot, PATCH_JUMP);
InjectHook(0x569420, &cAudioManager::PostInitialiseGameSpecificSetup, PATCH_JUMP); InjectHook(0x569420, &cAudioManager::PostInitialiseGameSpecificSetup, PATCH_JUMP);
InjectHook(0x569640, &cAudioManager::PostTerminateGameSpecificShutdown, PATCH_JUMP); InjectHook(0x569640, &cAudioManager::PostTerminateGameSpecificShutdown, PATCH_JUMP);
InjectHook(0x569400, &cAudioManager::PreInitialiseGameSpecificSetup, PATCH_JUMP); InjectHook(0x569400, &cAudioManager::PreInitialiseGameSpecificSetup, PATCH_JUMP);
@ -9300,6 +9750,7 @@ InjectHook(0x56E860, &cAudioManager::ProcessPlane, PATCH_JUMP);
InjectHook(0x56B0D0, &cAudioManager::ProcessPlayersVehicleEngine, PATCH_JUMP); InjectHook(0x56B0D0, &cAudioManager::ProcessPlayersVehicleEngine, PATCH_JUMP);
InjectHook(0x578190, &cAudioManager::ProcessPoliceCellBeatingScriptObject, PATCH_JUMP); InjectHook(0x578190, &cAudioManager::ProcessPoliceCellBeatingScriptObject, PATCH_JUMP);
InjectHook(0x577280, &cAudioManager::ProcessPornCinema, PATCH_JUMP); InjectHook(0x577280, &cAudioManager::ProcessPornCinema, PATCH_JUMP);
InjectHook(0x578A80, &cAudioManager::ProcessProjectiles, PATCH_JUMP);
InjectHook(0x569CC0, &cAudioManager::ProcessRainOnVehicle, PATCH_JUMP); InjectHook(0x569CC0, &cAudioManager::ProcessRainOnVehicle, PATCH_JUMP);
InjectHook(0x569700, &cAudioManager::ProcessReverb, PATCH_JUMP); InjectHook(0x569700, &cAudioManager::ProcessReverb, PATCH_JUMP);
InjectHook(0x569E50, &cAudioManager::ProcessReverseGear, PATCH_JUMP); InjectHook(0x569E50, &cAudioManager::ProcessReverseGear, PATCH_JUMP);
@ -9308,10 +9759,13 @@ InjectHook(0x576070, &cAudioManager::ProcessScriptObject, PATCH_JUMP);
InjectHook(0x577970, &cAudioManager::ProcessShopScriptObject, PATCH_JUMP); InjectHook(0x577970, &cAudioManager::ProcessShopScriptObject, PATCH_JUMP);
InjectHook(0x5697D0, &cAudioManager::ProcessSpecial, PATCH_JUMP); InjectHook(0x5697D0, &cAudioManager::ProcessSpecial, PATCH_JUMP);
InjectHook(0x56DBF0, &cAudioManager::ProcessTrainNoise, PATCH_JUMP); InjectHook(0x56DBF0, &cAudioManager::ProcessTrainNoise, PATCH_JUMP);
InjectHook(0x569A00, &cAudioManager::ProcessVehicle, PATCH_JUMP);
InjectHook(0x56C770, &cAudioManager::ProcessVehicleDoors, PATCH_JUMP); InjectHook(0x56C770, &cAudioManager::ProcessVehicleDoors, PATCH_JUMP);
InjectHook(0x56C200, &cAudioManager::ProcessVehicleHorn, PATCH_JUMP);
InjectHook(0x56C640, &cAudioManager::ProcessVehicleReverseWarning, PATCH_JUMP); InjectHook(0x56C640, &cAudioManager::ProcessVehicleReverseWarning, PATCH_JUMP);
InjectHook(0x56A230, &cAudioManager::ProcessVehicleRoadNoise, PATCH_JUMP); InjectHook(0x56A230, &cAudioManager::ProcessVehicleRoadNoise, PATCH_JUMP);
InjectHook(0x56BCB0, &cAudioManager::ProcessVehicleSkidding, PATCH_JUMP); InjectHook(0x56BCB0, &cAudioManager::ProcessVehicleSkidding, PATCH_JUMP);
InjectHook(0x575F30, &cAudioManager::ProcessWaterCannon, PATCH_JUMP);
InjectHook(0x578370, &cAudioManager::ProcessWeather, PATCH_JUMP); InjectHook(0x578370, &cAudioManager::ProcessWeather, PATCH_JUMP);
InjectHook(0x56A440, &cAudioManager::ProcessWetRoadNoise, PATCH_JUMP); InjectHook(0x56A440, &cAudioManager::ProcessWetRoadNoise, PATCH_JUMP);
InjectHook(0x577530, &cAudioManager::ProcessWorkShopScriptObject, PATCH_JUMP); InjectHook(0x577530, &cAudioManager::ProcessWorkShopScriptObject, PATCH_JUMP);

View file

@ -323,7 +323,7 @@ public:
void ClearRequestedQueue(); /// ok void ClearRequestedQueue(); /// ok
int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2,
float speedMultiplier) const; /// ok float speedMultiplier) const; /// ok
int32 ComputePan(float, CVector *); // todo int32 ComputePan(float, CVector *); /// ok
uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance) const; /// ok uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance) const; /// ok
int32 CreateEntity(int32 type, CPhysical *entity); /// ok int32 CreateEntity(int32 type, CPhysical *entity); /// ok
@ -437,7 +437,7 @@ public:
void Initialise(); /// ok void Initialise(); /// ok
void InitialisePoliceRadio(); /// ok void InitialisePoliceRadio(); /// ok
void InitialisePoliceRadioZones(); // todo void InitialisePoliceRadioZones(); /// ok
void InterrogateAudioEntities(); /// ok void InterrogateAudioEntities(); /// ok
bool IsAudioInitialised() const; /// ok bool IsAudioInitialised() const; /// ok
bool IsMissionAudioSampleFinished(); /// ok bool IsMissionAudioSampleFinished(); /// ok
@ -446,13 +446,13 @@ public:
bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok
void PlayLoadedMissionAudio(); /// ok void PlayLoadedMissionAudio(); /// ok
void PlayOneShot(int32 index, int16 sound, float vol); // todo void PlayOneShot(int32 index, int16 sound, float vol); // to do (need testing)
uint32 PlaySuspectLastSeen(float x, float y, float z); // todo uint32 PlaySuspectLastSeen(float x, float y, float z); // todo
void PlayerJustGotInCar() const; /// ok void PlayerJustGotInCar() const; /// ok
void PlayerJustLeftCar() const; /// ok void PlayerJustLeftCar() const; /// ok
void PostInitialiseGameSpecificSetup(); /// ok void PostInitialiseGameSpecificSetup(); /// ok
void PostTerminateGameSpecificShutdown(); /// ok void PostTerminateGameSpecificShutdown(); /// ok
void PreInitialiseGameSpecificSetup() const; void PreInitialiseGameSpecificSetup() const; //ok
void PreloadMissionAudio(char *); // todo void PreloadMissionAudio(char *); // todo
void PreTerminateGameSpecificShutdown(); /// ok void PreTerminateGameSpecificShutdown(); /// ok
/// processX - main logic of adding new sounds /// processX - main logic of adding new sounds
@ -497,10 +497,10 @@ public:
void ProcessPhysical(int32 id); /// ok void ProcessPhysical(int32 id); /// ok
void ProcessPlane(cVehicleParams *params); /// ok void ProcessPlane(cVehicleParams *params); /// ok
void ProcessPlayersVehicleEngine(cVehicleParams *params, void ProcessPlayersVehicleEngine(cVehicleParams *params,
CAutomobile *automobile); /// ok (check float comparisons) CAutomobile *automobile); /// ok
void ProcessPoliceCellBeatingScriptObject(uint8 sound); /// ok void ProcessPoliceCellBeatingScriptObject(uint8 sound); /// ok
void ProcessPornCinema(uint8 sound); /// ok void ProcessPornCinema(uint8 sound); /// ok
void ProcessProjectiles(); // todo requires CProjectileInfo void ProcessProjectiles(); /// ok
void ProcessRainOnVehicle(cVehicleParams *params); /// ok void ProcessRainOnVehicle(cVehicleParams *params); /// ok
void ProcessReverb() const; /// ok void ProcessReverb() const; /// ok
bool ProcessReverseGear(cVehicleParams *a2); /// ok bool ProcessReverseGear(cVehicleParams *a2); /// ok
@ -509,16 +509,16 @@ public:
void ProcessShopScriptObject(uint8 sound); /// ok void ProcessShopScriptObject(uint8 sound); /// ok
void ProcessSpecial(); /// ok void ProcessSpecial(); /// ok
bool ProcessTrainNoise(cVehicleParams *params); /// ok bool ProcessTrainNoise(cVehicleParams *params); /// ok
void ProcessVehicle(CVehicle *); // todo void ProcessVehicle(CVehicle *vehicle); /// ok
bool ProcessVehicleDoors(cVehicleParams *params); /// ok bool ProcessVehicleDoors(cVehicleParams *params); /// ok
bool ProcessVehicleEngine(void *); // todo bool ProcessVehicleEngine(cVehicleParams *params); // todo
void ProcessVehicleHorn(cVehicleParams *params); // todo void ProcessVehicleHorn(cVehicleParams *params); /// ok
void ProcessVehicleOneShots(void *); // todo void ProcessVehicleOneShots(void *); // todo
bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok
bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok
void ProcessVehicleSirenOrAlarm(void *); // todo void ProcessVehicleSirenOrAlarm(void *); // todo
void ProcessVehicleSkidding(cVehicleParams *params); /// ok void ProcessVehicleSkidding(cVehicleParams *params); /// ok
void ProcessWaterCannon(int32); // todo void ProcessWaterCannon(int32); /// ok
void ProcessWeather(int32 id); /// ok void ProcessWeather(int32 id); /// ok
bool ProcessWetRoadNoise(cVehicleParams *params); /// ok bool ProcessWetRoadNoise(cVehicleParams *params); /// ok
void ProcessWorkShopScriptObject(uint8 sound); /// ok void ProcessWorkShopScriptObject(uint8 sound); /// ok
@ -543,8 +543,7 @@ public:
void SetEffectsFadeVolume(uint8 volume) const; void SetEffectsFadeVolume(uint8 volume) const;
void SetEffectsMasterVolume(uint8 volume) const; void SetEffectsMasterVolume(uint8 volume) const;
void SetEntityStatus(int32 id, bool status); void SetEntityStatus(int32 id, bool status);
uint32 uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision); /// ok
SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision); /// ok
void SetMissionAudioLocation(float x, float y, float z); void SetMissionAudioLocation(float x, float y, float z);
void SetMissionScriptPoliceAudio(int32 sfx) const; void SetMissionScriptPoliceAudio(int32 sfx) const;
void SetMonoMode(uint8); // todo (mobile) void SetMonoMode(uint8); // todo (mobile)

View file

@ -255,7 +255,7 @@ CAnimViewer::Update(void)
if (modelInfo->m_type == MITYPE_VEHICLE) { if (modelInfo->m_type == MITYPE_VEHICLE) {
CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo; CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo;
if (veh->m_vehicleType != VEHICLE_TYPE_CAR) { if (veh->m_vehicleType != VEHICLE_TYPE_AUTOMOBILE) {
// Not ready yet // Not ready yet
/* if (veh->m_vehicleType == VEHICLE_TYPE_BOAT) /* if (veh->m_vehicleType == VEHICLE_TYPE_BOAT)
{ {

View file

@ -738,7 +738,7 @@ CFileLoader::LoadVehicleObject(const char *line)
if(strncmp(type, "car", 4) == 0){ if(strncmp(type, "car", 4) == 0){
mi->m_wheelId = misc; mi->m_wheelId = misc;
mi->m_wheelScale = wheelScale; mi->m_wheelScale = wheelScale;
mi->m_vehicleType = VEHICLE_TYPE_CAR; mi->m_vehicleType = VEHICLE_TYPE_AUTOMOBILE;
}else if(strncmp(type, "boat", 5) == 0){ }else if(strncmp(type, "boat", 5) == 0){
mi->m_vehicleType = VEHICLE_TYPE_BOAT; mi->m_vehicleType = VEHICLE_TYPE_BOAT;
}else if(strncmp(type, "train", 6) == 0){ }else if(strncmp(type, "train", 6) == 0){

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "common.h"
class CPtrNode class CPtrNode
{ {
public: public:

View file

@ -793,7 +793,7 @@ CWorld::TestSphereAgainstSectorList(CPtrList &list, CVector spherePos, float rad
*eCol, &ms_testSpherePoint, nil, nil); *eCol, &ms_testSpherePoint, nil, nil);
if (collidedSpheres != 0 || if (collidedSpheres != 0 ||
(e->IsVehicle() && ((CVehicle*)e)->m_vehType == VEHICLE_TYPE_CAR && (e->IsVehicle() && ((CVehicle*)e)->m_vehType == VEHICLE_TYPE_AUTOMOBILE &&
e->m_modelIndex != MI_DODO && radius + eCol->boundingBox.max.x > distance)) { e->m_modelIndex != MI_DODO && radius + eCol->boundingBox.max.x > distance)) {
return e; return e;
} }

View file

@ -339,7 +339,7 @@ void
RenderEffects(void) RenderEffects(void)
{ {
CGlass::Render(); CGlass::Render();
CWaterCannons::Render(); CWaterCannon::Render();
CSpecialFX::Render(); CSpecialFX::Render();
CShadows::RenderStaticShadows(); CShadows::RenderStaticShadows();
CShadows::RenderStoredShadows(); CShadows::RenderStoredShadows();

View file

@ -1897,7 +1897,7 @@ CPhysical::ProcessCollision(void)
CTimer::SetTimeStep(savedTimeStep); CTimer::SetTimeStep(savedTimeStep);
if(IsVehicle()){ if(IsVehicle()){
CVehicle *veh = (CVehicle*)this; CVehicle *veh = (CVehicle*)this;
if(veh->m_vehType == VEHICLE_TYPE_CAR){ if(veh->m_vehType == VEHICLE_TYPE_AUTOMOBILE){
CAutomobile *car = (CAutomobile*)this; CAutomobile *car = (CAutomobile*)this;
car->m_aSuspensionSpringRatio[0] = 1.0f; car->m_aSuspensionSpringRatio[0] = 1.0f;
car->m_aSuspensionSpringRatio[1] = 1.0f; car->m_aSuspensionSpringRatio[1] = 1.0f;

View file

@ -26,7 +26,7 @@ enum {
}; };
enum eVehicleType { enum eVehicleType {
VEHICLE_TYPE_CAR, VEHICLE_TYPE_AUTOMOBILE,
VEHICLE_TYPE_BOAT, VEHICLE_TYPE_BOAT,
VEHICLE_TYPE_TRAIN, VEHICLE_TYPE_TRAIN,
VEHICLE_TYPE_HELI, VEHICLE_TYPE_HELI,

View file

@ -4388,7 +4388,7 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
neededTurn = 2 * PI - neededTurn; neededTurn = 2 * PI - neededTurn;
CVehicle *veh = (CVehicle*)reason; CVehicle *veh = (CVehicle*)reason;
if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR) { if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_AUTOMOBILE) {
if (veh->m_nCarHornTimer) { if (veh->m_nCarHornTimer) {
vehPressedHorn = true; vehPressedHorn = true;
if (!IsPlayer()) if (!IsPlayer())
@ -4456,7 +4456,7 @@ CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump)
angleToFace = m_fRotationCur; angleToFace = m_fRotationCur;
CVehicle *veh = (CVehicle*) reason; CVehicle *veh = (CVehicle*) reason;
if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR && veh->m_nCarHornTimer && !IsPlayer()) { if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_AUTOMOBILE && veh->m_nCarHornTimer && !IsPlayer()) {
onlyRandomJump = true; onlyRandomJump = true;
} }
@ -7245,7 +7245,7 @@ CPed::Seek(void)
false, true, false, false, false, false); false, true, false, false, false, false);
if (obstacle) { if (obstacle) {
if (!obstacle->IsVehicle() || ((CVehicle*)obstacle)->m_vehType == VEHICLE_TYPE_CAR) { if (!obstacle->IsVehicle() || ((CVehicle*)obstacle)->m_vehType == VEHICLE_TYPE_AUTOMOBILE) {
distanceToCountItDone = 2.5f; distanceToCountItDone = 2.5f;
} else { } else {
CVehicleModelInfo *vehModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(obstacle->m_modelIndex); CVehicleModelInfo *vehModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(obstacle->m_modelIndex);
@ -8481,7 +8481,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
if (damageDir > 3) if (damageDir > 3)
damageDir = damageDir - 4; damageDir = damageDir - 4;
if (car->m_vehType == VEHICLE_TYPE_CAR) { if (car->m_vehType == VEHICLE_TYPE_AUTOMOBILE) {
CObject *bonnet = ((CAutomobile*)car)->RemoveBonnetInPedCollision(); CObject *bonnet = ((CAutomobile*)car)->RemoveBonnetInPedCollision();
if (bonnet) { if (bonnet) {

View file

@ -2,6 +2,8 @@
#include "patcher.h" #include "patcher.h"
#include "WaterCannon.h" #include "WaterCannon.h"
extern CWaterCannon* aCannons = (CWaterCannon*)0x8F2CA8;
WRAPPER void CWaterCannons::Update(void) { EAXJMP(0x522510); } WRAPPER void CWaterCannons::Update(void) { EAXJMP(0x522510); }
WRAPPER void CWaterCannons::UpdateOne(uint32 id, CVector *pos, CVector *dir) { EAXJMP(0x522470); } WRAPPER void CWaterCannon::UpdateOne(uint32 id, CVector *pos, CVector *dir) { EAXJMP(0x522470); }
WRAPPER void CWaterCannons::Render(void) { EAXJMP(0x522550); } WRAPPER void CWaterCannon::Render(void) { EAXJMP(0x522550); }

View file

@ -1,9 +1,21 @@
#pragma once #pragma once
class CWaterCannons class CWaterCannon
{ {
public: public:
int32 m_nId;
int16 m_wIndex;
char gap_6[2];
int32 m_nTimeCreated;
CVector m_avecPos[16];
CVector m_avecVelocity[16];
char m_abUsed[16];
static void Update(void); static void Update(void);
static void UpdateOne(uint32 id, CVector *pos, CVector *dir); static void UpdateOne(uint32 id, CVector *pos, CVector *dir);
static void Render(void); static void Render(void);
}; };
static_assert(sizeof(CWaterCannon) == 412, "CWaterCannon: error");
extern CWaterCannon* aCannons;

View file

@ -55,7 +55,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy)
{ {
int i; int i;
m_vehType = VEHICLE_TYPE_CAR; m_vehType = VEHICLE_TYPE_AUTOMOBILE;
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(id); CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(id);
m_fFireBlowUpTimer = 0.0f; m_fFireBlowUpTimer = 0.0f;
@ -2350,7 +2350,7 @@ CAutomobile::FireTruckControl(void)
Sin(m_fCarGunUD)); Sin(m_fCarGunUD));
cannonDir = Multiply3x3(GetMatrix(), cannonDir); cannonDir = Multiply3x3(GetMatrix(), cannonDir);
cannonDir.z += (CGeneral::GetRandomNumber()&0xF)/1000.0f; cannonDir.z += (CGeneral::GetRandomNumber()&0xF)/1000.0f;
CWaterCannons::UpdateOne((uintptr)this, &cannonPos, &cannonDir); CWaterCannon::UpdateOne((uintptr)this, &cannonPos, &cannonDir);
}else if(m_status == STATUS_PHYSICS){ }else if(m_status == STATUS_PHYSICS){
CFire *fire = gFireManager.FindFurthestFire_NeverMindFireMen(GetPosition(), 10.0f, 35.0f); CFire *fire = gFireManager.FindFurthestFire_NeverMindFireMen(GetPosition(), 10.0f, 35.0f);
if(fire == nil) if(fire == nil)
@ -2385,7 +2385,7 @@ CAutomobile::FireTruckControl(void)
Sin(m_fCarGunUD)); Sin(m_fCarGunUD));
cannonDir = Multiply3x3(GetMatrix(), cannonDir); cannonDir = Multiply3x3(GetMatrix(), cannonDir);
cannonDir.z += (CGeneral::GetRandomNumber()&0xF)/1000.0f; cannonDir.z += (CGeneral::GetRandomNumber()&0xF)/1000.0f;
CWaterCannons::UpdateOne((uintptr)this, &cannonPos, &cannonDir); CWaterCannon::UpdateOne((uintptr)this, &cannonPos, &cannonDir);
} }
} }
} }

View file

@ -191,7 +191,7 @@ public:
uint8 m_bRainAudioCounter; uint8 m_bRainAudioCounter;
uint8 m_bRainSamplesCounter; uint8 m_bRainSamplesCounter;
uint8 m_nCarHornTimer; uint8 m_nCarHornTimer;
int8 field_22D; int8 field_22D; // last horn?
bool m_bSirenOrAlarm; bool m_bSirenOrAlarm;
int8 m_comedyControlState; int8 m_comedyControlState;
CStoredCollPoly m_aCollPolys[2]; // poly which is under front/rear part of car CStoredCollPoly m_aCollPolys[2]; // poly which is under front/rear part of car
@ -230,7 +230,7 @@ public:
virtual float GetHeightAboveRoad(void); virtual float GetHeightAboveRoad(void);
virtual void PlayCarHorn(void) {} virtual void PlayCarHorn(void) {}
bool IsCar(void) { return m_vehType == VEHICLE_TYPE_CAR; } bool IsCar(void) { return m_vehType == VEHICLE_TYPE_AUTOMOBILE; }
bool IsBoat(void) { return m_vehType == VEHICLE_TYPE_BOAT; } bool IsBoat(void) { return m_vehType == VEHICLE_TYPE_BOAT; }
bool IsTrain(void) { return m_vehType == VEHICLE_TYPE_TRAIN; } bool IsTrain(void) { return m_vehType == VEHICLE_TYPE_TRAIN; }
bool IsHeli(void) { return m_vehType == VEHICLE_TYPE_HELI; } bool IsHeli(void) { return m_vehType == VEHICLE_TYPE_HELI; }
@ -286,7 +286,7 @@ class cTransmission;
class cVehicleParams class cVehicleParams
{ {
public: public:
char m_bDistanceCalculated; uint8 m_bDistancECalculated;
char gap_1[3]; char gap_1[3];
float m_fDistance; float m_fDistance;
CVehicle *m_pVehicle; CVehicle *m_pVehicle;

View file

@ -0,0 +1,10 @@
#include "CProjectileInfo.h"
CProjectileInfo *gaProjectileInfo = (CProjectileInfo *)0x64ED50;
CProjectileInfo *CProjectileInfo::ms_apProjectile = (CProjectileInfo *)0x87C748;
CProjectileInfo *
CProjectileInfo::GetProjectileInfo(int32 id)
{
return &gaProjectileInfo[id];
}

View file

@ -0,0 +1,20 @@
#pragma once
#include "Object.h"
#include "Weapon.h"
struct CProjectileInfo : public CObject {
eWeaponType m_eWeaponType;
CEntity *m_pSource;
int m_nExplosionTime;
char m_bInUse;
char field_13;
char field_14;
char field_15;
CVector m_vecPos;
static CProjectileInfo *GetProjectileInfo(int32 id);
static CProjectileInfo *ms_apProjectile;
};
extern CProjectileInfo *gaProjectileInfo;