More more more audio

This commit is contained in:
Filip Gawin 2019-08-16 20:17:15 +02:00
parent 458fc63f01
commit 2fabbc3b4c
56 changed files with 1675 additions and 964 deletions

View file

@ -119,7 +119,7 @@ bool EAX3ListenerInterpolate(LPEAXLISTENERPROPERTIES lpStart, LPEAXLISTENERPROPE
if (lpStart->flReflectionsDelay == lpFinish->flReflectionsDelay)
lpResult->flReflectionsDelay = lpStart->flReflectionsDelay;
else
lpResult->flReflectionsDelay = (float)exp( (log(lpStart->flReflectionsDelay+0.0001) * flInvRatio) + (log(lpFinish->flReflectionsDelay+0.0001) * flRatio) );
lpResult->flReflectionsDelay = (float)exp( (log(lpStart->flReflectionsDelay+0.0001f) * flInvRatio) + (log(lpFinish->flReflectionsDelay+0.0001f) * flRatio) );
// Reflections Pan
@ -155,7 +155,7 @@ bool EAX3ListenerInterpolate(LPEAXLISTENERPROPERTIES lpStart, LPEAXLISTENERPROPE
if (lpStart->flReverbDelay == lpFinish->flReverbDelay)
lpResult->flReverbDelay = lpStart->flReverbDelay;
else
lpResult->flReverbDelay = (float)exp( (log(lpStart->flReverbDelay+0.0001) * flInvRatio) + (log(lpFinish->flReverbDelay+0.0001) * flRatio) );
lpResult->flReverbDelay = (float)exp( (log(lpStart->flReverbDelay+0.0001f) * flInvRatio) + (log(lpFinish->flReverbDelay+0.0001f) * flRatio) );
// Reverb Pan
@ -354,7 +354,7 @@ void Clamp(EAXVECTOR *eaxVector)
// Array of scenario names //
//////////////////////////////////////////////////////
char* EAX30_SCENARIO_NAMES[] =
const char* EAX30_SCENARIO_NAMES[] =
{
"Castle",
"Factory",
@ -376,7 +376,7 @@ char* EAX30_SCENARIO_NAMES[] =
// Array of standardised location names //
//////////////////////////////////////////////////////
char* EAX30_LOCATION_NAMES[] =
const char* EAX30_LOCATION_NAMES[] =
{
"Hall",
"Large Room",
@ -410,7 +410,7 @@ EAXLISTENERPROPERTIES EAX30_STANDARD_PRESETS[EAX30_NUM_STANDARD_SCENARIOS][EAX30
// Array of original environment names //
//////////////////////////////////////////////////////
char* EAX30_ORIGINAL_PRESET_NAMES[] =
const char* EAX30_ORIGINAL_PRESET_NAMES[] =
{
"Generic",
"Padded Cell",
@ -480,7 +480,7 @@ EAXLISTENERPROPERTIES EAX30_ORIGINAL_PRESETS[] =
// Array of sport environment names //
//////////////////////////////////////////////////////
char* EAX30_SPORTS_PRESET_NAMES[] =
const char* EAX30_SPORTS_PRESET_NAMES[] =
{
"Empty Stadium",
"Full Stadium",
@ -512,7 +512,7 @@ EAXLISTENERPROPERTIES EAX30_SPORTS_PRESETS[] =
// Array of prefab environment names //
//////////////////////////////////////////////////////
char* EAX30_PREFAB_PRESET_NAMES[] =
const char* EAX30_PREFAB_PRESET_NAMES[] =
{
"Workshop",
"School Room",
@ -540,7 +540,7 @@ EAXLISTENERPROPERTIES EAX30_PREFAB_PRESETS[] =
// Array of Domes & Pipes environment names //
//////////////////////////////////////////////////////
char* EAX30_DOMESNPIPES_PRESET_NAMES[] =
const char* EAX30_DOMESNPIPES_PRESET_NAMES[] =
{
"Domed Tomb",
"Saint Paul's Dome",
@ -570,7 +570,7 @@ EAXLISTENERPROPERTIES EAX30_DOMESNPIPES_PRESETS[] =
// Array of Outdoors environment names //
//////////////////////////////////////////////////////
char* EAX30_OUTDOORS_PRESET_NAMES[] =
const char* EAX30_OUTDOORS_PRESET_NAMES[] =
{
"Backyard",
"Rolling Plains",
@ -598,7 +598,7 @@ EAXLISTENERPROPERTIES EAX30_OUTDOORS_PRESETS[] =
// Array of Mood environment names //
//////////////////////////////////////////////////////
char* EAX30_MOOD_PRESET_NAMES[] =
const char* EAX30_MOOD_PRESET_NAMES[] =
{
"Heaven",
"Hell",
@ -622,7 +622,7 @@ EAXLISTENERPROPERTIES EAX30_MOOD_PRESETS[] =
// Array of driving environment names //
//////////////////////////////////////////////////////
char* EAX30_DRIVING_PRESET_NAMES[] =
const char* EAX30_DRIVING_PRESET_NAMES[] =
{
"Race Commentator",
"Pit Garage",
@ -656,7 +656,7 @@ EAXLISTENERPROPERTIES EAX30_DRIVING_PRESETS[] =
// Array of City environment names //
//////////////////////////////////////////////////////
char* EAX30_CITY_PRESET_NAMES[] =
const char* EAX30_CITY_PRESET_NAMES[] =
{
"City Streets",
"Subway",
@ -686,7 +686,7 @@ EAXLISTENERPROPERTIES EAX30_CITY_PRESETS[] =
// Array of Misc environment names //
//////////////////////////////////////////////////////
char* EAX30_MISC_PRESET_NAMES[] =
const char* EAX30_MISC_PRESET_NAMES[] =
{
"Dusty Box Room",
"Chapel",

View file

@ -372,7 +372,7 @@ EAX30_SCENARIO;
// Array of scenario names //
//////////////////////////////////////////////////////
extern char* EAX30_SCENARIO_NAMES[];
extern const char* EAX30_SCENARIO_NAMES[];
//////////////////////////////////////////////////////
// Standardised Locations enumerated //
@ -402,7 +402,7 @@ EAX30_LOCATION;
// Array of standardised location names //
//////////////////////////////////////////////////////
extern char* EAX30_LOCATION_NAMES[];
extern const char* EAX30_LOCATION_NAMES[];
//////////////////////////////////////////////////////
// Number of effects in each scenario //
@ -471,7 +471,7 @@ EAX30_ORIGINAL_PRESET_ENUMS;
// Array of original environment names //
//////////////////////////////////////////////////////
extern char* EAX30_ORIGINAL_PRESET_NAMES[];
extern const char* EAX30_ORIGINAL_PRESET_NAMES[];
//////////////////////////////////////////////////////
// Original effects matrix //
@ -501,7 +501,7 @@ EAX30_SPORTS_PRESET_ENUMS;
// Array of sport environment names //
//////////////////////////////////////////////////////
extern char* EAX30_SPORTS_PRESET_NAMES[];
extern const char* EAX30_SPORTS_PRESET_NAMES[];
//////////////////////////////////////////////////////
// Sports effects matrix //
@ -529,7 +529,7 @@ EAX30_PREFAB_PRESET_ENUMS;
// Array of prefab environment names //
//////////////////////////////////////////////////////
char* EAX30_PREFAB_PRESET_NAMES[];
extern const char* EAX30_PREFAB_PRESET_NAMES[];
//////////////////////////////////////////////////////
// Prefab effects matrix //
@ -558,7 +558,7 @@ EAX30_DOMESNPIPES_PRESET_ENUMS;
// Array of Domes & Pipes environment names //
//////////////////////////////////////////////////////
extern char* EAX30_DOMESNPIPES_PRESET_NAMES[];
extern const char* EAX30_DOMESNPIPES_PRESET_NAMES[];
//////////////////////////////////////////////////////
// Domes & Pipes effects matrix //
@ -586,7 +586,7 @@ EAX30_OUTDOORS_PRESET_ENUMS;
// Array of Outdoors environment names //
//////////////////////////////////////////////////////
extern char* EAX30_OUTDOORS_PRESET_NAMES[];
extern const char* EAX30_OUTDOORS_PRESET_NAMES[];
//////////////////////////////////////////////////////
// Outdoors effects matrix //
@ -612,7 +612,7 @@ EAX30_MOOD_PRESET_ENUMS;
// Array of Mood environment names //
//////////////////////////////////////////////////////
extern char* EAX30_MOOD_PRESET_NAMES[];
extern const char* EAX30_MOOD_PRESET_NAMES[];
//////////////////////////////////////////////////////
// Mood effects matrix //
@ -643,7 +643,7 @@ EAX30_DRIVING_PRESET_ENUMS;
// Array of driving environment names //
//////////////////////////////////////////////////////
extern char* EAX30_DRIVING_PRESET_NAMES[];
extern const char* EAX30_DRIVING_PRESET_NAMES[];
//////////////////////////////////////////////////////
// Driving effects matrix //
@ -672,7 +672,7 @@ EAX30_CITY_PRESET_ENUMS;
// Array of City environment names //
//////////////////////////////////////////////////////
extern char* EAX30_CITY_PRESET_NAMES[];
extern const char* EAX30_CITY_PRESET_NAMES[];
//////////////////////////////////////////////////////
// City effects matrix //
@ -699,7 +699,7 @@ EAX30_MISC_PRESET_ENUMS;
// Array of Misc environment names //
//////////////////////////////////////////////////////
extern char* EAX30_MISC_PRESET_NAMES[];
extern const char* EAX30_MISC_PRESET_NAMES[];
//////////////////////////////////////////////////////
// Misc effects matrix //

View file

@ -129,7 +129,7 @@ CAnimBlendAssocGroup::CreateAssociations(const char *name)
// Create associations from hierarchies for a given clump
void
CAnimBlendAssocGroup::CreateAssociations(const char *blockName, RpClump *clump, char **animNames, int numAssocs)
CAnimBlendAssocGroup::CreateAssociations(const char *blockName, RpClump *clump, const char **animNames, int numAssocs)
{
int i;
CAnimBlock *animBlock;
@ -157,5 +157,5 @@ STARTPATCHES
InjectHook(0x401420, (CAnimBlendAssociation *(CAnimBlendAssocGroup::*)(uint32))&CAnimBlendAssocGroup::CopyAnimation, PATCH_JUMP);
InjectHook(0x4013E0, (CAnimBlendAssociation *(CAnimBlendAssocGroup::*)(const char*))&CAnimBlendAssocGroup::CopyAnimation, PATCH_JUMP);
InjectHook(0x401130, (void (CAnimBlendAssocGroup::*)(const char*))&CAnimBlendAssocGroup::CreateAssociations, PATCH_JUMP);
InjectHook(0x401220, (void (CAnimBlendAssocGroup::*)(const char*, RpClump*, char**, int))&CAnimBlendAssocGroup::CreateAssociations, PATCH_JUMP);
InjectHook(0x401220, (void (CAnimBlendAssocGroup::*)(const char*, RpClump*, const char**, int))&CAnimBlendAssocGroup::CreateAssociations, PATCH_JUMP);
ENDPATCHES

View file

@ -16,5 +16,5 @@ public:
CAnimBlendAssociation *CopyAnimation(uint32 id);
CAnimBlendAssociation *CopyAnimation(const char *name);
void CreateAssociations(const char *name);
void CreateAssociations(const char *blockName, RpClump *clump, char **animNames, int numAssocs);
void CreateAssociations(const char *blockName, RpClump *clump, const char **animNames, int numAssocs);
};

View file

@ -185,7 +185,7 @@ CAnimBlendAssociation::UpdateBlend(float timeDelta)
if(blendAmount <= 0.0f && blendDelta < 0.0f){
// We're faded out and are not fading in
blendAmount = 0.0f;
blendDelta = max(0.0, blendDelta);
blendDelta = Max(0.0f, blendDelta);
if(flags & ASSOC_DELETEFADEDOUT){
if(callbackType == CB_FINISH || callbackType == CB_DELETE)
callback(this, callbackArg);
@ -197,7 +197,7 @@ CAnimBlendAssociation::UpdateBlend(float timeDelta)
if(blendAmount > 1.0f){
// Maximally faded in, clamp values
blendAmount = 1.0f;
blendDelta = min(0.0, blendDelta);
blendDelta = Min(0.0f, blendDelta);
}
return true;

View file

@ -36,7 +36,7 @@ CAnimBlendHierarchy::CalcTotalTime(void)
float seqTime = 0.0f;
for(j = 0; j < sequences[i].numFrames; j++)
seqTime += sequences[i].GetKeyFrame(j)->deltaTime;
totalTime = max(totalTime, seqTime);
totalTime = Max(totalTime, seqTime);
}
totalLength = totalTime;
}

View file

@ -198,7 +198,7 @@ AnimAssocDesc aStdAnimDescsSide[] = {
{ ANIM_IDLE_STANCE, ASSOC_REPEAT },
{ ANIM_WALK_START, ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION },
};
char *aStdAnimations[] = {
char const *aStdAnimations[] = {
"walk_civi",
"run_civi",
"sprint_panic",
@ -373,162 +373,162 @@ char *aStdAnimations[] = {
"PHONE_out",
"PHONE_talk",
};
char *aPlayerAnimations[] = {
char const *aPlayerAnimations[] = {
"walk_player",
"run_player",
"SPRINT_civi",
"IDLE_STANCE",
"walk_start",
};
char *aPlayerWithRocketAnimations[] = {
char const *aPlayerWithRocketAnimations[] = {
"walk_rocket",
"run_rocket",
"run_rocket",
"idle_rocket",
"walk_start_rocket",
};
char *aPlayer1ArmedAnimations[] = {
char const *aPlayer1ArmedAnimations[] = {
"walk_player",
"run_1armed",
"SPRINT_civi",
"IDLE_STANCE",
"walk_start",
};
char *aPlayer2ArmedAnimations[] = {
char const *aPlayer2ArmedAnimations[] = {
"walk_player",
"run_armed",
"run_armed",
"idle_stance",
"walk_start",
};
char *aPlayerBBBatAnimations[] = {
char const *aPlayerBBBatAnimations[] = {
"walk_player",
"run_player",
"run_player",
"IDLE_STANCE",
"walk_start",
};
char *aShuffleAnimations[] = {
char const *aShuffleAnimations[] = {
"WALK_shuffle",
"RUN_civi",
"SPRINT_civi",
"IDLE_STANCE",
};
char *aOldAnimations[] = {
char const *aOldAnimations[] = {
"walk_old",
"run_civi",
"sprint_civi",
"idle_stance",
};
char *aGang1Animations[] = {
char const *aGang1Animations[] = {
"walk_gang1",
"run_gang1",
"sprint_civi",
"idle_stance",
};
char *aGang2Animations[] = {
char const *aGang2Animations[] = {
"walk_gang2",
"run_gang1",
"sprint_civi",
"idle_stance",
};
char *aFatAnimations[] = {
char const *aFatAnimations[] = {
"walk_fat",
"run_civi",
"woman_runpanic",
"idle_stance",
};
char *aOldFatAnimations[] = {
char const *aOldFatAnimations[] = {
"walk_fatold",
"run_fatold",
"woman_runpanic",
"idle_stance",
};
char *aStdWomanAnimations[] = {
char const *aStdWomanAnimations[] = {
"woman_walknorm",
"woman_run",
"woman_runpanic",
"woman_idlestance",
};
char *aWomanShopAnimations[] = {
char const *aWomanShopAnimations[] = {
"woman_walkshop",
"woman_run",
"woman_run",
"woman_idlestance",
};
char *aBusyWomanAnimations[] = {
char const *aBusyWomanAnimations[] = {
"woman_walkbusy",
"woman_run",
"woman_runpanic",
"woman_idlestance",
};
char *aSexyWomanAnimations[] = {
char const *aSexyWomanAnimations[] = {
"woman_walksexy",
"woman_run",
"woman_runpanic",
"woman_idlestance",
};
char *aOldWomanAnimations[] = {
char const *aOldWomanAnimations[] = {
"woman_walkold",
"woman_run",
"woman_runpanic",
"woman_idlestance",
};
char *aFatWomanAnimations[] = {
char const *aFatWomanAnimations[] = {
"walk_fat",
"woman_run",
"woman_runpanic",
"woman_idlestance",
};
char *aPanicChunkyAnimations[] = {
char const *aPanicChunkyAnimations[] = {
"run_fatold",
"woman_runpanic",
"woman_runpanic",
"idle_stance",
};
char *aPlayerStrafeBackAnimations[] = {
char const *aPlayerStrafeBackAnimations[] = {
"walk_player_back",
"run_player_back",
"run_player_back",
"IDLE_STANCE",
"walk_start_back",
};
char *aPlayerStrafeLeftAnimations[] = {
char const *aPlayerStrafeLeftAnimations[] = {
"walk_player_left",
"run_left",
"run_left",
"IDLE_STANCE",
"walk_start_left",
};
char *aPlayerStrafeRightAnimations[] = {
char const *aPlayerStrafeRightAnimations[] = {
"walk_player_right",
"run_right",
"run_right",
"IDLE_STANCE",
"walk_start_right",
};
char *aRocketStrafeBackAnimations[] = {
char const *aRocketStrafeBackAnimations[] = {
"walk_rocket_back",
"run_rocket_back",
"run_rocket_back",
"idle_rocket",
"walkst_rocket_back",
};
char *aRocketStrafeLeftAnimations[] = {
char const *aRocketStrafeLeftAnimations[] = {
"walk_rocket_left",
"run_rocket_left",
"run_rocket_left",
"idle_rocket",
"walkst_rocket_left",
};
char *aRocketStrafeRightAnimations[] = {
char const *aRocketStrafeRightAnimations[] = {
"walk_rocket_right",
"run_rocket_right",
"run_rocket_right",
"idle_rocket",
"walkst_rocket_right",
};
AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS] = {
const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS] = {
{ "man", "ped", MI_COP, 173, aStdAnimations, aStdAnimDescs },
{ "player", "ped", MI_COP, 5, aPlayerAnimations, aStdAnimDescs },
{ "playerrocket", "ped", MI_COP, 5, aPlayerWithRocketAnimations, aStdAnimDescs },
@ -749,7 +749,7 @@ CAnimManager::LoadAnimFiles(void)
RpClump *clump = (RpClump*)mi->CreateInstance();
RpAnimBlendClumpInit(clump);
CAnimBlendAssocGroup *group = &CAnimManager::ms_aAnimAssocGroups[i];
AnimAssocDefinition *def = &CAnimManager::ms_aAnimAssocDefinitions[i];
const AnimAssocDefinition *def = &CAnimManager::ms_aAnimAssocDefinitions[i];
group->CreateAssociations(def->blockName, clump, def->animNames, def->numAnims);
for(j = 0; j < group->numAssociations; j++)
group->GetAnimation(j)->flags |= def->animDescs[j].flags;

View file

@ -231,17 +231,17 @@ struct AnimAssocDesc
struct AnimAssocDefinition
{
char *name;
char *blockName;
char const *name;
char const *blockName;
int32 modelIndex;
int32 numAnims;
char **animNames;
char const **animNames;
AnimAssocDesc *animDescs;
};
class CAnimManager
{
static AnimAssocDefinition ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS];
static const AnimAssocDefinition ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS];
static CAnimBlock *ms_aAnimBlocks; //[2]
static CAnimBlendHierarchy *ms_aAnimations; //[250]
static int32 &ms_numAnimBlocks;

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "AudioSamples.h"
#include "DMAudio.h"
@ -8,7 +8,7 @@ class tActiveSample
{
public:
int32 m_nEntityIndex;
int32 field_4;
int32 m_counter;
int32 m_nSampleIndex;
uint8 m_bBankIndex;
uint8 m_bIsDistant;
@ -49,6 +49,8 @@ public:
uint8 field_89;
uint8 field_90;
uint8 field_91;
// no methods
};
static_assert(sizeof(tActiveSample) == 92, "tActiveSample: error");
@ -84,8 +86,10 @@ public:
int16 m_awAudioEvent[4];
uint8 gap_18[2];
float m_afVolume[4];
uint8 field_24; // is looping
uint8 m_Loops;
uint8 field_25[3];
// no methods
};
static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error");
@ -93,13 +97,15 @@ static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error");
class tPedComment
{
public:
int m_nSampleIndex;
int field_4;
int32 m_nSampleIndex;
int32 m_entityIndex;
CVector m_vecPos;
float m_fDistance;
uint8 m_bVolume;
uint8 field_25;
int8 field_25; // allocated time?
uint8 gap_26[2];
// no methods
};
static_assert(sizeof(tPedComment) == 28, "tPedComment: error");
@ -108,12 +114,14 @@ class cPedComments
{
public:
tPedComment m_asPedComments[2][20];
uint8 field_1120[2][20];
uint8 indexMap[2][20];
uint8 nrOfCommentsInBank[2];
uint8 activeBank;
uint8 gap_1163[1];
// reversed all methods
void Add(tPedComment *com); /// ok
void Process(); /// ok
};
static_assert(sizeof(cPedComments) == 1164, "cPedComments: error");
@ -134,6 +142,8 @@ public:
CVector m_vecPosition;
float m_fDistance;
int32 m_nBaseVolume;
// no methods
};
static_assert(sizeof(cAudioCollision) == 40, "cAudioCollision: error");
@ -176,6 +186,7 @@ class CPlane;
class CVehicle;
class CPed;
class cPedParams;
class cTransmission;
class cAudioScriptObject {
public:
@ -271,9 +282,10 @@ public:
uint8 field_19192;
uint8 m_bUserPause;
uint8 m_bPreviousUserPause;
uint8 field_19195;
uint8 field_19195; // time?
uint32 m_FrameCounter;
<<<<<<< HEAD
inline uint32 GetFrameCounter(void) { return m_FrameCounter; }
float GetReflectionsDistance(int32 idx) { return m_afReflectionsDistances[idx]; }
<<<<<<< HEAD
@ -283,25 +295,36 @@ public:
>>>>>>> Cleanup
//
=======
// getters
uint32 GetFrameCounter() const { return m_FrameCounter; }
float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; }
int32 GetRandomTabe(int32 idx) const { return m_anRandomTable[idx]; }
>>>>>>> More more more audio
// "Should" be in alphabetic order, except "getXTalkSfx"
void AddDetailsToRequestedOrderList(uint8 sample); /// ok
void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1,
uint8 unk2, bool notLooping); /// ok
void AddReflectionsToRequestedQueue(); /// ok (check value)
void AddReleasingSounds(); // todo (difficult)
void AddSampleToRequestedQueue(); /// ok
void AgeCrimes(); // todo
int8 GetCurrent3DProviderIndex(); /// ok
uint8 counter, bool notLooping); /// ok
void AddReflectionsToRequestedQueue(); /// ok (check value)
void AddReleasingSounds(); // todo (difficult)
void AddSampleToRequestedQueue(); /// ok
void AgeCrimes(); // todo
void CalculateDistance(bool *ptr, float dist); /// ok
bool CheckForAnAudioFileOnCD(); /// ok
bool CheckForAnAudioFileOnCD() const; /// ok
void ClearMissionAudio(); /// ok
void ClearRequestedQueue(); /// ok
int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2,
float speedMultiplier); /// ok
float speedMultiplier) const; /// ok
int32 ComputePan(float, CVector *); // todo
<<<<<<< HEAD
uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance); /// ok
int32 CreateEntity(int32 type, void *entity); /// ok
=======
uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance) const; /// ok
int32 CreateEntity(int32 type, CPhysical *entity); /// ok
>>>>>>> More more more audio
void DestroyAllGameCreatedEntities(); /// ok
void DestroyEntity(int32 id); /// ok
@ -309,89 +332,60 @@ public:
void GenerateIntegerRandomNumberTable(); /// ok
float GetDistanceSquared(CVector *v); /// ok
void TranslateEntity(CVector *v1, CVector *v2) const ; /// ok
void TranslateEntity(CVector *v1, CVector *v2); /// ok
// done
void Initialise();
void PostInitialiseGameSpecificSetup();
void InitialisePoliceRadioZones(); // todo
void ResetAudioLogicTimers(int32 timer); // todo
void ResetAudioLogicTimers(int32 timer); /// ok
void Terminate();
uint8 GetNum3DProvidersAvailable() const;
bool IsMP3RadioChannelAvailable() const;
uint8 GetCDAudioDriveLetter() const;
char GetMissionScriptPoliceAudioPlayingStatus();
bool GetMissionAudioLoadingStatus();
void SetEffectsMasterVolume(uint8 volume) const;
void SetMusicMasterVolume(uint8 volume) const;
void SetEffectsFadeVolume(uint8 volume) const;
void SetMusicFadeVolume(uint8 volume) const;
uint8 GetNum3DProvidersAvailable();
bool IsMP3RadioChannelAvailable();
uint8 GetCDAudioDriveLetter();
void SetEffectsMasterVolume(uint8 volume);
void SetMusicMasterVolume(uint8 volume);
void SetEffectsFadeVolume(uint8 volume);
void SetMusicFadeVolume(uint8 volume);
void SetSpeakerConfig(int32 conf);
void SetSpeakerConfig(int32 conf) const;
bool SetupJumboEngineSound(uint8, int32); // todo
void PreInitialiseGameSpecificSetup();
void SetMissionScriptPoliceAudio(int32 sfx);
void PreInitialiseGameSpecificSetup() const;
void SetMissionScriptPoliceAudio(int32 sfx) const;
bool UsesSiren(int32 model);
bool UsesSirenSwitching(int32 model);
bool UsesSiren(int32 model) const;
bool UsesSirenSwitching(int32 model) const;
bool MissionScriptAudioUsesPoliceChannel(int32 soundMission);
char *Get3DProviderName(uint8 id);
char *Get3DProviderName(uint8 id) const;
bool SetupJumboFlySound(uint8 emittingVol); /// ok
bool SetupJumboRumbleSound(uint8 emittingVol); /// ok
bool SetupJumboTaxiSound(uint8 vol); /// ok
bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok
void PlayLoadedMissionAudio();
void SetMissionAudioLocation(float x, float y, float z);
void ResetPoliceRadio();
void InterrogateAudioEntities();
bool UsesReverseWarning(int32 model) const;
bool UsesReverseWarning(int32 model);
bool HasAirBrakes(int32 model);
int32 RandomDisplacement(uint32 seed) const;
int32 GetJumboTaxiFreq();
bool IsMissionAudioSampleFinished();
void InitialisePoliceRadio(); // todo
int32 RandomDisplacement(uint32 seed);
void ReleaseDigitalHandle();
void ReacquireDigitalHandle();
void ReleaseDigitalHandle() const;
void ReacquireDigitalHandle() const;
void SetDynamicAcousticModelingStatus(bool status);
bool IsAudioInitialised() const;
void SetEntityStatus(int32 id, bool status);
void PreTerminateGameSpecificShutdown();
void PostTerminateGameSpecificShutdown();
void PlayerJustGotInCar();
void PlayerJustLeftCar();
void Service();
void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset);
void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const;
void DoJumboVolOffset();
void DoJumboVolOffset() const;
int32 GetPedCommentSfx(CPed *ped, int32 sound);
// order from GetPedCommentSfx
uint32 GetPlayerTalkSfx(int16 sound);
uint32 GetCopTalkSfx(int16 sound);
uint32 GetSwatTalkSfx(int16 sound);
@ -469,8 +463,38 @@ public:
uint32 GetGenericMaleTalkSfx(int16 sound);
uint32 GetGenericFemaleTalkSfx(int16 sound);
void PlayOneShot(int32 index, int16 sound, float vol); // todo
int8 GetCurrent3DProviderIndex() const; /// ok
float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // todo hook
float GetCollisionOneShotRatio(uint32 a, float b) const; // todo hook
float GetCollisionRatio(float a, float b, float c, float d) const; // todo hook
float GetDistanceSquared(CVector *v) const; /// ok
int32 GetJumboTaxiFreq() const; /// ok
bool GetMissionAudioLoadingStatus() const; /// ok
char GetMissionScriptPoliceAudioPlayingStatus() const; /// ok
float GetVehicleDriveWheelSkidValue(uint8 a1, CAutomobile *a2, cTransmission *a3,
float a4); // todo
int32 GetVehicleNonDriveWheelSkidValue(float a1, int a2, int a3, int a4, float a5); // todo
bool HasAirBrakes(int32 model) const; /// ok
void Initialise(); /// ok
void InitialisePoliceRadio(); // todo
void InitialisePoliceRadioZones(); // todo
void InterrogateAudioEntities(); /// ok
bool IsMissionAudioSampleFinished(); /// ok
bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok
void PlayLoadedMissionAudio(); /// ok
void PlayOneShot(int32 index, int16 sound, float vol); // todo
uint32 PlaySuspectLastSeen(float x, float y, float z); // todo
void PlayerJustGotInCar() const; /// ok
void PlayerJustLeftCar() const; /// ok
void PostInitialiseGameSpecificSetup(); /// ok
void PostTerminateGameSpecificShutdown(); /// ok
void PreTerminateGameSpecificShutdown(); /// ok
void PreloadMissionAudio(char *); // todo
/// processX - main logic of adding new sounds
void ProcessActiveQueues(); // todo
bool ProcessAirBrakes(cVehicleParams *params); /// ok
void ProcessAirportScriptObject(uint8 sound); /// ok
@ -503,40 +527,40 @@ public:
void ProcessJumboTaxi(); /// ok
void ProcessLaunderetteScriptObject(uint8 sound); /// ok
void ProcessLoopingScriptObject(uint8 sound); /// ok
// void ProcessMissionAudio();
void ProcessModelCarEngine(cVehicleParams *params); /// (check float comparisons)
void ProcessOneShotScriptObject(uint8 sound); /// ok
void ProcessPed(CPhysical *ped); /// ok
void ProcessPedHeadphones(cPedParams *params); /// ok
void ProcessPedOneShots(cPedParams *params); /// ok
void ProcessPhysical(int32 id); /// ok
void ProcessPlane(cVehicleParams *params); /// ok
void ProcessMissionAudio(); /// ok
void ProcessModelCarEngine(cVehicleParams *params); /// ok (check float comparisons)
void ProcessOneShotScriptObject(uint8 sound); /// ok
void ProcessPed(CPhysical *ped); /// ok
void ProcessPedHeadphones(cPedParams *params); /// ok
void ProcessPedOneShots(cPedParams *params); // todo later (weird)
void ProcessPhysical(int32 id); /// ok
void ProcessPlane(cVehicleParams *params); /// ok
void ProcessPlayersVehicleEngine(cVehicleParams *params,
CAutomobile *automobile); /// ok (check float comparisons)
void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo
void ProcessPornCinema(uint8 sound); /// ok
void ProcessProjectiles(); // todo requires CProjectileInfo
void ProcessRainOnVehicle(cVehicleParams *params); /// ok
// void ProcessReverb();
// bool ProcessReverseGear(void *);
void ProcessSawMillScriptObject(uint8 sound); /// ok
void ProcessScriptObject(int32 id); /// ok
void ProcessShopScriptObject(uint8 sound); /// ok
void ProcessSpecial(); /// ok
// bool ProcessTrainNoise(void *);
void ProcessVehicle(CVehicle *); // todo
// bool ProcessVehicleDoors(void *);
void ProcessReverb() const; /// ok
bool ProcessReverseGear(cVehicleParams *a2); /// ok
void ProcessSawMillScriptObject(uint8 sound); /// ok
void ProcessScriptObject(int32 id); /// ok
void ProcessShopScriptObject(uint8 sound); /// ok
void ProcessSpecial(); /// ok
bool ProcessTrainNoise(cVehicleParams *params); /// ok
void ProcessVehicle(CVehicle *); // todo
bool ProcessVehicleDoors(cVehicleParams *params); /// ok
// bool ProcessVehicleEngine(void *);
// void ProcessVehicleHorn(void *);
// void ProcessVehicleHorn(cVehicleParams *params);
// void ProcessVehicleOneShots(void *);
// bool ProcessVehicleReverseWarning(void *);
// bool ProcessVehicleRoadNoise(void *);
bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok
bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok
// void ProcessVehicleSirenOrAlarm(void *);
// void ProcessVehicleSkidding(void *);
void ProcessWaterCannon(int32); // todo
void ProcessWeather(int32 id); // todo
// bool ProcessWetRoadNoise(void *);
void ProcessWorkShopScriptObject(uint8 sound); /// ok
void ProcessWaterCannon(int32); // todo
void ProcessWeather(int32 id); // todo
bool ProcessWetRoadNoise(cVehicleParams *params); // todo hook
void ProcessWorkShopScriptObject(uint8 sound); /// ok
void SetupPedComments(cPedParams *params, uint32 sound); /// ok
};

View file

@ -158,14 +158,14 @@ release_existing()
if ( opened_samples[i] )
{
AIL_release_3D_sample_handle(opened_samples[i]);
opened_samples[i] = NULL;
opened_samples[i] = 0;
}
}
if ( opened_provider )
{
AIL_close_3D_provider(opened_provider);
opened_provider = NULL;
opened_provider = 0;
}
_fPrevEaxRatioDestination = 0.0f;
@ -879,7 +879,7 @@ cSampleManager::Initialise(void)
_maxSamples = 0;
opened_provider = NULL;
opened_provider = 0;
DIG = NULL;
for ( int32 i = 0; i < MAXCHANNELS; i++ )
@ -2020,10 +2020,9 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
uint32 i = 0;
if ( !_bIsMp3Active ) goto FIND_MP3TRACK;
do
{
if(_bIsMp3Active){
if ( ++_CurMP3Index >= nNumMP3s )
_CurMP3Index = 0;
@ -2059,21 +2058,15 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
AIL_pause_stream(mp3Stream[nStream], 0);
return true;
}
goto NEXT_MP3TRACK;
FIND_MP3TRACK:
if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
position = 0;
tMP3Entry *e;
if ( !_GetMP3PosFromStreamPos(&position, &e) )
{
if ( e == NULL )
{
nFile = 0;
goto PLAY_STREAMEDTRACK;
}
}
if(nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]) position = 0;
tMP3Entry *e;
if(!_GetMP3PosFromStreamPos(&position, &e)) {
if(e == NULL) {
nFile = 0;
goto PLAY_STREAMEDTRACK;
}
}
if ( e->pLinkPath != NULL )
@ -2097,14 +2090,12 @@ FIND_MP3TRACK:
return true;
}
NEXT_MP3TRACK:
_bIsMp3Active = false;
} while ( ++i < nNumMP3s );
position = 0;
nFile = 0;
goto PLAY_STREAMEDTRACK;
}
PLAY_STREAMEDTRACK:

View file

@ -340,7 +340,7 @@ CCarCtrl::GenerateOneRandomCar()
if (distanceBetweenNodes / 2 < carLength)
positionBetweenNodes = 0.5f;
else
positionBetweenNodes = min(1.0f - carLength / distanceBetweenNodes, max(carLength / distanceBetweenNodes, positionBetweenNodes));
positionBetweenNodes = Min(1.0f - carLength / distanceBetweenNodes, Max(carLength / distanceBetweenNodes, positionBetweenNodes));
pCar->AutoPilot.m_nNextDirection = (curNodeId >= nextNodeId) ? 1 : -1;
if (pCurNode->numLinks == 1){
/* Do not create vehicle if there is nowhere to go. */
@ -793,10 +793,10 @@ CCarCtrl::FindMaximumSpeedForThisCarInTraffic(CVehicle* pVehicle)
float right = pVehicle->GetPosition().x + DISTANCE_TO_SCAN_FOR_DANGER;
float top = pVehicle->GetPosition().y - DISTANCE_TO_SCAN_FOR_DANGER;
float bottom = pVehicle->GetPosition().y + DISTANCE_TO_SCAN_FOR_DANGER;
int xstart = max(0, CWorld::GetSectorIndexX(left));
int xend = min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(right));
int ystart = max(0, CWorld::GetSectorIndexY(top));
int yend = min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(bottom));
int xstart = Max(0, CWorld::GetSectorIndexX(left));
int xend = Min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(right));
int ystart = Max(0, CWorld::GetSectorIndexY(top));
int yend = Min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(bottom));
assert(xstart <= xend);
assert(ystart <= yend);
@ -827,10 +827,10 @@ CCarCtrl::ScanForPedDanger(CVehicle* pVehicle)
float right = pVehicle->GetPosition().x + DISTANCE_TO_SCAN_FOR_DANGER;
float top = pVehicle->GetPosition().y - DISTANCE_TO_SCAN_FOR_DANGER;
float bottom = pVehicle->GetPosition().y + DISTANCE_TO_SCAN_FOR_DANGER;
int xstart = max(0, CWorld::GetSectorIndexX(left));
int xend = min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(right));
int ystart = max(0, CWorld::GetSectorIndexY(top));
int yend = min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(bottom));
int xstart = Max(0, CWorld::GetSectorIndexX(left));
int xend = Min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(right));
int ystart = Max(0, CWorld::GetSectorIndexY(top));
int yend = Min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(bottom));
assert(xstart <= xend);
assert(ystart <= yend);
@ -862,12 +862,12 @@ CCarCtrl::SlowCarOnRailsDownForTrafficAndLights(CVehicle* pVehicle)
float curSpeed = pVehicle->AutoPilot.m_fMaxTrafficSpeed;
if (maxSpeed >= curSpeed){
if (maxSpeed > curSpeed)
pVehicle->AutoPilot.ModifySpeed(min(maxSpeed, curSpeed + 0.05f * CTimer::GetTimeStep()));
pVehicle->AutoPilot.ModifySpeed(Min(maxSpeed, curSpeed + 0.05f * CTimer::GetTimeStep()));
}else{
if (curSpeed == 0.0f)
return;
if (curSpeed >= 0.1f)
pVehicle->AutoPilot.ModifySpeed(max(maxSpeed, curSpeed - 0.5f * CTimer::GetTimeStep()));
pVehicle->AutoPilot.ModifySpeed(Max(maxSpeed, curSpeed - 0.5f * CTimer::GetTimeStep()));
else if (curSpeed != 0.0f) /* no need to check */
pVehicle->AutoPilot.ModifySpeed(0.0f);
}

View file

@ -157,7 +157,7 @@ void CCarGenerator::Setup(float x, float y, float z, float angle, int32 mi, int1
m_bIsBlocking = false;
m_vecInf = CModelInfo::GetModelInfo(m_nModelIndex)->GetColModel()->boundingBox.min;
m_vecSup = CModelInfo::GetModelInfo(m_nModelIndex)->GetColModel()->boundingBox.max;
m_fSize = max(m_vecInf.Magnitude(), m_vecSup.Magnitude());
m_fSize = Max(m_vecInf.Magnitude(), m_vecSup.Magnitude());
}
bool CCarGenerator::CheckForBlockage()

View file

@ -68,7 +68,7 @@ bool CGarages::HasCarBeenCrushed(int32 handle)
return CrushedCarId == handle;
}
WRAPPER void CGarages::TriggerMessage(char *text, int16, uint16 time, int16) { EAXJMP(0x426B20); }
WRAPPER void CGarages::TriggerMessage(const char *text, int16, uint16 time, int16) { EAXJMP(0x426B20); }
WRAPPER bool CGarages::IsPointWithinHideOutGarage(CVector*) { EAXJMP(0x428260); }
#if 0
@ -97,7 +97,7 @@ void CGarages::PrintMessages()
CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, -1, -1, -1, -1, -1, gUString);
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(-84.0f + 2.0 - 40.0f), gUString);
CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(-84.0f + 2.0f - 40.0f), gUString);
CFont::SetColor(CRGBA(89, 115, 150, 255));
CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(-84.0f - 40.0f), gUString);
@ -107,7 +107,7 @@ void CGarages::PrintMessages()
CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString);
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(-84.0f + 2.0 - 40.0f), gUString);
CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(-84.0f + 2.0f - 40.0f), gUString);
CFont::SetColor(CRGBA(89, 115, 150, 255));
CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(-84.0f - 40.0f), gUString);

View file

@ -22,7 +22,7 @@ public:
public:
static bool IsModelIndexADoor(uint32 id);
static void TriggerMessage(char *text, int16, uint16 time, int16);
static void TriggerMessage(const char *text, int16, uint16 time, int16);
static void PrintMessages(void);
static bool HasCarBeenCrushed(int32);
static bool IsPointWithinHideOutGarage(CVector*);

View file

@ -207,8 +207,8 @@ CPathFind::PreparePathData(void)
numExtern++;
if(InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes > numLanes)
numLanes = InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes;
maxX = max(maxX, Abs(InfoForTileCars[k].x));
maxY = max(maxY, Abs(InfoForTileCars[k].y));
maxX = Max(maxX, Abs(InfoForTileCars[k].x));
maxY = Max(maxY, Abs(InfoForTileCars[k].y));
}else if(InfoForTileCars[k].type == NodeTypeIntern)
numIntern++;
}
@ -392,7 +392,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
if(Abs(dx) < nearestDist){
dy = tempnodes[k].pos.y - CoorsXFormed.y;
if(Abs(dy) < nearestDist){
nearestDist = max(Abs(dx), Abs(dy));
nearestDist = Max(Abs(dx), Abs(dy));
nearestId = k;
}
}
@ -501,13 +501,13 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
// Find i inside path segment
iseg = 0;
for(j = max(oldNumPathNodes, i-12); j < i; j++)
for(j = Max(oldNumPathNodes, i-12); j < i; j++)
if(m_pathNodes[j].objectIndex == m_pathNodes[i].objectIndex)
iseg++;
istart = 12*m_mapObjects[m_pathNodes[i].objectIndex]->m_modelIndex;
// Add links to other internal nodes
for(j = max(oldNumPathNodes, i-12); j < min(m_numPathNodes, i+12); j++){
for(j = Max(oldNumPathNodes, i-12); j < Min(m_numPathNodes, i+12); j++){
if(m_pathNodes[i].objectIndex != m_pathNodes[j].objectIndex || i == j)
continue;
// N.B.: in every path segment, the externals have to be at the end
@ -1263,7 +1263,9 @@ CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode
static CPathNode *apNodesToBeCleared[4995];
void
CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector target, CPathNode **nodes, int16 *pNumNodes, int16 maxNumNodes, CVehicle *vehicle, float *pDist, float distLimit, int32 forcedTargetNode)
CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector target,
CPathNode **nodes, int16 *pNumNodes, int16 maxNumNodes, CVehicle *vehicle,
float *pDist, float distLimit, int32 forcedTargetNode)
{
int i, j;
@ -1273,41 +1275,51 @@ 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;
}
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;
for(i = 0; i < 512; i++) m_searchNodes[i].next = nil;
AddNodeToList(&m_pathNodes[targetNode], 0);
int numNodesToBeCleared = 0;
apNodesToBeCleared[numNodesToBeCleared++] = &m_pathNodes[targetNode];
@ -1383,11 +1395,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

@ -342,7 +342,7 @@ void CReplay::StorePedUpdate(CPed *ped, int id)
tPedUpdatePacket* pp = (tPedUpdatePacket*)&Record.m_pBase[Record.m_nOffset];
pp->type = REPLAYPACKET_PED_UPDATE;
pp->index = id;
pp->heading = 128.0f / M_PI * ped->m_fRotationCur;
pp->heading = 128.0f / PI * ped->m_fRotationCur;
pp->matrix.CompressFromFullMatrix(ped->GetMatrix());
pp->assoc_group_id = ped->m_animGroup;
/* Would be more sane to use GetJustIndex(ped->m_pMyVehicle) in following assignment */
@ -366,8 +366,8 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
CAnimBlendAssociation* main = RpAnimBlendClumpGetMainAssociation((RpClump*)ped->m_rwObject, &second, &blend_amount);
if (main){
state->animId = main->animId;
state->time = 255.0f / 4.0f * max(0.0f, min(4.0f, main->currentTime));
state->speed = 255.0f / 3.0f * max(0.0f, min(3.0f, main->speed));
state->time = 255.0f / 4.0f * Max(0.0f, Min(4.0f, main->currentTime));
state->speed = 255.0f / 3.0f * Max(0.0f, Min(3.0f, main->speed));
}else{
state->animId = 3;
state->time = 0;
@ -375,9 +375,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
}
if (second) {
state->secAnimId = second->animId;
state->secTime = 255.0f / 4.0f * max(0.0f, min(4.0f, second->currentTime));
state->secSpeed = 255.0f / 3.0f * max(0.0f, min(3.0f, second->speed));
state->blendAmount = 255.0f / 2.0f * max(0.0f, min(2.0f, blend_amount));
state->secTime = 255.0f / 4.0f * Max(0.0f, Min(4.0f, second->currentTime));
state->secSpeed = 255.0f / 3.0f * Max(0.0f, Min(3.0f, second->speed));
state->blendAmount = 255.0f / 2.0f * Max(0.0f, Min(2.0f, blend_amount));
}else{
state->secAnimId = 0;
state->secTime = 0;
@ -387,9 +387,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject);
if (partial) {
state->partAnimId = partial->animId;
state->partAnimTime = 255.0f / 4.0f * max(0.0f, min(4.0f, partial->currentTime));
state->partAnimSpeed = 255.0f / 3.0f * max(0.0f, min(3.0f, partial->speed));
state->partBlendAmount = 255.0f / 2.0f * max(0.0f, min(2.0f, partial->blendAmount));
state->partAnimTime = 255.0f / 4.0f * Max(0.0f, Min(4.0f, partial->currentTime));
state->partAnimSpeed = 255.0f / 3.0f * Max(0.0f, Min(3.0f, partial->speed));
state->partBlendAmount = 255.0f / 2.0f * Max(0.0f, Min(2.0f, partial->blendAmount));
}else{
state->partAnimId = 0;
state->partAnimTime = 0;
@ -408,9 +408,9 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainAssociation_N((RpClump*)ped->m_rwObject, i);
if (assoc){
state->aAnimId[i] = assoc->animId;
state->aCurTime[i] = 255.0f / 4.0f * max(0.0f, min(4.0f, assoc->currentTime));
state->aSpeed[i] = 255.0f / 3.0f * max(0.0f, min(3.0f, assoc->speed));
state->aBlendAmount[i] = 255.0f / 2.0f * max(0.0f, min(2.0f, assoc->blendAmount));
state->aCurTime[i] = 255.0f / 4.0f * Max(0.0f, Min(4.0f, assoc->currentTime));
state->aSpeed[i] = 255.0f / 3.0f * Max(0.0f, Min(3.0f, assoc->speed));
state->aBlendAmount[i] = 255.0f / 2.0f * Max(0.0f, Min(2.0f, assoc->blendAmount));
state->aFlags[i] = assoc->flags;
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
state->aFunctionCallbackID[i] = FindCBFunctionID(assoc->callback);
@ -431,9 +431,9 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainPartialAssociation_N((RpClump*)ped->m_rwObject, i);
if (assoc) {
state->aAnimId2[i] = assoc->animId;
state->aCurTime2[i] = 255.0f / 4.0f * max(0.0f, min(4.0f, assoc->currentTime));
state->aSpeed2[i] = 255.0f / 3.0f * max(0.0f, min(3.0f, assoc->speed));
state->aBlendAmount2[i] = 255.0f / 2.0f * max(0.0f, min(2.0f, assoc->blendAmount));
state->aCurTime2[i] = 255.0f / 4.0f * Max(0.0f, Min(4.0f, assoc->currentTime));
state->aSpeed2[i] = 255.0f / 3.0f * Max(0.0f, Min(3.0f, assoc->speed));
state->aBlendAmount2[i] = 255.0f / 2.0f * Max(0.0f, Min(2.0f, assoc->blendAmount));
state->aFlags2[i] = assoc->flags;
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
state->aFunctionCallbackID2[i] = FindCBFunctionID(assoc->callback);
@ -464,8 +464,8 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB
buffer->m_nOffset += sizeof(tPedUpdatePacket);
return;
}
ped->m_fRotationCur = pp->heading * M_PI / 128.0f;
ped->m_fRotationDest = pp->heading * M_PI / 128.0f;
ped->m_fRotationCur = pp->heading * PI / 128.0f;
ped->m_fRotationDest = pp->heading * PI / 128.0f;
CMatrix ped_matrix;
pp->matrix.DecompressIntoFullMatrix(ped_matrix);
ped->GetMatrix() = ped->GetMatrix() * CMatrix(1.0f - interpolation);
@ -625,24 +625,24 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */
vp->acceleration = vehicle->m_fGasPedal * 100.0f;
vp->panels = vehicle->IsCar() ? ((CAutomobile*)vehicle)->Damage.m_panelStatus : 0;
vp->velocityX = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */
vp->velocityY = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetMoveSpeed().y));
vp->velocityZ = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetMoveSpeed().z));
vp->velocityX = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */
vp->velocityY = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().y));
vp->velocityZ = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().z));
vp->mi = vehicle->GetModelIndex();
vp->primary_color = vehicle->m_currentColour1;
vp->secondary_color = vehicle->m_currentColour2;
if (vehicle->GetModelIndex() == MI_RHINO)
vp->car_gun = 128.0f / M_PI * ((CAutomobile*)vehicle)->m_fCarGunLR;
vp->car_gun = 128.0f / PI * ((CAutomobile*)vehicle)->m_fCarGunLR;
else
vp->wheel_state = 50.0f * vehicle->m_fSteerAngle;
if (vehicle->IsCar()){
CAutomobile* car = (CAutomobile*)vehicle;
for (int i = 0; i < 4; i++){
vp->wheel_susp_dist[i] = 50.0f * car->m_aSuspensionSpringRatio[i];
vp->wheel_rotation[i] = 128.0f / M_PI * car->m_aWheelRotation[i];
vp->wheel_rotation[i] = 128.0f / PI * car->m_aWheelRotation[i];
}
vp->door_angles[0] = 127.0f / M_PI * car->Doors[2].m_fAngle;
vp->door_angles[1] = 127.0f / M_PI * car->Doors[3].m_fAngle;
vp->door_angles[0] = 127.0f / PI * car->Doors[2].m_fAngle;
vp->door_angles[1] = 127.0f / PI * car->Doors[3].m_fAngle;
vp->door_status = 0;
for (int i = 0; i < 6; i++){
if (car->Damage.GetDoorStatus(i) == 3)
@ -675,7 +675,7 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
ApplyPanelDamageToCar(vp->panels, (CAutomobile*)vehicle, true);
vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f);
if (vehicle->GetModelIndex() == MI_RHINO) {
((CAutomobile*)vehicle)->m_fCarGunLR = vp->car_gun * M_PI / 128.0f;
((CAutomobile*)vehicle)->m_fCarGunLR = vp->car_gun * PI / 128.0f;
vehicle->m_fSteerAngle = 0.0f;
}else{
vehicle->m_fSteerAngle = vp->wheel_state / 50.0f;
@ -684,10 +684,10 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
CAutomobile* car = (CAutomobile*)vehicle;
for (int i = 0; i < 4; i++) {
car->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
car->m_aWheelRotation[i] = vp->wheel_rotation[i] * M_PI / 128.0f;
car->m_aWheelRotation[i] = vp->wheel_rotation[i] * PI / 128.0f;
}
car->Doors[2].m_fAngle = car->Doors[2].m_fPrevAngle = vp->door_angles[0] * M_PI / 127.0f;
car->Doors[3].m_fAngle = car->Doors[3].m_fPrevAngle = vp->door_angles[1] * M_PI / 127.0f;
car->Doors[2].m_fAngle = car->Doors[2].m_fPrevAngle = vp->door_angles[0] * PI / 127.0f;
car->Doors[3].m_fAngle = car->Doors[3].m_fPrevAngle = vp->door_angles[1] * PI / 127.0f;
if (vp->door_angles[0])
car->Damage.SetDoorStatus(2, 2);
if (vp->door_angles[1])
@ -1501,9 +1501,9 @@ void CReplay::ProcessLookAroundCam(void)
--FramesActiveLookAroundCam;
fBetaAngleLookAroundCam += x_moved;
if (CPad::NewMouseControllerState.LMB && CPad::NewMouseControllerState.RMB)
fDistanceLookAroundCam = max(3.0f, min(15.0f, fDistanceLookAroundCam + 2.0f * y_moved));
fDistanceLookAroundCam = Max(3.0f, Min(15.0f, fDistanceLookAroundCam + 2.0f * y_moved));
else
fAlphaAngleLookAroundCam = max(0.1f, min(1.5f, fAlphaAngleLookAroundCam + y_moved));
fAlphaAngleLookAroundCam = Max(0.1f, Min(1.5f, fAlphaAngleLookAroundCam + y_moved));
CVector camera_pt(
fDistanceLookAroundCam * Sin(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam),
fDistanceLookAroundCam * Cos(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam),

View file

@ -1987,7 +1987,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
car->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS;
car->m_status = STATUS_PHYSICS;
car->bEngineOn = true;
car->AutoPilot.m_nCruiseSpeed = max(car->AutoPilot.m_nCruiseSpeed, 6);
car->AutoPilot.m_nCruiseSpeed = Max(car->AutoPilot.m_nCruiseSpeed, 6);
car->AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds();
return 0;
}
@ -1999,7 +1999,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CCarCtrl::JoinCarWithRoadSystem(car);
car->AutoPilot.m_nCarMission = MISSION_CRUISE;
car->bEngineOn = true;
car->AutoPilot.m_nCruiseSpeed = max(car->AutoPilot.m_nCruiseSpeed, 6);
car->AutoPilot.m_nCruiseSpeed = Max(car->AutoPilot.m_nCruiseSpeed, 6);
car->AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds();
return 0;
}
@ -2083,7 +2083,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CollectParameters(&m_nIp, 2);
CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(car);
car->AutoPilot.m_nCruiseSpeed = min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fUnkMaxVelocity);
car->AutoPilot.m_nCruiseSpeed = Min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fUnkMaxVelocity);
return 0;
}
case COMMAND_SET_CAR_DRIVING_STYLE:

