summaryrefslogtreecommitdiff
path: root/src/core/Zones.h
blob: 8d5af182d751162048e85f8ce6ff499264b2919f (plain)
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
108
109
110
111
112
#pragma once

#include "Game.h"
#include "Gangs.h"
#include "CarCtrl.h"

enum eZoneType
{
	ZONE_DEFAULT,
	ZONE_NAVIG,
	ZONE_INFO,
	ZONE_MAPZONE,
};

class CZone
{
public:
	char       name[8];
	float      minx;
	float      miny;
	float      minz;
	float      maxx;
	float      maxy;
	float      maxz;
	eZoneType  type;
	eLevelName level;
	int16      zoneinfoDay;
	int16      zoneinfoNight;
	CZone     *child;
	CZone     *parent;
	CZone     *next;

	wchar *GetTranslatedName(void);
};

class CZoneInfo
{
public:
	// Car data
	int16 carDensity;
	int16 carThreshold[CCarCtrl::NUM_CAR_CLASSES];
	int16 boatThreshold[CCarCtrl::NUM_BOAT_CLASSES];
	int16 gangThreshold[NUM_GANGS];
	int16 copThreshold;

	// Ped data
	uint16 pedDensity;
	uint16 gangPedThreshold[NUM_GANGS];
	uint16 copPedThreshold;
	uint16 pedGroup;
};


class CTheZones
{
	static int16 FindIndex;

	static uint16 NumberOfAudioZones;
	static int16 AudioZoneArray[NUMAUDIOZONES];
	static uint16 TotalNumberOfMapZones;
	static uint16 TotalNumberOfInfoZones;
	static uint16 TotalNumberOfNavigationZones;
	static CZone InfoZoneArray[NUMINFOZONES];
	static CZone MapZoneArray[NUMMAPZONES];
	static CZone NavigationZoneArray[NUMNAVIGZONES];
	static uint16 TotalNumberOfZoneInfos;
	static CZoneInfo ZoneInfoArray[2*NUMINFOZONES];
public:
	static eLevelName m_CurrLevel;

	static void Init(void);
	static void Update(void);
	static void CreateZone(char *name, eZoneType type,
	                       float minx, float miny, float minz,
	                       float maxx, float maxy, float maxz,
	                       eLevelName level);
	static CZone *GetInfoZone(uint16 i) { return &InfoZoneArray[i]; }
	static CZone *GetNavigationZone(uint16 i) { return &NavigationZoneArray[i]; }
	static CZone *GetMapZone(uint16 i) { return &MapZoneArray[i]; }
	static CZone *GetAudioZone(uint16 i) { return &InfoZoneArray[AudioZoneArray[i]]; }
	static void PostZoneCreation(void);
	static void CheckZonesForOverlap(void);
	static void InsertZoneIntoZoneHierarchy(CZone *zone);
	static bool InsertZoneIntoZoneHierRecursive(CZone *z1, CZone *z2);
	static bool ZoneIsEntirelyContainedWithinOtherZone(CZone *z1, CZone *z2);
	static bool PointLiesWithinZone(const CVector *v, CZone *zone);
	static eLevelName GetLevelFromPosition(const CVector *v);
	static CZone *FindInformationZoneForPosition(const CVector *v);
	static CZone *FindSmallestNavigationZoneForPosition(const CVector *v, bool findDefault, bool findNavig);
	static int16 FindZoneByLabelAndReturnIndex(char *name, eZoneType type);
	static int16 FindNextZoneByLabelAndReturnIndex(char *name, eZoneType type);
	static CZoneInfo *GetZoneInfo(const CVector *v, uint8 day);
	static void GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info);
	static void SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity,
		int16 copCarDensity, const int16 *gangCarDensities /*[NUMGANGS]*/);
	static void SetZoneCivilianCarInfo(uint16 zoneid, uint8 day,
		const int16* carDensities, const int16* boatDensities);
	static void SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity,
		int16 gang0Density, int16 gang1Density, int16 gang2Density, int16 gang3Density,
		int16 gang4Density, int16 gang5Density, int16 gang6Density, int16 gang7Density,
		int16 gang8Density, int16 copDensity);
	static void SetCarDensity(uint16 zoneid, uint8 day, uint16 cardensity);
	static void SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity);
	static void SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup);
	static int16 FindAudioZone(CVector *pos);
	static CZone *GetPointerForZoneIndex(int32 i) { return i == -1 ? nil : &InfoZoneArray[i]; }
	static int32 GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - InfoZoneArray; }
	static void AddZoneToAudioZoneArray(CZone *zone);
	static void InitialiseAudioZoneArray(void);
	static void SaveAllZones(uint8 *buffer, uint32 *length);
	static void LoadAllZones(uint8 *buffer, uint32 length);
};