Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Nikolay Korolev 2020-04-21 11:55:39 +03:00
commit 7cc3410846
91 changed files with 1108 additions and 1052 deletions

2
librw

@ -1 +1 @@
Subproject commit 8b677c4dd77a73da68447556e3b07c6c0371629e
Subproject commit a2b79a71aa45e083c18789a21e8c99990b1a5202

View File

@ -1,5 +1,7 @@
#include "common.h"
#include "ctype.h"
#include "General.h"
#include "ModelInfo.h"
#include "AnimManager.h"
@ -75,12 +77,21 @@ strcmpIgnoringDigits(const char *s1, const char *s2)
c2 = *s2;
if(c1) s1++;
if(c2) s2++;
if(c1 == '\0' && c2 == '\0')
return true;
if(c1 == '\0' && c2 == '\0') return true;
#if defined _WIN32 && !defined __MINGW32__
if(__ascii_iswdigit(c1) && __ascii_iswdigit(c2))
#else
if(iswdigit(c1) && iswdigit(c2))
#endif
continue;
#if defined _WIN32 && !defined __MINGW32__
c1 = __ascii_toupper(c1);
c2 = __ascii_toupper(c2);
#else
c1 = toupper(c1);
c2 = toupper(c2);
#endif
if(c1 != c2)
return false;
}

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.0f, 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.0f, 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

@ -1,6 +1,7 @@
#pragma once
#include "AnimBlendHierarchy.h"
#include "AnimationId.h"
enum AssocGroupId
{
@ -33,185 +34,6 @@ enum AssocGroupId
NUM_ANIM_ASSOC_GROUPS
};
enum AnimationId
{
ANIM_WALK,
ANIM_RUN,
ANIM_SPRINT,
ANIM_IDLE_STANCE,
ANIM_WALK_START,
ANIM_RUN_STOP,
ANIM_RUN_STOP_R,
ANIM_IDLE_CAM,
ANIM_IDLE_HBHB,
ANIM_IDLE_TIRED,
ANIM_IDLE_ARMED,
ANIM_IDLE_CHAT,
ANIM_IDLE_TAXI,
ANIM_KO_SHOT_FRONT1,
ANIM_KO_SHOT_FRONT2,
ANIM_KO_SHOT_FRONT3,
ANIM_KO_SHOT_FRONT4,
ANIM_KO_SHOT_FACE,
ANIM_KO_SHOT_STOM,
ANIM_KO_SHOT_ARML,
ANIM_KO_SHOT_ARMR,
ANIM_KO_SHOT_LEGL,
ANIM_KO_SHOT_LEGR,
ANIM_KD_LEFT,
ANIM_KD_RIGHT,
ANIM_KO_SKID_FRONT,
ANIM_KO_SPIN_R, // named left in VC
ANIM_KO_SKID_BACK,
ANIM_KO_SPIN_L, // named right in VC
ANIM_SHOT_FRONT_PARTIAL,
ANIM_SHOT_LEFT_PARTIAL,
ANIM_SHOT_BACK_PARTIAL,
ANIM_SHOT_RIGHT_PARTIAL,
ANIM_HIT_FRONT,
ANIM_HIT_LEFT,
ANIM_HIT_BACK,
ANIM_HIT_RIGHT,
ANIM_FLOOR_HIT,
ANIM_HIT_BODYBLOW,
ANIM_HIT_CHEST,
ANIM_HIT_HEAD,
ANIM_HIT_WALK,
ANIM_HIT_WALL,
ANIM_FLOOR_HIT_F,
ANIM_HIT_BEHIND,
ANIM_PUNCH_R,
ANIM_KICK_FLOOR,
ANIM_WEAPON_BAT_H,
ANIM_WEAPON_BAT_V,
ANIM_WEAPON_HGUN_BODY,
ANIM_WEAPON_AK_BODY,
ANIM_WEAPON_PUMP,
ANIM_WEAPON_SNIPER,
ANIM_WEAPON_THROW,
ANIM_WEAPON_THROWU,
ANIM_WEAPON_START_THROW,
ANIM_BOMBER,
ANIM_HGUN_RELOAD,
ANIM_AK_RELOAD,
ANIM_FPS_PUNCH,
ANIM_FPS_BAT,
ANIM_FPS_UZI,
ANIM_FPS_PUMP,
ANIM_FPS_AK,
ANIM_FPS_M16,
ANIM_FPS_ROCKET,
ANIM_FIGHT_IDLE,
ANIM_FIGHT2_IDLE,
ANIM_FIGHT_SH_F,
ANIM_FIGHT_BODYBLOW,
ANIM_FIGHT_HEAD,
ANIM_FIGHT_KICK,
ANIM_FIGHT_KNEE,
ANIM_FIGHT_LHOOK,
ANIM_FIGHT_PUNCH,
ANIM_FIGHT_ROUNDHOUSE,
ANIM_FIGHT_LONGKICK,
ANIM_FIGHT_PPUNCH,
ANIM_CAR_JACKED_RHS,
ANIM_CAR_LJACKED_RHS,
ANIM_CAR_JACKED_LHS,
ANIM_CAR_LJACKED_LHS,
ANIM_CAR_QJACK,
ANIM_CAR_QJACKED,
ANIM_CAR_ALIGN_LHS,
ANIM_CAR_ALIGNHI_LHS,
ANIM_CAR_OPEN_LHS,
ANIM_CAR_DOORLOCKED_LHS,
ANIM_CAR_PULLOUT_LHS,
ANIM_CAR_PULLOUT_LOW_LHS,
ANIM_CAR_GETIN_LHS,
ANIM_CAR_GETIN_LOW_LHS,
ANIM_CAR_CLOSEDOOR_LHS,
ANIM_CAR_CLOSEDOOR_LOW_LHS,
ANIM_CAR_ROLLDOOR,
ANIM_CAR_ROLLDOOR_LOW,
ANIM_CAR_GETOUT_LHS,
ANIM_CAR_GETOUT_LOW_LHS,
ANIM_CAR_CLOSE_LHS,
ANIM_CAR_ALIGN_RHS,
ANIM_CAR_ALIGNHI_RHS,
ANIM_CAR_OPEN_RHS,
ANIM_CAR_DOORLOCKED_RHS,
ANIM_CAR_PULLOUT_RHS,
ANIM_CAR_PULLOUT_LOW_RHS,
ANIM_CAR_GETIN_RHS,
ANIM_CAR_GETIN_LOW_RHS,
ANIM_CAR_CLOSEDOOR_RHS,
ANIM_CAR_CLOSEDOOR_LOW_RHS,
ANIM_CAR_SHUFFLE_RHS,
ANIM_CAR_LSHUFFLE_RHS,
ANIM_CAR_SIT,
ANIM_CAR_LSIT,
ANIM_CAR_SITP,
ANIM_CAR_SITPLO,
ANIM_DRIVE_L,
ANIM_DRIVE_R,
ANIM_DRIVE_LOW_L,
ANIM_DRIVE_LOW_R,
ANIM_DRIVEBY_L,
ANIM_DRIVEBY_R,
ANIM_CAR_LB,
ANIM_DRIVE_BOAT,
ANIM_CAR_GETOUT_RHS,
ANIM_CAR_GETOUT_LOW_RHS,
ANIM_CAR_CLOSE_RHS,
ANIM_CAR_HOOKERTALK,
ANIM_COACH_OPEN_L,
ANIM_COACH_OPEN_R,
ANIM_COACH_IN_L,
ANIM_COACH_IN_R,
ANIM_COACH_OUT_L,
ANIM_TRAIN_GETIN,
ANIM_TRAIN_GETOUT,
ANIM_CAR_CRAWLOUT_RHS,
ANIM_CAR_CRAWLOUT_RHS2,
ANIM_VAN_OPEN_L,
ANIM_VAN_GETIN_L,
ANIM_VAN_CLOSE_L,
ANIM_VAN_GETOUT_L,
ANIM_VAN_OPEN,
ANIM_VAN_GETIN,
ANIM_VAN_CLOSE,
ANIM_VAN_GETOUT,
ANIM_GETUP1,
ANIM_GETUP2,
ANIM_GETUP3,
ANIM_GETUP_FRONT,
ANIM_JUMP_LAUNCH,
ANIM_JUMP_GLIDE,
ANIM_JUMP_LAND,
ANIM_FALL_FALL,
ANIM_FALL_GLIDE,
ANIM_FALL_LAND,
ANIM_FALL_COLLAPSE,
ANIM_EV_STEP,
ANIM_EV_DIVE,
ANIM_XPRESS_SCRATCH,
ANIM_ROAD_CROSS,
ANIM_TURN_180,
ANIM_ARREST_GUN,
ANIM_DROWN,
ANIM_CPR,
ANIM_DUCK_DOWN,
ANIM_DUCK_LOW,
ANIM_RBLOCK_CSHOOT,
ANIM_WEAPON_THROWU2,
ANIM_HANDSUP,
ANIM_HANDSCOWER,
ANIM_FUCKU,
ANIM_PHONE_IN,
ANIM_PHONE_OUT,
ANIM_PHONE_TALK,
NUM_ANIMS
};
class CAnimBlendAssociation;
class CAnimBlendAssocGroup;

180
src/animation/AnimationId.h Normal file
View File

@ -0,0 +1,180 @@
#pragma once
enum AnimationId
{
ANIM_WALK,
ANIM_RUN,
ANIM_SPRINT,
ANIM_IDLE_STANCE,
ANIM_WALK_START,
ANIM_RUN_STOP,
ANIM_RUN_STOP_R,
ANIM_IDLE_CAM,
ANIM_IDLE_HBHB,
ANIM_IDLE_TIRED,
ANIM_IDLE_ARMED,
ANIM_IDLE_CHAT,
ANIM_IDLE_TAXI,
ANIM_KO_SHOT_FRONT1,
ANIM_KO_SHOT_FRONT2,
ANIM_KO_SHOT_FRONT3,
ANIM_KO_SHOT_FRONT4,
ANIM_KO_SHOT_FACE,
ANIM_KO_SHOT_STOM,
ANIM_KO_SHOT_ARML,
ANIM_KO_SHOT_ARMR,
ANIM_KO_SHOT_LEGL,
ANIM_KO_SHOT_LEGR,
ANIM_KD_LEFT,
ANIM_KD_RIGHT,
ANIM_KO_SKID_FRONT,
ANIM_KO_SPIN_R, // named left in VC
ANIM_KO_SKID_BACK,
ANIM_KO_SPIN_L, // named right in VC
ANIM_SHOT_FRONT_PARTIAL,
ANIM_SHOT_LEFT_PARTIAL,
ANIM_SHOT_BACK_PARTIAL,
ANIM_SHOT_RIGHT_PARTIAL,
ANIM_HIT_FRONT,
ANIM_HIT_LEFT,
ANIM_HIT_BACK,
ANIM_HIT_RIGHT,
ANIM_FLOOR_HIT,
ANIM_HIT_BODYBLOW,
ANIM_HIT_CHEST,
ANIM_HIT_HEAD,
ANIM_HIT_WALK,
ANIM_HIT_WALL,
ANIM_FLOOR_HIT_F,
ANIM_HIT_BEHIND,
ANIM_PUNCH_R,
ANIM_KICK_FLOOR,
ANIM_WEAPON_BAT_H,
ANIM_WEAPON_BAT_V,
ANIM_WEAPON_HGUN_BODY,
ANIM_WEAPON_AK_BODY,
ANIM_WEAPON_PUMP,
ANIM_WEAPON_SNIPER,
ANIM_WEAPON_THROW,
ANIM_WEAPON_THROWU,
ANIM_WEAPON_START_THROW,
ANIM_BOMBER,
ANIM_HGUN_RELOAD,
ANIM_AK_RELOAD,
ANIM_FPS_PUNCH,
ANIM_FPS_BAT,
ANIM_FPS_UZI,
ANIM_FPS_PUMP,
ANIM_FPS_AK,
ANIM_FPS_M16,
ANIM_FPS_ROCKET,
ANIM_FIGHT_IDLE,
ANIM_FIGHT2_IDLE,
ANIM_FIGHT_SH_F,
ANIM_FIGHT_BODYBLOW,
ANIM_FIGHT_HEAD,
ANIM_FIGHT_KICK,
ANIM_FIGHT_KNEE,
ANIM_FIGHT_LHOOK,
ANIM_FIGHT_PUNCH,
ANIM_FIGHT_ROUNDHOUSE,
ANIM_FIGHT_LONGKICK,
ANIM_FIGHT_PPUNCH,
ANIM_CAR_JACKED_RHS,
ANIM_CAR_LJACKED_RHS,
ANIM_CAR_JACKED_LHS,
ANIM_CAR_LJACKED_LHS,
ANIM_CAR_QJACK,
ANIM_CAR_QJACKED,
ANIM_CAR_ALIGN_LHS,
ANIM_CAR_ALIGNHI_LHS,
ANIM_CAR_OPEN_LHS,
ANIM_CAR_DOORLOCKED_LHS,
ANIM_CAR_PULLOUT_LHS,
ANIM_CAR_PULLOUT_LOW_LHS,
ANIM_CAR_GETIN_LHS,
ANIM_CAR_GETIN_LOW_LHS,
ANIM_CAR_CLOSEDOOR_LHS,
ANIM_CAR_CLOSEDOOR_LOW_LHS,
ANIM_CAR_ROLLDOOR,
ANIM_CAR_ROLLDOOR_LOW,
ANIM_CAR_GETOUT_LHS,
ANIM_CAR_GETOUT_LOW_LHS,
ANIM_CAR_CLOSE_LHS,
ANIM_CAR_ALIGN_RHS,
ANIM_CAR_ALIGNHI_RHS,
ANIM_CAR_OPEN_RHS,
ANIM_CAR_DOORLOCKED_RHS,
ANIM_CAR_PULLOUT_RHS,
ANIM_CAR_PULLOUT_LOW_RHS,
ANIM_CAR_GETIN_RHS,
ANIM_CAR_GETIN_LOW_RHS,
ANIM_CAR_CLOSEDOOR_RHS,
ANIM_CAR_CLOSEDOOR_LOW_RHS,
ANIM_CAR_SHUFFLE_RHS,
ANIM_CAR_LSHUFFLE_RHS,
ANIM_CAR_SIT,
ANIM_CAR_LSIT,
ANIM_CAR_SITP,
ANIM_CAR_SITPLO,
ANIM_DRIVE_L,
ANIM_DRIVE_R,
ANIM_DRIVE_LOW_L,
ANIM_DRIVE_LOW_R,
ANIM_DRIVEBY_L,
ANIM_DRIVEBY_R,
ANIM_CAR_LB,
ANIM_DRIVE_BOAT,
ANIM_CAR_GETOUT_RHS,
ANIM_CAR_GETOUT_LOW_RHS,
ANIM_CAR_CLOSE_RHS,
ANIM_CAR_HOOKERTALK,
ANIM_COACH_OPEN_L,
ANIM_COACH_OPEN_R,
ANIM_COACH_IN_L,
ANIM_COACH_IN_R,
ANIM_COACH_OUT_L,
ANIM_TRAIN_GETIN,
ANIM_TRAIN_GETOUT,
ANIM_CAR_CRAWLOUT_RHS,
ANIM_CAR_CRAWLOUT_RHS2,
ANIM_VAN_OPEN_L,
ANIM_VAN_GETIN_L,
ANIM_VAN_CLOSE_L,
ANIM_VAN_GETOUT_L,
ANIM_VAN_OPEN,
ANIM_VAN_GETIN,
ANIM_VAN_CLOSE,
ANIM_VAN_GETOUT,
ANIM_GETUP1,
ANIM_GETUP2,
ANIM_GETUP3,
ANIM_GETUP_FRONT,
ANIM_JUMP_LAUNCH,
ANIM_JUMP_GLIDE,
ANIM_JUMP_LAND,
ANIM_FALL_FALL,
ANIM_FALL_GLIDE,
ANIM_FALL_LAND,
ANIM_FALL_COLLAPSE,
ANIM_EV_STEP,
ANIM_EV_DIVE,
ANIM_XPRESS_SCRATCH,
ANIM_ROAD_CROSS,
ANIM_TURN_180,
ANIM_ARREST_GUN,
ANIM_DROWN,
ANIM_CPR,
ANIM_DUCK_DOWN,
ANIM_DUCK_LOW,
ANIM_RBLOCK_CSHOOT,
ANIM_WEAPON_THROWU2,
ANIM_HANDSUP,
ANIM_HANDSCOWER,
ANIM_FUCKU,
ANIM_PHONE_IN,
ANIM_PHONE_OUT,
ANIM_PHONE_TALK,
NUM_ANIMS
};

View File

