summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/audio/AudioManager.h4
-rw-r--r--src/peds/Ped.cpp2
-rw-r--r--src/peds/PedFight.cpp12
-rw-r--r--src/peds/PlayerPed.cpp24
-rw-r--r--src/weapons/ShotInfo.cpp6
-rw-r--r--src/weapons/WeaponInfo.cpp18
-rw-r--r--src/weapons/WeaponInfo.h30
7 files changed, 43 insertions, 53 deletions
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index e3d91876..9fe2f4ef 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -135,9 +135,9 @@ public:
cPedParams()
{
- m_pPed = nil;
m_bDistanceCalculated = false;
m_fDistance = 0.0f;
+ m_pPed = nil;
}
};
@@ -155,7 +155,7 @@ public:
{
m_bDistanceCalculated = false;
m_fDistance = 0.0f;
- m_pVehicle = 0;
+ m_pVehicle = nil;
m_pTransmission = nil;
m_nIndex = 0;
m_fVelocityChange = 0.0f;
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index b8b3e92c..3d2278bd 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -1046,7 +1046,7 @@ CPed::SetAimFlag(float angle)
m_lookTimer = 0;
m_pLookTarget = nil;
m_pSeekTarget = nil;
- if (CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAimWithArm)
+ if (CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM))
m_pedIK.m_flags |= CPedIK::AIMS_WITH_ARM;
else
m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM;
diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp
index 6188f019..ca720479 100644
--- a/src/peds/PedFight.cpp
+++ b/src/peds/PedFight.cpp
@@ -201,7 +201,7 @@ CPed::PointGunAt(void)
weaponAssoc->SetCurrentTime(weaponInfo->m_fAnimLoopStart);
weaponAssoc->flags &= ~ASSOC_RUNNING;
- if (weaponInfo->m_bCanAimWithArm)
+ if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM))
m_pedIK.m_flags |= CPedIK::AIMS_WITH_ARM;
else
m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM;
@@ -300,7 +300,7 @@ CPed::SetAttack(CEntity *victim)
if (m_pSeekTarget)
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
- if (curWeapon->m_bCanAim) {
+ if (curWeapon->IsFlagSet(WEAPONFLAG_CANAIM)) {
CVector aimPos = GetRight() * 0.1f + GetForward() * 0.2f + GetPosition();
CEntity *obstacle = CWorld::TestSphereAgainstWorld(aimPos, 0.2f, nil, true, false, false, true, false, false);
if (obstacle)
@@ -342,7 +342,7 @@ CPed::SetAttack(CEntity *victim)
if (pointBlankStatus == POINT_BLANK_FOR_WANTED_PED || !victimPed)
StartFightAttack(200);
} else {
- if (!curWeapon->m_bCanAim)
+ if (!curWeapon->IsFlagSet(WEAPONFLAG_CANAIM))
m_pSeekTarget = nil;
if (m_nPedState != PED_AIM_GUN)
@@ -417,7 +417,7 @@ CPed::ClearAttackByRemovingAnim(void)
if (!weaponAssoc) {
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), weapon->m_Anim2ToPlay);
- if (!weaponAssoc && weapon->m_bThrow)
+ if (!weaponAssoc && weapon->IsFlagSet(WEAPONFLAG_THROW))
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_THROWU);
if (!weaponAssoc) {
@@ -569,7 +569,7 @@ CPed::Attack(void)
delayBetweenAnimAndFire = ourWeapon->m_fAnim2FrameFire;
// Long throw granade, molotov
- if (!weaponAnimAssoc && ourWeapon->m_bThrow) {
+ if (!weaponAnimAssoc && ourWeapon->IsFlagSet(WEAPONFLAG_THROW)) {
weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_THROWU);
delayBetweenAnimAndFire = 0.2f;
}
@@ -605,7 +605,7 @@ CPed::Attack(void)
animStart = ourWeapon->m_fAnimLoopStart;
weaponAnimTime = weaponAnimAssoc->currentTime;
if (weaponAnimTime > animStart && weaponAnimTime - weaponAnimAssoc->timeStep <= animStart) {
- if (ourWeapon->m_bCanAimWithArm)
+ if (ourWeapon->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM))
m_pedIK.m_flags |= CPedIK::AIMS_WITH_ARM;
else
m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM;
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index 330d209b..ef5815ed 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -192,7 +192,7 @@ CPlayerPed::MakeChangesForNewWeapon(int8 weapon)
GetWeapon()->m_nAmmoInClip = Min(GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition);
- if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAim))
+ if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM))
ClearWeaponTarget();
CAnimBlendAssociation *weaponAnim = RpAnimBlendClumpGetAssociation(GetClump(), CWeaponInfo::GetWeaponInfo(WEAPONTYPE_SNIPERRIFLE)->m_AnimToPlay);
@@ -685,7 +685,7 @@ CPlayerPed::PlayerControlFighter(CPad *padUsed)
bIsAttacking = false;
}
- if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy && padUsed->JumpJustDown()) {
+ if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY) && padUsed->JumpJustDown()) {
if (m_nEvadeAmount != 0 && m_pEvadingFrom) {
SetEvasiveDive((CPhysical*)m_pEvadingFrom, 1);
m_nEvadeAmount = 0;
@@ -723,13 +723,13 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
m_fMoveSpeed = 0.0f;
}
}
- if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
+ if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY) && padUsed->GetSprint()) {
m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
SetRealMoveAnim();
- if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
+ if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY))
&& padUsed->JumpJustDown() && m_nPedState != PED_JUMP) {
ClearAttack();
ClearWeaponTarget();
@@ -1061,12 +1061,12 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) {
// Weapons except throwable and melee ones
- if (weaponInfo->m_bCanAim || weaponInfo->m_b1stPerson || weaponInfo->m_bExpands) {
- if ((padUsed->GetTarget() && weaponInfo->m_bCanAimWithArm) || padUsed->GetWeapon()) {
+ if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) || weaponInfo->IsFlagSet(WEAPONFLAG_1ST_PERSON) || weaponInfo->IsFlagSet(WEAPONFLAG_EXPANDS)) {
+ if ((padUsed->GetTarget() && weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) || padUsed->GetWeapon()) {
float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation);
// On this one we can rotate arm.
- if (weaponInfo->m_bCanAimWithArm) {
+ if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) {
if (!padUsed->GetWeapon()) { // making this State != ATTACK still stops it after attack. Re-start it immediately!
SetPointGunAt(nil);
bIsPointingGunAt = false; // to not stop after attack
@@ -1083,7 +1083,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_headingRate = 50.0f;
// Anim. fix for shotgun, ak47 and m16 (we must finish rot. it quickly)
- if (weaponInfo->m_bCanAim && padUsed->WeaponJustDown()) {
+ if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) && padUsed->WeaponJustDown()) {
m_fRotationCur = CGeneral::LimitRadianAngle(m_fRotationCur);
float limitedRotDest = m_fRotationDest;
@@ -1096,7 +1096,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2;
}
}
- } else if (weaponInfo->m_bCanAimWithArm && m_nPedState != PED_ATTACK)
+ } else if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM) && m_nPedState != PED_ATTACK)
ClearPointGunAt();
}
}
@@ -1133,7 +1133,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
TheCamera.UpdateAimingCoors(m_pPointGunAt->GetPosition());
}
#ifdef FREE_CAM
- else if ((CCamera::bFreeCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE) || (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson)) {
+ else if ((CCamera::bFreeCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE) || (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) && !CCamera::m_bUseMouse3rdPerson)) {
#else
else if (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson) {
#endif
@@ -1215,13 +1215,13 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
}
}
- if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
+ if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY) && padUsed->GetSprint()) {
m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
SetRealMoveAnim();
- if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
+ if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY))
&& padUsed->JumpJustDown() && m_nPedState != PED_JUMP) {
ClearAttack();
ClearWeaponTarget();
diff --git a/src/weapons/ShotInfo.cpp b/src/weapons/ShotInfo.cpp
index c0ab9ac1..e604093c 100644
--- a/src/weapons/ShotInfo.cpp
+++ b/src/weapons/ShotInfo.cpp
@@ -76,7 +76,7 @@ CShotInfo::AddShot(CEntity *sourceEntity, eWeaponType weapon, CVector startPos,
gaShotInfo[slot].m_areaAffected.z += CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)];
}
gaShotInfo[slot].m_areaAffected.Normalise();
- if (weaponInfo->m_bRandSpeed)
+ if (weaponInfo->IsFlagSet(WEAPONFLAG_RAND_SPEED))
gaShotInfo[slot].m_areaAffected *= CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)] + weaponInfo->m_fSpeed;
else
gaShotInfo[slot].m_areaAffected *= weaponInfo->m_fSpeed;
@@ -117,10 +117,10 @@ CShotInfo::Update()
shot.m_inUse = false;
}
- if (weaponInfo->m_bSlowsDown)
+ if (weaponInfo->IsFlagSet(WEAPONFLAG_SLOWS_DOWN))
shot.m_areaAffected *= pow(0.96, CTimer::GetTimeStep()); // FRAMERATE
- if (weaponInfo->m_bExpands)
+ if (weaponInfo->IsFlagSet(WEAPONFLAG_EXPANDS))
shot.m_radius += 0.075f * CTimer::GetTimeStep();
shot.m_startPos += CTimer::GetTimeStep() * shot.m_areaAffected;
diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp
index 69d2faed..546aa6ba 100644
--- a/src/weapons/WeaponInfo.cpp
+++ b/src/weapons/WeaponInfo.cpp
@@ -39,11 +39,7 @@ CWeaponInfo::Initialise(void)
ms_apWeaponInfos[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT;
ms_apWeaponInfos[i].m_AnimToPlay = ANIM_PUNCH_R;
ms_apWeaponInfos[i].m_Anim2ToPlay = NUM_ANIMS;
- ms_apWeaponInfos[i].m_bUseGravity = 1;
- ms_apWeaponInfos[i].m_bSlowsDown = 1;
- ms_apWeaponInfos[i].m_bRandSpeed = 1;
- ms_apWeaponInfos[i].m_bExpands = 1;
- ms_apWeaponInfos[i].m_bExplodes = 1;
+ ms_apWeaponInfos[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES;
}
debug("Loading weapon data...\n");
LoadWeaponData();
@@ -160,17 +156,7 @@ CWeaponInfo::LoadWeaponData(void)
ms_apWeaponInfos[weaponType].m_fAnimFrameFire = delayBetweenAnimAndFire / 30.0f;
ms_apWeaponInfos[weaponType].m_fAnim2FrameFire = delayBetweenAnim2AndFire / 30.0f;
ms_apWeaponInfos[weaponType].m_nModelId = modelId;
- ms_apWeaponInfos[weaponType].m_bUseGravity = flags & 1;
- ms_apWeaponInfos[weaponType].m_bSlowsDown = (flags >> 1) & 1;
- ms_apWeaponInfos[weaponType].m_bDissipates = (flags >> 2) & 1;
- ms_apWeaponInfos[weaponType].m_bRandSpeed = (flags >> 3) & 1;
- ms_apWeaponInfos[weaponType].m_bExpands = (flags >> 4) & 1;
- ms_apWeaponInfos[weaponType].m_bExplodes = (flags >> 5) & 1;
- ms_apWeaponInfos[weaponType].m_bCanAim = (flags >> 6) & 1;
- ms_apWeaponInfos[weaponType].m_bCanAimWithArm = (flags >> 7) & 1;
- ms_apWeaponInfos[weaponType].m_b1stPerson = (flags >> 8) & 1;
- ms_apWeaponInfos[weaponType].m_bHeavy = (flags >> 9) & 1;
- ms_apWeaponInfos[weaponType].m_bThrow = (flags >> 10) & 1;
+ ms_apWeaponInfos[weaponType].m_Flags = flags;
}
}
diff --git a/src/weapons/WeaponInfo.h b/src/weapons/WeaponInfo.h
index c89dd482..69ad1f39 100644
--- a/src/weapons/WeaponInfo.h
+++ b/src/weapons/WeaponInfo.h
@@ -3,8 +3,22 @@
#include "AnimationId.h"
#include "WeaponType.h"
+enum
+{
+ WEAPONFLAG_USE_GRAVITY = 1,
+ WEAPONFLAG_SLOWS_DOWN = 1 << 1,
+ WEAPONFLAG_DISSIPATES = 1 << 2,
+ WEAPONFLAG_RAND_SPEED = 1 << 3,
+ WEAPONFLAG_EXPANDS = 1 << 4,
+ WEAPONFLAG_EXPLODES = 1 << 5,
+ WEAPONFLAG_CANAIM = 1 << 6,
+ WEAPONFLAG_CANAIM_WITHARM = 1 << 7,
+ WEAPONFLAG_1ST_PERSON = 1 << 8,
+ WEAPONFLAG_HEAVY = 1 << 9,
+ WEAPONFLAG_THROW = 1 << 10,
+};
+
class CWeaponInfo {
-// static CWeaponInfo(&ms_apWeaponInfos)[14];
static CWeaponInfo ms_apWeaponInfos[WEAPONTYPE_LAST_WEAPONTYPE];
public:
eWeaponFire m_eWeaponFire;
@@ -25,18 +39,7 @@ public:
float m_fAnimFrameFire;
float m_fAnim2FrameFire;
int32 m_nModelId;
- // flags
- uint8 m_bUseGravity : 1;
- uint8 m_bSlowsDown : 1;
- uint8 m_bDissipates : 1;
- uint8 m_bRandSpeed : 1;
- uint8 m_bExpands : 1;
- uint8 m_bExplodes : 1;
- uint8 m_bCanAim : 1;
- uint8 m_bCanAimWithArm : 1;
- uint8 m_b1stPerson : 1;
- uint8 m_bHeavy : 1;
- uint8 m_bThrow : 1;
+ uint32 m_Flags;
static void Initialise(void);
static void LoadWeaponData(void);
@@ -44,6 +47,7 @@ public:
static eWeaponFire FindWeaponFireType(char *name);
static eWeaponType FindWeaponType(char *name);
static void Shutdown(void);
+ bool IsFlagSet(uint32 flag) const { return (m_Flags & flag) != 0; }
};
VALIDATE_SIZE(CWeaponInfo, 0x54); \ No newline at end of file