Added missing audio ctors

This commit is contained in:
Sergeanur 2020-04-14 17:13:38 +03:00
parent 41d42a3e53
commit 9a7b833aa5
4 changed files with 65 additions and 28 deletions

View file

@ -10,6 +10,22 @@
const int CollisionSoundIntensity = 60; const int CollisionSoundIntensity = 60;
cAudioCollisionManager::cAudioCollisionManager()
{
m_sQueue.m_pEntity1 = nil;
m_sQueue.m_pEntity2 = nil;
m_sQueue.m_bSurface1 = SURFACE_DEFAULT;
m_sQueue.m_bSurface2 = SURFACE_DEFAULT;
m_sQueue.m_fIntensity2 = 0.0f;
m_sQueue.m_fIntensity1 = 0.0f;
m_sQueue.m_vecPosition = CVector(0.0f, 0.0f, 0.0f);
for (int i = 0; i < NUMAUDIOCOLLISIONS; i++)
m_bIndicesTable[i] = NUMAUDIOCOLLISIONS;
m_bCollisionsInQueue = 0;
}
void void
cAudioCollisionManager::AddCollisionToRequestedQueue() cAudioCollisionManager::AddCollisionToRequestedQueue()
{ {

View file

@ -29,8 +29,8 @@ public:
uint8 m_bCollisionsInQueue; uint8 m_bCollisionsInQueue;
cAudioCollision m_sQueue; cAudioCollision m_sQueue;
// reversed all methods cAudioCollisionManager();
void AddCollisionToRequestedQueue(); /// ok void AddCollisionToRequestedQueue();
}; };
static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error"); static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error");

View file