@ -226,7 +226,7 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
if(s1 == SURFACE_METAL6 && s2 == SURFACE_FLESH) ratio = 0.25f * ratio;
if(s1 == SURFACE_METAL6 && ratio < 0.6f) {
s1 = SURFACE_BILLBOARD;
ratio = min(1.f, 2.f * ratio);
ratio = Min(1.f, 2.f * ratio);
}
emittingVol = 40.f * ratio;
if(emittingVol) {

View File

@ -635,9 +635,9 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1,
float speedOfSource = (dist / m_bTimeSpent) * speedMultiplier;
if(m_fSpeedOfSound > Abs(speedOfSource)) {
if(speedOfSource < 0.0f) {
speedOfSource = max(speedOfSource, -1.5f);
speedOfSource = Max(speedOfSource, -1.5f);
} else {
speedOfSource = min(speedOfSource, 1.5f);
speedOfSource = Min(speedOfSource, 1.5f);
}
newFreq =
(oldFreq * m_fSpeedOfSound) / (speedOfSource + m_fSpeedOfSound);
@ -650,10 +650,10 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1,
int32
cAudioManager::ComputePan(float dist, CVector *vec)
{
int32 index = min(63, Abs(vec->x / (dist / 64.f)));
int32 index = Min(63, Abs(vec->x / (dist / 64.f)));
if(vec->x > 0.f) return max(20, 63 - panTable[index]);
return min(107, panTable[index] + 63);
if(vec->x > 0.f) return Max(20, 63 - panTable[index]);
return Min(107, panTable[index] + 63);
}
uint8
@ -2894,7 +2894,7 @@ cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobil
relativeVelChange = (gasPedalAudio - 0.4f) * 1.25f;
} else if(wheelState == WHEEL_STATE_SKIDDING) {
relativeVelChange = min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity);
relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity);
} else if(wheelState == WHEEL_STATE_FIXED) {
modificator = 0.4f;
relativeVelChange = gasPedalAudio;
@ -2905,7 +2905,7 @@ cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobil
velChange = Abs(velocityChange);
if(relativeVelChange > 0.4f) relativeVelChange = relativeVelChange * modificator;
if(velChange > 0.04f) {
relativeVel = min(1.0f, velChange / transmission->fMaxVelocity);
relativeVel = Min(1.0f, velChange / transmission->fMaxVelocity);
} else {
relativeVel = 0.0f;
}
@ -2914,7 +2914,7 @@ cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobil
relativeVelChange = 0.0f;
}
return max(relativeVelChange, min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f));
return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f));
}
float
@ -2924,12 +2924,12 @@ cAudioManager::GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automo
float relativeVelChange;
if(automobile->m_aWheelState[wheel] == 2) {
relativeVelChange = min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity);
relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity);
} else {
relativeVelChange = 0.0f;
}
return max(relativeVelChange, min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f));
return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f));
}
bool
@ -3326,7 +3326,7 @@ cAudioManager::ProcessActiveQueues()
if(field_4) {
emittingVol =
2 *
min(63,
Min(63,
sample.m_bEmittingVolume);
} else {
emittingVol =
@ -3353,13 +3353,13 @@ cAudioManager::ProcessActiveQueues()
if(sample.m_nFrequency <=
m_asActiveSamples[j]
.m_nFrequency) {
freq = max(
freq = Max(
sample.m_nFrequency,
m_asActiveSamples[j]
.m_nFrequency -
6000);
} else {
freq = min(
freq = Min(
sample.m_nFrequency,
m_asActiveSamples[j]
.m_nFrequency +
@ -3376,14 +3376,14 @@ cAudioManager::ProcessActiveQueues()
if(sample.m_bEmittingVolume <=
m_asActiveSamples[j]
.m_bEmittingVolume) {
vol = max(
vol = Max(
m_asActiveSamples[j]
.m_bEmittingVolume -
10,
sample
.m_bEmittingVolume);
} else {
vol = min(
vol = Min(
m_asActiveSamples[j]
.m_bEmittingVolume +
10,
@ -3394,7 +3394,7 @@ cAudioManager::ProcessActiveQueues()
uint8 emittingVol;
if(field_4) {
emittingVol =
2 * min(63, vol);
2 * Min(63, vol);
} else {
emittingVol = vol;
}
@ -3461,7 +3461,7 @@ cAudioManager::ProcessActiveQueues()
&position);
if(field_4) {
emittingVol =
2 * min(63, m_asActiveSamples[j]
2 * Min(63, m_asActiveSamples[j]
.m_bEmittingVolume);
} else {
emittingVol =
@ -3783,7 +3783,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params)
velocityChange = Abs(params->m_fVelocityChange);
if(velocityChange <= 0.0005f && params->m_pVehicle->GetPosition().y) return true;
velocityChange = min(0.75f, velocityChange);
velocityChange = Min(0.75f, velocityChange);
multiplier = (velocityChange - 0.0005f) * 1.3342f;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
vol = (30.f * multiplier);
@ -5044,7 +5044,7 @@ void
cAudioManager::ProcessJumboDecel(CPlane *plane)
{
if(SetupJumboFlySound(20) && SetupJumboTaxiSound(75)) {
const float modificator = min(1.f, (plane->m_fSpeed - 0.10334f) * 1.676f);
const float modificator = Min(1.f, (plane->m_fSpeed - 0.10334f) * 1.676f);
SetupJumboEngineSound(maxVolume * modificator, 6050.f * modificator + 16000);
SetupJumboWhineSound(18, 29500);
}
@ -7259,7 +7259,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
CurrentPretendGear = 1;
}
if(CReplay::IsPlayingBack()) {
accelerateState = 255.f * max(0.0f, min(1.0f, automobile->m_fGasPedal));
accelerateState = 255.f * Max(0.0f, Min(1.0f, automobile->m_fGasPedal));
} else {
accelerateState = Pads->GetAccelerate();
}
@ -7268,7 +7268,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
velocityChange = params->m_fVelocityChange;
relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity;
accelerationMultipler = min(min(1.f, relativeVelocityChange), 0.f);
accelerationMultipler = Min(Min(1.f, relativeVelocityChange), 0.f);
gasPedalAudio = accelerationMultipler;
currentGear = params->m_pVehicle->m_nCurrentGear;
@ -7290,9 +7290,9 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
if(0.0f != velocityChange) {
time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange;
if(time <= 0.0f) {
freqModifier = max(-0.2f, time) * -15000.f;
freqModifier = Max(-0.2f, time) * -15000.f;
} else {
freqModifier = -(min(0.2f, time) * 15000.f);
freqModifier = -(Min(0.2f, time) * 15000.f);
}
if(params->m_fVelocityChange < -0.001f) freqModifier = -freqModifier;
} else {
@ -7311,10 +7311,10 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
gasPedalAudio = automobile->m_fGasPedalAudio;
} else {
gasPedalAudio =
min(1.0f, params->m_fVelocityChange /
Min(1.0f, params->m_fVelocityChange /
params->m_pTransmission->fMaxReverseVelocity);
}
gasPedalAudio = max(0.0f, gasPedalAudio);
gasPedalAudio = Max(0.0f, gasPedalAudio);
automobile->m_fGasPedalAudio = gasPedalAudio;
} else if(LastAccel > 0) {
if(channelUsed) {
@ -7343,7 +7343,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq,
(engineSoundType + SFX_CAR_REV_10), 0, 52, 1);
CurrentPretendGear = max(1, currentGear);
CurrentPretendGear = Max(1, currentGear);
LastAccel = accelerateState;
bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn;
@ -8005,7 +8005,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params)
if(params->m_fVelocityChange > 0.0f) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
train = (CTrain *)params->m_pVehicle;
speedMultipler = min(1.0f, train->m_fSpeed * 250.f / 51.f);
speedMultipler = Min(1.0f, train->m_fSpeed * 250.f / 51.f);
emittingVol = (75.f * speedMultipler);
if(train->m_fWagonPosition == 0.0f) {
m_sQueueSample.m_bVolume =
@ -8176,7 +8176,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params)
if(automobile->Damage.GetDoorStatus(i) == 2) {
doorState = automobile->Doors[i].m_nDoorState;
if(doorState == 1 || doorState == 2) {
velocity = min(0.3f, Abs(automobile->Doors[i].m_fAngVel));
velocity = Min(0.3f, Abs(automobile->Doors[i].m_fAngVel));
if(velocity > 0.0035f) {
emittingVol = (100.f * velocity * 10.f / 3.f);
m_sQueueSample.m_bVolume = ComputeVolume(
@ -8599,7 +8599,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params)
m_sQueueSample.m_fSoundIntensity = 30.0f;
break;
case SOUND_CAR_JUMP:
emittingVol = max(
emittingVol = Max(
80.f,
2 * (100.f *
m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]));
@ -9081,7 +9081,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
params->m_fDistance);
emittingVol =
30.f *
min(1.f,
Min(1.f,
velocity / (0.5f * params->m_pTransmission->fMaxVelocity));
m_sQueueSample.m_bVolume =
ComputeVolume(emittingVol, 95.f, m_sQueueSample.m_fDistance);
@ -9397,7 +9397,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params)
CalculateDistance(params->m_bDistanceCalculated,
params->m_fDistance);
relativeVelocity =
min(1.0f,
Min(1.0f,
velChange / (0.5f * params->m_pTransmission->fMaxVelocity));
emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads;
m_sQueueSample.m_bVolume =
@ -10035,7 +10035,7 @@ cAudioManager::UpdateReflections()
if(CWorld::ProcessVerticalLine(
camPos, m_avecReflectionsPos[4].z, colpoint,
ent, true, false, false, false, true, false,
false)) {
nil)) {
m_afReflectionsDistances[4] =
colpoint.point.z - camPos.z;
} else {

View File

@ -1,6 +1,7 @@
#pragma once
#include "audio_enums.h"
#include "Crime.h"
enum eSound : int16
{
@ -179,7 +180,6 @@ enum eSound : int16
class cAudioScriptObject;
class CEntity;
enum eCrimeType;
class cDMAudio
{

View File

@ -705,7 +705,7 @@ cMusicManager::GetTrackStartPos(uint8 track)
result = m_aTracks[track].m_nPosition;
m_aTracks[track].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode();
} else
result = min(CTimer::GetTimeInMillisecondsPauseMode() - timer, 90000) + m_aTracks[track].m_nPosition;
result = Min(CTimer::GetTimeInMillisecondsPauseMode() - timer, 90000) + m_aTracks[track].m_nPosition;
if (result > m_aTracks[track].m_nLength) result %= m_aTracks[track].m_nLength;
return result;

View File

@ -1986,50 +1986,59 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
{
uint32 i = 0;
if ( !_bIsMp3Active ) goto FIND_MP3TRACK;
do
{
if ( ++_CurMP3Index >= nNumMP3s )
_CurMP3Index = 0;
_CurMP3Pos = 0;
tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
if ( mp3 )
{
mp3 = _pMP3List;
if ( mp3 == NULL )
{
_bIsMp3Active = false;
nFile = 0;
goto PLAY_STREAMEDTRACK;
do {
if(i != 0 || _bIsMp3Active) {
if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
_CurMP3Pos = 0;
tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
if(mp3) {
mp3 = _pMP3List;
if(mp3 == NULL) {
_bIsMp3Active = false;
nFile = 0;
strcpy(filename, m_szCDRomRootPath);
strcat(filename, StreamedNameTable[nFile]);
mp3Stream[nStream] =
AIL_open_stream(DIG, filename, 0);
if(mp3Stream[nStream]) {
AIL_set_stream_loop_count(
mp3Stream[nStream], 1);
AIL_set_stream_ms_position(
mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream],
0);
return true;
}
return false;
}
}
if(mp3->pLinkPath != NULL)
mp3Stream[nStream] =
AIL_open_stream(DIG, mp3->pLinkPath, 0);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, mp3->aFilename);
mp3Stream[nStream] =
AIL_open_stream(DIG, filename, 0);
}
if(mp3Stream[nStream]) {
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
AIL_set_stream_ms_position(mp3Stream[nStream], 0);
AIL_pause_stream(mp3Stream[nStream], 0);
return true;
}
_bIsMp3Active = false;
continue;
}
if ( mp3->pLinkPath != NULL )
mp3Stream[nStream] = AIL_open_stream(DIG, mp3->pLinkPath, 0);
else
{
strcpy(filename, _mp3DirectoryPath);
strcat(filename, mp3->aFilename);
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
}
if ( mp3Stream[nStream] )
{
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
AIL_set_stream_ms_position(mp3Stream[nStream], 0);
AIL_pause_stream(mp3Stream[nStream], 0);
return true;
}
goto NEXT_MP3TRACK;
FIND_MP3TRACK:
if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
position = 0;
@ -2039,10 +2048,23 @@ FIND_MP3TRACK:
if ( e == NULL )
{
nFile = 0;
goto PLAY_STREAMEDTRACK;
strcpy(filename, m_szCDRomRootPath);
strcat(filename, StreamedNameTable[nFile]);
mp3Stream[nStream] =
AIL_open_stream(DIG, filename, 0);
if(mp3Stream[nStream]) {
AIL_set_stream_loop_count(
mp3Stream[nStream], 1);
AIL_set_stream_ms_position(
mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream], 0);
return true;
}
return false;
}
}
if ( e->pLinkPath != NULL )
mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0);
else
@ -2064,17 +2086,14 @@ FIND_MP3TRACK:
return true;
}
NEXT_MP3TRACK:
_bIsMp3Active = false;
} while ( ++i < nNumMP3s );
} while(++i < nNumMP3s);
position = 0;
nFile = 0;
goto PLAY_STREAMEDTRACK;
}
PLAY_STREAMEDTRACK:
strcpy(filename, m_szCDRomRootPath);
strcat(filename, StreamedNameTable[nFile]);

View File

@ -8,7 +8,7 @@
void CAutoPilot::ModifySpeed(float speed)
{
m_fMaxTrafficSpeed = max(0.01f, speed);
m_fMaxTrafficSpeed = Max(0.01f, speed);
float positionBetweenNodes = (float)(CTimer::GetTimeInMilliseconds() - m_nTimeEnteredCurve) / m_nTimeToSpendOnCurrentCurve;
CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[m_nCurrentPathNodeInfo];
CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[m_nNextPathNodeInfo];

View File

@ -374,7 +374,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 750;
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
if (pVehicle->VehicleCreatedBy == RANDOM_VEHICLE)
pVehicle->AutoPilot.m_nDrivingStyle = max(DRIVINGSTYLE_AVOID_CARS, pVehicle->AutoPilot.m_nDrivingStyle);
pVehicle->AutoPilot.m_nDrivingStyle = Max(DRIVINGSTYLE_AVOID_CARS, pVehicle->AutoPilot.m_nDrivingStyle);
pVehicle->PlayCarHorn();
}
}
@ -510,7 +510,7 @@ void CCarAI::TellCarToRamOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
pTarget->RegisterReference((CEntity**)&pVehicle->AutoPilot.m_pTargetCar);
pVehicle->AutoPilot.m_nCarMission = MISSION_RAMCAR_FARAWAY;
pVehicle->bEngineOn = true;
pVehicle->AutoPilot.m_nCruiseSpeed = max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
}
void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
@ -519,7 +519,7 @@ void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
pTarget->RegisterReference((CEntity**)&pVehicle->AutoPilot.m_pTargetCar);
pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKCAR_FARAWAY;
pVehicle->bEngineOn = true;
pVehicle->AutoPilot.m_nCruiseSpeed = max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
}
eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
{

View File

@ -362,7 +362,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. */
@ -804,10 +804,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);
@ -838,10 +838,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);
@ -873,12 +873,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) {
if (curSpeed < 0.1f)
pVehicle->AutoPilot.ModifySpeed(0.0f);
else
pVehicle->AutoPilot.ModifySpeed(max(maxSpeed, curSpeed - 0.5f * CTimer::GetTimeStep()));
pVehicle->AutoPilot.ModifySpeed(Max(maxSpeed, curSpeed - 0.5f * CTimer::GetTimeStep()));
}
}
@ -979,7 +979,7 @@ void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList& lst, CVehicle* pVehicle, f
if (distanceUntilHit < 10.0f){
if (pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_STOP_FOR_CARS ||
pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_SLOW_DOWN_FOR_CARS){
*pSpeed = min(*pSpeed, ABS(distanceUntilHit - 1.0f) * 0.1f * curSpeed);
*pSpeed = Min(*pSpeed, ABS(distanceUntilHit - 1.0f) * 0.1f * curSpeed);
pVehicle->AutoPilot.m_bSlowedDownBecauseOfPeds = true;
if (distanceUntilHit < 2.0f){
pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT;
@ -1028,11 +1028,11 @@ void CCarCtrl::SlowCarDownForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle,
float projectionY = speedOtherY - forwardA.y * curSpeed;
float proximityA = TestCollisionBetween2MovingRects(pOtherVehicle, pVehicle, projectionX, projectionY, &forwardA, &forwardB, 0);
float proximityB = TestCollisionBetween2MovingRects(pVehicle, pOtherVehicle, -projectionX, -projectionY, &forwardB, &forwardA, 1);
float minProximity = min(proximityA, proximityB);
float minProximity = Min(proximityA, proximityB);
if (minProximity >= 0.0f && minProximity < 1.0f){
minProximity = max(0.0f, (minProximity - 0.2f) * 1.25f);
minProximity = Max(0.0f, (minProximity - 0.2f) * 1.25f);
pVehicle->AutoPilot.m_bSlowedDownBecauseOfCars = true;
*pSpeed = min(*pSpeed, minProximity * curSpeed);
*pSpeed = Min(*pSpeed, minProximity * curSpeed);
}
if (minProximity >= 0.0f && minProximity < 0.5f && pOtherEntity->IsVehicle() &&
CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeToStartMission > 15000 &&
@ -1041,7 +1041,7 @@ void CCarCtrl::SlowCarDownForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle,
if (pOtherEntity != FindPlayerVehicle() &&
DotProduct2D(pVehicle->GetForward(), pOtherVehicle->GetForward()) < 0.5f &&
pVehicle < pOtherVehicle){ /* that comparasion though... */
*pSpeed = max(curSpeed / 5, *pSpeed);
*pSpeed = Max(curSpeed / 5, *pSpeed);
if (pVehicle->m_status == STATUS_SIMPLE){
pVehicle->m_status = STATUS_PHYSICS;
SwitchVehicleToRealPhysics(pVehicle);
@ -1097,7 +1097,7 @@ float CCarCtrl::TestCollisionBetween2MovingRects(CVehicle* pVehicleA, CVehicle*
float proximityWidth = -(widthDistance - widthB) / widthProjection;
if (proximityWidth < 1.0f){
baseWidthProximity = proximityWidth;
fullWidthProximity = min(1.0f, proximityWidth - fullWidthB / widthProjection);
fullWidthProximity = Min(1.0f, proximityWidth - fullWidthB / widthProjection);
}else{
baseWidthProximity = 1.0f;
}
@ -1110,7 +1110,7 @@ float CCarCtrl::TestCollisionBetween2MovingRects(CVehicle* pVehicleA, CVehicle*
float proximityWidth = -(widthDistance + widthB) / widthProjection;
if (proximityWidth < 1.0f) {
baseWidthProximity = proximityWidth;
fullWidthProximity = min(1.0f, proximityWidth + fullWidthB / widthProjection);
fullWidthProximity = Min(1.0f, proximityWidth + fullWidthB / widthProjection);
}
else {
baseWidthProximity = 1.0f;
@ -1135,7 +1135,7 @@ float CCarCtrl::TestCollisionBetween2MovingRects(CVehicle* pVehicleA, CVehicle*
float proximityLength = -(lenDistance - lenB) / lenProjection;
if (proximityLength < 1.0f) {
baseLengthProximity = proximityLength;
fullLengthProximity = min(1.0f, proximityLength - fullLenB / lenProjection);
fullLengthProximity = Min(1.0f, proximityLength - fullLenB / lenProjection);
}
else {
baseLengthProximity = 1.0f;
@ -1151,7 +1151,7 @@ float CCarCtrl::TestCollisionBetween2MovingRects(CVehicle* pVehicleA, CVehicle*
float proximityLength = -(lenDistance + backLenB) / lenProjection;
if (proximityLength < 1.0f) {
baseLengthProximity = proximityLength;
fullLengthProximity = min(1.0f, proximityLength + fullLenB / lenProjection);
fullLengthProximity = Min(1.0f, proximityLength + fullLenB / lenProjection);
}
else {
baseLengthProximity = 1.0f;
@ -1168,24 +1168,24 @@ float CCarCtrl::TestCollisionBetween2MovingRects(CVehicle* pVehicleA, CVehicle*
else if (lenProjection < 0.0f) {
fullLengthProximity = -(backLenB + lenDistance) / lenProjection;
}
float baseProximity = max(baseWidthProximity, baseLengthProximity);
float baseProximity = Max(baseWidthProximity, baseLengthProximity);
if (baseProximity < fullWidthProximity && baseProximity < fullLengthProximity)
proximity = min(proximity, baseProximity);
proximity = Min(proximity, baseProximity);
}
return proximity;
}
float CCarCtrl::FindAngleToWeaveThroughTraffic(CVehicle* pVehicle, CPhysical* pTarget, float angleToTarget, float angleForward)
{
float distanceToTest = min(2.0f, pVehicle->GetMoveSpeed().Magnitude2D() * 2.5f + 1.0f) * 12.0f;
float distanceToTest = Min(2.0f, pVehicle->GetMoveSpeed().Magnitude2D() * 2.5f + 1.0f) * 12.0f;
float left = pVehicle->GetPosition().x - distanceToTest;
float right = pVehicle->GetPosition().x + distanceToTest;
float top = pVehicle->GetPosition().y - distanceToTest;
float bottom = pVehicle->GetPosition().y + distanceToTest;
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);
@ -1566,8 +1566,8 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nNextLane -= 1;
}
}
pVehicle->AutoPilot.m_nNextLane = min(lanesOnNextNode - 1, pVehicle->AutoPilot.m_nNextLane);
pVehicle->AutoPilot.m_nNextLane = max(0, pVehicle->AutoPilot.m_nNextLane);
pVehicle->AutoPilot.m_nNextLane = Min(lanesOnNextNode - 1, pVehicle->AutoPilot.m_nNextLane);
pVehicle->AutoPilot.m_nNextLane = Max(0, pVehicle->AutoPilot.m_nNextLane);
}else{
pVehicle->AutoPilot.m_nNextLane = pVehicle->AutoPilot.m_nCurrentLane;
}
@ -1595,7 +1595,7 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
if (pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve < 10)
/* Oh hey there Obbe */
printf("fout\n");
pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = max(10, pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = Max(10, pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
}
uint8 CCarCtrl::FindPathDirection(int32 prevNode, int32 curNode, int32 nextNode)
@ -1746,8 +1746,8 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
pVehicle->AutoPilot.m_nNextLane -= 1;
}
}
pVehicle->AutoPilot.m_nNextLane = min(lanesOnNextNode - 1, pVehicle->AutoPilot.m_nNextLane);
pVehicle->AutoPilot.m_nNextLane = max(0, pVehicle->AutoPilot.m_nNextLane);
pVehicle->AutoPilot.m_nNextLane = Min(lanesOnNextNode - 1, pVehicle->AutoPilot.m_nNextLane);
pVehicle->AutoPilot.m_nNextLane = Max(0, pVehicle->AutoPilot.m_nNextLane);
}
else {
pVehicle->AutoPilot.m_nNextLane = pVehicle->AutoPilot.m_nCurrentLane;
@ -1773,7 +1773,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
directionCurrentLinkX, directionCurrentLinkY,
directionNextLinkX, directionNextLinkY
) * (1000.0f / pVehicle->AutoPilot.m_fMaxTrafficSpeed);
pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = max(10, pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = Max(10, pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
}
bool CCarCtrl::PickNextNodeToFollowPath(CVehicle* pVehicle)
@ -1826,8 +1826,8 @@ bool CCarCtrl::PickNextNodeToFollowPath(CVehicle* pVehicle)
else
pVehicle->AutoPilot.m_nNextLane -= 1;
}
pVehicle->AutoPilot.m_nNextLane = min(lanesOnNextNode - 1, pVehicle->AutoPilot.m_nNextLane);
pVehicle->AutoPilot.m_nNextLane = max(0, pVehicle->AutoPilot.m_nNextLane);
pVehicle->AutoPilot.m_nNextLane = Min(lanesOnNextNode - 1, pVehicle->AutoPilot.m_nNextLane);
pVehicle->AutoPilot.m_nNextLane = Max(0, pVehicle->AutoPilot.m_nNextLane);
}
else {
pVehicle->AutoPilot.m_nNextLane = pVehicle->AutoPilot.m_nCurrentLane;
@ -1853,7 +1853,7 @@ bool CCarCtrl::PickNextNodeToFollowPath(CVehicle* pVehicle)
directionCurrentLinkX, directionCurrentLinkY,
directionNextLinkX, directionNextLinkY
) * (1000.0f / pVehicle->AutoPilot.m_fMaxTrafficSpeed);
pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = max(10, pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = Max(10, pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
return false;
}
@ -1965,7 +1965,7 @@ float CCarCtrl::FindSpeedMultiplier(float angleChange, float minAngle, float max
{
float angle = Abs(LimitRadianAngle(angleChange));
float n = angle - minAngle;
n = max(0.0f, n);
n = Max(0.0f, n);
float d = maxAngle - minAngle;
float mult = 1.0f - n / d * (1.0f - coef);
if (n > d)
@ -2252,9 +2252,9 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
angleCurrentLink = FindAngleToWeaveThroughTraffic(pVehicle, nil, angleCurrentLink, angleForward);
float steerAngle = LimitRadianAngle(angleCurrentLink - angleForward);
float maxAngle = FindMaxSteerAngle(pVehicle);
steerAngle = min(maxAngle, max(-maxAngle, steerAngle));
steerAngle = Min(maxAngle, Max(-maxAngle, steerAngle));
if (pVehicle->GetMoveSpeed().Magnitude() > MIN_SPEED_TO_START_LIMITING_STEER)
steerAngle = min(MAX_ANGLE_TO_STEER_AT_HIGH_SPEED, max(-MAX_ANGLE_TO_STEER_AT_HIGH_SPEED, steerAngle));
steerAngle = Min(MAX_ANGLE_TO_STEER_AT_HIGH_SPEED, Max(-MAX_ANGLE_TO_STEER_AT_HIGH_SPEED, steerAngle));
float currentForwardSpeed = DotProduct(pVehicle->GetMoveSpeed(), pVehicle->GetForward()) * GAME_SPEED_TO_CARAI_SPEED;
float speedStyleMultiplier;
switch (pVehicle->AutoPilot.m_nDrivingStyle) {
@ -2298,21 +2298,21 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
speedNodesMultiplier = 1.0f -
(1.0f - scalarDistanceToNextNode / DISTANCE_TO_NEXT_NODE_TO_CONSIDER_SLOWING_DOWN) *
(1.0f - tmpWideMultiplier);
float speedMultiplier = min(speedStyleMultiplier, min(speedAngleMultiplier, speedNodesMultiplier));
float speedMultiplier = Min(speedStyleMultiplier, Min(speedAngleMultiplier, speedNodesMultiplier));
float speed = pVehicle->AutoPilot.m_nCruiseSpeed * speedMultiplier;
float speedDifference = speed - currentForwardSpeed;
if (speed < 0.05f && speedDifference < 0.03f){
*pBrake = 1.0f;
*pAccel = 0.0f;
}else if (speedDifference <= 0.0f){
*pBrake = min(0.5f, -speedDifference * 0.05f);
*pBrake = Min(0.5f, -speedDifference * 0.05f);
*pAccel = 0.0f;
}else if (currentForwardSpeed < 2.0f){
*pBrake = 0.0f;
*pAccel = min(1.0f, speedDifference * 0.25f);
*pAccel = Min(1.0f, speedDifference * 0.25f);
}else{
*pBrake = 0.0f;
*pAccel = min(1.0f, speedDifference * 0.125f);
*pAccel = Min(1.0f, speedDifference * 0.125f);
}
*pSwerve = steerAngle;
*pHandbrake = false;
@ -2332,7 +2332,7 @@ void CCarCtrl::SteerAICarWithPhysicsHeadingForTarget(CVehicle* pVehicle, CPhysic
if (ABS(steerAngle) > MIN_ANGLE_TO_APPLY_HANDBRAKE)
*pHandbrake = true;
float maxAngle = FindMaxSteerAngle(pVehicle);
steerAngle = min(maxAngle, max(-maxAngle, steerAngle));
steerAngle = Min(maxAngle, Max(-maxAngle, steerAngle));
float speedMultiplier = FindSpeedMultiplier(angleToTarget - angleForward,
MIN_ANGLE_FOR_SPEED_LIMITING, MAX_ANGLE_FOR_SPEED_LIMITING, MIN_LOWERING_SPEED_COEFFICIENT);
float speedTarget = pVehicle->AutoPilot.m_nCruiseSpeed * speedMultiplier;
@ -2340,9 +2340,9 @@ void CCarCtrl::SteerAICarWithPhysicsHeadingForTarget(CVehicle* pVehicle, CPhysic
float speedDiff = speedTarget - currentSpeed;
if (speedDiff <= 0.0f){
*pAccel = 0.0f;
*pBrake = min(0.5f, -speedDiff * 0.05f);
*pBrake = Min(0.5f, -speedDiff * 0.05f);
}else if (currentSpeed < 25.0f){
*pAccel = min(1.0f, speedDiff * 0.1f);
*pAccel = Min(1.0f, speedDiff * 0.1f);
*pBrake = 0.0f;
}else{
*pAccel = 1.0f;
@ -2414,7 +2414,7 @@ void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CBoat* pBoat, float target
float angleToTarget = CGeneral::GetATanOfXY(distanceToTarget.x, distanceToTarget.y);
float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
float angleDiff = LimitRadianAngle(angleToTarget - angleForward);
angleDiff = min(DEFAULT_MAX_STEER_ANGLE, max(-DEFAULT_MAX_STEER_ANGLE, angleDiff));
angleDiff = Min(DEFAULT_MAX_STEER_ANGLE, Max(-DEFAULT_MAX_STEER_ANGLE, angleDiff));
float currentSpeed = pBoat->GetMoveSpeed().Magnitude2D(); // +0.0f for some reason
float speedDiff = pBoat->AutoPilot.m_nCruiseSpeed - currentSpeed * 60.0f;
if (speedDiff > 0.0f){

View File

@ -284,7 +284,7 @@ CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, uint16 kill, int32 mode
if (FindPlayerVehicle()) {
player->m_currentWeapon = player->m_nSelectedWepSlot;
player->GetWeapon()->m_nAmmoInClip = min(player->GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(player->GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition);
player->GetWeapon()->m_nAmmoInClip = Min(player->GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(player->GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition);
player->ClearWeaponTarget();
}
}

View File

@ -1,9 +1,10 @@
#pragma once
#include "ModelIndices.h"
#include "WeaponType.h"
class CVehicle;
class CPed;
enum eWeaponType;
enum
{

View File

@ -93,7 +93,7 @@ CGameLogic::Update()
if (pPlayerInfo.m_bGetOutOfHospitalFree) {
pPlayerInfo.m_bGetOutOfHospitalFree = false;
} else {
pPlayerInfo.m_nMoney = max(0, pPlayerInfo.m_nMoney - 1000);
pPlayerInfo.m_nMoney = Max(0, pPlayerInfo.m_nMoney - 1000);
pPlayerInfo.m_pPed->ClearWeapons();
}
@ -163,7 +163,7 @@ CGameLogic::Update()
if (pPlayerInfo.m_bGetOutOfJailFree) {
pPlayerInfo.m_bGetOutOfJailFree = false;
} else {
pPlayerInfo.m_nMoney = max(0, pPlayerInfo.m_nMoney - takeMoney);
pPlayerInfo.m_nMoney = Max(0, pPlayerInfo.m_nMoney - takeMoney);
pPlayerInfo.m_pPed->ClearWeapons();
}

View File

@ -206,12 +206,12 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float Z
return NumGarages++;
}
CGarage* pGarage = &aGarages[NumGarages];
pGarage->m_fX1 = min(X1, X2);
pGarage->m_fX2 = max(X1, X2);
pGarage->m_fY1 = min(Y1, Y2);
pGarage->m_fY2 = max(Y1, Y2);
pGarage->m_fZ1 = min(Z1, Z2);
pGarage->m_fZ2 = max(Z1, Z2);
pGarage->m_fX1 = Min(X1, X2);
pGarage->m_fX2 = Max(X1, X2);
pGarage->m_fY1 = Min(Y1, Y2);
pGarage->m_fY2 = Max(Y1, Y2);
pGarage->m_fZ1 = Min(Z1, Z2);
pGarage->m_fZ2 = Max(Z1, Z2);
pGarage->m_pDoor1 = nil;
pGarage->m_pDoor2 = nil;
pGarage->m_fDoor1Z = Z1;
@ -361,7 +361,7 @@ void CGarage::Update()
}
break;
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_RESPRAY;
@ -440,7 +440,7 @@ void CGarage::Update()
}
if (bTakeMoney) {
if (!CGarages::RespraysAreFree)
CWorld::Players[CWorld::PlayerInFocus].m_nMoney = max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - RESPRAY_PRICE);
CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - RESPRAY_PRICE);
CGarages::TriggerMessage("GA_2", -1, 4000, -1); // New engine and paint job. The cops won't recognize you!
}
else if (bChangedColour) {
@ -458,7 +458,7 @@ void CGarage::Update()
m_fY2 + DISTANCE_TO_CALL_OFF_CHASE);
break;
case GS_OPENING:
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENEDCONTAINSCAR;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -503,7 +503,7 @@ void CGarage::Update()
}
break;
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_SETUP_BOMB;
@ -520,7 +520,7 @@ void CGarage::Update()
}
m_eGarageState = GS_OPENING;
if (!CGarages::BombsAreFree)
CWorld::Players[CWorld::PlayerInFocus].m_nMoney = max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - BOMB_PRICE);
CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - BOMB_PRICE);
if (FindPlayerVehicle() && FindPlayerVehicle()->IsCar()) {
((CAutomobile*)(FindPlayerVehicle()))->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType);
((CAutomobile*)(FindPlayerVehicle()))->m_pBombRigger = FindPlayerPed();
@ -562,7 +562,7 @@ void CGarage::Update()
}
break;
case GS_OPENING:
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENEDCONTAINSCAR;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -597,7 +597,7 @@ void CGarage::Update()
}
break;
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
if (m_bClosingWithoutTargetCar)
@ -626,7 +626,7 @@ void CGarage::Update()
}
break;
case GS_OPENING:
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -663,7 +663,7 @@ void CGarage::Update()
}
break;
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
@ -710,7 +710,7 @@ void CGarage::Update()
m_pTarget = FindPlayerVehicle();
m_pTarget->RegisterReference((CEntity**)&m_pTarget);
}
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -759,7 +759,7 @@ void CGarage::Update()
}
break;
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
@ -799,7 +799,7 @@ void CGarage::Update()
m_pTarget = FindPlayerVehicle();
m_pTarget->RegisterReference((CEntity**)&m_pTarget);
}
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -820,7 +820,7 @@ void CGarage::Update()
m_eGarageState = GS_CLOSING;
break;
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
@ -831,7 +831,7 @@ void CGarage::Update()
case GS_FULLYCLOSED:
break;
case GS_OPENING:
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -865,7 +865,7 @@ void CGarage::Update()
}
case GS_CLOSING:
if (m_pTarget) {
m_fDoorPos = max(0.0f, m_fDoorPos - CRUSHER_CRANE_SPEED * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - CRUSHER_CRANE_SPEED * CTimer::GetTimeStep());
if (m_fDoorPos < TWOPI / 5) {
m_pTarget->bUsesCollision = false;
m_pTarget->bAffectedByGravity = false;
@ -876,7 +876,7 @@ void CGarage::Update()
}
if (m_fDoorPos == 0.0f) {
CGarages::CrushedCarId = CPools::GetVehiclePool()->GetIndex(m_pTarget);
float reward = min(CRUSHER_MAX_REWARD, CRUSHER_MIN_REWARD + m_pTarget->pHandling->nMonetaryValue * m_pTarget->m_fHealth * CRUSHER_REWARD_COEFFICIENT);
float reward = Min(CRUSHER_MAX_REWARD, CRUSHER_MIN_REWARD + m_pTarget->pHandling->nMonetaryValue * m_pTarget->m_fHealth * CRUSHER_REWARD_COEFFICIENT);
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += reward;
DestroyVehicleAndDriverAndPassengers(m_pTarget);
++CStats::CarsCrushed;
@ -900,7 +900,7 @@ void CGarage::Update()
}
break;
case GS_OPENING:
m_fDoorPos = min(HALFPI, m_fDoorPos + CTimer::GetTimeStep() * CRUSHER_CRANE_SPEED);
m_fDoorPos = Min(HALFPI, m_fDoorPos + CTimer::GetTimeStep() * CRUSHER_CRANE_SPEED);
if (m_fDoorPos == HALFPI) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -933,7 +933,7 @@ void CGarage::Update()
}
break;
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
if (m_bClosingWithoutTargetCar)
@ -961,7 +961,7 @@ void CGarage::Update()
m_eGarageState = GS_OPENING;
break;
case GS_OPENING:
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -981,7 +981,7 @@ void CGarage::Update()
case GARAGE_FOR_SCRIPT_TO_OPEN:
switch (m_eGarageState) {
case GS_OPENING:
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -1001,7 +1001,7 @@ void CGarage::Update()
case GARAGE_FOR_SCRIPT_TO_OPEN_AND_CLOSE:
switch (m_eGarageState) {
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
@ -1009,7 +1009,7 @@ void CGarage::Update()
UpdateDoorsHeight();
break;
case GS_OPENING:
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -1050,7 +1050,7 @@ void CGarage::Update()
break;
}
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (!IsPlayerOutsideGarage())
m_eGarageState = GS_OPENING;
else if (m_fDoorPos == 0.0f) {
@ -1096,7 +1096,7 @@ void CGarage::Update()
break;
}
case GS_OPENING:
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -1121,7 +1121,7 @@ void CGarage::Update()
}
break;
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
@ -1137,7 +1137,7 @@ void CGarage::Update()
m_eGarageState = GS_OPENING;
break;
case GS_OPENING:
m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
@ -1695,17 +1695,17 @@ float CGarage::CalcSmallestDistToGarageDoorSquared(float X, float Y)
dist1 = SQR(m_fDoor1X - X) + SQR(m_fDoor1Y - Y);
if (m_pDoor2)
dist2 = SQR(m_fDoor2X - X) + SQR(m_fDoor2Y - Y);
return min(dist1, dist2);
return Min(dist1, dist2);
}
void CGarage::FindDoorsEntities()
{
m_pDoor1 = nil;
m_pDoor2 = nil;
int xstart = max(0, CWorld::GetSectorIndexX(m_fX1));
int xend = min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(m_fX2));
int ystart = max(0, CWorld::GetSectorIndexY(m_fY1));
int yend = min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(m_fY2));
int xstart = Max(0, CWorld::GetSectorIndexX(m_fX1));
int xend = Min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(m_fX2));
int ystart = Max(0, CWorld::GetSectorIndexY(m_fY1));
int yend = Min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(m_fY2));
assert(xstart <= xend);
assert(ystart <= yend);
@ -1891,7 +1891,7 @@ void CGarage::StoreAndRemoveCarsForThisHideout(CStoredCar* aCars, int32 nMax)
pVehicle->GetPosition().y > m_fY1 && pVehicle->GetPosition().y < m_fY2 &&
pVehicle->GetPosition().z > m_fZ1 && pVehicle->GetPosition().z < m_fZ2) {
if (pVehicle->VehicleCreatedBy != MISSION_VEHICLE) {
if (index < max(NUM_GARAGE_STORED_CARS, nMax) && !EntityHasASphereWayOutsideGarage(pVehicle, 1.0f))
if (index < Max(NUM_GARAGE_STORED_CARS, nMax) && !EntityHasASphereWayOutsideGarage(pVehicle, 1.0f))
aCars[index++].StoreCar(pVehicle);
CWorld::Players[CWorld::PlayerInFocus].CancelPlayerEnteringCars(pVehicle);
CWorld::Remove(pVehicle);

View File

@ -55,10 +55,10 @@ CPedPath::CalcPedRoute(int8 pathType, CVector position, CVector destination, CVe
}
CWorld::AdvanceCurrentScanCode();
if (pathType != ROUTE_NO_BLOCKADE) {
const int32 nStartX = max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0);
const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0);
const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1);
const int32 nStartX = Max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0);
const int32 nStartY = Max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0);
const int32 nEndX = Min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = Min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1);
for (int32 y = nStartY; y <= nEndY; y++) {
for (int32 x = nStartX; x <= nEndX; x++) {
CSector *pSector = CWorld::GetSector(x, y);
@ -397,8 +397,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++;
}
@ -582,7 +582,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;
}
}
@ -691,13 +691,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
@ -1466,8 +1466,11 @@ 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;
@ -1486,19 +1489,28 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta
numPathsToTry = 1;
startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex];
}
if(numPathsToTry == 0)
goto fail;
if(numPathsToTry == 0) {
*pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
return;
}
if(startNodeId < 0){
// why only check node 0?
if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != m_pathNodes[targetNode].group)
goto fail;
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)
goto fail;
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;
AddNodeToList(&m_pathNodes[targetNode], 0);
@ -1576,11 +1588,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

