summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-04-19 15:56:39 +0200
committerGitHub <noreply@github.com>2020-04-19 15:56:39 +0200
commit0f07a323c9a0a97429c551808a38249a6b8ad1ff (patch)
tree563add6e54b45ac77ab863815a8750afed24bb1e /src
parentMerge pull request #475 from erorcun/erorcun (diff)
parentmissing ifded (diff)
downloadre3-0f07a323c9a0a97429c551808a38249a6b8ad1ff.tar
re3-0f07a323c9a0a97429c551808a38249a6b8ad1ff.tar.gz
re3-0f07a323c9a0a97429c551808a38249a6b8ad1ff.tar.bz2
re3-0f07a323c9a0a97429c551808a38249a6b8ad1ff.tar.lz
re3-0f07a323c9a0a97429c551808a38249a6b8ad1ff.tar.xz
re3-0f07a323c9a0a97429c551808a38249a6b8ad1ff.tar.zst
re3-0f07a323c9a0a97429c551808a38249a6b8ad1ff.zip
Diffstat (limited to '')
-rw-r--r--src/control/Phones.cpp7
-rw-r--r--src/control/Replay.cpp33
-rw-r--r--src/control/Replay.h47
-rw-r--r--src/core/Camera.cpp8
-rw-r--r--src/core/PlayerInfo.cpp8
-rw-r--r--src/core/References.cpp9
-rw-r--r--src/core/Streaming.cpp15
-rw-r--r--src/core/User.cpp5
-rw-r--r--src/core/World.cpp15
-rw-r--r--src/peds/PlayerPed.cpp3
-rw-r--r--src/render/Shadows.cpp7
-rw-r--r--src/vehicles/Heli.cpp139
12 files changed, 200 insertions, 96 deletions
diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp
index 7fdc81c5..15e9f9f1 100644
--- a/src/control/Phones.cpp
+++ b/src/control/Phones.cpp
@@ -12,6 +12,9 @@
#include "AudioScriptObject.h"
#include "RpAnimBlend.h"
#include "AnimBlendAssociation.h"
+#ifdef FIX_BUGS
+#include "Replay.h"
+#endif
CPhoneInfo gPhoneInfo;
@@ -45,6 +48,10 @@ isPhoneAvailable(int m_phoneId)
void
CPhoneInfo::Update(void)
{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack())
+ return;
+#endif
CPlayerPed *player = FindPlayerPed();
CPlayerInfo *playerInfo = &CWorld::Players[CWorld::PlayerInFocus];
if (bDisplayingPhoneMessage && CTimer::GetTimeInMilliseconds() > PhoneEnableControlsTimer) {
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index c67e7cbf..466aa25e 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -68,8 +68,8 @@ bool CReplay::bReplayEnabled = true;
uint32 CReplay::SlowMotion;
uint32 CReplay::FramesActiveLookAroundCam;
bool CReplay::bDoLoadSceneWhenDone;
-CPtrList CReplay::WorldPtrList;
-CPtrList CReplay::BigBuildingPtrList;
+CPtrNode* CReplay::WorldPtrList;
+CPtrNode* CReplay::BigBuildingPtrList;
CWanted CReplay::PlayerWanted;
CPlayerInfo CReplay::PlayerInfo;
uint32 CReplay::Time1;
@@ -101,6 +101,9 @@ bool CReplay::bPlayerInRCBuggy;
float CReplay::fDistanceLookAroundCam;
float CReplay::fBetaAngleLookAroundCam;
float CReplay::fAlphaAngleLookAroundCam;
+#ifdef FIX_BUGS
+int CReplay::nHandleOfPlayerPed[NUMPLAYERS];
+#endif
static void(*CBArray[])(CAnimBlendAssociation*, void*) =
{
@@ -275,7 +278,7 @@ void CReplay::RecordThisFrame(void)
continue;
memory_required += sizeof(tBulletTracePacket);
}
- memory_required += sizeof(tEndOfFramePacket);
+ memory_required += sizeof(tEndOfFramePacket) + 1; // 1 for Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
if (Record.m_nOffset + memory_required > REPLAYBUFFERSIZE) {
Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
BufferStatus[Record.m_bSlot] = REPLAYBUFFER_PLAYBACK;
@@ -1108,6 +1111,10 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca
void CReplay::StoreStuffInMem(void)
{
+#ifdef FIX_BUGS
+ for (int i = 0; i < NUMPLAYERS; i++)
+ nHandleOfPlayerPed[i] = CPools::GetPedPool()->GetIndex(CWorld::Players[i].m_pPed);
+#endif
CPools::GetVehiclePool()->Store(pBuf0, pBuf1);
CPools::GetPedPool()->Store(pBuf2, pBuf3);
CPools::GetObjectPool()->Store(pBuf4, pBuf5);
@@ -1116,8 +1123,8 @@ void CReplay::StoreStuffInMem(void)
CPools::GetDummyPool()->Store(pBuf10, pBuf11);
pWorld1 = new uint8[sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y];
memcpy(pWorld1, CWorld::GetSector(0, 0), NUMSECTORS_X * NUMSECTORS_Y * sizeof(CSector));
- WorldPtrList = CWorld::GetMovingEntityList();
- BigBuildingPtrList = CWorld::GetBigBuildingList(LEVEL_NONE);
+ WorldPtrList = CWorld::GetMovingEntityList().first; // why
+ BigBuildingPtrList = CWorld::GetBigBuildingList(LEVEL_NONE).first;
pPickups = new uint8[sizeof(CPickup) * NUMPICKUPS];
memcpy(pPickups, CPickups::aPickUps, NUMPICKUPS * sizeof(CPickup));
pReferences = new uint8[(sizeof(CReference) * NUMREFERENCES)];
@@ -1162,8 +1169,8 @@ void CReplay::RestoreStuffFromMem(void)
memcpy(CWorld::GetSector(0, 0), pWorld1, sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y);
delete[] pWorld1;
pWorld1 = nil;
- CWorld::GetMovingEntityList() = WorldPtrList;
- CWorld::GetBigBuildingList(LEVEL_NONE) = BigBuildingPtrList;
+ CWorld::GetMovingEntityList().first = WorldPtrList;
+ CWorld::GetBigBuildingList(LEVEL_NONE).first = BigBuildingPtrList;
memcpy(CPickups::aPickUps, pPickups, sizeof(CPickup) * NUMPICKUPS);
delete[] pPickups;
pPickups = nil;
@@ -1178,6 +1185,14 @@ void CReplay::RestoreStuffFromMem(void)
memcpy(CRadar::ms_RadarTrace, pRadarBlips, sizeof(sRadarTrace) * NUMRADARBLIPS);
delete[] pRadarBlips;
pRadarBlips = nil;
+#ifdef FIX_BUGS
+ for (int i = 0; i < NUMPLAYERS; i++) {
+ CPlayerPed* pPlayerPed = (CPlayerPed*)CPools::GetPedPool()->GetAt(nHandleOfPlayerPed[i]);
+ assert(pPlayerPed);
+ CWorld::Players[i].m_pPed = pPlayerPed;
+ pPlayerPed->RegisterReference((CEntity**)&CWorld::Players[i].m_pPed);
+ }
+#endif
FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted);
CWorld::Players[0] = PlayerInfo;
int i = CPools::GetPedPool()->GetSize();
@@ -1393,8 +1408,8 @@ void CReplay::SaveReplayToHD(void)
for (first = (current + 1) % NUM_REPLAYBUFFERS; ; first = (first + 1) % NUM_REPLAYBUFFERS)
if (BufferStatus[first] == REPLAYBUFFER_RECORD || BufferStatus[first] == REPLAYBUFFER_PLAYBACK)
break;
- for(int i = first;; i = (i + 1) % NUM_REPLAYBUFFERS){
- CFileMgr::Write(fw, (char*)Buffers[first], sizeof(Buffers[first]));
+ for(int i = first; ; i = (i + 1) % NUM_REPLAYBUFFERS){
+ CFileMgr::Write(fw, (char*)Buffers[i], sizeof(Buffers[i]));
if (BufferStatus[i] == REPLAYBUFFER_RECORD)
break;
}
diff --git a/src/control/Replay.h b/src/control/Replay.h
index 6f6c2a91..bf70a28a 100644
--- a/src/control/Replay.h
+++ b/src/control/Replay.h
@@ -192,7 +192,7 @@ class CReplay
int8 velocityX;
int8 velocityY;
int8 velocityZ;
- union{
+ union {
int8 car_gun;
int8 wheel_state;
};
@@ -208,25 +208,25 @@ private:
static uint8 Mode;
static CAddressInReplayBuffer Record;
static CAddressInReplayBuffer Playback;
- static uint8 *pBuf0;
- static CAutomobile *pBuf1;
- static uint8 *pBuf2;
- static CPlayerPed *pBuf3;
- static uint8 *pBuf4;
- static CCutsceneHead *pBuf5;
- static uint8 *pBuf6;
- static CPtrNode *pBuf7;
- static uint8 *pBuf8;
- static CEntryInfoNode *pBuf9;
- static uint8 *pBuf10;
- static CDummyPed *pBuf11;
- static uint8 *pRadarBlips;
- static uint8 *pStoredCam;
- static uint8 *pWorld1;
- static CReference *pEmptyReferences;
- static CStoredDetailedAnimationState *pPedAnims;
- static uint8 *pPickups;
- static uint8 *pReferences;
+ static uint8* pBuf0;
+ static CAutomobile* pBuf1;
+ static uint8* pBuf2;
+ static CPlayerPed* pBuf3;
+ static uint8* pBuf4;
+ static CCutsceneHead* pBuf5;
+ static uint8* pBuf6;
+ static CPtrNode* pBuf7;
+ static uint8* pBuf8;
+ static CEntryInfoNode* pBuf9;
+ static uint8* pBuf10;
+ static CDummyPed* pBuf11;
+ static uint8* pRadarBlips;
+ static uint8* pStoredCam;
+ static uint8* pWorld1;
+ static CReference* pEmptyReferences;
+ static CStoredDetailedAnimationState* pPedAnims;
+ static uint8* pPickups;
+ static uint8* pReferences;
static uint8 BufferStatus[NUM_REPLAYBUFFERS];
static uint8 Buffers[NUM_REPLAYBUFFERS][REPLAYBUFFERSIZE];
static bool bPlayingBackFromFile;
@@ -234,8 +234,8 @@ private:
static uint32 SlowMotion;
static uint32 FramesActiveLookAroundCam;
static bool bDoLoadSceneWhenDone;
- static CPtrList WorldPtrList;
- static CPtrList BigBuildingPtrList;
+ static CPtrNode* WorldPtrList;
+ static CPtrNode* BigBuildingPtrList;
static CWanted PlayerWanted;
static CPlayerInfo PlayerInfo;
static uint32 Time1;
@@ -267,6 +267,9 @@ private:
static float fDistanceLookAroundCam;
static float fAlphaAngleLookAroundCam;
static float fBetaAngleLookAroundCam;
+#ifdef FIX_BUGS
+ static int nHandleOfPlayerPed[NUMPLAYERS];
+#endif
public:
static void Init(void);
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index f1445d2e..6747ebf5 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -2490,6 +2490,10 @@ CCamera::TryToStartNewCamMode(int obbeMode)
TakeControl(FindPlayerEntity(), CCam::MODE_CAM_ON_A_STRING, JUMP_CUT, CAMCONTROL_OBBE);
return true;
case OBBE_COPCAR:
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack())
+ return false;
+#endif
if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1)
return false;
if(FindPlayerVehicle() == nil)
@@ -2514,6 +2518,10 @@ CCamera::TryToStartNewCamMode(int obbeMode)
}
return false;
case OBBE_COPCAR_WHEEL:
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack())
+ return false;
+#endif
if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1)
return false;
if(FindPlayerVehicle() == nil)
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index 6209e5ab..69b8b7bf 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -41,6 +41,10 @@ CPlayerInfo::SetPlayerSkin(char *skin)
CVector&
CPlayerInfo::GetPos()
{
+#ifdef FIX_BUGS
+ if (!m_pPed)
+ return TheCamera.GetPosition();
+#endif
if (m_pPed->InVehicle())
return m_pPed->m_pMyVehicle->GetPosition();
return m_pPed->GetPosition();
@@ -342,6 +346,10 @@ CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1,
void
CPlayerInfo::Process(void)
{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack())
+ return;
+#endif
// Unused taxi feature. Gives you a dollar for every second with a passenger. Can be toggled via 0x29A opcode.
bool startTaxiTimer = true;
if (m_bUnusedTaxiThing && m_pPed->bInVehicle) {
diff --git a/src/core/References.cpp b/src/core/References.cpp
index 3eb2eaf3..52abbc3e 100644
--- a/src/core/References.cpp
+++ b/src/core/References.cpp
@@ -26,8 +26,17 @@ CReferences::RemoveReferencesToPlayer(void)
{
if(FindPlayerVehicle())
FindPlayerVehicle()->ResolveReferences();
+#ifdef FIX_BUGS
+ if (FindPlayerPed()) {
+ CPlayerPed* pPlayerPed = FindPlayerPed();
+ FindPlayerPed()->ResolveReferences();
+ CWorld::Players[CWorld::PlayerInFocus].m_pPed = pPlayerPed;
+ pPlayerPed->RegisterReference((CEntity**)&CWorld::Players[CWorld::PlayerInFocus].m_pPed);
+ }
+#else
if(FindPlayerPed())
FindPlayerPed()->ResolveReferences();
+#endif
}
void
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index 039377f4..dae83d89 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -28,6 +28,9 @@
#include "CutsceneMgr.h"
#include "CdStream.h"
#include "Streaming.h"
+#ifdef FIX_BUGS
+#include "Replay.h"
+#endif
#include "main.h"
bool CStreaming::ms_disableStreaming;
@@ -280,7 +283,11 @@ CStreaming::Update(void)
!requestedSubway &&
!CGame::playingIntro &&
ms_numModelsRequested < 5 &&
- !CRenderer::m_loadingPriority){
+ !CRenderer::m_loadingPriority
+#ifdef FIX_BUGS
+ && !CReplay::IsPlayingBack()
+#endif
+ ){
StreamVehiclesAndPeds();
StreamZoneModels(FindPlayerCoors());
}
@@ -1248,7 +1255,11 @@ CStreaming::StreamVehiclesAndPeds(void)
static int modelQualityClass = 0;
if(CRecordDataForGame::IsRecording() ||
- CRecordDataForGame::IsPlayingBack())
+ CRecordDataForGame::IsPlayingBack()
+#ifdef FIX_BUGS
+ || CReplay::IsPlayingBack()
+#endif
+ )
return;
if(FindPlayerPed()->m_pWanted->AreSwatRequired()){
diff --git a/src/core/User.cpp b/src/core/User.cpp
index 36f07cbd..50eb7d9d 100644
--- a/src/core/User.cpp
+++ b/src/core/User.cpp
@@ -3,6 +3,7 @@
#include "Hud.h"
#include "PlayerPed.h"
+#include "Replay.h"
#include "Text.h"
#include "User.h"
#include "Vehicle.h"
@@ -115,6 +116,10 @@ CUserDisplay::Init()
void
CUserDisplay::Process()
{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack())
+ return;
+#endif
PlaceName.Process();
OnscnTimer.Process();
Pager.Process();
diff --git a/src/core/World.cpp b/src/core/World.cpp
index eacb3404..7ef43593 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -1386,6 +1386,10 @@ FindPlayerEntity(void)
CVector
FindPlayerCoors(void)
{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack())
+ return TheCamera.GetPosition();
+#endif
CPlayerPed *ped = FindPlayerPed();
if(ped->InVehicle())
return ped->m_pMyVehicle->GetPosition();
@@ -1396,6 +1400,11 @@ FindPlayerCoors(void)
CVector &
FindPlayerSpeed(void)
{
+#ifdef FIX_BUGS
+ static CVector vecTmpVector(0.0f, 0.0f, 0.0f);
+ if (CReplay::IsPlayingBack())
+ return vecTmpVector;
+#endif
CPlayerPed *ped = FindPlayerPed();
if(ped->InVehicle())
return ped->m_pMyVehicle->m_vecMoveSpeed;
@@ -1406,6 +1415,9 @@ FindPlayerSpeed(void)
CVector &
FindPlayerCentreOfWorld(int32 player)
{
+#ifdef FIX_BUGS
+ if(CReplay::IsPlayingBack()) return TheCamera.GetPosition();
+#endif
if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
if(CWorld::Players[player].m_pRemoteVehicle) return CWorld::Players[player].m_pRemoteVehicle->GetPosition();
if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition();
@@ -1415,6 +1427,9 @@ FindPlayerCentreOfWorld(int32 player)
CVector &
FindPlayerCentreOfWorld_NoSniperShift(void)
{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack()) return TheCamera.GetPosition();
+#endif
if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle)
return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetPosition();
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index 0a0fe6a3..962c83df 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -135,6 +135,9 @@ CPlayerPed::SetupPlayerPed(int32 index)
{
CPlayerPed *player = new CPlayerPed();
CWorld::Players[index].m_pPed = player;
+#ifdef FIX_BUGS
+ player->RegisterReference((CEntity**)&CWorld::Players[index].m_pPed);
+#endif
player->SetOrientation(0.0f, 0.0f, 0.0f);
diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp
index 8685b93a..330f1b06 100644
--- a/src/render/Shadows.cpp
+++ b/src/render/Shadows.cpp
@@ -13,6 +13,9 @@
#include "Weather.h"
#include "ModelIndices.h"
#include "RenderBuffer.h"
+#ifdef FIX_BUGS
+#include "Replay.h"
+#endif
#include "PointLights.h"
#include "SpecialFX.h"
#include "Shadows.h"
@@ -1609,6 +1612,10 @@ CShadows::CalcPedShadowValues(CVector vecLightDir,
void
CShadows::RenderExtraPlayerShadows(void)
{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack())
+ return;
+#endif
if ( CTimeCycle::GetLightShadowStrength() != 0 )
{
CVehicle *pCar = FindPlayerVehicle();
diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp
index 1f92b678..6a83a30e 100644
--- a/src/vehicles/Heli.cpp
+++ b/src/vehicles/Heli.cpp
@@ -24,6 +24,9 @@
#include "Object.h"
#include "HandlingMgr.h"
#include "Heli.h"
+#ifdef FIX_BUGS
+#include "Replay.h"
+#endif
enum
{
@@ -428,89 +431,95 @@ CHeli::ProcessControl(void)
// Search light and shooting
if(m_heliStatus == HELI_STATUS_FLY_AWAY || m_heliType == HELI_TYPE_CATALINA || CCullZones::PlayerNoRain())
m_fSearchLightIntensity = 0.0f;
- else{
+ else {
// Update search light history once every 1000ms
int timeDiff = CTimer::GetTimeInMilliseconds() - m_nSearchLightTimer;
- while(timeDiff > 1000){
- for(i = 5; i > 0; i--){
- m_aSearchLightHistoryX[i] = m_aSearchLightHistoryX[i-1];
- m_aSearchLightHistoryY[i] = m_aSearchLightHistoryY[i-1];
+ while (timeDiff > 1000) {
+ for (i = 5; i > 0; i--) {
+ m_aSearchLightHistoryX[i] = m_aSearchLightHistoryX[i - 1];
+ m_aSearchLightHistoryY[i] = m_aSearchLightHistoryY[i - 1];
}
- m_aSearchLightHistoryX[0] = FindPlayerCoors().x + FindPlayerSpeed().x*50.0f*(m_nHeliId+2);
- m_aSearchLightHistoryY[0] = FindPlayerCoors().y + FindPlayerSpeed().y*50.0f*(m_nHeliId+2);
+ m_aSearchLightHistoryX[0] = FindPlayerCoors().x + FindPlayerSpeed().x * 50.0f * (m_nHeliId + 2);
+ m_aSearchLightHistoryY[0] = FindPlayerCoors().y + FindPlayerSpeed().y * 50.0f * (m_nHeliId + 2);
timeDiff -= 1000;
m_nSearchLightTimer += 1000;
}
assert(timeDiff <= 1000);
- float f1 = timeDiff/1000.0f;
+ float f1 = timeDiff / 1000.0f;
float f2 = 1.0f - f1;
- m_fSearchLightX = m_aSearchLightHistoryX[m_nHeliId+2]*f2 + m_aSearchLightHistoryX[m_nHeliId+2-1]*f1;
- m_fSearchLightY = m_aSearchLightHistoryY[m_nHeliId+2]*f2 + m_aSearchLightHistoryY[m_nHeliId+2-1]*f1;
+ m_fSearchLightX = m_aSearchLightHistoryX[m_nHeliId + 2] * f2 + m_aSearchLightHistoryX[m_nHeliId + 2 - 1] * f1;
+ m_fSearchLightY = m_aSearchLightHistoryY[m_nHeliId + 2] * f2 + m_aSearchLightHistoryY[m_nHeliId + 2 - 1] * f1;
float searchLightDist = (CVector2D(m_fSearchLightX, m_fSearchLightY) - GetPosition()).Magnitude();
- if(searchLightDist > 60.0f)
+ if (searchLightDist > 60.0f)
m_fSearchLightIntensity = 0.0f;
- else if(searchLightDist < 40.0f)
+ else if (searchLightDist < 40.0f)
m_fSearchLightIntensity = 1.0f;
else
- m_fSearchLightIntensity = 1.0f - (40.0f-searchLightDist)/40.0f;
+ m_fSearchLightIntensity = 1.0f - (40.0f - searchLightDist) / 40.0f;
- if(m_fSearchLightIntensity < 0.9f || sq(FindPlayerCoors().x-m_fSearchLightX) + sq(FindPlayerCoors().y-m_fSearchLightY) > sq(7.0f))
+ if (m_fSearchLightIntensity < 0.9f || sq(FindPlayerCoors().x - m_fSearchLightX) + sq(FindPlayerCoors().y - m_fSearchLightY) > sq(7.0f))
m_nShootTimer = CTimer::GetTimeInMilliseconds();
- else if(CTimer::GetTimeInMilliseconds() > m_nPoliceShoutTimer){
+ else if (CTimer::GetTimeInMilliseconds() > m_nPoliceShoutTimer) {
DMAudio.PlayOneShot(m_audioEntityId, SOUND_PED_HELI_PLAYER_FOUND, 0.0f);
- m_nPoliceShoutTimer = CTimer::GetTimeInMilliseconds() + 4500 + (CGeneral::GetRandomNumber()&0xFFF);
+ m_nPoliceShoutTimer = CTimer::GetTimeInMilliseconds() + 4500 + (CGeneral::GetRandomNumber() & 0xFFF);
}
-
- // Shoot
- int shootTimeout;
- if(m_heliType == HELI_TYPE_RANDOM){
- switch(FindPlayerPed()->m_pWanted->m_nWantedLevel){
- case 0:
- case 1:
- case 2: shootTimeout = 999999; break;
- case 3: shootTimeout = 10000; break;
- case 4: shootTimeout = 5000; break;
- case 5: shootTimeout = 3500; break;
- case 6: shootTimeout = 2000; break;
- }
- if(CCullZones::NoPolice())
- shootTimeout /= 2;
- }else
- shootTimeout = 1500;
-
- if(FindPlayerPed()->m_pWanted->IsIgnored())
- m_nShootTimer = CTimer::GetTimeInMilliseconds();
- else{
- // Check if line of sight is clear
- if(CTimer::GetTimeInMilliseconds() > m_nShootTimer + shootTimeout &&
- CTimer::GetPreviousTimeInMilliseconds() <= m_nShootTimer + shootTimeout){
- if(CWorld::GetIsLineOfSightClear(GetPosition(), FindPlayerCoors(), true, false, false, false, false, false)){
- if(m_heliStatus == HELI_STATUS_HOVER2)
- m_heliStatus = HELI_STATUS_HOVER;
- }else{
- m_nShootTimer = CTimer::GetTimeInMilliseconds();
- if(m_heliStatus == HELI_STATUS_HOVER)
- m_heliStatus = HELI_STATUS_HOVER2;
+#ifdef FIX_BUGS
+ if (!CReplay::IsPlayingBack())
+#endif
+ {
+ // Shoot
+ int shootTimeout;
+ if (m_heliType == HELI_TYPE_RANDOM) {
+ switch (FindPlayerPed()->m_pWanted->m_nWantedLevel) {
+ case 0:
+ case 1:
+ case 2: shootTimeout = 999999; break;
+ case 3: shootTimeout = 10000; break;
+ case 4: shootTimeout = 5000; break;
+ case 5: shootTimeout = 3500; break;
+ case 6: shootTimeout = 2000; break;
}
+ if (CCullZones::NoPolice())
+ shootTimeout /= 2;
}
+ else
+ shootTimeout = 1500;
+
+ if (FindPlayerPed()->m_pWanted->IsIgnored())
+ m_nShootTimer = CTimer::GetTimeInMilliseconds();
+ else {
+ // Check if line of sight is clear
+ if (CTimer::GetTimeInMilliseconds() > m_nShootTimer + shootTimeout &&
+ CTimer::GetPreviousTimeInMilliseconds() <= m_nShootTimer + shootTimeout) {
+ if (CWorld::GetIsLineOfSightClear(GetPosition(), FindPlayerCoors(), true, false, false, false, false, false)) {
+ if (m_heliStatus == HELI_STATUS_HOVER2)
+ m_heliStatus = HELI_STATUS_HOVER;
+ }
+ else {
+ m_nShootTimer = CTimer::GetTimeInMilliseconds();
+ if (m_heliStatus == HELI_STATUS_HOVER)
+ m_heliStatus = HELI_STATUS_HOVER2;
+ }
+ }
- // Shoot!
- if(CTimer::GetTimeInMilliseconds() > m_nShootTimer + shootTimeout &&
- CTimer::GetTimeInMilliseconds() > m_nLastShotTime + 200){
- CVector shotTarget = FindPlayerCoors();
- // some inaccuracy
- shotTarget.x += ((CGeneral::GetRandomNumber()&0xFF)-128)/50.0f;
- shotTarget.y += ((CGeneral::GetRandomNumber()&0xFF)-128)/50.0f;
- CVector direction = FindPlayerCoors() - GetPosition();
- direction.Normalise();
- shotTarget += 3.0f*direction;
- CVector shotSource = GetPosition();
- shotSource += 3.0f*direction;
- FireOneInstantHitRound(&shotSource, &shotTarget, 20);
- DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f);
- m_nLastShotTime = CTimer::GetTimeInMilliseconds();
+ // Shoot!
+ if (CTimer::GetTimeInMilliseconds() > m_nShootTimer + shootTimeout &&
+ CTimer::GetTimeInMilliseconds() > m_nLastShotTime + 200) {
+ CVector shotTarget = FindPlayerCoors();
+ // some inaccuracy
+ shotTarget.x += ((CGeneral::GetRandomNumber() & 0xFF) - 128) / 50.0f;
+ shotTarget.y += ((CGeneral::GetRandomNumber() & 0xFF) - 128) / 50.0f;
+ CVector direction = FindPlayerCoors() - GetPosition();
+ direction.Normalise();
+ shotTarget += 3.0f * direction;
+ CVector shotSource = GetPosition();
+ shotSource += 3.0f * direction;
+ FireOneInstantHitRound(&shotSource, &shotTarget, 20);
+ DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f);
+ m_nLastShotTime = CTimer::GetTimeInMilliseconds();
+ }
}
}
}
@@ -825,7 +834,11 @@ CHeli::UpdateHelis(void)
int i, j;
// Spawn new police helis
- int numHelisRequired = FindPlayerPed()->m_pWanted->NumOfHelisRequired();
+ int numHelisRequired =
+#ifdef FIX_BUGS
+ CReplay::IsPlayingBack() ? 0 :
+#endif
+ FindPlayerPed()->m_pWanted->NumOfHelisRequired();
if(CStreaming::HasModelLoaded(MI_CHOPPER) && CTimer::GetTimeInMilliseconds() > TestForNewRandomHelisTimer){
// Spawn a police heli
TestForNewRandomHelisTimer = CTimer::GetTimeInMilliseconds() + 15000;