re3/src/core/Zones.h

115 lines
4 KiB
C
Raw Normal View History

2019-05-15 14:52:37 +00:00
#pragma once
#include "Game.h"
2020-02-17 23:56:13 +00:00
#include "Gangs.h"
#include "CarCtrl.h"
2019-05-15 14:52:37 +00:00
enum eZoneType
{
2020-05-06 10:23:57 +00:00
ZONE_DEFAULT,
ZONE_NAVIG,
ZONE_INFO,
2019-05-15 14:52:37 +00:00
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;
2019-06-05 20:32:49 +00:00
2019-07-06 10:27:21 +00:00
wchar *GetTranslatedName(void);
2019-05-15 14:52:37 +00:00
};
class CZoneInfo
{
public:
// Car data
2019-06-01 21:17:39 +00:00
int16 carDensity;
int16 carThreshold[CCarCtrl::NUM_CAR_CLASSES];
int16 boatThreshold[CCarCtrl::NUM_BOAT_CLASSES];
2020-02-17 23:56:13 +00:00
int16 gangThreshold[NUM_GANGS];
int16 copThreshold;
2019-05-15 14:52:37 +00:00
// Ped data
uint16 pedDensity;
uint16 gangPedThreshold[NUM_GANGS];
uint16 copPedThreshold;
2019-05-15 14:52:37 +00:00
uint16 pedGroup;
};
class CTheZones
{
2020-04-17 05:54:14 +00:00
static int16 FindIndex;
2019-05-15 14:52:37 +00:00
2020-04-17 05:54:14 +00:00
static uint16 NumberOfAudioZones;
static int16 AudioZoneArray[NUMAUDIOZONES];
static uint16 TotalNumberOfMapZones;
2020-05-06 10:23:57 +00:00
static uint16 TotalNumberOfInfoZones;
static uint16 TotalNumberOfNavigationZones;
static CZone InfoZoneArray[NUMINFOZONES];
2020-04-17 05:54:14 +00:00
static CZone MapZoneArray[NUMMAPZONES];
2020-05-06 10:23:57 +00:00
static CZone NavigationZoneArray[NUMNAVIGZONES];
2020-04-17 05:54:14 +00:00
static uint16 TotalNumberOfZoneInfos;
2020-05-06 10:23:57 +00:00
static CZoneInfo ZoneInfoArray[2*NUMINFOZONES];
public:
static eLevelName m_CurrLevel;
2019-05-15 14:52:37 +00:00
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);
2020-05-06 10:23:57 +00:00
static CZone *GetInfoZone(uint16 i) { return &InfoZoneArray[i]; }
static CZone *GetNavigationZone(uint16 i) { return &NavigationZoneArray[i]; }
static CZone *GetMapZone(uint16 i) { return &MapZoneArray[i]; }
2020-10-22 09:38:09 +00:00
static CZone *GetAudioZone(uint16 i) { return &NavigationZoneArray[AudioZoneArray[i]]; }
2019-05-15 14:52:37 +00:00
static void PostZoneCreation(void);
2020-05-06 10:23:57 +00:00
static void CheckZonesForOverlap(void);
2019-05-15 14:52:37 +00:00
static void InsertZoneIntoZoneHierarchy(CZone *zone);
static bool InsertZoneIntoZoneHierRecursive(CZone *z1, CZone *z2);
static bool ZoneIsEntirelyContainedWithinOtherZone(CZone *z1, CZone *z2);
2020-05-06 10:23:57 +00:00
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);
2019-05-15 14:52:37 +00:00
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]*/);
2020-05-08 13:16:46 +00:00
static void SetZoneCivilianCarInfo(uint16 zoneid, uint8 day,
const int16* carDensities, const int16* boatDensities);
2019-05-15 14:52:37 +00:00
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);
2020-08-24 15:21:45 +00:00
static CZone *GetPointerForZoneIndex(int32 i) { return i == -1 ? nil : &NavigationZoneArray[i]; }
static int32 GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - NavigationZoneArray; }
2019-05-15 14:52:37 +00:00
static void AddZoneToAudioZoneArray(CZone *zone);
static void InitialiseAudioZoneArray(void);
2019-07-06 10:27:21 +00:00
static void SaveAllZones(uint8 *buffer, uint32 *length);
2020-10-10 20:50:00 +00:00
static void SaveOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType);
2019-07-06 10:27:21 +00:00
static void LoadAllZones(uint8 *buffer, uint32 length);
2020-10-10 20:50:00 +00:00
static void LoadOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType);
2019-05-15 14:52:37 +00:00
};