This commit is contained in:
Filip Gawin 2019-08-30 00:44:57 +02:00
parent e7cb489b22
commit 12ee71e4f7
8 changed files with 956 additions and 161 deletions

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,7 @@ public:
uint8 field_82; uint8 field_82;
uint8 field_83; uint8 field_83;
int32 calculatedVolume; int32 calculatedVolume;
uint8 field_88; int8 field_88;
uint8 field_89; uint8 field_89;
uint8 field_90; uint8 field_90;
uint8 field_91; uint8 field_91;
@ -158,7 +158,8 @@ public:
uint8 gap_811; uint8 gap_811;
cAudioCollision m_sQueue; cAudioCollision m_sQueue;
void AddCollisionToRequestedQueue(); // todo // reversed all methods
void AddCollisionToRequestedQueue(); /// ok
}; };
static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error"); static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error");
@ -199,6 +200,8 @@ public:
CVector Posn; CVector Posn;
int32 AudioEntity; int32 AudioEntity;
void Reset(); // todo hook
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);
static void operator delete(void *, size_t); static void operator delete(void *, size_t);
@ -232,6 +235,15 @@ enum AudioEntityHandle {
AEHANDLE_ERROR_BADAUDIOTYPE = -1, AEHANDLE_ERROR_BADAUDIOTYPE = -1,
}; };
struct Crime {
int32 type;
CVector position;
uint16 timer;
uint16 b;
};
static_assert(sizeof(Crime) == 20, "Crime: error ");
class cAudioManager class cAudioManager
{ {
public: public:
@ -248,10 +260,13 @@ public:
uint8 field_13; uint8 field_13;
uint8 field_14; uint8 field_14;
uint8 field_15; uint8 field_15;
// 100
int32 m_nTimer; int32 m_nTimer;
tActiveSample m_sQueueSample; tActiveSample m_sQueueSample;
uint8 m_bActiveSampleQueue; // 224
bool m_bActiveSampleQueue;
uint8 gap_109[3]; uint8 gap_109[3];
// 264
tActiveSample m_asSamples[2][27]; tActiveSample m_asSamples[2][27];
uint8 m_abSampleQueueIndexTable[2][27]; uint8 m_abSampleQueueIndexTable[2][27];
uint8 m_bSampleRequestQueuesStatus[2]; uint8 m_bSampleRequestQueuesStatus[2];
@ -267,7 +282,13 @@ public:
int32 m_nFireAudioEntity; int32 m_nFireAudioEntity;
int32 m_nWaterCannonEntity; int32 m_nWaterCannonEntity;
int32 m_nPoliceChannelEntity; int32 m_nPoliceChannelEntity;
uint8 gap45B8[444]; uint8 stuff[239];
uint8 unk1;
uint8 unk2;
uint8 unk3;
uint8 unk4;
uint8 unk5;
Crime crimes[10];
int32 m_nFrontEndEntity; int32 m_nFrontEndEntity;
int32 m_nCollisionEntity; int32 m_nCollisionEntity;
cAudioCollisionManager m_sCollisionManager; cAudioCollisionManager m_sCollisionManager;
@ -279,24 +300,25 @@ public:
uint8 m_bUserPause; uint8 m_bUserPause;
uint8 m_bPreviousUserPause; uint8 m_bPreviousUserPause;
uint8 field_19195; // time? uint8 field_19195; // time?
uint32 m_FrameCounter; uint32 m_nTimeOfRecentCrime;
// getters // getters
uint32 GetFrameCounter() const { return m_FrameCounter; } uint32 GetFrameCounter() const { return m_nTimeOfRecentCrime; }
float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; }
int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; } int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; }
// "Should" be in alphabetic order, except "getXTalkSfx" // "Should" be in alphabetic order, except "getXTalkSfx"
void AddDetailsToRequestedOrderList(uint8 sample); /// ok void AddDetailsToRequestedOrderList(uint8 sample); /// ok (check once more)
void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1,
uint8 counter, bool notLooping); /// ok uint8 counter, bool notLooping); /// ok
void AddReflectionsToRequestedQueue(); /// ok (check value) void AddReflectionsToRequestedQueue(); /// ok (check value)
void AddReleasingSounds(); // todo (difficult) void AddReleasingSounds(); /// ok (check)
void AddSampleToRequestedQueue(); /// ok void AddSampleToRequestedQueue(); /// ok
void AgeCrimes(); // todo void AgeCrimes(); /// ok
void CalculateDistance(bool *ptr, float dist); /// ok void CalculateDistance(bool *ptr, float dist); /// ok
bool CheckForAnAudioFileOnCD() const; /// ok bool CheckForAnAudioFileOnCD() const; /// ok
void ClearActiveSamples(); /// ok
void ClearMissionAudio(); /// ok void ClearMissionAudio(); /// ok
void ClearRequestedQueue(); /// ok void ClearRequestedQueue(); /// ok
int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2,
@ -395,7 +417,7 @@ public:
uint8 GetCDAudioDriveLetter() const; uint8 GetCDAudioDriveLetter() const;
int8 GetCurrent3DProviderIndex() const; /// ok int8 GetCurrent3DProviderIndex() const; /// ok
float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used
float GetCollisionOneShotRatio(uint32 a, float b) const; /// ok float GetCollisionOneShotRatio(int32 a, float b) const; /// ok
float GetCollisionRatio(float a, float b, float c, float d) const; /// ok float GetCollisionRatio(float a, float b, float c, float d) const; /// ok
float GetDistanceSquared(CVector *v) const; /// ok float GetDistanceSquared(CVector *v) const; /// ok
int32 GetJumboTaxiFreq() const; /// ok int32 GetJumboTaxiFreq() const; /// ok
@ -404,14 +426,17 @@ public:
uint8 GetNum3DProvidersAvailable() const; uint8 GetNum3DProvidersAvailable() const;
int32 GetPedCommentSfx(CPed *ped, int32 sound); int32 GetPedCommentSfx(CPed *ped, int32 sound);
void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const;
float GetVehicleDriveWheelSkidValue(uint8 a1, CAutomobile *a2, cTransmission *a3, float GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile,
float a4); // todo cTransmission *transmission,
int32 GetVehicleNonDriveWheelSkidValue(float a1, int a2, int a3, int a4, float a5); // todo float velocityChange); /// ok
float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile,
cTransmission *transmission,
float velocityChange); /// ok
bool HasAirBrakes(int32 model) const; /// ok bool HasAirBrakes(int32 model) const; /// ok
void Initialise(); /// ok void Initialise(); /// ok
void InitialisePoliceRadio(); // todo void InitialisePoliceRadio(); /// ok
void InitialisePoliceRadioZones(); // todo void InitialisePoliceRadioZones(); // todo
void InterrogateAudioEntities(); /// ok void InterrogateAudioEntities(); /// ok
bool IsAudioInitialised() const; /// ok bool IsAudioInitialised() const; /// ok
@ -464,7 +489,7 @@ public:
void ProcessLaunderetteScriptObject(uint8 sound); /// ok void ProcessLaunderetteScriptObject(uint8 sound); /// ok
void ProcessLoopingScriptObject(uint8 sound); /// ok void ProcessLoopingScriptObject(uint8 sound); /// ok
void ProcessMissionAudio(); /// ok void ProcessMissionAudio(); /// ok
void ProcessModelCarEngine(cVehicleParams *params); /// ok (check float comparisons) void ProcessModelCarEngine(cVehicleParams *params); /// ok
void ProcessOneShotScriptObject(uint8 sound); /// ok void ProcessOneShotScriptObject(uint8 sound); /// ok
void ProcessPed(CPhysical *ped); /// ok void ProcessPed(CPhysical *ped); /// ok
void ProcessPedHeadphones(cPedParams *params); /// ok void ProcessPedHeadphones(cPedParams *params); /// ok
@ -473,7 +498,7 @@ public:
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 (check float comparisons)
void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo void ProcessPoliceCellBeatingScriptObject(uint8 sound); /// ok
void ProcessPornCinema(uint8 sound); /// ok void ProcessPornCinema(uint8 sound); /// ok
void ProcessProjectiles(); // todo requires CProjectileInfo void ProcessProjectiles(); // todo requires CProjectileInfo
void ProcessRainOnVehicle(cVehicleParams *params); /// ok void ProcessRainOnVehicle(cVehicleParams *params); /// ok
@ -486,49 +511,49 @@ public:
bool ProcessTrainNoise(cVehicleParams *params); /// ok bool ProcessTrainNoise(cVehicleParams *params); /// ok
void ProcessVehicle(CVehicle *); // todo void ProcessVehicle(CVehicle *); // todo
bool ProcessVehicleDoors(cVehicleParams *params); /// ok bool ProcessVehicleDoors(cVehicleParams *params); /// ok
// bool ProcessVehicleEngine(void *); bool ProcessVehicleEngine(void *); // todo
// void ProcessVehicleHorn(cVehicleParams *params); void ProcessVehicleHorn(cVehicleParams *params); // todo
// void ProcessVehicleOneShots(void *); 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 *); void ProcessVehicleSirenOrAlarm(void *); // todo
// void ProcessVehicleSkidding(void *); void ProcessVehicleSkidding(cVehicleParams *params); /// ok
void ProcessWaterCannon(int32); // todo void ProcessWaterCannon(int32); // todo
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
int32 RandomDisplacement(uint32 seed) const; int32 RandomDisplacement(uint32 seed) const;
void ReacquireDigitalHandle() const; void ReacquireDigitalHandle() const;
void ReleaseDigitalHandle() const; void ReleaseDigitalHandle() const;
int32 ReportCollision(CEntity *a2, CEntity *a3, uint8 a4, uint8 a5, float a6, void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2,
float a7); // todo float collisionPower, float intensity2); /// ok
int32 ReportCrime(eCrimeType crime, const CVector *pos); // todo void ReportCrime(int32 crime, const CVector *pos); /// ok
void ResetAudioLogicTimers(int32 timer); /// ok void ResetAudioLogicTimers(int32 timer); /// ok
void ResetPoliceRadio(); /// ok void ResetPoliceRadio(); /// ok
void ResetTimers(uint32 a2); // todo void ResetTimers(uint32 time); /// ok
void Service(); // todo void Service(); // todo
void ServiceCollisions(); // todo void ServiceCollisions(); // todo
void ServicePoliceRadio(); // todo void ServicePoliceRadio(); /// ok
void ServicePoliceRadioChannel(int a2); // todo void ServicePoliceRadioChannel(int32 wantedLevel); /// ok
void ServiceSoundEffects(); // todo void ServiceSoundEffects(); /// ok
int8 SetCurrent3DProvider(uint8); // todo int8 SetCurrent3DProvider(uint8 which); /// ok
void SetDynamicAcousticModelingStatus(bool status); void SetDynamicAcousticModelingStatus(bool status);
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 SetLoopingCollisionRequestedSfxFreqAndGetVol(int32); // todo uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision); // todo hook
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 void SetMonoMode(uint8); // todo (mobile)
void SetMusicFadeVolume(uint8 volume) const; void SetMusicFadeVolume(uint8 volume) const;
void SetMusicMasterVolume(uint8 volume) const; void SetMusicMasterVolume(uint8 volume) const;
void SetSpeakerConfig(int32 conf) const; void SetSpeakerConfig(int32 conf) const;
void SetUpLoopingCollisionSound(int a2, int a3); // todo void SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter); // todo hook
void SetUpOneShotCollisionSound(int a2); // todo void SetUpOneShotCollisionSound(int a2); // todo
void SetupCrimeReport(); // todo bool SetupCrimeReport(); // todo
bool SetupJumboEngineSound(uint8, int32); // todo bool SetupJumboEngineSound(uint8 a2, int32 a3); // todo
bool SetupJumboFlySound(uint8 emittingVol); /// ok bool SetupJumboFlySound(uint8 emittingVol); /// ok
bool SetupJumboRumbleSound(uint8 emittingVol); /// ok bool SetupJumboRumbleSound(uint8 emittingVol); /// ok
bool SetupJumboTaxiSound(uint8 vol); /// ok bool SetupJumboTaxiSound(uint8 vol); /// ok
@ -537,12 +562,15 @@ public:
void SetupSuspectLastSeenReport(); // todo void SetupSuspectLastSeenReport(); // todo
void Terminate(); void Terminate();
void TranslateEntity(CVector *v1, CVector *v2) const; /// ok void TranslateEntity(CVector *v1, CVector *v2) const;
void UpdateGasPedalAudio(CAutomobile *automobile); // todo hook void UpdateGasPedalAudio(CAutomobile *automobile);
bool UsesReverseWarning(int32 model) const; bool UsesReverseWarning(int32 model) const;
bool UsesSiren(int32 model) const; bool UsesSiren(int32 model) const;
bool UsesSirenSwitching(int32 model) const; bool UsesSirenSwitching(int32 model) const;
void sub_57C2B0(); // todo (weird) and obtain name
int32 sub_57C320(uint8 a1, float a2, float a3); /// ok (get name)
}; };
static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");

