CParticleObject done, cDMAudio done

This commit is contained in:
Fire-Head 2019-08-15 04:43:00 +03:00
parent 7ed494906a
commit 6093d855b0
17 changed files with 1927 additions and 232 deletions

View File

@ -440,7 +440,7 @@ cAudioManager::ComputeVolume(int emittingVolume, float soundIntensity, float dis
} }
int32 int32
cAudioManager::CreateEntity(int32 type, CPhysical *entity) cAudioManager::CreateEntity(int32 type, void *entity)
{ {
if(!m_bIsInitialised) return -4; if(!m_bIsInitialised) return -4;
if(!entity) return -2; if(!entity) return -2;
@ -477,8 +477,8 @@ cAudioManager::DestroyAllGameCreatedEntities()
case AUDIOTYPE_WEATHER: case AUDIOTYPE_WEATHER:
case AUDIOTYPE_CRANE: case AUDIOTYPE_CRANE:
case AUDIOTYPE_GARAGE: case AUDIOTYPE_GARAGE:
case AUDIOTYPE_HYDRANT: cAudioManager::DestroyEntity(i); break; case AUDIOTYPE_FIREHYDRANT: cAudioManager::DestroyEntity(i); break;
case AUDIOTYPE_ONE_SHOT: 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; }
@ -602,10 +602,10 @@ cAudioManager::PostInitialiseGameSpecificSetup()
m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (CPhysical *)1); m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (CPhysical *)1);
if(m_nProjectileEntity >= 0) SetEntityStatus(m_nProjectileEntity, 1); if(m_nProjectileEntity >= 0) SetEntityStatus(m_nProjectileEntity, 1);
m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATER_CANNON, (CPhysical *)1); m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATERCANNON, (CPhysical *)1);
if(m_nWaterCannonEntity >= 0) SetEntityStatus(m_nWaterCannonEntity, 1); if(m_nWaterCannonEntity >= 0) SetEntityStatus(m_nWaterCannonEntity, 1);
m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_D, (CPhysical *)1); m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (CPhysical *)1);
if(m_nPoliceChannelEntity >= 0) SetEntityStatus(m_nPoliceChannelEntity, 1); if(m_nPoliceChannelEntity >= 0) SetEntityStatus(m_nPoliceChannelEntity, 1);
m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (CPhysical *)1); m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (CPhysical *)1);
@ -4029,7 +4029,7 @@ cAudioManager::ProcessEntity(int32 id)
cAudioManager::ProcessCrane(); cAudioManager::ProcessCrane();
} }
break; break;
case AUDIOTYPE_ONE_SHOT: case AUDIOTYPE_SCRIPTOBJECT:
if(!m_bUserPause) { if(!m_bUserPause) {
m_sQueueSample.m_bReverbFlag = 1; m_sQueueSample.m_bReverbFlag = 1;
cAudioManager::ProcessScriptObject(id); cAudioManager::ProcessScriptObject(id);
@ -4054,13 +4054,13 @@ cAudioManager::ProcessEntity(int32 id)
case AUDIOTYPE_GARAGE: case AUDIOTYPE_GARAGE:
if(!m_bUserPause) cAudioManager::ProcessGarages(); if(!m_bUserPause) cAudioManager::ProcessGarages();
break; break;
case AUDIOTYPE_HYDRANT: case AUDIOTYPE_FIREHYDRANT:
if(!m_bUserPause) { if(!m_bUserPause) {
m_sQueueSample.m_bReverbFlag = 1; m_sQueueSample.m_bReverbFlag = 1;
cAudioManager::ProcessFireHydrant(); cAudioManager::ProcessFireHydrant();
} }
break; break;
case AUDIOTYPE_WATER_CANNON: case AUDIOTYPE_WATERCANNON:
if(!m_bUserPause) { if(!m_bUserPause) {
m_sQueueSample.m_bReverbFlag = 1; m_sQueueSample.m_bReverbFlag = 1;
cAudioManager::ProcessWaterCannon(id); cAudioManager::ProcessWaterCannon(id);
@ -5617,6 +5617,51 @@ cAudioManager::Service()
EAXJMP(0x57A2A0); EAXJMP(0x57A2A0);
} }
WRAPPER void cAudioManager::PlayOneShot(int, unsigned short, float)
{
EAXJMP(0x57A500);
}
WRAPPER void cAudioManager::SetEffectsFadeVol(unsigned char)
{
EAXJMP(0x57A770);
}
WRAPPER void cAudioManager::SetMusicFadeVol(unsigned char)
{
EAXJMP(0x57A790);
}
WRAPPER int8 cAudioManager::SetCurrent3DProvider(unsigned char)
{
EAXJMP(0x57A910);
}
WRAPPER void cAudioManager::ReportCrime(eCrimeType, CVector const &)
{
EAXJMP(0x5803D0);
}
WRAPPER void cAudioManager::PlaySuspectLastSeen(float, float, float)
{
EAXJMP(0x580500);
}
WRAPPER void cAudioManager::ReportCollision(CEntity *, CEntity *, unsigned char, unsigned char, float, float)
{
EAXJMP(0x568410);
}
WRAPPER void cAudioManager::ResetTimers(unsigned int)
{
EAXJMP(0x57A7B0);
}
WRAPPER void cAudioManager::PreloadMissionAudio(char *)
{
EAXJMP(0x579550);
}
STARTPATCHES STARTPATCHES
InjectHook(0x57B210, &cAudioManager::AddDetailsToRequestedOrderList, PATCH_JUMP); InjectHook(0x57B210, &cAudioManager::AddDetailsToRequestedOrderList, PATCH_JUMP);
InjectHook(0x56AD30, &cAudioManager::AddPlayerCarSample, PATCH_JUMP); InjectHook(0x56AD30, &cAudioManager::AddPlayerCarSample, PATCH_JUMP);

View File

@ -59,15 +59,15 @@ enum eAudioType : int32 {
AUDIOTYPE_FIRE = 2, AUDIOTYPE_FIRE = 2,
AUDIOTYPE_WEATHER = 3, AUDIOTYPE_WEATHER = 3,
AUDIOTYPE_CRANE = 4, AUDIOTYPE_CRANE = 4,
AUDIOTYPE_ONE_SHOT = 5, AUDIOTYPE_SCRIPTOBJECT = 5,
AUDIOTYPE_BRIDGE = 6, AUDIOTYPE_BRIDGE = 6,
AUDIOTYPE_COLLISION = 7, AUDIOTYPE_COLLISION = 7,
AUDIOTYPE_FRONTEND = 8, AUDIOTYPE_FRONTEND = 8,
AUDIOTYPE_PROJECTILE = 9, AUDIOTYPE_PROJECTILE = 9,
AUDIOTYPE_GARAGE = 10, AUDIOTYPE_GARAGE = 10,
AUDIOTYPE_HYDRANT = 11, AUDIOTYPE_FIREHYDRANT = 11,
AUDIOTYPE_WATER_CANNON = 12, AUDIOTYPE_WATERCANNON = 12,
AUDIOTYPE_D = 13, AUDIOTYPE_POLICERADIO = 13,
TOTAL_AUDIO_TYPES = 14, TOTAL_AUDIO_TYPES = 14,
}; };
@ -173,11 +173,12 @@ class CPlane;
class CVehicle; class CVehicle;
class CPed; class CPed;
struct cAudioScriptObject { class cAudioScriptObject {
int16 m_wSound; public:
char gap_2[2]; int16 AudioId;
CVector m_vecPos; char _pad0[2];
int m_nAudioEntityId; CVector Posn;
int32 AudioEntity;
static void *operator new(size_t); static void *operator new(size_t);
static void *operator new(size_t, int); static void *operator new(size_t, int);
@ -204,6 +205,19 @@ enum
REFLECTION_UP, REFLECTION_UP,
MAX_REFLECTIONS, MAX_REFLECTIONS,
}; };
enum AudioEntityHandle
{
AEHANDLE_NONE = -5,
AEHANDLE_ERROR_NOAUDIOSYS = -4,
AEHANDLE_ERROR_NOFREESLOT = -3,
AEHANDLE_ERROR_NOENTITY = -2,
AEHANDLE_ERROR_BADAUDIOTYPE = -1,
};
#define AEHANDLE_IS_FAILED(h) ((h)<0)
#define AEHANDLE_IS_OK(h) ((h)>=0)
class cAudioManager class cAudioManager
{ {
@ -256,8 +270,7 @@ public:
inline uint32 GetFrameCounter(void) { return m_FrameCounter; } inline uint32 GetFrameCounter(void) { return m_FrameCounter; }
float GetReflectionsDistance(int32 idx) { return m_afReflectionsDistances[idx]; } float GetReflectionsDistance(int32 idx) { return m_afReflectionsDistances[idx]; }
int32 GetRandomTabe(int32 idx) { return m_anRandomTable[idx]; } int32 GetRandomNumber(int32 idx) { return m_anRandomTable[idx]; }
// //
void AddDetailsToRequestedOrderList(uint8 sample); /// ok void AddDetailsToRequestedOrderList(uint8 sample); /// ok
@ -277,7 +290,7 @@ public:
float speedMultiplier); /// ok float speedMultiplier); /// ok
int32 ComputePan(float, CVector *); // todo int32 ComputePan(float, CVector *); // todo
uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance); /// ok uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance); /// ok
int32 CreateEntity(int32 type, CPhysical *entity); /// ok int32 CreateEntity(int32 type, void *entity); /// ok
void DestroyAllGameCreatedEntities(); /// ok void DestroyAllGameCreatedEntities(); /// ok
void DestroyEntity(int32 id); /// ok void DestroyEntity(int32 id); /// ok
@ -510,6 +523,17 @@ public:
void ProcessWeather(int32 id); // todo void ProcessWeather(int32 id); // todo
// bool ProcessWetRoadNoise(void *); // bool ProcessWetRoadNoise(void *);
void ProcessWorkShopScriptObject(uint8 sound); /// ok void ProcessWorkShopScriptObject(uint8 sound); /// ok
void PlayOneShot(int, unsigned short, float);
void SetEffectsFadeVol(unsigned char);
void SetMusicFadeVol(unsigned char);
int8 SetCurrent3DProvider(unsigned char);
void ReportCrime(eCrimeType, CVector const &);
void PlaySuspectLastSeen(float, float, float);
void ReportCollision(CEntity *, CEntity *, unsigned char, unsigned char, float, float);
void ResetTimers(unsigned int);
void PreloadMissionAudio(char *);
}; };
static_assert(sizeof(cAudioManager) == 0x4B14, "cAudioManager: error"); static_assert(sizeof(cAudioManager) == 0x4B14, "cAudioManager: error");

