1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-18 10:47:49 +00:00
re3/src/control/Replay.h

422 lines
10 KiB
C
Raw Normal View History

#pragma once
2019-06-22 18:16:29 +00:00
#include "Pools.h"
#include "World.h"
2020-09-26 18:10:23 +00:00
#include "WeaponEffects.h"
2020-05-27 00:18:02 +00:00
#include "ParticleType.h"
2019-06-22 18:16:29 +00:00
2020-03-15 15:47:21 +00:00
#ifdef FIX_BUGS
#ifndef DONT_FIX_REPLAY_BUGS
#define FIX_REPLAY_BUGS
#endif
#endif
2020-03-28 14:47:52 +00:00
class CVehicle;
struct CReference;
2019-06-22 18:16:29 +00:00
struct CAddressInReplayBuffer
{
2019-06-22 18:42:26 +00:00
uint32 m_nOffset;
2019-06-22 18:16:29 +00:00
uint8 *m_pBase;
uint8 m_bSlot;
};
struct CStoredAnimationState
{
2019-06-23 10:58:14 +00:00
uint8 animId;
uint8 time;
uint8 speed;
2020-09-26 18:10:23 +00:00
uint8 groupId;
2019-06-23 10:58:14 +00:00
uint8 secAnimId;
uint8 secTime;
uint8 secSpeed;
2020-09-26 18:10:23 +00:00
uint8 secGroupId;
2019-06-23 10:58:14 +00:00
uint8 blendAmount;
uint8 partAnimId;
uint8 partAnimTime;
uint8 partAnimSpeed;
uint8 partBlendAmount;
2020-09-26 18:10:23 +00:00
uint8 partGroupId;
2019-06-22 18:16:29 +00:00
};
2020-03-15 15:47:21 +00:00
enum {
NUM_MAIN_ANIMS_IN_REPLAY = 3,
NUM_PARTIAL_ANIMS_IN_REPLAY = 6
};
2019-06-22 18:16:29 +00:00
struct CStoredDetailedAnimationState
{
2020-03-15 15:47:21 +00:00
uint8 aAnimId[NUM_MAIN_ANIMS_IN_REPLAY];
uint8 aCurTime[NUM_MAIN_ANIMS_IN_REPLAY];
uint8 aSpeed[NUM_MAIN_ANIMS_IN_REPLAY];
uint8 aBlendAmount[NUM_MAIN_ANIMS_IN_REPLAY];
int8 aBlendDelta[NUM_MAIN_ANIMS_IN_REPLAY];
uint8 aFunctionCallbackID[NUM_MAIN_ANIMS_IN_REPLAY];
uint16 aFlags[NUM_MAIN_ANIMS_IN_REPLAY];
2020-09-26 18:10:23 +00:00
uint8 aGroupId[NUM_MAIN_ANIMS_IN_REPLAY];
2020-03-15 15:47:21 +00:00
uint8 aAnimId2[NUM_PARTIAL_ANIMS_IN_REPLAY];
uint8 aCurTime2[NUM_PARTIAL_ANIMS_IN_REPLAY];
uint8 aSpeed2[NUM_PARTIAL_ANIMS_IN_REPLAY];
uint8 aBlendAmount2[NUM_PARTIAL_ANIMS_IN_REPLAY];
int8 aBlendDelta2[NUM_PARTIAL_ANIMS_IN_REPLAY];
uint8 aFunctionCallbackID2[NUM_PARTIAL_ANIMS_IN_REPLAY];
uint16 aFlags2[NUM_PARTIAL_ANIMS_IN_REPLAY];
2020-09-26 18:10:23 +00:00
uint8 aGroupId2[NUM_PARTIAL_ANIMS_IN_REPLAY];
2019-06-22 18:16:29 +00:00
};
2019-06-30 20:29:53 +00:00
void PlayReplayFromHD(void);
#ifdef GTA_REPLAY
#define REPLAY_STUB
#else
#define REPLAY_STUB {}
#endif
class CReplay
{
2019-06-12 11:46:02 +00:00
enum {
2019-06-22 18:16:29 +00:00
MODE_RECORD = 0,
MODE_PLAYBACK = 1
};
enum {
REPLAYCAMMODE_ASSTORED = 0,
2020-09-26 18:10:23 +00:00
REPLAYCAMMODE_TOPDOWN,
REPLAYCAMMODE_FIXED
2019-06-12 11:46:02 +00:00
};
2019-06-07 20:31:03 +00:00
2019-06-22 18:16:29 +00:00
enum {
REPLAYPACKET_END = 0,
2020-09-26 18:10:23 +00:00
REPLAYPACKET_VEHICLE,
REPLAYPACKET_BIKE,
REPLAYPACKET_PED_HEADER,
REPLAYPACKET_PED_UPDATE,
REPLAYPACKET_GENERAL,
REPLAYPACKET_CLOCK,
REPLAYPACKET_WEATHER,
REPLAYPACKET_ENDOFFRAME,
REPLAYPACKET_TIMER,
REPLAYPACKET_BULLET_TRACES,
REPLAYPACKET_PARTICLE,
REPLAYPACKET_MISC
2019-06-22 18:16:29 +00:00
};
enum {
REPLAYBUFFER_UNUSED = 0,
REPLAYBUFFER_PLAYBACK = 1,
REPLAYBUFFER_RECORD = 2
};
2020-03-15 15:47:21 +00:00
enum {
NUM_REPLAYBUFFERS = 8,
REPLAYBUFFERSIZE = 100000
};
2019-06-22 18:16:29 +00:00
2019-06-22 18:35:23 +00:00
struct tGeneralPacket
{
uint8 type;
bool in_rcvehicle;
CMatrix camera_pos;
CVector player_pos;
};
2020-05-10 13:54:37 +00:00
VALIDATE_SIZE(tGeneralPacket, 88);
2019-06-22 18:35:23 +00:00
struct tClockPacket
{
uint8 type;
uint8 hours;
uint8 minutes;
private:
uint8 __align;
};
VALIDATE_SIZE(tClockPacket, 4);
2019-06-22 18:35:23 +00:00
struct tWeatherPacket
{
uint8 type;
uint8 old_weather;
uint8 new_weather;
float interpolation;
};
VALIDATE_SIZE(tWeatherPacket, 8);
2019-06-22 18:35:23 +00:00
struct tTimerPacket
{
uint8 type;
uint32 timer;
};
VALIDATE_SIZE(tTimerPacket, 8);
2019-06-22 18:35:23 +00:00
struct tPedHeaderPacket
{
uint8 type;
uint8 index;
uint16 mi;
uint8 pedtype;
private:
uint8 __align[3];
};
VALIDATE_SIZE(tPedHeaderPacket, 8);
2019-06-22 18:35:23 +00:00
struct tBulletTracePacket
{
uint8 type;
uint8 frames;
uint8 lifetime;
uint8 index;
CVector inf;
CVector sup;
};
VALIDATE_SIZE(tBulletTracePacket, 28);
2019-06-22 18:35:23 +00:00
struct tEndOfFramePacket
{
uint8 type;
private:
uint8 __align[3];
};
VALIDATE_SIZE(tEndOfFramePacket, 4);
2019-06-22 18:16:29 +00:00
2019-06-22 22:34:11 +00:00
struct tPedUpdatePacket
{
uint8 type;
uint8 index;
int8 heading;
int8 vehicle_index;
CStoredAnimationState anim_state;
CCompressedMatrixNotAligned matrix;
2020-05-16 14:00:40 +00:00
uint16 weapon_model;
2020-09-26 18:10:23 +00:00
int8 assoc_group_id;
bool is_visible;
2019-06-22 22:34:11 +00:00
};
VALIDATE_SIZE(tPedUpdatePacket, 40);
2019-06-22 22:34:11 +00:00
2019-06-24 22:42:23 +00:00
struct tVehicleUpdatePacket
{
uint8 type;
uint8 index;
uint8 health;
uint8 acceleration;
CCompressedMatrixNotAligned matrix;
int8 door_angles[2];
uint16 mi;
uint32 panels;
int8 velocityX;
int8 velocityY;
int8 velocityZ;
2020-04-18 20:50:37 +00:00
union {
2019-06-24 22:42:23 +00:00
int8 car_gun;
2019-07-20 13:18:56 +00:00
int8 wheel_state;
2019-06-24 22:42:23 +00:00
};
uint8 wheel_susp_dist[4];
uint8 wheel_rotation[4];
uint8 door_status;
uint8 primary_color;
uint8 secondary_color;
2020-09-26 18:10:23 +00:00
bool render_scorched;
int8 skimmer_speed;
int8 vehicle_type;
};
VALIDATE_SIZE(tVehicleUpdatePacket, 52);
struct tBikeUpdatePacket
{
uint8 type;
uint8 index;
uint8 health;
uint8 acceleration;
CCompressedMatrixNotAligned matrix;
int8 door_angles[2];
uint16 mi;
int8 velocityX;
int8 velocityY;
int8 velocityZ;
int8 wheel_state;
uint8 wheel_susp_dist[4];
uint8 wheel_rotation[4];
uint8 primary_color;
uint8 secondary_color;
int8 lean_angle;
int8 wheel_angle;
};
VALIDATE_SIZE(tBikeUpdatePacket, 44);
struct tParticlePacket
{
uint8 type;
uint8 particle_type;
int8 dir_x;
int8 dir_y;
int8 dir_z;
uint8 r;
uint8 g;
uint8 b;
uint8 a;
int16 pos_x;
int16 pos_y;
int16 pos_z;
float size;
};
VALIDATE_SIZE(tParticlePacket, 20);
struct tMiscPacket
{
uint8 type;
uint32 cam_shake_start;
float cam_shake_strength;
uint8 cur_area;
2020-11-01 15:21:05 +00:00
uint8 video_cam : 1;
uint8 lift_cam : 1;
2019-06-24 22:42:23 +00:00
};
2020-09-26 18:10:23 +00:00
VALIDATE_SIZE(tMiscPacket, 16);
2019-06-24 22:42:23 +00:00
2019-06-22 18:16:29 +00:00
private:
2020-04-17 05:54:14 +00:00
static uint8 Mode;
static CAddressInReplayBuffer Record;
static CAddressInReplayBuffer Playback;
2020-04-18 20:50:37 +00:00
static uint8* pBuf0;
static CAutomobile* pBuf1;
static uint8* pBuf2;
static CPlayerPed* pBuf3;
static uint8* pBuf4;
2020-05-09 11:00:39 +00:00
static CCutsceneObject* pBuf5;
2020-04-18 20:50:37 +00:00
static uint8* pBuf6;
static CPtrNode* pBuf7;
static uint8* pBuf8;
static CEntryInfoNode* pBuf9;
static uint8* pBuf10;
static CDummyPed* pBuf11;
static uint8* pRadarBlips;
static uint8* pStoredCam;
static uint8* pWorld1;
static CReference* pEmptyReferences;
static CStoredDetailedAnimationState* pPedAnims;
static uint8* pPickups;
static uint8* pReferences;
2020-04-17 05:54:14 +00:00
static uint8 BufferStatus[NUM_REPLAYBUFFERS];
static uint8 Buffers[NUM_REPLAYBUFFERS][REPLAYBUFFERSIZE];
static bool bPlayingBackFromFile;
static bool bReplayEnabled;
static uint32 SlowMotion;
static uint32 FramesActiveLookAroundCam;
static bool bDoLoadSceneWhenDone;
2020-04-18 20:50:37 +00:00
static CPtrNode* WorldPtrList;
static CPtrNode* BigBuildingPtrList;
2020-04-17 05:54:14 +00:00
static CWanted PlayerWanted;
static CPlayerInfo PlayerInfo;
static uint32 Time1;
static uint32 Time2;
static uint32 Time3;
static uint32 Time4;
static uint32 Frame;
static uint8 ClockHours;
static uint8 ClockMinutes;
static uint16 OldWeatherType;
static uint16 NewWeatherType;
static float WeatherInterpolationValue;
static float TimeStepNonClipped;
static float TimeStep;
static float TimeScale;
static float CameraFixedX;
static float CameraFixedY;
static float CameraFixedZ;
static int32 OldRadioStation;
static int8 CameraMode;
static bool bAllowLookAroundCam;
static float LoadSceneX;
static float LoadSceneY;
static float LoadSceneZ;
static float CameraFocusX;
static float CameraFocusY;
static float CameraFocusZ;
static bool bPlayerInRCBuggy;
static float fDistanceLookAroundCam;
static float fAlphaAngleLookAroundCam;
static float fBetaAngleLookAroundCam;
2020-09-26 18:10:23 +00:00
static int ms_nNumCivMale_Stored;
static int ms_nNumCivFemale_Stored;
static int ms_nNumCop_Stored;
static int ms_nNumEmergency_Stored;
static int ms_nNumGang1_Stored;
static int ms_nNumGang2_Stored;
static int ms_nNumGang3_Stored;
static int ms_nNumGang4_Stored;
static int ms_nNumGang5_Stored;
static int ms_nNumGang6_Stored;
static int ms_nNumGang7_Stored;
static int ms_nNumGang8_Stored;
static int ms_nNumGang9_Stored;
static int ms_nNumDummy_Stored;
static int ms_nTotalCarPassengerPeds_Stored;
static int ms_nTotalCivPeds_Stored;
static int ms_nTotalGangPeds_Stored;
static int ms_nTotalPeds_Stored;
static int ms_nTotalMissionPeds_Stored;
static uint8* pGarages;
static CFire* FireArray;
static uint32 NumOfFires;
static uint8* paProjectileInfo;
static uint8* paProjectiles;
static uint8 CurrArea;
2020-04-18 20:50:37 +00:00
#ifdef FIX_BUGS
static int nHandleOfPlayerPed[NUMPLAYERS];
#endif
2019-06-14 23:34:19 +00:00
2019-06-22 18:16:29 +00:00
public:
static void Init(void) REPLAY_STUB;
static void DisableReplays(void) REPLAY_STUB;
static void EnableReplays(void) REPLAY_STUB;
static void Update(void) REPLAY_STUB;
static void FinishPlayback(void) REPLAY_STUB;
static void EmptyReplayBuffer(void) REPLAY_STUB;
static void Display(void) REPLAY_STUB;
static void TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene) REPLAY_STUB;
static void StreamAllNecessaryCarsAndPeds(void) REPLAY_STUB;
static void RecordParticle(tParticleType type, CVector const& vecPos, CVector const& vecDir, float fSize, RwRGBA const& color) REPLAY_STUB;
#ifndef GTA_REPLAY
static bool ShouldStandardCameraBeProcessed(void) { return true; }
static bool IsPlayingBack() { return false; }
static bool IsPlayingBackFromFile() { return false; }
#else
2019-06-22 18:16:29 +00:00
static bool ShouldStandardCameraBeProcessed(void);
static bool IsPlayingBack() { return Mode == MODE_PLAYBACK; }
static bool IsPlayingBackFromFile() { return bPlayingBackFromFile; }
private:
2019-06-22 18:16:29 +00:00
static void RecordThisFrame(void);
static void StorePedUpdate(CPed *ped, int id);
static void StorePedAnimation(CPed *ped, CStoredAnimationState *state);
2019-06-29 18:38:47 +00:00
static void StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state);
2019-06-22 18:16:29 +00:00
static void ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer);
static void RetrievePedAnimation(CPed *ped, CStoredAnimationState *state);
static void RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state);
static void PlaybackThisFrame(void);
2020-03-15 15:47:21 +00:00
static void TriggerPlaybackLastCoupleOfSeconds(uint32, uint8, float, float, float, uint32);
static bool FastForwardToTime(uint32);
2019-06-22 18:16:29 +00:00
static void StoreCarUpdate(CVehicle *vehicle, int id);
2020-09-26 18:10:23 +00:00
static void StoreBikeUpdate(CVehicle* vehicle, int id);
2019-06-22 18:16:29 +00:00
static void ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer);
2020-09-26 18:10:23 +00:00
static void ProcessBikeUpdate(CVehicle* vehicle, float interpolation, CAddressInReplayBuffer* buffer);
2019-06-22 18:16:29 +00:00
static bool PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer);
static void ProcessReplayCamera(void);
static void StoreStuffInMem(void);
static void RestoreStuffFromMem(void);
static void EmptyPedsAndVehiclePools(void);
static void EmptyAllPools(void);
static void MarkEverythingAsNew(void);
static void SaveReplayToHD(void);
static void FindFirstFocusCoordinate(CVector *coord);
static void ProcessLookAroundCam(void);
static size_t FindSizeOfPacket(uint8);
2020-09-26 18:10:23 +00:00
static void GoToNextBlock(void);
2019-06-30 20:29:53 +00:00
/* Absolute nonsense, but how could this function end up being outside of class? */
friend void PlayReplayFromHD(void);
#endif
};