@ -296,7 +296,7 @@ void CRecordDataForChase::SaveOrRetrieveCarPositions(void)
case STATE_PLAYBACK:
{
TimeMultiplier += CTimer::GetTimeStepNonClippedInSeconds();
float EndOfFrameTime = CHASE_SCENE_FRAMES_PER_SECOND * min(CHASE_SCENE_LENGTH_IN_SECONDS, TimeMultiplier);
float EndOfFrameTime = CHASE_SCENE_FRAMES_PER_SECOND * Min(CHASE_SCENE_LENGTH_IN_SECONDS, TimeMultiplier);
for (int i = 0; i < NUM_CHASE_CARS; i++) {
if (!pBaseMemForCar[i])
continue;
@ -371,7 +371,7 @@ void CRecordDataForChase::RestoreInfoForCar(CAutomobile* pCar, CCarStateEachFram
else
pCar->GetModelInfo()->ChooseVehicleColour(pCar->m_currentColour1, pCar->m_currentColour2);
}
pCar->m_fHealth = min(pCar->m_fHealth, 500.0f);
pCar->m_fHealth = Min(pCar->m_fHealth, 500.0f);
if (stop) {
pCar->m_fGasPedal = 0.0f;
pCar->m_fBrakePedal = 0.0f;

View File

@ -681,9 +681,9 @@ 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;
@ -1512,9 +1512,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

@ -569,7 +569,7 @@ void CSceneEdit::ProcessCommand(void)
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS;
pActors[m_nActor]->m_pMyVehicle->m_status = STATUS_PHYSICS;
pActors[m_nActor]->m_pMyVehicle->bEngineOn = true;
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = max(16, pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed);
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = Max(16, pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed);
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
TheCamera.TakeControl(pActors[m_nActor]->m_pMyVehicle, CCam::MODE_BEHINDCAR, JUMP_CUT, CAMCONTROL_SCRIPT);
}
@ -847,7 +847,7 @@ void CSceneEdit::PlayBack(void)
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS;
pActors[m_nActor]->m_pMyVehicle->m_status = STATUS_PHYSICS;
pActors[m_nActor]->m_pMyVehicle->bEngineOn = true;
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = max(16, pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed);
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = Max(16, pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed);
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
if (m_nCurrentCommand != MOVIE_GOTO_WAIT)
++m_nCurrentMovieCommand;

View File

@ -5,6 +5,7 @@
#include "Script.h"
#include "ScriptCommands.h"
#include "AnimBlendAssociation.h"
#include "Boat.h"
#include "BulletInfo.h"
#include "Camera.h"
@ -18,11 +19,12 @@
#include "Cranes.h"
#include "Credits.h"
#include "CutsceneMgr.h"
#include "Darkel.h"
#include "DMAudio.h"
#include "Darkel.h"
#include "EmergencyPed.h"
#include "Explosion.h"
#include "FileMgr.h"
#include "Fire.h"
#include "Frontend.h"
#include "Gangs.h"
#include "Garages.h"
@ -31,7 +33,6 @@
#include "Heli.h"
#include "Hud.h"
#include "Lines.h"
#include "main.h"
#include "Messages.h"
#include "ModelIndices.h"
#include "Pad.h"
@ -48,13 +49,12 @@
#include "Population.h"
#include "PowerPoints.h"
#include "ProjectileInfo.h"
#include "Radar.h"
#include "Record.h"
#include "Remote.h"
#include "Restart.h"
#include "Replay.h"
#include "Restart.h"
#include "RpAnimBlend.h"
#include "AnimBlendAssociation.h"
#include "Fire.h"
#include "Rubbish.h"
#include "Shadows.h"
#include "SpecialFX.h"
@ -67,7 +67,7 @@
#include "Weather.h"
#include "World.h"
#include "Zones.h"
#include "Radar.h"
#include "main.h"
#define PICKUP_PLACEMENT_OFFSET 0.5f
#define PED_FIND_Z_OFFSET 5.0f
@ -2004,7 +2004,7 @@ int8 CRunningScript::ProcessCommands100To199(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_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
return 0;
}
@ -2016,7 +2016,7 @@ int8 CRunningScript::ProcessCommands100To199(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_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
return 0;
}
@ -2100,7 +2100,7 @@ int8 CRunningScript::ProcessCommands100To199(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:
@ -3639,7 +3639,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
pos.x = (infX + supX) / 2;
pos.y = (infY + supY) / 2;
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
float radius = max(pos.x - infX, pos.y - infY);
float radius = Max(pos.x - infX, pos.y - infY);
pPed->bScriptObjectiveCompleted = false;
pPed->SetObjective(OBJECTIVE_GUARD_SPOT, pos, radius);
return 0;
@ -4145,7 +4145,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
pos.x = (infX + supX) / 2;
pos.y = (infY + supY) / 2;
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
float radius = max(pos.x - infX, pos.y - infY);
float radius = Max(pos.x - infX, pos.y - infY);
pPed->bScriptObjectiveCompleted = false;
pPed->SetObjective(OBJECTIVE_GOTO_AREA_ON_FOOT, pos, radius);
return 0;
@ -4941,7 +4941,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
pos.x = (infX + supX) / 2;
pos.y = (infY + supY) / 2;
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
float radius = max(pos.x - infX, pos.y - infY);
float radius = Max(pos.x - infX, pos.y - infY);
pPed->bScriptObjectiveCompleted = false;
pPed->SetObjective(OBJECTIVE_RUN_TO_AREA, pos, radius);
return 0;
@ -5363,7 +5363,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
pos.x = (infX + supX) / 2;
pos.y = (infY + supY) / 2;
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
float radius = max(pos.x - infX, pos.y - infY);
float radius = Max(pos.x - infX, pos.y - infY);
pPed->bScriptObjectiveCompleted = false;
pPed->SetObjective(OBJECTIVE_GOTO_AREA_ANY_MEANS, pos, radius);
return 0;
@ -5600,7 +5600,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
pVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_ACCURATE;
pVehicle->m_status = STATUS_PHYSICS;
pVehicle->bEngineOn = true;
pVehicle->AutoPilot.m_nCruiseSpeed = max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
return 0;
}
@ -5715,7 +5715,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
pBoat->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_ASTHECROWSWIMS;
pBoat->AutoPilot.m_vecDestinationCoors = pos;
pBoat->m_status = STATUS_PHYSICS;
pBoat->AutoPilot.m_nCruiseSpeed = max(6, pBoat->AutoPilot.m_nCruiseSpeed);
pBoat->AutoPilot.m_nCruiseSpeed = Max(6, pBoat->AutoPilot.m_nCruiseSpeed);
pBoat->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
return 0;
}
@ -6300,23 +6300,23 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
return 0;
case COMMAND_REGISTER_JUMP_DISTANCE:
CollectParameters(&m_nIp, 1);
CStats::MaximumJumpDistance = max(CStats::MaximumJumpDistance, *(float*)&ScriptParams[0]);
CStats::MaximumJumpDistance = Max(CStats::MaximumJumpDistance, *(float*)&ScriptParams[0]);
return 0;
case COMMAND_REGISTER_JUMP_HEIGHT:
CollectParameters(&m_nIp, 1);
CStats::MaximumJumpHeight = max(CStats::MaximumJumpHeight, *(float*)&ScriptParams[0]);
CStats::MaximumJumpHeight = Max(CStats::MaximumJumpHeight, *(float*)&ScriptParams[0]);
return 0;
case COMMAND_REGISTER_JUMP_FLIPS:
CollectParameters(&m_nIp, 1);
CStats::MaximumJumpFlips = max(CStats::MaximumJumpFlips, ScriptParams[0]);
CStats::MaximumJumpFlips = Max(CStats::MaximumJumpFlips, ScriptParams[0]);
return 0;
case COMMAND_REGISTER_JUMP_SPINS:
CollectParameters(&m_nIp, 1);
CStats::MaximumJumpSpins = max(CStats::MaximumJumpSpins, ScriptParams[0]);
CStats::MaximumJumpSpins = Max(CStats::MaximumJumpSpins, ScriptParams[0]);
return 0;
case COMMAND_REGISTER_JUMP_STUNT:
CollectParameters(&m_nIp, 1);
CStats::BestStuntJump = max(CStats::BestStuntJump, ScriptParams[0]);
CStats::BestStuntJump = Max(CStats::BestStuntJump, ScriptParams[0]);
return 0;
case COMMAND_REGISTER_UNIQUE_JUMP_FOUND:
++CStats::NumberOfUniqueJumpsFound;
@ -6849,10 +6849,10 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
CVector cp4 = tmp_matrix * CVector(pColModel->boundingBox.min.x, pColModel->boundingBox.min.y, pColModel->boundingBox.max.z);
int16 collisions;
CWorld::FindObjectsIntersectingAngledCollisionBox(pColModel->boundingBox, tmp_matrix, pos,
min(cp1.x, min(cp2.x, min(cp3.x, cp4.x))),
min(cp1.y, min(cp2.y, min(cp3.y, cp4.y))),
max(cp1.x, max(cp2.x, max(cp3.x, cp4.x))),
max(cp1.y, max(cp2.y, max(cp3.y, cp4.y))),
Min(cp1.x, Min(cp2.x, Min(cp3.x, cp4.x))),
Min(cp1.y, Min(cp2.y, Min(cp3.y, cp4.y))),
Max(cp1.x, Max(cp2.x, Max(cp3.x, cp4.x))),
Max(cp1.y, Max(cp2.y, Max(cp3.y, cp4.y))),
&collisions, 2, nil, false, true, true, false, false);
if (collisions > 0)
obstacleInPath = true;
@ -6904,10 +6904,10 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
CVector cp4 = tmp_matrix * CVector(pColModel->boundingBox.min.x, pColModel->boundingBox.min.y, pColModel->boundingBox.max.z);
int16 collisions;
CWorld::FindObjectsIntersectingAngledCollisionBox(pColModel->boundingBox, tmp_matrix, newPosition,
min(cp1.x, min(cp2.x, min(cp3.x, cp4.x))),
min(cp1.y, min(cp2.y, min(cp3.y, cp4.y))),
max(cp1.x, max(cp2.x, max(cp3.x, cp4.x))),
max(cp1.y, max(cp2.y, max(cp3.y, cp4.y))),
Min(cp1.x, Min(cp2.x, Min(cp3.x, cp4.x))),
Min(cp1.y, Min(cp2.y, Min(cp3.y, cp4.y))),
Max(cp1.x, Max(cp2.x, Max(cp3.x, cp4.x))),
Max(cp1.y, Max(cp2.y, Max(cp3.y, cp4.y))),
&collisions, 2, nil, false, true, true, false, false);
if (collisions > 0)
obstacleInPath = true;
@ -7740,7 +7740,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
CVector pos = *(CVector*)&ScriptParams[1];
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
float size = max(0.0f, *(float*)&ScriptParams[7]);
float size = Max(0.0f, *(float*)&ScriptParams[7]);
eParticleObjectType type = (eParticleObjectType)ScriptParams[0];
RwRGBA color;
if (type == POBJECT_SMOKE_TRAIL){
@ -11450,22 +11450,22 @@ void CTheScripts::HighlightImportantAngledArea(uint32 id, float x1, float y1, fl
supY = infY = Y;
X = (x2 + x3) / 2;
Y = (y2 + y3) / 2;
infX = min(infX, X);
supX = max(supX, X);
infY = min(infY, Y);
supY = max(supY, Y);
infX = Min(infX, X);
supX = Max(supX, X);
infY = Min(infY, Y);
supY = Max(supY, Y);
X = (x3 + x4) / 2;
Y = (y3 + y4) / 2;
infX = min(infX, X);
supX = max(supX, X);
infY = min(infY, Y);
supY = max(supY, Y);
infX = Min(infX, X);
supX = Max(supX, X);
infY = Min(infY, Y);
supY = Max(supY, Y);
X = (x4 + x1) / 2;
Y = (y4 + y1) / 2;
infX = min(infX, X);
supX = max(supX, X);
infY = min(infY, Y);
supY = max(supY, Y);
infX = Min(infX, X);
supX = Max(supX, X);
infY = Min(infY, Y);
supY = Max(supY, Y);
CVector center;
center.x = (infX + supX) / 2;
center.y = (infY + supY) / 2;

View File

@ -1,19 +1,19 @@
#include "common.h"
#include "General.h"
#include "Camera.h"
#include "World.h"
#include "PathFind.h"
#include "Timer.h"
#include "Clock.h"
#include "Weather.h"
#include "Timecycle.h"
#include "Pointlights.h"
#include "Shadows.h"
#include "Coronas.h"
#include "General.h"
#include "PathFind.h"
#include "PointLights.h"
#include "Shadows.h"
#include "SpecialFX.h"
#include "Vehicle.h"
#include "Timecycle.h"
#include "Timer.h"
#include "TrafficLights.h"
#include "Vehicle.h"
#include "Weather.h"
#include "World.h"
// TODO: figure out the meaning of this
enum { SOME_FLAG = 0x80 };
@ -39,10 +39,10 @@ CTrafficLights::DisplayActualLight(CEntity *ent)
float zMax = mi->Get2dEffect(0)->pos.z;
for(i = 1; i < 6; i++){
assert(mi->Get2dEffect(i));
yMin = min(yMin, mi->Get2dEffect(i)->pos.y);
yMax = max(yMax, mi->Get2dEffect(i)->pos.y);
zMin = min(zMin, mi->Get2dEffect(i)->pos.z);
zMax = max(zMax, mi->Get2dEffect(i)->pos.z);
yMin = Min(yMin, mi->Get2dEffect(i)->pos.y);
yMax = Max(yMax, mi->Get2dEffect(i)->pos.y);
zMin = Min(zMin, mi->Get2dEffect(i)->pos.z);
zMax = Max(zMax, mi->Get2dEffect(i)->pos.z);
}
CVector pos1, pos2;

View File

@ -117,9 +117,9 @@ CCam::Process(void)
float FwdSpeedX = ((CVehicle*)CamTargetEntity)->GetMoveSpeed().x * Fwd.x;
float FwdSpeedY = ((CVehicle*)CamTargetEntity)->GetMoveSpeed().y * Fwd.y;
if(FwdSpeedX + FwdSpeedY > 0.0f)
TargetSpeedVar = min(Sqrt(SQR(FwdSpeedX) + SQR(FwdSpeedY))/0.9f, 1.0f);
TargetSpeedVar = Min(Sqrt(SQR(FwdSpeedX) + SQR(FwdSpeedY))/0.9f, 1.0f);
else
TargetSpeedVar = -min(Sqrt(SQR(FwdSpeedX) + SQR(FwdSpeedY))/1.8f, 0.5f);
TargetSpeedVar = -Min(Sqrt(SQR(FwdSpeedX) + SQR(FwdSpeedY))/1.8f, 0.5f);
SpeedVar = 0.895f*SpeedVar + 0.105*TargetSpeedVar;
}else{
CameraTarget = CamTargetEntity->GetPosition();
@ -341,7 +341,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
@ -467,7 +467,7 @@ CCam::ProcessSpecialHeightRoutines(void)
vehicle->IsVehicle()){
float height = vehicle->GetColModel()->boundingBox.GetSize().z;
if(FoundCar){
HighestCar = max(HighestCar, height);
HighestCar = Max(HighestCar, height);
}else{
FoundCar = true;
HighestCar = height;
@ -481,7 +481,7 @@ CCam::ProcessSpecialHeightRoutines(void)
vehicle->IsVehicle()){
float height = vehicle->GetColModel()->boundingBox.GetSize().z;
if(FoundCar){
HighestCar = max(HighestCar, height);
HighestCar = Max(HighestCar, height);
}else{
FoundCar = true;
HighestCar = height;
@ -1323,7 +1323,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
else if(ReqSpeed > 0.0f && BetaSpeed > ReqSpeed)
BetaSpeed = ReqSpeed;
Beta += BetaSpeed * min(10.0f, CTimer::GetTimeStep());
Beta += BetaSpeed * Min(10.0f, CTimer::GetTimeStep());
*/
WellBufferMe(FixedTargetOrientation, &Beta, &BetaSpeed, MaxSpeed, Acceleration, true);
@ -1398,7 +1398,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
// Process height offset to avoid peds and cars
float TargetZOffSet = m_fRoadOffSet + m_fDimensionOfHighestNearCar;
TargetZOffSet = max(TargetZOffSet, m_fPedBetweenCameraHeightOffset);
TargetZOffSet = Max(TargetZOffSet, m_fPedBetweenCameraHeightOffset);
float TargetHeight = CameraTarget.z + TargetZOffSet - Source.z;
if(TargetHeight > m_fCamBufferedHeight){
@ -1454,7 +1454,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;
@ -1553,7 +1553,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient
#else
if(Alpha > fBaseDist) // comparing an angle against a distance?
#endif
CamDist = fBaseDist + Cos(min(Alpha*fFalloff, HALFPI))*fAngleDist;
CamDist = fBaseDist + Cos(Min(Alpha*fFalloff, HALFPI))*fAngleDist;
else
CamDist = fBaseDist + Cos(Alpha)*fAngleDist;
@ -1585,14 +1585,14 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient
PedColDist = (TargetCoors - colPoint.point).Magnitude();
Source = colPoint.point;
if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f));
}else{
RwCameraSetNearClipPlane(Scene.camera, min(ColCamDist-0.35f, DEFAULT_NEAR));
RwCameraSetNearClipPlane(Scene.camera, Min(ColCamDist-0.35f, DEFAULT_NEAR));
}
}else{
Source = colPoint.point;
if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f));
}
}
CWorld::pIgnoreEntity = nil;
@ -1609,7 +1609,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient
float dist = (CamToCol - Front*frontDist).Magnitude() / ViewPlaneWidth;
// Try to decrease near clip
dist = max(min(Near, dist), 0.1f);
dist = Max(Min(Near, dist), 0.1f);
if(dist < Near)
RwCameraSetNearClipPlane(Scene.camera, dist);
@ -1639,7 +1639,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient
float PlayerDist = (Source - player->GetPosition()).Magnitude();
if(PlayerDist < 2.75f)
Near = PlayerDist/2.75f * DEFAULT_NEAR - 0.3f;
RwCameraSetNearClipPlane(Scene.camera, max(Near, 0.1f));
RwCameraSetNearClipPlane(Scene.camera, Max(Near, 0.1f));
}
}
@ -1881,7 +1881,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;
@ -2139,7 +2139,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;
@ -2361,7 +2361,7 @@ CCam::Process_TopDownPed(const CVector &CameraTarget, float TargetOrientation, f
if(FindPlayerPed()->m_pPointGunAt){
Dist = (FindPlayerPed()->m_pPointGunAt->GetPosition() - CameraTarget).Magnitude2D();
if(Dist > 6.0f)
HeightTarget = max(HeightTarget, Dist/22.0f*37.0f);
HeightTarget = Max(HeightTarget, Dist/22.0f*37.0f);
}
Source = TargetCoors + CVector(0.0f, -1.0f, 9.0f);
@ -2826,13 +2826,13 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float,
m_vecBufferedPlayerBodyOffset.z =
TheCamera.m_fGaitSwayBuffer * m_vecBufferedPlayerBodyOffset.z +
(1.0f-TheCamera.m_fGaitSwayBuffer) * HeadPos.z;
HeadPos = RwV3d(CamTargetEntity->GetMatrix() * m_vecBufferedPlayerBodyOffset);
HeadPos = (CamTargetEntity->GetMatrix() * m_vecBufferedPlayerBodyOffset).toRwV3d();
}else{
float HeadDelta = (HeadPos - InitialHeadPos).Magnitude2D();
CVector Fwd = CamTargetEntity->GetForward();
Fwd.z = 0.0f;
Fwd.Normalise();
HeadPos = RwV3d(HeadDelta*1.23f*Fwd + CamTargetEntity->GetPosition());
HeadPos = (HeadDelta*1.23f*Fwd + CamTargetEntity->GetPosition()).toRwV3d();
HeadPos.z += 0.59f;
}
Source = HeadPos;
@ -3138,7 +3138,7 @@ CCam::Process_Syphon(const CVector &CameraTarget, float, float, float)
Front = TargetCoors - Source;
m_fMinDistAwayFromCamWhenInterPolating = Front.Magnitude2D();
if(m_fMinDistAwayFromCamWhenInterPolating < 1.1f)
RwCameraSetNearClipPlane(Scene.camera, max(m_fMinDistAwayFromCamWhenInterPolating - 0.35f, 0.05f));
RwCameraSetNearClipPlane(Scene.camera, Max(m_fMinDistAwayFromCamWhenInterPolating - 0.35f, 0.05f));
Front.Normalise();
GetVectorsReadyForRW();
}
@ -3395,7 +3395,7 @@ CCam::Process_Fight_Cam(const CVector &CameraTarget, float TargetOrientation, fl
WellBufferMe(TargetOrientation, &m_fBufferedTargetOrientation, &m_fBufferedTargetOrientationSpeed, 0.07f, 0.004f, true);
TargetCoors = CameraTarget + 0.5f*CVector(Cos(m_fBufferedTargetOrientation), Sin(m_fBufferedTargetOrientation), 0.0f);
TargetCamHeight = CameraTarget.z - Source.z + max(m_fPedBetweenCameraHeightOffset, m_fRoadOffSet + m_fDimensionOfHighestNearCar) - 0.5f;
TargetCamHeight = CameraTarget.z - Source.z + Max(m_fPedBetweenCameraHeightOffset, m_fRoadOffSet + m_fDimensionOfHighestNearCar) - 0.5f;
if(TargetCamHeight > m_fCamBufferedHeight)
WellBufferMe(TargetCamHeight, &m_fCamBufferedHeight, &m_fCamBufferedHeightSpeed, 0.15f, 0.04f, false);
else
@ -4569,14 +4569,14 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient
PedColDist = (TargetCoors - colPoint.point).Magnitude();
Source = colPoint.point;
if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f));
}else{
RwCameraSetNearClipPlane(Scene.camera, min(ColCamDist-0.35f, DEFAULT_NEAR));
RwCameraSetNearClipPlane(Scene.camera, Min(ColCamDist-0.35f, DEFAULT_NEAR));
}
}else{
Source = colPoint.point;
if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f));
}
}
CWorld::pIgnoreEntity = nil;
@ -4593,7 +4593,7 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient
float dist = (CamToCol - Front*frontDist).Magnitude() / ViewPlaneWidth;
// Try to decrease near clip
dist = max(min(Near, dist), 0.1f);
dist = Max(Min(Near, dist), 0.1f);
if(dist < Near)
RwCameraSetNearClipPlane(Scene.camera, dist);
@ -4727,7 +4727,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
minDistForVehType = minDistForVehType * 0.65f;
}
float nextDistance = max(newDistance, minDistForVehType);
float nextDistance = Max(newDistance, minDistForVehType);
CA_MAX_DISTANCE = newDistance;
CA_MIN_DISTANCE = 3.5f;
@ -4824,7 +4824,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float betaChangeMult2 = (car->m_vecMoveSpeed - DotProduct(car->m_vecMoveSpeed, Front) * Front).Magnitude();
float betaChange = min(1.0f, betaChangeMult1 * betaChangeMult2) * (velocityRightHeading - camRightHeading);
float betaChange = Min(1.0f, betaChangeMult1 * betaChangeMult2) * (velocityRightHeading - camRightHeading);
if (betaChange <= betaChangeLimit) {
if (betaChange < -betaChangeLimit)
betaChange = -betaChangeLimit;
@ -4840,7 +4840,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float carPosChange = (TargetCoors - m_aTargetHistoryPosTwo).Magnitude();
if (carPosChange < newDistance && newDistance > minDistForThisCar) {
newDistance = max(minDistForThisCar, carPosChange);
newDistance = Max(minDistForThisCar, carPosChange);
}
float maxAlphaAllowed = CARCAM_SET[camSetArrPos][13];
@ -4864,7 +4864,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
v200 = (1.5f - carCol->boundingBox.min.y) / Cos(v88);
} else {
float a6g = 1.2f + carCol->boundingBox.max.x;
v200 = a6g / Cos(max(0.0f, HALFPI - v88));
v200 = a6g / Cos(Max(0.0f, HALFPI - v88));
}
maxAlphaAllowed = Cos(Beta - (car->GetForward().Heading() - HALFPI)) * Atan2(car->GetForward().z, car->GetForward().Magnitude2D())
+ Atan2(TargetCoors.z - car->GetPosition().z + car->GetHeightAboveRoad(), v200 * 1.2f);
@ -4957,7 +4957,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
yMovement = 0.0;
xMovement = 0.0;
targetAlpha = Alpha;
stepsLeftToChangeBetaByMouse = max(0.0f, stepsLeftToChangeBetaByMouse - CTimer::GetTimeStep());
stepsLeftToChangeBetaByMouse = Max(0.0f, stepsLeftToChangeBetaByMouse - CTimer::GetTimeStep());
mouseChangesBeta = true;
}
}
@ -4976,7 +4976,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float newAngleSpeedMaxBlendAmount = CARCAM_SET[camSetArrPos][9];
float angleChangeStep = pow(CARCAM_SET[camSetArrPos][8], CTimer::GetTimeStep());
float targetBetaWithStickBlendAmount = betaSpeedFromStickX + (targetBeta - Beta) / max(CTimer::GetTimeStep(), 1.0f);
float targetBetaWithStickBlendAmount = betaSpeedFromStickX + (targetBeta - Beta) / Max(CTimer::GetTimeStep(), 1.0f);
if (targetBetaWithStickBlendAmount < -newAngleSpeedMaxBlendAmount)
targetBetaWithStickBlendAmount = -newAngleSpeedMaxBlendAmount;
@ -5101,7 +5101,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
if (!foundEnt->IsPed() || obstacleCamDist <= 1.0f) {
Source = foundCol.point;
if (obstacleTargetDist < 1.2f) {
RwCameraSetNearClipPlane(Scene.camera, max(0.05f, obstacleTargetDist - 0.3f));
RwCameraSetNearClipPlane(Scene.camera, Max(0.05f, obstacleTargetDist - 0.3f));
}
} else {
if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, true, false, true, false)) {

View File

@ -485,7 +485,7 @@ CCamera::Process(void)
GetPosition().z += shakeOffset*(((shakeRand&0xF00)>>8)-7);
if(shakeOffset > 0.0f && m_BlurType != MBLUR_SNIPER)
SetMotionBlurAlpha(min((int)(shakeStrength*255.0f) + 25, 150));
SetMotionBlurAlpha(Min((int)(shakeStrength*255.0f) + 25, 150));
if(Cams[ActiveCam].Mode == CCam::MODE_1STPERSON && FindPlayerVehicle() && FindPlayerVehicle()->GetUp().z < 0.2f)
SetMotionBlur(230, 230, 230, 215, MBLUR_NORMAL);
@ -507,19 +507,19 @@ CCamera::Process(void)
CDraw::SetFOV(Cams[2].FOV);
m_vecGameCamPos = Cams[ActiveCam].Source;
*RwMatrixGetPos(RwFrameGetMatrix(frame)) = (RwV3d)GetPosition();
*RwMatrixGetAt(RwFrameGetMatrix(frame)) = (RwV3d)GetForward();
*RwMatrixGetUp(RwFrameGetMatrix(frame)) = (RwV3d)GetUp();
*RwMatrixGetRight(RwFrameGetMatrix(frame)) = (RwV3d)GetRight();
*RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition().toRwV3d();
*RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward().toRwV3d();
*RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp().toRwV3d();
*RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight().toRwV3d();
RwMatrixUpdate(RwFrameGetMatrix(frame));
RwFrameUpdateObjects(frame);
}else{
RwFrame *frame = RwCameraGetFrame(m_pRwCamera);
m_vecGameCamPos = GetPosition();
*RwMatrixGetPos(RwFrameGetMatrix(frame)) = (RwV3d)GetPosition();
*RwMatrixGetAt(RwFrameGetMatrix(frame)) = (RwV3d)GetForward();
*RwMatrixGetUp(RwFrameGetMatrix(frame)) = (RwV3d)GetUp();
*RwMatrixGetRight(RwFrameGetMatrix(frame)) = (RwV3d)GetRight();
*RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition().toRwV3d();
*RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward().toRwV3d();
*RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp().toRwV3d();
*RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight().toRwV3d();
RwMatrixUpdate(RwFrameGetMatrix(frame));
RwFrameUpdateObjects(frame);
}
@ -786,27 +786,27 @@ CCamera::CamControl(void)
if(m_bUseScriptZoomValueCar){
if(CarZoomValueSmooth < m_fCarZoomValueScript){
CarZoomValueSmooth += 0.12f * CTimer::GetTimeStep();
CarZoomValueSmooth = min(CarZoomValueSmooth, m_fCarZoomValueScript);
CarZoomValueSmooth = Min(CarZoomValueSmooth, m_fCarZoomValueScript);
}else{
CarZoomValueSmooth -= 0.12f * CTimer::GetTimeStep();
CarZoomValueSmooth = max(CarZoomValueSmooth, m_fCarZoomValueScript);
CarZoomValueSmooth = Max(CarZoomValueSmooth, m_fCarZoomValueScript);
}
}else if(m_bFailedCullZoneTestPreviously){
CloseInCarHeightTarget = 0.65f;
if(CarZoomValueSmooth < -0.65f){
CarZoomValueSmooth += 0.12f * CTimer::GetTimeStep();
CarZoomValueSmooth = min(CarZoomValueSmooth, -0.65f);
CarZoomValueSmooth = Min(CarZoomValueSmooth, -0.65f);
}else{
CarZoomValueSmooth -= 0.12f * CTimer::GetTimeStep();
CarZoomValueSmooth = max(CarZoomValueSmooth, -0.65f);
CarZoomValueSmooth = Max(CarZoomValueSmooth, -0.65f);
}
}else{
if(CarZoomValueSmooth < CarZoomValue){
CarZoomValueSmooth += 0.12f * CTimer::GetTimeStep();
CarZoomValueSmooth = min(CarZoomValueSmooth, CarZoomValue);
CarZoomValueSmooth = Min(CarZoomValueSmooth, CarZoomValue);
}else{
CarZoomValueSmooth -= 0.12f * CTimer::GetTimeStep();
CarZoomValueSmooth = max(CarZoomValueSmooth, CarZoomValue);
CarZoomValueSmooth = Max(CarZoomValueSmooth, CarZoomValue);
}
}
@ -890,28 +890,28 @@ CCamera::CamControl(void)
if(m_bUseScriptZoomValuePed){
if(m_fPedZoomValueSmooth < m_fPedZoomValueScript){
m_fPedZoomValueSmooth += 0.12f * CTimer::GetTimeStep();
m_fPedZoomValueSmooth = min(m_fPedZoomValueSmooth, m_fPedZoomValueScript);
m_fPedZoomValueSmooth = Min(m_fPedZoomValueSmooth, m_fPedZoomValueScript);
}else{
m_fPedZoomValueSmooth -= 0.12f * CTimer::GetTimeStep();
m_fPedZoomValueSmooth = max(m_fPedZoomValueSmooth, m_fPedZoomValueScript);
m_fPedZoomValueSmooth = Max(m_fPedZoomValueSmooth, m_fPedZoomValueScript);
}
}else if(m_bFailedCullZoneTestPreviously){
static float PedZoomedInVal = 0.5f;
CloseInPedHeightTarget = 0.7f;
if(m_fPedZoomValueSmooth < PedZoomedInVal){
m_fPedZoomValueSmooth += 0.12f * CTimer::GetTimeStep();
m_fPedZoomValueSmooth = min(m_fPedZoomValueSmooth, PedZoomedInVal);
m_fPedZoomValueSmooth = Min(m_fPedZoomValueSmooth, PedZoomedInVal);
}else{
m_fPedZoomValueSmooth -= 0.12f * CTimer::GetTimeStep();
m_fPedZoomValueSmooth = max(m_fPedZoomValueSmooth, PedZoomedInVal);
m_fPedZoomValueSmooth = Max(m_fPedZoomValueSmooth, PedZoomedInVal);
}
}else{
if(m_fPedZoomValueSmooth < m_fPedZoomValue){
m_fPedZoomValueSmooth += 0.12f * CTimer::GetTimeStep();
m_fPedZoomValueSmooth = min(m_fPedZoomValueSmooth, m_fPedZoomValue);
m_fPedZoomValueSmooth = Min(m_fPedZoomValueSmooth, m_fPedZoomValue);
}else{
m_fPedZoomValueSmooth -= 0.12f * CTimer::GetTimeStep();
m_fPedZoomValueSmooth = max(m_fPedZoomValueSmooth, m_fPedZoomValue);
m_fPedZoomValueSmooth = Max(m_fPedZoomValueSmooth, m_fPedZoomValue);
}
}
@ -2274,7 +2274,7 @@ CCamera::IsItTimeForNewcam(int32 obbeMode, int32 time)
if(fwd.Magnitude() < 2.0f)
// very close, fix near clip
SetNearClipScript(max(fwd.Magnitude()*0.5f, 0.05f));
SetNearClipScript(Max(fwd.Magnitude()*0.5f, 0.05f));
// too far and driving away from cam
if(fwd.Magnitude() > 19.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f)
return true;

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++){

36
src/core/Crime.h Normal file
View File

@ -0,0 +1,36 @@
#pragma once
enum eCrimeType {
CRIME_NONE,
CRIME_POSSESSION_GUN,
CRIME_HIT_PED,
CRIME_HIT_COP,
CRIME_SHOOT_PED,
CRIME_SHOOT_COP,
CRIME_STEAL_CAR,
CRIME_RUN_REDLIGHT,
CRIME_RECKLESS_DRIVING,
CRIME_SPEEDING,
CRIME_RUNOVER_PED,
CRIME_RUNOVER_COP,
CRIME_SHOOT_HELI,
CRIME_PED_BURNED,
CRIME_COP_BURNED,
CRIME_VEHICLE_BURNED,
CRIME_DESTROYED_CESSNA,
NUM_CRIME_TYPES
};
class CCrimeBeingQd
{
public:
eCrimeType m_nType;
uint32 m_nId;
uint32 m_nTime;
CVector m_vecPosn;
bool m_bReported;
bool m_bPoliceDoesntCare;
CCrimeBeingQd() { };
~CCrimeBeingQd() { };
};

View File

@ -349,8 +349,8 @@ CMenuManager::PageUpList(bool playSoundOnSuccess)
if(playSoundOnSuccess)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0);
m_nFirstVisibleRowOnList = max(0, m_nFirstVisibleRowOnList - MAX_VISIBLE_LIST_ROW);
m_nSelectedListRow = min(m_nSelectedListRow, m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW - 1);
m_nFirstVisibleRowOnList = Max(0, m_nFirstVisibleRowOnList - MAX_VISIBLE_LIST_ROW);
m_nSelectedListRow = Min(m_nSelectedListRow, m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW - 1);
} else {
m_nFirstVisibleRowOnList = 0;
m_nSelectedListRow = 0;
@ -367,8 +367,8 @@ CMenuManager::PageDownList(bool playSoundOnSuccess)
if(playSoundOnSuccess)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0);
m_nFirstVisibleRowOnList = min(m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW, m_nTotalListRow - MAX_VISIBLE_LIST_ROW);
m_nSelectedListRow = max(m_nSelectedListRow, m_nFirstVisibleRowOnList);
m_nFirstVisibleRowOnList = Min(m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW, m_nTotalListRow - MAX_VISIBLE_LIST_ROW);
m_nSelectedListRow = Max(m_nSelectedListRow, m_nFirstVisibleRowOnList);
} else {
m_nFirstVisibleRowOnList = m_nTotalListRow - MAX_VISIBLE_LIST_ROW;
m_nSelectedListRow = m_nTotalListRow - 1;
@ -643,7 +643,7 @@ CMenuManager::DisplaySlider(float x, float y, float mostLeftBarSize, float mostR
} else
color = CRGBA(185, 120, 0, FadeIn(255));
maxBarHeight = max(mostLeftBarSize, mostRightBarSize);
maxBarHeight = Max(mostLeftBarSize, mostRightBarSize);
float curBarFreeSpace = ((16 - i) * mostLeftBarSize + i * mostRightBarSize) / 16.0f;
float left = curBarX;
@ -2492,7 +2492,7 @@ CMenuManager::DrawPlayerSetupScreen()
strncpy(&m_pSelectedSkin->skinNameDisplayed[k], "(", 1);
if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "}", 1))
strncpy(&m_pSelectedSkin->skinNameDisplayed[k], ")", 1);
if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "£", 1))
if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "<EFBFBD>", 1))
strncpy(&m_pSelectedSkin->skinNameDisplayed[k], "$", 1);
}
@ -2829,7 +2829,7 @@ CMenuManager::FadeIn(int alpha)
m_nCurrScreen == MENUPAGE_DELETING)
return alpha;
return min(m_nMenuFadeAlpha, alpha);
return Min(m_nMenuFadeAlpha, alpha);
}
void
@ -5426,7 +5426,7 @@ CMenuManager::PrintMap(void)
if (fMapCenterY + fMapSize < SCREEN_HEIGHT - MENU_Y(60.0f))
fMapCenterY = SCREEN_HEIGHT - MENU_Y(60.0f) - fMapSize;
fMapCenterY = min(fMapCenterY, fMapSize); // To not show beyond north border
fMapCenterY = Min(fMapCenterY, fMapSize); // To not show beyond north border
bMenuMapActive = false;
@ -5488,7 +5488,7 @@ CMenuManager::ConstructStatLine(int rowIdx)
int percentCompleted = (CStats::TotalProgressInGame == 0 ? 0 :
CStats::ProgressMade * 100.0f / (CGame::nastyGame ? CStats::TotalProgressInGame : CStats::TotalProgressInGame - 1));
percentCompleted = min(percentCompleted, 100);
percentCompleted = Min(percentCompleted, 100);
STAT_LINE("PER_COM", &percentCompleted, false, nil);
STAT_LINE("NMISON", &CStats::MissionsGiven, false, nil);