View file

@ -209,7 +209,7 @@ WellBufferMe(float Target, float *CurrentValue, float *CurrentSpeed, float MaxSp
else if(TargetSpeed > 0.0f && *CurrentSpeed > TargetSpeed)
*CurrentSpeed = TargetSpeed;
*CurrentValue += *CurrentSpeed * min(10.0f, CTimer::GetTimeStep());
*CurrentValue += *CurrentSpeed * Min(10.0f, CTimer::GetTimeStep());
}
void
@ -697,7 +697,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
// Process height offset to avoid peds and cars
float TargetZOffSet = m_fUnknownZOffSet + m_fDimensionOfHighestNearCar;
TargetZOffSet = max(TargetZOffSet, m_fPedBetweenCameraHeightOffset);
TargetZOffSet = Max(TargetZOffSet, m_fPedBetweenCameraHeightOffset);
float TargetHeight = CameraTarget.z + TargetZOffSet - Source.z;
if(TargetHeight > m_fCamBufferedHeight){
@ -753,7 +753,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
}
}
TargetCoors.z += min(1.0f, m_fCamBufferedHeight/2.0f);
TargetCoors.z += Min(1.0f, m_fCamBufferedHeight/2.0f);
m_cvecTargetCoorsForFudgeInter = TargetCoors;
Front = TargetCoors - Source;
@ -991,7 +991,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
}
if(FoundCamRoof){
// Camera is under something
float roof = FoundRoofCenter ? min(CamRoof, CarRoof) : CamRoof;
float roof = FoundRoofCenter ? Min(CamRoof, CarRoof) : CamRoof;
// Same weirdness again?
TargetAlpha = CGeneral::GetATanOfXY(CA_MAX_DISTANCE, roof - CamTargetZ - 1.5f);
CamClear = false;
@ -1249,7 +1249,7 @@ void
CCam::Cam_On_A_String_Unobscured(const CVector &TargetCoors, float BaseDist)
{
CA_MAX_DISTANCE = BaseDist + 0.1f + TheCamera.CarZoomValueSmooth;
CA_MIN_DISTANCE = min(BaseDist*0.6f, 3.5f);
CA_MIN_DISTANCE = Min(BaseDist*0.6f, 3.5f);
CVector Dist = Source - TargetCoors;

View file

@ -153,10 +153,10 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
// on water we expect to be between levels
multipleLevels = true;
}else{
xmin = max(sx - 1, 0);
xmax = min(sx + 1, NUMSECTORS_X-1);
ymin = max(sy - 1, 0);
ymax = min(sy + 1, NUMSECTORS_Y-1);
xmin = Max(sx - 1, 0);
xmax = Min(sx + 1, NUMSECTORS_X-1);
ymin = Max(sy - 1, 0);
ymax = Min(sy + 1, NUMSECTORS_Y-1);
for(x = xmin; x <= xmax; x++)
for(y = ymin; y <= ymax; y++){

View file

@ -248,15 +248,15 @@ CFileMgr::OpenFileForWriting(const char *file)
}
int
CFileMgr::Read(int fd, char *buf, int len)
CFileMgr::Read(int fd, const char *buf, int len)
{
return myfread(buf, 1, len, fd);
return myfread((void*)buf, 1, len, fd);
}
int
CFileMgr::Write(int fd, char *buf, int len)
CFileMgr::Write(int fd, const char *buf, int len)
{
return myfwrite(buf, 1, len, fd);
return myfwrite((void*)buf, 1, len, fd);
}
bool

View file

@ -12,8 +12,8 @@ public:
static int LoadFile(const char *file, uint8 *buf, int unused, const char *mode);
static int OpenFile(const char *file, const char *mode);
static int OpenFileForWriting(const char *file);
static int Read(int fd, char *buf, int len);
static int Write(int fd, char *buf, int len);
static int Read(int fd, const char *buf, int len);
static int Write(int fd, const char *buf, int len);
static bool Seek(int fd, int offset, int whence);
static bool ReadLine(int fd, char *buf, int len);
static int CloseFile(int fd);

View file

@ -95,7 +95,7 @@ bool GetMouseMoveRight();
bool GetPadInput();
bool GetMouseInput();
char *FrontendFilenames[] = {
const char *FrontendFilenames[] = {
"fe2_mainpanel_ul",
"fe2_mainpanel_ur",
"fe2_mainpanel_dl",
@ -126,7 +126,7 @@ char *FrontendFilenames[] = {
"fe_radio9", // CHATTERBOX
};
char *MenuFilenames[] = {
const char *MenuFilenames[] = {
"connection24", "",
"findgame24", "",
"hostgame24", "",
@ -1030,7 +1030,7 @@ int CMenuManager::FadeIn(int alpha)
m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS ||
m_nCurrScreen == MENUPAGE_DELETING)
return alpha;
return min(m_nMenuFadeAlpha, alpha);
return Min(m_nMenuFadeAlpha, alpha);
}
#endif

View file

@ -97,7 +97,7 @@ public:
}
// should return direction in 0-8 range. fits perfectly to peds' path directions.
static int CGeneral::GetNodeHeadingFromVector(float x, float y)
static int GetNodeHeadingFromVector(float x, float y)
{
float angle = CGeneral::GetRadianAngleBetweenPoints(x, y, 0.0f, 0.0f);
if (angle < 0.0f)

View file

@ -17,10 +17,10 @@ void CIniFile::LoadIniFile()
if (f){
CFileMgr::ReadLine(f, gString, 200);
sscanf(gString, "%f", &PedNumberMultiplier);
PedNumberMultiplier = min(3.0f, max(0.5f, PedNumberMultiplier));
PedNumberMultiplier = Min(3.0f, Max(0.5f, PedNumberMultiplier));
CFileMgr::ReadLine(f, gString, 200);
sscanf(gString, "%f", &CarNumberMultiplier);
CarNumberMultiplier = min(3.0f, max(0.5f, CarNumberMultiplier));
CarNumberMultiplier = Min(3.0f, Max(0.5f, CarNumberMultiplier));
CFileMgr::CloseFile(f);
}
CPopulation::MaxNumberOfPedsInUse = 25.0f * PedNumberMultiplier;

View file

@ -299,10 +299,10 @@ CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &Stat
{ if ( State1.button || State2.button ) ReconState.button = 255; }
#define _RECONCILE_AXIS_POSITIVE(axis) \
{ if ( State1.axis >= 0 && State2.axis >= 0 ) ReconState.axis = max(State1.axis, State2.axis); }
{ if ( State1.axis >= 0 && State2.axis >= 0 ) ReconState.axis = Max(State1.axis, State2.axis); }
#define _RECONCILE_AXIS_NEGATIVE(axis) \
{ if ( State1.axis <= 0 && State2.axis <= 0 ) ReconState.axis = min(State1.axis, State2.axis); }
{ if ( State1.axis <= 0 && State2.axis <= 0 ) ReconState.axis = Min(State1.axis, State2.axis); }
#define _RECONCILE_AXIS(axis) \
{ _RECONCILE_AXIS_POSITIVE(axis); _RECONCILE_AXIS_NEGATIVE(axis); }

View file

@ -1940,7 +1940,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
if(mi->m_type != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())){
lodDistSq = sq(mi->GetLargestLodDistance());
lodDistSq = min(lodDistSq, sq(STREAM_DIST));
lodDistSq = Min(lodDistSq, sq(STREAM_DIST));
pos = CVector2D(e->GetPosition());
if(xmin < pos.x && pos.x < xmax &&
ymin < pos.y && pos.y < ymax &&
@ -2160,20 +2160,20 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
if(Abs(TheCamera.GetForward().x) > Abs(TheCamera.GetForward().y)){
// looking west/east
ymin = max(iy - 10, 0);
ymax = min(iy + 10, NUMSECTORS_Y);
ymin = Max(iy - 10, 0);
ymax = Min(iy + 10, NUMSECTORS_Y);
assert(ymin <= ymax);
// Delete a block of sectors that we know is behind the camera
if(TheCamera.GetForward().x > 0){
// looking east
xmax = max(ix - 2, 0);
xmin = max(ix - 10, 0);
xmax = Max(ix - 2, 0);
xmin = Max(ix - 10, 0);
inc = 1;
}else{
// looking west
xmax = min(ix + 2, NUMSECTORS_X);
xmin = min(ix + 10, NUMSECTORS_X);
xmax = Min(ix + 2, NUMSECTORS_X);
xmin = Min(ix + 10, NUMSECTORS_X);
inc = -1;
}
for(y = ymin; y <= ymax; y++){
@ -2189,13 +2189,13 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
// Now a block that intersects with the camera's frustum
if(TheCamera.GetForward().x > 0){
// looking east
xmax = max(ix + 10, 0);
xmin = max(ix - 2, 0);
xmax = Max(ix + 10, 0);
xmin = Max(ix - 2, 0);
inc = 1;
}else{
// looking west
xmax = min(ix - 10, NUMSECTORS_X);
xmin = min(ix + 2, NUMSECTORS_X);
xmax = Min(ix - 10, NUMSECTORS_X);
xmin = Min(ix + 2, NUMSECTORS_X);
inc = -1;
}
for(y = ymin; y <= ymax; y++){
@ -2224,20 +2224,20 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
}else{
// looking north/south
xmin = max(ix - 10, 0);
xmax = min(ix + 10, NUMSECTORS_X);
xmin = Max(ix - 10, 0);
xmax = Min(ix + 10, NUMSECTORS_X);
assert(xmin <= xmax);
// Delete a block of sectors that we know is behind the camera
if(TheCamera.GetForward().y > 0){
// looking north
ymax = max(iy - 2, 0);
ymin = max(iy - 10, 0);
ymax = Max(iy - 2, 0);
ymin = Max(iy - 10, 0);
inc = 1;
}else{
// looking south
ymax = min(iy + 2, NUMSECTORS_Y);
ymin = min(iy + 10, NUMSECTORS_Y);
ymax = Min(iy + 2, NUMSECTORS_Y);
ymin = Min(iy + 10, NUMSECTORS_Y);
inc = -1;
}
for(x = xmin; x <= xmax; x++){
@ -2253,13 +2253,13 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
// Now a block that intersects with the camera's frustum
if(TheCamera.GetForward().y > 0){
// looking north
ymax = max(iy + 10, 0);
ymin = max(iy - 2, 0);
ymax = Max(iy + 10, 0);
ymin = Max(iy - 2, 0);
inc = 1;
}else{
// looking south
ymax = min(iy - 10, NUMSECTORS_Y);
ymin = min(iy + 2, NUMSECTORS_Y);
ymax = Min(iy - 10, NUMSECTORS_Y);
ymin = Min(iy + 2, NUMSECTORS_Y);
inc = -1;
}
for(x = xmin; x <= xmax; x++){

View file

@ -209,7 +209,7 @@ CWanted::ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesnt
else
sensitivity = m_fCrimeSensitivity;
wantedLevelDrop = min(CCullZones::GetWantedLevelDrop(), 100);
wantedLevelDrop = Min(CCullZones::GetWantedLevelDrop(), 100);
chaos = (1.0f - wantedLevelDrop/100.0f) * sensitivity;
if (policeDoesntCare)

View file

@ -156,7 +156,7 @@ public:
inline float sq(float x) { return x*x; }
#define SQR(x) ((x) * (x))
#define PI M_PI
#define PI (float)M_PI
#define TWOPI (PI*2)
#define HALFPI (PI/2)
#define DEGTORAD(x) ((x) * PI / 180.0f)
@ -171,8 +171,8 @@ inline float sq(float x) { return x*x; }
int myrand(void);
void mysrand(unsigned int seed);
void re3_debug(char *format, ...);
void re3_trace(const char *filename, unsigned int lineno, const char *func, char *format, ...);
void re3_debug(const char *format, ...);
void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...);
void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func);
#define DEBUGBREAK() __debugbreak();
@ -195,8 +195,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))
#define Max(a, b) (((a) > (b)) ? (a) : (b))
#define Min(a, b) (((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)))))

View file

@ -453,7 +453,7 @@ DoFade(void)
CRGBA fadeColor;
CRect rect;
int fadeValue = CDraw::FadeValue;
float brightness = min(CMenuManager::m_PrefsBrightness, 256);
float brightness = Min(CMenuManager::m_PrefsBrightness, 256);
if(brightness <= 50)
brightness = 50;
if(FrontEndMenuManager.m_bMenuActive)

View file

@ -425,7 +425,7 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
abort();
}
void re3_debug(char *format, ...)
void re3_debug(const char *format, ...)
{
va_list va;
va_start(va, format);
@ -435,7 +435,7 @@ void re3_debug(char *format, ...)
printf("%s", re3_buff);
}
void re3_trace(const char *filename, unsigned int lineno, const char *func, char *format, ...)
void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...)
{
char buff[re3_buffsize *2];
va_list va;

View file

@ -457,7 +457,7 @@ CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector &
{
float compression = 1.0f - springRatio;
if(compression > 0.0f){
float step = min(CTimer::GetTimeStep(), 3.0f);
float step = Min(CTimer::GetTimeStep(), 3.0f);
float impulse = -GRAVITY*m_fMass*step * springConst * compression * bias*2.0f;
ApplyMoveForce(springDir*impulse);
ApplyTurnForce(springDir*impulse, point);
@ -471,12 +471,12 @@ CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &poin
{
float speedA = DotProduct(speed, springDir);
float speedB = DotProduct(GetSpeed(point), springDir);
float step = min(CTimer::GetTimeStep(), 3.0f);
float step = Min(CTimer::GetTimeStep(), 3.0f);
float impulse = -damping * (speedA + speedB)/2.0f * m_fMass * step * 0.53f;
// what is this?
float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass);
a = min(a, 1.0f);
a = Min(a, 1.0f);
float b = Abs(impulse / (speedB * m_fMass));
if(a < b)
impulse *= a/b;
@ -646,7 +646,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
// positive if B is moving towards A
// not interested in how much B moves into A apparently?
// only interested in cases where A collided into B
speedB = max(0.0f, DotProduct(B->m_vecMoveSpeed, colpoint.normal));
speedB = Max(0.0f, DotProduct(B->m_vecMoveSpeed, colpoint.normal));
// A has moved into B
if(speedA < speedB){
if(!A->bHasHitWall)
@ -1147,18 +1147,18 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CVector dir = A->GetPosition() - B->GetPosition();
dir.Normalise();
if(dir.z < 0.0f && dir.z < A->GetForward().z && dir.z < A->GetRight().z)
dir.z = min(0.0f, min(A->GetForward().z, A->GetRight().z));
dir.z = Min(0.0f, Min(A->GetForward().z, A->GetRight().z));
shift += dir * colpoints[mostColliding].depth * 0.5f;
}else if(A->IsPed() && B->IsVehicle() && ((CVehicle*)B)->IsBoat()){
CVector dir = colpoints[mostColliding].normal;
float f = min(Abs(dir.z), 0.9f);
float f = Min(Abs(dir.z), 0.9f);
dir.z = 0.0f;
dir.Normalise();
shift += dir * colpoints[mostColliding].depth / (1.0f - f);
boat = B;
}else if(B->IsPed() && A->IsVehicle() && ((CVehicle*)A)->IsBoat()){
CVector dir = colpoints[mostColliding].normal * -1.0f;
float f = min(Abs(dir.z), 0.9f);
float f = Min(Abs(dir.z), 0.9f);
dir.z = 0.0f;
dir.Normalise();
B->GetPosition() += dir * colpoints[mostColliding].depth / (1.0f - f);
@ -1246,7 +1246,7 @@ collision:
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
}
}else if(A->bHasContacted){
CVector savedMoveFriction = A->m_vecMoveFriction;
@ -1268,7 +1268,7 @@ collision:
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@ -1301,7 +1301,7 @@ collision:
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@ -1328,7 +1328,7 @@ collision:
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@ -1506,7 +1506,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, Max(turnSpeedDiff, moveSpeedDiff));
}
}else{
for(i = 0; i < numCollisions; i++){
@ -1527,7 +1527,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, Max(turnSpeedDiff, moveSpeedDiff));
float adhesion = CSurfaceTable::GetAdhesiveLimit(aColPoints[i]) / numCollisions;
@ -1545,7 +1545,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
else if(A->GetUp().z > 0.3f)
adhesion = 0.0f;
else
adhesion *= min(5.0f, 0.03f*impulseA + 1.0f);
adhesion *= Min(5.0f, 0.03f*impulseA + 1.0f);
}
if(A->ApplyFriction(adhesion, aColPoints[i]))
@ -1594,7 +1594,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
}
}else if(A->bHasContacted){
CVector savedMoveFriction = A->m_vecMoveFriction;
@ -1619,7 +1619,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@ -1655,7 +1655,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@ -1685,7 +1685,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@ -1831,7 +1831,7 @@ CPhysical::ProcessCollision(void)
if(IsPed() && (distSq >= sq(0.2f) || ped->IsPlayer())){
if(ped->IsPlayer())
n = max(NUMSTEPS(0.2f), 2.0);
n = Max(NUMSTEPS(0.2f), 2.0);
else
n = NUMSTEPS(0.3f);
step = savedTimeStep / n;
@ -1852,7 +1852,7 @@ CPhysical::ProcessCollision(void)
speedDown = Multiply3x3(GetMatrix(), speedDown);
speedUp = GetSpeed(speedUp);
speedDown = GetSpeed(speedDown);
distSq = max(speedUp.MagnitudeSqr(), speedDown.MagnitudeSqr()) * sq(CTimer::GetTimeStep());
distSq = Max(speedUp.MagnitudeSqr(), speedDown.MagnitudeSqr()) * sq(CTimer::GetTimeStep());
if(distSq >= sq(0.3f)){
n = NUMSTEPS(0.3f);
step = savedTimeStep / n;

View file

@ -4,14 +4,14 @@
struct RwObjectNameIdAssocation
{
char *name;
const char *name;
int32 hierId;
uint32 flags;
};
struct RwObjectNameAssociation
{
char *name;
const char *name;
RwFrame *frame;
};

View file

@ -1038,7 +1038,7 @@ CVehicleModelInfo::SetEnvironmentMap(void)
void
CVehicleModelInfo::LoadEnvironmentMaps(void)
{
char *texnames[] = {
const char *texnames[] = {
"reflection01", // only one used
"reflection02",
"reflection03",

View file

@ -1792,7 +1792,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
neededPos.z = autoZPos.z;
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
} else if (neededPos.z <= currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) {
adjustedTimeStep = min(m_pVehicleAnim->timeStep, 0.1f);
adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f);
// Smoothly change ped position
neededPos.z = currentZ - (currentZ - neededPos.z) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep);
@ -1807,12 +1807,12 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (m_pVehicleAnim &&
(vehAnim == ANIM_CAR_GETIN_RHS || vehAnim == ANIM_CAR_GETIN_LOW_RHS || vehAnim == ANIM_CAR_GETIN_LHS || vehAnim == ANIM_CAR_GETIN_LOW_LHS
|| vehAnim == ANIM_CAR_QJACK || vehAnim == ANIM_VAN_GETIN_L || vehAnim == ANIM_VAN_GETIN)) {
adjustedTimeStep = min(m_pVehicleAnim->timeStep, 0.1f);
adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f);
// Smoothly change ped position
neededPos.z = (neededPos.z - currentZ) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep) + currentZ;
} else if (m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK) {
neededPos.z = max(currentZ, autoZPos.z);
neededPos.z = Max(currentZ, autoZPos.z);
}
}
}
@ -4622,7 +4622,7 @@ CPed::LoadFightData(void)
// Actually GetLocalDirectionTo(Turn/Look)
int
CPed::GetLocalDirection(CVector2D const &posOffset)
CPed::GetLocalDirection(const CVector2D &posOffset)
{
float direction;
@ -4771,12 +4771,12 @@ CPed::FightStrike(CVector &touchedNodePos)
float moveMult;
if (m_lastFightMove == FIGHTMOVE_GROUNDKICK) {
moveMult = min(damageMult * 0.6f, 4.0f);
moveMult = Min(damageMult * 0.6f, 4.0f);
} else {
if (nearPed->m_nPedState != PED_DIE || damageMult >= 20) {
moveMult = damageMult;
} else {
moveMult = min(damageMult * 2.0f, 14.0f);
moveMult = Min(damageMult * 2.0f, 14.0f);
}
}
@ -5434,7 +5434,7 @@ CPed::CreateDeadPedWeaponPickups(void)
pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f;
}
if (found)
CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, min(weaponAmmo, AmmoForWeapon_OnStreet[weapon]));
CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, Min(weaponAmmo, AmmoForWeapon_OnStreet[weapon]));
}
ClearWeapons();
}
@ -5443,7 +5443,7 @@ void
CPed::SetAttackTimer(uint32 time)
{
if (CTimer::GetTimeInMilliseconds() > m_attackTimer)
m_attackTimer = max(m_lastHitTime, CTimer::GetTimeInMilliseconds()) + time;
m_attackTimer = Max(m_lastHitTime, CTimer::GetTimeInMilliseconds()) + time;
}
void