View File

@ -1,131 +1,131 @@
#pragma once #pragma once
enum /*eSounds*/ enum
{ {
SOUND_TEST_1 = 0, SCRSOUND_TEST_1 = 0,
_SOUND_UNK_1 = 1, _SCRSOUND_UNK_1 = 1,
_SOUND_UNK_2 = 2, _SCRSOUND_UNK_2 = 2,
_SOUND_UNK_3 = 3, _SCRSOUND_UNK_3 = 3,
_SOUND_CLUB_1_S = 4, _SCRSOUND_CLUB_1_S = 4,
_SOUND_CLUB_1_L = 5, _SCRSOUND_CLUB_1_L = 5,
_SOUND_CLUB_2_S = 6, _SCRSOUND_CLUB_2_S = 6,
_SOUND_CLUB_2_L = 7, _SCRSOUND_CLUB_2_L = 7,
_SOUND_CLUB_3_S = 8, _SCRSOUND_CLUB_3_S = 8,
_SOUND_CLUB_3_L = 9, _SCRSOUND_CLUB_3_L = 9,
_SOUND_CLUB_4_S = 10, _SCRSOUND_CLUB_4_S = 10,
_SOUND_CLUB_4_L = 11, _SCRSOUND_CLUB_4_L = 11,
_SOUND_CLUB_5_S = 12, _SCRSOUND_CLUB_5_S = 12,
_SOUND_CLUB_5_L = 13, _SCRSOUND_CLUB_5_L = 13,
_SOUND_CLUB_6_S = 14, _SCRSOUND_CLUB_6_S = 14,
_SOUND_CLUB_6_L = 15, _SCRSOUND_CLUB_6_L = 15,
_SOUND_CLUB_7_S = 16, _SCRSOUND_CLUB_7_S = 16,
_SOUND_CLUB_7_L = 17, _SCRSOUND_CLUB_7_L = 17,
_SOUND_CLUB_8_S = 18, _SCRSOUND_CLUB_8_S = 18,
_SOUND_CLUB_8_L = 19, _SCRSOUND_CLUB_8_L = 19,
_SOUND_CLUB_9_S = 20, _SCRSOUND_CLUB_9_S = 20,
_SOUND_CLUB_9_L = 21, _SCRSOUND_CLUB_9_L = 21,
_SOUND_CLUB_10_S = 22, _SCRSOUND_CLUB_10_S = 22,
_SOUND_CLUB_10_L = 23, _SCRSOUND_CLUB_10_L = 23,
_SOUND_CLUB_11_S = 24, _SCRSOUND_CLUB_11_S = 24,
_SOUND_CLUB_11_L = 25, _SCRSOUND_CLUB_11_L = 25,
_SOUND_CLUB_12_S = 26, _SCRSOUND_CLUB_12_S = 26,
_SOUND_CLUB_12_L = 27, _SCRSOUND_CLUB_12_L = 27,
_SOUND_CLUB_RAGGA_S = 28, _SCRSOUND_CLUB_RAGGA_S = 28,
_SOUND_CLUB_RAGGA_L = 29, _SCRSOUND_CLUB_RAGGA_L = 29,
SOUND_STRIP_CLUB_LOOP_1_S = 30, SCRSOUND_STRIP_CLUB_LOOP_1_S = 30,
_SOUND_STRIP_CLUB_LOOP_1_L = 31, _SCRSOUND_STRIP_CLUB_LOOP_1_L = 31,
SOUND_STRIP_CLUB_LOOP_2_S = 32, SCRSOUND_STRIP_CLUB_LOOP_2_S = 32,
_SOUND_STRIP_CLUB_LOOP_2_L = 33, _SCRSOUND_STRIP_CLUB_LOOP_2_L = 33,
_SOUND_SFX_WORKSHOP_1 = 34, _SCRSOUND_SFX_WORKSHOP_1 = 34,
_SOUND_SFX_WORKSHOP_2 = 35, _SCRSOUND_SFX_WORKSHOP_2 = 35,
_SOUND_SAWMILL_LOOP_S = 36, _SCRSOUND_SAWMILL_LOOP_S = 36,
SOUND_SAWMILL_LOOP_L = 37, SCRSOUND_SAWMILL_LOOP_L = 37,
_SOUND_DOG_FOOD_FACTORY_S = 38, _SCRSOUND_DOG_FOOD_FACTORY_S = 38,
_SOUND_DOG_FOOD_FACTORY_L = 39, _SCRSOUND_DOG_FOOD_FACTORY_L = 39,
_SOUND_LAUNDERETTE_1 = 40, _SCRSOUND_LAUNDERETTE_1 = 40,
_SOUND_LAUNDERETTE_2 = 41, _SCRSOUND_LAUNDERETTE_2 = 41,
_SOUND_RESTAURANT_CHINATOWN_S = 42, _SCRSOUND_RESTAURANT_CHINATOWN_S = 42,
_SOUND_RESTAURANT_CHINATOWN_L = 43, _SCRSOUND_RESTAURANT_CHINATOWN_L = 43,
_SOUND_RESTAURANT_ITALY_S = 44, _SCRSOUND_RESTAURANT_ITALY_S = 44,
_SOUND_RESTAURANT_ITALY_L = 45, _SCRSOUND_RESTAURANT_ITALY_L = 45,
_SOUND_RESTAURANT_GENERIC_1_S = 46, _SCRSOUND_RESTAURANT_GENERIC_1_S = 46,
_SOUND_RESTAURANT_GENERIC_1_L = 47, _SCRSOUND_RESTAURANT_GENERIC_1_L = 47,
_SOUND_RESTAURANT_GENERIC_2_S = 48, _SCRSOUND_RESTAURANT_GENERIC_2_S = 48,
_SOUND_RESTAURANT_GENERIC_2_L = 49, _SCRSOUND_RESTAURANT_GENERIC_2_L = 49,
_SOUND_AIRPORT_ANNOUNCEMENT_S = 50, _SCRSOUND_AIRPORT_ANNOUNCEMENT_S = 50,
_SOUND_AIRPORT_ANNOUNCEMENT_L = 51, _SCRSOUND_AIRPORT_ANNOUNCEMENT_L = 51,
_SOUND_SHOP_LOOP_1 = 52, _SCRSOUND_SHOP_LOOP_1 = 52,
_SOUND_SHOP_LOOP_2 = 53, _SCRSOUND_SHOP_LOOP_2 = 53,
_SOUND_CINEMA_S = 54, _SCRSOUND_CINEMA_S = 54,
_SOUND_CINEMA_L = 55, _SCRSOUND_CINEMA_L = 55,
_SOUND_DOCKS_FOGHORN_S = 56, _SCRSOUND_DOCKS_FOGHORN_S = 56,
_SOUND_DOCKS_FOGHORN_L = 57, _SCRSOUND_DOCKS_FOGHORN_L = 57,
_SOUND_HOME_S = 58, _SCRSOUND_HOME_S = 58,
_SOUND_HOME_L = 59, _SCRSOUND_HOME_L = 59,
_SOUND_PIANO_BAR = 60, _SCRSOUND_PIANO_BAR = 60,
_SOUND_CLUB = 61, _SCRSOUND_CLUB = 61,
SOUND_PORN_CINEMA_1_S = 62, SCRSOUND_PORN_CINEMA_1_S = 62,
_SOUND_PORN_CINEMA_1_L = 63, _SCRSOUND_PORN_CINEMA_1_L = 63,
SOUND_PORN_CINEMA_2_S = 64, SCRSOUND_PORN_CINEMA_2_S = 64,
_SOUND_PORN_CINEMA_2_L = 65, _SCRSOUND_PORN_CINEMA_2_L = 65,
SOUND_PORN_CINEMA_3_S = 66, SCRSOUND_PORN_CINEMA_3_S = 66,
_SOUND_PORN_CINEMA_3_L = 67, _SCRSOUND_PORN_CINEMA_3_L = 67,
_SOUND_BANK_ALARM_LOOP_S = 68, _SCRSOUND_BANK_ALARM_LOOP_S = 68,
SOUND_BANK_ALARM_LOOP_L = 69, SCRSOUND_BANK_ALARM_LOOP_L = 69,
_SOUND_POLICE_BALL_LOOP_S = 70, _SCRSOUND_POLICE_BALL_LOOP_S = 70,
SOUND_POLICE_BALL_LOOP_L = 71, SCRSOUND_POLICE_BALL_LOOP_L = 71,
_SOUND_RAVE_LOOP_INDUSTRIAL_S = 72, _SCRSOUND_RAVE_LOOP_INDUSTRIAL_S = 72,
SOUND_RAVE_LOOP_INDUSTRIAL_L = 73, SCRSOUND_RAVE_LOOP_INDUSTRIAL_L = 73,
_SOUND_UNK_74 = 74, _SCRSOUND_UNK_74 = 74,
_SOUND_UNK_75 = 75, _SCRSOUND_UNK_75 = 75,
_SOUND_POLICE_CELL_BEATING_LOOP_S = 76, _SCRSOUND_POLICE_CELL_BEATING_LOOP_S = 76,
SOUND_POLICE_CELL_BEATING_LOOP_L = 77, SCRSOUND_POLICE_CELL_BEATING_LOOP_L = 77,
SOUND_INJURED_PED_MALE_OUCH_S = 78, SCRSOUND_INJURED_PED_MALE_OUCH_S = 78,
SOUND_INJURED_PED_MALE_OUCH_L = 79, SCRSOUND_INJURED_PED_MALE_OUCH_L = 79,
SOUND_INJURED_PED_FEMALE_OUCH_S = 80, SCRSOUND_INJURED_PED_FEMALE_OUCH_S = 80,
SOUND_INJURED_PED_FEMALE_OUCH_L = 81, SCRSOUND_INJURED_PED_FEMALE_OUCH_L = 81,
SOUND_EVIDENCE_PICKUP = 82, SCRSOUND_EVIDENCE_PICKUP = 82,
SOUND_UNLOAD_GOLD = 83, SCRSOUND_UNLOAD_GOLD = 83,
_SOUND_RAVE_INDUSTRIAL_S = 84, _SCRSOUND_RAVE_INDUSTRIAL_S = 84,
_SOUND_RAVE_INDUSTRIAL_L = 85, _SCRSOUND_RAVE_INDUSTRIAL_L = 85,
_SOUND_RAVE_COMMERCIAL_S = 86, _SCRSOUND_RAVE_COMMERCIAL_S = 86,
_SOUND_RAVE_COMMERCIAL_L = 87, _SCRSOUND_RAVE_COMMERCIAL_L = 87,
_SOUND_RAVE_SUBURBAN_S = 88, _SCRSOUND_RAVE_SUBURBAN_S = 88,
_SOUND_RAVE_SUBURBAN_L = 89, _SCRSOUND_RAVE_SUBURBAN_L = 89,
_SOUND_GROAN_S = 90, _SCRSOUND_GROAN_S = 90,
_SOUND_GROAN_L = 91, _SCRSOUND_GROAN_L = 91,
SOUND_GATE_START_CLUNK = 92, SCRSOUND_GATE_START_CLUNK = 92,
SOUND_GATE_STOP_CLUNK = 93, SCRSOUND_GATE_STOP_CLUNK = 93,
SOUND_PART_MISSION_COMPLETE = 94, SCRSOUND_PART_MISSION_COMPLETE = 94,
SOUND_CHUNKY_RUN_SHOUT = 95, SCRSOUND_CHUNKY_RUN_SHOUT = 95,
SOUND_SECURITY_GUARD_RUN_AWAY_SHOUT = 96, SCRSOUND_SECURITY_GUARD_RUN_AWAY_SHOUT = 96,
SOUND_RACE_START_1 = 97, SCRSOUND_RACE_START_1 = 97,
SOUND_RACE_START_2 = 98, SCRSOUND_RACE_START_2 = 98,
SOUND_RACE_START_3 = 99, SCRSOUND_RACE_START_3 = 99,
SOUND_RACE_START_GO = 100, SCRSOUND_RACE_START_GO = 100,
SOUND_SWAT_PED_SHOUT = 101, SCRSOUND_SWAT_PED_SHOUT = 101,
SOUND_PRETEND_FIRE_LOOP = 102, SCRSOUND_PRETEND_FIRE_LOOP = 102,
SOUND_AMMUNATION_CHAT_1 = 103, SCRSOUND_AMMUNATION_CHAT_1 = 103,
SOUND_AMMUNATION_CHAT_2 = 104, SCRSOUND_AMMUNATION_CHAT_2 = 104,
SOUND_AMMUNATION_CHAT_3 = 105, SCRSOUND_AMMUNATION_CHAT_3 = 105,
_SOUND_BULLET_WALL_1 = 106, _SCRSOUND_BULLET_WALL_1 = 106,
_SOUND_BULLET_WALL_2 = 107, _SCRSOUND_BULLET_WALL_2 = 107,
_SOUND_BULLET_WALL_3 = 108, _SCRSOUND_BULLET_WALL_3 = 108,
_SOUND_UNK_109 = 109, _SCRSOUND_UNK_109 = 109,
_SOUND_GLASSFX2_1 = 110, _SCRSOUND_GLASSFX2_1 = 110,
_SOUND_GLASSFX2_2 = 111, _SCRSOUND_GLASSFX2_2 = 111,
_SOUND_PHONE_RING = 112, _SCRSOUND_PHONE_RING = 112,
_SOUND_UNK_113 = 113, _SCRSOUND_UNK_113 = 113,
_SOUND_GLASS_SMASH_1 = 114, _SCRSOUND_GLASS_SMASH_1 = 114,
_SOUND_GLASS_SMASH_2 = 115, _SCRSOUND_GLASS_SMASH_2 = 115,
_SOUND_GLASS_CRACK = 116, _SCRSOUND_GLASS_CRACK = 116,
_SOUND_GLASS_SHARD = 117, _SCRSOUND_GLASS_SHARD = 117,
_SOUND_WOODEN_BOX_SMASH = 118, _SCRSOUND_WOODEN_BOX_SMASH = 118,
_SOUND_CARDBOARD_BOX_SMASH = 119, _SCRSOUND_CARDBOARD_BOX_SMASH = 119,
_SOUND_COL_CAR = 120, _SCRSOUND_COL_CAR = 120,
_SOUND_TYRE_BUMP = 121, _SCRSOUND_TYRE_BUMP = 121,
_SOUND_BULLET_SHELL_HIT_GROUND_1 = 122, _SCRSOUND_BULLET_SHELL_HIT_GROUND_1 = 122,
_SOUND_BULLET_SHELL_HIT_GROUND_2 = 123, _SCRSOUND_BULLET_SHELL_HIT_GROUND_2 = 123,
}; };
extern void PlayOneShotScriptObject(uint8 id, CVector const &pos); extern void PlayOneShotScriptObject(uint8 id, CVector const &pos);