View File

@ -1,4 +1,4 @@
#pragma
#pragma once
#include "Sprite2d.h"

View File

@ -72,7 +72,7 @@
#include "Streaming.h"
#include "SurfaceTable.h"
#include "TempColModels.h"
#include "TimeCycle.h"
#include "Timecycle.h"
#include "TrafficLights.h"
#include "Train.h"
#include "TxdStore.h"

View File

@ -1,7 +1,6 @@
#pragma once
enum eLevelName
{
enum eLevelName {
LEVEL_IGNORE = -1, // beware, this is only used in CPhysical's m_nZoneLevel
LEVEL_NONE = 0,
LEVEL_INDUSTRIAL,

View File

@ -124,7 +124,7 @@ public:
static bool faststricmp(const char *str1, const char *str2)
{
for (; *str1; str1++, str2++) {
#if MUCH_SLOWER
#if MUCH_SLOWER || !defined _WIN32 || defined __MINGW32__
if (toupper(*str1) != toupper(*str2))
#else
if (__ascii_toupper(*str1) != __ascii_toupper(*str2))

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

@ -6,7 +6,7 @@
#include "common.h"
#ifdef XINPUT
#include <Xinput.h>
#include <xinput.h>
#pragma comment( lib, "Xinput9_1_0.lib" )
#endif
@ -205,7 +205,7 @@ void ArmourCheat()
void WantedLevelUpCheat()
{
CHud::SetHelpMessage(TheText.Get("CHEAT5"), true);
FindPlayerPed()->SetWantedLevel(min(FindPlayerPed()->m_pWanted->m_nWantedLevel + 2, 6));
FindPlayerPed()->SetWantedLevel(Min(FindPlayerPed()->m_pWanted->m_nWantedLevel + 2, 6));
}
void WantedLevelDownCheat()
@ -513,10 +513,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

@ -1,35 +1,35 @@
#include "common.h"
#include "main.h"
#include "PlayerPed.h"
#include "Wanted.h"
#include "PlayerInfo.h"
#include "Automobile.h"
#include "Bridge.h"
#include "Camera.h"
#include "Cranes.h"
#include "Darkel.h"
#include "Explosion.h"
#include "Fire.h"
#include "Frontend.h"
#include "PlayerSkin.h"
#include "Darkel.h"
#include "Messages.h"
#include "Text.h"
#include "Stats.h"
#include "Remote.h"
#include "World.h"
#include "Replay.h"
#include "Camera.h"
#include "Pad.h"
#include "ProjectileInfo.h"
#include "Explosion.h"
#include "Script.h"
#include "Automobile.h"
#include "HandlingMgr.h"
#include "General.h"
#include "SpecialFX.h"
#include "Cranes.h"
#include "Bridge.h"
#include "WaterLevel.h"
#include "HandlingMgr.h"
#include "Messages.h"
#include "Pad.h"
#include "PathFind.h"
#include "ZoneCull.h"
#include "PlayerInfo.h"
#include "PlayerPed.h"
#include "PlayerSkin.h"
#include "ProjectileInfo.h"
#include "Remote.h"
#include "Renderer.h"
#include "Replay.h"
#include "Script.h"
#include "SpecialFX.h"
#include "Stats.h"
#include "Streaming.h"
#include "Text.h"
#include "Wanted.h"
#include "WaterLevel.h"
#include "World.h"
#include "ZoneCull.h"
#include "main.h"
void
CPlayerInfo::SetPlayerSkin(char *skin)
@ -184,7 +184,7 @@ CPlayerInfo::MakePlayerSafe(bool toggle)
m_pPed->bExplosionProof = true;
m_pPed->m_bCanBeDamaged = false;
((CPlayerPed*)m_pPed)->ClearAdrenaline();
CancelPlayerEnteringCars(false);
CancelPlayerEnteringCars(nil);
gFireManager.ExtinguishPoint(GetPos(), 4000.0f);
CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f);
CProjectileInfo::RemoveAllProjectiles();

View File

@ -110,7 +110,7 @@ INITSAVEBUF
CStreaming::LoadAllRequestedModels(false);
int32 slot = ReadSaveBuf<int32>(buf);
CVehicle* pVehicle;
char* vbuf = new char[max(sizeof(CAutomobile), sizeof(CBoat))];
char* vbuf = new char[Max(sizeof(CAutomobile), sizeof(CBoat))];
if (type == VEHICLE_TYPE_BOAT) {
memcpy(vbuf, buf, sizeof(CBoat));
SkipSaveBuf(buf, sizeof(CBoat));

View File

@ -52,20 +52,20 @@ void CProfile::SuspendProfile(eProfile profile)
void CProfile::ShowResults()
{
ms_afMaxEndTime[PROFILE_FRAME_RATE] = max(ms_afMaxEndTime[PROFILE_FRAME_RATE], ms_afEndTime[PROFILE_FRAME_RATE]);
ms_afMaxEndTime[PROFILE_PHYSICS] = max(ms_afMaxEndTime[PROFILE_PHYSICS], ms_afEndTime[PROFILE_PHYSICS]);
ms_afMaxEndTime[PROFILE_COLLISION] = max(ms_afMaxEndTime[PROFILE_COLLISION], ms_afEndTime[PROFILE_COLLISION]);
ms_afMaxEndTime[PROFILE_PED_AI] = max(ms_afMaxEndTime[PROFILE_PED_AI], ms_afEndTime[PROFILE_PED_AI]);
ms_afMaxEndTime[PROFILE_PROCESSING_TIME] = max(ms_afMaxEndTime[PROFILE_PROCESSING_TIME], ms_afEndTime[PROFILE_PROCESSING_TIME]);
ms_afMaxEndTime[PROFILE_RENDERING_TIME] = max(ms_afMaxEndTime[PROFILE_RENDERING_TIME], ms_afEndTime[PROFILE_RENDERING_TIME]);
ms_afMaxEndTime[PROFILE_TOTAL] = max(ms_afMaxEndTime[PROFILE_TOTAL], ms_afEndTime[PROFILE_TOTAL]);
ms_afMaxEndTime[PROFILE_FRAME_RATE] = Max(ms_afMaxEndTime[PROFILE_FRAME_RATE], ms_afEndTime[PROFILE_FRAME_RATE]);
ms_afMaxEndTime[PROFILE_PHYSICS] = Max(ms_afMaxEndTime[PROFILE_PHYSICS], ms_afEndTime[PROFILE_PHYSICS]);
ms_afMaxEndTime[PROFILE_COLLISION] = Max(ms_afMaxEndTime[PROFILE_COLLISION], ms_afEndTime[PROFILE_COLLISION]);
ms_afMaxEndTime[PROFILE_PED_AI] = Max(ms_afMaxEndTime[PROFILE_PED_AI], ms_afEndTime[PROFILE_PED_AI]);
ms_afMaxEndTime[PROFILE_PROCESSING_TIME] = Max(ms_afMaxEndTime[PROFILE_PROCESSING_TIME], ms_afEndTime[PROFILE_PROCESSING_TIME]);
ms_afMaxEndTime[PROFILE_RENDERING_TIME] = Max(ms_afMaxEndTime[PROFILE_RENDERING_TIME], ms_afEndTime[PROFILE_RENDERING_TIME]);
ms_afMaxEndTime[PROFILE_TOTAL] = Max(ms_afMaxEndTime[PROFILE_TOTAL], ms_afEndTime[PROFILE_TOTAL]);
ms_afMaxCumulativeTime[PROFILE_FRAME_RATE] = max(ms_afMaxCumulativeTime[PROFILE_FRAME_RATE], ms_afCumulativeTime[PROFILE_FRAME_RATE]);
ms_afMaxCumulativeTime[PROFILE_PHYSICS] = max(ms_afMaxCumulativeTime[PROFILE_PHYSICS], ms_afCumulativeTime[PROFILE_PHYSICS]);
ms_afMaxCumulativeTime[PROFILE_COLLISION] = max(ms_afMaxCumulativeTime[PROFILE_COLLISION], ms_afCumulativeTime[PROFILE_COLLISION]);
ms_afMaxCumulativeTime[PROFILE_PED_AI] = max(ms_afMaxCumulativeTime[PROFILE_PED_AI], ms_afCumulativeTime[PROFILE_PED_AI]);
ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME] = max(ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME], ms_afCumulativeTime[PROFILE_PROCESSING_TIME]);
ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME] = max(ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME], ms_afCumulativeTime[PROFILE_RENDERING_TIME]);
ms_afMaxCumulativeTime[PROFILE_TOTAL] = max(ms_afMaxCumulativeTime[PROFILE_TOTAL], ms_afCumulativeTime[PROFILE_TOTAL]);
ms_afMaxCumulativeTime[PROFILE_FRAME_RATE] = Max(ms_afMaxCumulativeTime[PROFILE_FRAME_RATE], ms_afCumulativeTime[PROFILE_FRAME_RATE]);
ms_afMaxCumulativeTime[PROFILE_PHYSICS] = Max(ms_afMaxCumulativeTime[PROFILE_PHYSICS], ms_afCumulativeTime[PROFILE_PHYSICS]);
ms_afMaxCumulativeTime[PROFILE_COLLISION] = Max(ms_afMaxCumulativeTime[PROFILE_COLLISION], ms_afCumulativeTime[PROFILE_COLLISION]);
ms_afMaxCumulativeTime[PROFILE_PED_AI] = Max(ms_afMaxCumulativeTime[PROFILE_PED_AI], ms_afCumulativeTime[PROFILE_PED_AI]);
ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME] = Max(ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME], ms_afCumulativeTime[PROFILE_PROCESSING_TIME]);
ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME] = Max(ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME], ms_afCumulativeTime[PROFILE_RENDERING_TIME]);
ms_afMaxCumulativeTime[PROFILE_TOTAL] = Max(ms_afMaxCumulativeTime[PROFILE_TOTAL], ms_afCumulativeTime[PROFILE_TOTAL]);
}
#endif