View file

@ -575,7 +575,7 @@ public:
void StartFightAttack(uint8);
void SetWaitState(eWaitState, void*);
bool FightStrike(CVector&);
int GetLocalDirection(CVector2D const &);
int GetLocalDirection(const CVector2D &);
void StartFightDefend(uint8, uint8, uint8);
void PlayHitSound(CPed*);
void SetFall(int, AnimationId, uint8);

View file

@ -29,7 +29,7 @@ CPedPlacement::FindZCoorForPed(CVector* pos)
if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil))
foundColZ2 = foundCol.point.z;
zForPed = max(foundColZ, foundColZ2);
zForPed = Max(foundColZ, foundColZ2);
if (zForPed > -99.0f)
pos->z = 1.04f + zForPed;

View file

@ -388,7 +388,7 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
ms_colourBottom.b = topblue;
ms_colourBottom.a = alpha;
botpos = min(SCREEN_HEIGHT, topedge);
botpos = Min(SCREEN_HEIGHT, topedge);
CSprite2d::DrawRect(CRect(0, 0, SCREEN_WIDTH, botpos),
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
}
@ -415,18 +415,18 @@ CClouds::RenderHorizon(void)
if(ms_horizonZ > SCREEN_HEIGHT)
return;
float z1 = min(ms_horizonZ + SMALLSTRIPHEIGHT, SCREEN_HEIGHT);
float z1 = Min(ms_horizonZ + SMALLSTRIPHEIGHT, SCREEN_HEIGHT);
CSprite2d::DrawRectXLU(CRect(0, ms_horizonZ, SCREEN_WIDTH, z1),
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
// This is just weird
float a = SCREEN_HEIGHT/400.0f * HORIZSTRIPHEIGHT +
SCREEN_HEIGHT/300.0f * max(TheCamera.GetPosition().z, 0.0f);
SCREEN_HEIGHT/300.0f * Max(TheCamera.GetPosition().z, 0.0f);
float b = TheCamera.GetUp().z < 0.0f ?
SCREEN_HEIGHT :
SCREEN_HEIGHT * Abs(TheCamera.GetRight().z);
float z2 = z1 + (a + b)*TheCamera.LODDistMultiplier;
z2 = min(z2, SCREEN_HEIGHT);
z2 = Min(z2, SCREEN_HEIGHT);
CSprite2d::DrawRect(CRect(0, z1, SCREEN_WIDTH, z2),
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
}

View file

@ -109,7 +109,7 @@ CCoronas::Update(void)
int i;
static int LastCamLook = 0;
LightsMult = min(LightsMult + 0.03f * CTimer::GetTimeStep(), 1.0f);
LightsMult = Min(LightsMult + 0.03f * CTimer::GetTimeStep(), 1.0f);
int CamLook = 0;
if(TheCamera.Cams[TheCamera.ActiveCam].LookingLeft) CamLook |= 1;
@ -121,7 +121,7 @@ CCoronas::Update(void)
if(LastCamLook != CamLook)
bChangeBrightnessImmediately = 3;
else
bChangeBrightnessImmediately = max(bChangeBrightnessImmediately-1, 0);
bChangeBrightnessImmediately = Max(bChangeBrightnessImmediately-1, 0);
LastCamLook = CamLook;
for(i = 0; i < NUMCORONAS; i++)
@ -309,7 +309,7 @@ CCoronas::Render(void)
// render corona itself
if(aCoronas[i].texture){
float fogscale = CWeather::Foggyness*min(spriteCoors.z, 40.0f)/40.0f + 1.0f;
float fogscale = CWeather::Foggyness*Min(spriteCoors.z, 40.0f)/40.0f + 1.0f;
if(CCoronas::aCoronas[i].id == SUN_CORE)
spriteCoors.z = 0.95f * RwCameraGetFarClipPlane(Scene.camera);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(aCoronas[i].texture));
@ -320,7 +320,7 @@ CCoronas::Render(void)
float f = 1.0f - aCoronas[i].someAngle*2.0f/PI;
float wscale = 6.0f*sq(sq(sq(f))) + 0.5f;
float hscale = 0.35f - (wscale - 0.5f) * 0.06f;
hscale = max(hscale, 0.15f);
hscale = Max(hscale, 0.15f);
CSprite::RenderOneXLUSprite(spriteCoors.x, spriteCoors.y, spriteCoors.z,
spritew * aCoronas[i].size * wscale,
@ -467,7 +467,7 @@ CCoronas::RenderReflections(void)
float spritew, spriteh;
if(CSprite::CalcScreenCoors(coors, spriteCoors, &spritew, &spriteh, true)){
float drawDist = 0.75f * aCoronas[i].drawDist;
drawDist = min(drawDist, 50.0f);
drawDist = Min(drawDist, 50.0f);
if(spriteCoors.z < drawDist){
float fadeDistance = drawDist / 2.0f;
float distanceFade = spriteCoors.z < fadeDistance ? 1.0f : 1.0f - (spriteCoors.z - fadeDistance)/fadeDistance;
@ -546,25 +546,25 @@ CRegisteredCorona::Update(void)
(CCoronas::SunBlockedByClouds && id == CCoronas::SUN_CORONA ||
!CWorld::GetIsLineOfSightClear(coors, TheCamera.GetPosition(), true, false, false, false, false, false))){
// Corona is blocked, fade out
fadeAlpha = max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), 0.0f);
fadeAlpha = Max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), 0.0f);
}else if(offScreen){
// Same when off screen
fadeAlpha = max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), 0.0f);
fadeAlpha = Max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), 0.0f);
}else{
// Visible
if(alpha > fadeAlpha){
// fade in
fadeAlpha = min(fadeAlpha + 15.0f*CTimer::GetTimeStep(), alpha);
fadeAlpha = Min(fadeAlpha + 15.0f*CTimer::GetTimeStep(), alpha);
if(CCoronas::bChangeBrightnessImmediately)
fadeAlpha = alpha;
}else if(alpha < fadeAlpha){
// too visible, decrease alpha but not below alpha
fadeAlpha = max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), alpha);
fadeAlpha = Max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), alpha);
}
// darken scene when the sun is visible
if(id == CCoronas::SUN_CORONA)
CCoronas::LightsMult = max(CCoronas::LightsMult - CTimer::GetTimeStep()*0.06f, 0.6f);
CCoronas::LightsMult = Max(CCoronas::LightsMult - CTimer::GetTimeStep()*0.06f, 0.6f);
}
// remove if invisible