View File

@ -26,7 +26,7 @@ cDMAudio::Service(void)
} }
int32 int32
cDMAudio::CreateEntity(eAudioType type, void *UID) cDMAudio::CreateEntity(int32 type, void *UID)
{ {
return AudioManager.CreateEntity(type, (CPhysical *)UID); return AudioManager.CreateEntity(type, (CPhysical *)UID);
} }

View File

@ -180,7 +180,6 @@ enum eSound : int16
class cAudioScriptObject; class cAudioScriptObject;
class CEntity; class CEntity;
enum eCrimeType; enum eCrimeType;
enum eAudioType;
class cDMAudio class cDMAudio
{ {
@ -192,7 +191,7 @@ public:
void Terminate(void); void Terminate(void);
void Service(void); void Service(void);
int32 CreateEntity(eAudioType type, void *UID); int32 CreateEntity(int32 type, void *UID);
void DestroyEntity(int32 audioEntity); void DestroyEntity(int32 audioEntity);
void SetEntityStatus(int32 audioEntity, uint8 status); void SetEntityStatus(int32 audioEntity, uint8 status);
void PlayOneShot(int32 audioEntity, uint16 oneShot, float volume); void PlayOneShot(int32 audioEntity, uint16 oneShot, float volume);

View File

@ -239,7 +239,15 @@ WRAPPER void cMusicManager::SetRadioInCar(unsigned int)
EAXJMP(0x57D2C0); EAXJMP(0x57D2C0);
} }
WRAPPER void cMusicManager::SetRadioChannelByScript(unsigned char, int) WRAPPER void
cMusicManager::SetRadioChannelByScript(unsigned char, int)
{ {
EAXJMP(0x57D180); EAXJMP(0x57D180);
}
WRAPPER
void
cMusicManager::ResetMusicAfterReload()
{
EAXJMP(0x57CF30);
} }