View File

@ -121,13 +121,13 @@ void CStats::RegisterFastestTime(int32 index, int32 time)
if (FastestTimes[index] == 0)
FastestTimes[index] = time;
else
FastestTimes[index] = min(FastestTimes[index], time);
FastestTimes[index] = Min(FastestTimes[index], time);
}
void CStats::RegisterHighestScore(int32 index, int32 score)
{
assert(index >= 0 && index < TOTAL_HIGHEST_SCORES);
HighestScores[index] = max(HighestScores[index], score);
HighestScores[index] = Max(HighestScores[index], score);
}
void CStats::RegisterElBurroTime(int32 time)
@ -167,7 +167,7 @@ void CStats::AnotherCriminalCaught()
void CStats::RegisterLevelAmbulanceMission(int32 level)
{
HighestLevelAmbulanceMission = max(HighestLevelAmbulanceMission, level);
HighestLevelAmbulanceMission = Max(HighestLevelAmbulanceMission, level);
}
void CStats::AnotherFireExtinguished()
@ -177,7 +177,7 @@ void CStats::AnotherFireExtinguished()
void CStats::RegisterLongestFlightInDodo(int32 time)
{
LongestFlightInDodo = max(LongestFlightInDodo, time);
LongestFlightInDodo = Max(LongestFlightInDodo, time);
}
void CStats::RegisterTimeTakenDefuseMission(int32 time)

View File

@ -1950,7 +1950,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 &&
@ -2170,20 +2170,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 - 1);
ymin = Max(iy - 10, 0);
ymax = Min(iy + 10, NUMSECTORS_Y - 1);
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 - 1);
xmin = min(ix + 10, NUMSECTORS_X - 1);
xmax = Min(ix + 2, NUMSECTORS_X - 1);
xmin = Min(ix + 10, NUMSECTORS_X - 1);
inc = -1;
}
for(y = ymin; y <= ymax; y++){
@ -2199,13 +2199,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 - 1);
xmin = min(ix + 2, NUMSECTORS_X - 1);
xmax = Min(ix - 10, NUMSECTORS_X - 1);
xmin = Min(ix + 2, NUMSECTORS_X - 1);
inc = -1;
}
for(y = ymin; y <= ymax; y++){
@ -2234,20 +2234,20 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
}else{
// looking north/south
xmin = max(ix - 10, 0);
xmax = min(ix + 10, NUMSECTORS_X - 1);
xmin = Max(ix - 10, 0);
xmax = Min(ix + 10, NUMSECTORS_X - 1);
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 - 1);
ymin = min(iy + 10, NUMSECTORS_Y - 1);
ymax = Min(iy + 2, NUMSECTORS_Y - 1);
ymin = Min(iy + 10, NUMSECTORS_Y - 1);
inc = -1;
}
for(x = xmin; x <= xmax; x++){
@ -2263,13 +2263,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 - 1);
ymin = min(iy + 2, NUMSECTORS_Y - 1);
ymax = Min(iy - 10, NUMSECTORS_Y - 1);
ymin = Min(iy + 2, NUMSECTORS_Y - 1);
inc = -1;
}
for(x = xmin; x <= xmax; x++){

View File

@ -71,7 +71,6 @@ struct CStreamingChannel
};
class CDirectory;
enum eLevelName;
class CPtrList;
class CStreaming