View file

@ -10,7 +10,7 @@
#include "Clock.h"
#include "Weather.h"
#include "Stats.h"
#include "math/maths.h"
#include "maths.h"
#include "Frontend.h"
uint8 ScrollCharSet[59][5] = {

View file

@ -1,6 +1,6 @@
#pragma once
#include "common.h"
#include "math/Vector.h"
#include "Vector.h"
class CMovingThings
{

View file

@ -1128,7 +1128,7 @@ void CHud::DrawAfterFade()
switch (OddJob2On) {
case 0:
OddJob2On = 1;
OddJob2XOffset = 380.0;
OddJob2XOffset = 380.0f;
break;
case 1:
if (OddJob2XOffset <= 2.0f) {
@ -1136,27 +1136,27 @@ void CHud::DrawAfterFade()
OddJob2On = 2;
}
else {
fStep = 40.0;
if ((OddJob2XOffset * 0.16667) <= 40.0)
fStep = OddJob2XOffset * 0.16667;
fStep = 40.0f;
if ((OddJob2XOffset * 0.16667f) <= 40.0f)
fStep = OddJob2XOffset * 0.16667f;
OddJob2XOffset = OddJob2XOffset - fStep;
}
break;
case 2:
OddJob2Timer += (20.0 * CTimer::GetTimeStep());
OddJob2Timer += (20.0f * CTimer::GetTimeStep());
if (OddJob2Timer > 1500) {
OddJob2On = 3;
}
break;
case 3:
fStep = 30.0;
if ((OddJob2XOffset * 0.2) >= 30.0)
fStep = OddJob2XOffset * 0.2;
fStep = 30.0f;
if ((OddJob2XOffset * 0.2f) >= 30.0f)
fStep = OddJob2XOffset * 0.2f;
OddJob2XOffset = OddJob2XOffset - fStep;
if (OddJob2XOffset < -380.0) {
OddJob2OffTimer = 5000.0;
if (OddJob2XOffset < -380.0f) {
OddJob2OffTimer = 5000.0f;
OddJob2On = 0;
}
break;

View file

@ -37,9 +37,9 @@ SetLightsWithTimeOfDayColour(RpWorld *)
AmbientLightColourForFrame.green = 1.0f;
AmbientLightColourForFrame.blue = 1.0f;
}
AmbientLightColourForFrame_PedsCarsAndObjects.red = min(1.0f, AmbientLightColourForFrame.red*1.3f);
AmbientLightColourForFrame_PedsCarsAndObjects.green = min(1.0f, AmbientLightColourForFrame.green*1.3f);
AmbientLightColourForFrame_PedsCarsAndObjects.blue = min(1.0f, AmbientLightColourForFrame.blue*1.3f);
AmbientLightColourForFrame_PedsCarsAndObjects.red = Min(1.0f, AmbientLightColourForFrame.red*1.3f);
AmbientLightColourForFrame_PedsCarsAndObjects.green = Min(1.0f, AmbientLightColourForFrame.green*1.3f);
AmbientLightColourForFrame_PedsCarsAndObjects.blue = Min(1.0f, AmbientLightColourForFrame.blue*1.3f);
RpLightSetColor(pAmbient, &AmbientLightColourForFrame);
}
@ -70,16 +70,16 @@ SetLightsWithTimeOfDayColour(RpWorld *)
float f1 = 2.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f;
float f2 = 3.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f;
AmbientLightColourForFrame.red = min(1.0f, AmbientLightColourForFrame.red * f2);
AmbientLightColourForFrame.green = min(1.0f, AmbientLightColourForFrame.green * f2);
AmbientLightColourForFrame.blue = min(1.0f, AmbientLightColourForFrame.blue * f2);
AmbientLightColourForFrame_PedsCarsAndObjects.red = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.red * f1);
AmbientLightColourForFrame_PedsCarsAndObjects.green = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.green * f1);
AmbientLightColourForFrame_PedsCarsAndObjects.blue = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.blue * f1);
AmbientLightColourForFrame.red = Min(1.0f, AmbientLightColourForFrame.red * f2);
AmbientLightColourForFrame.green = Min(1.0f, AmbientLightColourForFrame.green * f2);
AmbientLightColourForFrame.blue = Min(1.0f, AmbientLightColourForFrame.blue * f2);
AmbientLightColourForFrame_PedsCarsAndObjects.red = Min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.red * f1);
AmbientLightColourForFrame_PedsCarsAndObjects.green = Min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.green * f1);
AmbientLightColourForFrame_PedsCarsAndObjects.blue = Min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.blue * f1);
#ifdef FIX_BUGS
DirectionalLightColourForFrame.red = min(1.0f, DirectionalLightColourForFrame.red * f1);
DirectionalLightColourForFrame.green = min(1.0f, DirectionalLightColourForFrame.green * f1);
DirectionalLightColourForFrame.blue = min(1.0f, DirectionalLightColourForFrame.blue * f1);
DirectionalLightColourForFrame.red = Min(1.0f, DirectionalLightColourForFrame.red * f1);
DirectionalLightColourForFrame.green = Min(1.0f, DirectionalLightColourForFrame.green * f1);
DirectionalLightColourForFrame.blue = Min(1.0f, DirectionalLightColourForFrame.blue * f1);
#else
DirectionalLightColourForFrame.red = min(1.0f, AmbientLightColourForFrame.red * f1);
DirectionalLightColourForFrame.green = min(1.0f, AmbientLightColourForFrame.green * f1);
@ -193,7 +193,7 @@ AddAnExtraDirectionalLight(RpWorld *world, float dirx, float diry, float dirz, f
RwRGBAReal color;
RwV3d *dir;
strength = max(max(red, green), blue);
strength = Max(Max(red, green), blue);
n = -1;
if(NumExtraDirLightsInWorld < NUMEXTRADIRECTIONALS)
n = NumExtraDirLightsInWorld;
@ -221,7 +221,7 @@ AddAnExtraDirectionalLight(RpWorld *world, float dirx, float diry, float dirz, f
RwFrameUpdateObjects(RpLightGetFrame(pExtraDirectionals[n]));
RpLightSetFlags(pExtraDirectionals[n], rpLIGHTLIGHTATOMICS);
LightStrengths[n] = strength;
NumExtraDirLightsInWorld = min(NumExtraDirLightsInWorld+1, NUMEXTRADIRECTIONALS);
NumExtraDirLightsInWorld = Min(NumExtraDirLightsInWorld+1, NUMEXTRADIRECTIONALS);
}
void

View file

@ -91,7 +91,7 @@ void cParticleSystemMgr::LoadParticleData()
break;
case CFG_PARAM_INITIAL_COLOR_VARIATION:
entry->m_InitialColorVariation = min(atoi(value), 100);
entry->m_InitialColorVariation = Min(atoi(value), 100);
break;
case CFG_PARAM_FADE_DESTINATION_COLOR_R:

View file

@ -98,7 +98,7 @@ CPointLights::GenerateLightsAffectingObject(CVector *objCoors)
if(aLights[i].type == LIGHT_DIRECTIONAL){
float dot = -DotProduct(dir, aLights[i].dir);
intensity *= max((dot-0.5f)*2.0f, 0.0f);
intensity *= Max((dot-0.5f)*2.0f, 0.0f);
}
if(intensity > 0.0f)

View file

@ -727,10 +727,10 @@ CShadows::RenderStoredShadows(void)
float fStartY = shadowPos.y - fHeight;
float fEndY = shadowPos.y + fHeight;
int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0);
int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0);
int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X-1);
int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y-1);
int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0);
int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0);
int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X-1);
int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y-1);
CWorld::AdvanceCurrentScanCode();
@ -873,10 +873,10 @@ CShadows::GeneratePolysForStaticShadow(int16 nStaticShadowID)
float fStartY = shadowPos.y - fHeight;
float fEndY = shadowPos.y + fHeight;
int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0);
int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0);
int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X-1);
int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y-1);
int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0);
int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0);
int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X-1);
int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y-1);
CWorld::AdvanceCurrentScanCode();
@ -1016,11 +1016,11 @@ CShadows::CastShadowEntity(CEntity *pEntity, float fStartX, float fStartY, floa
Points[3].x = (fLengthRight - fFrontRight) - fSideRight;
Points[3].y = (fLengthForward - fFrontForward) - fSideForward;
float MinX = min(min(Points[0].x, Points[1].x), min(Points[2].x, Points[3].x));
float MaxX = max(max(Points[0].x, Points[1].x), max(Points[2].x, Points[3].x));
float MinX = Min(Min(Points[0].x, Points[1].x), Min(Points[2].x, Points[3].x));
float MaxX = Max(Max(Points[0].x, Points[1].x), Max(Points[2].x, Points[3].x));
float MinY = min(min(Points[0].y, Points[1].y), min(Points[2].y, Points[3].y));
float MaxY = max(max(Points[0].y, Points[1].y), max(Points[2].y, Points[3].y));
float MinY = Min(Min(Points[0].y, Points[1].y), Min(Points[2].y, Points[3].y));
float MaxY = Max(Max(Points[0].y, Points[1].y), Max(Points[2].y, Points[3].y));
float MaxZ = pPosn->z - pEntity->GetPosition().z;
float MinZ = MaxZ - fZDistance;
@ -1767,7 +1767,7 @@ CShadows::RenderIndicatorShadow(uint32 nID, uint8 ShadowType, RwTexture *pTextur
{
ASSERT(pPosn != NULL);
C3dMarkers::PlaceMarkerSet(nID, _TODOCONST(4), *pPosn, max(fFrontX, -fSideY),
C3dMarkers::PlaceMarkerSet(nID, _TODOCONST(4), *pPosn, Max(fFrontX, -fSideY),
0, 128, 255, 128,
2048, 0.2f, 0);
}

View file

@ -290,7 +290,7 @@ CTimeCycle::Update(void)
TheCamera.SetMotionBlur(m_fCurrentBlurRed, m_fCurrentBlurGreen, m_fCurrentBlurBlue, m_fCurrentBlurAlpha, MBLUR_NORMAL);
if(m_FogReduction != 0)
m_fCurrentFarClip = max(m_fCurrentFarClip, m_FogReduction/64.0f * 650.0f);
m_fCurrentFarClip = Max(m_fCurrentFarClip, m_FogReduction/64.0f * 650.0f);
m_nCurrentFogColourRed = (m_nCurrentSkyTopRed + 2*m_nCurrentSkyBottomRed) / 3;
m_nCurrentFogColourGreen = (m_nCurrentSkyTopGreen + 2*m_nCurrentSkyBottomGreen) / 3;
m_nCurrentFogColourBlue = (m_nCurrentSkyTopBlue + 2*m_nCurrentSkyBottomBlue) / 3;
@ -311,9 +311,9 @@ CTimeCycle::Update(void)
if(TheCamera.GetForward().z < -0.9f ||
!CWeather::bScriptsForceRain && (CCullZones::PlayerNoRain() || CCullZones::CamNoRain() || CCutsceneMgr::IsRunning()))
m_FogReduction = min(m_FogReduction+1, 64);
m_FogReduction = Min(m_FogReduction+1, 64);
else
m_FogReduction = max(m_FogReduction-1, 0);
m_FogReduction = Max(m_FogReduction-1, 0);
}
STARTPATCHES

View file

@ -103,14 +103,14 @@ CVisibilityPlugins::SetRenderWareCamera(RwCamera *camera)
else
ms_cullCompsDist = sq(TheCamera.LODDistMultiplier * 20.0f);
ms_vehicleLod0Dist = sq(70.0 * TheCamera.GenerationDistMultiplier);
ms_vehicleLod1Dist = sq(90.0 * TheCamera.GenerationDistMultiplier);
ms_vehicleFadeDist = sq(100.0 * TheCamera.GenerationDistMultiplier);
ms_bigVehicleLod0Dist = sq(60.0 * TheCamera.GenerationDistMultiplier);
ms_bigVehicleLod1Dist = sq(150.0 * TheCamera.GenerationDistMultiplier);
ms_pedLod0Dist = sq(25.0 * TheCamera.LODDistMultiplier);
ms_pedLod1Dist = sq(60.0 * TheCamera.LODDistMultiplier);
ms_pedFadeDist = sq(70.0 * TheCamera.LODDistMultiplier);
ms_vehicleLod0Dist = sq(70.0f * TheCamera.GenerationDistMultiplier);
ms_vehicleLod1Dist = sq(90.0f * TheCamera.GenerationDistMultiplier);
ms_vehicleFadeDist = sq(100.0f * TheCamera.GenerationDistMultiplier);
ms_bigVehicleLod0Dist = sq(60.0f * TheCamera.GenerationDistMultiplier);
ms_bigVehicleLod1Dist = sq(150.0f * TheCamera.GenerationDistMultiplier);
ms_pedLod0Dist = sq(25.0f * TheCamera.LODDistMultiplier);
ms_pedLod1Dist = sq(60.0f * TheCamera.LODDistMultiplier);
ms_pedFadeDist = sq(70.0f * TheCamera.LODDistMultiplier);
}
RpMaterial*

View file

@ -979,7 +979,7 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
SMALL_SECTOR_SIZE / 2,
apBoatList) )
{
float fWakeColor = fAdd1 - max(255.0f - float(color.blue + color.red + color.green) / 3, fAdd2);
float fWakeColor = fAdd1 - Max(255.0f - float(color.blue + color.red + color.green) / 3, fAdd2);
RpGeometry *wavyGeometry = RpAtomicGetGeometry(ms_pWavyAtomic);
RpGeometry *geom = apGeomArray[nGeomUsed++];
@ -1035,9 +1035,9 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
RwRGBAAssign(&wakeColor, &color);
wakeColor.red = min(color.red + int32(fWakeColor * fRedMult * fDistMult), 255);
wakeColor.green = min(color.green + int32(fWakeColor * fGreenMult * fDistMult), 255);
wakeColor.blue = min(color.blue + int32(fWakeColor * fBlueMult * fDistMult), 255);
wakeColor.red = Min(color.red + int32(fWakeColor * fRedMult * fDistMult), 255);
wakeColor.green = Min(color.green + int32(fWakeColor * fGreenMult * fDistMult), 255);
wakeColor.blue = Min(color.blue + int32(fWakeColor * fBlueMult * fDistMult), 255);
RwRGBAAssign(&geomPreLights[9*i+j], &wakeColor);
@ -1114,7 +1114,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
fSectorY + SMALL_SECTOR_SIZE - fY
);
fDistSqr = min(vecDist.MagnitudeSqr(), fDistSqr);
fDistSqr = Min(vecDist.MagnitudeSqr(), fDistSqr);
}
}
}