View File

@ -1,37 +1,375 @@
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include "DMAudio.h" #include "DMAudio.h"
#include "MusicManager.h"
#include "AudioManager.h"
#include "sampman.h"
cDMAudio &DMAudio = *(cDMAudio*)0x95CDBE; cDMAudio &DMAudio = *(cDMAudio*)0x95CDBE;
WRAPPER void cDMAudio::Terminate(void) { EAXJMP(0x57C780); }
WRAPPER void cDMAudio::ReleaseDigitalHandle(void) { EAXJMP(0x57CA10); }
WRAPPER void cDMAudio::ReacquireDigitalHandle(void) { EAXJMP(0x57CA30); }
WRAPPER void cDMAudio::Service(void) { EAXJMP(0x57C7A0); }
WRAPPER void cDMAudio::ReportCollision(CEntity *A, CEntity *B, uint8 surfA, uint8 surfB, float impulse, float speed) { EAXJMP(0x57CBE0); }
WRAPPER void cDMAudio::ResetTimers(uint32 timerval) { EAXJMP(0x57CCD0); }
WRAPPER bool cDMAudio::IsAudioInitialised() { EAXJMP(0x57CAB0); }
WRAPPER char cDMAudio::GetCDAudioDriveLetter() { EAXJMP(0x57CA90); }
WRAPPER bool cDMAudio::CheckForAnAudioFileOnCD() { EAXJMP(0x57CA70); }
WRAPPER void cDMAudio::ChangeMusicMode(uint8 mode) { EAXJMP(0x57CCF0); }
WRAPPER void cDMAudio::PlayFrontEndSound(uint32, uint32) { EAXJMP(0x57CC20); } void
WRAPPER void cDMAudio::PlayFrontEndTrack(uint32, uint32) { EAXJMP(0x57CC80); } cDMAudio::Initialise(void)
WRAPPER void cDMAudio::StopFrontEndTrack() { EAXJMP(0x57CCB0); } {
WRAPPER void cDMAudio::PlayOneShot(int32 audioentity, uint16 sound/*eSound*/, float) { EAXJMP(0x57C840); } AudioManager.Initialise();
WRAPPER void cDMAudio::SetMusicMasterVolume(uint8) { EAXJMP(0x57C8C0); } }
WRAPPER void cDMAudio::SetEffectsMasterVolume(uint8) { EAXJMP(0x57C890); }
WRAPPER uint8 cDMAudio::SetCurrent3DProvider(uint8) { EAXJMP(0x57C9B0); }
WRAPPER int32 cDMAudio::SetSpeakerConfig(int32) { EAXJMP(0x57C9D0); }
WRAPPER int32 cDMAudio::GetRadioInCar() { EAXJMP(0x57CE40); } void
WRAPPER uint8 cDMAudio::IsMP3RadioChannelAvailable() { EAXJMP(0x57C9F0); } cDMAudio::Terminate(void)
WRAPPER void cDMAudio::SetEffectsFadeVol(uint8) { EAXJMP(0x57C8F0); } {
WRAPPER void cDMAudio::SetMusicFadeVol(uint8) { EAXJMP(0x57C920); } AudioManager.Terminate();
WRAPPER int32 cDMAudio::CreateEntity(int, void*) { EAXJMP(0x57C7C0); } }
WRAPPER void cDMAudio::SetEntityStatus(int32 id, uint8 enable) { EAXJMP(0x57C810); }
WRAPPER void cDMAudio::SetRadioInCar(int32) { EAXJMP(0x57CE60); } void
WRAPPER void cDMAudio::DestroyEntity(int32) { EAXJMP(0x57C7F0); } cDMAudio::Service(void)
WRAPPER void cDMAudio::ClearMissionAudio(void) { EAXJMP(0x57CE20); } {
WRAPPER void cDMAudio::ReportCrime(eCrimeType crime, const CVector &pos) { EAXJMP(0x57CAD0); } AudioManager.Service();
}
int32
cDMAudio::CreateEntity(eAudioType type, void *UID)
{
return AudioManager.CreateEntity(type, UID);
}
void
cDMAudio::DestroyEntity(int32 audioEntity)
{
AudioManager.DestroyEntity(audioEntity);
}
void
cDMAudio::SetEntityStatus(int32 audioEntity, uint8 status)
{
AudioManager.SetEntityStatus(audioEntity, status);
}
void
cDMAudio::PlayOneShot(int32 audioEntity, uint16 oneShot, float volume)
{
AudioManager.PlayOneShot(audioEntity, oneShot, volume);
}
void
cDMAudio::DestroyAllGameCreatedEntities(void)
{
AudioManager.DestroyAllGameCreatedEntities();
}
void
cDMAudio::SetEffectsMasterVolume(uint8 volume)
{
uint8 vol = volume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
AudioManager.SetEffectsMasterVolume(vol);
}
void
cDMAudio::SetMusicMasterVolume(uint8 volume)
{
uint8 vol = volume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
AudioManager.SetMusicMasterVolume(vol);
}
void
cDMAudio::SetEffectsFadeVol(uint8 volume)
{
uint8 vol = volume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
AudioManager.SetEffectsFadeVol(vol);
}
void
cDMAudio::SetMusicFadeVol(uint8 volume)
{
uint8 vol = volume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
AudioManager.SetMusicFadeVol(vol);
}
uint8
cDMAudio::GetNum3DProvidersAvailable(void)
{
return AudioManager.GetNum3DProvidersAvailable();
}
char *
cDMAudio::Get3DProviderName(uint8 id)
{
return AudioManager.Get3DProviderName(id);
}
int8
cDMAudio::GetCurrent3DProviderIndex(void)
{
return AudioManager.GetCurrent3DProviderIndex();
}
int8
cDMAudio::SetCurrent3DProvider(uint8 which)
{
return AudioManager.SetCurrent3DProvider(which);
}
void
cDMAudio::SetSpeakerConfig(int32 config)
{
AudioManager.SetSpeakerConfig(config);
}
bool
cDMAudio::IsMP3RadioChannelAvailable(void)
{
return AudioManager.IsMP3RadioChannelAvailable();
}
void
cDMAudio::ReleaseDigitalHandle(void)
{
AudioManager.ReleaseDigitalHandle();
}
void
cDMAudio::ReacquireDigitalHandle(void)
{
AudioManager.ReacquireDigitalHandle();
}
void
cDMAudio::SetDynamicAcousticModelingStatus(uint8 status)
{
AudioManager.SetDynamicAcousticModelingStatus(status);
}
bool
cDMAudio::CheckForAnAudioFileOnCD(void)
{
return AudioManager.CheckForAnAudioFileOnCD();
}
char
cDMAudio::GetCDAudioDriveLetter(void)
{
return AudioManager.GetCDAudioDriveLetter();
}
bool
cDMAudio::IsAudioInitialised(void)
{
return AudioManager.IsAudioInitialised();
}
void
cDMAudio::ReportCrime(eCrimeType crime, CVector const &pos)
{
AudioManager.ReportCrime(crime, pos);
}
int32
cDMAudio::CreateLoopingScriptObject(cAudioScriptObject *scriptObject)
{
int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, scriptObject);
if ( AEHANDLE_IS_OK(audioEntity) )
AudioManager.SetEntityStatus(audioEntity, true);
return audioEntity;
}
void
cDMAudio::DestroyLoopingScriptObject(int32 audioEntity)
{
AudioManager.DestroyEntity(audioEntity);
}
void
cDMAudio::CreateOneShotScriptObject(cAudioScriptObject *scriptObject)
{
int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, scriptObject);
if ( AEHANDLE_IS_OK(audioEntity) )
{
AudioManager.SetEntityStatus(audioEntity, true);
AudioManager.PlayOneShot(audioEntity, scriptObject->AudioId, 0.0f);
}
}
void
cDMAudio::PlaySuspectLastSeen(float x, float y, float z)
{
AudioManager.PlaySuspectLastSeen(x, y, z);
}
void
cDMAudio::ReportCollision(CEntity *entityA, CEntity *entityB, uint8 surfaceTypeA, uint8 surfaceTypeB, float collisionPower, float velocity)
{
AudioManager.ReportCollision(entityA, entityB, surfaceTypeA, surfaceTypeB, collisionPower, velocity);
}
void
cDMAudio::PlayFrontEndSound(uint16 frontend, uint32 volume)
{
AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, frontend, (float)volume);
}
void
cDMAudio::PlayRadioAnnouncement(uint8 announcement)
{
MusicManager.PlayAnnouncement(announcement);
}
void
cDMAudio::PlayFrontEndTrack(uint8 track, uint8 frontendFlag)
{
MusicManager.PlayFrontEndTrack(track, frontendFlag);
}
void
cDMAudio::StopFrontEndTrack(void)
{
MusicManager.StopFrontEndTrack();
}
void
cDMAudio::ResetTimers(uint32 time)
{
AudioManager.ResetTimers(time);
}
void
cDMAudio::ChangeMusicMode(uint8 mode)
{
MusicManager.ChangeMusicMode(mode);
}
void
cDMAudio::PreloadCutSceneMusic(uint8 track)
{
MusicManager.PreloadCutSceneMusic(track);
}
void
cDMAudio::PlayPreloadedCutSceneMusic(void)
{
MusicManager.PlayPreloadedCutSceneMusic();
}
void
cDMAudio::StopCutSceneMusic(void)
{
MusicManager.StopCutSceneMusic();
}
void
cDMAudio::PreloadMissionAudio(char *missionAudio)
{
AudioManager.PreloadMissionAudio(missionAudio);
}
uint8
cDMAudio::GetMissionAudioLoadingStatus(void)
{
return AudioManager.GetMissionAudioLoadingStatus();
}
void
cDMAudio::SetMissionAudioLocation(float x, float y, float z)
{
AudioManager.SetMissionAudioLocation(x, y, z);
}
void
cDMAudio::PlayLoadedMissionAudio(void)
{
AudioManager.PlayLoadedMissionAudio();
}
bool
cDMAudio::IsMissionAudioSampleFinished(void)
{
return AudioManager.IsMissionAudioSampleFinished();
}
void
cDMAudio::ClearMissionAudio(void)
{
AudioManager.ClearMissionAudio();
}
int32
cDMAudio::GetRadioInCar(void)
{
return MusicManager.GetRadioInCar();
}
void
cDMAudio::SetRadioInCar(uint32 radio)
{
MusicManager.SetRadioInCar(radio);
}
void
cDMAudio::SetRadioChannel(int8 radio, int32 pos)
{
MusicManager.SetRadioChannelByScript(radio, pos);
}
STARTPATCHES
InjectHook(0x57C760, &cDMAudio::Initialise, PATCH_JUMP);
InjectHook(0x57C780, &cDMAudio::Terminate, PATCH_JUMP);
InjectHook(0x57C7A0, &cDMAudio::Service, PATCH_JUMP);
InjectHook(0x57C7C0, &cDMAudio::CreateEntity, PATCH_JUMP);
InjectHook(0x57C7F0, &cDMAudio::DestroyEntity, PATCH_JUMP);
InjectHook(0x57C810, &cDMAudio::SetEntityStatus, PATCH_JUMP);
InjectHook(0x57C840, &cDMAudio::PlayOneShot, PATCH_JUMP);
InjectHook(0x57C870, &cDMAudio::DestroyAllGameCreatedEntities, PATCH_JUMP);
InjectHook(0x57C890, &cDMAudio::SetEffectsMasterVolume, PATCH_JUMP);
InjectHook(0x57C8C0, &cDMAudio::SetMusicMasterVolume, PATCH_JUMP);
InjectHook(0x57C8F0, &cDMAudio::SetEffectsFadeVol, PATCH_JUMP);
InjectHook(0x57C920, &cDMAudio::SetMusicFadeVol, PATCH_JUMP);
InjectHook(0x57C950, &cDMAudio::GetNum3DProvidersAvailable, PATCH_JUMP);
InjectHook(0x57C970, &cDMAudio::Get3DProviderName, PATCH_JUMP);
InjectHook(0x57C990, &cDMAudio::GetCurrent3DProviderIndex, PATCH_JUMP);
InjectHook(0x57C9B0, &cDMAudio::SetCurrent3DProvider, PATCH_JUMP);
InjectHook(0x57C9D0, &cDMAudio::SetSpeakerConfig, PATCH_JUMP);
InjectHook(0x57C9F0, &cDMAudio::IsMP3RadioChannelAvailable, PATCH_JUMP);
InjectHook(0x57CA10, &cDMAudio::ReleaseDigitalHandle, PATCH_JUMP);
InjectHook(0x57CA30, &cDMAudio::ReacquireDigitalHandle, PATCH_JUMP);
InjectHook(0x57CA50, &cDMAudio::SetDynamicAcousticModelingStatus, PATCH_JUMP);
InjectHook(0x57CA70, &cDMAudio::CheckForAnAudioFileOnCD, PATCH_JUMP);
InjectHook(0x57CA90, &cDMAudio::GetCDAudioDriveLetter, PATCH_JUMP);
InjectHook(0x57CAB0, &cDMAudio::IsAudioInitialised, PATCH_JUMP);
InjectHook(0x57CAD0, &cDMAudio::ReportCrime, PATCH_JUMP);
InjectHook(0x57CB00, &cDMAudio::CreateLoopingScriptObject, PATCH_JUMP);
InjectHook(0x57CB40, &cDMAudio::DestroyLoopingScriptObject, PATCH_JUMP);
InjectHook(0x57CB60, &cDMAudio::CreateOneShotScriptObject, PATCH_JUMP);
InjectHook(0x57CBB0, &cDMAudio::PlaySuspectLastSeen, PATCH_JUMP);
InjectHook(0x57CBE0, &cDMAudio::ReportCollision, PATCH_JUMP);
InjectHook(0x57CC20, &cDMAudio::PlayFrontEndSound, PATCH_JUMP);
InjectHook(0x57CC60, &cDMAudio::PlayRadioAnnouncement, PATCH_JUMP);
InjectHook(0x57CC80, &cDMAudio::PlayFrontEndTrack, PATCH_JUMP);
InjectHook(0x57CCB0, &cDMAudio::StopFrontEndTrack, PATCH_JUMP);
InjectHook(0x57CCD0, &cDMAudio::ResetTimers, PATCH_JUMP);
InjectHook(0x57CCF0, &cDMAudio::ChangeMusicMode, PATCH_JUMP);
InjectHook(0x57CD10, &cDMAudio::PreloadCutSceneMusic, PATCH_JUMP);
InjectHook(0x57CD30, &cDMAudio::PlayPreloadedCutSceneMusic, PATCH_JUMP);
InjectHook(0x57CD50, &cDMAudio::StopCutSceneMusic, PATCH_JUMP);
InjectHook(0x57CD70, &cDMAudio::PreloadMissionAudio, PATCH_JUMP);
InjectHook(0x57CD90, &cDMAudio::GetMissionAudioLoadingStatus, PATCH_JUMP);
InjectHook(0x57CDB0, &cDMAudio::SetMissionAudioLocation, PATCH_JUMP);
InjectHook(0x57CDE0, &cDMAudio::PlayLoadedMissionAudio, PATCH_JUMP);
InjectHook(0x57CE00, &cDMAudio::IsMissionAudioSampleFinished, PATCH_JUMP);
InjectHook(0x57CE20, &cDMAudio::ClearMissionAudio, PATCH_JUMP);
InjectHook(0x57CE40, &cDMAudio::GetRadioInCar, PATCH_JUMP);
InjectHook(0x57CE60, &cDMAudio::SetRadioInCar, PATCH_JUMP);
InjectHook(0x57CE80, &cDMAudio::SetRadioChannel, PATCH_JUMP);
//InjectHook(0x57CEB0, `global constructor keyed to'dmaudio.cpp, PATCH_JUMP);
//InjectHook(0x57CED0, cDMAudio::~cDMAudio, PATCH_JUMP);
ENDPATCHES

