1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-24 17:55:29 +00:00

Merge branch 'master' into game_dev

This commit is contained in:
Nikolay Korolev 2020-04-14 20:10:39 +03:00
commit f2c78e4bfb
21 changed files with 3359 additions and 1918 deletions

View file

@ -32,7 +32,6 @@ to reverse at the time, calling the original functions is acceptable.
### Unreversed / incomplete classes (at least the ones we know) ### Unreversed / incomplete classes (at least the ones we know)
``` ```
cAudioManager - WIP
CBulletInfo CBulletInfo
CPedPath CPedPath
CWeapon CWeapon

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");

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,14 @@
#pragma once #pragma once
#include "DMAudio.h"
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "DMAudio.h"
#include "AudioCollision.h" #include "AudioCollision.h"
#include "PoliceRadio.h" #include "PoliceRadio.h"
enum eScriptSounds : int16 enum eScriptSounds : int16 {
{
SCRIPT_SOUND_0 = 0, SCRIPT_SOUND_0 = 0,
SCRIPT_SOUND_1 = 1, SCRIPT_SOUND_1 = 1,
SCRIPT_SOUND_2 = 2, SCRIPT_SOUND_2 = 2,
@ -142,28 +143,28 @@ public:
int32 m_nSampleIndex; int32 m_nSampleIndex;
uint8 m_bBankIndex; uint8 m_bBankIndex;
bool m_bIs2D; bool m_bIs2D;
uint8 field_14; uint8 field_14; // unused
uint8 field_15; uint8 field_15; // unused
int32 m_nReleasingVolumeModificator; int32 m_nReleasingVolumeModificator;
int32 m_nFrequency; int32 m_nFrequency;
uint8 m_bVolume; uint8 m_bVolume;
uint8 field_25; uint8 field_25; // unused
uint8 field_26; uint8 field_26; // unused
uint8 field_27; uint8 field_27; // unused
float m_fDistance; float m_fDistance;
int32 m_nLoopCount; int32 m_nLoopCount;
int32 m_nLoopStart; int32 m_nLoopStart;
int32 m_nLoopEnd; int32 m_nLoopEnd;
uint8 m_bEmittingVolume; uint8 m_bEmittingVolume;
uint8 field_45; uint8 field_45; // unused
uint8 field_46; uint8 field_46; // unused
uint8 field_47; uint8 field_47; // unused
float m_fSpeedMultiplier; float m_fSpeedMultiplier;
float m_fSoundIntensity; float m_fSoundIntensity;
bool m_bReleasingSoundFlag; bool m_bReleasingSoundFlag;
uint8 field_57; uint8 field_57; // unused
uint8 field_58; uint8 field_58; // unused
uint8 field_59; uint8 field_59; // unused
CVector m_vecPos; CVector m_vecPos;
bool m_bReverbFlag; bool m_bReverbFlag;
uint8 m_bLoopsRemaining; uint8 m_bLoopsRemaining;
@ -172,13 +173,13 @@ public:
int32 m_nReleasingVolumeDivider; int32 m_nReleasingVolumeDivider;
bool m_bIsProcessed; bool m_bIsProcessed;
bool m_bLoopEnded; bool m_bLoopEnded;
uint8 field_82; uint8 field_82; // unused
uint8 field_83; uint8 field_83; // unused
int32 calculatedVolume; int32 m_nCalculatedVolume;
int8 m_nVolumeChange; int8 m_nVolumeChange;
uint8 field_89; uint8 field_89; // unused
uint8 field_90; uint8 field_90; // unused
uint8 field_91; uint8 field_91; // unused
// no methods // no methods
}; };
@ -196,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];
@ -214,8 +215,7 @@ public:
CVector m_vecPos; CVector m_vecPos;
float m_fDistance; float m_fDistance;
uint8 m_bVolume; uint8 m_bVolume;
int8 field_25; // allocated time? int8 m_nProcess;
uint8 gap_26[2];
// no methods // no methods
}; };
@ -229,11 +229,10 @@ 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];
// reversed all methods cPedComments();
void Add(tPedComment *com); /// ok void Add(tPedComment *com);
void Process(); /// ok void Process();
}; };
static_assert(sizeof(cPedComments) == 1164, "cPedComments: error"); static_assert(sizeof(cPedComments) == 1164, "cPedComments: error");
@ -245,22 +244,34 @@ class cMissionAudio
public: public:
CVector m_vecPos; CVector m_vecPos;
bool m_bPredefinedProperties; bool m_bPredefinedProperties;
uint8 gap_13[3]; //uint8 gap_13[3];
int m_nSampleIndex; int m_nSampleIndex;
uint8 m_bLoadingStatus; uint8 m_bLoadingStatus;
uint8 m_bPlayStatus; uint8 m_bPlayStatus;
uint8 field_22; uint8 field_22; // todo find a name
uint8 field_23; uint8 field_23; // unused
int32 m_nMissionAudioCounter; int32 m_nMissionAudioCounter;
bool m_bIsPlayed; bool m_bIsPlayed;
uint8 field_29; uint8 field_29; // unused
uint8 field_30; uint8 field_30; // unused
uint8 field_31; uint8 field_31; // unused
// no methods // no methods
}; };
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;
@ -314,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;
@ -334,6 +344,9 @@ public:
uint8 field_19195; // unused uint8 field_19195; // unused
uint32 m_FrameCounter; uint32 m_FrameCounter;
cAudioManager();
~cAudioManager();
// getters // getters
uint32 GetFrameCounter() const { return m_FrameCounter; } uint32 GetFrameCounter() const { return m_FrameCounter; }
float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; }
@ -341,29 +354,29 @@ public:
bool IsMissionAudioPlaying() const { return m_sMissionAudio.m_bPlayStatus == 1; } bool IsMissionAudioPlaying() const { return m_sMissionAudio.m_bPlayStatus == 1; }
// "Should" be in alphabetic order, except "getXTalkSfx" // "Should" be in alphabetic order, except "getXTalkSfx"
void AddDetailsToRequestedOrderList(uint8 sample); /// ok (check once more) void AddDetailsToRequestedOrderList(uint8 sample);
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);
void AddReflectionsToRequestedQueue(); /// ok (check value) void AddReflectionsToRequestedQueue();
void AddReleasingSounds(); /// ok (check) void AddReleasingSounds();
void AddSampleToRequestedQueue(); /// ok void AddSampleToRequestedQueue();
void AgeCrimes(); /// ok void AgeCrimes();
void CalculateDistance(bool &condition, float dist); /// ok void CalculateDistance(bool &condition, float dist);
bool CheckForAnAudioFileOnCD() const; /// ok bool CheckForAnAudioFileOnCD() const;
void ClearActiveSamples(); /// ok void ClearActiveSamples();
void ClearMissionAudio(); /// ok void ClearMissionAudio();
void ClearRequestedQueue(); /// ok void ClearRequestedQueue();
int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2,
float speedMultiplier) const; /// ok float speedMultiplier) const;
int32 ComputePan(float, CVector *); /// ok int32 ComputePan(float, CVector *);
uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const; /// ok uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const;
int32 CreateEntity(int32 type, void *entity); /// ok int32 CreateEntity(int32 type, void *entity);
void DestroyAllGameCreatedEntities(); /// ok void DestroyAllGameCreatedEntities();
void DestroyEntity(int32 id); /// ok void DestroyEntity(int32 id);
void DoJumboVolOffset() const; /// ok void DoJumboVolOffset() const;
void DoPoliceRadioCrackle(); /// ok void DoPoliceRadioCrackle();
// functions returning talk sfx, // functions returning talk sfx,
// order from GetPedCommentSfx // order from GetPedCommentSfx
@ -445,154 +458,151 @@ public:
uint32 GetGenericFemaleTalkSfx(int16 sound); uint32 GetGenericFemaleTalkSfx(int16 sound);
// end of functions returning talk sfx // end of functions returning talk sfx
void GenerateIntegerRandomNumberTable(); /// ok void GenerateIntegerRandomNumberTable();
char *Get3DProviderName(uint8 id) const; char *Get3DProviderName(uint8 id) const;
uint8 GetCDAudioDriveLetter() const; uint8 GetCDAudioDriveLetter() const;
int8 GetCurrent3DProviderIndex() const; /// ok int8 GetCurrent3DProviderIndex() const;
float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used
float GetCollisionOneShotRatio(int32 a, float b) const; /// ok float GetCollisionOneShotRatio(int32 a, float b) const;
float GetCollisionRatio(float a, float b, float c, float d) const; /// ok float GetCollisionRatio(float a, float b, float c, float d) const;
float GetDistanceSquared(CVector *v) const; /// ok float GetDistanceSquared(CVector *v) const;
int32 GetJumboTaxiFreq() const; /// ok int32 GetJumboTaxiFreq() const;
bool GetMissionAudioLoadingStatus() const; /// ok bool GetMissionAudioLoadingStatus() const;
int8 GetMissionScriptPoliceAudioPlayingStatus() const; /// ok int8 GetMissionScriptPoliceAudioPlayingStatus() const;
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 wheel, CAutomobile *automobile, float GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile,
cTransmission *transmission, cTransmission *transmission, float velocityChange);
float velocityChange); /// ok
float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile,
cTransmission *transmission, cTransmission *transmission, float velocityChange);
float velocityChange); /// ok
bool HasAirBrakes(int32 model) const; /// ok bool HasAirBrakes(int32 model) const;
void Initialise(); /// ok void Initialise();
void InitialisePoliceRadio(); /// ok void InitialisePoliceRadio();
void InitialisePoliceRadioZones(); /// ok void InitialisePoliceRadioZones();
void InterrogateAudioEntities(); /// ok void InterrogateAudioEntities();
bool IsAudioInitialised() const; /// ok bool IsAudioInitialised() const;
bool IsMissionAudioSampleFinished(); /// ok bool IsMissionAudioSampleFinished();
bool IsMP3RadioChannelAvailable() const; bool IsMP3RadioChannelAvailable() const;
bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const;
void PlayLoadedMissionAudio(); /// ok void PlayLoadedMissionAudio();
void PlayOneShot(int32 index, int16 sound, float vol); /// ok void PlayOneShot(int32 index, int16 sound, float vol);
void PlaySuspectLastSeen(float x, float y, float z); /// ok void PlaySuspectLastSeen(float x, float y, float z);
void PlayerJustGotInCar() const; /// ok void PlayerJustGotInCar() const;
void PlayerJustLeftCar() const; /// ok void PlayerJustLeftCar() const;
void PostInitialiseGameSpecificSetup(); /// ok void PostInitialiseGameSpecificSetup();
void PostTerminateGameSpecificShutdown(); /// ok void PostTerminateGameSpecificShutdown();
void PreInitialiseGameSpecificSetup() const; /// ok void PreInitialiseGameSpecificSetup() const;
void PreloadMissionAudio(const char *name); /// ok void PreloadMissionAudio(const char *name);
void PreTerminateGameSpecificShutdown(); /// ok void PreTerminateGameSpecificShutdown();
/// processX - main logic of adding new sounds /// processX - main logic of adding new sounds
void ProcessActiveQueues(); /// ok void ProcessActiveQueues();
bool ProcessAirBrakes(cVehicleParams *params); /// ok bool ProcessAirBrakes(cVehicleParams *params);
void ProcessAirportScriptObject(uint8 sound); /// ok void ProcessAirportScriptObject(uint8 sound);
bool ProcessBoatEngine(cVehicleParams *params); /// ok bool ProcessBoatEngine(cVehicleParams *params);
bool ProcessBoatMovingOverWater(cVehicleParams *params); /// ok bool ProcessBoatMovingOverWater(cVehicleParams *params);
void ProcessBridge(); /// ok void ProcessBridge();
void ProcessBridgeMotor(); /// ok void ProcessBridgeMotor();
void ProcessBridgeOneShots(); /// ok void ProcessBridgeOneShots();
void ProcessBridgeWarning(); /// ok void ProcessBridgeWarning();
bool ProcessCarBombTick(cVehicleParams *params); /// ok bool ProcessCarBombTick(cVehicleParams *params);
void ProcessCesna(cVehicleParams *params); /// ok void ProcessCesna(cVehicleParams *params);
void ProcessCinemaScriptObject(uint8 sound); /// ok void ProcessCinemaScriptObject(uint8 sound);
void ProcessCrane(); /// ok void ProcessCrane();
void ProcessDocksScriptObject(uint8 sound); /// ok void ProcessDocksScriptObject(uint8 sound);
bool ProcessEngineDamage(cVehicleParams *params); /// ok bool ProcessEngineDamage(cVehicleParams *params);
void ProcessEntity(int32 sound); /// ok void ProcessEntity(int32 sound);
void ProcessExplosions(int32 explosion); /// ok void ProcessExplosions(int32 explosion);
void ProcessFireHydrant(); /// ok void ProcessFireHydrant();
void ProcessFires(int32 entity); /// ok void ProcessFires(int32 entity);
void ProcessFrontEnd(); /// ok void ProcessFrontEnd();
void ProcessGarages(); /// ok void ProcessGarages();
bool ProcessHelicopter(cVehicleParams *params); /// ok bool ProcessHelicopter(cVehicleParams *params);
void ProcessHomeScriptObject(uint8 sound); /// ok void ProcessHomeScriptObject(uint8 sound);
void ProcessJumbo(cVehicleParams *); /// ok void ProcessJumbo(cVehicleParams *);
void ProcessJumboAccel(CPlane *plane); /// ok void ProcessJumboAccel(CPlane *plane);
void ProcessJumboDecel(CPlane *plane); /// ok void ProcessJumboDecel(CPlane *plane);
void ProcessJumboFlying(); /// ok void ProcessJumboFlying();
void ProcessJumboLanding(CPlane *plane); /// ok void ProcessJumboLanding(CPlane *plane);
void ProcessJumboTakeOff(CPlane *plane); /// ok void ProcessJumboTakeOff(CPlane *plane);
void ProcessJumboTaxi(); /// ok void ProcessJumboTaxi();
void ProcessLaunderetteScriptObject(uint8 sound); /// ok void ProcessLaunderetteScriptObject(uint8 sound);
void ProcessLoopingScriptObject(uint8 sound); /// ok void ProcessLoopingScriptObject(uint8 sound);
void ProcessMissionAudio(); /// ok void ProcessMissionAudio();
void ProcessModelCarEngine(cVehicleParams *params); /// ok void ProcessModelCarEngine(cVehicleParams *params);
void ProcessOneShotScriptObject(uint8 sound); /// ok void ProcessOneShotScriptObject(uint8 sound);
void ProcessPed(CPhysical *ped); /// ok void ProcessPed(CPhysical *ped);
void ProcessPedHeadphones(cPedParams *params); /// ok void ProcessPedHeadphones(cPedParams *params);
void ProcessPedOneShots(cPedParams *params); // todo later (weird) void ProcessPedOneShots(cPedParams *params);
void ProcessPhysical(int32 id); /// ok void ProcessPhysical(int32 id);
void ProcessPlane(cVehicleParams *params); /// ok void ProcessPlane(cVehicleParams *params);
void ProcessPlayersVehicleEngine(cVehicleParams *params, void ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile);
CAutomobile *automobile); /// ok void ProcessPoliceCellBeatingScriptObject(uint8 sound);
void ProcessPoliceCellBeatingScriptObject(uint8 sound); /// ok void ProcessPornCinema(uint8 sound);
void ProcessPornCinema(uint8 sound); /// ok void ProcessProjectiles();
void ProcessProjectiles(); /// ok void ProcessRainOnVehicle(cVehicleParams *params);
void ProcessRainOnVehicle(cVehicleParams *params); /// ok void ProcessReverb() const;
void ProcessReverb() const; /// ok bool ProcessReverseGear(cVehicleParams *params);
bool ProcessReverseGear(cVehicleParams *params); /// ok void ProcessSawMillScriptObject(uint8 sound);
void ProcessSawMillScriptObject(uint8 sound); /// ok void ProcessScriptObject(int32 id);
void ProcessScriptObject(int32 id); /// ok void ProcessShopScriptObject(uint8 sound);
void ProcessShopScriptObject(uint8 sound); /// ok void ProcessSpecial();
void ProcessSpecial(); /// ok bool ProcessTrainNoise(cVehicleParams *params);
bool ProcessTrainNoise(cVehicleParams *params); /// ok void ProcessVehicle(CVehicle *vehicle);
void ProcessVehicle(CVehicle *vehicle); /// ok bool ProcessVehicleDoors(cVehicleParams *params);
bool ProcessVehicleDoors(cVehicleParams *params); /// ok void ProcessVehicleEngine(cVehicleParams *params);
void ProcessVehicleEngine(cVehicleParams *params); /// ok void ProcessVehicleHorn(cVehicleParams *params);
void ProcessVehicleHorn(cVehicleParams *params); /// ok void ProcessVehicleOneShots(cVehicleParams *params);
void ProcessVehicleOneShots(void *); // todo bool ProcessVehicleReverseWarning(cVehicleParams *params);
bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok bool ProcessVehicleRoadNoise(cVehicleParams *params);
bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok void ProcessVehicleSirenOrAlarm(cVehicleParams *params);
void ProcessVehicleSirenOrAlarm(cVehicleParams *params); /// ok void ProcessVehicleSkidding(cVehicleParams *params);
void ProcessVehicleSkidding(cVehicleParams *params); /// ok void ProcessWaterCannon(int32);
void ProcessWaterCannon(int32); /// ok void ProcessWeather(int32 id);
void ProcessWeather(int32 id); /// ok bool ProcessWetRoadNoise(cVehicleParams *params);
bool ProcessWetRoadNoise(cVehicleParams *params); /// ok void ProcessWorkShopScriptObject(uint8 sound);
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;
void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower, void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2,
float intensity2); /// ok float collisionPower, float intensity2);
void ReportCrime(int32 crime, const CVector *pos); /// ok void ReportCrime(int32 crime, const CVector *pos);
void ResetAudioLogicTimers(uint32 timer); /// ok void ResetAudioLogicTimers(uint32 timer);
void ResetPoliceRadio(); /// ok void ResetPoliceRadio();
void ResetTimers(uint32 time); /// ok void ResetTimers(uint32 time);
void Service(); /// ok void Service();
void ServiceCollisions(); /// ok void ServiceCollisions();
void ServicePoliceRadio(); /// ok void ServicePoliceRadio();
void ServicePoliceRadioChannel(int32 wantedLevel); /// ok void ServicePoliceRadioChannel(int32 wantedLevel);
void ServiceSoundEffects(); /// ok void ServiceSoundEffects();
int8 SetCurrent3DProvider(uint8 which); /// ok int8 SetCurrent3DProvider(uint8 which);
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, uint8 status); void SetEntityStatus(int32 id, uint8 status);
uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision); /// ok uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision);
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)
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(cAudioCollision *col, uint8 counter); /// ok void SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter);
void SetUpOneShotCollisionSound(cAudioCollision *col); /// ok void SetUpOneShotCollisionSound(cAudioCollision *col);
bool SetupCrimeReport(); /// ok bool SetupCrimeReport();
bool SetupJumboEngineSound(uint8 vol, int32 freq); /// ok bool SetupJumboEngineSound(uint8 vol, int32 freq);
bool SetupJumboFlySound(uint8 emittingVol); /// ok bool SetupJumboFlySound(uint8 emittingVol);
bool SetupJumboRumbleSound(uint8 emittingVol); /// ok bool SetupJumboRumbleSound(uint8 emittingVol);
bool SetupJumboTaxiSound(uint8 vol); /// ok bool SetupJumboTaxiSound(uint8 vol);
bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok bool SetupJumboWhineSound(uint8 emittingVol, int32 freq);
void SetupPedComments(cPedParams *params, uint32 sound); /// ok void SetupPedComments(cPedParams *params, uint32 sound);
void SetupSuspectLastSeenReport(); /// ok void SetupSuspectLastSeenReport();
void Terminate(); void Terminate();
void TranslateEntity(CVector *v1, CVector *v2) const; void TranslateEntity(CVector *v1, CVector *v2) const;
@ -604,11 +614,10 @@ public:
bool UsesSirenSwitching(int32 model) const; bool UsesSirenSwitching(int32 model) const;
// only used in pc // only used in pc
void AdjustSamplesVolume(); /// ok void AdjustSamplesVolume();
uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist);
float dist); /// ok
}; };
static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");
extern cAudioManager &AudioManager; extern cAudioManager AudioManager;

