summaryrefslogtreecommitdiffstats
path: root/src/control/Replay.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/control/Replay.cpp116
1 files changed, 82 insertions, 34 deletions
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index f21703ac..d8b15385 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-
+#ifdef GTA_REPLAY
#include "AnimBlendAssociation.h"
#include "Boat.h"
#include "SpecialFX.h"
@@ -10,6 +10,10 @@
#include "DMAudio.h"
#include "Draw.h"
#include "FileMgr.h"
+#ifdef FIX_BUGS
+#include "Fire.h"
+#include "Garages.h"
+#endif
#include "Heli.h"
#include "main.h"
#include "Matrix.h"
@@ -22,6 +26,10 @@
#include "Plane.h"
#include "Pools.h"
#include "Population.h"
+#ifdef FIX_BUGS
+#include "Projectile.h"
+#include "ProjectileInfo.h"
+#endif
#include "Replay.h"
#include "References.h"
#include "Pools.h"
@@ -102,6 +110,11 @@ float CReplay::fDistanceLookAroundCam;
float CReplay::fBetaAngleLookAroundCam;
float CReplay::fAlphaAngleLookAroundCam;
#ifdef FIX_BUGS
+uint8* CReplay::pGarages;
+CFire* CReplay::FireArray;
+uint32 CReplay::NumOfFires;
+uint8* CReplay::paProjectileInfo;
+uint8* CReplay::paProjectiles;
int CReplay::nHandleOfPlayerPed[NUMPLAYERS];
#endif
@@ -292,7 +305,7 @@ void CReplay::RecordThisFrame(void)
#endif
tGeneralPacket* general = (tGeneralPacket*)&Record.m_pBase[Record.m_nOffset];
general->type = REPLAYPACKET_GENERAL;
- general->camera_pos.CopyOnlyMatrix(&TheCamera.GetMatrix());
+ general->camera_pos.CopyOnlyMatrix(TheCamera.GetMatrix());
general->player_pos = FindPlayerCoors();
general->in_rcvehicle = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle ? true : false;
Record.m_nOffset += sizeof(*general);
@@ -444,7 +457,7 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
state->aFunctionCallbackID[i] = 0;
}
}else{
- state->aAnimId[i] = NUM_ANIMS;
+ state->aAnimId[i] = ANIM_STD_NUM;
state->aCurTime[i] = 0;
state->aSpeed[i] = 85;
state->aFunctionCallbackID[i] = 0;
@@ -471,7 +484,7 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
}
}
else {
- state->aAnimId2[i] = NUM_ANIMS;
+ state->aAnimId2[i] = ANIM_STD_NUM;
state->aCurTime2[i] = 0;
state->aSpeed2[i] = 85;
state->aFunctionCallbackID2[i] = 0;
@@ -545,7 +558,7 @@ void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state)
float time = state->partAnimTime * 4.0f / 255.0f;
float speed = state->partAnimSpeed * 3.0f / 255.0f;
float blend = state->partBlendAmount * 2.0f / 255.0f;
- if (blend > 0.0f && state->partAnimId != ANIM_IDLE_STANCE){
+ if (blend > 0.0f && state->partAnimId != ANIM_STD_IDLE){
CAnimBlendAssociation* anim3 = CAnimManager::BlendAnimation(
(RpClump*)ped->m_rwObject, ASSOCGRP_STD, (AnimationId)state->partAnimId, 1000.0f);
anim3->SetCurrentTime(time);
@@ -565,7 +578,7 @@ void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationSt
assoc->SetBlend(0.0f, -1.0f);
#endif
for (int i = 0; i < NUM_MAIN_ANIMS_IN_REPLAY; i++) {
- if (state->aAnimId[i] == NUM_ANIMS)
+ if (state->aAnimId[i] == ANIM_STD_NUM)
continue;
#ifdef FIX_REPLAY_BUGS
CAnimBlendAssociation* anim = CAnimManager::AddAnimation(ped->GetClump(),
@@ -594,7 +607,7 @@ void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationSt
anim->SetDeleteCallback(FindCBFunction(callback & 0x7F), ped);
}
for (int i = 0; i < NUM_PARTIAL_ANIMS_IN_REPLAY; i++) {
- if (state->aAnimId2[i] == NUM_ANIMS)
+ if (state->aAnimId2[i] == ANIM_STD_NUM)
continue;
#ifdef FIX_REPLAY_BUGS
CAnimBlendAssociation* anim = CAnimManager::AddAnimation(ped->GetClump(),
@@ -1025,10 +1038,10 @@ void CReplay::ProcessReplayCamera(void)
TheCamera.GetUp() = CVector(0.0f, 1.0f, 0.0f);
TheCamera.GetRight() = CVector(1.0f, 0.0f, 0.0f);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)&TheCamera.GetPosition();
- pm->at = *(RwV3d*)&TheCamera.GetForward();
- pm->up = *(RwV3d*)&TheCamera.GetUp();
- pm->right = *(RwV3d*)&TheCamera.GetRight();
+ pm->pos = TheCamera.GetPosition();
+ pm->at = TheCamera.GetForward();
+ pm->up = TheCamera.GetUp();
+ pm->right = TheCamera.GetRight();
break;
}
case REPLAYCAMMODE_FIXED:
@@ -1044,10 +1057,10 @@ void CReplay::ProcessReplayCamera(void)
TheCamera.GetMatrix().GetUp() = up;
TheCamera.GetMatrix().GetRight() = right;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)&TheCamera.GetMatrix().GetPosition();
- pm->at = *(RwV3d*)&TheCamera.GetMatrix().GetForward();
- pm->up = *(RwV3d*)&TheCamera.GetMatrix().GetUp();
- pm->right = *(RwV3d*)&TheCamera.GetMatrix().GetRight();
+ pm->pos = TheCamera.GetMatrix().GetPosition();
+ pm->at = TheCamera.GetMatrix().GetForward();
+ pm->up = TheCamera.GetMatrix().GetUp();
+ pm->right = TheCamera.GetMatrix().GetRight();
break;
}
default:
@@ -1156,6 +1169,17 @@ void CReplay::StoreStuffInMem(void)
if (ped)
StoreDetailedPedAnimation(ped, &pPedAnims[i]);
}
+#ifdef FIX_BUGS
+ pGarages = new uint8[sizeof(CGarages::aGarages)];
+ memcpy(pGarages, CGarages::aGarages, sizeof(CGarages::aGarages));
+ FireArray = new CFire[NUM_FIRES];
+ memcpy(FireArray, gFireManager.m_aFires, sizeof(gFireManager.m_aFires));
+ NumOfFires = gFireManager.m_nTotalFires;
+ paProjectileInfo = new uint8[sizeof(gaProjectileInfo)];
+ memcpy(paProjectileInfo, gaProjectileInfo, sizeof(gaProjectileInfo));
+ paProjectiles = new uint8[sizeof(CProjectileInfo::ms_apProjectile)];
+ memcpy(paProjectiles, CProjectileInfo::ms_apProjectile, sizeof(CProjectileInfo::ms_apProjectile));
+#endif
}
void CReplay::RestoreStuffFromMem(void)
@@ -1206,7 +1230,7 @@ void CReplay::RestoreStuffFromMem(void)
ped->m_rwObject = nil;
ped->m_modelIndex = -1;
ped->SetModelIndex(mi);
- ped->m_pVehicleAnim = 0;
+ ped->m_pVehicleAnim = nil;
ped->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, ped);
DMAudio.SetEntityStatus(ped->m_audioEntityId, true);
CPopulation::UpdatePedCount((ePedType)ped->m_nPedType, false);
@@ -1322,6 +1346,22 @@ void CReplay::RestoreStuffFromMem(void)
}
delete[] pPedAnims;
pPedAnims = nil;
+#ifdef FIX_BUGS
+ memcpy(CGarages::aGarages, pGarages, sizeof(CGarages::aGarages));
+ delete[] pGarages;
+ pGarages = nil;
+ memcpy(gFireManager.m_aFires, FireArray, sizeof(gFireManager.m_aFires));
+ delete[] FireArray;
+ FireArray = nil;
+ gFireManager.m_nTotalFires = NumOfFires;
+ memcpy(gaProjectileInfo, paProjectileInfo, sizeof(gaProjectileInfo));
+ delete[] paProjectileInfo;
+ paProjectileInfo = nil;
+ memcpy(CProjectileInfo::ms_apProjectile, paProjectiles, sizeof(CProjectileInfo::ms_apProjectile));
+ delete[] paProjectiles;
+ paProjectiles = nil;
+ //CExplosion::ClearAllExplosions(); not in III
+#endif
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
DMAudio.SetRadioInCar(OldRadioStation);
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
@@ -1417,7 +1457,7 @@ void CReplay::SaveReplayToHD(void)
CFileMgr::SetDir("");
}
-void PlayReplayFromHD(void)
+void CReplay::PlayReplayFromHD(void)
{
CFileMgr::SetDirMyDocuments();
int fr = CFileMgr::OpenFile("replay.rep", "rb");
@@ -1436,17 +1476,17 @@ void PlayReplayFromHD(void)
return;
}
int slot;
- for (slot = 0; CFileMgr::Read(fr, (char*)CReplay::Buffers[slot], sizeof(CReplay::Buffers[slot])); slot++)
- CReplay::BufferStatus[slot] = CReplay::REPLAYBUFFER_PLAYBACK;
- CReplay::BufferStatus[slot - 1] = CReplay::REPLAYBUFFER_RECORD;
- while (slot < CReplay::NUM_REPLAYBUFFERS)
- CReplay::BufferStatus[slot++] = CReplay::REPLAYBUFFER_UNUSED;
+ for (slot = 0; CFileMgr::Read(fr, (char*)Buffers[slot], sizeof(Buffers[slot])); slot++)
+ BufferStatus[slot] = REPLAYBUFFER_PLAYBACK;
+ BufferStatus[slot - 1] = REPLAYBUFFER_RECORD;
+ while (slot < NUM_REPLAYBUFFERS)
+ BufferStatus[slot++] = REPLAYBUFFER_UNUSED;
CFileMgr::CloseFile(fr);
CFileMgr::SetDir("");
- CReplay::TriggerPlayback(CReplay::REPLAYCAMMODE_ASSTORED, 0.0f, 0.0f, 0.0f, false);
- CReplay::bPlayingBackFromFile = true;
- CReplay::bAllowLookAroundCam = true;
- CReplay::StreamAllNecessaryCarsAndPeds();
+ TriggerPlayback(REPLAYCAMMODE_ASSTORED, 0.0f, 0.0f, 0.0f, false);
+ bPlayingBackFromFile = true;
+ bAllowLookAroundCam = true;
+ StreamAllNecessaryCarsAndPeds();
}
void CReplay::StreamAllNecessaryCarsAndPeds(void)
@@ -1541,10 +1581,10 @@ void CReplay::ProcessLookAroundCam(void)
TheCamera.GetRight() = right;
TheCamera.SetPosition(camera_pt);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)&TheCamera.GetPosition();
- pm->at = *(RwV3d*)&TheCamera.GetForward();
- pm->up = *(RwV3d*)&TheCamera.GetUp();
- pm->right = *(RwV3d*)&TheCamera.GetRight();
+ pm->pos = TheCamera.GetPosition();
+ pm->at = TheCamera.GetForward();
+ pm->up = TheCamera.GetUp();
+ pm->right = TheCamera.GetRight();
TheCamera.CalculateDerivedValues();
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
@@ -1576,12 +1616,20 @@ void CReplay::Display()
TimeCount = (TimeCount + 1) % UINT16_MAX;
if ((TimeCount & 0x20) == 0)
return;
- CFont::SetPropOn();
- CFont::SetBackgroundOff();
+
CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f));
- CFont::SetAlignment(ALIGN_LEFT);
+ CFont::SetJustifyOff();
+ CFont::SetBackgroundOff();
+#ifdef FIX_BUGS
+ CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-20));
+#else
+ CFont::SetCentreSize(SCREEN_WIDTH-20);
+#endif
+ CFont::SetCentreOff();
+ CFont::SetPropOn();
CFont::SetColor(CRGBA(255, 255, 200, 200));
CFont::SetFontStyle(FONT_BANK);
if (Mode == MODE_PLAYBACK)
- CFont::PrintString(SCREEN_SCALE_X(63.5f), SCREEN_SCALE_Y(30.0f), TheText.Get("REPLAY"));
+ CFont::PrintString(SCREEN_WIDTH/15, SCREEN_HEIGHT/10, TheText.Get("REPLAY"));
}
+#endif