summaryrefslogtreecommitdiffstats
path: root/src/Streaming.h
blob: f31faf9c567def06a46db64a66a5088df8e7d659 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#pragma once

enum {
	STREAM_OFFSET_MODEL = 0,
	STREAM_OFFSET_TXD = STREAM_OFFSET_MODEL+MODELINFOSIZE,
	NUMSTREAMINFO = STREAM_OFFSET_TXD+TXDSTORESIZE
};

enum StreamFlags
{
	STREAMFLAGS_DONT_REMOVE = 0x01,
	STREAMFLAGS_SCRIPTOWNED = 0x02,
	STREAMFLAGS_DEPENDENCY  = 0x04,
	STREAMFLAGS_PRIORITY    = 0x08,
	STREAMFLAGS_NOFADE      = 0x10,
};

enum StreamLoadState
{
	STREAMSTATE_NOTLOADED = 0,
	STREAMSTATE_LOADED    = 1,
	STREAMSTATE_INQUEUE   = 2,
	STREAMSTATE_READING   = 3,	// what is this?
	STREAMSTATE_BIGFILE   = 4,
};

enum ChannelState
{
	CHANNELSTATE_0 = 0,
};

class CStreamingInfo
{
public:
	CStreamingInfo *m_next;
	CStreamingInfo *m_prev;
	uint8 m_loadState;
	uint8 m_flags;

	int16  m_nextID;
	uint32 m_position;
	uint32 m_size;

	bool GetCdPosnAndSize(uint32 &posn, uint32 &size);
	void SetCdPosnAndSize(uint32 posn, uint32 size);
	void AddToList(CStreamingInfo *link);
	void RemoveFromList(void);
	uint32 GetCdSize(void) { return m_size; }
};

struct CStreamingChannel
{
	int32 modelIds[4];
	int32 offsets[4];
	int32 state;
	int32 field24;
	int32 position;
	int32 size;
	int32 field30;
	int32 status;	// from CdStream
};

class CDirectory;

class CStreaming
{
public:
	static bool &ms_disableStreaming;
	static bool &ms_bLoadingBigModel;
	static int32 &ms_numModelsRequested;
	static CStreamingInfo *ms_aInfoForModel;	//[NUMSTREAMINFO]
	static CStreamingInfo &ms_startLoadedList;
	static CStreamingInfo &ms_endLoadedList;
	static CStreamingInfo &ms_startRequestedList;
	static CStreamingInfo &ms_endRequestedList;
	static int32 &ms_oldSectorX;
	static int32 &ms_oldSectorY;
	static uint32 &ms_streamingBufferSize;
	static uint8 **ms_pStreamingBuffer;	//[2]
	static int32 &ms_memoryUsed;
	static CStreamingChannel *ms_channel;	//[2]
	static int32 &ms_numVehiclesLoaded;
	static int32 *ms_vehiclesLoaded;	//[MAXVEHICLESLOADED]
	static CDirectory *&ms_pExtraObjectsDir;
	static int32 &ms_numPriorityRequests;
	static bool &ms_hasLoadedLODs;
	static int32 &ms_currentPedGrp;
	static int32 ms_lastCullZone;
	static uint16 &ms_loadedGangs;
	static int32 ms_currentPedLoading;
	static int32 *ms_imageOffsets;	//[NUMCDIMAGES]
	static int32 &ms_lastImageRead;
	static int32 &ms_imageSize;
	static int32 &ms_memoryAvailable;

	static void Init(void);
	static void Shutdown(void);
	static void LoadCdDirectory(void);
	static void LoadCdDirectory(const char *dirname, int n);

	static void RemoveModel(int32 id);
	static void RequestModel(int32 model, int32 flags);
	static void MakeSpaceFor(int32 size);
	static void ImGonnaUseStreamingMemory(void);
	static void IHaveUsedStreamingMemory(void);
	static void UpdateMemoryUsed(void);
};