View file

@ -82,34 +82,34 @@ int curBottomBarOption = -1;
int hoveredBottomBarOption = -1; int hoveredBottomBarOption = -1;
#endif #endif
int32 &CMenuManager::OS_Language = *(int32*)0x5F2F78; // 9 int32 CMenuManager::OS_Language = LANG_ENGLISH; // *(int32*)0x5F2F78;
int8 &CMenuManager::m_PrefsUseVibration = *(int8*)0x95CD92; int8 CMenuManager::m_PrefsUseVibration; // = *(int8*)0x95CD92;
int8 &CMenuManager::m_DisplayControllerOnFoot = *(int8*)0x95CD8D; int8 CMenuManager::m_DisplayControllerOnFoot; // = *(int8*)0x95CD8D;
int8 &CMenuManager::m_PrefsVsync = *(int8*)0x5F2E58; // 1 int8 CMenuManager::m_PrefsVsync = 1; // *(int8*)0x5F2E58;
int8 &CMenuManager::m_PrefsVsyncDisp = *(int8*)0x5F2E5C; // 1 int8 CMenuManager::m_PrefsVsyncDisp = 1; // *(int8*)0x5F2E5C;
int8 &CMenuManager::m_PrefsFrameLimiter = *(int8*)0x5F2E60; // 1 int8 CMenuManager::m_PrefsFrameLimiter = 1; // *(int8*)0x5F2E60;
int8 &CMenuManager::m_PrefsShowSubtitles = *(int8*)0x5F2E54; // 1 int8 CMenuManager::m_PrefsShowSubtitles = 1; // *(int8*)0x5F2E54;
int8 &CMenuManager::m_PrefsSpeakers = *(int8*)0x95CD7E; int8 CMenuManager::m_PrefsSpeakers; // = *(int8*)0x95CD7E;
int32 &CMenuManager::m_ControlMethod = *(int32*)0x8F5F7C; int32 CMenuManager::m_ControlMethod; // = *(int32*)0x8F5F7C;
int8 &CMenuManager::m_PrefsDMA = *(int8*)0x5F2F74; // 1 int8 CMenuManager::m_PrefsDMA = 1; // *(int8*)0x5F2F74;
int32 &CMenuManager::m_PrefsLanguage = *(int32*)0x941238; int32 CMenuManager::m_PrefsLanguage; // = *(int32*)0x941238;
uint8 CMenuManager::m_PrefsStereoMono; // *(bool*)0x95CDB5; // unused except restore settings uint8 CMenuManager::m_PrefsStereoMono; // *(bool*)0x95CDB5; // unused except restore settings
bool &CMenuManager::m_PrefsAllowNastyGame = *(bool*)0x5F2E64; // true bool CMenuManager::m_PrefsAllowNastyGame = true; // *(bool*)0x5F2E64;
bool &CMenuManager::m_bStartUpFrontEndRequested = *(bool*)0x95CCF4; bool CMenuManager::m_bStartUpFrontEndRequested; // = *(bool*)0x95CCF4;
bool &CMenuManager::m_bShutDownFrontEndRequested = *(bool*)0x95CD6A; bool CMenuManager::m_bShutDownFrontEndRequested; // = *(bool*)0x95CD6A;
int8 &CMenuManager::m_PrefsUseWideScreen = *(int8*)0x95CD23; int8 CMenuManager::m_PrefsUseWideScreen; // = *(int8*)0x95CD23;
int8 &CMenuManager::m_PrefsRadioStation = *(int8*)0x95CDA4; int8 CMenuManager::m_PrefsRadioStation; // = *(int8*)0x95CDA4;
int32 &CMenuManager::m_PrefsBrightness = *(int32*)0x5F2E50; // 256 int32 CMenuManager::m_PrefsBrightness = 256; // = *(int32*)0x5F2E50;
float &CMenuManager::m_PrefsLOD = *(float*)0x8F42C4; float CMenuManager::m_PrefsLOD; // = *(float*)0x8F42C4;
int8 &CMenuManager::m_bFrontEnd_ReloadObrTxtGxt = *(int8*)0x628CFC; int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt; // = *(int8*)0x628CFC;
int32 &CMenuManager::m_PrefsMusicVolume = *(int32*)0x5F2E4C; // 102 int32 CMenuManager::m_PrefsMusicVolume = 102; // = *(int32*)0x5F2E4C;
int32 &CMenuManager::m_PrefsSfxVolume = *(int32*)0x5F2E48; // 102 int32 CMenuManager::m_PrefsSfxVolume = 102; // = *(int32*)0x5F2E48;
char *CMenuManager::m_PrefsSkinFile = (char*)0x5F2E74; //[256] "$$\"\"" char CMenuManager::m_PrefsSkinFile[256] = "$$\"\""; // = (char*)0x5F2E74;
int32 &CMenuManager::m_KeyPressedCode = *(int32*)0x5F2E70; // -1 int32 CMenuManager::m_KeyPressedCode = -1; // = *(int32*)0x5F2E70;
// Originally that was PS2 option color, they forget it here and used in PrintBriefs once(but didn't use the output anyway) // Originally that was PS2 option color, they forget it here and used in PrintBriefs once(but didn't use the output anyway)
#ifdef PS2_LIKE_MENU #ifdef PS2_LIKE_MENU
@ -1655,7 +1655,6 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
} }
} }
// TODO: Complete aScreens and test that
void void
CMenuManager::DrawControllerScreenExtraText(int yStart, int xStart, int lineHeight) CMenuManager::DrawControllerScreenExtraText(int yStart, int xStart, int lineHeight)
{ {
@ -2463,7 +2462,7 @@ CMenuManager::DrawPlayerSetupScreen()
m_pSelectedSkin->skinNameDisplayed[oldLength - 4] = '\0'; m_pSelectedSkin->skinNameDisplayed[oldLength - 4] = '\0';
m_pSelectedSkin->skinNameOriginal[oldLength - 4] = '\0'; m_pSelectedSkin->skinNameOriginal[oldLength - 4] = '\0';
// Truncate to 40 bytes-39 chars, idk why. This is done in sepearate function in game. // Fill to 40 bytes-39 chars, idk why. This is done in sepearate function in game.
strncpy(nameTemp, m_pSelectedSkin->skinNameDisplayed, 39); // game doesn't do that, but in our day strncpy to same string is forbidden strncpy(nameTemp, m_pSelectedSkin->skinNameDisplayed, 39); // game doesn't do that, but in our day strncpy to same string is forbidden
strncpy(m_pSelectedSkin->skinNameDisplayed, nameTemp, 39); strncpy(m_pSelectedSkin->skinNameDisplayed, nameTemp, 39);
if (oldLength - 4 > 39) if (oldLength - 4 > 39)
@ -4875,7 +4874,7 @@ float CMenuManager::StretchY(float y)
void void
CMenuManager::SwitchMenuOnAndOff() CMenuManager::SwitchMenuOnAndOff()
{ {
bool menuWasActive = !!m_bMenuActive; bool menuWasActive = GetIsMenuActive();
// Reminder: You need REGISTER_START_BUTTON defined to make it work. // Reminder: You need REGISTER_START_BUTTON defined to make it work.
if (CPad::GetPad(0)->GetStartJustDown() if (CPad::GetPad(0)->GetStartJustDown()

View file

@ -530,30 +530,30 @@ public:
bool GetIsMenuActive() {return !!m_bMenuActive;} bool GetIsMenuActive() {return !!m_bMenuActive;}
public: public:
static int32 &OS_Language; static int32 OS_Language;
static int8 &m_PrefsUseVibration; static int8 m_PrefsUseVibration;
static int8 &m_DisplayControllerOnFoot; static int8 m_DisplayControllerOnFoot;
static int8 &m_PrefsUseWideScreen; static int8 m_PrefsUseWideScreen;
static int8 &m_PrefsRadioStation; static int8 m_PrefsRadioStation;
static int8 &m_PrefsVsync; static int8 m_PrefsVsync;
static int8 &m_PrefsVsyncDisp; static int8 m_PrefsVsyncDisp;
static int8 &m_PrefsFrameLimiter; static int8 m_PrefsFrameLimiter;
static int8 &m_PrefsShowSubtitles; static int8 m_PrefsShowSubtitles;
static int8 &m_PrefsSpeakers; static int8 m_PrefsSpeakers;
static int32 &m_ControlMethod; static int32 m_ControlMethod;
static int8 &m_PrefsDMA; static int8 m_PrefsDMA;
static int32 &m_PrefsLanguage; static int32 m_PrefsLanguage;
static int32 &m_PrefsBrightness; static int32 m_PrefsBrightness;
static float &m_PrefsLOD; static float m_PrefsLOD;
static int8 &m_bFrontEnd_ReloadObrTxtGxt; static int8 m_bFrontEnd_ReloadObrTxtGxt;
static int32 &m_PrefsMusicVolume; static int32 m_PrefsMusicVolume;
static int32 &m_PrefsSfxVolume; static int32 m_PrefsSfxVolume;
static char *m_PrefsSkinFile; static char m_PrefsSkinFile[256];
static int32 &m_KeyPressedCode; static int32 m_KeyPressedCode;
static bool &m_bStartUpFrontEndRequested; static bool m_bStartUpFrontEndRequested;
static bool &m_bShutDownFrontEndRequested; static bool m_bShutDownFrontEndRequested;
static bool &m_PrefsAllowNastyGame; static bool m_PrefsAllowNastyGame;
static uint8 m_PrefsStereoMono; static uint8 m_PrefsStereoMono;
static int32 m_SelectedMap; static int32 m_SelectedMap;

71
src/core/Profile.cpp Normal file
View file

@ -0,0 +1,71 @@
#include "common.h"
#include "Profile.h"
#ifndef MASTER
float CProfile::ms_afStartTime[NUM_PROFILES];
float CProfile::ms_afCumulativeTime[NUM_PROFILES];
float CProfile::ms_afEndTime[NUM_PROFILES];
float CProfile::ms_afMaxEndTime[NUM_PROFILES];
float CProfile::ms_afMaxCumulativeTime[NUM_PROFILES];
char *CProfile::ms_pProfileString[NUM_PROFILES];
RwRGBA CProfile::ms_aBarColours[NUM_PROFILES];
void CProfile::Initialise()
{
ms_afMaxEndTime[PROFILE_FRAME_RATE] = 0.0f;
ms_afMaxEndTime[PROFILE_PHYSICS] = 0.0f;
ms_afMaxEndTime[PROFILE_COLLISION] = 0.0f;
ms_afMaxEndTime[PROFILE_PED_AI] = 0.0f;
ms_afMaxEndTime[PROFILE_PROCESSING_TIME] = 0.0f;
ms_afMaxEndTime[PROFILE_RENDERING_TIME] = 0.0f;
ms_afMaxEndTime[PROFILE_TOTAL] = 0.0f;
ms_pProfileString[PROFILE_FRAME_RATE] = "Frame rate";
ms_pProfileString[PROFILE_PHYSICS] = "Physics";
ms_pProfileString[PROFILE_COLLISION] = "Collision";
ms_pProfileString[PROFILE_PED_AI] = "Ped AI";
ms_pProfileString[PROFILE_PROCESSING_TIME] = "Processing time";
ms_pProfileString[PROFILE_RENDERING_TIME] = "Rendering time";
ms_pProfileString[PROFILE_TOTAL] = "Total";
ms_afMaxCumulativeTime[PROFILE_FRAME_RATE] = 0.0f;
ms_afMaxCumulativeTime[PROFILE_PHYSICS] = 0.0f;
ms_afMaxCumulativeTime[PROFILE_COLLISION] = 0.0f;
ms_afMaxCumulativeTime[PROFILE_PED_AI] = 0.0f;
ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME] = 0.0f;
ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME] = 0.0f;
ms_afMaxCumulativeTime[PROFILE_TOTAL] = 0.0f;
ms_aBarColours[PROFILE_PHYSICS] = { 0, 127, 255, 255 };
ms_aBarColours[PROFILE_COLLISION] = { 0, 255, 255, 255 };
ms_aBarColours[PROFILE_PED_AI] = { 255, 0, 0, 255 };
ms_aBarColours[PROFILE_PROCESSING_TIME] = { 0, 255, 0, 255 };
ms_aBarColours[PROFILE_RENDERING_TIME] = { 0, 0, 255, 255 };
ms_aBarColours[PROFILE_TOTAL] = { 255, 255, 255, 255 };
}
void CProfile::SuspendProfile(eProfile profile)
{
ms_afEndTime[profile] = -ms_afStartTime[profile];
ms_afCumulativeTime[profile] -= ms_afStartTime[profile];
}
void CProfile::ShowResults()
{
ms_afMaxEndTime[PROFILE_FRAME_RATE] = max(ms_afMaxEndTime[PROFILE_FRAME_RATE], ms_afEndTime[PROFILE_FRAME_RATE]);
ms_afMaxEndTime[PROFILE_PHYSICS] = max(ms_afMaxEndTime[PROFILE_PHYSICS], ms_afEndTime[PROFILE_PHYSICS]);
ms_afMaxEndTime[PROFILE_COLLISION] = max(ms_afMaxEndTime[PROFILE_COLLISION], ms_afEndTime[PROFILE_COLLISION]);
ms_afMaxEndTime[PROFILE_PED_AI] = max(ms_afMaxEndTime[PROFILE_PED_AI], ms_afEndTime[PROFILE_PED_AI]);
ms_afMaxEndTime[PROFILE_PROCESSING_TIME] = max(ms_afMaxEndTime[PROFILE_PROCESSING_TIME], ms_afEndTime[PROFILE_PROCESSING_TIME]);
ms_afMaxEndTime[PROFILE_RENDERING_TIME] = max(ms_afMaxEndTime[PROFILE_RENDERING_TIME], ms_afEndTime[PROFILE_RENDERING_TIME]);
ms_afMaxEndTime[PROFILE_TOTAL] = max(ms_afMaxEndTime[PROFILE_TOTAL], ms_afEndTime[PROFILE_TOTAL]);
ms_afMaxCumulativeTime[PROFILE_FRAME_RATE] = max(ms_afMaxCumulativeTime[PROFILE_FRAME_RATE], ms_afCumulativeTime[PROFILE_FRAME_RATE]);
ms_afMaxCumulativeTime[PROFILE_PHYSICS] = max(ms_afMaxCumulativeTime[PROFILE_PHYSICS], ms_afCumulativeTime[PROFILE_PHYSICS]);
ms_afMaxCumulativeTime[PROFILE_COLLISION] = max(ms_afMaxCumulativeTime[PROFILE_COLLISION], ms_afCumulativeTime[PROFILE_COLLISION]);
ms_afMaxCumulativeTime[PROFILE_PED_AI] = max(ms_afMaxCumulativeTime[PROFILE_PED_AI], ms_afCumulativeTime[PROFILE_PED_AI]);
ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME] = max(ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME], ms_afCumulativeTime[PROFILE_PROCESSING_TIME]);
ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME] = max(ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME], ms_afCumulativeTime[PROFILE_RENDERING_TIME]);
ms_afMaxCumulativeTime[PROFILE_TOTAL] = max(ms_afMaxCumulativeTime[PROFILE_TOTAL], ms_afCumulativeTime[PROFILE_TOTAL]);
}
#endif