View File

@ -1,5 +1,4 @@
#pragma once #pragma once
enum eSound : int16 enum eSound : int16
{ {
SOUND_CAR_DOOR_CLOSE_BONNET = 0, SOUND_CAR_DOOR_CLOSE_BONNET = 0,
@ -172,39 +171,84 @@ enum eSound : int16
SOUND_TOTAL_PED_SOUNDS = 167, SOUND_TOTAL_PED_SOUNDS = 167,
}; };
class cAudioScriptObject;
class CEntity; class CEntity;
enum eCrimeType; enum eCrimeType;
enum eAudioType;
class cDMAudio class cDMAudio
{ {
public: public:
~cDMAudio()
{ }
void Initialise(void);
void Terminate(void); void Terminate(void);
void Service(void);
int32 CreateEntity(eAudioType type, void *UID);
void DestroyEntity(int32 audioEntity);
void SetEntityStatus(int32 audioEntity, uint8 status);
void PlayOneShot(int32 audioEntity, uint16 oneShot, float volume);
void DestroyAllGameCreatedEntities(void);
void SetEffectsMasterVolume(uint8 volume);
void SetMusicMasterVolume(uint8 volume);
void SetEffectsFadeVol(uint8 volume);
void SetMusicFadeVol(uint8 volume);
uint8 GetNum3DProvidersAvailable(void);
char *Get3DProviderName(uint8 id);
int8 GetCurrent3DProviderIndex(void);
int8 SetCurrent3DProvider(uint8 which);
void SetSpeakerConfig(int32 config);
bool IsMP3RadioChannelAvailable(void);
void ReleaseDigitalHandle(void); void ReleaseDigitalHandle(void);
void ReacquireDigitalHandle(void); void ReacquireDigitalHandle(void);
void Service(void);
void ReportCollision(CEntity* A, CEntity* B, uint8 surfA, uint8 surfB, float impulse, float speed); void SetDynamicAcousticModelingStatus(uint8 status);
void ResetTimers(uint32 timerval);
bool IsAudioInitialised(void);
char GetCDAudioDriveLetter(void);
bool CheckForAnAudioFileOnCD(void); bool CheckForAnAudioFileOnCD(void);
char GetCDAudioDriveLetter(void);
bool IsAudioInitialised(void);
void ReportCrime(eCrimeType crime, CVector const &pos);
int32 CreateLoopingScriptObject(cAudioScriptObject *scriptObject);
void DestroyLoopingScriptObject(int32 audioEntity);
void CreateOneShotScriptObject(cAudioScriptObject *scriptObject);
void PlaySuspectLastSeen(float x, float y, float z);
void ReportCollision(CEntity *entityA, CEntity *entityB, uint8 surfaceTypeA, uint8 surfaceTypeB, float collisionPower, float velocity);
void PlayFrontEndSound(uint16 frontend, uint32 volume);
void PlayRadioAnnouncement(uint8 announcement);
void PlayFrontEndTrack(uint8 track, uint8 frontendFlag);
void StopFrontEndTrack(void);
void ResetTimers(uint32 time);
void ChangeMusicMode(uint8 mode); void ChangeMusicMode(uint8 mode);
void PlayFrontEndSound(uint32, uint32);
void PlayFrontEndTrack(uint32, uint32); void PreloadCutSceneMusic(uint8 track);
void StopFrontEndTrack(); void PlayPreloadedCutSceneMusic(void);
void PlayOneShot(int32 audioentity, uint16 sound/*eSound*/, float); void StopCutSceneMusic(void);
void SetMusicMasterVolume(uint8);
void SetEffectsMasterVolume(uint8); void PreloadMissionAudio(char *missionAudio);
uint8 SetCurrent3DProvider(uint8); uint8 GetMissionAudioLoadingStatus(void);
int32 SetSpeakerConfig(int32); void SetMissionAudioLocation(float x, float y, float z);
int32 GetRadioInCar(void); void PlayLoadedMissionAudio(void);
void SetEffectsFadeVol(uint8); bool IsMissionAudioSampleFinished(void);
void SetMusicFadeVol(uint8);
int32 CreateEntity(int, void*);
void SetEntityStatus(int32 id, uint8 enable);
void SetRadioInCar(int32);
uint8 IsMP3RadioChannelAvailable();
void DestroyEntity(int32);
void ClearMissionAudio(void); void ClearMissionAudio(void);
void ReportCrime(eCrimeType crime, const CVector &pos);
int32 GetRadioInCar(void);
void SetRadioInCar(uint32 radio);
void SetRadioChannel(int8 radio, int32 pos);
}; };
extern cDMAudio &DMAudio; extern cDMAudio &DMAudio;

