cleaned up MIAMI ifdefs

This commit is contained in:
aap
2020-05-05 18:06:38 +02:00
parent 2c0b82ec1a
commit e81652c2fc
46 changed files with 95 additions and 2006 deletions

View File

@ -85,19 +85,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
if (pVehicle->UsesSiren(pVehicle->GetModelIndex()))
pVehicle->m_bSirenOrAlarm = true;
}
#ifndef MIAMI
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
pVehicle->m_bSirenOrAlarm = false;
if (CCullZones::NoPolice())
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
}
#else
BackToCruisingIfNoWantedLevel(pVehicle);
#endif
break;
case MISSION_RAMPLAYER_CLOSE:
if (FindSwitchDistanceFar(pVehicle) >= (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||

View File

@ -696,7 +696,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
if (pVehicle->bExtendedRange)
threshold *= 1.5f;
if (distanceToPlayer > threshold && !CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){
if (pVehicle->GetIsOnScreenAndNotCulled()){
if (pVehicle->GetIsOnScreen()){
pVehicle->bFadeOut = true;
}else{
CWorld::Remove(pVehicle);
@ -722,7 +722,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
if (pVehicle->GetStatus() != STATUS_WRECKED || pVehicle->m_nTimeOfDeath == 0)
return;
if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nTimeOfDeath + 60000 &&
!pVehicle->GetIsOnScreenAndNotCulled()){
!pVehicle->GetIsOnScreen()){
if ((pVehicle->GetPosition() - vecPlayerPos).MagnitudeSqr() > SQR(7.5f)){
if (!CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){
CWorld::Remove(pVehicle);
@ -1641,43 +1641,13 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
CPathNode* pTargetNode;
int16 numNodes;
float distanceToTargetNode;
#ifndef MIAMI
if (pTarget && pTarget->m_pCurGroundEntity &&
pTarget->m_pCurGroundEntity->IsBuilding() &&
((CBuilding*)pTarget->m_pCurGroundEntity)->GetIsATreadable() &&
((CTreadable*)pTarget->m_pCurGroundEntity)->m_nodeIndices[0][0] >= 0){
CTreadable* pCurrentMapObject = (CTreadable*)pTarget->m_pCurGroundEntity;
int closestNode = -1;
float minDist = 100000.0f;
for (int i = 0; i < 12; i++){
int node = pCurrentMapObject->m_nodeIndices[0][i];
if (node < 0)
break;
float dist = (ThePaths.m_pathNodes[node].GetPosition() - pTarget->GetPosition()).Magnitude();
if (dist < minDist){
minDist = dist;
closestNode = node;
}
}
ThePaths.DoPathSearch(0, pCurNode->GetPosition(), curNode,
ThePaths.DoPathSearch(0, pCurNode->GetPosition(), curNode,
#ifdef FIX_PATHFIND_BUG
CVector(targetX, targetY, targetZ),
CVector(targetX, targetY, targetZ),
#else
CVector(targetX, targetY, 0.0f),
CVector(targetX, targetY, 0.0f),
#endif
&pTargetNode, &numNodes, 1, pVehicle, &distanceToTargetNode, 999999.9f, closestNode);
}else
#endif
{
ThePaths.DoPathSearch(0, pCurNode->GetPosition(), curNode,
#ifdef FIX_PATHFIND_BUG
CVector(targetX, targetY, targetZ),
#else
CVector(targetX, targetY, 0.0f),
#endif
&pTargetNode, &numNodes, 1, pVehicle, &distanceToTargetNode, 999999.9f, -1);
}
&pTargetNode, &numNodes, 1, pVehicle, &distanceToTargetNode, 999999.9f, -1);
int newNextNode;
int nextLink;

File diff suppressed because it is too large Load Diff

View File

@ -9,9 +9,6 @@ enum
{
NodeTypeExtern = 1,
NodeTypeIntern = 2,
UseInRoadBlock = 1,
ObjectEastWest = 2,
};
enum
@ -55,33 +52,6 @@ public:
struct CPathNode
{
#ifndef MIAMI
CVector pos;
CPathNode *prev;
CPathNode *next;
int16 distance; // in path search
int16 objectIndex;
int16 firstLink;
uint8 numLinks;
uint8 unkBits : 2;
uint8 bDeadEnd : 1;
uint8 bDisabled : 1;
uint8 bBetweenLevels : 1;
int8 group;
CVector &GetPosition(void) { return pos; }
void SetPosition(const CVector &p) { pos = p; }
float GetX(void) { return pos.x; }
float GetY(void) { return pos.y; }
float GetZ(void) { return pos.z; }
CPathNode *GetPrev(void) { return prev; }
CPathNode *GetNext(void) { return next; }
void SetPrev(CPathNode *node) { prev = node; }
void SetNext(CPathNode *node) { next = node; }
#else
int16 prevIndex;
int16 nextIndex;
int16 x;
@ -118,7 +88,6 @@ struct CPathNode
CPathNode *GetNext(void);
void SetPrev(CPathNode *node);
void SetNext(CPathNode *node);
#endif
};
union CConnectionFlags
@ -132,24 +101,6 @@ union CConnectionFlags
struct CCarPathLink
{
#ifndef MIAMI
CVector2D pos;
CVector2D dir;
int16 pathNodeIndex;
int8 numLeftLanes;
int8 numRightLanes;
uint8 trafficLightType;
uint8 bBridgeLights : 1;
// more?
CVector2D &GetPosition(void) { return pos; }
CVector2D &GetDirection(void) { return dir; }
float GetX(void) { return pos.x; }
float GetY(void) { return pos.y; }
float GetDirX(void) { return dir.x; }
float GetDirY(void) { return dir.y; }
#else
int16 x;
int16 y;
int16 pathNodeIndex;
@ -168,7 +119,6 @@ struct CCarPathLink
float GetY(void) { return y/8.0f; }
float GetDirX(void) { return dirX/100.0f; }
float GetDirY(void) { return dirY/100.0f; }
#endif
float OneWayLaneOffset()
{
@ -183,16 +133,6 @@ struct CCarPathLink
// This is what we're reading from the files, only temporary
struct CPathInfoForObject
{
#ifndef MIAMI
int16 x;
int16 y;
int16 z;
int8 type;
int8 next;
int8 numLeftLanes;
int8 numRightLanes;
uint8 crossing : 1;
#else
float x;
float y;
float z;
@ -213,7 +153,6 @@ struct CPathInfoForObject
uint8 spawnRate : 4;
void SwapConnectionsToBeRightWayRound(void);
#endif
};
extern CPathInfoForObject *InfoForTileCars;
extern CPathInfoForObject *InfoForTilePeds;
@ -221,15 +160,6 @@ extern CPathInfoForObject *InfoForTilePeds;
struct CTempNode
{
CVector pos;
#ifndef MIAMI
float dirX;
float dirY;
int16 link1;
int16 link2;
int8 numLeftLanes;
int8 numRightLanes;
int8 linkState;
#else
int8 dirX; // *100
int8 dirY;
int16 link1;
@ -239,10 +169,8 @@ struct CTempNode
int8 width;
bool isCross;
int8 linkState;
#endif
};
#ifdef MIAMI
struct CTempNodeExternal // made up name
{
CVector pos;
@ -252,14 +180,6 @@ struct CTempNodeExternal // made up name
int8 width;
bool isCross;
};
#endif
#ifndef MIAMI
struct CTempDetachedNode // unused
{
uint8 foo[20];
};
#endif
class CPathFind
{
@ -267,15 +187,8 @@ public:
CPathNode m_pathNodes[NUM_PATHNODES];
CCarPathLink m_carPathLinks[NUM_CARPATHLINKS];
CTreadable *m_mapObjects[NUM_MAPOBJECTS];
#ifndef MIAMI
uint8 m_objectFlags[NUM_MAPOBJECTS];
int16 m_connections[NUM_PATHCONNECTIONS];
int16 m_distances[NUM_PATHCONNECTIONS];
CConnectionFlags m_connectionFlags[NUM_PATHCONNECTIONS];
#else
uint16 m_connections[NUM_PATHCONNECTIONS]; // and flags
uint8 m_distances[NUM_PATHCONNECTIONS];
#endif
int16 m_carPathConnections[NUM_PATHCONNECTIONS];
int32 m_numPathNodes;
@ -293,20 +206,12 @@ public:
void RegisterMapObject(CTreadable *mapObject);
void StoreNodeInfoPed(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, bool crossing);
void StoreNodeInfoCar(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, int8 numLeft, int8 numRight);
#ifndef MIAMI
void CalcNodeCoors(int16 x, int16 y, int16 z, int32 id, CVector *out);
#else
void CalcNodeCoors(float x, float y, float z, int32 id, CVector *out);
#endif
bool LoadPathFindData(void);
void PreparePathData(void);
void CountFloodFillGroups(uint8 type);
void PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoForObject *objectpathinfo,
#ifndef MIAMI
float maxdist, CTempDetachedNode *detachednodes, int32 numDetached);
#else
float maxdist, CPathInfoForObject *detachednodes, int32 numDetached);
#endif
bool IsPathObject(int id) { return id < PATHNODESIZE && (InfoForTileCars[id*12].type != 0 || InfoForTilePeds[id*12].type != 0); }
@ -324,27 +229,19 @@ public:
void MarkRoadsBetweenLevelsNodeAndNeighbours(int32 nodeId);
void MarkRoadsBetweenLevelsInArea(float x1, float x2, float y1, float y2, float z1, float z2);
void PedMarkRoadsBetweenLevelsInArea(float x1, float x2, float y1, float y2, float z1, float z2);
#ifndef MIAMI
int32 FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool ignoreDisabled = false, bool ignoreBetweenLevels = false);
#else
//--MIAMI: TODO: check callers for new arguments
// TODO(MIAMI): check callers for new arguments
int32 FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool ignoreDisabled = false, bool ignoreBetweenLevels = false, bool ignoreFlagB4 = false, bool bWaterPath = false);
#endif
int32 FindNodeClosestToCoorsFavourDirection(CVector coors, uint8 type, float dirX, float dirY);
float FindNodeOrientationForCarPlacement(int32 nodeId);
float FindNodeOrientationForCarPlacementFacingDestination(int32 nodeId, float x, float y, bool towards);
bool NewGenerateCarCreationCoors(float x, float y, float dirX, float dirY, float spawnDist, float angleLimit, bool forward, CVector *pPosition, int32 *pNode1, int32 *pNode2, float *pPositionBetweenNodes, bool ignoreDisabled = false);
bool GeneratePedCreationCoors(float x, float y, float minDist, float maxDist, float minDistOffScreen, float maxDistOffScreen, CVector *pPosition, int32 *pNode1, int32 *pNode2, float *pPositionBetweenNodes, CMatrix *camMatrix);
#ifndef MIAMI
CTreadable *FindRoadObjectClosestToCoors(CVector coors, uint8 type);
#endif
void FindNextNodeWandering(uint8, CVector, CPathNode**, CPathNode**, uint8, uint8*);
void DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector target, CPathNode **nodes, int16 *numNodes, int16 maxNumNodes, CVehicle *vehicle, float *dist, float distLimit, int32 forcedTargetNode);
bool TestCoorsCloseness(CVector target, uint8 type, CVector start);
void Save(uint8 *buf, uint32 *size);
void Load(uint8 *buf, uint32 size);
#ifdef MIAMI
CPathNode *GetNode(int16 index);
int16 GetIndex(CPathNode *node);
@ -352,27 +249,16 @@ public:
bool ConnectionCrossesRoad(int id) { return !!(m_connections[id] & 0x8000); }
bool ConnectionHasTrafficLight(int id) { return !!(m_connections[id] & 0x4000); }
void ConnectionSetTrafficLight(int id) { m_connections[id] |= 0x4000; }
#else
uint16 ConnectedNode(int id) { return m_connections[id]; }
bool ConnectionCrossesRoad(int id) { return m_connectionFlags[id].bCrossesRoad; }
bool ConnectionHasTrafficLight(int id) { return m_connectionFlags[id].bTrafficLight; }
void ConnectionSetTrafficLight(int id) { m_connectionFlags[id].bTrafficLight = true; }
#endif
void DisplayPathData(void);
};
#ifndef MIAMI
static_assert(sizeof(CPathFind) == 0x49bf4, "CPathFind: error");
#endif
extern CPathFind ThePaths;
#ifdef MIAMI
inline CPathNode *CPathNode::GetPrev(void) { return ThePaths.GetNode(prevIndex); }
inline CPathNode *CPathNode::GetNext(void) { return ThePaths.GetNode(nextIndex); }
inline void CPathNode::SetPrev(CPathNode *node) { prevIndex = ThePaths.GetIndex(node); }
inline void CPathNode::SetNext(CPathNode *node) { nextIndex = ThePaths.GetIndex(node); }
#endif
extern bool gbShowPedPaths;
extern bool gbShowCarPaths;

View File

@ -420,19 +420,6 @@ void CRecordDataForChase::GiveUsACar(int32 mi, CVector pos, float angle, CAutomo
//--MIAMI: unused
void RemoveUnusedCollision(void)
{
#ifndef MIAMI
static const char* dontDeleteArray[] = {
"rd_SrRoad2A50", "rd_SrRoad2A20", "rd_CrossRda1w22", "rd_CrossRda1rw22",
"road_broadway02", "road_broadway01", "com_21way5", "com_21way50",
"cm1waycrosscom", "com_21way20", "com_21way10", "road_broadway04",
"com_rvroads52", "com_roadsrv", "com_roadkb23", "com_roadkb22"
};
for (int i = 0; i < ARRAY_SIZE(dontDeleteArray); i++)
CModelInfo::GetModelInfo(dontDeleteArray[i], nil)->GetColModel()->level = LEVEL_NONE;
CModelInfo::RemoveColModelsFromOtherLevels(LEVEL_NONE);
for (int i = 0; i < ARRAY_SIZE(dontDeleteArray); i++)
CModelInfo::GetModelInfo(dontDeleteArray[i], nil)->GetColModel()->level = LEVEL_COMMERCIAL;
#endif
}
void CRecordDataForChase::StartChaseScene(float startTime)

View File

@ -15,40 +15,23 @@
#include "CarCtrl.h"
#include "General.h"
#ifndef MIAMI
#define ROADBLOCKDIST (80.0f)
#else
#define ROADBLOCKDIST (90.0f)
#endif
int16 CRoadBlocks::NumRoadBlocks;
#ifndef MIAMI
int16 CRoadBlocks::RoadBlockObjects[NUMROADBLOCKS];
#else
int16 CRoadBlocks::RoadBlockNodes[NUMROADBLOCKS];
#endif
bool CRoadBlocks::InOrOut[NUMROADBLOCKS];
//--MIAMI: TODO: script roadblocks
//--MIAMI: TODO
void
CRoadBlocks::Init(void)
{
int i;
NumRoadBlocks = 0;
#ifndef MIAMI
for (i = 0; i < ThePaths.m_numMapObjects; i++) {
if (ThePaths.m_objectFlags[i] & UseInRoadBlock) {
#else
for(i = 0; i < ThePaths.m_numCarPathNodes; i++){
if(ThePaths.m_pathNodes[i].bUseInRoadBlock && ThePaths.m_pathNodes[i].numLinks == 2){
#endif
if (NumRoadBlocks < NUMROADBLOCKS) {
InOrOut[NumRoadBlocks] = true;
#ifndef MIAMI
RoadBlockObjects[NumRoadBlocks] = i;
#else
RoadBlockNodes[NumRoadBlocks] = i;
#endif
NumRoadBlocks++;
} else {
#ifndef MASTER
@ -59,6 +42,8 @@ CRoadBlocks::Init(void)
}
}
}
// TODO(MIAMI): script roadblocks
}
void
@ -120,6 +105,7 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
}
}
//--MIAMI: TODO: implement this
void
CRoadBlocks::GenerateRoadBlocks(void)
{
@ -128,12 +114,7 @@ CRoadBlocks::GenerateRoadBlocks(void)
int16 nRoadblockNode = (int16)(NUMROADBLOCKS * frame) / 16;
const int16 maxRoadBlocks = (int16)(NUMROADBLOCKS * (frame + 1)) / 16;
for (; nRoadblockNode < Min(NumRoadBlocks, maxRoadBlocks); nRoadblockNode++) {
#ifndef MIAMI
CTreadable *mapObject = ThePaths.m_mapObjects[RoadBlockObjects[nRoadblockNode]];
CVector2D vecDistance = FindPlayerCoors() - mapObject->GetPosition();
#else
CVector2D vecDistance = FindPlayerCoors() - ThePaths.m_pathNodes[nRoadblockNode].GetPosition();
#endif
if (vecDistance.x > -ROADBLOCKDIST && vecDistance.x < ROADBLOCKDIST &&
vecDistance.y > -ROADBLOCKDIST && vecDistance.y < ROADBLOCKDIST &&
vecDistance.Magnitude() < ROADBLOCKDIST) {
@ -218,5 +199,5 @@ CRoadBlocks::GenerateRoadBlocks(void)
}
}
//--MIAMI: TODO script roadblocks
// TODO(MIAMI): script roadblocks
}

View File

@ -372,9 +372,7 @@ private:
friend class CRunningScript;
friend class CHud;
friend void CMissionCleanup::Process();
#ifdef MIAMI
friend class CColStore;
#endif
};