28
src/core/Profile.h Normal file
View file

@ -0,0 +1,28 @@
#pragma once
enum eProfile
{
PROFILE_FRAME_RATE,
PROFILE_PHYSICS,
PROFILE_COLLISION,
PROFILE_PED_AI,
PROFILE_PROCESSING_TIME,
PROFILE_RENDERING_TIME,
PROFILE_TOTAL,
NUM_PROFILES,
};
class CProfile
{
static float ms_afStartTime[NUM_PROFILES];
static float ms_afCumulativeTime[NUM_PROFILES];
static float ms_afEndTime[NUM_PROFILES];
static float ms_afMaxEndTime[NUM_PROFILES];
static float ms_afMaxCumulativeTime[NUM_PROFILES];
static char *ms_pProfileString[NUM_PROFILES];
static RwRGBA ms_aBarColours[NUM_PROFILES];
public:
static void Initialise();
static void SuspendProfile(eProfile profile);
static void ShowResults();
};

View file

@ -4,7 +4,6 @@
#include "Gangs.h" #include "Gangs.h"
#include "Weapon.h" #include "Weapon.h"
//CGangInfo(&CGangs::Gang)[NUM_GANGS] = *(CGangInfo(*)[NUM_GANGS])*(uintptr*)0x6EDF78;
CGangInfo CGangs::Gang[NUM_GANGS]; CGangInfo CGangs::Gang[NUM_GANGS];
CGangInfo::CGangInfo() : CGangInfo::CGangInfo() :
@ -70,7 +69,6 @@ void CGangs::LoadAllGangData(uint8 *buf, uint32 size)
Initialise(); Initialise();
INITSAVEBUF INITSAVEBUF
// original: SkipSaveBuf(buf, SAVE_HEADER_SIZE);
CheckSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE); CheckSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE);
for (int i = 0; i < NUM_GANGS; i++) for (int i = 0; i < NUM_GANGS; i++)

