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_83;
int32 calculatedVolume;
uint8 field_88;
int8 field_88;
uint8 field_89;
uint8 field_90;
uint8 field_91;
@ -158,7 +158,8 @@ public:
uint8 gap_811;
cAudioCollision m_sQueue;
void AddCollisionToRequestedQueue(); // todo
// reversed all methods
void AddCollisionToRequestedQueue(); /// ok
};
static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error");
@ -199,6 +200,8 @@ public:
CVector Posn;
int32 AudioEntity;
void Reset(); // todo hook
static void *operator new(size_t);
static void *operator new(size_t, int);
static void operator delete(void *, size_t);
@ -232,6 +235,15 @@ enum AudioEntityHandle {
AEHANDLE_ERROR_BADAUDIOTYPE = -1,
};
struct Crime {
int32 type;
CVector position;
uint16 timer;
uint16 b;
};
static_assert(sizeof(Crime) == 20, "Crime: error ");
class cAudioManager
{
public:
@ -248,10 +260,13 @@ public:
uint8 field_13;
uint8 field_14;
uint8 field_15;
// 100
int32 m_nTimer;
tActiveSample m_sQueueSample;
uint8 m_bActiveSampleQueue;
// 224
bool m_bActiveSampleQueue;
uint8 gap_109[3];
// 264
tActiveSample m_asSamples[2][27];
uint8 m_abSampleQueueIndexTable[2][27];
uint8 m_bSampleRequestQueuesStatus[2];
@ -267,7 +282,13 @@ public:
int32 m_nFireAudioEntity;
int32 m_nWaterCannonEntity;
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_nCollisionEntity;
cAudioCollisionManager m_sCollisionManager;
@ -279,24 +300,25 @@ public:
uint8 m_bUserPause;
uint8 m_bPreviousUserPause;
uint8 field_19195; // time?
uint32 m_FrameCounter;
uint32 m_nTimeOfRecentCrime;
// getters
uint32 GetFrameCounter() const { return m_FrameCounter; }
uint32 GetFrameCounter() const { return m_nTimeOfRecentCrime; }
float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; }
int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; }
// "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,
uint8 counter, bool notLooping); /// ok
void AddReflectionsToRequestedQueue(); /// ok (check value)
void AddReleasingSounds(); // todo (difficult)
void AddReleasingSounds(); /// ok (check)
void AddSampleToRequestedQueue(); /// ok
void AgeCrimes(); // todo
void AgeCrimes(); /// ok
void CalculateDistance(bool *ptr, float dist); /// ok
bool CheckForAnAudioFileOnCD() const; /// ok
void ClearActiveSamples(); /// ok
void ClearMissionAudio(); /// ok
void ClearRequestedQueue(); /// ok
int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2,
@ -395,7 +417,7 @@ public:
uint8 GetCDAudioDriveLetter() const;
int8 GetCurrent3DProviderIndex() const; /// ok
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 GetDistanceSquared(CVector *v) const; /// ok
int32 GetJumboTaxiFreq() const; /// ok
@ -404,14 +426,17 @@ public:
uint8 GetNum3DProvidersAvailable() const;
int32 GetPedCommentSfx(CPed *ped, int32 sound);
void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const;
float GetVehicleDriveWheelSkidValue(uint8 a1, CAutomobile *a2, cTransmission *a3,
float a4); // todo
int32 GetVehicleNonDriveWheelSkidValue(float a1, int a2, int a3, int a4, float a5); // todo
float GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile,
cTransmission *transmission,
float velocityChange); /// ok
float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile,
cTransmission *transmission,
float velocityChange); /// ok
bool HasAirBrakes(int32 model) const; /// ok
void Initialise(); /// ok
void InitialisePoliceRadio(); // todo
void InitialisePoliceRadio(); /// ok
void InitialisePoliceRadioZones(); // todo
void InterrogateAudioEntities(); /// ok
bool IsAudioInitialised() const; /// ok
@ -464,7 +489,7 @@ public:
void ProcessLaunderetteScriptObject(uint8 sound); /// ok
void ProcessLoopingScriptObject(uint8 sound); /// ok
void ProcessMissionAudio(); /// ok
void ProcessModelCarEngine(cVehicleParams *params); /// ok (check float comparisons)
void ProcessModelCarEngine(cVehicleParams *params); /// ok
void ProcessOneShotScriptObject(uint8 sound); /// ok
void ProcessPed(CPhysical *ped); /// ok
void ProcessPedHeadphones(cPedParams *params); /// ok
@ -473,7 +498,7 @@ public:
void ProcessPlane(cVehicleParams *params); /// ok
void ProcessPlayersVehicleEngine(cVehicleParams *params,
CAutomobile *automobile); /// ok (check float comparisons)
void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo
void ProcessPoliceCellBeatingScriptObject(uint8 sound); /// ok
void ProcessPornCinema(uint8 sound); /// ok
void ProcessProjectiles(); // todo requires CProjectileInfo
void ProcessRainOnVehicle(cVehicleParams *params); /// ok
@ -486,49 +511,49 @@ public:
bool ProcessTrainNoise(cVehicleParams *params); /// ok
void ProcessVehicle(CVehicle *); // todo
bool ProcessVehicleDoors(cVehicleParams *params); /// ok
// bool ProcessVehicleEngine(void *);
// void ProcessVehicleHorn(cVehicleParams *params);
// void ProcessVehicleOneShots(void *);
bool ProcessVehicleEngine(void *); // todo
void ProcessVehicleHorn(cVehicleParams *params); // todo
void ProcessVehicleOneShots(void *); // todo
bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok
bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok
// void ProcessVehicleSirenOrAlarm(void *);
// void ProcessVehicleSkidding(void *);
void ProcessWaterCannon(int32); // todo
void ProcessWeather(int32 id); /// ok
bool ProcessWetRoadNoise(cVehicleParams *params); /// ok
void ProcessWorkShopScriptObject(uint8 sound); /// ok
void ProcessVehicleSirenOrAlarm(void *); // todo
void ProcessVehicleSkidding(cVehicleParams *params); /// ok
void ProcessWaterCannon(int32); // todo
void ProcessWeather(int32 id); /// ok
bool ProcessWetRoadNoise(cVehicleParams *params); /// ok
void ProcessWorkShopScriptObject(uint8 sound); /// ok
int32 RandomDisplacement(uint32 seed) const;
void ReacquireDigitalHandle() const;
void ReleaseDigitalHandle() const;
int32 ReportCollision(CEntity *a2, CEntity *a3, uint8 a4, uint8 a5, float a6,
float a7); // todo
int32 ReportCrime(eCrimeType crime, const CVector *pos); // todo
void ResetAudioLogicTimers(int32 timer); /// ok
void ResetPoliceRadio(); /// ok
void ResetTimers(uint32 a2); // todo
void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2,
float collisionPower, float intensity2); /// ok
void ReportCrime(int32 crime, const CVector *pos); /// ok
void ResetAudioLogicTimers(int32 timer); /// ok
void ResetPoliceRadio(); /// ok
void ResetTimers(uint32 time); /// ok
void Service(); // todo
void ServiceCollisions(); // todo
void ServicePoliceRadio(); // todo
void ServicePoliceRadioChannel(int a2); // todo
void ServiceSoundEffects(); // todo
int8 SetCurrent3DProvider(uint8); // todo
void Service(); // todo
void ServiceCollisions(); // todo
void ServicePoliceRadio(); /// ok
void ServicePoliceRadioChannel(int32 wantedLevel); /// ok
void ServiceSoundEffects(); /// ok
int8 SetCurrent3DProvider(uint8 which); /// ok
void SetDynamicAcousticModelingStatus(bool status);
void SetEffectsFadeVolume(uint8 volume) const;
void SetEffectsMasterVolume(uint8 volume) const;
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 SetMissionScriptPoliceAudio(int32 sfx) const;
void SetMonoMode(uint8); // todo
void SetMonoMode(uint8); // todo (mobile)
void SetMusicFadeVolume(uint8 volume) const;
void SetMusicMasterVolume(uint8 volume) 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 SetupCrimeReport(); // todo
bool SetupJumboEngineSound(uint8, int32); // todo
bool SetupCrimeReport(); // todo
bool SetupJumboEngineSound(uint8 a2, int32 a3); // todo
bool SetupJumboFlySound(uint8 emittingVol); /// ok
bool SetupJumboRumbleSound(uint8 emittingVol); /// ok
bool SetupJumboTaxiSound(uint8 vol); /// ok
@ -537,12 +562,15 @@ public:
void SetupSuspectLastSeenReport(); // todo
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 UsesSiren(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");

View File

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

View File

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

View File

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

View File

@ -286,7 +286,7 @@ public:
char *Get3DProviderName(char);
bool PlayerInCar();
void DisplayRadioStationName();
void PlayAnnouncement(unsigned char);
void PlayFrontEndTrack(unsigned char, unsigned char);
void PreloadCutSceneMusic(unsigned char);
@ -295,6 +295,8 @@ public:
int32 GetRadioInCar(void);
void SetRadioInCar(unsigned int);
void SetRadioChannelByScript(unsigned char, int);
void ResetMusicAfterReload();
};
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);
else
targetNode = forcedTargetNode;
if(targetNode < 0)
goto fail;
if(targetNode < 0) {
*pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
return;
}
// Find start
int numPathsToTry;
CTreadable *startObj;
if(startNodeId < 0){
if(startNodeId < 0) {
if(vehicle == nil || (startObj = vehicle->m_treadable[type]) == nil)
startObj = FindRoadObjectClosestToCoors(start, type);
numPathsToTry = 0;
for(i = 0; i < 12; i++){
if(startObj->m_nodeIndices[type][i] < 0)
break;
if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == m_pathNodes[targetNode].group)
for(i = 0; i < 12; i++) {
if(startObj->m_nodeIndices[type][i] < 0) break;
if(m_pathNodes[startObj->m_nodeIndices[type][i]].group ==
m_pathNodes[targetNode].group)
numPathsToTry++;
}
}else{
} else {
numPathsToTry = 1;
startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex];
}
if(numPathsToTry == 0)
goto fail;
if(startNodeId < 0){
// 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(numPathsToTry == 0) {
*pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
return;
}
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++)
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++)
apNodesToBeCleared[i]->distance = MAX_DIST;
return;
fail:
*pNumNodes = 0;
if(pDist)
*pDist = 100000.0f;
}
static CPathNode *pNodeList[32];

View File

@ -121,7 +121,7 @@ public:
CRGBA(void) { }
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->g = right.g;
@ -142,7 +142,7 @@ public:
return rwRGBA;
}
CRGBA &CRGBA::operator =(const RwRGBA &right)
CRGBA &operator =(const RwRGBA &right)
{
this->r = right.red;
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 BIT(num) (1<<(num))
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
auto max = [](auto a, auto b) { return ((a) > (b)) ? (a) : (b); };
auto min = [](auto a, auto b) { return ((a) < (b)) ? (a) : (b); };
#define ABS(a) (((a) < 0) ? (-(a)) : (a))
#define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min)))))