View File

@ -138,7 +138,7 @@ void CTimer::Update(void)
if ( !CRecordDataForGame::IsPlayingBack() )
{
ms_fTimeStep = min(3.0f, ms_fTimeStep);
ms_fTimeStep = Min(3.0f, ms_fTimeStep);
if ( (m_snTimeInMilliseconds - m_snPreviousTimeInMilliseconds) > 60 )
m_snTimeInMilliseconds = m_snPreviousTimeInMilliseconds + 60;

View File

@ -212,7 +212,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)
@ -371,7 +371,7 @@ CWanted::Update(void)
CVector playerPos = FindPlayerCoors();
if (WorkOutPolicePresence(playerPos, radius) == 0) {
m_nLastUpdateTime = CTimer::GetTimeInMilliseconds();
m_nChaos = max(0, m_nChaos - 1);
m_nChaos = Max(0, m_nChaos - 1);
UpdateWantedLevel();
}
}

View File

@ -1,44 +1,10 @@
#pragma once
#include "Crime.h"
class CEntity;
class CCopPed;
enum eCrimeType
{
CRIME_NONE,
CRIME_POSSESSION_GUN,
CRIME_HIT_PED,
CRIME_HIT_COP,
CRIME_SHOOT_PED,
CRIME_SHOOT_COP,
CRIME_STEAL_CAR,
CRIME_RUN_REDLIGHT,
CRIME_RECKLESS_DRIVING,
CRIME_SPEEDING,
CRIME_RUNOVER_PED,
CRIME_RUNOVER_COP,
CRIME_SHOOT_HELI,
CRIME_PED_BURNED,
CRIME_COP_BURNED,
CRIME_VEHICLE_BURNED,
CRIME_DESTROYED_CESSNA,
NUM_CRIME_TYPES
};
class CCrimeBeingQd
{
public:
eCrimeType m_nType;
uint32 m_nId;
uint32 m_nTime;
CVector m_vecPosn;
bool m_bReported;
bool m_bPoliceDoesntCare;
CCrimeBeingQd() { };
~CCrimeBeingQd() { };
};
class CWanted
{
public:

View File

@ -777,10 +777,10 @@ CWorld::FindObjectsOfTypeInRange(uint32 modelId, const CVector &position, float
*nEntitiesFound = 0;
const CVector2D vecSectorStartPos(position.x - radius, position.y - radius);
const CVector2D vecSectorEndPos(position.x + radius, position.y + radius);
const int32 nStartX = max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0);
const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0);
const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1);
const int32 nStartX = Max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0);
const int32 nStartY = Max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0);
const int32 nEndX = Min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = Min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1);
for(int32 y = nStartY; y <= nEndY; y++) {
for(int32 x = nStartX; x <= nEndX; x++) {
CSector *pSector = CWorld::GetSector(x, y);
@ -1045,10 +1045,10 @@ CWorld::FindObjectsKindaColliding(const CVector &position, float radius, bool bC
*nCollidingEntities = 0;
const CVector2D vecSectorStartPos(position.x - radius, position.y - radius);
const CVector2D vecSectorEndPos(position.x + radius, position.y + radius);
const int32 nStartX = max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0);
const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0);
const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1);
const int32 nStartX = Max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0);
const int32 nStartY = Max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0);
const int32 nEndX = Min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = Min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1);
for(int32 y = nStartY; y <= nEndY; y++) {
for(int32 x = nStartX; x <= nEndX; x++) {
CSector *pSector = CWorld::GetSector(x, y);
@ -1124,10 +1124,10 @@ CWorld::FindObjectsIntersectingCube(const CVector &vecStartPos, const CVector &v
{
CWorld::AdvanceCurrentScanCode();
*nIntersecting = 0;
const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0);
const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0);
const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1);
const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0);
const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0);
const int32 nEndX = Min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1);
for(int32 y = nStartY; y <= nEndY; y++) {
for(int32 x = nStartX; x <= nEndX; x++) {
CSector *pSector = CWorld::GetSector(x, y);
@ -1205,10 +1205,10 @@ CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox &boundingBox, co
{
CWorld::AdvanceCurrentScanCode();
*nEntitiesFound = 0;
const int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0);
const int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0);
const int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1);
const int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1);
const int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0);
const int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0);
const int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1);
const int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1);
for(int32 y = nStartY; y <= nEndY; y++) {
for(int32 x = nStartX; x <= nEndX; x++) {
CSector *pSector = CWorld::GetSector(x, y);
@ -1285,10 +1285,10 @@ CWorld::FindMissionEntitiesIntersectingCube(const CVector &vecStartPos, const CV
{
CWorld::AdvanceCurrentScanCode();
*nIntersecting = 0;
const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0);
const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0);
const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1);
const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0);
const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0);
const int32 nEndX = Min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1);
for(int32 y = nStartY; y <= nEndY; y++) {
for(int32 x = nStartX; x <= nEndX; x++) {
CSector *pSector = CWorld::GetSector(x, y);
@ -1499,10 +1499,10 @@ CWorld::CallOffChaseForArea(float x1, float y1, float x2, float y2)
float fStartY = y1 - 10.0f;
float fEndX = x2 + 10.0f;
float fEndY = y2 + 10.0f;
const int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0);
const int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0);
const int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1);
const int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1);
const int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0);
const int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0);
const int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1);
const int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1);
for(int32 y = nStartY; y <= nEndY; y++) {
for(int32 x = nStartX; x <= nEndX; x++) {
CSector *pSector = CWorld::GetSector(x, y);
@ -1544,13 +1544,13 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList &list, float x1, float y1
}
if(bInsideSphere) {
if(pVehicle->GetPosition().x <= (x1 + x2) * 0.5f)
pVehicle->m_vecMoveSpeed.x = min(pVehicle->m_vecMoveSpeed.x, 0.0f);
pVehicle->m_vecMoveSpeed.x = Min(pVehicle->m_vecMoveSpeed.x, 0.0f);
else
pVehicle->m_vecMoveSpeed.x = max(pVehicle->m_vecMoveSpeed.x, 0.0f);
pVehicle->m_vecMoveSpeed.x = Max(pVehicle->m_vecMoveSpeed.x, 0.0f);
if(pVehicle->GetPosition().y <= (y1 + y2) * 0.5f)
pVehicle->m_vecMoveSpeed.y = min(pVehicle->m_vecMoveSpeed.y, 0.0f);
pVehicle->m_vecMoveSpeed.y = Min(pVehicle->m_vecMoveSpeed.y, 0.0f);
else
pVehicle->m_vecMoveSpeed.y = max(pVehicle->m_vecMoveSpeed.y, 0.0f);
pVehicle->m_vecMoveSpeed.y = Max(pVehicle->m_vecMoveSpeed.y, 0.0f);
}
}
}
@ -2086,10 +2086,10 @@ CWorld::TriggerExplosion(const CVector &position, float fRadius, float fPower, C
{
CVector2D vecStartPos(position.x - fRadius, position.y - fRadius);
CVector2D vecEndPos(position.x + fRadius, position.y + fRadius);
const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0);
const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0);
const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1);
const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0);
const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0);
const int32 nEndX = Min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1);
for(int32 y = nStartY; y <= nEndY; y++) {
for(int32 x = nStartX; x <= nEndX; x++) {
CSector *pSector = CWorld::GetSector(x, y);
@ -2144,7 +2144,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
if(pEntity->bIsStatic) {
float fDamageMultiplier =
(fRadius - fMagnitude) * 2.0f / fRadius;
float fDamage = 300.0f * min(fDamageMultiplier, 1.0f);
float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f);
pObject->ObjectDamage(fDamage);
}
} else {
@ -2153,18 +2153,18 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
}
}
if(!pEntity->bIsStatic) {
float fDamageMultiplier = min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f);
float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f);
CVector vecForceDir =
vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier /
max(fMagnitude, 0.01f));
vecForceDir.z = max(vecForceDir.z, 0.0f);
if(pEntity == FindPlayerPed()) vecForceDir.z = min(vecForceDir.z, 1.0f);
Max(fMagnitude, 0.01f));
vecForceDir.z = Max(vecForceDir.z, 0.0f);
if(pEntity == FindPlayerPed()) vecForceDir.z = Min(vecForceDir.z, 1.0f);
pEntity->ApplyMoveForce(vecForceDir);
if(!pEntity->bPedPhysics) {
float fBoundRadius = pEntity->GetBoundRadius();
float fDistanceZ = position.z - pEntity->GetPosition().z;
float fPointZ = fBoundRadius;
if(max(fDistanceZ, -fBoundRadius) < fBoundRadius) {
if(Max(fDistanceZ, -fBoundRadius) < fBoundRadius) {
if(fDistanceZ <= -fBoundRadius)
fPointZ = -fBoundRadius;
else

View File

@ -289,7 +289,7 @@ CCullZones::FindAttributesForCoors(CVector coors, int32 *wantedLevel)
coors.z >= aAttributeZones[i].minz && coors.z <= aAttributeZones[i].maxz){
attribs |= aAttributeZones[i].attributes;
if(wantedLevel)
*wantedLevel = max(*wantedLevel, aAttributeZones[i].wantedLevel);
*wantedLevel = Max(*wantedLevel, aAttributeZones[i].wantedLevel);
}
return attribs;
}

View File

@ -12,7 +12,7 @@
#include <math.h>
#ifdef WITHWINDOWS
#include <Windows.h>
#include <windows.h>
#endif
#ifdef WITHD3D
@ -42,12 +42,8 @@
#undef near
#endif
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define Min(a,b) ((a) < (b) ? (a) : (b))
typedef uint8_t uint8;
typedef int8_t int8;
@ -62,7 +58,7 @@ typedef int64_t int64;
typedef uint16_t wchar;
#ifndef nil
#define nil nullptr
#define nil NULL
#endif
#include "config.h"
@ -276,7 +272,7 @@ class CTweakFunc : public CTweakVar
void (*m_pFunc)();
public:
CTweakFunc(void (*pFunc)(), const char *strName, const char *strPath) :
m_pFunc(pFunc), m_pVarName(strName), m_pPath(strPath)
m_pPath(strPath), m_pVarName(strName), m_pFunc(pFunc)
{
CTweakVars::Add(this);
}
@ -290,7 +286,7 @@ class CTweakBool : public CTweakVar
bool *m_pBoolVar;
public:
CTweakBool(bool *pBool, const char *strName, const char *strPath) :
m_pBoolVar(pBool), m_pVarName(strName), m_pPath(strPath)
m_pPath(strPath), m_pVarName(strName), m_pBoolVar(pBool)
{
CTweakVars::Add(this);
}
@ -306,9 +302,10 @@ class CTweakSwitch : public CTweakVar
const char **m_aStr;
void (*m_pFunc)();
public:
CTweakSwitch(void *pInt, const char *strName, int32 nMin, int32 nMax, const char **aStr, void (*pFunc)(), const char *strPath) :
m_pVarName(strName), m_pPath(strPath),
m_aStr(aStr), m_pIntVar(pInt), m_nMin(nMin), m_nMax(nMax)
CTweakSwitch(void *pInt, const char *strName, int32 nMin, int32 nMax, const char **aStr,
void (*pFunc)(), const char *strPath)
: m_pPath(strPath), m_pVarName(strName), m_pIntVar(pInt), m_nMin(nMin), m_nMax(nMax),
m_aStr(aStr)
{
CTweakVars::Add(this);
}
@ -316,22 +313,24 @@ public:
void AddDBG(const char *path);
};
#define _TWEEKCLASS(name, type) \
class name : public CTweakVar \
{ \
public: \
const char *m_pPath, *m_pVarName; \
type *m_pIntVar, m_nLoawerBound, m_nUpperBound, m_nStep; \
\
name(type *pInt, const char *strName, type nLower, type nUpper, type nStep, const char *strPath) : \
m_pIntVar(pInt), m_nLoawerBound(nLower), m_nUpperBound(nUpper), m_nStep(nStep), \
m_pVarName(strName), m_pPath(strPath) \
{ \
CTweakVars::Add(this); \
} \
\
void AddDBG(const char *path); \
};
#define _TWEEKCLASS(name, type) \
class name : public CTweakVar \
{ \
public: \
const char *m_pPath, *m_pVarName; \
type *m_pIntVar, m_nLoawerBound, m_nUpperBound, m_nStep; \
\
name(type *pInt, const char *strName, type nLower, type nUpper, type nStep, \
const char *strPath) \
: m_pPath(strPath), m_pVarName(strName), m_pIntVar(pInt), \
m_nLoawerBound(nLower), m_nUpperBound(nUpper), m_nStep(nStep) \
\
{ \
CTweakVars::Add(this); \
} \
\
void AddDBG(const char *path); \
};
_TWEEKCLASS(CTweakInt8, int8);
_TWEEKCLASS(CTweakUInt8, uint8);

View File

@ -205,7 +205,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

@ -4,7 +4,7 @@
#include <algorithm>
#include <vector>
#include <Windows.h>
#include <windows.h>
StaticPatcher *StaticPatcher::ms_head;

View File

@ -102,14 +102,14 @@ void tbDisplay()
#ifndef FINAL
// Timers output (my own implementation)
for (uint32 i = 0; i < TimerBar.count; i++) {
MaxTimes[i] = max(MaxTimes[i], TimerBar.Timers[i].endTime - TimerBar.Timers[i].startTime);
MaxTimes[i] = Max(MaxTimes[i], TimerBar.Timers[i].endTime - TimerBar.Timers[i].startTime);
sprintf(temp, "%s: %.2f", &TimerBar.Timers[i].name[0], MaxTimes[i]);
AsciiToUnicode(temp, wtemp);
CFont::PrintString(RsGlobal.maximumWidth * (4.0f / DEFAULT_SCREEN_WIDTH), RsGlobal.maximumHeight * ((8.0f * (i + 2)) / DEFAULT_SCREEN_HEIGHT), wtemp);
}
#ifdef FRAMETIME
MaxFrameTime = max(MaxFrameTime, FrameEndTime - FrameInitTime);
MaxFrameTime = Max(MaxFrameTime, FrameEndTime - FrameInitTime);
sprintf(temp, "Frame Time: %.2f", MaxFrameTime);
AsciiToUnicode(temp, wtemp);

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)
@ -1151,18 +1151,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);
@ -1250,7 +1250,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;
@ -1272,7 +1272,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;
@ -1305,7 +1305,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;
@ -1332,7 +1332,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;
@ -1510,7 +1510,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++){
@ -1531,7 +1531,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;
@ -1549,7 +1549,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]))
@ -1598,7 +1598,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;
@ -1623,7 +1623,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;
@ -1659,7 +1659,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;
@ -1689,7 +1689,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;
@ -1835,7 +1835,7 @@ CPhysical::ProcessCollision(void)
if(IsPed() && (distSq >= sq(0.2f) || ped->IsPlayer())){
if(ped->IsPlayer())
n = max(NUMSTEPS(0.2f), 2.0f);
n = Max(NUMSTEPS(0.2f), 2.0f);
else
n = NUMSTEPS(0.3f);
step = savedTimeStep / n;
@ -1856,7 +1856,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

@ -9,6 +9,11 @@ public:
#ifdef RWCORE_H
CVector(const RwV3d &v) : x(v.x), y(v.y), z(v.z) {}
RwV3d toRwV3d(void) const {
RwV3d vecRw = { this->x, this->y, this->z };
return vecRw;
}
operator RwV3d (void) const {
RwV3d vecRw = { this->x, this->y, this->z };
return vecRw;

View File

@ -214,7 +214,7 @@ CObject::ObjectDamage(float amount)
++nFrameGen;
int32 currentFrame = nFrameGen & 3;
float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f);
RwRGBA randomColor = { color.red * fRandom, color.green * fRandom , color.blue, color.alpha };
RwRGBA randomColor = { uint8(color.red * fRandom), uint8(color.green * fRandom) , color.blue, color.alpha };
float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f);
int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80);
CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0);
@ -237,7 +237,7 @@ CObject::ObjectDamage(float amount)
++nFrameGen;
int32 currentFrame = nFrameGen & 3;
float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f);
RwRGBA randomColor = { color.red * fRandom, color.green * fRandom , color.blue * fRandom, color.alpha };
RwRGBA randomColor = { uint8(color.red * fRandom), uint8(color.green * fRandom), uint8(color.blue * fRandom), color.alpha };
float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f);
int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80);
CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0);

View File

@ -1,6 +1,8 @@
#pragma once
#include "Placeable.h"
#include "AudioManager.h"
#include "ParticleType.h"
#include "Placeable.h"
#define MAX_PARTICLEOBJECTS 100
#define MAX_AUDIOHYDRANTS 8
@ -37,7 +39,6 @@ enum eParticleObjectState
POBJECTSTATE_FREE,
};
enum tParticleType;
class CParticle;
class CParticleObject : public CPlaceable

View File

@ -318,12 +318,12 @@ CCivilianPed::ProcessControl(void)
if (CWorld::Players[CWorld::PlayerInFocus].m_nMoney >= 10 && playerSexFrequency > 250) {
CWorld::Players[CWorld::PlayerInFocus].m_nNextSexFrequencyUpdateTime = CTimer::GetTimeInMilliseconds() + playerSexFrequency;
if (playerSexFrequency >= 350) {
CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = max(250, playerSexFrequency - 30);
CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = Max(250, playerSexFrequency - 30);
} else {
CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = max(250, playerSexFrequency - 10);
CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = Max(250, playerSexFrequency - 10);
}
m_pMyVehicle->pDriver->m_fHealth = min(125.0f, 1.0f + m_pMyVehicle->pDriver->m_fHealth);
m_pMyVehicle->pDriver->m_fHealth = Min(125.0f, 1.0f + m_pMyVehicle->pDriver->m_fHealth);
if (CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency == 250)
CWorld::Players[CWorld::PlayerInFocus].m_nNextSexFrequencyUpdateTime = CTimer::GetTimeInMilliseconds() + 3000;
} else {
@ -357,7 +357,7 @@ CCivilianPed::ProcessControl(void)
if (playerMoney <= 1) {
CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = 250;
} else {
CWorld::Players[CWorld::PlayerInFocus].m_nMoney = max(0, playerMoney - 1);
CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, playerMoney - 1);
}
CWorld::Players[CWorld::PlayerInFocus].m_nNextSexMoneyUpdateTime = CTimer::GetTimeInMilliseconds() + 1000;
}

View File