View file

@ -29,39 +29,54 @@
#define PED_REMOVE_DIST (MIN_CREATION_DIST + CREATION_RANGE + 1.0f) #define PED_REMOVE_DIST (MIN_CREATION_DIST + CREATION_RANGE + 1.0f)
#define PED_REMOVE_DIST_SPECIAL (MIN_CREATION_DIST + CREATION_RANGE + 15.0f) // for peds with bCullExtraFarAway flag #define PED_REMOVE_DIST_SPECIAL (MIN_CREATION_DIST + CREATION_RANGE + 15.0f) // for peds with bCullExtraFarAway flag
// TO-DO: These are hard-coded, reverse them. // Transition areas between zones
// More clearly they're transition areas between zones. const RegenerationPoint aSafeZones[] = {
RegenerationPoint (&aSafeZones)[8] = *(RegenerationPoint(*)[8]) * (uintptr*)0x5FA578; { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 400.0f, 814.0f, -954.0f, -903.0f, 30.0f, 100.0f,
CVector(790.0f, -917.0f, 39.0f), CVector(775.0f, -921.0f, 39.0f), CVector(424.0f, -942.0f, 38.0f), CVector(439.0f, -938.0f, 38.0f) },
{ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 555.0f, 711.0f, 118.0f, 186.0f, -30.0f, -10.0f,
CVector(698.0f, 182.0f, -20.0f), CVector(681.0f, 178.0f, -20.0f), CVector(586.0f, 144.0f, -20.0f), CVector(577.0f, 135.0f, -20.0f) },
{ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 26.0f, 44.0f, 124.0f, 87.0f, 20.0f, 6.0f,
CVector(736.0f, -117.0f, -13.0f), CVector(730.0f, -115.0f, -13.0f), CVector(635.0f, -93.0f, -12.5f), CVector(650.0f, -89.0f, -12.5f) },
{ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 45.0f, 34.0f, 780.0f, 750.0f, 25.0f, 6.0f,
CVector(729.0f, -764.0f, -18.0f), CVector(720.0f, -769.0f, -17.0f), CVector(652.0f, -774.0f, -10.5f), CVector(659.0f, -770.0f, -10.5f) },
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 532.0f, 136.0f, 668.0f, 599.0f, 4.0f, 0.0f,
CVector(-172.0f, -619.0f, 44.0f), CVector(-183.0f, -623.0f, 44.0f), CVector(-511.0f, -645.0f, 41.0f), CVector(-493.0f, -639.0f, 41.5f) },
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 325.0f, 175.0f, 7.0f, 5.0f, 30.0f, 10.0f,
CVector(-185.0f, 40.8f, -20.5f), CVector(-202.0f, 37.0f, -20.5f), CVector(-315.0f, 65.5f, -20.5f), CVector(-306.0f, 62.4f, -20.5f) },
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 410.0f, 310.0f, 1055.0f, 1030.0f, 20.0f, 6.0f,
CVector(-321.0f, -1043.0f, -13.2f), CVector(-328.0f, -1045.0f, -13.2f), CVector(-398.0f, -1044.0f, -13.5f), CVector(-390.0f, -1040.5f, -13.5f) },
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 425.0f, 280.0f, 471.0f, 447.0f, 20.0f, 5.0f,
CVector(-292.0f, -457.0f, -11.6f), CVector(-310.0f, -461.0f, -11.6f), CVector(-413.0f, -461.0f, -11.5f), CVector(-399.0f, -457.0f, -11.3f) }
}; // *(RegenerationPoint(*)[8]) * (uintptr*)0x5FA578;
//PedGroup (&CPopulation::ms_pPedGroups)[NUMPEDGROUPS] = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248; PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS]; // = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248;
PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS]; bool CPopulation::ms_bGivePedsWeapons; // = *(bool*)0x95CCF6;
bool &CPopulation::ms_bGivePedsWeapons = *(bool*)0x95CCF6; int32 CPopulation::m_AllRandomPedsThisType = -1; // = *(int32*)0x5FA570;
int32 &CPopulation::m_AllRandomPedsThisType = *(int32*)0x5FA570; float CPopulation::PedDensityMultiplier = 1.0f; // = *(float*)0x5FA56C;
float &CPopulation::PedDensityMultiplier = *(float*)0x5FA56C; uint32 CPopulation::ms_nTotalMissionPeds; // = *(uint32*)0x8F5F70;
uint32 &CPopulation::ms_nTotalMissionPeds = *(uint32*)0x8F5F70; int32 CPopulation::MaxNumberOfPedsInUse = 25; // *(int32*)0x5FA574;
int32 &CPopulation::MaxNumberOfPedsInUse = *(int32*)0x5FA574; uint32 CPopulation::ms_nNumCivMale; // = *(uint32*)0x8F2548;
uint32& CPopulation::ms_nNumCivMale = *(uint32*)0x8F2548; uint32 CPopulation::ms_nNumCivFemale; // = *(uint32*)0x8F5F44;
uint32& CPopulation::ms_nNumCivFemale = *(uint32*)0x8F5F44; uint32 CPopulation::ms_nNumCop; // = *(uint32*)0x885AFC;
uint32& CPopulation::ms_nNumCop = *(uint32*)0x885AFC; bool CPopulation::bZoneChangeHasHappened; // = *(bool*)0x95CD79;
bool& CPopulation::bZoneChangeHasHappened = *(bool*)0x95CD79; uint32 CPopulation::ms_nNumEmergency; // = *(uint32*)0x94071C;
uint32& CPopulation::ms_nNumEmergency = *(uint32*)0x94071C; int8 CPopulation::m_CountDownToPedsAtStart; // = *(int8*)0x95CD4F;
int8& CPopulation::m_CountDownToPedsAtStart = *(int8*)0x95CD4F; uint32 CPopulation::ms_nNumGang1; // = *(uint32*)0x8F1B1C;
uint32& CPopulation::ms_nNumGang1 = *(uint32*)0x8F1B1C; uint32 CPopulation::ms_nNumGang2; // = *(uint32*)0x8F1B14;
uint32& CPopulation::ms_nNumGang2 = *(uint32*)0x8F1B14; uint32 CPopulation::ms_nTotalPeds; // = *(uint32*)0x95CB50;
uint32& CPopulation::ms_nTotalPeds = *(uint32*)0x95CB50; uint32 CPopulation::ms_nNumGang3; // = *(uint32*)0x8F2548;
uint32& CPopulation::ms_nNumGang3 = *(uint32*)0x8F2548; uint32 CPopulation::ms_nTotalGangPeds; // = *(uint32*)0x885AF0;
uint32& CPopulation::ms_nTotalGangPeds = *(uint32*)0x885AF0; uint32 CPopulation::ms_nNumGang4; // = *(uint32*)0x8F1B2C;
uint32& CPopulation::ms_nNumGang4 = *(uint32*)0x8F1B2C; uint32 CPopulation::ms_nTotalCivPeds; // = *(uint32*)0x8F2C3C;
uint32& CPopulation::ms_nTotalCivPeds = *(uint32*)0x8F2C3C; uint32 CPopulation::ms_nNumGang5; // = *(uint32*)0x8F1B30;
uint32& CPopulation::ms_nNumGang5 = *(uint32*)0x8F1B30; uint32 CPopulation::ms_nNumDummy; // = *(uint32*)0x8F1A98;
uint32& CPopulation::ms_nNumDummy = *(uint32*)0x8F1A98; uint32 CPopulation::ms_nNumGang6; // = *(uint32*)0x8F1B20;
uint32& CPopulation::ms_nNumGang6 = *(uint32*)0x8F1B20; uint32 CPopulation::ms_nNumGang9; // = *(uint32*)0x8F1B10;
uint32& CPopulation::ms_nNumGang9 = *(uint32*)0x8F1B10; uint32 CPopulation::ms_nNumGang7; // = *(uint32*)0x8F1B28;
uint32& CPopulation::ms_nNumGang7 = *(uint32*)0x8F1B28; uint32 CPopulation::ms_nNumGang8; // = *(uint32*)0x8F1B0C;
uint32& CPopulation::ms_nNumGang8 = *(uint32*)0x8F1B0C; CVector CPopulation::RegenerationPoint_a; // = *(CVector*)0x8E2AA4;
CVector &CPopulation::RegenerationPoint_a = *(CVector*)0x8E2AA4; CVector CPopulation::RegenerationPoint_b; // = *(CVector*)0x8E2A98;
CVector &CPopulation::RegenerationPoint_b = *(CVector*)0x8E2A98; CVector CPopulation::RegenerationForward; // = *(CVector*)0x8F1AD4;
CVector &CPopulation::RegenerationForward = *(CVector*)0x8F1AD4;
void void
CPopulation::Initialise() CPopulation::Initialise()