View File

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

View File

@ -1278,38 +1278,50 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta
targetNode = FindNodeClosestToCoors(target, type, distLimit); targetNode = FindNodeClosestToCoors(target, type, distLimit);
else else
targetNode = forcedTargetNode; targetNode = forcedTargetNode;
if(targetNode < 0) if(targetNode < 0) {
goto fail; *pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
return;
}
// Find start // Find start
int numPathsToTry; int numPathsToTry;
CTreadable *startObj; CTreadable *startObj;
if(startNodeId < 0){ if(startNodeId < 0) {
if(vehicle == nil || (startObj = vehicle->m_treadable[type]) == nil) if(vehicle == nil || (startObj = vehicle->m_treadable[type]) == nil)
startObj = FindRoadObjectClosestToCoors(start, type); startObj = FindRoadObjectClosestToCoors(start, type);
numPathsToTry = 0; numPathsToTry = 0;
for(i = 0; i < 12; i++){ for(i = 0; i < 12; i++) {
if(startObj->m_nodeIndices[type][i] < 0) if(startObj->m_nodeIndices[type][i] < 0) break;
break; if(m_pathNodes[startObj->m_nodeIndices[type][i]].group ==
if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == m_pathNodes[targetNode].group) m_pathNodes[targetNode].group)
numPathsToTry++; numPathsToTry++;
} }
}else{ } else {
numPathsToTry = 1; numPathsToTry = 1;
startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex]; startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex];
} }
if(numPathsToTry == 0) if(numPathsToTry == 0) {
goto fail; *pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
if(startNodeId < 0){ return;
// why only check node 0?
if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != m_pathNodes[targetNode].group)
goto fail;
}else{
if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group)
goto fail;
} }
if(startNodeId < 0) {
// why only check node 0?
if(m_pathNodes[startObj->m_nodeIndices[type][0]].group !=
m_pathNodes[targetNode].group) {
*pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
return;
}
} else {
if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) {
*pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
return;
}
}
for(i = 0; i < 512; i++) for(i = 0; i < 512; i++)
m_searchNodes[i].next = nil; m_searchNodes[i].next = nil;
@ -1388,11 +1400,6 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta
for(i = 0; i < numNodesToBeCleared; i++) for(i = 0; i < numNodesToBeCleared; i++)
apNodesToBeCleared[i]->distance = MAX_DIST; apNodesToBeCleared[i]->distance = MAX_DIST;
return; return;
fail:
*pNumNodes = 0;
if(pDist)
*pDist = 100000.0f;
} }
static CPathNode *pNodeList[32]; static CPathNode *pNodeList[32];

View File

@ -121,7 +121,7 @@ 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) CRGBA &operator =(const CRGBA &right)
{ {
this->r = right.r; this->r = right.r;
this->g = right.g; this->g = right.g;
@ -142,7 +142,7 @@ public:
return rwRGBA; return rwRGBA;
} }
CRGBA &CRGBA::operator =(const RwRGBA &right) CRGBA &operator =(const RwRGBA &right)
{ {
this->r = right.red; this->r = right.red;
this->g = right.green; this->g = right.green;
@ -197,8 +197,8 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
#define BIT(num) (1<<(num)) #define BIT(num) (1<<(num))
#define max(a, b) (((a) > (b)) ? (a) : (b)) auto max = [](auto a, auto b) { return ((a) > (b)) ? (a) : (b); };
#define min(a, b) (((a) < (b)) ? (a) : (b)) auto min = [](auto a, auto b) { return ((a) < (b)) ? (a) : (b); };
#define ABS(a) (((a) < 0) ? (-(a)) : (a)) #define ABS(a) (((a) < 0) ? (-(a)) : (a))
#define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min))))) #define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min)))))