@ -153,7 +153,7 @@ CCopPed::ClearPursuit(void)
return;
m_bIsInPursuit = false;
for (int i = 0; i < max(wanted->m_MaxCops, wanted->m_CurrentCops); ++i) {
for (int i = 0; i < Max(wanted->m_MaxCops, wanted->m_CurrentCops); ++i) {
if (!foundMyself && wanted->m_pCops[i] == this) {
wanted->m_pCops[i] = nil;
--wanted->m_CurrentCops;
@ -342,7 +342,7 @@ CCopPed::CopAI(void)
int oldCopNum = wanted->m_CurrentCops;
int maxCops = wanted->m_MaxCops;
for (int i = 0; i < max(maxCops, oldCopNum); i++) {
for (int i = 0; i < Max(maxCops, oldCopNum); i++) {
CCopPed *cop = wanted->m_pCops[i];
if (cop && cop->m_fDistanceToTarget > copFarthestToTargetDist) {
copFarthestToTargetDist = cop->m_fDistanceToTarget;

View File

@ -344,15 +344,15 @@ CPed::DebugRenderOnePedText(void)
bitAbove.z += 2.0f;
if (CSprite::CalcScreenCoors(bitAbove, &screenCoords, &width, &height, true)) {
float lineHeight = SCREEN_SCALE_Y(min(height/100.0f, 0.7f) * 22.0f);
float lineHeight = SCREEN_SCALE_Y(Min(height/100.0f, 0.7f) * 22.0f);
DefinedState();
CFont::SetPropOn();
CFont::SetBackgroundOn();
// Originally both of them were being divided by 60.0f.
float xScale = min(width / 240.0f, 0.7f);
float yScale = min(height / 80.0f, 0.7f);
float xScale = Min(width / 240.0f, 0.7f);
float yScale = Min(height / 80.0f, 0.7f);
CFont::SetScale(SCREEN_SCALE_X(xScale), SCREEN_SCALE_Y(yScale));
CFont::SetCentreOn();
@ -1837,7 +1837,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
case ANIM_VAN_GETIN:
#ifdef VC_PED_PORTS
multExtractedFromAnim = true;
zBlend = max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.3f, 0.0f) / (1.0f - 0.3f);
zBlend = Max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.3f, 0.0f) / (1.0f - 0.3f);
// fall through
#endif
case ANIM_CAR_QJACKED:
@ -1848,7 +1848,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
#ifdef VC_PED_PORTS
if (!multExtractedFromAnim) {
multExtractedFromAnim = true;
zBlend = max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.5f, 0.0f) / (1.0f - 0.5f);
zBlend = Max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.5f, 0.0f) / (1.0f - 0.5f);
}
// fall through
#endif
@ -1863,7 +1863,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
#ifdef VC_PED_PORTS
if (veh && veh->IsCar() && veh->bIsBus) {
multExtractedFromAnimBus = true;
zBlend = min(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength, 0.5f) / 0.5f;
zBlend = Min(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength, 0.5f) / 0.5f;
}
// fall through
#endif
@ -1943,7 +1943,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);
@ -1965,12 +1965,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 (EnteringCar()) {
neededPos.z = max(currentZ, autoZPos.z);
neededPos.z = Max(currentZ, autoZPos.z);
}
#ifdef VC_PED_PORTS
}
@ -2511,7 +2511,7 @@ CPed::CanPedJumpThis(CEntity *unused, CVector *damageNormal = nil)
CVector invDamageNormal(-damageNormal->x, -damageNormal->y, 0.0f);
invDamageNormal *= 1.0f / collPower;
CVector estimatedJumpDist = invDamageNormal + collPower * invDamageNormal * ourCol->spheres->radius;
forwardOffset = estimatedJumpDist * min(2.0f / collPower, 4.0f);
forwardOffset = estimatedJumpDist * Min(2.0f / collPower, 4.0f);
}
} else {
pos.z -= 0.15f;
@ -5155,12 +5155,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);
}
}
@ -5884,7 +5884,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();
}
@ -5893,7 +5893,7 @@ void
CPed::SetAttackTimer(uint32 time)
{
if (CTimer::GetTimeInMilliseconds() > m_attackTimer)
m_attackTimer = max(m_shootTimer, CTimer::GetTimeInMilliseconds()) + time;
m_attackTimer = Max(m_shootTimer, CTimer::GetTimeInMilliseconds()) + time;
}
void
@ -8676,7 +8676,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
distVec.Normalise();
#ifdef VC_PED_PORTS
distVec *= min(car->m_fMass / 1400.0f, 1.0f);
distVec *= Min(car->m_fMass / 1400.0f, 1.0f);
#endif
car->ApplyMoveForce(distVec * -100.0f);
Say(SOUND_PED_DEFEND);
@ -8709,7 +8709,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
m_vecMoveSpeed.z = 0.0f;
distVec.Normalise();
#ifdef VC_PED_PORTS
distVec *= min(car->m_fMass / 1400.0f, 1.0f);
distVec *= Min(car->m_fMass / 1400.0f, 1.0f);
#endif
car->ApplyMoveForce(distVec * -60.0f);
Say(SOUND_PED_DEFEND);
@ -10027,7 +10027,7 @@ CPed::ProcessControl(void)
CVector offsetToCheck;
m_nPedStateTimer++;
float adjustedTs = max(CTimer::GetTimeStep(), 0.01f);
float adjustedTs = Max(CTimer::GetTimeStep(), 0.01f);
CPad *pad0 = CPad::GetPad(0);
if ((m_nPedStateTimer <= 50.0f / (4.0f * adjustedTs) || m_nPedStateTimer * 0.01f <= forceDir.MagnitudeSqr())
@ -10051,7 +10051,7 @@ CPed::ProcessControl(void)
CColPoint obstacleForFlying, obstacleForFlyingOtherDir;
// Check is there any room for being knocked up in reverse direction of force
if (CWorld::ProcessVerticalLine(posToCheck, -20.0f, obstacleForFlying, foundEnt, true, false, false, false, false, false, false)) {
if (CWorld::ProcessVerticalLine(posToCheck, -20.0f, obstacleForFlying, foundEnt, true, false, false, false, false, false, nil)) {
obstacleForFlyingZ = obstacleForFlying.point.z;
} else {
obstacleForFlyingZ = 500.0f;
@ -10060,7 +10060,7 @@ CPed::ProcessControl(void)
posToCheck = GetPosition() - offsetToCheck;
// Now check for direction of force this time
if (CWorld::ProcessVerticalLine(posToCheck, -20.0f, obstacleForFlyingOtherDir, foundEnt, true, false, false, false, false, false, false)) {
if (CWorld::ProcessVerticalLine(posToCheck, -20.0f, obstacleForFlyingOtherDir, foundEnt, true, false, false, false, false, false, nil)) {
obstacleForFlyingOtherDirZ = obstacleForFlyingOtherDir.point.z;
} else {
obstacleForFlyingOtherDirZ = 501.0f;
@ -10180,7 +10180,7 @@ CPed::ProcessControl(void)
offsetToCheck = GetPosition();
offsetToCheck.z += 0.5f;
if (CWorld::ProcessVerticalLine(offsetToCheck, GetPosition().z - FEET_OFFSET, foundCol, foundEnt, true, true, false, true, false, false, false)) {
if (CWorld::ProcessVerticalLine(offsetToCheck, GetPosition().z - FEET_OFFSET, foundCol, foundEnt, true, true, false, true, false, false, nil)) {
#ifdef VC_PED_PORTS
if (!bSomeVCflag1 || FEET_OFFSET + foundCol.point.z < GetPosition().z) {
GetPosition().z = FEET_OFFSET + foundCol.point.z;
@ -12245,7 +12245,7 @@ CPed::PlacePedOnDryLand(void)
CVector posToCheck = 0.5f * potentialGroundDist + gaTempSphereColPoints[0].point;
posToCheck.z = 3.0f + waterLevel;
if (CWorld::ProcessVerticalLine(posToCheck, waterLevel - 1.0f, foundCol, foundEnt, true, true, false, true, false, false, false)) {
if (CWorld::ProcessVerticalLine(posToCheck, waterLevel - 1.0f, foundCol, foundEnt, true, true, false, true, false, false, nil)) {
foundColZ = foundCol.point.z;
if (foundColZ >= waterLevel) {
posToCheck.z = 0.8f + foundColZ;
@ -12259,7 +12259,7 @@ CPed::PlacePedOnDryLand(void)
posToCheck = 5.0f * potentialGroundDist + GetPosition();
posToCheck.z = 3.0f + waterLevel;
if (!CWorld::ProcessVerticalLine(posToCheck, waterLevel - 1.0f, foundCol, foundEnt, true, true, false, true, false, false, false))
if (!CWorld::ProcessVerticalLine(posToCheck, waterLevel - 1.0f, foundCol, foundEnt, true, true, false, true, false, false, nil))
return false;
foundColZ = foundCol.point.z;
@ -13975,9 +13975,9 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
CVector2D adjustedColMin(objColMin.x - 0.35f, objColMin.y - 0.35f);
CVector2D adjustedColMax(objColMax.x + 0.35f, objColMax.y + 0.35f);
checkIntervalInDist = max(checkIntervalInDist, 0.5f);
checkIntervalInDist = min(checkIntervalInDist, (objColMax.z - objColMin.z) / 2.0f);
checkIntervalInDist = min(checkIntervalInDist, (adjustedColMax.x - adjustedColMin.x) / 2.0f);
checkIntervalInDist = Max(checkIntervalInDist, 0.5f);
checkIntervalInDist = Min(checkIntervalInDist, (objColMax.z - objColMin.z) / 2.0f);
checkIntervalInDist = Min(checkIntervalInDist, (adjustedColMax.x - adjustedColMin.x) / 2.0f);
if (objMat.GetUp().z < 0.0f)
objUpsideDown = true;
@ -14649,7 +14649,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2);
}
} else {
float damage = 100.0f * max(speed - 0.25f, 0.0f);
float damage = 100.0f * Max(speed - 0.25f, 0.0f);
float damage2 = damage;
if (m_vecMoveSpeed.z < -0.25f)
damage += (-0.25f - m_vecMoveSpeed.z) * 150.0f;
@ -14727,8 +14727,8 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
#ifdef VC_PED_PORTS
} else {
float speed = m_vecMoveSpeed.Magnitude2D();
sphereNormal.x = -m_vecMoveSpeed.x / max(0.001f, speed);
sphereNormal.y = -m_vecMoveSpeed.y / max(0.001f, speed);
sphereNormal.x = -m_vecMoveSpeed.x / Max(0.001f, speed);
sphereNormal.y = -m_vecMoveSpeed.y / Max(0.001f, speed);
GetPosition().z -= 0.05f;
bSomeVCflag1 = true;
}
@ -15093,7 +15093,7 @@ CPed::ProcessBuoyancy(void)
bTouchingWater = true;
CEntity *entity;
CColPoint point;
if (CWorld::ProcessVerticalLine(GetPosition(), GetPosition().z - 3.0f, point, entity, false, true, false, false, false, false, false)
if (CWorld::ProcessVerticalLine(GetPosition(), GetPosition().z - 3.0f, point, entity, false, true, false, false, false, false, nil)
&& entity->IsVehicle() && ((CVehicle*)entity)->IsBoat()) {
bIsInWater = false;
return;
@ -15470,7 +15470,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, true, false, false, true, false, nil))
foundColZ2 = foundCol.point.z;
zForPed = max(foundColZ, foundColZ2);
zForPed = Max(foundColZ, foundColZ2);
if (zForPed > -99.0f)
GetPosition().z = FEET_OFFSET + zForPed;
@ -17069,7 +17069,7 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
// Because buses have stairs
if (!m_pMyVehicle->bIsBus)
zDiff = max(0.0f, doorOpenPos.z - GetPosition().z);
zDiff = Max(0.0f, doorOpenPos.z - GetPosition().z);
m_vecOffsetSeek = doorOpenPos - GetPosition();
m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 600;
@ -17220,7 +17220,7 @@ CPed::WarpPedToNearEntityOffScreen(CEntity *warpTo)
CVector appropriatePos = GetPosition();
CVector zCorrectedPos = appropriatePos;
int tryCount = min(10, halfOfDist);
int tryCount = Min(10, halfOfDist);
for (int i = 0; i < tryCount; ++i) {
appropriatePos += halfNormalizedDist;
CPedPlacement::FindZCoorForPed(&zCorrectedPos);
@ -17254,7 +17254,7 @@ CPed::WarpPedToNearLeaderOffScreen(void)
CVector appropriatePos = GetPosition();
CVector zCorrectedPos = appropriatePos;
int tryCount = min(10, halfOfDist);
int tryCount = Min(10, halfOfDist);
for (int i = 0; i < tryCount; ++i) {
appropriatePos += halfNormalizedDist;
CPedPlacement::FindZCoorForPed(&zCorrectedPos);
@ -17296,7 +17296,7 @@ CPed::SetCarJack_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
car->m_nGettingInFlags |= doorFlag;
m_vecOffsetSeek = carEnterPos - GetPosition();
m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 600;
float zDiff = max(0.0f, carEnterPos.z - GetPosition().z);
float zDiff = Max(0.0f, carEnterPos.z - GetPosition().z);
bUsesCollision = false;
if (zDiff > 4.4f) {

View File

@ -1,12 +1,13 @@
#pragma once
#include "AnimManager.h"
#include "Crime.h"
#include "EventList.h"
#include "PedIK.h"
#include "PedStats.h"
#include "Physical.h"
#include "Weapon.h"
#include "PedStats.h"
#include "PedIK.h"
#include "AnimManager.h"
#include "WeaponInfo.h"
#include "EventList.h"
#define FEET_OFFSET 1.04f
#define CHECK_NEARBY_THINGS_MAX_DIST 15.0f
@ -17,7 +18,6 @@ class CObject;
class CFire;
struct AnimBlendFrameData;
class CAnimBlendAssociation;
enum eCrimeType;
struct PedAudioData
{

View File

@ -30,7 +30,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 = FEET_OFFSET + zForPed;

View File

@ -182,7 +182,7 @@ CPlayerPed::MakeChangesForNewWeapon(int8 weapon)
}
SetCurrentWeapon(weapon);
GetWeapon()->m_nAmmoInClip = min(GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition);
GetWeapon()->m_nAmmoInClip = Min(GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition);
if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAim))
ClearWeaponTarget();
@ -699,7 +699,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
#else
m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
#endif
m_fMoveSpeed = min(padMoveInGameUnit, 0.07f * CTimer::GetTimeStep() + m_fMoveSpeed);
m_fMoveSpeed = Min(padMoveInGameUnit, 0.07f * CTimer::GetTimeStep() + m_fMoveSpeed);
} else {
m_fMoveSpeed = 0.0f;
}
@ -1186,7 +1186,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
}
float maxAcc = 0.07f * CTimer::GetTimeStep();
m_fMoveSpeed = min(padMoveInGameUnit, m_fMoveSpeed + maxAcc);
m_fMoveSpeed = Min(padMoveInGameUnit, m_fMoveSpeed + maxAcc);
} else {
m_fMoveSpeed = 0.0f;
@ -1406,7 +1406,7 @@ CPlayerPed::ProcessControl(void)
if (bVehEnterDoorIsBlocked || bKindaStayInSamePlace) {
m_fMoveSpeed = 0.0f;
} else {
m_fMoveSpeed = min(2.0f, 2.0f * (m_vecSeekPos - GetPosition()).Magnitude2D());
m_fMoveSpeed = Min(2.0f, 2.0f * (m_vecSeekPos - GetPosition()).Magnitude2D());
}
if (padUsed && !padUsed->ArePlayerControlsDisabled()) {
if (padUsed->GetTarget() || padUsed->GetLeftStickXJustDown() || padUsed->GetLeftStickYJustDown() ||

View File

@ -595,7 +595,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
}
// Yeah, float
float maxPossiblePedsForArea = (zoneInfo.pedDensity + zoneInfo.carDensity) * playerInfo->m_fRoadDensity * PedDensityMultiplier * CIniFile::PedNumberMultiplier;
maxPossiblePedsForArea = min(maxPossiblePedsForArea, MaxNumberOfPedsInUse);
maxPossiblePedsForArea = Min(maxPossiblePedsForArea, MaxNumberOfPedsInUse);
if (ms_nTotalPeds < maxPossiblePedsForArea || addCop) {
int decisionThreshold = CGeneral::GetRandomNumberInRange(0, 1000);
@ -703,7 +703,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
if (!foundGround)
return;
generatedCoors.z = max(generatedCoors.z, groundZ);
generatedCoors.z = Max(generatedCoors.z, groundZ);
}
bool farEnoughToAdd = true;
CMatrix mat(TheCamera.GetCameraMatrix());

View File

@ -403,7 +403,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);
}
@ -430,18 +430,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

@ -106,7 +106,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;
@ -118,7 +118,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++)
@ -305,7 +305,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));
@ -316,7 +316,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,
@ -466,7 +466,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;
@ -545,25 +545,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

@ -6,7 +6,7 @@
#include "General.h"
#include "AudioScriptObject.h"
#include "World.h"
#include "TimeCycle.h"
#include "Timecycle.h"
#include "Particle.h"
#include "Camera.h"
#include "RenderBuffer.h"
@ -617,12 +617,12 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed,
CVector c = object->GetMatrix() * col->vertices[2];
CVector d = object->GetMatrix() * col->vertices[3];
float minx = min(min(a.x, b.x), min(c.x, d.x));
float maxx = max(max(a.x, b.x), max(c.x, d.x));
float miny = min(min(a.y, b.y), min(c.y, d.y));
float maxy = max(max(a.y, b.y), max(c.y, d.y));
float minz = min(min(a.z, b.z), min(c.z, d.z));
float maxz = max(max(a.z, b.z), max(c.z, d.z));
float minx = Min(Min(a.x, b.x), Min(c.x, d.x));
float maxx = Max(Max(a.x, b.x), Max(c.x, d.x));
float miny = Min(Min(a.y, b.y), Min(c.y, d.y));
float maxy = Max(Max(a.y, b.y), Max(c.y, d.y));
float minz = Min(Min(a.z, b.z), Min(c.z, d.z));
float maxz = Max(Max(a.z, b.z), Max(c.z, d.z));
if ( amount > 300.0f )

View File

@ -136,7 +136,7 @@ void CHud::Draw()
if (DrawCrossHair || DrawCrossHairPC) {
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void *)rwFILTERLINEAR);
SpriteBrightness = min(SpriteBrightness+1, 30);
SpriteBrightness = Min(SpriteBrightness+1, 30);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
@ -715,7 +715,7 @@ void CHud::Draw()
} else {
int counter = atoi(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer);
#ifdef FIX_BUGS
counter = min(counter, 100);
counter = Min(counter, 100);
#endif
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 80));
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_X(counter) / 2.0f + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET + 50.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 255));
@ -1206,7 +1206,7 @@ void CHud::DrawAfterFade()
OddJob2On = 2;
}
else {
fStep = min(40.0f, OddJob2XOffset / 6.0f);
fStep = Min(40.0f, OddJob2XOffset / 6.0f);
OddJob2XOffset = OddJob2XOffset - fStep;
}
break;
@ -1217,7 +1217,7 @@ void CHud::DrawAfterFade()
}
break;
case 3:
fStep = max(30.0f, OddJob2XOffset / 5.0f);
fStep = Max(30.0f, OddJob2XOffset / 5.0f);
OddJob2XOffset = OddJob2XOffset - fStep;

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

@ -1,82 +1,8 @@
#pragma once
class CParticle;
#include "ParticleType.h"
enum tParticleType
{
PARTICLE_SPARK = 0,
PARTICLE_SPARK_SMALL,
PARTICLE_WHEEL_DIRT,
PARTICLE_WHEEL_WATER,
PARTICLE_BLOOD,
PARTICLE_BLOOD_SMALL,
PARTICLE_BLOOD_SPURT,
PARTICLE_DEBRIS,
PARTICLE_DEBRIS2,
PARTICLE_WATER,
PARTICLE_FLAME,
PARTICLE_FIREBALL,
PARTICLE_GUNFLASH,
PARTICLE_GUNFLASH_NOANIM,
PARTICLE_GUNSMOKE,
PARTICLE_GUNSMOKE2,
PARTICLE_SMOKE,
PARTICLE_SMOKE_SLOWMOTION,
PARTICLE_GARAGEPAINT_SPRAY,
PARTICLE_SHARD,
PARTICLE_SPLASH,
PARTICLE_CARFLAME,
PARTICLE_STEAM,
PARTICLE_STEAM2,
PARTICLE_STEAM_NY,
PARTICLE_STEAM_NY_SLOWMOTION,
PARTICLE_ENGINE_STEAM,
PARTICLE_RAINDROP,
PARTICLE_RAINDROP_SMALL,
PARTICLE_RAIN_SPLASH,
PARTICLE_RAIN_SPLASH_BIGGROW,
PARTICLE_RAIN_SPLASHUP,
PARTICLE_WATERSPRAY,
PARTICLE_EXPLOSION_MEDIUM,
PARTICLE_EXPLOSION_LARGE,
PARTICLE_EXPLOSION_MFAST,
PARTICLE_EXPLOSION_LFAST,
PARTICLE_CAR_SPLASH,
PARTICLE_BOAT_SPLASH,
PARTICLE_BOAT_THRUSTJET,
PARTICLE_BOAT_WAKE,
PARTICLE_WATER_HYDRANT,
PARTICLE_WATER_CANNON,
PARTICLE_EXTINGUISH_STEAM,
PARTICLE_PED_SPLASH,
PARTICLE_PEDFOOT_DUST,
PARTICLE_HELI_DUST,
PARTICLE_HELI_ATTACK,
PARTICLE_ENGINE_SMOKE,
PARTICLE_ENGINE_SMOKE2,
PARTICLE_CARFLAME_SMOKE,
PARTICLE_FIREBALL_SMOKE,
PARTICLE_PAINT_SMOKE,
PARTICLE_TREE_LEAVES,
PARTICLE_CARCOLLISION_DUST,
PARTICLE_CAR_DEBRIS,
PARTICLE_HELI_DEBRIS,
PARTICLE_EXHAUST_FUMES,
PARTICLE_RUBBER_SMOKE,
PARTICLE_BURNINGRUBBER_SMOKE,
PARTICLE_BULLETHIT_SMOKE,
PARTICLE_GUNSHELL_FIRST,
PARTICLE_GUNSHELL,
PARTICLE_GUNSHELL_BUMP1,
PARTICLE_GUNSHELL_BUMP2,
PARTICLE_TEST,
PARTICLE_BIRD_FRONT,
PARTICLE_RAINDROP_2D,
MAX_PARTICLES,
PARTICLE_FIRST = PARTICLE_SPARK,
PARTICLE_LAST = PARTICLE_RAINDROP_2D
};
class CParticle;
enum
{

77
src/render/ParticleType.h Normal file
View File

@ -0,0 +1,77 @@
#pragma once
enum tParticleType
{
PARTICLE_SPARK = 0,
PARTICLE_SPARK_SMALL,
PARTICLE_WHEEL_DIRT,
PARTICLE_WHEEL_WATER,
PARTICLE_BLOOD,
PARTICLE_BLOOD_SMALL,
PARTICLE_BLOOD_SPURT,
PARTICLE_DEBRIS,
PARTICLE_DEBRIS2,
PARTICLE_WATER,
PARTICLE_FLAME,
PARTICLE_FIREBALL,
PARTICLE_GUNFLASH,
PARTICLE_GUNFLASH_NOANIM,
PARTICLE_GUNSMOKE,
PARTICLE_GUNSMOKE2,
PARTICLE_SMOKE,
PARTICLE_SMOKE_SLOWMOTION,
PARTICLE_GARAGEPAINT_SPRAY,
PARTICLE_SHARD,
PARTICLE_SPLASH,
PARTICLE_CARFLAME,
PARTICLE_STEAM,
PARTICLE_STEAM2,
PARTICLE_STEAM_NY,
PARTICLE_STEAM_NY_SLOWMOTION,
PARTICLE_ENGINE_STEAM,
PARTICLE_RAINDROP,
PARTICLE_RAINDROP_SMALL,
PARTICLE_RAIN_SPLASH,
PARTICLE_RAIN_SPLASH_BIGGROW,
PARTICLE_RAIN_SPLASHUP,
PARTICLE_WATERSPRAY,
PARTICLE_EXPLOSION_MEDIUM,
PARTICLE_EXPLOSION_LARGE,
PARTICLE_EXPLOSION_MFAST,
PARTICLE_EXPLOSION_LFAST,
PARTICLE_CAR_SPLASH,
PARTICLE_BOAT_SPLASH,
PARTICLE_BOAT_THRUSTJET,
PARTICLE_BOAT_WAKE,
PARTICLE_WATER_HYDRANT,
PARTICLE_WATER_CANNON,
PARTICLE_EXTINGUISH_STEAM,
PARTICLE_PED_SPLASH,
PARTICLE_PEDFOOT_DUST,
PARTICLE_HELI_DUST,
PARTICLE_HELI_ATTACK,
PARTICLE_ENGINE_SMOKE,
PARTICLE_ENGINE_SMOKE2,
PARTICLE_CARFLAME_SMOKE,
PARTICLE_FIREBALL_SMOKE,
PARTICLE_PAINT_SMOKE,
PARTICLE_TREE_LEAVES,
PARTICLE_CARCOLLISION_DUST,
PARTICLE_CAR_DEBRIS,
PARTICLE_HELI_DEBRIS,
PARTICLE_EXHAUST_FUMES,
PARTICLE_RUBBER_SMOKE,
PARTICLE_BURNINGRUBBER_SMOKE,
PARTICLE_BULLETHIT_SMOKE,
PARTICLE_GUNSHELL_FIRST,
PARTICLE_GUNSHELL,
PARTICLE_GUNSHELL_BUMP1,
PARTICLE_GUNSHELL_BUMP2,
PARTICLE_TEST,
PARTICLE_BIRD_FRONT,
PARTICLE_RAINDROP_2D,
MAX_PARTICLES,
PARTICLE_FIRST = PARTICLE_SPARK,
PARTICLE_LAST = PARTICLE_RAINDROP_2D
};

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

@ -217,9 +217,9 @@ CRubbish::Update(void)
// FRAMETIME
if(bRubbishInvisible)
RubbishVisibility = max(RubbishVisibility-5, 0);
RubbishVisibility = Max(RubbishVisibility-5, 0);
else
RubbishVisibility = min(RubbishVisibility+5, 255);
RubbishVisibility = Min(RubbishVisibility+5, 255);
// Spawn a new sheet
COneSheet *sheet = StartEmptyList.m_next;

View File

@ -719,10 +719,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();
@ -865,10 +865,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();
@ -1008,11 +1008,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;
@ -1763,7 +1763,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,7 +311,7 @@ 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);
}