View file

@ -34,33 +34,33 @@ class CPopulation
{ {
public: public:
static PedGroup ms_pPedGroups[NUMPEDGROUPS]; static PedGroup ms_pPedGroups[NUMPEDGROUPS];
static bool &ms_bGivePedsWeapons; static bool ms_bGivePedsWeapons;
static int32 &m_AllRandomPedsThisType; static int32 m_AllRandomPedsThisType;
static float &PedDensityMultiplier; static float PedDensityMultiplier;
static uint32 &ms_nTotalMissionPeds; static uint32 ms_nTotalMissionPeds;
static int32 &MaxNumberOfPedsInUse; static int32 MaxNumberOfPedsInUse;
static uint32& ms_nNumCivMale; static uint32 ms_nNumCivMale;
static uint32 &ms_nNumCivFemale; static uint32 ms_nNumCivFemale;
static uint32 &ms_nNumCop; static uint32 ms_nNumCop;
static bool &bZoneChangeHasHappened; static bool bZoneChangeHasHappened;
static uint32 &ms_nNumEmergency; static uint32 ms_nNumEmergency;
static int8& m_CountDownToPedsAtStart; static int8 m_CountDownToPedsAtStart;
static uint32& ms_nNumGang1; static uint32 ms_nNumGang1;
static uint32& ms_nNumGang2; static uint32 ms_nNumGang2;
static uint32& ms_nTotalPeds; static uint32 ms_nTotalPeds;
static uint32& ms_nNumGang3; static uint32 ms_nNumGang3;
static uint32& ms_nTotalGangPeds; static uint32 ms_nTotalGangPeds;
static uint32& ms_nNumGang4; static uint32 ms_nNumGang4;
static uint32& ms_nTotalCivPeds; static uint32 ms_nTotalCivPeds;
static uint32& ms_nNumGang5; static uint32 ms_nNumGang5;
static uint32& ms_nNumDummy; static uint32 ms_nNumDummy;
static uint32& ms_nNumGang6; static uint32 ms_nNumGang6;
static uint32& ms_nNumGang9; static uint32 ms_nNumGang9;
static uint32& ms_nNumGang7; static uint32 ms_nNumGang7;
static uint32& ms_nNumGang8; static uint32 ms_nNumGang8;
static CVector& RegenerationPoint_a; static CVector RegenerationPoint_a;
static CVector& RegenerationPoint_b; static CVector RegenerationPoint_b;
static CVector& RegenerationForward; static CVector RegenerationForward;
static void Initialise(); static void Initialise();
static void Update(void); static void Update(void);

View file

@ -3,6 +3,44 @@
#include "patcher.h" #include "patcher.h"
#include "Timecycle.h" #include "Timecycle.h"
#include "skeleton.h" #include "skeleton.h"
#if defined(RWLIBS) && !defined(FINAL)
#include "rtcharse.h"
#pragma comment( lib, "rtcharse.lib" )
RtCharset *debugCharset;
#endif
void CreateDebugFont()
{
#if defined(RWLIBS) && !defined(FINAL)
RwRGBA color = { 255, 255, 128, 255 };
RwRGBA colorbg = { 0, 0, 0, 0 };
RtCharsetOpen();
debugCharset = RtCharsetCreate(&color, &colorbg);
#endif
}
void DestroyDebugFont()
{
#if defined(RWLIBS) && !defined(FINAL)
RtCharsetDestroy(debugCharset);
RtCharsetClose();
#endif
}
void ObrsPrintfString(const char *str, short x, short y)
{
#if defined(RWLIBS) && !defined(FINAL)
RtCharsetPrintBuffered(debugCharset, str, x, y, true);
#endif
}
void FlushObrsPrintfs()
{
#if defined(RWLIBS) && !defined(FINAL)
RtCharsetBufferFlush();
#endif
}
void * void *
RwMallocAlign(RwUInt32 size, RwUInt32 align) RwMallocAlign(RwUInt32 size, RwUInt32 align)
@ -347,21 +385,6 @@ CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer)
return (nil); return (nil);
} }
void CreateDebugFont()
{
;
}
void DestroyDebugFont()
{
;
}
void FlushObrsPrintfs()
{
;
}
WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); } WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); }
WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); } WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); }