View file

@ -1661,7 +1661,7 @@ void CenterVideo(void)
/*
*****************************************************************************
*/
void PlayMovieInWindow(int cmdShow, LPTSTR szFile)
void PlayMovieInWindow(int cmdShow, const char* szFile)
{
WCHAR wFileName[256];
HRESULT hr;

View file

@ -316,7 +316,7 @@ CAutomobile::ProcessControl(void)
// Set Center of Mass to make car more stable
if(strongGrip1 || bCheat3)
m_vecCentreOfMass.z = 0.3f*m_aSuspensionSpringLength[0] + -1.0*m_fHeightAboveRoad;
m_vecCentreOfMass.z = 0.3f*m_aSuspensionSpringLength[0] + -1.0f*m_fHeightAboveRoad;
else if(pHandling->Flags & HANDLING_NONPLAYER_STABILISER && m_status == STATUS_PHYSICS)
m_vecCentreOfMass.z = pHandling->CentreOfMass.z - 0.2f*pHandling->Dimension.z;
else
@ -691,7 +691,7 @@ CAutomobile::ProcessControl(void)
if(m_aSuspensionSpringRatio[i] < 1.0f)
m_aWheelTimer[i] = 4.0f;
else
m_aWheelTimer[i] = max(m_aWheelTimer[i]-CTimer::GetTimeStep(), 0.0f);
m_aWheelTimer[i] = Max(m_aWheelTimer[i]-CTimer::GetTimeStep(), 0.0f);
if(m_aWheelTimer[i] > 0.0f){
m_nWheelsOnGround++;
@ -1009,7 +1009,7 @@ CAutomobile::ProcessControl(void)
if(m_status != STATUS_PLAYER && m_status != STATUS_PLAYER_REMOTE && m_status != STATUS_PHYSICS){
if(GetModelIndex() == MI_MIAMI_RCRAIDER || GetModelIndex() == MI_MIAMI_SPARROW)
m_aWheelSpeed[0] = max(m_aWheelSpeed[0]-0.0005f, 0.0f);
m_aWheelSpeed[0] = Max(m_aWheelSpeed[0]-0.0005f, 0.0f);
}else if((GetModelIndex() == MI_DODO || CVehicle::bAllDodosCheat) &&
m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){
FlyingControl(FLIGHT_MODEL_DODO);
@ -1017,7 +1017,7 @@ CAutomobile::ProcessControl(void)
FlyingControl(FLIGHT_MODEL_HELI);
}else if(GetModelIndex() == MI_MIAMI_RCRAIDER || GetModelIndex() == MI_MIAMI_SPARROW || bAllCarCheat){
if(CPad::GetPad(0)->GetCircleJustDown())
m_aWheelSpeed[0] = max(m_aWheelSpeed[0]-0.03f, 0.0f);
m_aWheelSpeed[0] = Max(m_aWheelSpeed[0]-0.03f, 0.0f);
if(m_aWheelSpeed[0] < 0.22f)
m_aWheelSpeed[0] += 0.0001f;
if(m_aWheelSpeed[0] > 0.15f)
@ -1129,10 +1129,10 @@ CAutomobile::ProcessControl(void)
if(speed > sq(0.1f)){
speed = Sqrt(speed);
if(suspShake > 0.0f){
uint8 freq = min(200.0f*suspShake*speed*2000.0f/m_fMass + 100.0f, 250.0f);
uint8 freq = Min(200.0f*suspShake*speed*2000.0f/m_fMass + 100.0f, 250.0f);
CPad::GetPad(0)->StartShake(20000.0f*CTimer::GetTimeStep()/freq, freq);
}else{
uint8 freq = min(200.0f*surfShake*speed*2000.0f/m_fMass + 40.0f, 145.0f);
uint8 freq = Min(200.0f*surfShake*speed*2000.0f/m_fMass + 40.0f, 145.0f);
CPad::GetPad(0)->StartShake(5000.0f*CTimer::GetTimeStep()/freq, freq);
}
}
@ -1591,10 +1591,11 @@ CAutomobile::PreRender(void)
break;
}
if(GetModelIndex() == MI_RCBANDIT ||
GetModelIndex() == MI_DODO ||
GetModelIndex() == MI_RHINO)
goto nolights;
if(GetModelIndex() == MI_RCBANDIT || GetModelIndex() == MI_DODO ||
GetModelIndex() == MI_RHINO) {
CShadows::StoreShadowForCar(this);
return;
}
// Turn lights on/off
bool shouldLightsBeOn =
@ -1739,7 +1740,7 @@ CAutomobile::PreRender(void)
// Taillight coronas
if(behindness > 0.0f){
// Behind car
float intensity = 0.4f*behindness + 0.4;
float intensity = 0.4f*behindness + 0.4f;
float size = (behindness + 1.0f)/2.0f;
if(m_fGasPedal < 0.0f){
@ -1757,7 +1758,7 @@ CAutomobile::PreRender(void)
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
}else{
if(m_fBrakePedal > 0.0){
if(m_fBrakePedal > 0.0f){
intensity += 0.4f;
size += 0.3f;
}
@ -1843,8 +1844,10 @@ CAutomobile::PreRender(void)
}else{
// Lights off
if(m_status == STATUS_ABANDONED || m_status == STATUS_WRECKED)
goto nolights;
if(m_status == STATUS_ABANDONED || m_status == STATUS_WRECKED) {
CShadows::StoreShadowForCar(this);
return;
}
CVector lightPos = mi->m_positions[CAR_POS_TAILLIGHTS];
CVector lightR = GetMatrix() * lightPos;
@ -1903,7 +1906,6 @@ CAutomobile::PreRender(void)
}
}
nolights:
CShadows::StoreShadowForCar(this);
}
@ -2586,7 +2588,7 @@ CAutomobile::HydraulicControl(void)
float minz = pos.z + extendedLowerLimit - wheelRadius;
if(minz < specialColModel->boundingBox.min.z)
specialColModel->boundingBox.min.z = minz;
float radius = max(specialColModel->boundingBox.min.Magnitude(), specialColModel->boundingBox.max.Magnitude());
float radius = Max(specialColModel->boundingBox.min.Magnitude(), specialColModel->boundingBox.max.Magnitude());
if(specialColModel->boundingSphere.radius < radius)
specialColModel->boundingSphere.radius = radius;
@ -2685,10 +2687,10 @@ CAutomobile::HydraulicControl(void)
float front = -rear;
float right = CPad::GetPad(0)->GetCarGunLeftRight()/128.0f;
float left = -right;
suspChange[CARWHEEL_FRONT_LEFT] = max(front+left, 0.0f);
suspChange[CARWHEEL_REAR_LEFT] = max(rear+left, 0.0f);
suspChange[CARWHEEL_FRONT_RIGHT] = max(front+right, 0.0f);
suspChange[CARWHEEL_REAR_RIGHT] = max(rear+right, 0.0f);
suspChange[CARWHEEL_FRONT_LEFT] = Max(front+left, 0.0f);
suspChange[CARWHEEL_REAR_LEFT] = Max(rear+left, 0.0f);
suspChange[CARWHEEL_FRONT_RIGHT] = Max(front+right, 0.0f);
suspChange[CARWHEEL_REAR_RIGHT] = Max(rear+right, 0.0f);
if(m_hydraulicState < 100){
// Lowered, move wheels up
@ -2804,7 +2806,7 @@ CAutomobile::ProcessBuoyancy(void)
ApplyTurnForce(impulse, point);
CVector initialSpeed = m_vecMoveSpeed;
float timeStep = max(CTimer::GetTimeStep(), 0.01f);
float timeStep = Max(CTimer::GetTimeStep(), 0.01f);
float impulseRatio = impulse.z / (GRAVITY * m_fMass * timeStep);
float waterResistance = Pow(1.0f - 0.05f*impulseRatio, CTimer::GetTimeStep());
m_vecMoveSpeed *= waterResistance;
@ -2877,7 +2879,7 @@ CAutomobile::ProcessBuoyancy(void)
static RwRGBA black;
if(pos.z >= 0.0f){
nGenerateRaindrops = 0;
pos.z += 0.5;
pos.z += 0.5f;
CParticleObject::AddObject(POBJECT_SPLASHES_AROUND,
pos, CVector(0.0f, 0.0f, 0.0f), 6.5f, 2500, black, true);
}
@ -2897,7 +2899,7 @@ CAutomobile::ProcessBuoyancy(void)
float fSpeed = vSpeed.MagnitudeSqr();
if(fSpeed > sq(0.05f)){
fSpeed = Sqrt(fSpeed);
float size = min((fSpeed < 0.15f ? 0.25f : 0.75f)*fSpeed, 0.6f);
float size = Min((fSpeed < 0.15f ? 0.25f : 0.75f)*fSpeed, 0.6f);
CVector right = 0.2f*fSpeed*GetRight() + 0.2f*vSpeed;
CParticle::AddParticle(PARTICLE_PED_SPLASH,
@ -2979,11 +2981,11 @@ CAutomobile::DoDriveByShootings(void)
// TODO: what is this?
if(!lookingLeft && m_weaponDoorTimerLeft > 0.0f){
m_weaponDoorTimerLeft = max(m_weaponDoorTimerLeft - CTimer::GetTimeStep()*0.1f, 0.0f);
m_weaponDoorTimerLeft = Max(m_weaponDoorTimerLeft - CTimer::GetTimeStep()*0.1f, 0.0f);
ProcessOpenDoor(CAR_DOOR_LF, NUM_ANIMS, m_weaponDoorTimerLeft);
}
if(!lookingRight && m_weaponDoorTimerRight > 0.0f){
m_weaponDoorTimerRight = max(m_weaponDoorTimerRight - CTimer::GetTimeStep()*0.1f, 0.0f);
m_weaponDoorTimerRight = Max(m_weaponDoorTimerRight - CTimer::GetTimeStep()*0.1f, 0.0f);
ProcessOpenDoor(CAR_DOOR_RF, NUM_ANIMS, m_weaponDoorTimerRight);
}
}
@ -3131,7 +3133,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
FindPlayerPed()->SetWantedLevelNoDrop(1);
if(m_status == STATUS_PLAYER && impulse > 50.0f){
uint8 freq = min(0.4f*impulse*2000.0f/m_fMass + 100.0f, 250.0f);
uint8 freq = Min(0.4f*impulse*2000.0f/m_fMass + 100.0f, 250.0f);
CPad::GetPad(0)->StartShake(40000/freq, freq);
}
@ -3284,7 +3286,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
if(m_pDamageEntity && m_pDamageEntity == FindPlayerVehicle() && impulse > 10.0f){
int money = (doubleMoney ? 2 : 1) * impulse*pHandling->nMonetaryValue/1000000.0f;
money = min(money, 40);
money = Min(money, 40);
if(money > 2){
sprintf(gString, "$%d", money);
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += money;
@ -3987,7 +3989,7 @@ CAutomobile::SetupSuspensionLines(void)
// adjust col model to include suspension lines
if(colModel->boundingBox.min.z > colModel->lines[0].p1.z)
colModel->boundingBox.min.z = colModel->lines[0].p1.z;
float radius = max(colModel->boundingBox.min.Magnitude(), colModel->boundingBox.max.Magnitude());
float radius = Max(colModel->boundingBox.min.Magnitude(), colModel->boundingBox.max.Magnitude());
if(colModel->boundingSphere.radius < radius)
colModel->boundingSphere.radius = radius;

View file

@ -61,7 +61,7 @@ float CBoat::IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat)
float fDist = vecDist.MagnitudeSqr();
if ( fDist < SQR(fMaxDist) )
return 1.0f - min(fRangeMult * Sqrt(fDist / SQR(fMaxDist)) + (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fTimeMult, 1.0f);
return 1.0f - Min(fRangeMult * Sqrt(fDist / SQR(fMaxDist)) + (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fTimeMult, 1.0f);
}
return 0.0f;

View file

@ -6,9 +6,9 @@
cHandlingDataMgr &mod_HandlingManager = *(cHandlingDataMgr*)0x728060;
char *HandlingFilename = "HANDLING.CFG";
const char *HandlingFilename = "HANDLING.CFG";
char VehicleNames[NUMHANDLINGS][14] = {
const char VehicleNames[NUMHANDLINGS][14] = {
"LANDSTAL",
"IDAHO",
"STINGER",
@ -199,7 +199,7 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
if(handling->fTurnMass < 10.0f)
handling->fTurnMass *= 5.0f;
handling->fInvMass = 1.0f/handling->fMass;
handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * 0.008*handling->fMass;
handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * 0.008f*handling->fMass;
// What the hell is going on here?
specificVolume = handling->Dimension.x*handling->Dimension.z*0.5f / handling->fMass; // ?
@ -207,7 +207,7 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
b = 100.0f;
velocity = handling->Transmission.fMaxVelocity;
while(a < b && velocity > 0.0f){
velocity -= 0.01;
velocity -= 0.01f;
a = handling->Transmission.fEngineAcceleration/6.0f;
b = -velocity * (1.0f/(specificVolume * sq(velocity) + 1.0f) - 1.0f);
}

View file

@ -14,7 +14,7 @@
#include "Shadows.h"
#include "Coronas.h"
#include "Explosion.h"
#include "TimeCycle.h"
#include "Timecycle.h"
#include "TempColModels.h"
#include "World.h"
#include "WaterLevel.h"
@ -223,19 +223,19 @@ CHeli::ProcessControl(void)
switch(m_heliStatus){
case HELI_STATUS_HOVER:
groundZ = CWorld::FindGroundZFor3DCoord(GetPosition().x, GetPosition().y, 1000.0f, nil);
m_fTargetZ = max(groundZ, m_fTargetZ) + 8.0f;
m_fTargetZ = Max(groundZ, m_fTargetZ) + 8.0f;
break;
case HELI_STATUS_SHOT_DOWN:
groundZ = CWorld::FindGroundZFor3DCoord(GetPosition().x, GetPosition().y, 1000.0f, nil);
m_fTargetZ = max(groundZ, m_fTargetZ) + 8.0f + m_fTargetOffset;
m_fTargetZ = Max(groundZ, m_fTargetZ) + 8.0f + m_fTargetOffset;
break;
case HELI_STATUS_HOVER2:
groundZ = CWorld::FindGroundZFor3DCoord(GetPosition().x, GetPosition().y, 1000.0f, nil);
m_fTargetZ = max(groundZ, m_fTargetZ) + 8.0f + m_fTargetOffset;
m_fTargetZ = Max(groundZ, m_fTargetZ) + 8.0f + m_fTargetOffset;
break;
default:
groundZ = CWorld::FindGroundZFor3DCoord(GetPosition().x, GetPosition().y, 1000.0f, nil);
m_fTargetZ = max(groundZ, m_fTargetZ) + 12.0f;
m_fTargetZ = Max(groundZ, m_fTargetZ) + 12.0f;
break;
}
@ -994,7 +994,7 @@ CHeli::TestBulletCollision(CVector *line0, CVector *line1, CVector *bulletPos, i
float distToHeli = (pHelis[i]->GetPosition() - *line0).Magnitude();
CVector line = (*line1 - *line0);
float lineLength = line.Magnitude();
*bulletPos = *line0 + line*max(1.0f, distToHeli-5.0f);
*bulletPos = *line0 + line*Max(1.0f, distToHeli-5.0f);
pHelis[i]->m_nBulletDamage += damage;

View file

@ -397,7 +397,7 @@ CPlane::ProcessControl(void)
planePathSpeed = PlanePath3Speed;
numPathNodes = NumPath3Nodes;
if(CesnaMissionStatus == CESNA_STATUS_LANDED){
pDrugRunCesna = false;
pDrugRunCesna = nil;
FlagToDestroyWhenNextProcessed();
}
}else if(m_bIsDropOffCesna){
@ -407,7 +407,7 @@ CPlane::ProcessControl(void)
planePathSpeed = PlanePath4Speed;
numPathNodes = NumPath4Nodes;
if(DropOffCesnaMissionStatus == CESNA_STATUS_LANDED){
pDropOffCesna = false;
pDropOffCesna = nil;
FlagToDestroyWhenNextProcessed();
}
}else{

View file

@ -273,7 +273,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
right = -contactSpeedRight/wheelsOnGround;
if(wheelStatus == WHEEL_STATUS_BURST){
float fwdspeed = min(contactSpeedFwd, 0.3f);
float fwdspeed = Min(contactSpeedFwd, 0.3f);
right += fwdspeed * CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
}
}
@ -363,7 +363,7 @@ CVehicle::ProcessWheelRotation(tWheelState state, const CVector &fwd, const CVec
void
CVehicle::ExtinguishCarFire(void)
{
m_fHealth = max(m_fHealth, 300.0f);
m_fHealth = Max(m_fHealth, 300.0f);
if(m_pCarFire)
m_pCarFire->Extinguish();
if(IsCar()){
@ -638,13 +638,13 @@ CVehicle::SetDriver(CPed *driver)
if(bFreebies && driver == FindPlayerPed()){
if(GetModelIndex() == MI_AMBULAN)
FindPlayerPed()->m_fHealth = min(FindPlayerPed()->m_fHealth + 20.0f, 100.0f);
FindPlayerPed()->m_fHealth = Min(FindPlayerPed()->m_fHealth + 20.0f, 100.0f);
else if(GetModelIndex() == MI_TAXI)
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 25;
else if(GetModelIndex() == MI_POLICE)
driver->GiveWeapon(WEAPONTYPE_SHOTGUN, 5);
else if(GetModelIndex() == MI_ENFORCER)
driver->m_fArmour = max(driver->m_fArmour, 100.0f);
driver->m_fArmour = Max(driver->m_fArmour, 100.0f);
else if(GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_BORGNINE)
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 25;
bFreebies = false;