summaryrefslogtreecommitdiffstats
path: root/src/control/Record.h
blob: 3cb09318da6ad61e54c2cc593e54bd0ae56ca889 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once

class CAutomobile;
class CVehicle;
class CControllerState;

enum {
	RECORDSTATE_0,
	RECORDSTATE_1,
	RECORDSTATE_2,
};

class CRecordDataForChase
{
	enum {
		NUM_CHASE_CARS = 20
	};
public:
	static uint8 &Status;
	static int &PositionChanges;
	static uint8 &CurrentCar;
	static CAutomobile*(&pChaseCars)[NUM_CHASE_CARS];
	static uint32 &AnimStartTime;

	static void SaveOrRetrieveDataForThisFrame(void);
	static void ProcessControlCars(void);
	static void SaveOrRetrieveCarPositions(void);
	static void StartChaseScene(float);
	static void CleanUpChaseScene();
	static void RemoveCarFromChase(int32);
	static CVehicle* TurnChaseCarIntoScriptCar(int32);
	static void Init(void);
};

struct tGameBuffer
{
	float m_fTimeStep;
	uint32 m_nTimeInMilliseconds;
	uint8 m_nSizeOfPads[2];
	uint16 m_nChecksum;
	uint8 m_ControllerBuffer[116];
};

class CRecordDataForGame
{
	enum {
		STATE_NONE = 0,
		STATE_RECORD = 1,
		STATE_PLAYBACK = 2,
	};
	static uint16& RecordingState;
	static uint8* &pDataBuffer;
	static uint8* &pDataBufferPointer;
	static int &FId;
	static tGameBuffer &pDataBufferForFrame;

public:
	static bool IsRecording() { return RecordingState == STATE_RECORD; }
	static bool IsPlayingBack() { return RecordingState == STATE_PLAYBACK; }

	static void SaveOrRetrieveDataForThisFrame(void);
	static void Init(void);

private:
	static uint16 CalcGameChecksum(void);
	static uint8* PackCurrentPadValues(uint8*, CControllerState*, CControllerState*);
	static uint8* UnPackCurrentPadValues(uint8*, uint8, CControllerState*);
};