View File

@ -202,3 +202,44 @@ cMusicManager::StopFrontEndTrack()
{ {
EAXJMP(0x57E3D0); EAXJMP(0x57E3D0);
} }
WRAPPER void cMusicManager::PlayAnnouncement(unsigned char)
{
EAXJMP(0x57E430);
}
WRAPPER void cMusicManager::PlayFrontEndTrack(unsigned char, unsigned char)
{
EAXJMP(0x57E2E0);
}
WRAPPER void cMusicManager::PreloadCutSceneMusic(unsigned char)
{
EAXJMP(0x57E210);
}
WRAPPER void cMusicManager::PlayPreloadedCutSceneMusic(void)
{
EAXJMP(0x57E290);
}
WRAPPER void cMusicManager::StopCutSceneMusic(void)
{
EAXJMP(0x57E2B0);
}
WRAPPER int32 cMusicManager::GetRadioInCar(void)
{
EAXJMP(0x57D1D0);
}
WRAPPER void cMusicManager::SetRadioInCar(unsigned int)
{
EAXJMP(0x57D2C0);
}
WRAPPER void cMusicManager::SetRadioChannelByScript(unsigned char, int)
{
EAXJMP(0x57D180);
}

View File

@ -286,6 +286,15 @@ public:
char *Get3DProviderName(char); char *Get3DProviderName(char);
bool PlayerInCar(); bool PlayerInCar();
void DisplayRadioStationName(); void DisplayRadioStationName();
void PlayAnnouncement(unsigned char);
void PlayFrontEndTrack(unsigned char, unsigned char);
void PreloadCutSceneMusic(unsigned char);
void PlayPreloadedCutSceneMusic(void);
void StopCutSceneMusic(void);
int32 GetRadioInCar(void);
void SetRadioInCar(unsigned int);
void SetRadioChannelByScript(unsigned char, int);
}; };
static_assert(sizeof(cMusicManager) == 0x95C, "cMusicManager: error"); static_assert(sizeof(cMusicManager) == 0x95C, "cMusicManager: error");