@ -39,7 +39,7 @@
#include "ZoneCull.h" #include "ZoneCull.h"
#include "sampman.h" #include "sampman.h"
cAudioManager &AudioManager = *(cAudioManager *)0x880FC0; cAudioManager AudioManager;
uint32 gPornNextTime; // = *(uint32*)0x6508A0; uint32 gPornNextTime; // = *(uint32*)0x6508A0;
uint32 gSawMillNextTime; // = *(uint32*)0x6508A4; uint32 gSawMillNextTime; // = *(uint32*)0x6508A4;
uint32 gShopNextTime; // = *(uint32*)0x6508A8; uint32 gShopNextTime; // = *(uint32*)0x6508A8;
@ -192,6 +192,19 @@ enum PLAY_STATUS : uint8 {
enum LOADING_STATUS : uint8 { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED = 1 }; enum LOADING_STATUS : uint8 { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED = 1 };
cPedComments::cPedComments()
{
for (int i = 0; i < NUM_PED_COMMENTS_SLOTS; i++)
for (int j = 0; j < NUM_PED_COMMENTS_BANKS; j++) {
m_asPedComments[j][i].m_nProcess = -1;
m_nIndexMap[j][i] = NUM_PED_COMMENTS_SLOTS;
}
for (int i = 0; i < NUM_PED_COMMENTS_BANKS; i++)
m_nCommentsInBank[i] = 0;
m_nActiveBank = 0;
}
void void
cPedComments::Add(tPedComment *com) cPedComments::Add(tPedComment *com)
{ {
@ -322,9 +335,9 @@ cPedComments::Process()
cAudioManager::cAudioManager() cAudioManager::cAudioManager()
{ {
m_bIsInitialised = 0; m_bIsInitialised = false;
field_1 = 1; field_1 = 1;
m_fSpeedOfSound = 6.8600001f; m_fSpeedOfSound = 6.86f;
m_bTimeSpent = 50; m_bTimeSpent = 50;
m_bActiveSamples = NUM_SOUNDS_SAMPLES_SLOTS; m_bActiveSamples = NUM_SOUNDS_SAMPLES_SLOTS;
m_bActiveSampleQueue = 1; m_bActiveSampleQueue = 1;
@ -350,7 +363,6 @@ cAudioManager::cAudioManager()
cAudioManager::~cAudioManager() cAudioManager::~cAudioManager()
{ {
if(m_bIsInitialised) Terminate(); if(m_bIsInitialised) Terminate();
m_nScriptObjectEntityTotal = 0;
} }
void void
@ -711,7 +723,7 @@ cAudioManager::DestroyAllGameCreatedEntities()
} }
} }
} }
m_nScriptObjectEntityTotal = 0; m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0;
} }
} }
@ -2714,8 +2726,8 @@ cAudioManager::GenerateIntegerRandomNumberTable()
char * char *
cAudioManager::Get3DProviderName(uint8 id) const cAudioManager::Get3DProviderName(uint8 id) const
{ {
if(!m_bIsInitialised) return 0; if(!m_bIsInitialised) return nil;
if(id >= SampleManager.GetNum3DProvidersAvailable()) return 0; if(id >= SampleManager.GetNum3DProvidersAvailable()) return nil;
return SampleManager.Get3DProviderName(id); return SampleManager.Get3DProviderName(id);
} }
@ -3028,12 +3040,12 @@ cAudioManager::PlayOneShot(int32 index, int16 sound, float vol)
if(entity.m_bIsUsed) { if(entity.m_bIsUsed) {
if(sound < SOUND_TOTAL_SOUNDS) { if(sound < SOUND_TOTAL_SOUNDS) {
if(entity.m_nType == AUDIOTYPE_SCRIPTOBJECT) { if(entity.m_nType == AUDIOTYPE_SCRIPTOBJECT) {
if(m_nScriptObjectEntityTotal < if(m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal <
ARRAY_SIZE(m_anScriptObjectEntityIndices)) { ARRAY_SIZE(m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices)) {
entity.m_awAudioEvent[0] = sound; entity.m_awAudioEvent[0] = sound;
entity.m_AudioEvents = 1; entity.m_AudioEvents = 1;
m_anScriptObjectEntityIndices m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices
[m_nScriptObjectEntityTotal++] = index; [m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal++] = index;
} }
} else { } else {
int32 i = 0; int32 i = 0;
@ -9588,15 +9600,15 @@ cAudioManager::ServiceSoundEffects()
ProcessMissionAudio(); ProcessMissionAudio();
AdjustSamplesVolume(); AdjustSamplesVolume();
ProcessActiveQueues(); ProcessActiveQueues();
for(int32 i = 0; i < m_nScriptObjectEntityTotal; ++i) { for(int32 i = 0; i < m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal; ++i) {
cAudioScriptObject *object = cAudioScriptObject *object =
(cAudioScriptObject *)m_asAudioEntities[m_anScriptObjectEntityIndices[i]] (cAudioScriptObject *)m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]]
.m_pEntity; .m_pEntity;
delete object; delete object;
m_asAudioEntities[m_anScriptObjectEntityIndices[i]].m_pEntity = nil; m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity = nil;
DestroyEntity(m_anScriptObjectEntityIndices[i]); DestroyEntity(m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]);
} }
m_nScriptObjectEntityTotal = 0; m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0;
} }
int8 int8
@ -9965,7 +9977,7 @@ cAudioManager::Terminate()
} }
m_nAudioEntitiesTotal = 0; m_nAudioEntitiesTotal = 0;
m_nScriptObjectEntityTotal = 0; m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0;
PreTerminateGameSpecificShutdown(); PreTerminateGameSpecificShutdown();
for(uint32 i = 0; i < DIGITALCHANNELS; i++) { for(uint32 i = 0; i < DIGITALCHANNELS; i++) {
@ -9974,7 +9986,7 @@ cAudioManager::Terminate()
SampleManager.Terminate(); SampleManager.Terminate();
m_bIsInitialised = 0; m_bIsInitialised = false;
PostTerminateGameSpecificShutdown(); PostTerminateGameSpecificShutdown();
} }
} }

View file

