2019-05-15 16:52:37 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Game.h"
|
|
|
|
#include "Lists.h"
|
2019-06-15 01:34:19 +02:00
|
|
|
#include "PlayerInfo.h"
|
2019-05-15 16:52:37 +02:00
|
|
|
|
2020-05-05 23:27:43 +02:00
|
|
|
/* Sectors span from -2400 to 1600 in x and -2000 to 2000 y.
|
|
|
|
* With 80x80 sectors, each is 50x50 units. */
|
2019-05-15 16:52:37 +02:00
|
|
|
|
2020-05-05 23:27:43 +02:00
|
|
|
#define SECTOR_SIZE_X (50.0f)
|
|
|
|
#define SECTOR_SIZE_Y (50.0f)
|
2019-06-21 11:09:09 +02:00
|
|
|
|
2020-05-05 23:27:43 +02:00
|
|
|
#define NUMSECTORS_X (80)
|
|
|
|
#define NUMSECTORS_Y (80)
|
2019-06-21 11:09:09 +02:00
|
|
|
|
|
|
|
#define WORLD_SIZE_X (NUMSECTORS_X * SECTOR_SIZE_X)
|
|
|
|
#define WORLD_SIZE_Y (NUMSECTORS_Y * SECTOR_SIZE_Y)
|
|
|
|
|
2020-05-05 23:27:43 +02:00
|
|
|
#define WORLD_MIN_X (-2400.0f)
|
2019-06-21 11:09:09 +02:00
|
|
|
#define WORLD_MIN_Y (-2000.0f)
|
|
|
|
|
|
|
|
#define WORLD_MAX_X (WORLD_MIN_X + WORLD_SIZE_X)
|
|
|
|
#define WORLD_MAX_Y (WORLD_MIN_Y + WORLD_SIZE_Y)
|
2019-05-15 16:52:37 +02:00
|
|
|
|
2020-01-03 17:48:13 +01:00
|
|
|
#define MAP_Z_LOW_LIMIT -100.0f
|
|
|
|
|
2019-05-15 16:52:37 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ENTITYLIST_BUILDINGS,
|
|
|
|
ENTITYLIST_BUILDINGS_OVERLAP,
|
|
|
|
ENTITYLIST_OBJECTS,
|
|
|
|
ENTITYLIST_OBJECTS_OVERLAP,
|
|
|
|
ENTITYLIST_VEHICLES,
|
|
|
|
ENTITYLIST_VEHICLES_OVERLAP,
|
|
|
|
ENTITYLIST_PEDS,
|
|
|
|
ENTITYLIST_PEDS_OVERLAP,
|
|
|
|
ENTITYLIST_DUMMIES,
|
|
|
|
ENTITYLIST_DUMMIES_OVERLAP,
|
|
|
|
|
|
|
|
NUMSECTORENTITYLISTS
|
|
|
|
};
|
|
|
|
|
|
|
|
class CSector
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CPtrList m_lists[NUMSECTORENTITYLISTS];
|
|
|
|
};
|
2020-05-10 15:54:37 +02:00
|
|
|
|
2020-05-10 17:49:33 +02:00
|
|
|
VALIDATE_SIZE(CSector, 0x28);
|
2019-05-15 16:52:37 +02:00
|
|
|
|
2019-05-17 14:08:18 +02:00
|
|
|
class CEntity;
|
2019-05-28 08:39:36 +02:00
|
|
|
struct CColPoint;
|
|
|
|
struct CColLine;
|
|
|
|
struct CStoredCollPoly;
|
2019-05-17 14:08:18 +02:00
|
|
|
|
2019-05-15 16:52:37 +02:00
|
|
|
class CWorld
|
|
|
|
{
|
2020-04-17 15:31:11 +02:00
|
|
|
static CPtrList ms_bigBuildingsList[4];
|
|
|
|
static CPtrList ms_listMovingEntityPtrs;
|
|
|
|
static CSector ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];
|
|
|
|
static uint16 ms_nCurrentScanCode;
|
2019-05-15 16:52:37 +02:00
|
|
|
|
|
|
|
public:
|
2020-04-17 15:31:11 +02:00
|
|
|
static uint8 PlayerInFocus;
|
2020-04-15 18:19:45 +02:00
|
|
|
static CPlayerInfo Players[NUMPLAYERS];
|
2020-04-17 15:31:11 +02:00
|
|
|
static CEntity *pIgnoreEntity;
|
|
|
|
static bool bIncludeDeadPeds;
|
|
|
|
static bool bNoMoreCollisionTorque;
|
|
|
|
static bool bSecondShift;
|
|
|
|
static bool bForceProcessControl;
|
|
|
|
static bool bProcessCutsceneOnly;
|
|
|
|
static bool bDoingCarCollisions;
|
|
|
|
static bool bIncludeCarTyres;
|
2020-05-24 15:14:27 +02:00
|
|
|
static CColPoint m_aTempColPts[MAX_COLLISION_POINTS];
|
2019-05-17 14:08:18 +02:00
|
|
|
|
2019-06-29 13:38:37 +02:00
|
|
|
static void Remove(CEntity *entity);
|
2019-06-18 09:50:26 +02:00
|
|
|
static void Add(CEntity *entity);
|
2019-05-15 16:52:37 +02:00
|
|
|
|
|
|
|
static CSector *GetSector(int x, int y) { return &ms_aSectors[y][x]; }
|
|
|
|
static CPtrList &GetBigBuildingList(eLevelName i) { return ms_bigBuildingsList[i]; }
|
|
|
|
static CPtrList &GetMovingEntityList(void) { return ms_listMovingEntityPtrs; }
|
|
|
|
static uint16 GetCurrentScanCode(void) { return ms_nCurrentScanCode; }
|
|
|
|
static void AdvanceCurrentScanCode(void){
|
|
|
|
if(++CWorld::ms_nCurrentScanCode == 0){
|
|
|
|
CWorld::ClearScanCodes();
|
|
|
|
CWorld::ms_nCurrentScanCode = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void ClearScanCodes(void);
|
2020-04-16 20:46:08 +02:00
|
|
|
static void ClearExcitingStuffFromArea(const CVector &pos, float radius, bool bRemoveProjectilesAndTidyUpShadows);
|
2019-05-15 16:52:37 +02:00
|
|
|
|
2019-05-28 08:39:36 +02:00
|
|
|
static bool CameraToIgnoreThisObject(CEntity *ent);
|
|
|
|
|
2020-05-24 15:14:27 +02:00
|
|
|
static bool ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false, bool ignoreShootThrough = false);
|
|
|
|
static bool ProcessLineOfSightSector(CSector §or, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects, bool ignoreShootThrough);
|
|
|
|
static bool ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool ignoreSeeThrough, bool ignoreSomeObjects, bool ignoreShootThrough);
|
2019-05-28 08:39:36 +02:00
|
|
|
static bool ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, CStoredCollPoly *poly);
|
|
|
|
static bool ProcessVerticalLineSector(CSector §or, const CColLine &line, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, CStoredCollPoly *poly);
|
|
|
|
static bool ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool ignoreSeeThrough, CStoredCollPoly *poly);
|
|
|
|
static bool GetIsLineOfSightClear(const CVector &point1, const CVector &point2, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false);
|
|
|
|
static bool GetIsLineOfSightSectorClear(CSector §or, const CColLine &line, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false);
|
|
|
|
static bool GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bool ignoreSeeThrough, bool ignoreSomeObjects = false);
|
2019-07-10 08:06:43 +02:00
|
|
|
|
2020-03-26 14:16:06 +01:00
|
|
|
static CEntity *TestSphereAgainstWorld(CVector centre, float radius, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects);
|
2019-08-04 00:31:00 +02:00
|
|
|
static CEntity *TestSphereAgainstSectorList(CPtrList&, CVector, float, CEntity*, bool);
|
2020-04-30 12:48:01 +02:00
|
|
|
static void FindObjectsInRangeSectorList(CPtrList&, Const CVector&, float, bool, short*, short, CEntity**);
|
|
|
|
static void FindObjectsInRange(Const CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool);
|
2020-04-16 20:46:08 +02:00
|
|
|
static void FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities);
|
|
|
|
static void FindObjectsOfTypeInRange(uint32 modelId, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies);
|
2019-05-28 08:39:36 +02:00
|
|
|
static float FindGroundZForCoord(float x, float y);
|
|
|
|
static float FindGroundZFor3DCoord(float x, float y, float z, bool *found);
|
|
|
|
static float FindRoofZFor3DCoord(float x, float y, float z, bool *found);
|
2019-07-14 11:49:03 +02:00
|
|
|
static void RemoveReferencesToDeletedObject(CEntity*);
|
2020-04-16 20:46:08 +02:00
|
|
|
static void FindObjectsKindaColliding(const CVector& position, float radius, bool bCheck2DOnly, int16* nCollidingEntities, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies);
|
|
|
|
static void FindObjectsKindaCollidingSectorList(CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nCollidingEntities, int16 maxEntitiesToFind, CEntity** aEntities);
|
|
|
|
static void FindObjectsIntersectingCube(const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies);
|
|
|
|
static void FindObjectsIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities);
|
2020-05-06 17:56:38 +02:00
|
|
|
static void FindObjectsIntersectingAngledCollisionBox(const CBox &, const CMatrix &, const CVector &, float, float, float, float, int16*, int16, CEntity **, bool, bool, bool, bool, bool);
|
|
|
|
static void FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList& list, const CBox& boundingBox, const CMatrix& matrix, const CVector& position, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities);
|
2020-04-16 20:46:08 +02:00
|
|
|
static void FindMissionEntitiesIntersectingCube(const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bVehicles, bool bPeds, bool bObjects);
|
|
|
|
static void FindMissionEntitiesIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bIsVehicleList, bool bIsPedList);
|
|
|
|
|
|
|
|
static void ClearCarsFromArea(float x1, float y1, float z1, float x2, float y2, float z2);
|
|
|
|
static void ClearPedsFromArea(float x1, float y1, float z1, float x2, float y2, float z2);
|
|
|
|
static void CallOffChaseForArea(float x1, float y1, float x2, float y2);
|
|
|
|
static void CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1, float x2, float y2, float fStartX, float fStartY, float fEndX, float fEndY);
|
|
|
|
static void CallOffChaseForAreaSectorListPeds(CPtrList& list, float x1, float y1, float x2, float y2);
|
2019-05-28 08:39:36 +02:00
|
|
|
|
2020-05-16 00:49:30 +02:00
|
|
|
static bool IsWanderPathClear(CVector const&, CVector const&, float, int);
|
|
|
|
|
2019-06-21 11:09:09 +02:00
|
|
|
static float GetSectorX(float f) { return ((f - WORLD_MIN_X)/SECTOR_SIZE_X); }
|
|
|
|
static float GetSectorY(float f) { return ((f - WORLD_MIN_Y)/SECTOR_SIZE_Y); }
|
2019-05-15 16:52:37 +02:00
|
|
|
static int GetSectorIndexX(float f) { return (int)GetSectorX(f); }
|
|
|
|
static int GetSectorIndexY(float f) { return (int)GetSectorY(f); }
|
2019-06-21 11:09:09 +02:00
|
|
|
static float GetWorldX(int x) { return x*SECTOR_SIZE_X + WORLD_MIN_X; }
|
|
|
|
static float GetWorldY(int y) { return y*SECTOR_SIZE_Y + WORLD_MIN_Y; }
|
2019-08-15 16:51:39 +02:00
|
|
|
|
2019-09-12 02:43:18 +02:00
|
|
|
static void RemoveEntityInsteadOfProcessingIt(CEntity* ent);
|
|
|
|
static void RemoveFallenPeds();
|
|
|
|
static void RemoveFallenCars();
|
|
|
|
|
2019-10-21 23:39:59 +02:00
|
|
|
static void StopAllLawEnforcersInTheirTracks();
|
2019-12-02 21:02:32 +01:00
|
|
|
static void SetAllCarsCanBeDamaged(bool);
|
|
|
|
static void ExtinguishAllCarFiresInArea(CVector, float);
|
2020-04-16 20:46:08 +02:00
|
|
|
static void SetCarsOnFire(float x, float y, float z, float radius, CEntity* reason);
|
|
|
|
static void SetPedsOnFire(float x, float y, float z, float radius, CEntity* reason);
|
2019-10-21 23:39:59 +02:00
|
|
|
|
2019-08-15 16:51:39 +02:00
|
|
|
static void Initialise();
|
2020-03-22 15:23:40 +01:00
|
|
|
static void AddParticles();
|
2019-08-15 16:51:39 +02:00
|
|
|
static void ShutDown();
|
2020-03-28 21:55:23 +01:00
|
|
|
static void ClearForRestart(void);
|
2019-10-19 00:23:40 +02:00
|
|
|
static void RepositionCertainDynamicObjects();
|
2020-04-16 20:46:08 +02:00
|
|
|
static void RepositionOneObject(CEntity* pEntity);
|
2019-10-19 00:23:40 +02:00
|
|
|
static void RemoveStaticObjects();
|
2019-08-15 16:51:39 +02:00
|
|
|
static void Process();
|
2020-04-16 20:46:08 +02:00
|
|
|
static void TriggerExplosion(const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer);
|
|
|
|
static void TriggerExplosionSectorList(CPtrList& list, const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer);
|
2020-04-17 00:20:34 +02:00
|
|
|
static void UseDetonator(CEntity *pEntity);
|
2019-05-15 16:52:37 +02:00
|
|
|
};
|
|
|
|
|
2020-04-15 18:19:45 +02:00
|
|
|
extern CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
|
2020-03-26 14:16:06 +01:00
|
|
|
|
2019-06-25 00:42:23 +02:00
|
|
|
class CPlayerPed;
|
2019-05-15 16:52:37 +02:00
|
|
|
class CVehicle;
|
2019-06-25 00:42:23 +02:00
|
|
|
CPlayerPed *FindPlayerPed(void);
|
2019-05-15 16:52:37 +02:00
|
|
|
CVehicle *FindPlayerVehicle(void);
|
|
|
|
CVehicle *FindPlayerTrain(void);
|
2019-06-29 11:09:33 +02:00
|
|
|
CEntity *FindPlayerEntity(void);
|
|
|
|
CVector FindPlayerCoors(void);
|
2019-06-23 13:11:41 +02:00
|
|
|
CVector &FindPlayerSpeed(void);
|
2020-05-05 03:45:18 +02:00
|
|
|
const CVector &FindPlayerCentreOfWorld(int32 player);
|
|
|
|
const CVector &FindPlayerCentreOfWorld_NoSniperShift(void);
|
2019-06-20 02:31:03 +02:00
|
|
|
float FindPlayerHeading(void);
|