summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio/AudioManager.cpp2
-rw-r--r--src/audio/sampman_oal.cpp12
-rw-r--r--src/control/OnscreenTimer.cpp122
-rw-r--r--src/core/Crime.h2
-rw-r--r--src/core/config.h10
-rw-r--r--src/peds/Ped.cpp53
-rw-r--r--src/peds/Ped.h2
-rw-r--r--src/peds/PedFight.cpp2
-rw-r--r--src/peds/PedIK.cpp4
-rw-r--r--src/peds/PedIK.h2
-rw-r--r--src/peds/PlayerPed.cpp4
-rw-r--r--src/save/SaveBuf.h18
-rw-r--r--src/weapons/Weapon.cpp4
13 files changed, 139 insertions, 98 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index a3bc6a01..2e391349 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -977,7 +977,7 @@ void
cAudioManager::AdjustSamplesVolume()
{
for (int i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
- tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] + 1];
+ tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
if (!pSample->m_bIs2D)
pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_fSoundIntensity, pSample->m_fDistance);
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index c566893a..7fb84965 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -1214,14 +1214,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
- int8 slot;
-
for ( int32 i = 0; i < _TODOCONST(3); i++ )
{
- slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
+ int8 slot = (int8)nCurrentPedSlot - i - 1;
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
+#else
+ uint8 slot = nCurrentPedSlot - i - 1;
#endif
if ( nComment == nPedSlotSfx[slot] )
return TRUE;
@@ -1234,14 +1234,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
int32
cSampleManager::_GetPedCommentSlot(uint32 nComment)
{
- int8 slot;
-
for (int32 i = 0; i < _TODOCONST(3); i++)
{
- slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
+ int8 slot = (int8)nCurrentPedSlot - i - 1;
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
+#else
+ uint8 slot = nCurrentPedSlot - i - 1;
#endif
if (nComment == nPedSlotSfx[slot])
return slot;
diff --git a/src/control/OnscreenTimer.cpp b/src/control/OnscreenTimer.cpp
index 8cc1ae69..08c68cb5 100644
--- a/src/control/OnscreenTimer.cpp
+++ b/src/control/OnscreenTimer.cpp
@@ -8,112 +8,111 @@
#include "Script.h"
#include "OnscreenTimer.h"
-void COnscreenTimer::Init() {
+void
+COnscreenTimer::Init()
+{
m_bDisabled = false;
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
m_sEntries[i].m_nTimerOffset = 0;
m_sEntries[i].m_nCounterOffset = 0;
for(uint32 j = 0; j < 10; j++) {
- m_sEntries[i].m_aTimerText[j] = 0;
- m_sEntries[i].m_aCounterText[j] = 0;
+ m_sEntries[i].m_aTimerText[j] = '\0';
+ m_sEntries[i].m_aCounterText[j] = '\0';
}
m_sEntries[i].m_nType = COUNTER_DISPLAY_NUMBER;
- m_sEntries[i].m_bTimerProcessed = 0;
- m_sEntries[i].m_bCounterProcessed = 0;
+ m_sEntries[i].m_bTimerProcessed = false;
+ m_sEntries[i].m_bCounterProcessed = false;
}
}
-void COnscreenTimer::Process() {
- if(!CReplay::IsPlayingBack() && !m_bDisabled) {
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
+void
+COnscreenTimer::Process()
+{
+ if(!CReplay::IsPlayingBack() && !m_bDisabled)
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
m_sEntries[i].Process();
- }
- }
}
-void COnscreenTimer::ProcessForDisplay() {
+void
+COnscreenTimer::ProcessForDisplay()
+{
if(CHud::m_Wants_To_Draw_Hud) {
m_bProcessed = false;
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
- if(m_sEntries[i].ProcessForDisplay()) {
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
+ if(m_sEntries[i].ProcessForDisplay())
m_bProcessed = true;
- }
- }
}
}
-void COnscreenTimer::ClearCounter(uint32 offset) {
+void
+COnscreenTimer::ClearCounter(uint32 offset)
+{
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
if(offset == m_sEntries[i].m_nCounterOffset) {
m_sEntries[i].m_nCounterOffset = 0;
- m_sEntries[i].m_aCounterText[0] = 0;
+ m_sEntries[i].m_aCounterText[0] = '\0';
m_sEntries[i].m_nType = COUNTER_DISPLAY_NUMBER;
- m_sEntries[i].m_bCounterProcessed = 0;
+ m_sEntries[i].m_bCounterProcessed = false;
}
}
}
-void COnscreenTimer::ClearClock(uint32 offset) {
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
+void
+COnscreenTimer::ClearClock(uint32 offset)
+{
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
if(offset == m_sEntries[i].m_nTimerOffset) {
m_sEntries[i].m_nTimerOffset = 0;
- m_sEntries[i].m_aTimerText[0] = 0;
- m_sEntries[i].m_bTimerProcessed = 0;
+ m_sEntries[i].m_aTimerText[0] = '\0';
+ m_sEntries[i].m_bTimerProcessed = false;
}
- }
}
-void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text) {
- uint32 i = 0;
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
+void
+COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text)
+{
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
if(m_sEntries[i].m_nCounterOffset == 0) {
+ m_sEntries[i].m_nCounterOffset = offset;
+ if (text)
+ strncpy(m_sEntries[i].m_aCounterText, text, 10);
+ else
+ m_sEntries[i].m_aCounterText[0] = '\0';
+ m_sEntries[i].m_nType = type;
break;
}
- return;
- }
-
- m_sEntries[i].m_nCounterOffset = offset;
- if(text) {
- strncpy(m_sEntries[i].m_aCounterText, text, 10);
- } else {
- m_sEntries[i].m_aCounterText[0] = 0;
- }
-
- m_sEntries[i].m_nType = type;
}
-void COnscreenTimer::AddClock(uint32 offset, char* text) {
- uint32 i = 0;
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
+void
+COnscreenTimer::AddClock(uint32 offset, char* text)
+{
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
if(m_sEntries[i].m_nTimerOffset == 0) {
+ m_sEntries[i].m_nTimerOffset = offset;
+ if (text)
+ strncpy(m_sEntries[i].m_aTimerText, text, 10);
+ else
+ m_sEntries[i].m_aTimerText[0] = '\0';
break;
}
- return;
- }
-
- m_sEntries[i].m_nTimerOffset = offset;
- if(text) {
- strncpy(m_sEntries[i].m_aTimerText, text, 10);
- } else {
- m_sEntries[i].m_aTimerText[0] = 0;
- }
}
-void COnscreenTimerEntry::Process() {
- if(m_nTimerOffset == 0) {
+void
+COnscreenTimerEntry::Process()
+{
+ if(m_nTimerOffset == 0)
return;
- }
int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nTimerOffset);
int32 oldTime = *timerPtr;
int32 newTime = oldTime - int32(CTimer::GetTimeStepInMilliseconds());
if(newTime < 0) {
*timerPtr = 0;
- m_bTimerProcessed = 0;
+ m_bTimerProcessed = false;
m_nTimerOffset = 0;
- m_aTimerText[0] = 0;
+ m_aTimerText[0] = '\0';
} else {
*timerPtr = newTime;
int32 oldTimeSeconds = oldTime / 1000;
@@ -123,13 +122,14 @@ void COnscreenTimerEntry::Process() {
}
}
-bool COnscreenTimerEntry::ProcessForDisplay() {
+bool
+COnscreenTimerEntry::ProcessForDisplay()
+{
m_bTimerProcessed = false;
m_bCounterProcessed = false;
- if(m_nTimerOffset == 0 && m_nCounterOffset == 0) {
+ if(m_nTimerOffset == 0 && m_nCounterOffset == 0)
return false;
- }
if(m_nTimerOffset != 0) {
m_bTimerProcessed = true;
@@ -143,13 +143,17 @@ bool COnscreenTimerEntry::ProcessForDisplay() {
return true;
}
-void COnscreenTimerEntry::ProcessForDisplayClock() {
+void
+COnscreenTimerEntry::ProcessForDisplayClock()
+{
uint32 time = *CTheScripts::GetPointerToScriptVariable(m_nTimerOffset);
sprintf(m_bTimerBuffer, "%02d:%02d", time / 1000 / 60,
time / 1000 % 60);
}
-void COnscreenTimerEntry::ProcessForDisplayCounter() {
+void
+COnscreenTimerEntry::ProcessForDisplayCounter()
+{
uint32 counter = *CTheScripts::GetPointerToScriptVariable(m_nCounterOffset);
sprintf(m_bCounterBuffer, "%d", counter);
}
diff --git a/src/core/Crime.h b/src/core/Crime.h
index 8dfae5b8..05829040 100644
--- a/src/core/Crime.h
+++ b/src/core/Crime.h
@@ -25,7 +25,7 @@ class CCrimeBeingQd
{
public:
eCrimeType m_nType;
- uint32 m_nId;
+ int32 m_nId;
uint32 m_nTime;
CVector m_vecPosn;
bool m_bReported;
diff --git a/src/core/config.h b/src/core/config.h
index a78aee22..2d1b75ae 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -380,12 +380,12 @@ enum Config {
#define CAMERA_PICKUP
// Peds
-#define PED_SKIN // support for skinned geometry on peds
+#define PED_SKIN // support for skinned geometry on peds, requires COMPATIBLE_SAVES
#define ANIMATE_PED_COL_MODEL
// #define VC_PED_PORTS // various ports from VC's CPed, mostly subtle
// #define NEW_WALK_AROUND_ALGORITHM // to make walking around vehicles/objects less awkward
#define CANCELLABLE_CAR_ENTER
-//#define PEDS_REPORT_CRIMES_ON_PHONE
+//#define PEDS_REPORT_CRIMES_ON_PHONE, requires COMPATIBLE_SAVES
// Camera
//#define PS2_CAM_TRANSITION // old way of transitioning between cam modes
@@ -430,6 +430,12 @@ enum Config {
#define VC_RAIN_NERF // Reduces number of rain particles
#endif
+// if these defines are enabled saves are not vanilla compatible without COMPATIBLE_SAVES
+#ifndef COMPATIBLE_SAVES
+#undef PED_SKIN
+#undef PEDS_REPORT_CRIMES_ON_PHONE
+#endif
+
// -------
#if defined __MWERKS__ || defined VANILLA_DEFINES
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 04e13c33..4d80cac2 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -308,6 +308,30 @@ CPed::~CPed(void)
m_pFire->Extinguish();
CPopulation::UpdatePedCount((ePedType)m_nPedType, true);
DMAudio.DestroyEntity(m_audioEntityId);
+
+ // Because of the nature of ped lists in GTA, it can sometimes be outdated.
+ // Remove ourself from nearPeds list of the Peds in our nearPeds list.
+#ifdef FIX_BUGS
+ for(int i = 0; i < m_numNearPeds; i++) {
+ CPed *nearPed = m_nearPeds[i];
+ assert(nearPed != nil);
+ if (!nearPed->IsPointerValid())
+ continue;
+
+ for(int j = 0; j < nearPed->m_numNearPeds;) {
+ assert(j == ARRAY_SIZE(m_nearPeds) - 1 || nearPed->m_nearPeds[j] || !nearPed->m_nearPeds[j+1]); // ensure nil comes after nil
+
+ if (nearPed->m_nearPeds[j] == this) {
+ for (int k = j; k < ARRAY_SIZE(m_nearPeds) - 1; k++) {
+ nearPed->m_nearPeds[k] = nearPed->m_nearPeds[k + 1];
+ nearPed->m_nearPeds[k + 1] = nil;
+ }
+ nearPed->m_numNearPeds--;
+ } else
+ j++;
+ }
+ }
+#endif
}
void
@@ -398,13 +422,15 @@ CPed::BuildPedLists(void)
} else
removePed = true;
}
+
+ assert(i == ARRAY_SIZE(m_nearPeds) - 1 || m_nearPeds[i] || !m_nearPeds[i+1]); // ensure nil comes after nil
+
if (removePed) {
// If we arrive here, the ped we're checking isn't "near", so we should remove it.
for (int j = i; j < ARRAY_SIZE(m_nearPeds) - 1; j++) {
m_nearPeds[j] = m_nearPeds[j + 1];
m_nearPeds[j + 1] = nil;
}
- // Above loop won't work on last slot, so we need to empty it.
m_nearPeds[ARRAY_SIZE(m_nearPeds) - 1] = nil;
m_numNearPeds--;
} else
@@ -3023,7 +3049,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
CColModel *hisCol = CModelInfo::GetModelInfo(collidingEnt->GetModelIndex())->GetColModel();
if (!bUsesCollision)
- return false;
+ return 0;
if (collidingEnt->IsVehicle() && ((CVehicle*)collidingEnt)->IsBoat())
collidedWithBoat = true;
@@ -6068,7 +6094,7 @@ CPed::FollowPath(void)
}
void
-CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
+CPed::SetEvasiveStep(CPhysical *reason, uint8 animType)
{
AnimationId stepAnim;
@@ -6086,22 +6112,23 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
if (neededTurn > PI)
neededTurn = TWOPI - neededTurn;
- CVehicle *veh = (CVehicle*)reason;
- if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR) {
+ if (reason->IsVehicle() && ((CVehicle*)reason)->IsCar()) {
+ CVehicle *veh = (CVehicle*)reason;
if (veh->m_nCarHornTimer != 0) {
vehPressedHorn = true;
if (!IsPlayer())
animType = 1;
}
}
- if (neededTurn <= DEGTORAD(90.0f) || veh->GetModelIndex() == MI_RCBANDIT || vehPressedHorn || animType != 0) {
- SetLookFlag(veh, true);
- if ((CGeneral::GetRandomNumber() & 1) && veh->GetModelIndex() != MI_RCBANDIT && animType == 0) {
+
+ if (neededTurn <= DEGTORAD(90.0f) || reason->GetModelIndex() == MI_RCBANDIT || vehPressedHorn || animType != 0) {
+ SetLookFlag(reason, true);
+ if ((CGeneral::GetRandomNumber() & 1) && reason->GetModelIndex() != MI_RCBANDIT && animType == 0) {
stepAnim = ANIM_STD_HAILTAXI;
} else {
- float vehDirection = CGeneral::GetRadianAngleBetweenPoints(
- veh->m_vecMoveSpeed.x, veh->m_vecMoveSpeed.y,
+ float dangerDirection = CGeneral::GetRadianAngleBetweenPoints(
+ reason->m_vecMoveSpeed.x, reason->m_vecMoveSpeed.y,
0.0f, 0.0f);
// Let's turn our back to the "reason"
@@ -6111,14 +6138,14 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
angleToFace -= TWOPI;
// We don't want to run towards car's direction
- float dangerZone = angleToFace - vehDirection;
+ float dangerZone = angleToFace - dangerDirection;
dangerZone = CGeneral::LimitRadianAngle(dangerZone);
// So, add or subtract 90deg (jump to left/right) according to that
if (dangerZone > 0.0f)
- angleToFace = vehDirection - HALFPI;
+ angleToFace = dangerDirection - HALFPI;
else
- angleToFace = vehDirection + HALFPI;
+ angleToFace = dangerDirection + HALFPI;
stepAnim = ANIM_STD_NUM;
if (animType == 0 || animType == 1)
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index 6d32b65e..33839aa7 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -625,7 +625,7 @@ public:
void SetAimFlag(CEntity* to);
void SetAimFlag(float angle);
void SetAmmo(eWeaponType weaponType, uint32 ammo);
- void SetEvasiveStep(CEntity*, uint8);
+ void SetEvasiveStep(CPhysical*, uint8);
void GrantAmmo(eWeaponType, uint32);
void SetEvasiveDive(CPhysical*, uint8);
void SetAttack(CEntity*);
diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp
index c03d492a..46ac369c 100644
--- a/src/peds/PedFight.cpp
+++ b/src/peds/PedFight.cpp
@@ -1044,7 +1044,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
if (IsPlayer())
moveAssoc->speed = 1.3f;
- m_takeAStepAfterAttack = 0;
+ m_takeAStepAfterAttack = false;
m_fightButtonPressure = 0;
} else if (IsPlayer() && m_currentWeapon != WEAPONTYPE_UNARMED) {
CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f);
diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp
index de2c23ce..8358a196 100644
--- a/src/peds/PedIK.cpp
+++ b/src/peds/PedIK.cpp
@@ -17,9 +17,9 @@ const RwV3d XaxisIK = { 1.0f, 0.0f, 0.0f};
const RwV3d YaxisIK = { 0.0f, 1.0f, 0.0f};
const RwV3d ZaxisIK = { 0.0f, 0.0f, 1.0f};
-CPedIK::CPedIK(CPed *ped)
+CPedIK::CPedIK(CPed *ped) : m_ped(ped)
{
- m_ped = ped;
+ assert(ped != nil);
m_flags = 0;
m_headOrient.yaw = 0.0f;
m_headOrient.pitch = 0.0f;
diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h
index 4eeef6f0..9077fbea 100644
--- a/src/peds/PedIK.h
+++ b/src/peds/PedIK.h
@@ -34,7 +34,7 @@ public:
AIMS_WITH_ARM = 4,
};
- CPed *m_ped;
+ CPed *Const m_ped;
LimbOrientation m_headOrient;
LimbOrientation m_torsoOrient;
LimbOrientation m_upperArmOrient;
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index a67e2abc..93a403bd 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -682,8 +682,8 @@ CPlayerPed::PlayerControlFighter(CPad *padUsed)
if (padMove > 0.0f) {
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
- m_takeAStepAfterAttack = padMove > 2 * PAD_MOVE_TO_GAME_WORLD_MOVE;
- if (padUsed->GetSprint() && padMove > 1 * PAD_MOVE_TO_GAME_WORLD_MOVE)
+ m_takeAStepAfterAttack = padMove > (2 * PAD_MOVE_TO_GAME_WORLD_MOVE);
+ if (padUsed->GetSprint() && padMove > (1 * PAD_MOVE_TO_GAME_WORLD_MOVE))
bIsAttacking = false;
}
diff --git a/src/save/SaveBuf.h b/src/save/SaveBuf.h
index 1b79c956..98fe888b 100644
--- a/src/save/SaveBuf.h
+++ b/src/save/SaveBuf.h
@@ -47,15 +47,15 @@ WriteSaveBuf(uint8 *&buf, const T &value)
#ifdef VALIDATE_SAVE_SIZE
#define CheckSaveHeader(buf, a, b, c, d, size) do { \
- char _C; uint32 _size;\
- ReadSaveBuf(&_C, buf);\
- assert(_C == a);\
- ReadSaveBuf(&_C, buf);\
- assert(_C == b);\
- ReadSaveBuf(&_C, buf);\
- assert(_C == c);\
- ReadSaveBuf(&_C, buf);\
- assert(_C == d);\
+ char _c; uint32 _size;\
+ ReadSaveBuf(&_c, buf);\
+ assert(_c == a);\
+ ReadSaveBuf(&_c, buf);\
+ assert(_c == b);\
+ ReadSaveBuf(&_c, buf);\
+ assert(_c == c);\
+ ReadSaveBuf(&_c, buf);\
+ assert(_c == d);\
ReadSaveBuf(&_size, buf);\
assert(_size == size);\
} while(0)
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp
index 5704c111..43a85db8 100644
--- a/src/weapons/Weapon.cpp
+++ b/src/weapons/Weapon.cpp
@@ -2266,7 +2266,11 @@ CWeapon::HitsGround(CEntity *holder, CVector *fireSource, CEntity *aimingTo)
void
CWeapon::BlowUpExplosiveThings(CEntity *thing)
{
+#ifdef FIX_BUGS
+ if ( thing && thing->IsObject() )
+#else
if ( thing )
+#endif
{
CObject *object = (CObject*)thing;
int32 mi = object->GetModelIndex();