View file

@ -5,6 +5,7 @@ void RwFreeAlign(void *mem);
void CreateDebugFont(); void CreateDebugFont();
void DestroyDebugFont(); void DestroyDebugFont();
void ObrsPrintfString(const char *str, short x, short y);
void FlushObrsPrintfs(); void FlushObrsPrintfs();
void DefinedState(void); void DefinedState(void);
RwFrame *GetFirstChild(RwFrame *frame); RwFrame *GetFirstChild(RwFrame *frame);

View file

@ -43,8 +43,16 @@ struct MatFX
int effects; int effects;
}; };
#ifdef RWLIBS
extern "C" {
extern int MatFXMaterialDataOffset;
extern int MatFXAtomicDataOffset;
void _rpMatFXD3D8AtomicMatFXEnvRender(RxD3D8InstanceData* inst, int flags, int sel, RwTexture* texture, RwTexture* envMap);
}
#else
int &MatFXMaterialDataOffset = *(int*)0x66188C; int &MatFXMaterialDataOffset = *(int*)0x66188C;
int &MatFXAtomicDataOffset = *(int*)0x66189C; int &MatFXAtomicDataOffset = *(int*)0x66189C;
#endif
#ifdef PS2_MATFX #ifdef PS2_MATFX
@ -206,8 +214,13 @@ _rpMatFXD3D8AtomicMatFXEnvRender_ps2(RxD3D8InstanceData *inst, int flags, int se
RwD3D8SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); RwD3D8SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
} }
STARTPATCHES STARTPATCHES
#ifdef RWLIBS
InjectHook((uintptr)&_rpMatFXD3D8AtomicMatFXEnvRender, _rpMatFXD3D8AtomicMatFXEnvRender_ps2, PATCH_JUMP);
#else
InjectHook(0x5CF6C0, _rpMatFXD3D8AtomicMatFXEnvRender_ps2, PATCH_JUMP); InjectHook(0x5CF6C0, _rpMatFXD3D8AtomicMatFXEnvRender_ps2, PATCH_JUMP);
#endif
ENDPATCHES ENDPATCHES
#endif #endif

View file

@ -283,7 +283,7 @@ GenericLoad()
LoadSaveDataBlock(); LoadSaveDataBlock();
ReadDataFromBlock("Loading Paths \n", ThePaths.Load); ReadDataFromBlock("Loading Paths \n", ThePaths.Load);
LoadSaveDataBlock(); LoadSaveDataBlock();
ReadDataFromBlock("Loading Cranes \n", CranesLoad); ReadDataFromBlock("Loading Cranes \n", CCranes::Load);
LoadSaveDataBlock(); LoadSaveDataBlock();
ReadDataFromBlock("Loading Pickups \n", CPickups::Load); ReadDataFromBlock("Loading Pickups \n", CPickups::Load);
LoadSaveDataBlock(); LoadSaveDataBlock();

View file