View File

@ -195,14 +195,14 @@ void CWaterCannon::PushPeds(void)
{
if ( m_abUsed[i] )
{
minx = min(minx, m_avecPos[i].x);
maxx = max(maxx, m_avecPos[i].x);
minx = Min(minx, m_avecPos[i].x);
maxx = Max(maxx, m_avecPos[i].x);
miny = min(miny, m_avecPos[i].y);
maxy = max(maxy, m_avecPos[i].y);
miny = Min(miny, m_avecPos[i].y);
maxy = Max(maxy, m_avecPos[i].y);
minz = min(minz, m_avecPos[i].z);
maxz = max(maxz, m_avecPos[i].z);
minz = Min(minz, m_avecPos[i].z);
maxz = Max(maxz, m_avecPos[i].z);
}
}

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

@ -163,7 +163,7 @@ void CWeather::Update(void)
else {
// 0.125 probability
LightningBurst = false;
LightningDuration = min(CTimer::GetFrameCounter() - LightningStart, 20);
LightningDuration = Min(CTimer::GetFrameCounter() - LightningStart, 20);
LightningFlash = false;
WhenToPlayLightningSound = CTimer::GetTimeInMilliseconds() + 150 * (20 - LightningDuration);
}
@ -219,9 +219,9 @@ void CWeather::Update(void)
fNewRain = 0.0f;
if (Rain != fNewRain) { // ok to use comparasion
if (Rain < fNewRain)
Rain = min(fNewRain, Rain + RAIN_CHANGE_SPEED * CTimer::GetTimeStep());
Rain = Min(fNewRain, Rain + RAIN_CHANGE_SPEED * CTimer::GetTimeStep());
else
Rain = max(fNewRain, Rain - RAIN_CHANGE_SPEED * CTimer::GetTimeStep());
Rain = Max(fNewRain, Rain - RAIN_CHANGE_SPEED * CTimer::GetTimeStep());
}
// Clouds

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,20 +70,20 @@ 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);
DirectionalLightColourForFrame.blue = min(1.0f, AmbientLightColourForFrame.blue * f1);
DirectionalLightColourForFrame.red = Min(1.0f, AmbientLightColourForFrame.red * f1);
DirectionalLightColourForFrame.green = Min(1.0f, AmbientLightColourForFrame.green * f1);
DirectionalLightColourForFrame.blue = Min(1.0f, AmbientLightColourForFrame.blue * f1);
#endif
}
}
@ -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

@ -692,7 +692,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++;
@ -1010,7 +1010,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);
@ -1018,7 +1018,7 @@ CAutomobile::ProcessControl(void)
FlyingControl(FLIGHT_MODEL_RCPLANE);
}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)
@ -1130,10 +1130,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);
}
}
@ -2601,7 +2601,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;
@ -2700,10 +2700,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
@ -2819,7 +2819,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;
@ -2912,7 +2912,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,
@ -2994,11 +2994,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);
}
}
@ -3146,7 +3146,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);
}
@ -3299,7 +3299,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;
@ -4004,7 +4004,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

@ -272,7 +272,7 @@ CBoat::ProcessControl(void)
impulse = m_vecMoveSpeed.MagnitudeSqr()*pHandling->fSuspensionForceLevel*buoyanceImpulse.z*CTimer::GetTimeStep()*0.5f*m_fGasPedal;
else
impulse = 0.0f;
impulse = min(impulse, GRAVITY*pHandling->fSuspensionDampingLevel*m_fMass*CTimer::GetTimeStep());
impulse = Min(impulse, GRAVITY*pHandling->fSuspensionDampingLevel*m_fMass*CTimer::GetTimeStep());
ApplyMoveForce(impulse*GetUp());
ApplyTurnForce(impulse*GetUp(), buoyancePoint - pHandling->fSuspensionBias*GetForward());
}
@ -375,10 +375,10 @@ CBoat::ProcessControl(void)
}
// Slow down or push down boat as it approaches the world limits
m_vecMoveSpeed.x = min(m_vecMoveSpeed.x, -(GetPosition().x - 1900.0f)*0.01f); // east
m_vecMoveSpeed.x = max(m_vecMoveSpeed.x, -(GetPosition().x - -1515.0f)*0.01f); // west
m_vecMoveSpeed.y = min(m_vecMoveSpeed.y, -(GetPosition().y - 600.0f)*0.01f); // north
m_vecMoveSpeed.y = max(m_vecMoveSpeed.y, -(GetPosition().y - -1900.0f)*0.01f); // south
m_vecMoveSpeed.x = Min(m_vecMoveSpeed.x, -(GetPosition().x - 1900.0f)*0.01f); // east
m_vecMoveSpeed.x = Max(m_vecMoveSpeed.x, -(GetPosition().x - -1515.0f)*0.01f); // west
m_vecMoveSpeed.y = Min(m_vecMoveSpeed.y, -(GetPosition().y - 600.0f)*0.01f); // north
m_vecMoveSpeed.y = Max(m_vecMoveSpeed.y, -(GetPosition().y - -1900.0f)*0.01f); // south
if(!onLand && bBoatInWater)
ApplyWaterResistance();
@ -765,7 +765,7 @@ 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;
@ -837,7 +837,7 @@ CBoat::AddWakePoint(CVector point)
int i;
if(m_afWakePointLifeTime[0] > 0.0f){
if((CVector2D(GetPosition()) - m_avec2dWakePoints[0]).MagnitudeSqr() < SQR(1.0f)){
for(i = min(m_nNumWakePoints, ARRAY_SIZE(m_afWakePointLifeTime)-1); i != 0; i--){
for(i = Min(m_nNumWakePoints, ARRAY_SIZE(m_afWakePointLifeTime)-1); i != 0; i--){
m_avec2dWakePoints[i] = m_avec2dWakePoints[i-1];
m_afWakePointLifeTime[i] = m_afWakePointLifeTime[i-1];
}

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

@ -213,10 +213,10 @@ void CCrane::Update(void)
CTimer::GetTimeInMilliseconds() > m_nTimeForNextCheck) {
CWorld::AdvanceCurrentScanCode();
#ifdef FIX_BUGS
int xstart = max(0, CWorld::GetSectorIndexX(m_fPickupX1));
int xend = min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(m_fPickupX2));
int ystart = max(0, CWorld::GetSectorIndexY(m_fPickupY1));
int yend = min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(m_fPickupY2));
int xstart = Max(0, CWorld::GetSectorIndexX(m_fPickupX1));
int xend = Min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(m_fPickupX2));
int ystart = Max(0, CWorld::GetSectorIndexY(m_fPickupY1));
int yend = Min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(m_fPickupY2));
#else
int xstart = CWorld::GetSectorIndexX(m_fPickupX1);
int xend = CWorld::GetSectorIndexX(m_fPickupX2);

View File

@ -231,19 +231,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;
}
@ -1017,7 +1017,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

@ -281,7 +281,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);
}
}
@ -533,7 +533,7 @@ CVehicle::DoFixedMachineGuns(void)
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()){
@ -874,13 +874,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;

View File

@ -232,35 +232,35 @@ bool CBulletInfo::TestForSniperBullet(float x1, float x2, float y1, float y2, fl
#else
float minP = 0.0f;
float maxP = 1.0f;
float minX = min(PlayerSniperBulletStart.x, PlayerSniperBulletEnd.x);
float maxX = max(PlayerSniperBulletStart.x, PlayerSniperBulletEnd.x);
float minX = Min(PlayerSniperBulletStart.x, PlayerSniperBulletEnd.x);
float maxX = Max(PlayerSniperBulletStart.x, PlayerSniperBulletEnd.x);
if (minX < x2 || maxX > x1) {
if (minX < x1)
minP = min(minP, (x1 - minX) / (maxX - minX));
minP = Min(minP, (x1 - minX) / (maxX - minX));
if (maxX > x2)
maxP = max(maxP, (maxX - x2) / (maxX - minX));
maxP = Max(maxP, (maxX - x2) / (maxX - minX));
}
else
return false;
float minY = min(PlayerSniperBulletStart.y, PlayerSniperBulletEnd.y);
float maxY = max(PlayerSniperBulletStart.y, PlayerSniperBulletEnd.y);
float minY = Min(PlayerSniperBulletStart.y, PlayerSniperBulletEnd.y);
float maxY = Max(PlayerSniperBulletStart.y, PlayerSniperBulletEnd.y);
if (minY < y2 || maxY > y1) {
if (minY < y1)
minP = min(minP, (y1 - minY) / (maxY - minY));
minP = Min(minP, (y1 - minY) / (maxY - minY));
if (maxY > y2)
maxP = max(maxP, (maxY - y2) / (maxY - minY));
maxP = Max(maxP, (maxY - y2) / (maxY - minY));
}
#ifdef FIX_BUGS
else
return false;
#endif
float minZ = min(PlayerSniperBulletStart.z, PlayerSniperBulletEnd.z);
float maxZ = max(PlayerSniperBulletStart.z, PlayerSniperBulletEnd.z);
float minZ = Min(PlayerSniperBulletStart.z, PlayerSniperBulletEnd.z);
float maxZ = Max(PlayerSniperBulletStart.z, PlayerSniperBulletEnd.z);
if (minZ < z2 || maxZ > z1) {
if (minZ < z1)
minP = min(minP, (z1 - minZ) / (maxZ - minZ));
minP = Min(minP, (z1 - minZ) / (maxZ - minZ));
if (maxZ > z2)
maxP = max(maxP, (maxZ - z2) / (maxZ - minZ));
maxP = Max(maxP, (maxZ - z2) / (maxZ - minZ));
}
else
return false;

View File

@ -1,7 +1,8 @@
#pragma once
#include "WeaponType.h"
class CEntity;
enum eWeaponType;
class CBulletInfo
{

View File

@ -1,9 +1,10 @@
#pragma once
#include "WeaponType.h"
class CEntity;
class CObject;
class CProjectile;
enum eWeaponType;
class CProjectileInfo
{

View File

@ -109,7 +109,7 @@ CShotInfo::Update()
if (shot.m_sourceEntity) {
assert(shot.m_sourceEntity->IsPed());
CPed *ped = (CPed*) shot.m_sourceEntity;
float radius = max(1.0f, shot.m_radius);
float radius = Max(1.0f, shot.m_radius);
for (int i = 0; i < ped->m_numNearPeds; ++i) {
CPed *nearPed = ped->m_nearPeds[i];

View File

@ -1,7 +1,8 @@
#pragma once
#include "WeaponType.h"
class CEntity;
enum eWeaponType;
class CShotInfo
{

View File

@ -107,9 +107,11 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
CVector fireOffset(0.0f, 0.0f, 0.6f);
CVector *source = fireSource;
if ( !fireSource )
source = &(shooter->GetMatrix() * fireOffset);
if (!fireSource) {
static CVector tmp;
tmp = shooter->GetMatrix() * fireOffset;
source = &tmp;
}
if ( m_bAddRotOffset )
{
float heading = RADTODEG(shooter->GetForward().Heading());
@ -997,7 +999,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
CParticle::AddParticle(PARTICLE_SPARK, point->point, point->normal*0.05f);
CVector dist = point->point - (*source);
CVector offset = dist - max(0.2f*dist.Magnitude(), 2.0f) * CVector(ahead.x, ahead.y, 0.0f);
CVector offset = dist - Max(0.2f*dist.Magnitude(), 2.0f) * CVector(ahead.x, ahead.y, 0.0f);
CVector smokePos = *source + offset;
smokePos.x += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
@ -1016,7 +1018,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
CParticle::AddParticle(PARTICLE_SPARK, point->point, point->normal*0.05f);
CVector dist = point->point - (*source);
CVector offset = dist - max(0.2f*dist.Magnitude(), 0.5f) * CVector(ahead.x, ahead.y, 0.0f);
CVector offset = dist - Max(0.2f*dist.Magnitude(), 0.5f) * CVector(ahead.x, ahead.y, 0.0f);
CVector smokePos = *source + offset;
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f));
@ -1265,7 +1267,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
CParticle::AddParticle(PARTICLE_SPARK, point.point, point.normal*0.05f);
CVector dist = point.point - (*fireSource);
CVector offset = dist - max(0.2f*dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
CVector offset = dist - Max(0.2f*dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
CVector smokePos = *fireSource + offset;
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f));
@ -1280,7 +1282,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
CParticle::AddParticle(PARTICLE_SPARK, point.point, point.normal*0.05f);
CVector dist = point.point - (*fireSource);
CVector offset = dist - max(0.2f*dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
CVector offset = dist - Max(0.2f*dist.Magnitude(), 2.0f) * CVector(shootRot.x, shootRot.y, 0.0f);
CVector smokePos = *fireSource + offset;
smokePos.x += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
@ -1347,7 +1349,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
else
{
CVector traceTarget = *fireSource;
traceTarget += (target - (*fireSource)) * min(info->m_fRange, 30.0f) / info->m_fRange;
traceTarget += (target - (*fireSource)) * Min(info->m_fRange, 30.0f) / info->m_fRange;
CBulletTraces::AddTrace(fireSource, &traceTarget);
}
}
@ -1877,8 +1879,9 @@ CWeapon::DoTankDoomAiming(CEntity *shooter, CEntity *driver, CVector *source, CV
if ( 3.0f*distToVictimZ < distToVictim )
{
CVector tmp = CVector(victim->GetPosition().x, victim->GetPosition().y, 0.0f);
if ( CCollision::DistToLine(source, target,
&CVector(victim->GetPosition().x, victim->GetPosition().y, 0.0f)) < victim->GetBoundRadius()*3.0f )
&tmp) < victim->GetBoundRadius()*3.0f )
{
float vehicleDist = Sqrt(SQR(distToVictim) + SQR(distToVictimZ));
if ( vehicleDist < closestEntityDist )
@ -2145,12 +2148,12 @@ CWeapon::MakePedsJumpAtShot(CPhysical *shooter, CVector *source, CVector *target
ASSERT(source!=nil);
ASSERT(target!=nil);
float minx = min(source->x, target->x) - 2.0f;
float maxx = max(source->x, target->x) + 2.0f;
float miny = min(source->y, target->y) - 2.0f;
float maxy = max(source->y, target->y) + 2.0f;
float minz = min(source->z, target->z) - 2.0f;
float maxz = max(source->z, target->z) + 2.0f;
float minx = Min(source->x, target->x) - 2.0f;
float maxx = Max(source->x, target->x) + 2.0f;
float miny = Min(source->y, target->y) - 2.0f;
float maxy = Max(source->y, target->y) + 2.0f;
float minz = Min(source->z, target->z) - 2.0f;
float maxz = Max(source->z, target->z) + 2.0f;
for ( int32 i = CPools::GetPedPool()->GetSize() - 1; i >= 0; i--)
{

View File

@ -1,56 +1,10 @@
#pragma once
#include "WeaponType.h"
#define DRIVEBYAUTOAIMING_MAXDIST (2.5f)
#define DOOMAUTOAIMING_MAXDIST (9000.0f)
enum eWeaponType
{
WEAPONTYPE_UNARMED,
WEAPONTYPE_BASEBALLBAT,
WEAPONTYPE_COLT45,
WEAPONTYPE_UZI,
WEAPONTYPE_SHOTGUN,
WEAPONTYPE_AK47,
WEAPONTYPE_M16,
WEAPONTYPE_SNIPERRIFLE,
WEAPONTYPE_ROCKETLAUNCHER,
WEAPONTYPE_FLAMETHROWER,
WEAPONTYPE_MOLOTOV,
WEAPONTYPE_GRENADE,
WEAPONTYPE_DETONATOR,
WEAPONTYPE_HELICANNON,
WEAPONTYPE_LAST_WEAPONTYPE,
WEAPONTYPE_ARMOUR,
WEAPONTYPE_RAMMEDBYCAR,
WEAPONTYPE_RUNOVERBYCAR,
WEAPONTYPE_EXPLOSION,
WEAPONTYPE_UZI_DRIVEBY,
WEAPONTYPE_DROWNING,
WEAPONTYPE_FALL,
WEAPONTYPE_UNIDENTIFIED,
WEAPONTYPE_TOTALWEAPONS = WEAPONTYPE_LAST_WEAPONTYPE,
WEAPONTYPE_TOTAL_INVENTORY_WEAPONS = 13,
};
enum eWeaponFire {
WEAPON_FIRE_MELEE,
WEAPON_FIRE_INSTANT_HIT,
WEAPON_FIRE_PROJECTILE,
WEAPON_FIRE_AREA_EFFECT,
WEAPON_FIRE_USE
};
// Taken from MTA SA, seems it's unchanged
enum eWeaponState
{
WEAPONSTATE_READY,
WEAPONSTATE_FIRING,
WEAPONSTATE_RELOADING,
WEAPONSTATE_OUT_OF_AMMO,
WEAPONSTATE_MELEE_MADECONTACT
};
class CEntity;
class CPhysical;
class CAutomobile;

View File

@ -1,8 +1,7 @@
#pragma once
enum AnimationId;
enum eWeaponFire;
enum eWeaponType;
#include "AnimationId.h"
#include "WeaponType.h"
class CWeaponInfo {
// static CWeaponInfo(&ms_apWeaponInfos)[14];

49
src/weapons/WeaponType.h Normal file
View File

@ -0,0 +1,49 @@
#pragma once
enum eWeaponType
{
WEAPONTYPE_UNARMED,
WEAPONTYPE_BASEBALLBAT,
WEAPONTYPE_COLT45,
WEAPONTYPE_UZI,
WEAPONTYPE_SHOTGUN,
WEAPONTYPE_AK47,
WEAPONTYPE_M16,
WEAPONTYPE_SNIPERRIFLE,
WEAPONTYPE_ROCKETLAUNCHER,
WEAPONTYPE_FLAMETHROWER,
WEAPONTYPE_MOLOTOV,
WEAPONTYPE_GRENADE,
WEAPONTYPE_DETONATOR,
WEAPONTYPE_HELICANNON,
WEAPONTYPE_LAST_WEAPONTYPE,
WEAPONTYPE_ARMOUR,
WEAPONTYPE_RAMMEDBYCAR,
WEAPONTYPE_RUNOVERBYCAR,
WEAPONTYPE_EXPLOSION,
WEAPONTYPE_UZI_DRIVEBY,
WEAPONTYPE_DROWNING,
WEAPONTYPE_FALL,
WEAPONTYPE_UNIDENTIFIED,
WEAPONTYPE_TOTALWEAPONS = WEAPONTYPE_LAST_WEAPONTYPE,
WEAPONTYPE_TOTAL_INVENTORY_WEAPONS = 13,
};
enum eWeaponFire {
WEAPON_FIRE_MELEE,
WEAPON_FIRE_INSTANT_HIT,
WEAPON_FIRE_PROJECTILE,
WEAPON_FIRE_AREA_EFFECT,
WEAPON_FIRE_USE
};
// Taken from MTA SA, seems it's unchanged
enum eWeaponState
{
WEAPONSTATE_READY,
WEAPONSTATE_FIRING,
WEAPONSTATE_RELOADING,
WEAPONSTATE_OUT_OF_AMMO,
WEAPONSTATE_MELEE_MADECONTACT
};