View File

@ -1194,7 +1194,7 @@ cSampleManager::Initialise(void)
int32 randval; int32 randval;
if ( bUseRandomTable ) if ( bUseRandomTable )
randval = AudioManager.GetRandomTabe(1); randval = AudioManager.GetRandomNumber(1);
else else
randval = localtm->tm_sec * localtm->tm_min; randval = localtm->tm_sec * localtm->tm_min;
@ -1205,16 +1205,16 @@ cSampleManager::Initialise(void)
randmp3 = randmp3->pNext; randmp3 = randmp3->pNext;
if ( bUseRandomTable ) if ( bUseRandomTable )
_CurMP3Pos = AudioManager.GetRandomTabe(0) % randmp3->nTrackLength; _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength;
else else
{ {
if ( localtm->tm_sec > 0 ) if ( localtm->tm_sec > 0 )
{ {
int32 s = localtm->tm_sec; int32 s = localtm->tm_sec;
_CurMP3Pos = s*s*s*s*s*s*s*s % randmp3->nTrackLength; _CurMP3Pos = s*s*s*s*s*s*s*s % randmp3->nTrackLength;
} }
else else
_CurMP3Pos = AudioManager.GetRandomTabe(0) % randmp3->nTrackLength; _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength;
} }
} }
else else
@ -1293,7 +1293,7 @@ cSampleManager::CheckForAnAudioFileOnCD(void)
strcpy(filepath, m_szCDRomRootPath); strcpy(filepath, m_szCDRomRootPath);
#endif // #if defined(GTA3_1_1_PATCH) #endif // #if defined(GTA3_1_1_PATCH)
strcat(filepath, StreamedNameTable[AudioManager.GetRandomTabe(1) % TOTAL_STREAMED_SOUNDS]); strcat(filepath, StreamedNameTable[AudioManager.GetRandomNumber(1) % TOTAL_STREAMED_SOUNDS]);
FILE *f = fopen(filepath, "rb"); FILE *f = fopen(filepath, "rb");