@ -14,11 +14,11 @@
#include "Vehicle.h" #include "Vehicle.h"
#include "World.h" #include "World.h"
uint8 &CTheCarGenerators::ProcessCounter = *(uint8*)0x95CDAF; uint8 CTheCarGenerators::ProcessCounter;
uint32 &CTheCarGenerators::NumOfCarGenerators = *(uint32*)0x8E2C1C; uint32 CTheCarGenerators::NumOfCarGenerators;
CCarGenerator (&CTheCarGenerators::CarGeneratorArray)[NUM_CARGENS] = *(CCarGenerator(*)[NUM_CARGENS])*(uintptr*)0x87CB18; CCarGenerator CTheCarGenerators::CarGeneratorArray[NUM_CARGENS];
uint8 &CTheCarGenerators::GenerateEvenIfPlayerIsCloseCounter = *(uint8*)0x95CDC6; uint8 CTheCarGenerators::GenerateEvenIfPlayerIsCloseCounter;
uint32 &CTheCarGenerators::CurrentActiveCount = *(uint32*)0x8F2C5C; uint32 CTheCarGenerators::CurrentActiveCount;
void CCarGenerator::SwitchOff() void CCarGenerator::SwitchOff()
{ {
@ -187,59 +187,6 @@ bool CCarGenerator::CheckIfWithinRangeOfAnyPlayer()
return DotProduct2D(direction, FindPlayerSpeed()) <= 0; return DotProduct2D(direction, FindPlayerSpeed()) <= 0;
} }
void CCarGenerator::Save(uint8 *&buffer)
{
WriteSaveBuf(buffer, m_nModelIndex);
WriteSaveBuf(buffer, m_vecPos);
WriteSaveBuf(buffer, m_fAngle);
WriteSaveBuf(buffer, m_nColor1);
WriteSaveBuf(buffer, m_nColor2);
WriteSaveBuf(buffer, m_bForceSpawn);
WriteSaveBuf(buffer, m_nAlarm);
WriteSaveBuf(buffer, m_nDoorlock);
WriteSaveBuf(buffer, (uint8)0);
WriteSaveBuf(buffer, m_nMinDelay);
WriteSaveBuf(buffer, m_nMaxDelay);
WriteSaveBuf(buffer, m_nTimer);
WriteSaveBuf(buffer, m_nVehicleHandle);
WriteSaveBuf(buffer, m_nUsesRemaining);
WriteSaveBuf(buffer, m_bIsBlocking);
WriteSaveBuf(buffer, (uint8)0);
WriteSaveBuf(buffer, m_vecInf);
WriteSaveBuf(buffer, m_vecSup);
WriteSaveBuf(buffer, m_fSize);
// or
//WriteSaveBuf(buffer, *this);
}
void CCarGenerator::Load(uint8 *&buffer)
{
m_nModelIndex = ReadSaveBuf<uint32>(buffer);
m_vecPos = ReadSaveBuf<CVector>(buffer);
m_fAngle = ReadSaveBuf<float>(buffer);
m_nColor1 = ReadSaveBuf<int16>(buffer);
m_nColor2 = ReadSaveBuf<int16>(buffer);
m_bForceSpawn = ReadSaveBuf<uint8>(buffer);
m_nAlarm = ReadSaveBuf<uint8>(buffer);
m_nDoorlock = ReadSaveBuf<uint8>(buffer);
ReadSaveBuf<uint8>(buffer);
m_nMinDelay = ReadSaveBuf<uint16>(buffer);
m_nMaxDelay = ReadSaveBuf<uint16>(buffer);
m_nTimer = ReadSaveBuf<uint32>(buffer);
m_nVehicleHandle = ReadSaveBuf<int32>(buffer);
m_nUsesRemaining = ReadSaveBuf<uint16>(buffer);
m_bIsBlocking = ReadSaveBuf<bool>(buffer);
ReadSaveBuf<uint8>(buffer);
m_vecInf = ReadSaveBuf<CVector>(buffer);
m_vecSup = ReadSaveBuf<CVector>(buffer);
m_fSize = ReadSaveBuf<float>(buffer);
// or
//*this = ReadSaveBuf<CCarGenerator>(buffer);
}
void CTheCarGenerators::Process() void CTheCarGenerators::Process()
{ {
if (FindPlayerTrain() || CCutsceneMgr::IsCutsceneProcessing()) if (FindPlayerTrain() || CCutsceneMgr::IsCutsceneProcessing())
@ -268,39 +215,38 @@ void CTheCarGenerators::Init()
void CTheCarGenerators::SaveAllCarGenerators(uint8 *buffer, uint32 *size) void CTheCarGenerators::SaveAllCarGenerators(uint8 *buffer, uint32 *size)
{ {
*size = 20 + sizeof(CarGeneratorArray) + SAVE_HEADER_SIZE; const uint32 nGeneralDataSize = sizeof(NumOfCarGenerators) + sizeof(CurrentActiveCount) + sizeof(ProcessCounter) + sizeof(GenerateEvenIfPlayerIsCloseCounter) + sizeof(int16);
*size = sizeof(int) + nGeneralDataSize + sizeof(uint32) + sizeof(CarGeneratorArray) + SAVE_HEADER_SIZE;
INITSAVEBUF INITSAVEBUF
WriteSaveHeader(buffer, 'C','G','N','\0', *size - SAVE_HEADER_SIZE); WriteSaveHeader(buffer, 'C','G','N','\0', *size - SAVE_HEADER_SIZE);
WriteSaveBuf(buffer, 12); /* what is this? */ WriteSaveBuf(buffer, nGeneralDataSize);
WriteSaveBuf(buffer, NumOfCarGenerators); WriteSaveBuf(buffer, NumOfCarGenerators);
WriteSaveBuf(buffer, CurrentActiveCount); WriteSaveBuf(buffer, CurrentActiveCount);
WriteSaveBuf(buffer, ProcessCounter); WriteSaveBuf(buffer, ProcessCounter);
WriteSaveBuf(buffer, GenerateEvenIfPlayerIsCloseCounter); WriteSaveBuf(buffer, GenerateEvenIfPlayerIsCloseCounter);
WriteSaveBuf(buffer, (int16)0); WriteSaveBuf(buffer, (int16)0); // alignment
WriteSaveBuf(buffer, sizeof(CarGeneratorArray)); WriteSaveBuf(buffer, sizeof(CarGeneratorArray));
for (int i = 0; i < NUM_CARGENS; i++){ for (int i = 0; i < NUM_CARGENS; i++)
CarGeneratorArray[i].Save(buffer); WriteSaveBuf(buffer, CarGeneratorArray[i]);
}
VALIDATESAVEBUF(*size) VALIDATESAVEBUF(*size)
} }
void CTheCarGenerators::LoadAllCarGenerators(uint8* buffer, uint32 size) void CTheCarGenerators::LoadAllCarGenerators(uint8* buffer, uint32 size)
{ {
const int32 nGeneralDataSize = sizeof(NumOfCarGenerators) + sizeof(CurrentActiveCount) + sizeof(ProcessCounter) + sizeof(GenerateEvenIfPlayerIsCloseCounter) + sizeof(int16);
Init(); Init();
INITSAVEBUF INITSAVEBUF
assert(size == 20 + sizeof(CarGeneratorArray) + SAVE_HEADER_SIZE);
CheckSaveHeader(buffer, 'C','G','N','\0', size - SAVE_HEADER_SIZE); CheckSaveHeader(buffer, 'C','G','N','\0', size - SAVE_HEADER_SIZE);
ReadSaveBuf<uint32>(buffer); assert(ReadSaveBuf<uint32>(buffer) == nGeneralDataSize);
NumOfCarGenerators = ReadSaveBuf<uint32>(buffer); NumOfCarGenerators = ReadSaveBuf<uint32>(buffer);
CurrentActiveCount = ReadSaveBuf<uint32>(buffer); CurrentActiveCount = ReadSaveBuf<uint32>(buffer);
ProcessCounter = ReadSaveBuf<uint8>(buffer); ProcessCounter = ReadSaveBuf<uint8>(buffer);
GenerateEvenIfPlayerIsCloseCounter = ReadSaveBuf<uint8>(buffer); GenerateEvenIfPlayerIsCloseCounter = ReadSaveBuf<uint8>(buffer);
ReadSaveBuf<int16>(buffer); ReadSaveBuf<int16>(buffer); // alignment
assert(ReadSaveBuf<uint32>(buffer) == sizeof(CarGeneratorArray)); assert(ReadSaveBuf<uint32>(buffer) == sizeof(CarGeneratorArray));
for (int i = 0; i < NUM_CARGENS; i++) { for (int i = 0; i < NUM_CARGENS; i++)
CarGeneratorArray[i].Load(buffer); CarGeneratorArray[i] = ReadSaveBuf<CCarGenerator>(buffer);
}
VALIDATESAVEBUF(size) VALIDATESAVEBUF(size)
} }

View file

@ -34,19 +34,17 @@ public:
void Setup(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay); void Setup(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay);
bool CheckForBlockage(); bool CheckForBlockage();
bool CheckIfWithinRangeOfAnyPlayer(); bool CheckIfWithinRangeOfAnyPlayer();
void Save(uint8*&);
void Load(uint8*&);
void SetUsesRemaining(uint16 uses) { m_nUsesRemaining = uses; } void SetUsesRemaining(uint16 uses) { m_nUsesRemaining = uses; }
}; };
class CTheCarGenerators class CTheCarGenerators
{ {
public: public:
static uint8 &ProcessCounter; static uint8 ProcessCounter;
static uint32 &NumOfCarGenerators; static uint32 NumOfCarGenerators;
static CCarGenerator (&CarGeneratorArray)[NUM_CARGENS]; static CCarGenerator CarGeneratorArray[NUM_CARGENS];
static uint8 &GenerateEvenIfPlayerIsCloseCounter; static uint8 GenerateEvenIfPlayerIsCloseCounter;
static uint32 &CurrentActiveCount; static uint32 CurrentActiveCount;
static void Process(); static void Process();
static int32 CreateCarGenerator(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay); static int32 CreateCarGenerator(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay);

View file

@ -38,9 +38,9 @@
uint32 TimerForCamInterpolation; uint32 TimerForCamInterpolation;
uint32& CCranes::CarsCollectedMilitaryCrane = *(uint32*)0x8F6248; uint32 CCranes::CarsCollectedMilitaryCrane;
int32& CCranes::NumCranes = *(int32*)0x8E28AC; int32 CCranes::NumCranes;
CCrane(&CCranes::aCranes)[NUM_CRANES] = *(CCrane(*)[NUM_CRANES])*(uintptr*)0x6FA4E0; CCrane CCranes::aCranes[NUM_CRANES];
void CCranes::InitCranes(void) void CCranes::InitCranes(void)
{ {
@ -466,13 +466,13 @@ bool CCrane::DoesCranePickUpThisCarType(uint32 mi)
bool CCranes::DoesMilitaryCraneHaveThisOneAlready(uint32 mi) bool CCranes::DoesMilitaryCraneHaveThisOneAlready(uint32 mi)
{ {
switch (mi) { switch (mi) {
case MI_FIRETRUCK: return (CCranes::CarsCollectedMilitaryCrane & 1); case MI_FIRETRUCK: return (CarsCollectedMilitaryCrane & 1);
case MI_AMBULAN: return (CCranes::CarsCollectedMilitaryCrane & 2); case MI_AMBULAN: return (CarsCollectedMilitaryCrane & 2);
case MI_ENFORCER: return (CCranes::CarsCollectedMilitaryCrane & 4); case MI_ENFORCER: return (CarsCollectedMilitaryCrane & 4);
case MI_FBICAR: return (CCranes::CarsCollectedMilitaryCrane & 8); case MI_FBICAR: return (CarsCollectedMilitaryCrane & 8);
case MI_RHINO: return (CCranes::CarsCollectedMilitaryCrane & 0x10); case MI_RHINO: return (CarsCollectedMilitaryCrane & 0x10);
case MI_BARRACKS: return (CCranes::CarsCollectedMilitaryCrane & 0x20); case MI_BARRACKS: return (CarsCollectedMilitaryCrane & 0x20);
case MI_POLICE: return (CCranes::CarsCollectedMilitaryCrane & 0x40); case MI_POLICE: return (CarsCollectedMilitaryCrane & 0x40);
default: break; default: break;
} }
return false; return false;
@ -481,20 +481,20 @@ bool CCranes::DoesMilitaryCraneHaveThisOneAlready(uint32 mi)
void CCranes::RegisterCarForMilitaryCrane(uint32 mi) void CCranes::RegisterCarForMilitaryCrane(uint32 mi)
{ {
switch (mi) { switch (mi) {
case MI_FIRETRUCK: CCranes::CarsCollectedMilitaryCrane |= 1; break; case MI_FIRETRUCK: CarsCollectedMilitaryCrane |= 1; break;
case MI_AMBULAN: CCranes::CarsCollectedMilitaryCrane |= 2; break; case MI_AMBULAN: CarsCollectedMilitaryCrane |= 2; break;
case MI_ENFORCER: CCranes::CarsCollectedMilitaryCrane |= 4; break; case MI_ENFORCER: CarsCollectedMilitaryCrane |= 4; break;
case MI_FBICAR: CCranes::CarsCollectedMilitaryCrane |= 8; break; case MI_FBICAR: CarsCollectedMilitaryCrane |= 8; break;
case MI_RHINO: CCranes::CarsCollectedMilitaryCrane |= 0x10; break; case MI_RHINO: CarsCollectedMilitaryCrane |= 0x10; break;
case MI_BARRACKS: CCranes::CarsCollectedMilitaryCrane |= 0x20; break; case MI_BARRACKS: CarsCollectedMilitaryCrane |= 0x20; break;
case MI_POLICE: CCranes::CarsCollectedMilitaryCrane |= 0x40; break; case MI_POLICE: CarsCollectedMilitaryCrane |= 0x40; break;
default: break; default: break;
} }
} }
bool CCranes::HaveAllCarsBeenCollectedByMilitaryCrane() bool CCranes::HaveAllCarsBeenCollectedByMilitaryCrane()
{ {
return (CCranes::CarsCollectedMilitaryCrane & 0x7F) == 0x7F; return (CarsCollectedMilitaryCrane & 0x7F) == 0x7F;
} }
bool CCrane::GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, float fTargetHeight, float fSpeedMultiplier) bool CCrane::GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, float fTargetHeight, float fSpeedMultiplier)
@ -509,8 +509,7 @@ bool CCrane::GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, floa
if (Abs(fHookAngleDelta) < fHookAngleChangeThisFrame) { if (Abs(fHookAngleDelta) < fHookAngleChangeThisFrame) {
m_fHookAngle = fAngleToTarget; m_fHookAngle = fAngleToTarget;
bAngleMovementFinished = true; bAngleMovementFinished = true;
} } else {
else {
if (fHookAngleDelta < 0.0f) { if (fHookAngleDelta < 0.0f) {
m_fHookAngle -= fHookAngleChangeThisFrame; m_fHookAngle -= fHookAngleChangeThisFrame;
if (m_fHookAngle < 0.0f) if (m_fHookAngle < 0.0f)
@ -528,8 +527,7 @@ bool CCrane::GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, floa
if (Abs(fHookOffsetDelta) < fHookOffsetChangeThisFrame) { if (Abs(fHookOffsetDelta) < fHookOffsetChangeThisFrame) {
m_fHookOffset = fDistanceToTarget; m_fHookOffset = fDistanceToTarget;
bOffsetMovementFinished = true; bOffsetMovementFinished = true;
} } else {
else {
if (fHookOffsetDelta < 0.0f) if (fHookOffsetDelta < 0.0f)
m_fHookOffset -= fHookOffsetChangeThisFrame; m_fHookOffset -= fHookOffsetChangeThisFrame;
else else
@ -541,8 +539,7 @@ bool CCrane::GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, floa
if (Abs(fHookHeightDelta) < fHookHeightChangeThisFrame) { if (Abs(fHookHeightDelta) < fHookHeightChangeThisFrame) {
m_fHookHeight = fTargetHeight; m_fHookHeight = fTargetHeight;
bHeightMovementFinished = true; bHeightMovementFinished = true;
} } else {
else {
if (fHookHeightDelta < 0.0f) if (fHookHeightDelta < 0.0f)
m_fHookHeight -= fHookHeightChangeThisFrame; m_fHookHeight -= fHookHeightChangeThisFrame;
else else
@ -560,8 +557,7 @@ bool CCrane::GoTowardsHeightTarget(float fTargetHeight, float fSpeedMultiplier)
if (Abs(fHookHeightDelta) < fHookHeightChangeThisFrame) { if (Abs(fHookHeightDelta) < fHookHeightChangeThisFrame) {
m_fHookHeight = fTargetHeight; m_fHookHeight = fTargetHeight;
bHeightMovementFinished = true; bHeightMovementFinished = true;
} } else {
else {
if (fHookHeightDelta < 0.0f) if (fHookHeightDelta < 0.0f)
m_fHookHeight -= fHookHeightChangeThisFrame; m_fHookHeight -= fHookHeightChangeThisFrame;
else else
@ -587,7 +583,7 @@ void CCrane::CalcHookCoordinates(float* pX, float* pY, float* pZ)
void CCrane::SetHookMatrix() void CCrane::SetHookMatrix()
{ {
if (!m_pHook) if (m_pHook == nil)
return; return;
m_pHook->GetPosition() = m_vecHookCurPos; m_pHook->GetPosition() = m_vecHookCurPos;
CVector up(m_vecHookInitPos.x - m_vecHookCurPos.x, m_vecHookInitPos.y - m_vecHookCurPos.y, 20.0f); CVector up(m_vecHookInitPos.x - m_vecHookCurPos.x, m_vecHookInitPos.y - m_vecHookCurPos.y, 20.0f);
@ -632,48 +628,44 @@ void CCranes::Save(uint8* buf, uint32* size)
{ {
INITSAVEBUF INITSAVEBUF
*size = 2 * sizeof(uint32) + NUM_CRANES * sizeof(CCrane); *size = 2 * sizeof(uint32) + sizeof(aCranes);
WriteSaveBuf(buf, NumCranes); WriteSaveBuf(buf, NumCranes);
WriteSaveBuf(buf, CarsCollectedMilitaryCrane); WriteSaveBuf(buf, CarsCollectedMilitaryCrane);
for (int i = 0; i < NUM_CRANES; i++) { for (int i = 0; i < NUM_CRANES; i++) {
CCrane* pCrane = WriteSaveBuf(buf, aCranes[i]); CCrane *pCrane = WriteSaveBuf(buf, aCranes[i]);
if (pCrane->m_pCraneEntity) if (pCrane->m_pCraneEntity != nil)
pCrane->m_pCraneEntity = (CBuilding*)(CPools::GetBuildingPool()->GetJustIndex((CBuilding*)pCrane->m_pCraneEntity) + 1); pCrane->m_pCraneEntity = (CBuilding*)(CPools::GetBuildingPool()->GetJustIndex(pCrane->m_pCraneEntity) + 1);
if (pCrane->m_pHook) if (pCrane->m_pHook != nil)
pCrane->m_pHook = (CObject*)(CPools::GetObjectPool()->GetJustIndex((CObject*)pCrane->m_pHook) + 1); pCrane->m_pHook = (CObject*)(CPools::GetObjectPool()->GetJustIndex(pCrane->m_pHook) + 1);
if (pCrane->m_pVehiclePickedUp) if (pCrane->m_pVehiclePickedUp != nil)
pCrane->m_pVehiclePickedUp = (CVehicle*)(CPools::GetVehiclePool()->GetJustIndex((CVehicle*)pCrane->m_pVehiclePickedUp) + 1); pCrane->m_pVehiclePickedUp = (CVehicle*)(CPools::GetVehiclePool()->GetJustIndex(pCrane->m_pVehiclePickedUp) + 1);
} }
VALIDATESAVEBUF(*size); VALIDATESAVEBUF(*size);
} }
void CranesLoad(uint8* buf, uint32 size) void CCranes::Load(uint8* buf, uint32 size)
{ {
INITSAVEBUF INITSAVEBUF
CCranes::NumCranes = ReadSaveBuf<int32>(buf); NumCranes = ReadSaveBuf<int32>(buf);
CCranes::CarsCollectedMilitaryCrane = ReadSaveBuf<uint32>(buf); CarsCollectedMilitaryCrane = ReadSaveBuf<uint32>(buf);
for (int i = 0; i < NUM_CRANES; i++) for (int i = 0; i < NUM_CRANES; i++)
CCranes::aCranes[i] = ReadSaveBuf<CCrane>(buf); aCranes[i] = ReadSaveBuf<CCrane>(buf);
for (int i = 0; i < NUM_CRANES; i++) { for (int i = 0; i < NUM_CRANES; i++) {
CCrane* pCrane = &CCranes::aCranes[i]; CCrane *pCrane = &aCranes[i];
if (pCrane->m_pCraneEntity) if (pCrane->m_pCraneEntity != nil)
pCrane->m_pCraneEntity = CPools::GetBuildingPool()->GetSlot((uint32)pCrane->m_pCraneEntity - 1); pCrane->m_pCraneEntity = CPools::GetBuildingPool()->GetSlot((uint32)pCrane->m_pCraneEntity - 1);
if (pCrane->m_pHook) if (pCrane->m_pHook != nil)
pCrane->m_pHook = CPools::GetObjectPool()->GetSlot((uint32)pCrane->m_pHook - 1); pCrane->m_pHook = CPools::GetObjectPool()->GetSlot((uint32)pCrane->m_pHook - 1);
if (pCrane->m_pVehiclePickedUp) if (pCrane->m_pVehiclePickedUp != nil)
pCrane->m_pVehiclePickedUp = CPools::GetVehiclePool()->GetSlot((uint32)pCrane->m_pVehiclePickedUp + 1); pCrane->m_pVehiclePickedUp = CPools::GetVehiclePool()->GetSlot((uint32)pCrane->m_pVehiclePickedUp - 1);
} }
for (int i = 0; i < NUM_CRANES; i++) { for (int i = 0; i < NUM_CRANES; i++) {
CCranes::aCranes[i].m_nAudioEntity = DMAudio.CreateEntity(AUDIOTYPE_CRANE, &CCranes::aCranes[i]); aCranes[i].m_nAudioEntity = DMAudio.CreateEntity(AUDIOTYPE_CRANE, &aCranes[i]);
if (CCranes::aCranes[i].m_nAudioEntity) if (aCranes[i].m_nAudioEntity != 0)
DMAudio.SetEntityStatus(CCranes::aCranes[i].m_nAudioEntity, 1); DMAudio.SetEntityStatus(aCranes[i].m_nAudioEntity, 1);
} }
VALIDATESAVEBUF(size); VALIDATESAVEBUF(size);
} }
STARTPATCHES
InjectHook(0x5454D0, CranesLoad, PATCH_JUMP); // GenericLoad
ENDPATCHES

View file

@ -89,10 +89,9 @@ public:
static bool IsThisCarBeingCarriedByAnyCrane(CVehicle* pVehicle); static bool IsThisCarBeingCarriedByAnyCrane(CVehicle* pVehicle);
static bool IsThisCarBeingTargettedByAnyCrane(CVehicle* pVehicle); static bool IsThisCarBeingTargettedByAnyCrane(CVehicle* pVehicle);
static void Save(uint8* buf, uint32* size); static void Save(uint8* buf, uint32* size);
static void Load(uint8* buf, uint32 size); // on mobile it's CranesLoad outside of the class
static uint32& CarsCollectedMilitaryCrane; static uint32 CarsCollectedMilitaryCrane;
static int32& NumCranes; static int32 NumCranes;
static CCrane(&aCranes)[NUM_CRANES]; static CCrane aCranes[NUM_CRANES];
}; };
void CranesLoad(uint8*, uint32); // is this really outside CCranes?