summaryrefslogtreecommitdiffstats
path: root/src/control
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/control
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 'src/control')
-rw-r--r--src/control/Phones.cpp7
-rw-r--r--src/control/Replay.cpp33
-rw-r--r--src/control/Replay.h47
3 files changed, 56 insertions, 31 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);