2019-05-30 19:24:47 +00:00
|
|
|
#include "common.h"
|
2020-12-01 20:08:05 +00:00
|
|
|
#ifdef GTA_REPLAY
|
2020-09-26 18:10:23 +00:00
|
|
|
#include "AnimBlendAssocGroup.h"
|
2019-06-23 10:58:14 +00:00
|
|
|
#include "AnimBlendAssociation.h"
|
2020-09-26 18:10:23 +00:00
|
|
|
#include "Bike.h"
|
2019-06-29 20:15:55 +00:00
|
|
|
#include "Boat.h"
|
2019-06-30 20:55:48 +00:00
|
|
|
#include "SpecialFX.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
#include "CarCtrl.h"
|
2019-06-30 10:59:55 +00:00
|
|
|
#include "CivilianPed.h"
|
2020-09-26 18:10:23 +00:00
|
|
|
#include "CopPed.h"
|
2020-03-28 14:47:52 +00:00
|
|
|
#include "Wanted.h"
|
2019-06-22 18:16:29 +00:00
|
|
|
#include "Clock.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
#include "DMAudio.h"
|
2019-06-22 18:16:29 +00:00
|
|
|
#include "Draw.h"
|
2020-09-26 18:10:23 +00:00
|
|
|
#include "Explosion.h"
|
2019-06-30 20:29:53 +00:00
|
|
|
#include "FileMgr.h"
|
2020-09-26 18:10:23 +00:00
|
|
|
#include "Fire.h"
|
|
|
|
#include "Frontend.h"
|
|
|
|
#include "Garages.h"
|
2019-06-30 10:59:55 +00:00
|
|
|
#include "Heli.h"
|
2019-06-30 20:29:53 +00:00
|
|
|
#include "main.h"
|
2019-07-08 19:44:32 +00:00
|
|
|
#include "Matrix.h"
|
2019-06-22 18:16:29 +00:00
|
|
|
#include "ModelIndices.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
#include "ModelInfo.h"
|
|
|
|
#include "Object.h"
|
2019-06-22 18:16:29 +00:00
|
|
|
#include "Pad.h"
|
2020-09-26 18:10:23 +00:00
|
|
|
#include "Particle.h"
|
2020-05-16 10:31:23 +00:00
|
|
|
#include "PedAttractor.h"
|
2019-07-07 11:09:11 +00:00
|
|
|
#include "Phones.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
#include "Pickups.h"
|
2019-06-30 10:59:55 +00:00
|
|
|
#include "Plane.h"
|
2019-06-22 18:16:29 +00:00
|
|
|
#include "Pools.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
#include "Population.h"
|
2020-09-26 18:10:23 +00:00
|
|
|
#include "Projectile.h"
|
|
|
|
#include "ProjectileInfo.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
#include "Replay.h"
|
2020-03-28 14:47:52 +00:00
|
|
|
#include "References.h"
|
|
|
|
#include "Pools.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
#include "RpAnimBlend.h"
|
|
|
|
#include "RwHelper.h"
|
2019-06-22 18:16:29 +00:00
|
|
|
#include "CutsceneMgr.h"
|
2019-07-08 19:44:32 +00:00
|
|
|
#include "Skidmarks.h"
|
2020-09-26 18:10:23 +00:00
|
|
|
#include "Stinger.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
#include "Streaming.h"
|
2019-06-22 18:16:29 +00:00
|
|
|
#include "Timer.h"
|
2019-06-30 10:59:55 +00:00
|
|
|
#include "Train.h"
|
2019-06-22 18:16:29 +00:00
|
|
|
#include "Weather.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
#include "Zones.h"
|
2019-06-25 00:34:29 +00:00
|
|
|
#include "Font.h"
|
|
|
|
#include "Text.h"
|
2020-03-28 14:47:52 +00:00
|
|
|
#include "Camera.h"
|
|
|
|
#include "Radar.h"
|
2020-08-19 18:11:19 +00:00
|
|
|
#include "Fluff.h"
|
2020-10-09 12:53:22 +00:00
|
|
|
#include "WaterCreatures.h"
|
2019-05-30 19:24:47 +00:00
|
|
|
|
2020-11-01 15:21:05 +00:00
|
|
|
//--MIAMI: file done
|
2020-10-11 09:56:33 +00:00
|
|
|
|
2020-04-17 05:54:14 +00:00
|
|
|
uint8 CReplay::Mode;
|
|
|
|
CAddressInReplayBuffer CReplay::Record;
|
|
|
|
CAddressInReplayBuffer CReplay::Playback;
|
|
|
|
uint8 *CReplay::pBuf0;
|
|
|
|
CAutomobile *CReplay::pBuf1;
|
|
|
|
uint8 *CReplay::pBuf2;
|
|
|
|
CPlayerPed *CReplay::pBuf3;
|
|
|
|
uint8 *CReplay::pBuf4;
|
2020-05-09 11:00:39 +00:00
|
|
|
CCutsceneObject *CReplay::pBuf5;
|
2020-04-17 05:54:14 +00:00
|
|
|
uint8 *CReplay::pBuf6;
|
|
|
|
CPtrNode *CReplay::pBuf7;
|
|
|
|
uint8 *CReplay::pBuf8;
|
|
|
|
CEntryInfoNode *CReplay::pBuf9;
|
|
|
|
uint8 *CReplay::pBuf10;
|
|
|
|
CDummyPed *CReplay::pBuf11;
|
|
|
|
uint8 *CReplay::pRadarBlips;
|
|
|
|
uint8 *CReplay::pStoredCam;
|
|
|
|
uint8 *CReplay::pWorld1;
|
|
|
|
CReference *CReplay::pEmptyReferences;
|
|
|
|
CStoredDetailedAnimationState *CReplay::pPedAnims;
|
|
|
|
uint8 *CReplay::pPickups;
|
|
|
|
uint8 *CReplay::pReferences;
|
|
|
|
uint8 CReplay::BufferStatus[NUM_REPLAYBUFFERS];
|
|
|
|
uint8 CReplay::Buffers[NUM_REPLAYBUFFERS][REPLAYBUFFERSIZE];
|
|
|
|
bool CReplay::bPlayingBackFromFile;
|
|
|
|
bool CReplay::bReplayEnabled = true;
|
|
|
|
uint32 CReplay::SlowMotion;
|
|
|
|
uint32 CReplay::FramesActiveLookAroundCam;
|
|
|
|
bool CReplay::bDoLoadSceneWhenDone;
|
2020-04-18 20:50:37 +00:00
|
|
|
CPtrNode* CReplay::WorldPtrList;
|
|
|
|
CPtrNode* CReplay::BigBuildingPtrList;
|
2020-04-17 05:54:14 +00:00
|
|
|
CWanted CReplay::PlayerWanted;
|
|
|
|
CPlayerInfo CReplay::PlayerInfo;
|
|
|
|
uint32 CReplay::Time1;
|
|
|
|
uint32 CReplay::Time2;
|
|
|
|
uint32 CReplay::Time3;
|
|
|
|
uint32 CReplay::Time4;
|
|
|
|
uint32 CReplay::Frame;
|
|
|
|
uint8 CReplay::ClockHours;
|
|
|
|
uint8 CReplay::ClockMinutes;
|
|
|
|
uint16 CReplay::OldWeatherType;
|
|
|
|
uint16 CReplay::NewWeatherType;
|
|
|
|
float CReplay::WeatherInterpolationValue;
|
|
|
|
float CReplay::TimeStepNonClipped;
|
|
|
|
float CReplay::TimeStep;
|
|
|
|
float CReplay::TimeScale;
|
|
|
|
float CReplay::CameraFixedX;
|
|
|
|
float CReplay::CameraFixedY;
|
|
|
|
float CReplay::CameraFixedZ;
|
|
|
|
int32 CReplay::OldRadioStation;
|
|
|
|
int8 CReplay::CameraMode;
|
|
|
|
bool CReplay::bAllowLookAroundCam;
|
|
|
|
float CReplay::LoadSceneX;
|
|
|
|
float CReplay::LoadSceneY;
|
|
|
|
float CReplay::LoadSceneZ;
|
|
|
|
float CReplay::CameraFocusX;
|
|
|
|
float CReplay::CameraFocusY;
|
|
|
|
float CReplay::CameraFocusZ;
|
|
|
|
bool CReplay::bPlayerInRCBuggy;
|
|
|
|
float CReplay::fDistanceLookAroundCam;
|
|
|
|
float CReplay::fBetaAngleLookAroundCam;
|
|
|
|
float CReplay::fAlphaAngleLookAroundCam;
|
2020-09-26 18:10:23 +00:00
|
|
|
int CReplay::ms_nNumCivMale_Stored;
|
|
|
|
int CReplay::ms_nNumCivFemale_Stored;
|
|
|
|
int CReplay::ms_nNumCop_Stored;
|
|
|
|
int CReplay::ms_nNumEmergency_Stored;
|
|
|
|
int CReplay::ms_nNumGang1_Stored;
|
|
|
|
int CReplay::ms_nNumGang2_Stored;
|
|
|
|
int CReplay::ms_nNumGang3_Stored;
|
|
|
|
int CReplay::ms_nNumGang4_Stored;
|
|
|
|
int CReplay::ms_nNumGang5_Stored;
|
|
|
|
int CReplay::ms_nNumGang6_Stored;
|
|
|
|
int CReplay::ms_nNumGang7_Stored;
|
|
|
|
int CReplay::ms_nNumGang8_Stored;
|
|
|
|
int CReplay::ms_nNumGang9_Stored;
|
|
|
|
int CReplay::ms_nNumDummy_Stored;
|
|
|
|
int CReplay::ms_nTotalCarPassengerPeds_Stored;
|
|
|
|
int CReplay::ms_nTotalCivPeds_Stored;
|
|
|
|
int CReplay::ms_nTotalGangPeds_Stored;
|
|
|
|
int CReplay::ms_nTotalPeds_Stored;
|
|
|
|
int CReplay::ms_nTotalMissionPeds_Stored;
|
|
|
|
uint8* CReplay::pGarages;
|
|
|
|
CFire* CReplay::FireArray;
|
|
|
|
uint32 CReplay::NumOfFires;
|
|
|
|
uint8* CReplay::paProjectileInfo;
|
|
|
|
uint8* CReplay::paProjectiles;
|
|
|
|
uint8 CReplay::CurrArea;
|
2020-04-18 20:50:37 +00:00
|
|
|
#ifdef FIX_BUGS
|
|
|
|
int CReplay::nHandleOfPlayerPed[NUMPLAYERS];
|
|
|
|
#endif
|
2019-06-24 22:42:23 +00:00
|
|
|
|
2020-04-17 05:54:14 +00:00
|
|
|
static void(*CBArray[])(CAnimBlendAssociation*, void*) =
|
2019-06-24 22:42:23 +00:00
|
|
|
{
|
|
|
|
nil, &CPed::PedGetupCB, &CPed::PedStaggerCB, &CPed::PedEvadeCB, &CPed::FinishDieAnimCB,
|
|
|
|
&CPed::FinishedWaitCB, &CPed::FinishLaunchCB, &CPed::FinishHitHeadCB, &CPed::PedAnimGetInCB, &CPed::PedAnimDoorOpenCB,
|
2019-09-06 22:27:07 +00:00
|
|
|
&CPed::PedAnimPullPedOutCB, &CPed::PedAnimDoorCloseCB, &CPed::PedSetInCarCB, &CPed::PedSetOutCarCB, &CPed::PedAnimAlignCB,
|
2020-06-17 18:24:59 +00:00
|
|
|
&CPed::PedSetDraggedOutCarCB, &CPed::PedAnimStepOutCarCB, &CPed::PedSetInTrainCB,
|
|
|
|
#ifdef GTA_TRAIN
|
|
|
|
&CPed::PedSetOutTrainCB,
|
|
|
|
#endif
|
|
|
|
&CPed::FinishedAttackCB,
|
2019-06-24 22:42:23 +00:00
|
|
|
&CPed::FinishFightMoveCB, &PhonePutDownCB, &PhonePickUpCB, &CPed::PedAnimDoorCloseRollingCB, &CPed::FinishJumpCB,
|
2020-06-17 18:24:59 +00:00
|
|
|
&CPed::PedLandCB, &CPed::RestoreHeadingRateCB, &CPed::PedSetQuickDraggedOutCarPositionCB, &CPed::PedSetDraggedOutCarPositionCB,
|
2020-11-01 15:21:05 +00:00
|
|
|
&CPed::PedSetPreviousStateCB, &CPed::FinishedReloadCB, &CPed::PedSetGetInCarPositionCB,
|
2020-09-26 18:10:23 +00:00
|
|
|
&CPed::PedAnimShuffleCB, &CPed::DeleteSunbatheIdleAnimCB, &StartTalkingOnMobileCB, &FinishTalkingOnMobileCB
|
2019-06-24 22:42:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static uint8 FindCBFunctionID(void(*f)(CAnimBlendAssociation*, void*))
|
|
|
|
{
|
|
|
|
for (int i = 0; i < sizeof(CBArray) / sizeof(*CBArray); i++){
|
|
|
|
if (CBArray[i] == f)
|
|
|
|
return i;
|
|
|
|
}
|
2020-04-17 05:54:14 +00:00
|
|
|
|
2019-06-24 22:42:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void(*FindCBFunction(uint8 id))(CAnimBlendAssociation*, void*)
|
|
|
|
{
|
2020-04-17 05:54:14 +00:00
|
|
|
return CBArray[id];
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
|
|
|
|
2019-06-30 21:15:34 +00:00
|
|
|
static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flying)
|
|
|
|
{
|
2019-07-06 17:44:00 +00:00
|
|
|
if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)){
|
|
|
|
vehicle->Damage.SetPanelStatus(VEHPANEL_FRONT_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT));
|
|
|
|
vehicle->SetPanelDamage(CAR_WING_LF, VEHPANEL_FRONT_LEFT, flying);
|
2019-06-30 21:15:34 +00:00
|
|
|
}
|
2019-07-06 17:44:00 +00:00
|
|
|
if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT)){
|
|
|
|
vehicle->Damage.SetPanelStatus(VEHPANEL_FRONT_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT));
|
|
|
|
vehicle->SetPanelDamage(CAR_WING_RF, VEHPANEL_FRONT_RIGHT, flying);
|
2019-06-30 21:15:34 +00:00
|
|
|
}
|
2019-07-06 17:44:00 +00:00
|
|
|
if(vehicle->Damage.GetPanelStatus(VEHPANEL_REAR_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT)){
|
|
|
|
vehicle->Damage.SetPanelStatus(VEHPANEL_REAR_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT));
|
|
|
|
vehicle->SetPanelDamage(CAR_WING_LR, VEHPANEL_REAR_LEFT, flying);
|
2019-06-30 21:15:34 +00:00
|
|
|
}
|
2019-07-06 17:44:00 +00:00
|
|
|
if(vehicle->Damage.GetPanelStatus(VEHPANEL_REAR_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT)){
|
|
|
|
vehicle->Damage.SetPanelStatus(VEHPANEL_REAR_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT));
|
|
|
|
vehicle->SetPanelDamage(CAR_WING_RR, VEHPANEL_REAR_RIGHT, flying);
|
2019-06-30 21:15:34 +00:00
|
|
|
}
|
2019-07-06 17:44:00 +00:00
|
|
|
if(vehicle->Damage.GetPanelStatus(VEHPANEL_WINDSCREEN) != CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN)){
|
|
|
|
vehicle->Damage.SetPanelStatus(VEHPANEL_WINDSCREEN, CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN));
|
|
|
|
vehicle->SetPanelDamage(CAR_WINDSCREEN, VEHPANEL_WINDSCREEN, flying);
|
2019-06-30 21:15:34 +00:00
|
|
|
}
|
2019-07-06 17:44:00 +00:00
|
|
|
if(vehicle->Damage.GetPanelStatus(VEHBUMPER_FRONT) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT)){
|
|
|
|
vehicle->Damage.SetPanelStatus(VEHBUMPER_FRONT, CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT));
|
|
|
|
vehicle->SetPanelDamage(CAR_BUMP_FRONT, VEHBUMPER_FRONT, flying);
|
2019-06-30 21:15:34 +00:00
|
|
|
}
|
2019-07-06 17:44:00 +00:00
|
|
|
if(vehicle->Damage.GetPanelStatus(VEHBUMPER_REAR) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR)){
|
|
|
|
vehicle->Damage.SetPanelStatus(VEHBUMPER_REAR, CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR));
|
|
|
|
vehicle->SetPanelDamage(CAR_BUMP_REAR, VEHBUMPER_REAR, flying);
|
2019-06-30 21:15:34 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-07 20:31:03 +00:00
|
|
|
|
2019-06-22 18:16:29 +00:00
|
|
|
void PrintElementsInPtrList(void)
|
|
|
|
{
|
2020-07-13 14:43:09 +00:00
|
|
|
for (CPtrNode* node = CWorld::GetBigBuildingList(LEVEL_GENERIC).first; node; node = node->next) {
|
2019-06-23 10:58:14 +00:00
|
|
|
/* Most likely debug print was present here */
|
2019-06-22 18:16:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::Init(void)
|
|
|
|
{
|
|
|
|
pBuf0 = nil;
|
|
|
|
pBuf1 = nil;
|
|
|
|
pBuf2 = nil;
|
|
|
|
pBuf3 = nil;
|
|
|
|
pBuf4 = nil;
|
|
|
|
pBuf5 = nil;
|
|
|
|
pBuf6 = nil;
|
|
|
|
pBuf7 = nil;
|
|
|
|
pBuf8 = nil;
|
|
|
|
pBuf9 = nil;
|
|
|
|
pBuf10 = nil;
|
|
|
|
pBuf11 = nil;
|
|
|
|
pRadarBlips = nil;
|
|
|
|
pStoredCam = nil;
|
|
|
|
pWorld1 = nil;
|
|
|
|
pEmptyReferences = nil;
|
|
|
|
pPedAnims = nil;
|
|
|
|
pPickups = nil;
|
|
|
|
pReferences = nil;
|
|
|
|
Mode = MODE_RECORD;
|
|
|
|
Playback.m_nOffset = 0;
|
|
|
|
Playback.m_pBase = nil;
|
|
|
|
Playback.m_bSlot = 0;
|
|
|
|
Record.m_nOffset = 0;
|
|
|
|
Record.m_pBase = nil;
|
|
|
|
Record.m_bSlot = 0;
|
2020-03-15 15:47:21 +00:00
|
|
|
for (int i = 0; i < NUM_REPLAYBUFFERS; i++)
|
2019-06-22 18:16:29 +00:00
|
|
|
BufferStatus[i] = REPLAYBUFFER_UNUSED;
|
|
|
|
Record.m_bSlot = 0;
|
|
|
|
Record.m_pBase = Buffers[0];
|
|
|
|
BufferStatus[0] = REPLAYBUFFER_RECORD;
|
|
|
|
Buffers[0][Record.m_nOffset] = REPLAYPACKET_END;
|
|
|
|
bPlayingBackFromFile = false;
|
|
|
|
bReplayEnabled = true;
|
|
|
|
SlowMotion = 1;
|
|
|
|
FramesActiveLookAroundCam = 0;
|
|
|
|
bDoLoadSceneWhenDone = false;
|
2020-09-26 18:10:23 +00:00
|
|
|
MarkEverythingAsNew();
|
2019-06-22 18:16:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::DisableReplays(void)
|
|
|
|
{
|
|
|
|
bReplayEnabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::EnableReplays(void)
|
|
|
|
{
|
|
|
|
bReplayEnabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayReplayFromHD(void);
|
|
|
|
void CReplay::Update(void)
|
|
|
|
{
|
2020-09-26 18:10:23 +00:00
|
|
|
if (CCutsceneMgr::IsCutsceneProcessing() || CPad::GetPad(0)->ArePlayerControlsDisabled() || CScriptPaths::IsOneActive() || FrontEndMenuManager.GetIsMenuActive()) {
|
|
|
|
Init();
|
2019-06-22 18:16:29 +00:00
|
|
|
return;
|
2020-09-26 18:10:23 +00:00
|
|
|
}
|
2019-06-22 18:16:29 +00:00
|
|
|
switch (Mode){
|
|
|
|
case MODE_RECORD:
|
|
|
|
RecordThisFrame();
|
|
|
|
break;
|
|
|
|
case MODE_PLAYBACK:
|
|
|
|
PlaybackThisFrame();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (CDraw::FadeValue || !bReplayEnabled)
|
|
|
|
return;
|
|
|
|
if (Mode == MODE_PLAYBACK){
|
2019-07-25 20:34:29 +00:00
|
|
|
if (CPad::GetPad(0)->GetFJustDown(0))
|
2019-06-22 18:16:29 +00:00
|
|
|
FinishPlayback();
|
|
|
|
}
|
|
|
|
else if (Mode == MODE_RECORD){
|
2019-07-25 20:34:29 +00:00
|
|
|
if (CPad::GetPad(0)->GetFJustDown(0))
|
2019-06-22 18:16:29 +00:00
|
|
|
TriggerPlayback(REPLAYCAMMODE_ASSTORED, 0.0f, 0.0f, 0.0f, false);
|
2019-07-25 20:34:29 +00:00
|
|
|
if (CPad::GetPad(0)->GetFJustDown(1))
|
2019-06-22 18:16:29 +00:00
|
|
|
SaveReplayToHD();
|
2019-07-25 20:34:29 +00:00
|
|
|
if (CPad::GetPad(0)->GetFJustDown(2))
|
2019-06-22 18:16:29 +00:00
|
|
|
PlayReplayFromHD();
|
2020-03-15 15:47:21 +00:00
|
|
|
#ifdef USE_BETA_REPLAY_MODE
|
|
|
|
if (CPad::GetPad(0)->GetFJustDown(3))
|
|
|
|
TriggerPlaybackLastCoupleOfSeconds(5000, REPLAYCAMMODE_TOPDOWN, 0.0f, 0.0f, 0.0f, 4);
|
|
|
|
#endif
|
2019-06-22 18:16:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::RecordThisFrame(void)
|
|
|
|
{
|
2020-09-26 18:10:23 +00:00
|
|
|
uint32 memory_required = sizeof(tGeneralPacket) + sizeof(tClockPacket) + sizeof(tWeatherPacket) + sizeof(tTimerPacket) + sizeof(tMiscPacket);
|
2020-03-15 15:47:21 +00:00
|
|
|
CVehiclePool* vehiclesT = CPools::GetVehiclePool();
|
|
|
|
for (int i = 0; i < vehiclesT->GetSize(); i++) {
|
|
|
|
CVehicle* v = vehiclesT->GetSlot(i);
|
2020-09-26 18:10:23 +00:00
|
|
|
if (v && v->m_rwObject && v->GetModelIndex() != MI_AIRTRAIN && v->GetModelIndex() != MI_TRAIN) {
|
|
|
|
if (v->IsBike())
|
|
|
|
memory_required += sizeof(tBikeUpdatePacket);
|
|
|
|
else
|
|
|
|
memory_required += sizeof(tVehicleUpdatePacket);
|
|
|
|
}
|
2020-03-15 15:47:21 +00:00
|
|
|
}
|
|
|
|
CPedPool* pedsT = CPools::GetPedPool();
|
|
|
|
for (int i = 0; i < pedsT->GetSize(); i++) {
|
|
|
|
CPed* p = pedsT->GetSlot(i);
|
|
|
|
if (!p || !p->m_rwObject)
|
|
|
|
continue;
|
|
|
|
if (!p->bHasAlreadyBeenRecorded) {
|
|
|
|
memory_required += sizeof(tPedHeaderPacket);
|
|
|
|
}
|
|
|
|
memory_required += sizeof(tPedUpdatePacket);
|
|
|
|
}
|
2020-03-22 10:20:36 +00:00
|
|
|
for (uint8 i = 0; i < NUMBULLETTRACES; i++) {
|
2020-03-15 15:47:21 +00:00
|
|
|
if (!CBulletTraces::aTraces[i].m_bInUse)
|
|
|
|
continue;
|
|
|
|
memory_required += sizeof(tBulletTracePacket);
|
|
|
|
}
|
2020-04-18 20:50:37 +00:00
|
|
|
memory_required += sizeof(tEndOfFramePacket) + 1; // 1 for Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
|
2020-09-26 18:10:23 +00:00
|
|
|
if (Record.m_nOffset + memory_required > REPLAYBUFFERSIZE - 16)
|
|
|
|
GoToNextBlock();
|
2019-06-22 18:16:29 +00:00
|
|
|
tGeneralPacket* general = (tGeneralPacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
general->type = REPLAYPACKET_GENERAL;
|
|
|
|
general->camera_pos.CopyOnlyMatrix(&TheCamera.GetMatrix());
|
2019-06-29 09:09:33 +00:00
|
|
|
general->player_pos = FindPlayerCoors();
|
2019-06-22 18:16:29 +00:00
|
|
|
general->in_rcvehicle = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle ? true : false;
|
|
|
|
Record.m_nOffset += sizeof(*general);
|
|
|
|
tClockPacket* clock = (tClockPacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
clock->type = REPLAYPACKET_CLOCK;
|
|
|
|
clock->hours = CClock::GetHours();
|
|
|
|
clock->minutes = CClock::GetMinutes();
|
|
|
|
Record.m_nOffset += sizeof(*clock);
|
|
|
|
tWeatherPacket* weather = (tWeatherPacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
weather->type = REPLAYPACKET_WEATHER;
|
|
|
|
weather->old_weather = CWeather::OldWeatherType;
|
|
|
|
weather->new_weather = CWeather::NewWeatherType;
|
|
|
|
weather->interpolation = CWeather::InterpolationValue;
|
|
|
|
Record.m_nOffset += sizeof(*weather);
|
|
|
|
tTimerPacket* timer = (tTimerPacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
timer->type = REPLAYPACKET_TIMER;
|
|
|
|
timer->timer = CTimer::GetTimeInMilliseconds();
|
|
|
|
Record.m_nOffset += sizeof(*timer);
|
|
|
|
CVehiclePool* vehicles = CPools::GetVehiclePool();
|
|
|
|
for (int i = 0; i < vehicles->GetSize(); i++){
|
|
|
|
CVehicle* v = vehicles->GetSlot(i);
|
2020-09-26 18:10:23 +00:00
|
|
|
if (v && v->m_rwObject && v->GetModelIndex() != MI_AIRTRAIN && v->GetModelIndex() != MI_TRAIN) {
|
|
|
|
if (v->IsBike())
|
|
|
|
StoreBikeUpdate(v, i);
|
|
|
|
else
|
|
|
|
StoreCarUpdate(v, i);
|
|
|
|
}
|
2019-06-22 18:16:29 +00:00
|
|
|
}
|
|
|
|
CPedPool* peds = CPools::GetPedPool();
|
|
|
|
for (int i = 0; i < peds->GetSize(); i++) {
|
|
|
|
CPed* p = peds->GetSlot(i);
|
|
|
|
if (!p || !p->m_rwObject)
|
|
|
|
continue;
|
2019-07-09 07:57:44 +00:00
|
|
|
if (!p->bHasAlreadyBeenRecorded){
|
2019-06-22 18:16:29 +00:00
|
|
|
tPedHeaderPacket* ph = (tPedHeaderPacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
ph->type = REPLAYPACKET_PED_HEADER;
|
|
|
|
ph->index = i;
|
|
|
|
ph->mi = p->GetModelIndex();
|
|
|
|
ph->pedtype = p->m_nPedType;
|
|
|
|
Record.m_nOffset += sizeof(*ph);
|
2019-07-09 07:57:44 +00:00
|
|
|
p->bHasAlreadyBeenRecorded = true;
|
2019-06-22 18:16:29 +00:00
|
|
|
}
|
|
|
|
StorePedUpdate(p, i);
|
|
|
|
}
|
2020-03-22 10:20:36 +00:00
|
|
|
for (uint8 i = 0; i < NUMBULLETTRACES; i++){
|
2019-06-22 18:16:29 +00:00
|
|
|
if (!CBulletTraces::aTraces[i].m_bInUse)
|
|
|
|
continue;
|
|
|
|
tBulletTracePacket* bt = (tBulletTracePacket*)&Record.m_pBase[Record.m_nOffset];
|
2019-06-22 22:34:11 +00:00
|
|
|
bt->type = REPLAYPACKET_BULLET_TRACES;
|
2019-06-22 18:16:29 +00:00
|
|
|
bt->index = i;
|
2020-10-15 12:42:10 +00:00
|
|
|
bt->inf = CBulletTraces::aTraces[i].m_vecStartPos;
|
|
|
|
bt->sup = CBulletTraces::aTraces[i].m_vecEndPos;
|
2019-06-22 18:16:29 +00:00
|
|
|
Record.m_nOffset += sizeof(*bt);
|
|
|
|
}
|
2020-09-26 18:10:23 +00:00
|
|
|
tMiscPacket* misc = (tMiscPacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
misc->type = REPLAYPACKET_MISC;
|
|
|
|
misc->cam_shake_start = TheCamera.m_uiCamShakeStart;
|
|
|
|
misc->cam_shake_strength = TheCamera.m_fCamShakeForce;
|
|
|
|
misc->cur_area = CGame::currArea;
|
2020-11-01 15:21:05 +00:00
|
|
|
misc->video_cam = CSpecialFX::bVideoCam;
|
|
|
|
misc->lift_cam = CSpecialFX::bLiftCam;
|
2020-09-26 18:10:23 +00:00
|
|
|
Record.m_nOffset += sizeof(*misc);
|
2019-06-22 18:16:29 +00:00
|
|
|
tEndOfFramePacket* eof = (tEndOfFramePacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
eof->type = REPLAYPACKET_ENDOFFRAME;
|
|
|
|
Record.m_nOffset += sizeof(*eof);
|
2020-03-15 15:47:21 +00:00
|
|
|
Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
|
2020-09-26 18:10:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::GoToNextBlock(void)
|
|
|
|
{
|
|
|
|
Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
|
2019-06-22 18:16:29 +00:00
|
|
|
BufferStatus[Record.m_bSlot] = REPLAYBUFFER_PLAYBACK;
|
2020-03-15 15:47:21 +00:00
|
|
|
Record.m_bSlot = (Record.m_bSlot + 1) % NUM_REPLAYBUFFERS;
|
2019-06-22 18:16:29 +00:00
|
|
|
BufferStatus[Record.m_bSlot] = REPLAYBUFFER_RECORD;
|
|
|
|
Record.m_pBase = Buffers[Record.m_bSlot];
|
|
|
|
Record.m_nOffset = 0;
|
|
|
|
*Record.m_pBase = REPLAYPACKET_END;
|
|
|
|
MarkEverythingAsNew();
|
|
|
|
}
|
2019-06-22 22:34:11 +00:00
|
|
|
|
2020-09-26 18:10:23 +00:00
|
|
|
void CReplay::RecordParticle(tParticleType type, const CVector& vecPos, const CVector& vecDir, float fSize, const RwRGBA& color)
|
|
|
|
{
|
|
|
|
if (Record.m_nOffset > REPLAYBUFFERSIZE - 16 - sizeof(tParticlePacket))
|
|
|
|
GoToNextBlock();
|
|
|
|
tParticlePacket* pp = (tParticlePacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
pp->type = REPLAYPACKET_PARTICLE;
|
|
|
|
pp->particle_type = type;
|
|
|
|
pp->pos_x = 4.0f * vecPos.x;
|
|
|
|
pp->pos_y = 4.0f * vecPos.y;
|
|
|
|
pp->pos_z = 4.0f * vecPos.z;
|
|
|
|
pp->dir_x = 120.0f * clamp(vecDir.x, -1.0f, 1.0f);
|
|
|
|
pp->dir_y = 120.0f * clamp(vecDir.y, -1.0f, 1.0f);
|
|
|
|
pp->dir_z = 120.0f * clamp(vecDir.z, -1.0f, 1.0f);
|
|
|
|
pp->size = fSize;
|
|
|
|
pp->r = color.red;
|
|
|
|
pp->g = color.green;
|
|
|
|
pp->b = color.blue;
|
|
|
|
pp->a = color.alpha;
|
|
|
|
Record.m_nOffset += sizeof(tParticlePacket);
|
|
|
|
Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
|
|
|
|
}
|
|
|
|
|
2019-06-22 22:34:11 +00:00
|
|
|
void CReplay::StorePedUpdate(CPed *ped, int id)
|
|
|
|
{
|
|
|
|
tPedUpdatePacket* pp = (tPedUpdatePacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
pp->type = REPLAYPACKET_PED_UPDATE;
|
|
|
|
pp->index = id;
|
2019-08-16 18:17:15 +00:00
|
|
|
pp->heading = 128.0f / PI * ped->m_fRotationCur;
|
2019-06-22 22:34:11 +00:00
|
|
|
pp->matrix.CompressFromFullMatrix(ped->GetMatrix());
|
|
|
|
pp->assoc_group_id = ped->m_animGroup;
|
2020-09-26 18:10:23 +00:00
|
|
|
pp->is_visible = ped->bIsVisible;
|
2019-06-22 22:34:11 +00:00
|
|
|
/* Would be more sane to use GetJustIndex(ped->m_pMyVehicle) in following assignment */
|
2019-12-02 20:02:32 +00:00
|
|
|
if (ped->InVehicle())
|
2019-06-22 22:34:11 +00:00
|
|
|
pp->vehicle_index = (CPools::GetVehiclePool()->GetIndex(ped->m_pMyVehicle) >> 8) + 1;
|
|
|
|
else
|
|
|
|
pp->vehicle_index = 0;
|
|
|
|
pp->weapon_model = ped->m_wepModelID;
|
|
|
|
StorePedAnimation(ped, &pp->anim_state);
|
|
|
|
Record.m_nOffset += sizeof(tPedUpdatePacket);
|
|
|
|
}
|
2019-06-23 10:58:14 +00:00
|
|
|
|
|
|
|
void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation* second;
|
|
|
|
float blend_amount;
|
|
|
|
CAnimBlendAssociation* main = RpAnimBlendClumpGetMainAssociation((RpClump*)ped->m_rwObject, &second, &blend_amount);
|
|
|
|
if (main){
|
|
|
|
state->animId = main->animId;
|
2020-03-15 15:47:21 +00:00
|
|
|
state->time = 255.0f / 4.0f * clamp(main->currentTime, 0.0f, 4.0f);
|
|
|
|
state->speed = 255.0f / 3.0f * clamp(main->speed, 0.0f, 3.0f);
|
2020-09-26 18:10:23 +00:00
|
|
|
state->groupId = main->groupId;
|
2019-06-23 10:58:14 +00:00
|
|
|
}else{
|
|
|
|
state->animId = 3;
|
|
|
|
state->time = 0;
|
|
|
|
state->speed = 85;
|
2020-09-26 18:10:23 +00:00
|
|
|
state->groupId = 0;
|
2019-06-23 10:58:14 +00:00
|
|
|
}
|
|
|
|
if (second) {
|
|
|
|
state->secAnimId = second->animId;
|
2020-03-15 15:47:21 +00:00
|
|
|
state->secTime = 255.0f / 4.0f * clamp(second->currentTime, 0.0f, 4.0f);
|
|
|
|
state->secSpeed = 255.0f / 3.0f * clamp(second->speed, 0.0f, 3.0f);
|
|
|
|
state->blendAmount = 255.0f / 2.0f * clamp(blend_amount, 0.0f, 2.0f);
|
2020-09-26 18:10:23 +00:00
|
|
|
state->secGroupId = second->groupId;
|
2019-06-23 10:58:14 +00:00
|
|
|
}else{
|
|
|
|
state->secAnimId = 0;
|
|
|
|
state->secTime = 0;
|
|
|
|
state->secSpeed = 0;
|
|
|
|
state->blendAmount = 0;
|
2020-09-26 18:10:23 +00:00
|
|
|
state->secGroupId = 0;
|
2019-06-23 10:58:14 +00:00
|
|
|
}
|
|
|
|
CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject);
|
|
|
|
if (partial) {
|
|
|
|
state->partAnimId = partial->animId;
|
2020-03-15 15:47:21 +00:00
|
|
|
state->partAnimTime = 255.0f / 4.0f * clamp(partial->currentTime, 0.0f, 4.0f);
|
|
|
|
state->partAnimSpeed = 255.0f / 3.0f * clamp(partial->speed, 0.0f, 3.0f);
|
|
|
|
state->partBlendAmount = 255.0f / 2.0f * clamp(partial->blendAmount, 0.0f, 2.0f);
|
2020-09-26 18:10:23 +00:00
|
|
|
state->partGroupId = partial->groupId;
|
2019-06-23 10:58:14 +00:00
|
|
|
}else{
|
|
|
|
state->partAnimId = 0;
|
|
|
|
state->partAnimTime = 0;
|
|
|
|
state->partAnimSpeed = 0;
|
|
|
|
state->partBlendAmount = 0;
|
2020-09-26 18:10:23 +00:00
|
|
|
state->partGroupId = 0;
|
2019-06-23 10:58:14 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-24 22:42:23 +00:00
|
|
|
|
|
|
|
void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state)
|
|
|
|
{
|
2020-03-15 15:47:21 +00:00
|
|
|
for (int i = 0; i < NUM_MAIN_ANIMS_IN_REPLAY; i++){
|
2019-06-24 22:42:23 +00:00
|
|
|
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainAssociation_N((RpClump*)ped->m_rwObject, i);
|
|
|
|
if (assoc){
|
|
|
|
state->aAnimId[i] = assoc->animId;
|
2020-03-15 15:47:21 +00:00
|
|
|
state->aCurTime[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f);
|
|
|
|
state->aSpeed[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f);
|
|
|
|
state->aBlendAmount[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f);
|
|
|
|
state->aBlendDelta[i] = 127.0f / 32.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
2019-06-24 22:42:23 +00:00
|
|
|
state->aFlags[i] = assoc->flags;
|
2020-09-26 18:10:23 +00:00
|
|
|
state->aGroupId[i] = assoc->groupId;
|
2019-06-24 22:42:23 +00:00
|
|
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
|
|
|
state->aFunctionCallbackID[i] = FindCBFunctionID(assoc->callback);
|
|
|
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH)
|
|
|
|
state->aFunctionCallbackID[i] |= 0x80;
|
|
|
|
}else{
|
|
|
|
state->aFunctionCallbackID[i] = 0;
|
|
|
|
}
|
|
|
|
}else{
|
2019-06-29 15:01:43 +00:00
|
|
|
state->aAnimId[i] = NUM_ANIMS;
|
2019-06-24 22:42:23 +00:00
|
|
|
state->aCurTime[i] = 0;
|
|
|
|
state->aSpeed[i] = 85;
|
|
|
|
state->aFunctionCallbackID[i] = 0;
|
|
|
|
state->aFlags[i] = 0;
|
2020-09-26 18:10:23 +00:00
|
|
|
state->aGroupId[i] = 0;
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-15 15:47:21 +00:00
|
|
|
for (int i = 0; i < NUM_PARTIAL_ANIMS_IN_REPLAY; i++) {
|
2019-06-24 22:42:23 +00:00
|
|
|
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainPartialAssociation_N((RpClump*)ped->m_rwObject, i);
|
|
|
|
if (assoc) {
|
|
|
|
state->aAnimId2[i] = assoc->animId;
|
2020-03-15 15:47:21 +00:00
|
|
|
state->aCurTime2[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f);
|
|
|
|
state->aSpeed2[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f);
|
|
|
|
state->aBlendAmount2[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f);
|
|
|
|
state->aBlendDelta2[i] = 127.0f / 16.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
2019-06-24 22:42:23 +00:00
|
|
|
state->aFlags2[i] = assoc->flags;
|
2020-09-26 18:10:23 +00:00
|
|
|
state->aGroupId2[i] = assoc->groupId;
|
2019-06-24 22:42:23 +00:00
|
|
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
|
|
|
state->aFunctionCallbackID2[i] = FindCBFunctionID(assoc->callback);
|
|
|
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH)
|
|
|
|
state->aFunctionCallbackID2[i] |= 0x80;
|
|
|
|
}else{
|
|
|
|
state->aFunctionCallbackID2[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2019-06-29 15:01:43 +00:00
|
|
|
state->aAnimId2[i] = NUM_ANIMS;
|
2019-06-24 22:42:23 +00:00
|
|
|
state->aCurTime2[i] = 0;
|
|
|
|
state->aSpeed2[i] = 85;
|
|
|
|
state->aFunctionCallbackID2[i] = 0;
|
|
|
|
state->aFlags2[i] = 0;
|
2020-09-26 18:10:23 +00:00
|
|
|
state->aGroupId2[i] = 0;
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-29 05:54:34 +00:00
|
|
|
|
2019-06-29 11:38:37 +00:00
|
|
|
void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer)
|
|
|
|
{
|
|
|
|
tPedUpdatePacket *pp = (tPedUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
|
2019-06-29 20:15:55 +00:00
|
|
|
if (!ped){
|
2020-03-15 15:47:21 +00:00
|
|
|
printf("Replay:Ped wasn't there\n");
|
2019-06-29 20:15:55 +00:00
|
|
|
buffer->m_nOffset += sizeof(tPedUpdatePacket);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-16 18:17:15 +00:00
|
|
|
ped->m_fRotationCur = pp->heading * PI / 128.0f;
|
|
|
|
ped->m_fRotationDest = pp->heading * PI / 128.0f;
|
2019-06-29 20:15:55 +00:00
|
|
|
CMatrix ped_matrix;
|
|
|
|
pp->matrix.DecompressIntoFullMatrix(ped_matrix);
|
|
|
|
ped->GetMatrix() = ped->GetMatrix() * CMatrix(1.0f - interpolation);
|
2019-07-08 15:07:34 +00:00
|
|
|
ped->GetMatrix().GetPosition() *= (1.0f - interpolation);
|
2019-06-29 20:15:55 +00:00
|
|
|
ped->GetMatrix() += CMatrix(interpolation) * ped_matrix;
|
|
|
|
if (pp->vehicle_index) {
|
|
|
|
ped->m_pMyVehicle = CPools::GetVehiclePool()->GetSlot(pp->vehicle_index - 1);
|
2020-09-26 18:10:23 +00:00
|
|
|
ped->bInVehicle = true;
|
2019-06-29 20:15:55 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ped->m_pMyVehicle = nil;
|
|
|
|
ped->bInVehicle = false;
|
2019-06-29 11:38:37 +00:00
|
|
|
}
|
2019-06-29 20:15:55 +00:00
|
|
|
if (pp->assoc_group_id != ped->m_animGroup) {
|
|
|
|
ped->m_animGroup = (AssocGroupId)pp->assoc_group_id;
|
|
|
|
if (ped == FindPlayerPed())
|
|
|
|
((CPlayerPed*)ped)->ReApplyMoveAnims();
|
|
|
|
}
|
2020-09-26 18:10:23 +00:00
|
|
|
ped->bIsVisible = pp->is_visible;
|
|
|
|
if (FramesActiveLookAroundCam && ped->m_nPedType == PEDTYPE_PLAYER1)
|
|
|
|
ped->bIsVisible = true;
|
2019-06-29 20:15:55 +00:00
|
|
|
RetrievePedAnimation(ped, &pp->anim_state);
|
|
|
|
ped->RemoveWeaponModel(-1);
|
2020-05-16 14:00:40 +00:00
|
|
|
if (pp->weapon_model != (uint16)-1) {
|
|
|
|
if (CStreaming::HasModelLoaded(pp->weapon_model))
|
|
|
|
ped->AddWeaponModel(pp->weapon_model);
|
|
|
|
else
|
|
|
|
CStreaming::RequestModel(pp->weapon_model, 0);
|
|
|
|
}
|
2019-06-29 20:15:55 +00:00
|
|
|
CWorld::Remove(ped);
|
|
|
|
CWorld::Add(ped);
|
2019-06-29 11:38:37 +00:00
|
|
|
buffer->m_nOffset += sizeof(tPedUpdatePacket);
|
|
|
|
}
|
2019-06-29 12:19:31 +00:00
|
|
|
|
2020-09-26 18:10:23 +00:00
|
|
|
bool HasAnimGroupLoaded(uint8 group)
|
|
|
|
{
|
|
|
|
CAnimBlendAssocGroup* pGroup = &CAnimManager::GetAnimAssocGroups()[group];
|
|
|
|
return pGroup->animBlock && pGroup->animBlock->isLoaded;
|
|
|
|
}
|
|
|
|
|
2019-06-29 12:19:31 +00:00
|
|
|
void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state)
|
|
|
|
{
|
2020-09-26 18:10:23 +00:00
|
|
|
CAnimBlendAssociation* anim1;
|
|
|
|
if (state->animId <= 3)
|
|
|
|
anim1 = CAnimManager::BlendAnimation(
|
|
|
|
(RpClump*)ped->m_rwObject, ped->m_animGroup, (AnimationId)state->animId, 100.0f);
|
|
|
|
else if (HasAnimGroupLoaded(state->groupId))
|
|
|
|
anim1 = CAnimManager::BlendAnimation((RpClump*)ped->m_rwObject, (AssocGroupId)state->groupId, (AnimationId)state->animId, 100.0f);
|
|
|
|
else
|
|
|
|
anim1 = CAnimManager::BlendAnimation((RpClump*)ped->m_rwObject, ASSOCGRP_STD, ANIM_WALK, 100.0f);
|
|
|
|
|
2019-06-29 12:19:31 +00:00
|
|
|
anim1->SetCurrentTime(state->time * 4.0f / 255.0f);
|
|
|
|
anim1->speed = state->speed * 3.0f / 255.0f;
|
|
|
|
anim1->SetBlend(1.0f, 1.0f);
|
|
|
|
anim1->callbackType = CAnimBlendAssociation::CB_NONE;
|
|
|
|
if (state->blendAmount && state->secAnimId){
|
|
|
|
float time = state->secTime * 4.0f / 255.0f;
|
|
|
|
float speed = state->secSpeed * 3.0f / 255.0f;
|
|
|
|
float blend = state->blendAmount * 2.0f / 255.0f;
|
|
|
|
CAnimBlendAssociation* anim2 = CAnimManager::BlendAnimation(
|
|
|
|
(RpClump*)ped->m_rwObject,
|
2020-09-26 18:10:23 +00:00
|
|
|
(state->secAnimId > 3) ? (AssocGroupId)state->secGroupId : ped->m_animGroup,
|
2019-06-29 12:19:31 +00:00
|
|
|
(AnimationId)state->secAnimId, 100.0f);
|
|
|
|
anim2->SetCurrentTime(time);
|
|
|
|
anim2->speed = speed;
|
|
|
|
anim2->SetBlend(blend, 1.0f);
|
|
|
|
anim2->callbackType = CAnimBlendAssociation::CB_NONE;
|
|
|
|
}
|
|
|
|
RpAnimBlendClumpRemoveAssociations((RpClump*)ped->m_rwObject, 0x10);
|
|
|
|
if (state->partAnimId){
|
|
|
|
float time = state->partAnimTime * 4.0f / 255.0f;
|
|
|
|
float speed = state->partAnimSpeed * 3.0f / 255.0f;
|
|
|
|
float blend = state->partBlendAmount * 2.0f / 255.0f;
|
2020-09-26 18:10:23 +00:00
|
|
|
if (blend > 0.0f && state->partAnimId != ANIM_IDLE_STANCE && HasAnimGroupLoaded(state->partGroupId)){
|
2019-06-29 12:19:31 +00:00
|
|
|
CAnimBlendAssociation* anim3 = CAnimManager::BlendAnimation(
|
2020-09-26 18:10:23 +00:00
|
|
|
(RpClump*)ped->m_rwObject, (AssocGroupId)state->partGroupId, (AnimationId)state->partAnimId, 1000.0f);
|
2019-06-29 12:19:31 +00:00
|
|
|
anim3->SetCurrentTime(time);
|
|
|
|
anim3->speed = speed;
|
2019-06-29 15:01:43 +00:00
|
|
|
anim3->SetBlend(blend, 0.0f);
|
2019-06-29 12:19:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-29 15:01:43 +00:00
|
|
|
|
|
|
|
void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state)
|
|
|
|
{
|
2020-03-15 15:47:21 +00:00
|
|
|
CAnimBlendAssociation* assoc;
|
|
|
|
for (int i = 0; ((assoc = RpAnimBlendClumpGetMainAssociation_N(ped->GetClump(), i))); i++)
|
|
|
|
assoc->SetBlend(0.0f, -1.0f);
|
|
|
|
for (int i = 0; ((assoc = RpAnimBlendClumpGetMainPartialAssociation_N(ped->GetClump(), i))); i++)
|
|
|
|
assoc->SetBlend(0.0f, -1.0f);
|
|
|
|
for (int i = 0; i < NUM_MAIN_ANIMS_IN_REPLAY; i++) {
|
2019-06-29 15:01:43 +00:00
|
|
|
if (state->aAnimId[i] == NUM_ANIMS)
|
|
|
|
continue;
|
2020-03-15 15:47:21 +00:00
|
|
|
CAnimBlendAssociation* anim = CAnimManager::AddAnimation(ped->GetClump(),
|
2020-09-26 18:10:23 +00:00
|
|
|
state->aAnimId[i] > 3 ? (AssocGroupId)state->aGroupId[i] : ped->m_animGroup,
|
2020-03-15 15:47:21 +00:00
|
|
|
(AnimationId)state->aAnimId[i]);
|
2019-06-29 15:01:43 +00:00
|
|
|
anim->SetCurrentTime(state->aCurTime[i] * 4.0f / 255.0f);
|
|
|
|
anim->speed = state->aSpeed[i] * 3.0f / 255.0f;
|
2020-03-15 15:47:21 +00:00
|
|
|
anim->SetBlend(state->aBlendAmount[i] * 2.0f / 255.0f, state->aBlendDelta[i] * 16.0f / 127.0f);
|
2019-06-29 15:01:43 +00:00
|
|
|
anim->flags = state->aFlags[i];
|
|
|
|
uint8 callback = state->aFunctionCallbackID[i];
|
|
|
|
if (!callback)
|
|
|
|
anim->callbackType = CAnimBlendAssociation::CB_NONE;
|
|
|
|
else if (callback & 0x80)
|
|
|
|
anim->SetFinishCallback(FindCBFunction(callback & 0x7F), ped);
|
|
|
|
else
|
|
|
|
anim->SetDeleteCallback(FindCBFunction(callback & 0x7F), ped);
|
|
|
|
}
|
2020-03-15 15:47:21 +00:00
|
|
|
for (int i = 0; i < NUM_PARTIAL_ANIMS_IN_REPLAY; i++) {
|
2019-06-29 15:01:43 +00:00
|
|
|
if (state->aAnimId2[i] == NUM_ANIMS)
|
|
|
|
continue;
|
2020-03-15 15:47:21 +00:00
|
|
|
CAnimBlendAssociation* anim = CAnimManager::AddAnimation(ped->GetClump(),
|
2020-09-26 18:10:23 +00:00
|
|
|
state->aAnimId2[i] > 3 ? (AssocGroupId)state->aGroupId2[i] : ped->m_animGroup,
|
2020-03-15 15:47:21 +00:00
|
|
|
(AnimationId)state->aAnimId2[i]);
|
2019-06-29 15:01:43 +00:00
|
|
|
anim->SetCurrentTime(state->aCurTime2[i] * 4.0f / 255.0f);
|
|
|
|
anim->speed = state->aSpeed2[i] * 3.0f / 255.0f;
|
2020-03-15 15:47:21 +00:00
|
|
|
anim->SetBlend(state->aBlendAmount2[i] * 2.0f / 255.0f, state->aBlendDelta2[i] * 16.0f / 127.0f);
|
2019-06-29 15:01:43 +00:00
|
|
|
anim->flags = state->aFlags2[i];
|
|
|
|
uint8 callback = state->aFunctionCallbackID2[i];
|
|
|
|
if (!callback)
|
|
|
|
anim->callbackType = CAnimBlendAssociation::CB_NONE;
|
|
|
|
else if (callback & 0x80)
|
|
|
|
anim->SetFinishCallback(FindCBFunction(callback & 0x7F), ped);
|
|
|
|
else
|
|
|
|
anim->SetDeleteCallback(FindCBFunction(callback & 0x7F), ped);
|
|
|
|
}
|
|
|
|
}
|
2019-06-29 18:38:47 +00:00
|
|
|
|
|
|
|
void CReplay::PlaybackThisFrame(void)
|
|
|
|
{
|
2020-03-15 15:47:21 +00:00
|
|
|
static int FrameSloMo = 0;
|
2019-06-29 18:38:47 +00:00
|
|
|
CAddressInReplayBuffer buf = Playback;
|
|
|
|
if (PlayBackThisFrameInterpolation(&buf, 1.0f, nil)){
|
|
|
|
DMAudio.SetEffectsFadeVol(127);
|
|
|
|
DMAudio.SetMusicFadeVol(127);
|
|
|
|
return;
|
|
|
|
}
|
2020-03-15 15:47:21 +00:00
|
|
|
if (FrameSloMo){
|
2019-06-29 18:38:47 +00:00
|
|
|
CAddressInReplayBuffer buf_sm = buf;
|
2020-03-15 15:47:21 +00:00
|
|
|
if (PlayBackThisFrameInterpolation(&buf_sm, FrameSloMo * 1.0f / SlowMotion, nil)){
|
2019-06-29 18:38:47 +00:00
|
|
|
DMAudio.SetEffectsFadeVol(127);
|
|
|
|
DMAudio.SetMusicFadeVol(127);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-03-15 15:47:21 +00:00
|
|
|
FrameSloMo = (FrameSloMo + 1) % SlowMotion;
|
|
|
|
if (FrameSloMo == 0)
|
2019-06-29 18:38:47 +00:00
|
|
|
Playback = buf;
|
|
|
|
ProcessLookAroundCam();
|
|
|
|
DMAudio.SetEffectsFadeVol(0);
|
|
|
|
DMAudio.SetMusicFadeVol(0);
|
|
|
|
}
|
2019-06-24 22:42:23 +00:00
|
|
|
|
2020-03-15 15:47:21 +00:00
|
|
|
// next two functions are only found in mobile version
|
|
|
|
// most likely they were optimized out for being unused
|
|
|
|
void CReplay::TriggerPlaybackLastCoupleOfSeconds(uint32 start, uint8 cam_mode, float cam_x, float cam_y, float cam_z, uint32 slomo)
|
|
|
|
{
|
|
|
|
if (Mode != MODE_RECORD)
|
|
|
|
return;
|
|
|
|
TriggerPlayback(cam_mode, cam_x, cam_y, cam_z, true);
|
|
|
|
SlowMotion = slomo;
|
|
|
|
bAllowLookAroundCam = false;
|
|
|
|
if (!FastForwardToTime(CTimer::GetTimeInMilliseconds() - start))
|
|
|
|
Mode = MODE_RECORD;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CReplay::FastForwardToTime(uint32 start)
|
|
|
|
{
|
|
|
|
uint32 timer = 0;
|
|
|
|
while (start > timer)
|
|
|
|
if (PlayBackThisFrameInterpolation(&Playback, 1.0f, &timer))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-06-24 22:42:23 +00:00
|
|
|
void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
|
|
|
|
{
|
|
|
|
tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
vp->type = REPLAYPACKET_VEHICLE;
|
|
|
|
vp->index = id;
|
|
|
|
vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix());
|
|
|
|
vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */
|
2019-06-26 20:47:23 +00:00
|
|
|
vp->acceleration = vehicle->m_fGasPedal * 100.0f;
|
2019-07-06 17:44:00 +00:00
|
|
|
vp->panels = vehicle->IsCar() ? ((CAutomobile*)vehicle)->Damage.m_panelStatus : 0;
|
2020-04-19 16:34:08 +00:00
|
|
|
vp->velocityX = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */
|
|
|
|
vp->velocityY = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().y));
|
|
|
|
vp->velocityZ = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().z));
|
2019-06-24 22:42:23 +00:00
|
|
|
vp->mi = vehicle->GetModelIndex();
|
|
|
|
vp->primary_color = vehicle->m_currentColour1;
|
|
|
|
vp->secondary_color = vehicle->m_currentColour2;
|
|
|
|
if (vehicle->GetModelIndex() == MI_RHINO)
|
2019-08-16 18:17:15 +00:00
|
|
|
vp->car_gun = 128.0f / PI * ((CAutomobile*)vehicle)->m_fCarGunLR;
|
2019-06-24 22:42:23 +00:00
|
|
|
else
|
2019-06-26 20:47:23 +00:00
|
|
|
vp->wheel_state = 50.0f * vehicle->m_fSteerAngle;
|
2019-06-24 22:42:23 +00:00
|
|
|
if (vehicle->IsCar()){
|
|
|
|
CAutomobile* car = (CAutomobile*)vehicle;
|
|
|
|
for (int i = 0; i < 4; i++){
|
2019-07-07 11:09:11 +00:00
|
|
|
vp->wheel_susp_dist[i] = 50.0f * car->m_aSuspensionSpringRatio[i];
|
2019-08-16 18:17:15 +00:00
|
|
|
vp->wheel_rotation[i] = 128.0f / PI * car->m_aWheelRotation[i];
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
2019-08-16 18:17:15 +00:00
|
|
|
vp->door_angles[0] = 127.0f / PI * car->Doors[2].m_fAngle;
|
|
|
|
vp->door_angles[1] = 127.0f / PI * car->Doors[3].m_fAngle;
|
2019-06-24 22:42:23 +00:00
|
|
|
vp->door_status = 0;
|
|
|
|
for (int i = 0; i < 6; i++){
|
2020-04-27 09:41:34 +00:00
|
|
|
if (car->Damage.GetDoorStatus(i) == DOOR_STATUS_MISSING)
|
2019-06-24 22:42:23 +00:00
|
|
|
vp->door_status |= BIT(i);
|
|
|
|
}
|
|
|
|
}
|
2020-09-26 18:10:23 +00:00
|
|
|
if (vehicle->GetModelIndex() == MI_SKIMMER)
|
|
|
|
vp->skimmer_speed = 50.0f * ((CBoat*)vehicle)->m_fMovingSpeed;
|
|
|
|
vp->render_scorched = vehicle->bRenderScorched;
|
|
|
|
vp->vehicle_type = vehicle->m_vehType;
|
2019-06-24 22:42:23 +00:00
|
|
|
Record.m_nOffset += sizeof(tVehicleUpdatePacket);
|
|
|
|
}
|
2019-06-29 20:15:55 +00:00
|
|
|
|
2020-09-26 18:10:23 +00:00
|
|
|
void CReplay::StoreBikeUpdate(CVehicle* vehicle, int id)
|
|
|
|
{
|
|
|
|
CBike* bike = (CBike*)vehicle;
|
|
|
|
tBikeUpdatePacket* vp = (tBikeUpdatePacket*)&Record.m_pBase[Record.m_nOffset];
|
|
|
|
vp->type = REPLAYPACKET_BIKE;
|
|
|
|
vp->index = id;
|
|
|
|
vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix());
|
|
|
|
vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */
|
|
|
|
vp->acceleration = vehicle->m_fGasPedal * 100.0f;
|
2020-12-26 09:56:20 +00:00
|
|
|
#ifdef FIX_BUGS // originally it's undefined behaviour - different fields are copied on PC and mobile
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
vp->wheel_rotation[i] = 128.0f / PI * bike->m_aWheelRotation[i];
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
vp->wheel_rotation[i + 2] = 128.0f / PI * bike->m_aWheelSpeed[i];
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
vp->wheel_susp_dist[i] = 50.0f * bike->m_aSuspensionSpringRatio[i];
|
|
|
|
#else
|
2020-09-26 18:10:23 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
vp->wheel_susp_dist[i] = 50.0f * bike->m_aSuspensionSpringRatio[i];
|
|
|
|
vp->wheel_rotation[i] = 128.0f / PI * bike->m_aWheelRotation[i];
|
|
|
|
}
|
2020-12-26 09:56:20 +00:00
|
|
|
#endif
|
2020-09-26 18:10:23 +00:00
|
|
|
vp->velocityX = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */
|
|
|
|
vp->velocityY = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().y));
|
|
|
|
vp->velocityZ = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().z));
|
|
|
|
vp->mi = vehicle->GetModelIndex();
|
|
|
|
vp->primary_color = vehicle->m_currentColour1;
|
|
|
|
vp->secondary_color = vehicle->m_currentColour2;
|
|
|
|
vp->wheel_state = 50.0f * vehicle->m_fSteerAngle;
|
|
|
|
vp->lean_angle = 50.0f * bike->m_fLeanLRAngle;
|
|
|
|
vp->wheel_angle = 50.0f * bike->m_fWheelAngle;
|
|
|
|
Record.m_nOffset += sizeof(tBikeUpdatePacket);
|
|
|
|
}
|
|
|
|
|
2019-06-29 20:15:55 +00:00
|
|
|
void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer)
|
|
|
|
{
|
|
|
|
tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
|
|
|
|
if (!vehicle){
|
2020-03-15 15:47:21 +00:00
|
|
|
printf("Replay:Car wasn't there");
|
2019-06-29 20:15:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
CMatrix vehicle_matrix;
|
|
|
|
vp->matrix.DecompressIntoFullMatrix(vehicle_matrix);
|
|
|
|
vehicle->GetMatrix() = vehicle->GetMatrix() * CMatrix(1.0f - interpolation);
|
2019-07-08 15:07:34 +00:00
|
|
|
vehicle->GetMatrix().GetPosition() *= (1.0f - interpolation);
|
2019-06-29 20:15:55 +00:00
|
|
|
vehicle->GetMatrix() += CMatrix(interpolation) * vehicle_matrix;
|
|
|
|
vehicle->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
vehicle->m_fHealth = 4 * vp->health;
|
|
|
|
vehicle->m_fGasPedal = vp->acceleration / 100.0f;
|
|
|
|
if (vehicle->IsCar())
|
|
|
|
ApplyPanelDamageToCar(vp->panels, (CAutomobile*)vehicle, true);
|
|
|
|
vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f);
|
|
|
|
if (vehicle->GetModelIndex() == MI_RHINO) {
|
2019-08-16 18:17:15 +00:00
|
|
|
((CAutomobile*)vehicle)->m_fCarGunLR = vp->car_gun * PI / 128.0f;
|
2019-06-29 20:15:55 +00:00
|
|
|
vehicle->m_fSteerAngle = 0.0f;
|
|
|
|
}else{
|
|
|
|
vehicle->m_fSteerAngle = vp->wheel_state / 50.0f;
|
|
|
|
}
|
|
|
|
if (vehicle->IsCar()) {
|
|
|
|
CAutomobile* car = (CAutomobile*)vehicle;
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2019-07-07 11:09:11 +00:00
|
|
|
car->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
|
2019-08-16 18:17:15 +00:00
|
|
|
car->m_aWheelRotation[i] = vp->wheel_rotation[i] * PI / 128.0f;
|
2019-06-29 20:15:55 +00:00
|
|
|
}
|
2020-03-15 15:47:21 +00:00
|
|
|
car->Doors[DOOR_FRONT_LEFT].m_fAngle = car->Doors[DOOR_FRONT_LEFT].m_fPrevAngle = vp->door_angles[0] * PI / 127.0f;
|
|
|
|
car->Doors[DOOR_FRONT_RIGHT].m_fAngle = car->Doors[DOOR_FRONT_RIGHT].m_fPrevAngle = vp->door_angles[1] * PI / 127.0f;
|
2019-06-29 20:15:55 +00:00
|
|
|
if (vp->door_angles[0])
|
2020-03-15 15:47:21 +00:00
|
|
|
car->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_SWINGING);
|
2019-06-29 20:15:55 +00:00
|
|
|
if (vp->door_angles[1])
|
2020-03-15 15:47:21 +00:00
|
|
|
car->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_SWINGING);
|
2020-09-26 18:10:23 +00:00
|
|
|
if (vp->door_status & 1 && car->Damage.GetDoorStatus(DOOR_BONNET) != DOOR_STATUS_MISSING) {
|
2020-03-15 15:47:21 +00:00
|
|
|
car->Damage.SetDoorStatus(DOOR_BONNET, DOOR_STATUS_MISSING);
|
2019-07-06 17:44:00 +00:00
|
|
|
car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true);
|
2019-06-29 20:15:55 +00:00
|
|
|
}
|
2020-04-27 09:41:34 +00:00
|
|
|
if (vp->door_status & 2 && car->Damage.GetDoorStatus(DOOR_BOOT) != DOOR_STATUS_MISSING) {
|
2020-03-15 15:47:21 +00:00
|
|
|
car->Damage.SetDoorStatus(DOOR_BOOT, DOOR_STATUS_MISSING);
|
2019-07-06 17:44:00 +00:00
|
|
|
car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true);
|
2019-06-29 20:15:55 +00:00
|
|
|
}
|
2020-04-27 09:41:34 +00:00
|
|
|
if (vp->door_status & 4 && car->Damage.GetDoorStatus(DOOR_FRONT_LEFT) != DOOR_STATUS_MISSING) {
|
2020-03-15 15:47:21 +00:00
|
|
|
car->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_MISSING);
|
2019-07-06 17:44:00 +00:00
|
|
|
car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true);
|
2019-06-29 20:15:55 +00:00
|
|
|
}
|
2020-04-27 09:41:34 +00:00
|
|
|
if (vp->door_status & 8 && car->Damage.GetDoorStatus(DOOR_FRONT_RIGHT) != DOOR_STATUS_MISSING) {
|
2020-03-15 15:47:21 +00:00
|
|
|
car->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_MISSING);
|
2019-07-06 17:44:00 +00:00
|
|
|
car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true);
|
2019-06-29 20:15:55 +00:00
|
|
|
}
|
2020-04-27 09:41:34 +00:00
|
|
|
if (vp->door_status & 0x10 && car->Damage.GetDoorStatus(DOOR_REAR_LEFT) != DOOR_STATUS_MISSING) {
|
2020-03-15 15:47:21 +00:00
|
|
|
car->Damage.SetDoorStatus(DOOR_REAR_LEFT, DOOR_STATUS_MISSING);
|
2019-07-06 17:44:00 +00:00
|
|
|
car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true);
|
2019-06-29 20:15:55 +00:00
|
|
|
}
|
2020-04-27 09:41:34 +00:00
|
|
|
if (vp->door_status & 0x20 && car->Damage.GetDoorStatus(DOOR_REAR_RIGHT) != DOOR_STATUS_MISSING) {
|
2020-03-15 15:47:21 +00:00
|
|
|
car->Damage.SetDoorStatus(DOOR_REAR_RIGHT, DOOR_STATUS_MISSING);
|
2019-07-06 17:44:00 +00:00
|
|
|
car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true);
|
2019-06-29 20:15:55 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-26 18:10:23 +00:00
|
|
|
vehicle->bEngineOn = true;
|
|
|
|
if (vehicle->IsCar())
|
|
|
|
((CAutomobile*)vehicle)->m_nDriveWheelsOnGround = 4;
|
|
|
|
CWorld::Remove(vehicle);
|
|
|
|
CWorld::Add(vehicle);
|
|
|
|
if (vehicle->IsBoat())
|
|
|
|
((CBoat*)vehicle)->m_bIsAnchored = false;
|
|
|
|
vehicle->bRenderScorched = vp->render_scorched;
|
|
|
|
if (vehicle->GetModelIndex() == MI_SKIMMER)
|
|
|
|
((CBoat*)vehicle)->m_fMovingSpeed = vp->skimmer_speed / 50.0f;
|
2019-06-29 20:15:55 +00:00
|
|
|
}
|
|
|
|
|
2020-09-26 18:10:23 +00:00
|
|
|
void CReplay::ProcessBikeUpdate(CVehicle* vehicle, float interpolation, CAddressInReplayBuffer* buffer)
|
|
|
|
{
|
|
|
|
CBike* bike = (CBike*)vehicle;
|
|
|
|
tBikeUpdatePacket* vp = (tBikeUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
|
|
|
|
if (!vehicle) {
|
|
|
|
printf("Replay:Car wasn't there");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CMatrix vehicle_matrix;
|
|
|
|
vp->matrix.DecompressIntoFullMatrix(vehicle_matrix);
|
|
|
|
vehicle->GetMatrix() = vehicle->GetMatrix() * CMatrix(1.0f - interpolation);
|
|
|
|
vehicle->GetMatrix().GetPosition() *= (1.0f - interpolation);
|
|
|
|
vehicle->GetMatrix() += CMatrix(interpolation) * vehicle_matrix;
|
|
|
|
vehicle->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
vehicle->m_fHealth = 4 * vp->health;
|
|
|
|
vehicle->m_fGasPedal = vp->acceleration / 100.0f;
|
|
|
|
vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f);
|
|
|
|
vehicle->m_fSteerAngle = vp->wheel_state / 50.0f;
|
|
|
|
vehicle->bEngineOn = true;
|
2020-12-26 09:56:20 +00:00
|
|
|
#ifdef FIX_BUGS
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
bike->m_aWheelRotation[i] = vp->wheel_rotation[i] / (128.0f / PI);
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
bike->m_aWheelSpeed[i] = vp->wheel_rotation[i + 2] / (128.0f / PI);
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
bike->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
|
|
|
|
#else
|
2020-09-26 18:10:23 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
bike->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
|
|
|
|
bike->m_aWheelRotation[i] = vp->wheel_rotation[i] / (128.0f / PI);
|
|
|
|
}
|
2020-12-26 09:56:20 +00:00
|
|
|
#endif
|
2020-09-26 18:10:23 +00:00
|
|
|
bike->m_fLeanLRAngle = vp->lean_angle / 50.0f;
|
|
|
|
bike->m_fWheelAngle = vp->wheel_angle / 50.0f;
|
|
|
|
bike->bLeanMatrixClean = false;
|
|
|
|
bike->CalculateLeanMatrix();
|
|
|
|
CWorld::Remove(vehicle);
|
|
|
|
CWorld::Add(vehicle);
|
|
|
|
}
|
2019-06-30 10:59:55 +00:00
|
|
|
|
2020-09-26 18:10:23 +00:00
|
|
|
bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer)
|
|
|
|
{
|
2019-06-30 10:59:55 +00:00
|
|
|
CBulletTraces::Init();
|
|
|
|
float split = 1.0f - interpolation;
|
|
|
|
int ped_min_index = 0; /* Optimization due to peds and vehicles placed in buffer sequentially. */
|
|
|
|
int vehicle_min_index = 0; /* So next ped can't have pool index less than current. */
|
|
|
|
for(;;){
|
|
|
|
uint8* ptr = buffer->m_pBase;
|
|
|
|
uint32 offset = buffer->m_nOffset;
|
|
|
|
uint8 type = ptr[offset];
|
|
|
|
if (type == REPLAYPACKET_ENDOFFRAME)
|
|
|
|
break;
|
|
|
|
switch (type) {
|
|
|
|
case REPLAYPACKET_END:
|
|
|
|
{
|
|
|
|
int slot = buffer->m_bSlot;
|
|
|
|
if (BufferStatus[slot] == REPLAYBUFFER_RECORD) {
|
|
|
|
FinishPlayback();
|
|
|
|
return true;
|
|
|
|
}
|
2020-03-15 15:47:21 +00:00
|
|
|
buffer->m_bSlot = (slot + 1) % NUM_REPLAYBUFFERS;
|
2019-06-30 10:59:55 +00:00
|
|
|
buffer->m_nOffset = 0;
|
|
|
|
buffer->m_pBase = Buffers[buffer->m_bSlot];
|
|
|
|
ped_min_index = 0;
|
|
|
|
vehicle_min_index = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_VEHICLE:
|
|
|
|
{
|
|
|
|
tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&ptr[offset];
|
|
|
|
for (int i = vehicle_min_index; i < vp->index; i++) {
|
|
|
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
|
|
|
|
if (!v)
|
|
|
|
continue;
|
|
|
|
/* Removing vehicles not present in this frame. */
|
|
|
|
CWorld::Remove(v);
|
|
|
|
delete v;
|
|
|
|
}
|
|
|
|
vehicle_min_index = vp->index + 1;
|
|
|
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(vp->index);
|
|
|
|
CVehicle* new_v;
|
|
|
|
if (!v) {
|
|
|
|
int mi = vp->mi;
|
|
|
|
if (CStreaming::ms_aInfoForModel[mi].m_loadState != 1) {
|
|
|
|
CStreaming::RequestModel(mi, 0);
|
|
|
|
}
|
|
|
|
else {
|
2020-09-26 18:10:23 +00:00
|
|
|
switch (vp->vehicle_type) {
|
|
|
|
case VEHICLE_TYPE_CAR:
|
|
|
|
new_v = new(vp->index << 8) CAutomobile(mi, 2);
|
|
|
|
break;
|
|
|
|
case VEHICLE_TYPE_BOAT:
|
|
|
|
new_v = new(vp->index << 8) CBoat(mi, 2);
|
|
|
|
break;
|
|
|
|
case VEHICLE_TYPE_TRAIN:
|
2019-06-30 10:59:55 +00:00
|
|
|
new_v = new(vp->index << 8) CTrain(mi, 2);
|
2020-09-26 18:10:23 +00:00
|
|
|
break;
|
|
|
|
case VEHICLE_TYPE_HELI:
|
2019-06-30 10:59:55 +00:00
|
|
|
new_v = new(vp->index << 8) CHeli(mi, 2);
|
2020-09-26 18:10:23 +00:00
|
|
|
break;
|
|
|
|
case VEHICLE_TYPE_PLANE:
|
|
|
|
new_v = new(vp->index << 8) CPlane(mi, 2);
|
|
|
|
break;
|
|
|
|
case VEHICLE_TYPE_BIKE: // not possible
|
|
|
|
new_v = new(vp->index << 8) CBike(mi, 2);
|
|
|
|
break;
|
2019-06-30 10:59:55 +00:00
|
|
|
}
|
2020-04-30 13:45:45 +00:00
|
|
|
new_v->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
|
2019-06-30 10:59:55 +00:00
|
|
|
vp->matrix.DecompressIntoFullMatrix(new_v->GetMatrix());
|
|
|
|
new_v->m_currentColour1 = vp->primary_color;
|
|
|
|
new_v->m_currentColour2 = vp->secondary_color;
|
|
|
|
CWorld::Add(new_v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ProcessCarUpdate(CPools::GetVehiclePool()->GetSlot(vp->index), interpolation, buffer);
|
|
|
|
buffer->m_nOffset += sizeof(tVehicleUpdatePacket);
|
|
|
|
break;
|
|
|
|
}
|
2020-09-26 18:10:23 +00:00
|
|
|
case REPLAYPACKET_BIKE:
|
|
|
|
{
|
|
|
|
tBikeUpdatePacket* vp = (tBikeUpdatePacket*)&ptr[offset];
|
|
|
|
for (int i = vehicle_min_index; i < vp->index; i++) {
|
|
|
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
|
|
|
|
if (!v)
|
|
|
|
continue;
|
|
|
|
/* Removing vehicles not present in this frame. */
|
|
|
|
CWorld::Remove(v);
|
|
|
|
delete v;
|
|
|
|
}
|
|
|
|
vehicle_min_index = vp->index + 1;
|
|
|
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(vp->index);
|
|
|
|
CVehicle* new_v;
|
|
|
|
if (!v) {
|
|
|
|
int mi = vp->mi;
|
|
|
|
if (CStreaming::ms_aInfoForModel[mi].m_loadState != 1) {
|
|
|
|
CStreaming::RequestModel(mi, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
new_v = new(vp->index << 8) CBike(mi, 2);
|
|
|
|
new_v->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
|
|
|
|
vp->matrix.DecompressIntoFullMatrix(new_v->GetMatrix());
|
|
|
|
new_v->m_currentColour1 = vp->primary_color;
|
|
|
|
new_v->m_currentColour2 = vp->secondary_color;
|
|
|
|
CWorld::Add(new_v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ProcessBikeUpdate(CPools::GetVehiclePool()->GetSlot(vp->index), interpolation, buffer);
|
|
|
|
buffer->m_nOffset += sizeof(tBikeUpdatePacket);
|
|
|
|
break;
|
|
|
|
}
|
2019-06-30 10:59:55 +00:00
|
|
|
case REPLAYPACKET_PED_HEADER:
|
|
|
|
{
|
|
|
|
tPedHeaderPacket* ph = (tPedHeaderPacket*)&ptr[offset];
|
|
|
|
if (!CPools::GetPedPool()->GetSlot(ph->index)) {
|
2020-09-26 18:10:23 +00:00
|
|
|
if (!CStreaming::HasModelLoaded(ph->mi) || (ph->mi >= MI_SPECIAL01 && ph->mi < MI_LAST_PED)) {
|
2019-06-30 10:59:55 +00:00
|
|
|
CStreaming::RequestModel(ph->mi, 0);
|
|
|
|
}
|
|
|
|
else {
|
2020-09-26 18:10:23 +00:00
|
|
|
CPed* new_p;
|
|
|
|
if (ph->pedtype != PEDTYPE_PLAYER1)
|
|
|
|
new_p = new(ph->index << 8) CCivilianPed((ePedType)ph->pedtype, ph->mi);
|
|
|
|
else
|
|
|
|
new_p = new(ph->index << 8) CPlayerPed();
|
2020-04-30 13:45:45 +00:00
|
|
|
new_p->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
|
2019-06-30 10:59:55 +00:00
|
|
|
new_p->GetMatrix().SetUnity();
|
|
|
|
CWorld::Add(new_p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buffer->m_nOffset += sizeof(tPedHeaderPacket);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_PED_UPDATE:
|
|
|
|
{
|
|
|
|
tPedUpdatePacket* pu = (tPedUpdatePacket*)&ptr[offset];
|
|
|
|
for (int i = ped_min_index; i < pu->index; i++) {
|
|
|
|
CPed* p = CPools::GetPedPool()->GetSlot(i);
|
|
|
|
if (!p)
|
|
|
|
continue;
|
|
|
|
/* Removing peds not present in this frame. */
|
|
|
|
CWorld::Remove(p);
|
|
|
|
delete p;
|
|
|
|
}
|
|
|
|
ped_min_index = pu->index + 1;
|
|
|
|
ProcessPedUpdate(CPools::GetPedPool()->GetSlot(pu->index), interpolation, buffer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_GENERAL:
|
|
|
|
{
|
|
|
|
tGeneralPacket* pg = (tGeneralPacket*)&ptr[offset];
|
|
|
|
TheCamera.GetMatrix() = TheCamera.GetMatrix() * CMatrix(split);
|
2019-07-08 15:07:34 +00:00
|
|
|
TheCamera.GetMatrix().GetPosition() *= split;
|
2019-06-30 10:59:55 +00:00
|
|
|
TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos;
|
2019-06-30 20:29:53 +00:00
|
|
|
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
|
2020-05-05 01:45:18 +00:00
|
|
|
pm->pos = TheCamera.GetPosition();
|
|
|
|
pm->at = TheCamera.GetForward();
|
|
|
|
pm->up = TheCamera.GetUp();
|
|
|
|
pm->right = TheCamera.GetRight();
|
2019-06-30 10:59:55 +00:00
|
|
|
CameraFocusX = split * CameraFocusX + interpolation * pg->player_pos.x;
|
|
|
|
CameraFocusY = split * CameraFocusY + interpolation * pg->player_pos.y;
|
|
|
|
CameraFocusZ = split * CameraFocusZ + interpolation * pg->player_pos.z;
|
|
|
|
bPlayerInRCBuggy = pg->in_rcvehicle;
|
|
|
|
buffer->m_nOffset += sizeof(tGeneralPacket);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_CLOCK:
|
|
|
|
{
|
|
|
|
tClockPacket* pc = (tClockPacket*)&ptr[offset];
|
|
|
|
CClock::SetGameClock(pc->hours, pc->minutes);
|
|
|
|
buffer->m_nOffset += sizeof(tClockPacket);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_WEATHER:
|
|
|
|
{
|
|
|
|
tWeatherPacket* pw = (tWeatherPacket*)&ptr[offset];
|
|
|
|
CWeather::OldWeatherType = pw->old_weather;
|
|
|
|
CWeather::NewWeatherType = pw->new_weather;
|
|
|
|
CWeather::InterpolationValue = pw->interpolation;
|
|
|
|
buffer->m_nOffset += sizeof(tWeatherPacket);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_ENDOFFRAME:
|
|
|
|
{
|
|
|
|
/* Not supposed to be here. */
|
2020-03-15 15:47:21 +00:00
|
|
|
assert(false);
|
2019-06-30 10:59:55 +00:00
|
|
|
buffer->m_nOffset++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_TIMER:
|
|
|
|
{
|
|
|
|
tTimerPacket* pt = (tTimerPacket*)&ptr[offset];
|
|
|
|
if (pTimer)
|
|
|
|
*pTimer = pt->timer;
|
|
|
|
CTimer::SetTimeInMilliseconds(pt->timer);
|
|
|
|
buffer->m_nOffset += sizeof(tTimerPacket);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_BULLET_TRACES:
|
|
|
|
{
|
|
|
|
tBulletTracePacket* pb = (tBulletTracePacket*)&ptr[offset];
|
|
|
|
CBulletTraces::aTraces[pb->index].m_bInUse = true;
|
2020-10-15 12:42:10 +00:00
|
|
|
CBulletTraces::aTraces[pb->index].m_vecStartPos = pb->inf;
|
|
|
|
CBulletTraces::aTraces[pb->index].m_vecEndPos = pb->sup;
|
2019-06-30 10:59:55 +00:00
|
|
|
buffer->m_nOffset += sizeof(tBulletTracePacket);
|
2020-09-26 18:10:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_PARTICLE:
|
|
|
|
{
|
|
|
|
tParticlePacket* pp = (tParticlePacket*)&ptr[offset];
|
|
|
|
CVector pos(pp->pos_x / 4.0f, pp->pos_y / 4.0f, pp->pos_z / 4.0f);
|
|
|
|
CVector dir(pp->dir_x / 120.0f, pp->dir_y / 120.0f, pp->dir_z / 120.0f);
|
|
|
|
RwRGBA color;
|
|
|
|
color.red = pp->r;
|
|
|
|
color.green = pp->g;
|
|
|
|
color.blue = pp->b;
|
|
|
|
color.alpha = pp->a;
|
|
|
|
CParticle::AddParticle((tParticleType)pp->particle_type, pos, dir, nil, pp->size, color);
|
|
|
|
buffer->m_nOffset += sizeof(tParticlePacket);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPLAYPACKET_MISC:
|
|
|
|
{
|
|
|
|
tMiscPacket* pm = (tMiscPacket*)&ptr[offset];
|
|
|
|
TheCamera.m_uiCamShakeStart = pm->cam_shake_start;
|
|
|
|
TheCamera.m_fCamShakeForce = pm->cam_shake_strength;
|
2020-11-01 15:21:05 +00:00
|
|
|
CSpecialFX::bVideoCam = pm->video_cam;
|
|
|
|
CSpecialFX::bLiftCam = pm->lift_cam;
|
2020-09-26 18:10:23 +00:00
|
|
|
CGame::currArea = pm->cur_area;
|
|
|
|
buffer->m_nOffset += sizeof(tMiscPacket);
|
|
|
|
break;
|
2019-06-30 10:59:55 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buffer->m_nOffset += 4;
|
|
|
|
for (int i = vehicle_min_index; i < CPools::GetVehiclePool()->GetSize(); i++) {
|
|
|
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
|
|
|
|
if (!v)
|
|
|
|
continue;
|
|
|
|
/* Removing vehicles not present in this frame. */
|
|
|
|
CWorld::Remove(v);
|
|
|
|
delete v;
|
|
|
|
}
|
|
|
|
for (int i = ped_min_index; i < CPools::GetPedPool()->GetSize(); i++) {
|
|
|
|
CPed* p = CPools::GetPedPool()->GetSlot(i);
|
|
|
|
if (!p)
|
|
|
|
continue;
|
|
|
|
/* Removing peds not present in this frame. */
|
|
|
|
CWorld::Remove(p);
|
|
|
|
delete p;
|
|
|
|
}
|
|
|
|
ProcessReplayCamera();
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-29 05:54:34 +00:00
|
|
|
|
2019-06-30 10:59:55 +00:00
|
|
|
void CReplay::FinishPlayback(void)
|
|
|
|
{
|
|
|
|
if (Mode != MODE_PLAYBACK)
|
|
|
|
return;
|
|
|
|
EmptyAllPools();
|
|
|
|
RestoreStuffFromMem();
|
|
|
|
Mode = MODE_RECORD;
|
|
|
|
if (bDoLoadSceneWhenDone){
|
|
|
|
CVector v_ls(LoadSceneX, LoadSceneY, LoadSceneZ);
|
2020-05-06 10:23:57 +00:00
|
|
|
CGame::currLevel = CTheZones::GetLevelFromPosition(&v_ls);
|
2019-06-30 10:59:55 +00:00
|
|
|
CCollision::SortOutCollisionAfterLoad();
|
|
|
|
CStreaming::LoadScene(v_ls);
|
|
|
|
}
|
|
|
|
bDoLoadSceneWhenDone = false;
|
|
|
|
if (bPlayingBackFromFile){
|
|
|
|
Init();
|
|
|
|
MarkEverythingAsNew();
|
|
|
|
}
|
|
|
|
DMAudio.SetEffectsFadeVol(127);
|
|
|
|
DMAudio.SetMusicFadeVol(127);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::EmptyReplayBuffer(void)
|
|
|
|
{
|
|
|
|
if (Mode == MODE_PLAYBACK)
|
|
|
|
return;
|
2019-09-14 17:53:04 +00:00
|
|
|
Record.m_nOffset = 0;
|
2020-03-15 15:47:21 +00:00
|
|
|
for (int i = 0; i < NUM_REPLAYBUFFERS; i++){
|
2019-06-30 10:59:55 +00:00
|
|
|
BufferStatus[i] = REPLAYBUFFER_UNUSED;
|
|
|
|
}
|
|
|
|
Record.m_bSlot = 0;
|
|
|
|
Record.m_pBase = Buffers[0];
|
|
|
|
BufferStatus[0] = REPLAYBUFFER_RECORD;
|
|
|
|
Record.m_pBase[Record.m_nOffset] = 0;
|
|
|
|
MarkEverythingAsNew();
|
|
|
|
}
|
|
|
|
|
2019-06-30 16:22:44 +00:00
|
|
|
void CReplay::ProcessReplayCamera(void)
|
|
|
|
{
|
|
|
|
switch (CameraMode) {
|
|
|
|
case REPLAYCAMMODE_TOPDOWN:
|
2019-06-30 20:29:53 +00:00
|
|
|
{
|
2020-04-30 10:48:01 +00:00
|
|
|
TheCamera.SetPosition(CameraFocusX, CameraFocusY, CameraFocusZ + 15.0f);
|
2019-07-20 13:18:56 +00:00
|
|
|
TheCamera.GetForward() = CVector(0.0f, 0.0f, -1.0f);
|
|
|
|
TheCamera.GetUp() = CVector(0.0f, 1.0f, 0.0f);
|
|
|
|
TheCamera.GetRight() = CVector(1.0f, 0.0f, 0.0f);
|
2019-06-30 20:29:53 +00:00
|
|
|
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
|
2020-12-18 00:58:09 +00:00
|
|
|
pm->pos = TheCamera.GetPosition();
|
|
|
|
pm->at = TheCamera.GetForward();
|
|
|
|
pm->up = TheCamera.GetUp();
|
|
|
|
pm->right = TheCamera.GetRight();
|
2019-06-30 16:22:44 +00:00
|
|
|
break;
|
2019-06-30 20:29:53 +00:00
|
|
|
}
|
2019-06-30 16:22:44 +00:00
|
|
|
case REPLAYCAMMODE_FIXED:
|
2019-06-30 20:29:53 +00:00
|
|
|
{
|
2019-07-08 15:07:34 +00:00
|
|
|
TheCamera.GetMatrix().GetPosition() = CVector(CameraFixedX, CameraFixedY, CameraFixedZ);
|
2019-06-30 16:22:44 +00:00
|
|
|
CVector forward(CameraFocusX - CameraFixedX, CameraFocusY - CameraFixedY, CameraFocusZ - CameraFixedZ);
|
|
|
|
forward.Normalise();
|
|
|
|
CVector right = CrossProduct(CVector(0.0f, 0.0f, 1.0f), forward);
|
|
|
|
right.Normalise();
|
|
|
|
CVector up = CrossProduct(forward, right);
|
|
|
|
up.Normalise();
|
2019-07-08 15:07:34 +00:00
|
|
|
TheCamera.GetMatrix().GetForward() = forward;
|
|
|
|
TheCamera.GetMatrix().GetUp() = up;
|
|
|
|
TheCamera.GetMatrix().GetRight() = right;
|
2019-06-30 20:29:53 +00:00
|
|
|
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
|
2020-12-18 00:58:09 +00:00
|
|
|
pm->pos = TheCamera.GetMatrix().GetPosition();
|
|
|
|
pm->at = TheCamera.GetMatrix().GetForward();
|
|
|
|
pm->up = TheCamera.GetMatrix().GetUp();
|
|
|
|
pm->right = TheCamera.GetMatrix().GetRight();
|
2019-06-30 16:22:44 +00:00
|
|
|
break;
|
2019-06-30 20:29:53 +00:00
|
|
|
}
|
2019-06-30 16:22:44 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-07-08 19:37:47 +00:00
|
|
|
TheCamera.m_vecGameCamPos = TheCamera.GetMatrix().GetPosition();
|
2019-06-30 16:22:44 +00:00
|
|
|
TheCamera.CalculateDerivedValues();
|
|
|
|
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
|
|
|
|
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
|
|
|
|
}
|
2019-06-24 22:42:23 +00:00
|
|
|
|
2020-09-26 18:10:23 +00:00
|
|
|
extern CWeaponEffects gCrossHair;
|
|
|
|
|
2019-06-24 22:42:23 +00:00
|
|
|
void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene)
|
|
|
|
{
|
|
|
|
if (Mode != MODE_RECORD)
|
|
|
|
return;
|
|
|
|
CameraFixedX = cam_x;
|
|
|
|
CameraFixedY = cam_y;
|
|
|
|
CameraFixedZ = cam_z;
|
|
|
|
Mode = MODE_PLAYBACK;
|
|
|
|
FramesActiveLookAroundCam = 0;
|
|
|
|
CameraMode = cam_mode;
|
|
|
|
bAllowLookAroundCam = true;
|
|
|
|
bPlayingBackFromFile = false;
|
|
|
|
OldRadioStation = DMAudio.GetRadioInCar();
|
2019-10-26 12:20:12 +00:00
|
|
|
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
|
2019-06-24 22:42:23 +00:00
|
|
|
DMAudio.SetEffectsFadeVol(0);
|
|
|
|
DMAudio.SetMusicFadeVol(0);
|
2020-09-26 18:10:23 +00:00
|
|
|
CEscalators::Shutdown();
|
2020-10-09 12:53:22 +00:00
|
|
|
CWaterCreatures::RemoveAll();
|
2019-06-24 22:42:23 +00:00
|
|
|
int current;
|
2020-03-15 15:47:21 +00:00
|
|
|
for (current = 0; current < NUM_REPLAYBUFFERS; current++)
|
2019-06-24 22:42:23 +00:00
|
|
|
if (BufferStatus[current] == REPLAYBUFFER_RECORD)
|
|
|
|
break;
|
|
|
|
int first;
|
2020-03-15 15:47:21 +00:00
|
|
|
for (first = (current + 1) % NUM_REPLAYBUFFERS; ; first = (first + 1) % NUM_REPLAYBUFFERS)
|
2019-06-24 22:42:23 +00:00
|
|
|
if (BufferStatus[first] == REPLAYBUFFER_RECORD || BufferStatus[first] == REPLAYBUFFER_PLAYBACK)
|
|
|
|
break;
|
|
|
|
Playback.m_bSlot = first;
|
|
|
|
Playback.m_nOffset = 0;
|
|
|
|
Playback.m_pBase = Buffers[first];
|
2020-04-16 18:46:08 +00:00
|
|
|
CObject::DeleteAllTempObjectsInArea(CVector(0.0f, 0.0f, 0.0f), 1000000.0f);
|
2019-06-24 22:42:23 +00:00
|
|
|
StoreStuffInMem();
|
|
|
|
EmptyPedsAndVehiclePools();
|
|
|
|
SlowMotion = 1;
|
|
|
|
CSkidmarks::Clear();
|
|
|
|
StreamAllNecessaryCarsAndPeds();
|
|
|
|
if (load_scene)
|
|
|
|
bDoLoadSceneWhenDone = false;
|
|
|
|
else{
|
|
|
|
bDoLoadSceneWhenDone = true;
|
|
|
|
LoadSceneX = TheCamera.GetPosition().x;
|
|
|
|
LoadSceneY = TheCamera.GetPosition().y;
|
|
|
|
LoadSceneZ = TheCamera.GetPosition().z;
|
|
|
|
CVector ff_coord;
|
|
|
|
FindFirstFocusCoordinate(&ff_coord);
|
2020-05-06 10:23:57 +00:00
|
|
|
CGame::currLevel = CTheZones::GetLevelFromPosition(&ff_coord);
|
2019-06-24 22:42:23 +00:00
|
|
|
CCollision::SortOutCollisionAfterLoad();
|
2019-06-26 22:12:58 +00:00
|
|
|
CStreaming::LoadScene(ff_coord);
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
|
|
|
if (cam_mode == REPLAYCAMMODE_ASSTORED)
|
2020-04-08 06:58:08 +00:00
|
|
|
TheCamera.CarZoomIndicator = CAM_ZOOM_CINEMATIC;
|
2020-09-26 18:10:23 +00:00
|
|
|
gCrossHair.m_bActive = false;
|
|
|
|
CExplosion::ClearAllExplosions();
|
|
|
|
CPlaneBanners::Init();
|
|
|
|
#ifndef FIX_BUGS // this doesn't do anything useful and accesses destroyed player ped
|
|
|
|
TheCamera.Restore();
|
|
|
|
#endif
|
|
|
|
CDraw::SetFOV(70.0f);
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::StoreStuffInMem(void)
|
|
|
|
{
|
2020-04-18 20:50:37 +00:00
|
|
|
#ifdef FIX_BUGS
|
|
|
|
for (int i = 0; i < NUMPLAYERS; i++)
|
|
|
|
nHandleOfPlayerPed[i] = CPools::GetPedPool()->GetIndex(CWorld::Players[i].m_pPed);
|
|
|
|
#endif
|
2020-05-16 10:31:23 +00:00
|
|
|
int i = CPools::GetPedPool()->GetSize();
|
|
|
|
while (--i >= 0) {
|
|
|
|
CPed* ped = CPools::GetPedPool()->GetSlot(i);
|
|
|
|
if (!ped)
|
|
|
|
continue;
|
|
|
|
if (ped->m_attractor)
|
|
|
|
GetPedAttractorManager()->DeRegisterPed(ped, ped->m_attractor);
|
|
|
|
}
|
2019-06-24 22:42:23 +00:00
|
|
|
CPools::GetVehiclePool()->Store(pBuf0, pBuf1);
|
|
|
|
CPools::GetPedPool()->Store(pBuf2, pBuf3);
|
|
|
|
CPools::GetObjectPool()->Store(pBuf4, pBuf5);
|
|
|
|
CPools::GetPtrNodePool()->Store(pBuf6, pBuf7);
|
|
|
|
CPools::GetEntryInfoNodePool()->Store(pBuf8, pBuf9);
|
|
|
|
CPools::GetDummyPool()->Store(pBuf10, pBuf11);
|
2019-06-30 13:20:11 +00:00
|
|
|
pWorld1 = new uint8[sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y];
|
2019-06-24 22:42:23 +00:00
|
|
|
memcpy(pWorld1, CWorld::GetSector(0, 0), NUMSECTORS_X * NUMSECTORS_Y * sizeof(CSector));
|
2020-04-18 20:50:37 +00:00
|
|
|
WorldPtrList = CWorld::GetMovingEntityList().first; // why
|
2020-07-13 14:43:09 +00:00
|
|
|
BigBuildingPtrList = CWorld::GetBigBuildingList(LEVEL_GENERIC).first;
|
2019-06-30 13:20:11 +00:00
|
|
|
pPickups = new uint8[sizeof(CPickup) * NUMPICKUPS];
|
2019-06-24 22:42:23 +00:00
|
|
|
memcpy(pPickups, CPickups::aPickUps, NUMPICKUPS * sizeof(CPickup));
|
2019-06-30 13:20:11 +00:00
|
|
|
pReferences = new uint8[(sizeof(CReference) * NUMREFERENCES)];
|
2019-06-24 22:42:23 +00:00
|
|
|
memcpy(pReferences, CReferences::aRefs, NUMREFERENCES * sizeof(CReference));
|
|
|
|
pEmptyReferences = CReferences::pEmptyList;
|
2019-06-30 13:20:11 +00:00
|
|
|
pStoredCam = new uint8[sizeof(CCamera)];
|
2019-06-24 22:42:23 +00:00
|
|
|
memcpy(pStoredCam, &TheCamera, sizeof(CCamera));
|
2020-04-09 03:20:44 +00:00
|
|
|
pRadarBlips = new uint8[sizeof(sRadarTrace) * NUMRADARBLIPS];
|
|
|
|
memcpy(pRadarBlips, CRadar::ms_RadarTrace, NUMRADARBLIPS * sizeof(sRadarTrace));
|
2019-06-24 22:42:23 +00:00
|
|
|
PlayerWanted = *FindPlayerPed()->m_pWanted;
|
|
|
|
PlayerInfo = CWorld::Players[0];
|
|
|
|
Time1 = CTimer::GetTimeInMilliseconds();
|
|
|
|
Time2 = CTimer::GetTimeInMillisecondsNonClipped();
|
|
|
|
Time3 = CTimer::GetPreviousTimeInMilliseconds();
|
|
|
|
Time4 = CTimer::GetTimeInMillisecondsPauseMode();
|
|
|
|
Frame = CTimer::GetFrameCounter();
|
|
|
|
ClockHours = CClock::GetHours();
|
|
|
|
ClockMinutes = CClock::GetMinutes();
|
|
|
|
OldWeatherType = CWeather::OldWeatherType;
|
|
|
|
NewWeatherType = CWeather::NewWeatherType;
|
|
|
|
WeatherInterpolationValue = CWeather::InterpolationValue;
|
2020-09-26 18:10:23 +00:00
|
|
|
CurrArea = CGame::currArea;
|
2019-06-24 22:42:23 +00:00
|
|
|
TimeStepNonClipped = CTimer::GetTimeStepNonClipped();
|
|
|
|
TimeStep = CTimer::GetTimeStep();
|
|
|
|
TimeScale = CTimer::GetTimeScale();
|
2020-09-26 18:10:23 +00:00
|
|
|
ms_nNumCivMale_Stored = CPopulation::ms_nNumCivMale;
|
|
|
|
ms_nNumCivFemale_Stored = CPopulation::ms_nNumCivFemale;
|
|
|
|
ms_nNumCop_Stored = CPopulation::ms_nNumCop;
|
|
|
|
ms_nNumEmergency_Stored = CPopulation::ms_nNumEmergency;
|
|
|
|
ms_nNumGang1_Stored = CPopulation::ms_nNumGang1;
|
|
|
|
ms_nNumGang2_Stored = CPopulation::ms_nNumGang2;
|
|
|
|
ms_nNumGang3_Stored = CPopulation::ms_nNumGang3;
|
|
|
|
ms_nNumGang4_Stored = CPopulation::ms_nNumGang4;
|
|
|
|
ms_nNumGang5_Stored = CPopulation::ms_nNumGang5;
|
|
|
|
ms_nNumGang6_Stored = CPopulation::ms_nNumGang6;
|
|
|
|
ms_nNumGang7_Stored = CPopulation::ms_nNumGang7;
|
|
|
|
ms_nNumGang8_Stored = CPopulation::ms_nNumGang8;
|
|
|
|
ms_nNumGang9_Stored = CPopulation::ms_nNumGang9;
|
|
|
|
ms_nNumDummy_Stored = CPopulation::ms_nNumDummy;
|
|
|
|
ms_nTotalCivPeds_Stored = CPopulation::ms_nTotalCivPeds;
|
|
|
|
ms_nTotalGangPeds_Stored = CPopulation::ms_nTotalGangPeds;
|
|
|
|
ms_nTotalPeds_Stored = CPopulation::ms_nTotalPeds;
|
|
|
|
ms_nTotalMissionPeds_Stored = CPopulation::ms_nTotalMissionPeds;
|
2019-06-24 22:42:23 +00:00
|
|
|
int size = CPools::GetPedPool()->GetSize();
|
2019-07-20 13:18:56 +00:00
|
|
|
pPedAnims = new CStoredDetailedAnimationState[size];
|
2019-06-24 22:42:23 +00:00
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
CPed* ped = CPools::GetPedPool()->GetSlot(i);
|
|
|
|
if (ped)
|
|
|
|
StoreDetailedPedAnimation(ped, &pPedAnims[i]);
|
|
|
|
}
|
2020-09-26 18:10:23 +00:00
|
|
|
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));
|
2020-08-19 18:11:19 +00:00
|
|
|
CScriptPaths::Save_ForReplay();
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::RestoreStuffFromMem(void)
|
|
|
|
{
|
|
|
|
CPools::GetVehiclePool()->CopyBack(pBuf0, pBuf1);
|
|
|
|
CPools::GetPedPool()->CopyBack(pBuf2, pBuf3);
|
|
|
|
CPools::GetObjectPool()->CopyBack(pBuf4, pBuf5);
|
|
|
|
CPools::GetPtrNodePool()->CopyBack(pBuf6, pBuf7);
|
|
|
|
CPools::GetEntryInfoNodePool()->CopyBack(pBuf8, pBuf9);
|
|
|
|
CPools::GetDummyPool()->CopyBack(pBuf10, pBuf11);
|
|
|
|
memcpy(CWorld::GetSector(0, 0), pWorld1, sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y);
|
2019-06-30 13:20:11 +00:00
|
|
|
delete[] pWorld1;
|
2019-06-24 22:42:23 +00:00
|
|
|
pWorld1 = nil;
|
2020-04-18 20:50:37 +00:00
|
|
|
CWorld::GetMovingEntityList().first = WorldPtrList;
|
2020-07-13 14:43:09 +00:00
|
|
|
CWorld::GetBigBuildingList(LEVEL_GENERIC).first = BigBuildingPtrList;
|
2019-06-24 22:42:23 +00:00
|
|
|
memcpy(CPickups::aPickUps, pPickups, sizeof(CPickup) * NUMPICKUPS);
|
2019-06-30 13:20:11 +00:00
|
|
|
delete[] pPickups;
|
2019-06-24 22:42:23 +00:00
|
|
|
pPickups = nil;
|
|
|
|
memcpy(CReferences::aRefs, pReferences, sizeof(CReference) * NUMREFERENCES);
|
2019-06-30 13:20:11 +00:00
|
|
|
delete[] pReferences;
|
2019-06-24 22:42:23 +00:00
|
|
|
pReferences = nil;
|
|
|
|
CReferences::pEmptyList = pEmptyReferences;
|
|
|
|
pEmptyReferences = nil;
|
|
|
|
memcpy(&TheCamera, pStoredCam, sizeof(CCamera));
|
2019-06-30 13:20:11 +00:00
|
|
|
delete[] pStoredCam;
|
2019-06-24 22:42:23 +00:00
|
|
|
pStoredCam = nil;
|
2020-04-09 03:20:44 +00:00
|
|
|
memcpy(CRadar::ms_RadarTrace, pRadarBlips, sizeof(sRadarTrace) * NUMRADARBLIPS);
|
2019-06-30 13:20:11 +00:00
|
|
|
delete[] pRadarBlips;
|
2019-06-24 22:42:23 +00:00
|
|
|
pRadarBlips = nil;
|
2020-04-18 20:50:37 +00:00
|
|
|
#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
|
2020-03-15 15:47:21 +00:00
|
|
|
FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted);
|
2019-06-24 22:42:23 +00:00
|
|
|
CWorld::Players[0] = PlayerInfo;
|
2019-06-30 13:20:11 +00:00
|
|
|
int i = CPools::GetPedPool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-24 22:42:23 +00:00
|
|
|
CPed* ped = CPools::GetPedPool()->GetSlot(i);
|
|
|
|
if (!ped)
|
|
|
|
continue;
|
|
|
|
int mi = ped->GetModelIndex();
|
|
|
|
CStreaming::RequestModel(mi, 0);
|
|
|
|
CStreaming::LoadAllRequestedModels(false);
|
|
|
|
ped->m_rwObject = nil;
|
|
|
|
ped->m_modelIndex = -1;
|
|
|
|
ped->SetModelIndex(mi);
|
2020-12-12 20:05:12 +00:00
|
|
|
ped->m_pVehicleAnim = nil;
|
2019-08-15 01:43:00 +00:00
|
|
|
ped->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, ped);
|
2019-06-29 09:09:33 +00:00
|
|
|
DMAudio.SetEntityStatus(ped->m_audioEntityId, true);
|
2020-02-16 02:15:58 +00:00
|
|
|
CPopulation::UpdatePedCount((ePedType)ped->m_nPedType, false);
|
2020-05-16 14:00:40 +00:00
|
|
|
for (int j = 0; j < TOTAL_WEAPON_SLOTS; j++) {
|
|
|
|
int mi1 = CWeaponInfo::GetWeaponInfo(ped->m_weapons[j].m_eWeaponType)->m_nModelId;
|
|
|
|
if (mi1 != -1)
|
|
|
|
CStreaming::RequestModel(mi1, STREAMFLAGS_DEPENDENCY);
|
|
|
|
int mi2 = CWeaponInfo::GetWeaponInfo(ped->m_weapons[j].m_eWeaponType)->m_nModel2Id;
|
|
|
|
if (mi2 != -1)
|
|
|
|
CStreaming::RequestModel(mi2, STREAMFLAGS_DEPENDENCY);
|
|
|
|
CStreaming::LoadAllRequestedModels(false);
|
|
|
|
ped->m_weapons[j].Initialise(ped->m_weapons[j].m_eWeaponType, ped->m_weapons[j].m_nAmmoTotal);
|
|
|
|
}
|
2020-09-26 18:10:23 +00:00
|
|
|
if (ped->m_wepModelID >= 0) {
|
|
|
|
ped->m_pWeaponModel = nil;
|
|
|
|
if (ped->IsPlayer())
|
|
|
|
((CPlayerPed*)ped)->m_pMinigunTopAtomic = nil;
|
2019-06-24 22:42:23 +00:00
|
|
|
ped->AddWeaponModel(ped->m_wepModelID);
|
2020-09-26 18:10:23 +00:00
|
|
|
}
|
|
|
|
if (ped->m_nPedType == PEDTYPE_COP)
|
|
|
|
((CCopPed*)ped)->m_pStinger = new CStinger;
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
2019-06-30 13:20:11 +00:00
|
|
|
i = CPools::GetVehiclePool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-24 22:42:23 +00:00
|
|
|
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
|
|
|
|
if (!vehicle)
|
|
|
|
continue;
|
|
|
|
int mi = vehicle->GetModelIndex();
|
|
|
|
CStreaming::RequestModel(mi, 0);
|
|
|
|
CStreaming::LoadAllRequestedModels(false);
|
|
|
|
vehicle->m_rwObject = nil;
|
|
|
|
vehicle->m_modelIndex = -1;
|
|
|
|
vehicle->SetModelIndex(mi);
|
2020-09-26 18:10:23 +00:00
|
|
|
if (vehicle->IsCar()) {
|
|
|
|
CAutomobile* car = (CAutomobile*)vehicle;
|
|
|
|
if (mi == MI_DODO) {
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_LF]), 0);
|
|
|
|
CMatrix tmp1;
|
|
|
|
tmp1.Attach(RwFrameGetMatrix(car->m_aCarNodes[CAR_WHEEL_RF]), false);
|
|
|
|
CMatrix tmp2(RwFrameGetMatrix(car->m_aCarNodes[CAR_WHEEL_LF]), false);
|
|
|
|
tmp1.GetPosition() += CVector(tmp2.GetPosition().x + 0.1f, 0.0f, tmp2.GetPosition().z);
|
|
|
|
tmp1.UpdateRW();
|
|
|
|
}
|
|
|
|
else if (mi == MI_HUNTER) {
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_LB]), 0);
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_RB]), 0);
|
|
|
|
}
|
|
|
|
else if (vehicle->IsRealHeli()) {
|
2021-01-03 20:36:32 +00:00
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_LF]), 0);
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_RF]), 0);
|
2020-09-26 18:10:23 +00:00
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_LB]), 0);
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_RB]), 0);
|
|
|
|
}
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
|
|
|
if (vehicle->IsCar()){
|
|
|
|
CAutomobile* car = (CAutomobile*)vehicle;
|
2019-07-06 17:44:00 +00:00
|
|
|
int32 panels = car->Damage.m_panelStatus;
|
|
|
|
car->Damage.m_panelStatus = 0;
|
2019-06-24 22:42:23 +00:00
|
|
|
ApplyPanelDamageToCar(panels, car, true);
|
2019-07-06 17:44:00 +00:00
|
|
|
car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true);
|
|
|
|
car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true);
|
|
|
|
car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true);
|
|
|
|
car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true);
|
|
|
|
car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true);
|
|
|
|
car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true);
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
2019-08-15 01:43:00 +00:00
|
|
|
vehicle->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, vehicle);
|
2019-06-29 09:09:33 +00:00
|
|
|
DMAudio.SetEntityStatus(vehicle->m_audioEntityId, true);
|
2019-06-24 22:42:23 +00:00
|
|
|
CCarCtrl::UpdateCarCount(vehicle, false);
|
|
|
|
if ((mi == MI_AIRTRAIN || mi == MI_DEADDODO) && vehicle->m_rwObject){
|
|
|
|
CVehicleModelInfo* info = (CVehicleModelInfo*)CModelInfo::GetModelInfo(mi);
|
|
|
|
if (RwObjectGetType(vehicle->m_rwObject) == rpATOMIC){
|
|
|
|
vehicle->GetMatrix().Detach();
|
|
|
|
if (vehicle->m_rwObject){
|
|
|
|
if (RwObjectGetType(vehicle->m_rwObject) == rpATOMIC){
|
2020-04-15 12:05:24 +00:00
|
|
|
RwFrame* frame = RpAtomicGetFrame((RpAtomic*)vehicle->m_rwObject);
|
2019-06-24 22:42:23 +00:00
|
|
|
RpAtomicDestroy((RpAtomic*)vehicle->m_rwObject);
|
|
|
|
RwFrameDestroy(frame);
|
|
|
|
}
|
|
|
|
vehicle->m_rwObject = nil;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
vehicle->DeleteRwObject();
|
|
|
|
int model_id = info->m_wheelId;
|
|
|
|
if (model_id != -1){
|
|
|
|
if ((vehicle->m_rwObject = CModelInfo::GetModelInfo(model_id)->CreateInstance())){
|
2020-04-15 12:05:24 +00:00
|
|
|
vehicle->GetMatrix().AttachRW(RwFrameGetMatrix(RpClumpGetFrame((RpClump*)vehicle->m_rwObject)), false);
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PrintElementsInPtrList();
|
2019-06-30 13:20:11 +00:00
|
|
|
i = CPools::GetObjectPool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-24 22:42:23 +00:00
|
|
|
CObject* object = CPools::GetObjectPool()->GetSlot(i);
|
|
|
|
if (!object)
|
|
|
|
continue;
|
|
|
|
int mi = object->GetModelIndex();
|
|
|
|
object->m_rwObject = nil;
|
|
|
|
object->m_modelIndex = -1;
|
2020-09-26 18:10:23 +00:00
|
|
|
object->SetModelIndexNoCreate(mi);
|
2019-06-24 22:42:23 +00:00
|
|
|
object->GetMatrix().m_attachment = nil;
|
|
|
|
}
|
2019-06-30 13:20:11 +00:00
|
|
|
i = CPools::GetDummyPool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-24 22:42:23 +00:00
|
|
|
CDummy* dummy = CPools::GetDummyPool()->GetSlot(i);
|
|
|
|
if (!dummy)
|
|
|
|
continue;
|
|
|
|
int mi = dummy->GetModelIndex();
|
|
|
|
dummy->m_rwObject = nil;
|
|
|
|
dummy->m_modelIndex = -1;
|
2020-09-26 18:10:23 +00:00
|
|
|
dummy->SetModelIndexNoCreate(mi);
|
2019-06-24 22:42:23 +00:00
|
|
|
dummy->GetMatrix().m_attachment = nil;
|
|
|
|
}
|
2020-09-26 18:10:23 +00:00
|
|
|
++ClockMinutes;
|
2019-06-24 22:42:23 +00:00
|
|
|
CTimer::SetTimeInMilliseconds(Time1);
|
|
|
|
CTimer::SetTimeInMillisecondsNonClipped(Time2);
|
|
|
|
CTimer::SetPreviousTimeInMilliseconds(Time3);
|
|
|
|
CTimer::SetTimeInMillisecondsPauseMode(Time4);
|
|
|
|
CTimer::SetTimeScale(TimeScale);
|
|
|
|
CTimer::SetFrameCounter(Frame);
|
|
|
|
CTimer::SetTimeStep(TimeStep);
|
|
|
|
CTimer::SetTimeStepNonClipped(TimeStepNonClipped);
|
|
|
|
CClock::SetGameClock(ClockHours, ClockMinutes);
|
|
|
|
CWeather::OldWeatherType = OldWeatherType;
|
|
|
|
CWeather::NewWeatherType = NewWeatherType;
|
|
|
|
CWeather::InterpolationValue = WeatherInterpolationValue;
|
2020-09-26 18:10:23 +00:00
|
|
|
CGame::currArea = CurrArea;
|
|
|
|
CPopulation::ms_nNumCivMale = ms_nNumCivMale_Stored;
|
|
|
|
CPopulation::ms_nNumCivFemale = ms_nNumCivFemale_Stored;
|
|
|
|
CPopulation::ms_nNumCop = ms_nNumCop_Stored;
|
|
|
|
CPopulation::ms_nNumEmergency = ms_nNumEmergency_Stored;
|
|
|
|
CPopulation::ms_nNumGang1 = ms_nNumGang1_Stored;
|
|
|
|
CPopulation::ms_nNumGang2 = ms_nNumGang2_Stored;
|
|
|
|
CPopulation::ms_nNumGang3 = ms_nNumGang3_Stored;
|
|
|
|
CPopulation::ms_nNumGang4 = ms_nNumGang4_Stored;
|
|
|
|
CPopulation::ms_nNumGang5 = ms_nNumGang5_Stored;
|
|
|
|
CPopulation::ms_nNumGang6 = ms_nNumGang6_Stored;
|
|
|
|
CPopulation::ms_nNumGang7 = ms_nNumGang7_Stored;
|
|
|
|
CPopulation::ms_nNumGang8 = ms_nNumGang8_Stored;
|
|
|
|
CPopulation::ms_nNumGang9 = ms_nNumGang9_Stored;
|
|
|
|
CPopulation::ms_nNumDummy = ms_nNumDummy_Stored;
|
|
|
|
CPopulation::ms_nTotalCivPeds = ms_nTotalCivPeds_Stored;
|
|
|
|
CPopulation::ms_nTotalGangPeds = ms_nTotalGangPeds_Stored;
|
|
|
|
CPopulation::ms_nTotalPeds = ms_nTotalPeds_Stored;
|
|
|
|
CPopulation::ms_nTotalMissionPeds = ms_nTotalMissionPeds_Stored;
|
2019-06-30 13:20:11 +00:00
|
|
|
for (int i = 0; i < CPools::GetPedPool()->GetSize(); i++) {
|
2019-06-24 22:42:23 +00:00
|
|
|
CPed* ped = CPools::GetPedPool()->GetSlot(i);
|
|
|
|
if (!ped)
|
|
|
|
continue;
|
|
|
|
RetrieveDetailedPedAnimation(ped, &pPedAnims[i]);
|
|
|
|
}
|
2019-07-20 13:18:56 +00:00
|
|
|
delete[] pPedAnims;
|
2019-06-24 22:42:23 +00:00
|
|
|
pPedAnims = nil;
|
2020-09-26 18:10:23 +00:00
|
|
|
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;
|
2020-08-19 18:11:19 +00:00
|
|
|
CScriptPaths::Load_ForReplay();
|
2020-09-26 18:10:23 +00:00
|
|
|
CExplosion::ClearAllExplosions();
|
2019-10-26 12:20:12 +00:00
|
|
|
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
|
2019-06-24 22:42:23 +00:00
|
|
|
DMAudio.SetRadioInCar(OldRadioStation);
|
2019-10-26 12:20:12 +00:00
|
|
|
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
|
2019-06-24 22:42:23 +00:00
|
|
|
}
|
2019-06-30 16:22:44 +00:00
|
|
|
|
|
|
|
void CReplay::EmptyPedsAndVehiclePools(void)
|
|
|
|
{
|
|
|
|
int i = CPools::GetVehiclePool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-30 16:22:44 +00:00
|
|
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
|
|
|
|
if (!v)
|
|
|
|
continue;
|
|
|
|
CWorld::Remove(v);
|
|
|
|
delete v;
|
|
|
|
}
|
|
|
|
i = CPools::GetPedPool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-30 16:22:44 +00:00
|
|
|
CPed* p = CPools::GetPedPool()->GetSlot(i);
|
|
|
|
if (!p)
|
|
|
|
continue;
|
|
|
|
CWorld::Remove(p);
|
|
|
|
delete p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::EmptyAllPools(void)
|
|
|
|
{
|
|
|
|
EmptyPedsAndVehiclePools();
|
|
|
|
int i = CPools::GetObjectPool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-30 16:22:44 +00:00
|
|
|
CObject* o = CPools::GetObjectPool()->GetSlot(i);
|
|
|
|
if (!o)
|
|
|
|
continue;
|
|
|
|
CWorld::Remove(o);
|
|
|
|
delete o;
|
|
|
|
}
|
|
|
|
i = CPools::GetDummyPool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-30 16:22:44 +00:00
|
|
|
CDummy* d = CPools::GetDummyPool()->GetSlot(i);
|
|
|
|
if (!d)
|
|
|
|
continue;
|
|
|
|
CWorld::Remove(d);
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::MarkEverythingAsNew(void)
|
|
|
|
{
|
|
|
|
int i = CPools::GetVehiclePool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-30 16:22:44 +00:00
|
|
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
|
|
|
|
if (!v)
|
|
|
|
continue;
|
2019-07-09 07:57:44 +00:00
|
|
|
v->bHasAlreadyBeenRecorded = false;
|
2019-06-30 16:22:44 +00:00
|
|
|
}
|
|
|
|
i = CPools::GetPedPool()->GetSize();
|
2019-10-16 21:53:25 +00:00
|
|
|
while (--i >= 0) {
|
2019-06-30 16:22:44 +00:00
|
|
|
CPed* p = CPools::GetPedPool()->GetSlot(i);
|
|
|
|
if (!p)
|
|
|
|
continue;
|
2019-07-09 07:57:44 +00:00
|
|
|
p->bHasAlreadyBeenRecorded = false;
|
2019-06-30 16:22:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-30 20:29:53 +00:00
|
|
|
|
|
|
|
void CReplay::SaveReplayToHD(void)
|
|
|
|
{
|
|
|
|
CFileMgr::SetDirMyDocuments();
|
|
|
|
int fw = CFileMgr::OpenFileForWriting("replay.rep");
|
2020-03-15 15:47:21 +00:00
|
|
|
#ifdef FIX_REPLAY_BUGS
|
2020-02-01 21:01:25 +00:00
|
|
|
if (fw == 0) {
|
|
|
|
#else
|
|
|
|
if (fw < 0){ // BUG?
|
|
|
|
#endif
|
2020-03-15 15:47:21 +00:00
|
|
|
printf("Couldn't open replay.rep for writing");
|
2019-06-30 20:29:53 +00:00
|
|
|
CFileMgr::SetDir("");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CFileMgr::Write(fw, "gta3_7f", sizeof("gta3_7f"));
|
|
|
|
int current;
|
2020-03-15 15:47:21 +00:00
|
|
|
for (current = 0; current < NUM_REPLAYBUFFERS; current++)
|
2019-06-30 20:29:53 +00:00
|
|
|
if (BufferStatus[current] == REPLAYBUFFER_RECORD)
|
|
|
|
break;
|
|
|
|
int first;
|
2020-03-15 15:47:21 +00:00
|
|
|
for (first = (current + 1) % NUM_REPLAYBUFFERS; ; first = (first + 1) % NUM_REPLAYBUFFERS)
|
2019-06-30 20:29:53 +00:00
|
|
|
if (BufferStatus[first] == REPLAYBUFFER_RECORD || BufferStatus[first] == REPLAYBUFFER_PLAYBACK)
|
|
|
|
break;
|
2020-04-18 20:50:37 +00:00
|
|
|
for(int i = first; ; i = (i + 1) % NUM_REPLAYBUFFERS){
|
|
|
|
CFileMgr::Write(fw, (char*)Buffers[i], sizeof(Buffers[i]));
|
2019-06-30 20:29:53 +00:00
|
|
|
if (BufferStatus[i] == REPLAYBUFFER_RECORD)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
CFileMgr::CloseFile(fw);
|
|
|
|
CFileMgr::SetDir("");
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayReplayFromHD(void)
|
|
|
|
{
|
|
|
|
CFileMgr::SetDirMyDocuments();
|
|
|
|
int fr = CFileMgr::OpenFile("replay.rep", "rb");
|
2020-02-01 21:01:25 +00:00
|
|
|
if (fr == 0) {
|
2020-03-15 15:47:21 +00:00
|
|
|
printf("Couldn't open replay.rep for reading");
|
|
|
|
#ifdef FIX_REPLAY_BUGS
|
|
|
|
CFileMgr::SetDir("");
|
|
|
|
#endif
|
2019-06-30 20:29:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
CFileMgr::Read(fr, gString, 8);
|
|
|
|
if (strncmp(gString, "gta3_7f", sizeof("gta3_7f"))){
|
|
|
|
CFileMgr::CloseFile(fr);
|
2020-03-15 15:47:21 +00:00
|
|
|
printf("Wrong file type for replay");
|
2019-06-30 20:29:53 +00:00
|
|
|
CFileMgr::SetDir("");
|
|
|
|
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;
|
2020-03-15 15:47:21 +00:00
|
|
|
while (slot < CReplay::NUM_REPLAYBUFFERS)
|
2019-06-30 20:29:53 +00:00
|
|
|
CReplay::BufferStatus[slot++] = CReplay::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();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::StreamAllNecessaryCarsAndPeds(void)
|
|
|
|
{
|
2020-03-15 15:47:21 +00:00
|
|
|
for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) {
|
2019-06-30 20:29:53 +00:00
|
|
|
if (BufferStatus[slot] == REPLAYBUFFER_UNUSED)
|
|
|
|
continue;
|
2020-07-22 11:56:28 +00:00
|
|
|
for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
2019-06-30 20:29:53 +00:00
|
|
|
switch (Buffers[slot][offset]) {
|
|
|
|
case REPLAYPACKET_VEHICLE:
|
|
|
|
CStreaming::RequestModel(((tVehicleUpdatePacket*)&Buffers[slot][offset])->mi, 0);
|
|
|
|
break;
|
2020-09-26 18:10:23 +00:00
|
|
|
case REPLAYPACKET_BIKE:
|
|
|
|
CStreaming::RequestModel(((tBikeUpdatePacket*)&Buffers[slot][offset])->mi, 0);
|
|
|
|
break;
|
2019-06-30 20:29:53 +00:00
|
|
|
case REPLAYPACKET_PED_HEADER:
|
|
|
|
CStreaming::RequestModel(((tPedHeaderPacket*)&Buffers[slot][offset])->mi, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CStreaming::LoadAllRequestedModels(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::FindFirstFocusCoordinate(CVector *coord)
|
|
|
|
{
|
|
|
|
*coord = CVector(0.0f, 0.0f, 0.0f);
|
2020-03-15 15:47:21 +00:00
|
|
|
for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) {
|
2019-06-30 20:29:53 +00:00
|
|
|
if (BufferStatus[slot] == REPLAYBUFFER_UNUSED)
|
|
|
|
continue;
|
2020-07-22 11:56:28 +00:00
|
|
|
for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
2019-06-30 20:29:53 +00:00
|
|
|
if (Buffers[slot][offset] == REPLAYPACKET_GENERAL) {
|
|
|
|
*coord = ((tGeneralPacket*)&Buffers[slot][offset])->player_pos;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CReplay::ShouldStandardCameraBeProcessed(void)
|
|
|
|
{
|
|
|
|
if (Mode != MODE_PLAYBACK)
|
|
|
|
return true;
|
|
|
|
if (FramesActiveLookAroundCam || bPlayerInRCBuggy)
|
|
|
|
return false;
|
|
|
|
return FindPlayerVehicle() != nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReplay::ProcessLookAroundCam(void)
|
|
|
|
{
|
|
|
|
if (!bAllowLookAroundCam)
|
|
|
|
return;
|
|
|
|
float x_moved = CPad::NewMouseControllerState.x / 200.0f;
|
|
|
|
float y_moved = CPad::NewMouseControllerState.y / 200.0f;
|
|
|
|
if (x_moved > 0.01f || y_moved > 0.01f) {
|
|
|
|
if (FramesActiveLookAroundCam == 0)
|
|
|
|
fDistanceLookAroundCam = 9.0f;
|
|
|
|
FramesActiveLookAroundCam = 60;
|
|
|
|
}
|
|
|
|
if (bPlayerInRCBuggy)
|
|
|
|
FramesActiveLookAroundCam = 0;
|
|
|
|
if (!FramesActiveLookAroundCam)
|
|
|
|
return;
|
|
|
|
--FramesActiveLookAroundCam;
|
|
|
|
fBetaAngleLookAroundCam += x_moved;
|
|
|
|
if (CPad::NewMouseControllerState.LMB && CPad::NewMouseControllerState.RMB)
|
2020-04-19 16:34:08 +00:00
|
|
|
fDistanceLookAroundCam = Max(3.0f, Min(15.0f, fDistanceLookAroundCam + 2.0f * y_moved));
|
2019-06-30 20:29:53 +00:00
|
|
|
else
|
2020-04-19 16:34:08 +00:00
|
|
|
fAlphaAngleLookAroundCam = Max(0.1f, Min(1.5f, fAlphaAngleLookAroundCam + y_moved));
|
2019-06-30 20:29:53 +00:00
|
|
|
CVector camera_pt(
|
2019-07-10 15:18:26 +00:00
|
|
|
fDistanceLookAroundCam * Sin(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam),
|
|
|
|
fDistanceLookAroundCam * Cos(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam),
|
|
|
|
fDistanceLookAroundCam * Sin(fAlphaAngleLookAroundCam)
|
2019-06-30 20:29:53 +00:00
|
|
|
);
|
|
|
|
CVector focus = CVector(CameraFocusX, CameraFocusY, CameraFocusZ);
|
|
|
|
camera_pt += focus;
|
|
|
|
CColPoint cp;
|
|
|
|
CEntity* pe = nil;
|
|
|
|
if (CWorld::ProcessLineOfSight(focus, camera_pt, cp, pe, true, false, false, false, false, true, true)){
|
|
|
|
camera_pt = cp.point;
|
|
|
|
CVector direction = focus - cp.point;
|
|
|
|
direction.Normalise();
|
|
|
|
camera_pt += direction / 4.0f;
|
|
|
|
}
|
|
|
|
CVector forward = focus - camera_pt;
|
|
|
|
forward.Normalise();
|
|
|
|
CVector right = CrossProduct(CVector(0.0f, 0.0f, 1.0f), forward);
|
|
|
|
right.Normalise();
|
|
|
|
CVector up = CrossProduct(forward, right);
|
|
|
|
up.Normalise();
|
2019-07-20 13:18:56 +00:00
|
|
|
TheCamera.GetForward() = forward;
|
|
|
|
TheCamera.GetUp() = up;
|
|
|
|
TheCamera.GetRight() = right;
|
2020-04-30 10:48:01 +00:00
|
|
|
TheCamera.SetPosition(camera_pt);
|
2019-06-30 20:29:53 +00:00
|
|
|
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
|
2020-12-18 00:58:09 +00:00
|
|
|
pm->pos = TheCamera.GetPosition();
|
|
|
|
pm->at = TheCamera.GetForward();
|
|
|
|
pm->up = TheCamera.GetUp();
|
|
|
|
pm->right = TheCamera.GetRight();
|
2019-06-30 20:29:53 +00:00
|
|
|
TheCamera.CalculateDerivedValues();
|
|
|
|
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
|
|
|
|
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t CReplay::FindSizeOfPacket(uint8 type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case REPLAYPACKET_END: return 4;
|
|
|
|
case REPLAYPACKET_VEHICLE: return sizeof(tVehicleUpdatePacket);
|
2020-09-26 18:16:55 +00:00
|
|
|
case REPLAYPACKET_BIKE: return sizeof(tBikeUpdatePacket);
|
2019-06-30 20:29:53 +00:00
|
|
|
case REPLAYPACKET_PED_HEADER: return sizeof(tPedHeaderPacket);
|
|
|
|
case REPLAYPACKET_PED_UPDATE: return sizeof(tPedUpdatePacket);
|
|
|
|
case REPLAYPACKET_GENERAL: return sizeof(tGeneralPacket);
|
|
|
|
case REPLAYPACKET_CLOCK: return sizeof(tClockPacket);
|
|
|
|
case REPLAYPACKET_WEATHER: return sizeof(tWeatherPacket);
|
|
|
|
case REPLAYPACKET_ENDOFFRAME: return 4;
|
|
|
|
case REPLAYPACKET_TIMER: return sizeof(tTimerPacket);
|
|
|
|
case REPLAYPACKET_BULLET_TRACES:return sizeof(tBulletTracePacket);
|
2020-09-26 18:16:55 +00:00
|
|
|
case REPLAYPACKET_PARTICLE: return sizeof(tParticlePacket);
|
|
|
|
case REPLAYPACKET_MISC: return sizeof(tMiscPacket);
|
2020-03-15 15:47:21 +00:00
|
|
|
default: assert(false); break;
|
2019-06-30 20:29:53 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2019-06-22 18:16:29 +00:00
|
|
|
|
2019-06-25 00:34:29 +00:00
|
|
|
void CReplay::Display()
|
|
|
|
{
|
2020-03-15 15:47:21 +00:00
|
|
|
static int TimeCount = 0;
|
2019-06-30 20:49:32 +00:00
|
|
|
if (Mode == MODE_RECORD)
|
|
|
|
return;
|
2020-03-15 15:47:21 +00:00
|
|
|
TimeCount = (TimeCount + 1) % UINT16_MAX;
|
|
|
|
if ((TimeCount & 0x20) == 0)
|
2019-06-30 20:49:32 +00:00
|
|
|
return;
|
2020-12-19 18:25:45 +00:00
|
|
|
|
2019-06-30 20:49:32 +00:00
|
|
|
CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f));
|
2020-12-19 18:25:45 +00:00
|
|
|
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();
|
2019-06-30 20:49:32 +00:00
|
|
|
CFont::SetColor(CRGBA(255, 255, 200, 200));
|
2020-06-07 01:10:06 +00:00
|
|
|
CFont::SetFontStyle(FONT_STANDARD);
|
2019-06-30 20:49:32 +00:00
|
|
|
if (Mode == MODE_PLAYBACK)
|
2020-12-19 18:25:45 +00:00
|
|
|
CFont::PrintString(SCREEN_WIDTH/15, SCREEN_HEIGHT/10, TheText.Get("REPLAY"));
|
2019-06-25 00:34:29 +00:00
|
|
|
}
|
2020-12-01 20:08:05 +00:00
|
|
|
#endif
|