View File

@ -1166,7 +1166,7 @@ void CReplay::RestoreStuffFromMem(void)
ped->m_modelIndex = -1; ped->m_modelIndex = -1;
ped->SetModelIndex(mi); ped->SetModelIndex(mi);
ped->m_pVehicleAnim = 0; ped->m_pVehicleAnim = 0;
ped->m_audioEntityId = DMAudio.CreateEntity(0, ped); ped->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, ped);
DMAudio.SetEntityStatus(ped->m_audioEntityId, true); DMAudio.SetEntityStatus(ped->m_audioEntityId, true);
CPopulation::UpdatePedCount(ped->m_nPedType, false); CPopulation::UpdatePedCount(ped->m_nPedType, false);
if (ped->m_wepModelID >= 0) if (ped->m_wepModelID >= 0)
@ -1204,7 +1204,7 @@ void CReplay::RestoreStuffFromMem(void)
car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true); car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true);
car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true); car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true);
} }
vehicle->m_audioEntityId = DMAudio.CreateEntity(0, vehicle); vehicle->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, vehicle);
DMAudio.SetEntityStatus(vehicle->m_audioEntityId, true); DMAudio.SetEntityStatus(vehicle->m_audioEntityId, true);
CCarCtrl::UpdateCarCount(vehicle, false); CCarCtrl::UpdateCarCount(vehicle, false);
if ((mi == MI_AIRTRAIN || mi == MI_DEADDODO) && vehicle->m_rwObject){ if ((mi == MI_AIRTRAIN || mi == MI_DEADDODO) && vehicle->m_rwObject){

View File

@ -118,6 +118,15 @@ public:
CRGBA(void) { } CRGBA(void) { }
CRGBA(uint8 r, uint8 g, uint8 b, uint8 a) : r(r), g(g), b(b), a(a) { } CRGBA(uint8 r, uint8 g, uint8 b, uint8 a) : r(r), g(g), b(b), a(a) { }
CRGBA &CRGBA::operator =(const CRGBA &right)
{
this->r = right.r;
this->g = right.g;
this->b = right.b;
this->a = right.a;
return *this;
}
#ifdef RWCORE_H #ifdef RWCORE_H
operator RwRGBA &(void) { operator RwRGBA &(void) {
return rwRGBA; return rwRGBA;
@ -130,6 +139,15 @@ public:
operator RwRGBA (void) const { operator RwRGBA (void) const {
return rwRGBA; return rwRGBA;
} }
CRGBA &CRGBA::operator =(const RwRGBA &right)
{
this->r = right.red;
this->g = right.green;
this->b = right.blue;
this->a = right.alpha;
return *this;
}
#endif #endif
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,9 @@
#pragma once #pragma once
#include "Placeable.h" #include "Placeable.h"
#include "AudioManager.h"
#define MAX_PARTICLEOBJECTS 100
#define MAX_AUDIOHYDRANTS 8
enum eParticleObjectType enum eParticleObjectType
{ {
@ -26,13 +29,79 @@ enum eParticleObjectType
POBJECT_CATALINAS_SHOTGUNFLASH, POBJECT_CATALINAS_SHOTGUNFLASH,
}; };
enum eParticleObjectState
{
POBJECTSTATE_INITIALISED = 0,
POBJECTSTATE_UPDATE_CLOSE,
POBJECTSTATE_UPDATE_FAR,
POBJECTSTATE_FREE,
};
enum tParticleType;
class CParticle;
class CParticleObject : CPlaceable class CParticleObject : CPlaceable
{ {
public: public:
static void AddObject(uint16 type, const CVector &pos, uint8 remove); CParticleObject *m_pNext;
static void AddObject(uint16 type, const CVector &pos, float size, uint8 remove); CParticleObject *m_pPrev;
static void AddObject(uint16 type, const CVector &pos, const CVector &dir, float size, uint8 remove); CParticle *m_pParticle;
static void AddObject(uint16 type, const CVector &pos, const CVector &dir, float size, uint32, const RwRGBA &col, uint8 remove); uint32 m_nRemoveTimer;
static void Initialise(); eParticleObjectType m_Type;
static void UpdateAll(); tParticleType m_ParticleType;
uint8 m_nNumEffectCycles;
uint8 m_nSkipFrames;
uint16 m_nFrameCounter;
uint16 m_nState;
char _pad0[2];
CVector m_vecTarget;
float m_fRandVal;
float m_fSize;
CRGBA m_Color;
uint8 m_bRemove;
int8 m_nCreationChance;
char _pad1[2];
static CParticleObject *&pCloseListHead;
static CParticleObject *&pFarListHead;
static CParticleObject *&pUnusedListHead;
CParticleObject();
~CParticleObject();
static void Initialise(void);
static CParticleObject *AddObject(uint16 type, CVector const &pos, uint8 remove);
static CParticleObject *AddObject(uint16 type, CVector const &pos, float size, uint8 remove);
static CParticleObject *AddObject(uint16 type, CVector const &pos, CVector const &target, float size, uint8 remove);
static CParticleObject *AddObject(uint16 type, CVector const &pos, CVector const &target, float size, uint32 lifeTime, RwRGBA const &color, uint8 remove);
void RemoveObject(void);
static void UpdateAll(void);
void UpdateClose(void);
void UpdateFar(void);
static bool SaveParticle(uint8 *buffer, uint32 *length);
static bool LoadParticle(uint8 *buffer, uint32 length);
static void RemoveAllParticleObjects(void);
static void MoveToList(CParticleObject **from, CParticleObject **to, CParticleObject *obj);
}; };
extern CParticleObject (&gPObjectArray)[MAX_PARTICLEOBJECTS];
class CAudioHydrant
{
public:
int32 AudioEntity;
CParticleObject *pParticleObject;
CAudioHydrant() :
AudioEntity(AEHANDLE_NONE),
pParticleObject(NULL)
{ }
static bool Add (CParticleObject *particleobject);
static void Remove(CParticleObject *particleobject);
};

View File

@ -456,7 +456,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
if ((CGeneral::GetRandomNumber() & 3) == 0) if ((CGeneral::GetRandomNumber() & 3) == 0)
m_ped_flagD1 = true; m_ped_flagD1 = true;
m_audioEntityId = DMAudio.CreateEntity(0, this); m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, this);
DMAudio.SetEntityStatus(m_audioEntityId, 1); DMAudio.SetEntityStatus(m_audioEntityId, 1);
m_fearFlags = CPedType::GetThreats(m_nPedType); m_fearFlags = CPedType::GetThreats(m_nPedType);
m_threatEntity = nil; m_threatEntity = nil;

View File

@ -1261,7 +1261,7 @@ void CParticle::Update()
nil, nil,
particle->m_fSize, color, particle->m_nRotationStep, 0, 0, 0); particle->m_fSize, color, particle->m_nRotationStep, 0, 0, 0);
PlayOneShotScriptObject(_SOUND_BULLET_SHELL_HIT_GROUND_1, particle->m_vecPosition); PlayOneShotScriptObject(_SCRSOUND_BULLET_SHELL_HIT_GROUND_1, particle->m_vecPosition);
} }
break; break;
@ -1280,7 +1280,7 @@ void CParticle::Update()
nil, nil,
particle->m_fSize, color, 0, 0, 0, 0); particle->m_fSize, color, 0, 0, 0, 0);
PlayOneShotScriptObject(_SOUND_BULLET_SHELL_HIT_GROUND_2, particle->m_vecPosition); PlayOneShotScriptObject(_SCRSOUND_BULLET_SHELL_HIT_GROUND_2, particle->m_vecPosition);
} }
break; break;
@ -1410,13 +1410,11 @@ void CParticle::Update()
if ( particle->m_fCurrentZRadius != 0.0f ) if ( particle->m_fCurrentZRadius != 0.0f )
{ {
int32 nSinCosIndex = particle->m_nCurrentZRotation % (SIN_COS_TABLE_SIZE - 1); int32 nRot = particle->m_nCurrentZRotation % (SIN_COS_TABLE_SIZE - 1);
float fX = (m_CosTable[nSinCosIndex] - m_SinTable[nSinCosIndex]) float fX = (Cos(nRot) - Sin(nRot)) * particle->m_fCurrentZRadius;
* particle->m_fCurrentZRadius;
float fY = (m_SinTable[nSinCosIndex] + m_CosTable[nSinCosIndex]) float fY = (Sin(nRot) + Cos(nRot)) * particle->m_fCurrentZRadius;
* particle->m_fCurrentZRadius;
moveStep -= particle->m_vecParticleMovementOffset; moveStep -= particle->m_vecParticleMovementOffset;

View File

@ -60,6 +60,8 @@ public:
static float (&m_SinTable)[SIN_COS_TABLE_SIZE]; static float (&m_SinTable)[SIN_COS_TABLE_SIZE];
static float (&m_CosTable)[SIN_COS_TABLE_SIZE]; static float (&m_CosTable)[SIN_COS_TABLE_SIZE];
static float Sin(int32 value) { return m_SinTable[value]; }
static float Cos(int32 value) { return m_CosTable[value]; }
static void ReloadConfig(); static void ReloadConfig();
static void Initialise(); static void Initialise();

View File

@ -731,10 +731,10 @@ CWaterLevel::RenderWater()
float fAngle = CGeneral::GetRandomNumberInRange(90.0f, 150.0f); float fAngle = CGeneral::GetRandomNumberInRange(90.0f, 150.0f);
int32 nSinCosIdx = CGeneral::GetRandomNumber() % CParticle::SIN_COS_TABLE_SIZE-1; int32 nRot = CGeneral::GetRandomNumber() % CParticle::SIN_COS_TABLE_SIZE-1;
float fCos = CParticle::m_CosTable[nSinCosIdx]; float fCos = CParticle::Cos(nRot);
float fSin = CParticle::m_SinTable[nSinCosIdx]; float fSin = CParticle::Sin(nRot);
vecPos.x += (fCos - fSin) * fAngle; vecPos.x += (fCos - fSin) * fAngle;
vecPos.y += (fSin + fCos) * fAngle; vecPos.y += (fSin + fCos) * fAngle;

View File

@ -88,7 +88,7 @@ CVehicle::CVehicle(uint8 CreatedBy)
m_nLastWeaponDamage = -1; m_nLastWeaponDamage = -1;
field_220 = 0.0; field_220 = 0.0;
field_21C = field_220; field_21C = field_220;
m_audioEntityId = DMAudio.CreateEntity(0, this); m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, this);
if(m_audioEntityId) if(m_audioEntityId)
DMAudio.SetEntityStatus(m_audioEntityId, true); DMAudio.SetEntityStatus(m_audioEntityId, true);
m_nRadioStation = CGeneral::GetRandomNumber() % USERTRACK; m_nRadioStation = CGeneral::GetRandomNumber() % USERTRACK;