@ -197,7 +197,7 @@ public:
bool m_bIsUsed; bool m_bIsUsed;
uint8 m_bStatus; uint8 m_bStatus;
int16 m_awAudioEvent[NUM_AUDIOENTITY_EVENTS]; int16 m_awAudioEvent[NUM_AUDIOENTITY_EVENTS];
uint8 gap_18[2]; //uint8 gap_18[2];
float m_afVolume[NUM_AUDIOENTITY_EVENTS]; float m_afVolume[NUM_AUDIOENTITY_EVENTS];
uint8 m_AudioEvents; uint8 m_AudioEvents;
uint8 field_25[3]; uint8 field_25[3];
@ -216,7 +216,6 @@ public:
float m_fDistance; float m_fDistance;
uint8 m_bVolume; uint8 m_bVolume;
int8 m_nProcess; int8 m_nProcess;
uint8 gap_26[2]; // unused
// no methods // no methods
}; };
@ -230,9 +229,8 @@ public:
uint8 m_nIndexMap[NUM_PED_COMMENTS_BANKS][NUM_PED_COMMENTS_SLOTS]; uint8 m_nIndexMap[NUM_PED_COMMENTS_BANKS][NUM_PED_COMMENTS_SLOTS];
uint8 m_nCommentsInBank[NUM_PED_COMMENTS_BANKS]; uint8 m_nCommentsInBank[NUM_PED_COMMENTS_BANKS];
uint8 m_nActiveBank; uint8 m_nActiveBank;
uint8 gap_1163[1]; // unused
// reversed all methods cPedComments();
void Add(tPedComment *com); void Add(tPedComment *com);
void Process(); void Process();
}; };
@ -246,7 +244,7 @@ class cMissionAudio
public: public:
CVector m_vecPos; CVector m_vecPos;
bool m_bPredefinedProperties; bool m_bPredefinedProperties;
uint8 gap_13[3]; // unused //uint8 gap_13[3];
int m_nSampleIndex; int m_nSampleIndex;
uint8 m_bLoadingStatus; uint8 m_bLoadingStatus;
uint8 m_bPlayStatus; uint8 m_bPlayStatus;
@ -262,6 +260,18 @@ public:
static_assert(sizeof(cMissionAudio) == 32, "cMissionAudio: error"); static_assert(sizeof(cMissionAudio) == 32, "cMissionAudio: error");
// name made up
class cAudioScriptObjectManager
{
public:
int32 m_anScriptObjectEntityIndices[NUM_SCRIPT_MAX_ENTITIES];
int32 m_nScriptObjectEntityTotal;
cAudioScriptObjectManager() { m_nScriptObjectEntityTotal = 0; }
~cAudioScriptObjectManager() { m_nScriptObjectEntityTotal = 0; }
};
class cVehicleParams; class cVehicleParams;
class CPlane; class CPlane;
class CVehicle; class CVehicle;
@ -315,8 +325,7 @@ public:
int32 m_nAudioEntitiesTotal; int32 m_nAudioEntitiesTotal;
CVector m_avecReflectionsPos[NUM_AUDIO_REFLECTIONS]; CVector m_avecReflectionsPos[NUM_AUDIO_REFLECTIONS];
float m_afReflectionsDistances[NUM_AUDIO_REFLECTIONS]; float m_afReflectionsDistances[NUM_AUDIO_REFLECTIONS];
int32 m_anScriptObjectEntityIndices[NUM_SCRIPT_MAX_ENTITIES]; cAudioScriptObjectManager m_sAudioScriptObjectManager;
int32 m_nScriptObjectEntityTotal;
cPedComments m_sPedComments; cPedComments m_sPedComments;
int32 m_nFireAudioEntity; int32 m_nFireAudioEntity;
int32 m_nWaterCannonEntity; int32 m_nWaterCannonEntity;
@ -611,4 +620,4 @@ public:
static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");
extern cAudioManager &AudioManager; extern cAudioManager AudioManager;