Merge remote-tracking branch 'upstream/miami' into miami

This commit is contained in:
Nikolay Korolev 2020-05-05 20:22:17 +03:00
commit f45ea0a1cf
45 changed files with 112 additions and 2023 deletions

View File

@ -23,7 +23,7 @@ else
Librw = os.getenv("LIBRW") or "librw"
end
workspace "re3"
workspace "reVC"
language "C++"
configurations { "Debug", "Release" }
location "build"
@ -103,7 +103,7 @@ project "librw"
filter {}
end
project "re3"
project "reVC"
kind "WindowedApp"
targetname "re3"
targetdir "bin/%{cfg.platform}/%{cfg.buildcfg}"
@ -111,6 +111,7 @@ project "re3"
characterset ("MBCS")
linkoptions "/SAFESEH:NO"
defines { "MIAMI" }
files { "src/*.*" }
files { "src/animation/*.*" }
@ -161,7 +162,7 @@ project "re3"
libdirs { "milessdk/lib" }
setpaths("$(GTA_III_RE_DIR)/", "$(TargetFileName)", "")
setpaths("$(GTA_VC_RE_DIR)/", "$(TargetFileName)", "")
filter "platforms:*RW33*"
staticruntime "on"

View File

@ -698,7 +698,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);
@ -724,7 +724,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);
@ -1643,43 +1643,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
};

View File

@ -1,5 +1,4 @@
#include "common.h"
#ifdef MIAMI
#include "templates.h"
#include "General.h"
@ -227,5 +226,3 @@ CColStore::HasCollisionLoaded(const CVector2D &pos)
return false;
return true;
}
#endif

View File

@ -20,10 +20,8 @@
#include "SurfaceTable.h"
#include "Lines.h"
#include "Collision.h"
#ifdef MIAMI
#include "Camera.h"
#include "ColStore.h"
#endif
enum Direction
{
@ -44,9 +42,7 @@ CCollision::Init(void)
{
ms_colModelCache.Init(NUMCOLCACHELINKS);
ms_collisionInMemory = LEVEL_NONE;
#ifdef MIAMI
CColStore::Initialise();
#endif
}
//--MIAMI: done
@ -54,50 +50,13 @@ void
CCollision::Shutdown(void)
{
ms_colModelCache.Shutdown();
#ifdef MIAMI
CColStore::Shutdown();
#endif
}
//--MIAMI: done
void
CCollision::Update(void)
{
#ifndef MIAMI
CVector playerCoors;
playerCoors = FindPlayerCoors();
eLevelName level = CTheZones::m_CurrLevel;
bool forceLevelChange = false;
if(CTimer::GetTimeInMilliseconds() < 2000 || CCutsceneMgr::IsCutsceneProcessing())
return;
// hardcode a level if there are no zones
if(level == LEVEL_NONE){
if(CGame::currLevel == LEVEL_INDUSTRIAL &&
playerCoors.x < 400.0f){
level = LEVEL_COMMERCIAL;
forceLevelChange = true;
}else if(CGame::currLevel == LEVEL_SUBURBAN &&
playerCoors.x > -450.0f && playerCoors.y < -1400.0f){
level = LEVEL_COMMERCIAL;
forceLevelChange = true;
}else{
if(playerCoors.x > 800.0f){
level = LEVEL_INDUSTRIAL;
forceLevelChange = true;
}else if(playerCoors.x < -800.0f){
level = LEVEL_SUBURBAN;
forceLevelChange = true;
}
}
}
if(level != LEVEL_NONE && level != CGame::currLevel)
CGame::currLevel = level;
if(ms_collisionInMemory != CGame::currLevel)
LoadCollisionWhenINeedIt(forceLevelChange);
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
#endif
}
//--MIAMI: unused
@ -142,116 +101,12 @@ GetCollisionInSector(CSector &sect)
void
CCollision::LoadCollisionWhenINeedIt(bool forceChange)
{
#ifndef MIAMI
eLevelName level, l;
bool multipleLevels;
CVector playerCoors;
CVehicle *veh;
CEntryInfoNode *ei;
int sx, sy;
int xmin, xmax, ymin, ymax;
int x, y;
level = LEVEL_NONE;
playerCoors = FindPlayerCoors();
sx = CWorld::GetSectorIndexX(playerCoors.x);
sy = CWorld::GetSectorIndexY(playerCoors.y);
multipleLevels = false;
veh = FindPlayerVehicle();
if(veh && veh->IsTrain()){
if(((CTrain*)veh)->m_nDoorState != TRAIN_DOOR_OPEN)
return;
}else if(playerCoors.z < -4.0f && !CCullZones::DoINeedToLoadCollision())
return;
// Figure out whose level's collisions we're most likely to be interested in
if(!forceChange){
if(veh && veh->IsBoat()){
// on water we expect to be between levels
multipleLevels = true;
}else{
xmin = Max(sx - 1, 0);
xmax = Min(sx + 1, NUMSECTORS_X-1);
ymin = Max(sy - 1, 0);
ymax = Min(sy + 1, NUMSECTORS_Y-1);
for(x = xmin; x <= xmax; x++)
for(y = ymin; y <= ymax; y++){
l = GetCollisionInSector(*CWorld::GetSector(x, y));
if(l != LEVEL_NONE){
if(level == LEVEL_NONE)
level = l;
if(level != l)
multipleLevels = true;
}
}
}
if(multipleLevels && veh && veh->IsBoat())
for(ei = veh->m_entryInfoList.first; ei; ei = ei->next){
level = GetCollisionInSector(*ei->sector);
if(level != LEVEL_NONE)
break;
}
}
if(level == CGame::currLevel || forceChange){
CTimer::Stop();
DMAudio.SetEffectsFadeVol(0);
CPad::StopPadsShaking();
LoadCollisionScreen(CGame::currLevel);
DMAudio.Service();
CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false);
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN);
CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL);
CStreaming::RemoveBigBuildings(LEVEL_COMMERCIAL);
CStreaming::RemoveBigBuildings(LEVEL_SUBURBAN);
CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel);
CStreaming::RemoveUnusedModelsInLoadedList();
CGame::TidyUpMemory(true, true);
CFileLoader::LoadCollisionFromDatFile(CGame::currLevel);
ms_collisionInMemory = CGame::currLevel;
CReplay::EmptyReplayBuffer();
if(CGame::currLevel != LEVEL_NONE)
LoadSplash(GetLevelSplashScreen(CGame::currLevel));
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel);
CStreaming::RequestBigBuildings(CGame::currLevel);
CStreaming::LoadAllRequestedModels(true);
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
CGame::TidyUpMemory(true, true);
CTimer::Update();
DMAudio.SetEffectsFadeVol(127);
}
#endif
}
//--MIAMI: done
void
CCollision::SortOutCollisionAfterLoad(void)
{
#ifndef MIAMI
if(ms_collisionInMemory == CGame::currLevel)
return;
CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel);
if(CGame::currLevel != LEVEL_NONE){
CFileLoader::LoadCollisionFromDatFile(CGame::currLevel);
if(!CGame::playingIntro)
LoadSplash(GetLevelSplashScreen(CGame::currLevel));
}
ms_collisionInMemory = CGame::currLevel;
CGame::TidyUpMemory(true, false);
#else
CColStore::LoadCollision(TheCamera.GetPosition());
CStreaming::LoadAllRequestedModels(false);
#endif
}
void
@ -2000,11 +1855,7 @@ CColModel::CColModel(void)
vertices = nil;
triangles = nil;
trianglePlanes = nil;
#ifndef MIAMI
level = CGame::currLevel;
#else
level = 0; // generic col slot
#endif
ownsCollisionVolumes = true;
}

View File

@ -87,17 +87,14 @@ struct CStoredCollPoly
struct CColModel
{
// TODO(MIAMI): CSphere and CBox
CColSphere boundingSphere;
CColBox boundingBox;
int16 numSpheres;
int16 numLines;
int16 numBoxes;
int16 numTriangles;
#ifndef MIAMI
int32 level;
#else
uint8 level; // colstore slot but probably same name
#endif
uint8 level; // colstore slot but probably still named level
bool ownsCollisionVolumes;
CColSphere *spheres;
CColLine *lines;

View File

@ -24,10 +24,8 @@
#include "ZoneCull.h"
#include "CdStream.h"
#include "FileLoader.h"
#ifdef MIAMI
#include "Streaming.h"
#include "ColStore.h"
#endif
char CFileLoader::ms_line[256];
@ -50,16 +48,12 @@ CFileLoader::LoadLevel(const char *filename)
{
int fd;
RwTexDictionary *savedTxd;
eLevelName savedLevel;
bool objectsLoaded;
char *line;
char txdname[64];
savedTxd = RwTexDictionaryGetCurrent();
objectsLoaded = false;
#ifndef MIAMI
savedLevel = CGame::currLevel;
#endif
if(savedTxd == nil){
savedTxd = RwTexDictionaryCreate();
RwTexDictionarySetCurrent(savedTxd);
@ -83,17 +77,8 @@ CFileLoader::LoadLevel(const char *filename)
AddTexDictionaries(savedTxd, txd);
RwTexDictionaryDestroy(txd);
}else if(strncmp(line, "COLFILE", 7) == 0){
#ifndef MIAMI
int level;
sscanf(line+8, "%d", &level);
CGame::currLevel = (eLevelName)level;
LoadingScreenLoadingFile(line+10);
LoadCollisionFile(line+10);
CGame::currLevel = savedLevel;
#else
LoadingScreenLoadingFile(line+10);
LoadCollisionFile(line+10, 0);
#endif
}else if(strncmp(line, "MODELFILE", 9) == 0){
LoadingScreenLoadingFile(line + 10);
LoadModelFile(line + 10);
@ -105,16 +90,11 @@ CFileLoader::LoadLevel(const char *filename)
LoadObjectTypes(line + 4);
}else if(strncmp(line, "IPL", 3) == 0){
if(!objectsLoaded){
#ifndef MIAMI
CModelInfo::ConstructMloClumps();
CObjectData::Initialise("DATA\\OBJECT.DAT");
#else
LoadingScreenLoadingFile("Collision");
CObjectData::Initialise("DATA\\OBJECT.DAT");
CStreaming::Init();
CColStore::LoadAllCollision();
// TODO: anim indices
#endif
// TODO(MIAMI): anim indices
objectsLoaded = true;
}
LoadingScreenLoadingFile(line + 4);
@ -132,42 +112,14 @@ CFileLoader::LoadLevel(const char *filename)
CFileMgr::CloseFile(fd);
RwTexDictionarySetCurrent(savedTxd);
#ifdef MIAMI
int i;
for(i = 1; i < COLSTORESIZE; i++)
if(CColStore::GetSlot(i))
CColStore::GetBoundingBox(i).Grow(120.0f);
CWorld::RepositionCertainDynamicObjects();
CColStore::RemoveAllCollision();
#endif
}
#ifndef MIAMI
void
CFileLoader::LoadCollisionFromDatFile(int currlevel)
{
int fd;
char *line;
fd = CFileMgr::OpenFile(CGame::aDatFile, "r");
assert(fd > 0);
for(line = LoadLine(fd); line; line = LoadLine(fd)){
if(*line == '#')
continue;
if(strncmp(line, "COLFILE", 7) == 0){
int level;
sscanf(line+8, "%d", &level);
if(currlevel == level)
LoadCollisionFile(line+10);
}
}
CFileMgr::CloseFile(fd);
}
#endif
char*
CFileLoader::LoadLine(int fd)
{
@ -209,13 +161,8 @@ struct ColHeader
};
//--MIAMI: done
#ifndef MIAMI
void
CFileLoader::LoadCollisionFile(const char *filename)
#else
void
CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
#endif
{
int fd;
char modelname[24];
@ -232,17 +179,11 @@ CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
mi = CModelInfo::GetModelInfo(modelname, nil);
if(mi){
#ifndef MIAMI
if(mi->GetColModel()){
#else
if(mi->GetColModel() && mi->DoesOwnColModel()){
#endif
LoadCollisionModel(work_buff+24, *mi->GetColModel(), modelname);
}else{
CColModel *model = new CColModel;
#ifdef MIAMI
model->level = colSlot;
#endif
LoadCollisionModel(work_buff+24, *model, modelname);
mi->SetColModel(model, true);
}
@ -254,7 +195,6 @@ CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
CFileMgr::CloseFile(fd);
}
#ifdef MIAMI
bool
CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlot)
{
@ -278,8 +218,6 @@ CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlo
mi = CModelInfo::GetModelInfo(modelname, &modelIndex);
if(mi){
if(modelIndex == 855)
modelIndex = modelIndex;
CColStore::IncludeModelIndex(colSlot, modelIndex);
CColModel *model = new CColModel;
model->level = colSlot;
@ -328,7 +266,6 @@ CFileLoader::LoadCollisionFile(uint8 *buffer, uint32 size, uint8 colSlot)
}
return true;
}
#endif
void
CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
@ -617,7 +554,6 @@ CFileLoader::LoadObjectTypes(const char *filename)
enum {
NONE,
OBJS,
MLO,
TOBJ,
HIER,
CARS,
@ -652,16 +588,10 @@ CFileLoader::LoadObjectTypes(const char *filename)
else if(strncmp(line, "path", 4) == 0) section = PATH;
else if(strncmp(line, "2dfx", 4) == 0) section = TWODFX;
}else if(strncmp(line, "end", 3) == 0){
section = section == MLO ? OBJS : NONE;
section = NONE;
}else switch(section){
case OBJS:
if(strncmp(line, "sta", 3) == 0)
mlo = LoadMLO(line);
else
LoadObject(line);
break;
case MLO:
LoadMLOInstance(mlo, line);
LoadObject(line);
break;
case TOBJ:
LoadTimeObject(line);
@ -764,57 +694,6 @@ CFileLoader::LoadObject(const char *line)
MatchModelString(model, id);
}
int
CFileLoader::LoadMLO(const char *line)
{
char smth[8];
char name[24];
int modelIndex;
float someFloat;
sscanf(line, "%s %s %d %f", smth, name, &modelIndex, &someFloat);
CMloModelInfo *minfo = CModelInfo::AddMloModel(modelIndex);
minfo->SetName(name);
minfo->field_34 = someFloat;
int instId = CModelInfo::GetMloInstanceStore().allocPtr;
minfo->firstInstance = instId;
minfo->lastInstance = instId;
minfo->SetTexDictionary("generic");
return modelIndex;
}
void
CFileLoader::LoadMLOInstance(int id, const char *line)
{
char name[24];
RwV3d pos, scale, rot;
float angle;
int modelIndex;
CMloModelInfo *minfo = (CMloModelInfo*)CModelInfo::GetModelInfo(id);
sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f",
&modelIndex,
name,
&pos.x, &pos.y, &pos.z,
&scale.x, &scale.y, &scale.z,
&rot.x, &rot.y, &rot.z,
&angle);
float rad = Acos(angle) * 2.0f;
CInstance *inst = CModelInfo::GetMloInstanceStore().alloc();
minfo->lastInstance++;
RwMatrix *matrix = RwMatrixCreate();
RwMatrixScale(matrix, &scale, rwCOMBINEREPLACE);
RwMatrixRotate(matrix, &rot, -RADTODEG(rad), rwCOMBINEPOSTCONCAT);
RwMatrixTranslate(matrix, &pos, rwCOMBINEPOSTCONCAT);
inst->GetMatrix() = CMatrix(matrix);
inst->GetMatrix().UpdateRW();
inst->m_modelIndex = modelIndex;
RwMatrixDestroy(matrix);
}
void
CFileLoader::LoadTimeObject(const char *line)
{
@ -1182,7 +1061,6 @@ CFileLoader::LoadObjectInstance(const char *line)
CSimpleModelInfo *mi;
RwMatrix *xform;
CEntity *entity;
#ifdef MIAMI
float area;
if(sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f %f",
@ -1190,27 +1068,22 @@ CFileLoader::LoadObjectInstance(const char *line)
&trans.x, &trans.y, &trans.z,
&scale.x, &scale.y, &scale.z,
&axis.x, &axis.y, &axis.z, &angle) != 13){
#endif
if(sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f",
&id, name,
&trans.x, &trans.y, &trans.z,
&scale.x, &scale.y, &scale.z,
&axis.x, &axis.y, &axis.z, &angle) != 12)
return;
#ifdef MIAMI
if(sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f",
&id, name,
&trans.x, &trans.y, &trans.z,
&scale.x, &scale.y, &scale.z,
&axis.x, &axis.y, &axis.z, &angle) != 12)
return;
area = 0;
}
#endif
mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(id);
if(mi == nil)
return;
assert(mi->IsSimple());
#ifdef MIAMI
if(!CStreaming::IsObjectInCdImage(id))
debug("Not in cdimage %s\n", mi->GetName());
#endif
angle = -RADTODEG(2.0f * acosf(angle));
xform = RwMatrixCreate();
@ -1226,9 +1099,7 @@ CFileLoader::LoadObjectInstance(const char *line)
entity->SetModelIndexNoCreate(id);
entity->GetMatrix() = CMatrix(xform);
entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition());
#ifdef MIAMI
entity->m_area = area;
#endif
if(mi->IsSimple()){
if(mi->m_isBigBuilding)
entity->SetupBigBuilding();
@ -1239,27 +1110,24 @@ CFileLoader::LoadObjectInstance(const char *line)
entity->bIsVisible = false;
CWorld::Add(entity);
#ifdef MIAMI
CColModel *col = entity->GetColModel();
if(col->numSpheres || col->numBoxes || col->numTriangles){
if(col->level != 0)
CColStore::GetBoundingBox(col->level).ContainRect(entity->GetBoundRect());
}else
entity->bUsesCollision = false;
// TODO: set some flag here if col min is below 6
#endif
// TODO(MIAMI): set some flag here if col min is below 6
}else{
entity = new CDummyObject;
entity->SetModelIndexNoCreate(id);
entity->GetMatrix() = CMatrix(xform);
CWorld::Add(entity);
// TODO(MIAMI)
//--MIAMI: TODO
if(IsGlass(entity->GetModelIndex()))
entity->bIsVisible = false;
entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition());
#ifdef MIAMI
entity->m_area = area;
#endif
}
RwMatrixDestroy(xform);

View File

@ -5,16 +5,11 @@ class CFileLoader
static char ms_line[256];
public:
static void LoadLevel(const char *filename);
static void LoadCollisionFromDatFile(int currlevel);
static char *LoadLine(int fd);
static RwTexDictionary *LoadTexDictionary(const char *filename);
#ifndef MIAMI
static void LoadCollisionFile(const char *filename);
#else
static void LoadCollisionFile(const char *filename, uint8 colSlot = 0);
static void LoadCollisionFile(const char *filename, uint8 colSlot);
static bool LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlot);
static bool LoadCollisionFile(uint8 *buffer, uint32 size, uint8 colSlot);
#endif
static void LoadCollisionModel(uint8 *buf, struct CColModel &model, char *name);
static void LoadModelFile(const char *filename);
static RpAtomic *FindRelatedModelInfoCB(RpAtomic *atomic, void *data);
@ -29,8 +24,6 @@ public:
static void LoadObjectTypes(const char *filename);
static void LoadObject(const char *line);
static int LoadMLO(const char *line);
static void LoadMLOInstance(int id, const char *line);
static void LoadTimeObject(const char *line);
static void LoadClumpObject(const char *line);
static void LoadVehicleObject(const char *line);

View File

@ -1060,10 +1060,10 @@ CMenuManager::Draw()
rightText = TheText.Get(gbBigWhiteDebugLightSwitchedOn ? "FEM_ON" : "FEM_OFF");
break;
case MENUACTION_PEDROADGROUPS:
rightText = TheText.Get(gbShowPedRoadGroups ? "FEM_ON" : "FEM_OFF");
// REMOVED(MIAMI)
break;
case MENUACTION_CARROADGROUPS:
rightText = TheText.Get(gbShowCarRoadGroups ? "FEM_ON" : "FEM_OFF");
// REMOVED(MIAMI)
break;
case MENUACTION_COLLISIONPOLYS:
rightText = TheText.Get(gbShowCollisionPolys ? "FEM_ON" : "FEM_OFF");
@ -4904,11 +4904,11 @@ CMenuManager::ProcessOnOffMenuOptions()
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0);
break;
case MENUACTION_PEDROADGROUPS:
gbShowPedRoadGroups = !gbShowPedRoadGroups;
// REMOVED(MIAMI)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0);
break;
case MENUACTION_CARROADGROUPS:
gbShowCarRoadGroups = !gbShowCarRoadGroups;
// REMOVED(MIAMI)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0);
break;
case MENUACTION_COLLISIONPOLYS:

View File

@ -624,10 +624,8 @@ public:
void LoadAllTextures();
void LoadSettings();
void MessageScreen(const char *);
#ifdef MIAMI
//--MIAMI: TODO: implement the second argument
// TODO(MIAMI): implement the second argument
void MessageScreen(const char *str, bool) { MessageScreen(str); }
#endif
void PickNewPlayerColour();
void PrintBriefs();
static void PrintErrorMessage();

View File

@ -89,9 +89,7 @@
eLevelName CGame::currLevel;
#ifdef MIAMI
int32 CGame::currArea;
#endif
bool CGame::bDemoMode = true;
bool CGame::nastyGame = true;
bool CGame::frenchGame;
@ -322,9 +320,6 @@ bool CGame::Initialise(const char* datFile)
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
LoadingScreen("Loading the Game", "Setup streaming", nil);
#ifndef MIAMI
CStreaming::Init();
#endif
CStreaming::LoadInitialVehicles();
CStreaming::LoadInitialPeds();
CStreaming::RequestBigBuildings(LEVEL_NONE);
@ -372,14 +367,7 @@ bool CGame::Initialise(const char* datFile)
CWaterCannons::Init();
CBridge::Init();
CGarages::Init();
#ifndef MIAMI
LoadingScreen("Loading the Game", "Position dynamic objects", nil);
CWorld::RepositionCertainDynamicObjects();
#endif
LoadingScreen("Loading the Game", "Initialise vehicle paths", nil);
#ifdef GTA_ZONECULL
CCullZones::ResolveVisibilities();
#endif
CTrain::InitTrains();
CPlane::InitPlanes();
CCredits::Init();
@ -390,9 +378,6 @@ bool CGame::Initialise(const char* datFile)
CTheScripts::Process();
TheCamera.Process();
LoadingScreen("Loading the Game", "Load scene", nil);
#ifndef MIAMI
CModelInfo::RemoveColModelsFromOtherLevels(currLevel);
#endif
CCollision::ms_collisionInMemory = currLevel;
for (int i = 0; i < MAX_PADS; i++)
CPad::GetPad(i)->Clear(true);
@ -532,12 +517,6 @@ void CGame::ReloadIPLs(void)
CRoadBlocks::Init();
CCranes::InitCranes();
CGarages::Init();
#ifndef MIAMI
CWorld::RepositionCertainDynamicObjects();
#endif
#ifdef GTA_ZONECULL
CCullZones::ResolveVisibilities();
#endif
CRenderer::SortBIGBuildings();
CTimer::Update();
}

View File

@ -35,9 +35,7 @@ class CGame
{
public:
static eLevelName currLevel;
#ifdef MIAMI
static int32 currArea;
#endif
static bool bDemoMode;
static bool nastyGame;
static bool frenchGame;

View File

@ -80,6 +80,3 @@ public:
~CPlayerInfo() { };
};
#ifndef MIAMI
static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error");
#endif

View File

@ -18,7 +18,6 @@
#include "FileMgr.h"
#include "FileLoader.h"
#include "Zones.h"
#include "ZoneCull.h"
#include "Radar.h"
#include "Camera.h"
#include "Record.h"
@ -28,14 +27,10 @@
#include "CutsceneMgr.h"
#include "CdStream.h"
#include "Streaming.h"
#ifdef FIX_BUGS
#include "Replay.h"
#endif
#include "main.h"
#ifdef MIAMI
#include "ColStore.h"
#include "DMAudio.h"
#endif
bool CStreaming::ms_disableStreaming;
bool CStreaming::ms_bLoadingBigModel;
@ -57,9 +52,6 @@ int32 CStreaming::ms_vehiclesLoaded[MAXVEHICLESLOADED];
int32 CStreaming::ms_lastVehicleDeleted;
CDirectory *CStreaming::ms_pExtraObjectsDir;
int32 CStreaming::ms_numPriorityRequests;
#ifndef MIAMI
bool CStreaming::ms_hasLoadedLODs;
#endif
int32 CStreaming::ms_currentPedGrp;
int32 CStreaming::ms_currentPedLoading;
int32 CStreaming::ms_lastCullZone;
@ -190,9 +182,6 @@ CStreaming::Init2(void)
ms_pExtraObjectsDir = new CDirectory(EXTRADIRSIZE);
ms_numPriorityRequests = 0;
#ifndef MIAMI
ms_hasLoadedLODs = true;
#endif
ms_currentPedGrp = -1;
ms_lastCullZone = -1; // unused because RemoveModelsNotVisibleFromCullzone is gone
ms_loadedGangs = 0;
@ -238,19 +227,6 @@ CStreaming::Init2(void)
CModelInfo::GetModelInfo("IslandLODcomSUB", &islandLODcomSub);
CModelInfo::GetModelInfo("IslandLODsubIND", &islandLODsubInd);
CModelInfo::GetModelInfo("IslandLODsubCOM", &islandLODsubCom);
#ifndef MIAMI
for(i = CPools::GetBuildingPool()->GetSize()-1; i >= 0; i--){
CBuilding *building = CPools::GetBuildingPool()->GetSlot(i);
if(building == nil)
continue;
if(building->GetModelIndex() == islandLODindust) pIslandLODindustEntity = building;
if(building->GetModelIndex() == islandLODcomInd) pIslandLODcomIndEntity = building;
if(building->GetModelIndex() == islandLODcomSub) pIslandLODcomSubEntity = building;
if(building->GetModelIndex() == islandLODsubInd) pIslandLODsubIndEntity = building;
if(building->GetModelIndex() == islandLODsubCom) pIslandLODsubComEntity = building;
}
#endif
}
void
@ -288,7 +264,6 @@ CStreaming::Shutdown(void)
void
CStreaming::Update(void)
{
CEntity *train;
CStreamingInfo *si, *prev;
bool requestedSubway = false;
@ -302,46 +277,24 @@ CStreaming::Update(void)
if(CTimer::GetIsPaused())
return;
#ifndef MIAMI
train = FindPlayerTrain();
if(train && train->GetPosition().z < 0.0f){
RequestSubway();
requestedSubway = true;
}else if(!ms_disableStreaming)
AddModelsToRequestList(TheCamera.GetPosition());
#else
LoadBigBuildingsWhenNeeded();
if(!ms_disableStreaming && TheCamera.GetPosition().z < 55.0f)
AddModelsToRequestList(TheCamera.GetPosition());
#endif
DeleteFarAwayRwObjects(TheCamera.GetPosition());
if(!ms_disableStreaming &&
#ifndef MIAMI
!CCutsceneMgr::IsRunning() &&
!requestedSubway &&
!CGame::playingIntro &&
#else
!CCutsceneMgr::IsCutsceneProcessing() &&
#endif
ms_numModelsRequested < 5 &&
!CRenderer::m_loadingPriority
#ifdef MIAMI
&& CGame::currArea == 0
// replay is also MIAMI
#endif
#ifdef FIX_BUGS
&& !CReplay::IsPlayingBack()
#endif
){
!CRenderer::m_loadingPriority &&
CGame::currArea == 0 &&
!CReplay::IsPlayingBack()){
StreamVehiclesAndPeds();
StreamZoneModels(FindPlayerCoors());
}
LoadRequestedModels();
#ifdef MIAMI
if(CWorld::Players[0].m_pRemoteVehicle){
CColStore::AddCollisionNeededAtPosn(FindPlayerCoors());
CColStore::LoadCollision(CWorld::Players[0].m_pRemoteVehicle->GetPosition());
@ -350,7 +303,6 @@ CStreaming::Update(void)
CColStore::LoadCollision(FindPlayerCoors());
CColStore::EnsureCollisionIsInMemory(FindPlayerCoors());
}
#endif
for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){
prev = si->m_prev;
@ -397,8 +349,7 @@ void
CStreaming::LoadCdDirectory(const char *dirname, int n)
{
int fd, lastID, imgSelector;
int modelId, txdId;
uint32 posn, size;
int modelId;
CDirectory::DirectoryInfo direntry;
char *dot;
@ -409,50 +360,6 @@ CStreaming::LoadCdDirectory(const char *dirname, int n)
imgSelector = n<<24;
assert(sizeof(direntry) == 32);
while(CFileMgr::Read(fd, (char*)&direntry, sizeof(direntry))){
#ifndef MIAMI
dot = strchr(direntry.name, '.');
if(dot) *dot = '\0';
if(direntry.size > (uint32)ms_streamingBufferSize)
ms_streamingBufferSize = direntry.size;
if(!CGeneral::faststrcmp(dot+1, "DFF") || !CGeneral::faststrcmp(dot+1, "dff")){
if(CModelInfo::GetModelInfo(direntry.name, &modelId)){
if(ms_aInfoForModel[modelId].GetCdPosnAndSize(posn, size)){
debug("%s appears more than once in %s\n", direntry.name, dirname);
lastID = -1;
}else{
direntry.offset |= imgSelector;
ms_aInfoForModel[modelId].SetCdPosnAndSize(direntry.offset, direntry.size);
if(lastID != -1)
ms_aInfoForModel[lastID].m_nextID = modelId;
lastID = modelId;
}
}else{
#ifdef FIX_BUGS
// remember which cdimage this came from
ms_pExtraObjectsDir->AddItem(direntry, n);
#else
ms_pExtraObjectsDir->AddItem(direntry);
#endif
lastID = -1;
}
}else if(!CGeneral::faststrcmp(dot+1, "TXD") || !CGeneral::faststrcmp(dot+1, "txd")){
txdId = CTxdStore::FindTxdSlot(direntry.name);
if(txdId == -1)
txdId = CTxdStore::AddTxdSlot(direntry.name);
if(ms_aInfoForModel[txdId + STREAM_OFFSET_TXD].GetCdPosnAndSize(posn, size)){
debug("%s appears more than once in %s\n", direntry.name, dirname);
lastID = -1;
}else{
direntry.offset |= imgSelector;
ms_aInfoForModel[txdId + STREAM_OFFSET_TXD].SetCdPosnAndSize(direntry.offset, direntry.size);
if(lastID != -1)
ms_aInfoForModel[lastID].m_nextID = txdId + STREAM_OFFSET_TXD;
lastID = txdId + STREAM_OFFSET_TXD;
}
}else
lastID = -1;
#else
bool bAddToStreaming = false;
if(direntry.size > (uint32)ms_streamingBufferSize)
@ -491,7 +398,7 @@ CStreaming::LoadCdDirectory(const char *dirname, int n)
modelId = CColStore::AddColSlot(direntry.name);
modelId += STREAM_OFFSET_COL;
bAddToStreaming = true;
// TODO: IFP
// TODO(MIAMI): IFP
}else{
*dot = '.';
lastID = -1;
@ -509,7 +416,6 @@ CStreaming::LoadCdDirectory(const char *dirname, int n)
lastID = modelId;
}
}
#endif
}
CFileMgr::CloseFile(fd);
@ -575,11 +481,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
RwStreamClose(stream, &mem);
return false;
}
#ifndef MIAMI
}else{
#else
}else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){
#endif
// Txd
assert(streamId < NUMSTREAMINFO);
if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_KEEP_IN_MEMORY) == 0 &&
@ -604,7 +506,6 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
RwStreamClose(stream, &mem);
return false;
}
#ifdef MIAMI
}else if(streamId >= STREAM_OFFSET_COL && streamId < NUMSTREAMINFO){
if(!CColStore::LoadCol(streamId-STREAM_OFFSET_COL, mem.start, mem.length)){
debug("Failed to load %s.col\n", CColStore::GetColName(streamId - STREAM_OFFSET_COL));
@ -613,24 +514,11 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
RwStreamClose(stream, &mem);
return false;
}
// TODO: IFPs
#endif
// TODO(MIAMI): IFP
}
RwStreamClose(stream, &mem);
#ifndef MIAMI
// We shouldn't even end up here unless load was successful
if(!success){
ReRequestModel(streamId);
if(streamId < STREAM_OFFSET_TXD)
debug("Failed to load %s.dff\n", mi->GetName());
else
debug("Failed to load %s.txd\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD));
return false;
}
#endif
if(streamId < STREAM_OFFSET_TXD){
// Model
// Vehicles and Peds not in loaded list
@ -648,14 +536,11 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_CANT_REMOVE) == 0)
ms_aInfoForModel[streamId].AddToList(&ms_startLoadedList);
}
#ifndef MIAMI
}else{
#else
}else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){ // TODO: animations
#endif
}else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){
// Txd
if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_CANT_REMOVE) == 0)
ms_aInfoForModel[streamId].AddToList(&ms_startLoadedList);
// TODO(MIAMI): animations
}
// Mark objects as loaded
@ -667,12 +552,6 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
endTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond();
timeDiff = endTime - startTime;
if(timeDiff > 5){
#ifndef MIAMI
if(streamId < STREAM_OFFSET_TXD)
debug("model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetName(), timeDiff);
else
debug("txd %s took %d ms\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD), timeDiff);
#else
// TODO: is this inlined?
static char objname[32];
if(streamId < STREAM_OFFSET_TXD)
@ -681,9 +560,8 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
sprintf(objname, "%s.txd", CTxdStore::GetTxdName(streamId-STREAM_OFFSET_TXD));
else if(streamId >= STREAM_OFFSET_COL && streamId < NUMSTREAMINFO)
sprintf(objname, "%s.col", CColStore::GetColName(streamId-STREAM_OFFSET_COL));
// TODO: IFP
// TODO(MIAMI): IFP
debug("%s took %d ms\n", objname, timeDiff);
#endif
}
return true;
@ -841,11 +719,7 @@ CStreaming::RequestSubway(void)
}
}
#ifndef MIAMI
#define BIGBUILDINGFLAGS STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY
#else
#define BIGBUILDINGFLAGS STREAMFLAGS_DONT_REMOVE
#endif
void
CStreaming::RequestBigBuildings(eLevelName level)
@ -857,18 +731,12 @@ CStreaming::RequestBigBuildings(eLevelName level)
for(i = n; i >= 0; i--){
b = CPools::GetBuildingPool()->GetSlot(i);
if(b && b->bIsBIGBuilding && b->m_level == level)
#ifdef MIAMI
if(!b->bStreamBIGBuilding)
#endif
RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS);
RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS);
}
RequestIslands(level);
#ifndef MIAMI
ms_hasLoadedLODs = false;
#endif
}
#ifdef MIAMI
void
CStreaming::RequestBigBuildings(eLevelName level, const CVector &pos)
{
@ -903,7 +771,6 @@ CStreaming::InstanceBigBuildings(eLevelName level, const CVector &pos)
b->CreateRwObject();
}
}
#endif
void
CStreaming::RequestIslands(eLevelName level)
@ -1002,20 +869,13 @@ CStreaming::RemoveModel(int32 id)
return;
if(ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED){
#ifndef MIAMI
if(id < STREAM_OFFSET_TXD)
CModelInfo::GetModelInfo(id)->DeleteRwObject();
else
CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD);
#else
if(id < STREAM_OFFSET_TXD)
CModelInfo::GetModelInfo(id)->DeleteRwObject();
else if(id >= STREAM_OFFSET_TXD && id < STREAM_OFFSET_COL)
CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD);
else if(id >= STREAM_OFFSET_COL && id < NUMSTREAMINFO)
CColStore::RemoveCol(id - STREAM_OFFSET_COL);
// TODO: IFP
#endif
// TODO(MIAMI): IFP
ms_memoryUsed -= ms_aInfoForModel[id].GetCdSize()*CDSTREAM_SECTOR_SIZE;
}
@ -1034,20 +894,13 @@ CStreaming::RemoveModel(int32 id)
}
if(ms_aInfoForModel[id].m_loadState == STREAMSTATE_STARTED){
#ifndef MIAMI
if(id < STREAM_OFFSET_TXD)
RpClumpGtaCancelStream();
else
CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD);
#else
if(id < STREAM_OFFSET_TXD)
RpClumpGtaCancelStream();
else if(id >= STREAM_OFFSET_TXD && id < STREAM_OFFSET_COL)
CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD);
else if(id >= STREAM_OFFSET_COL && id < NUMSTREAMINFO)
CColStore::RemoveCol(id - STREAM_OFFSET_COL);
// TODO: IFP
#endif
// TODO(MIAMI): IFP
}
ms_aInfoForModel[id].m_loadState = STREAMSTATE_NOTLOADED;
@ -1155,7 +1008,6 @@ DeleteIsland(CEntity *island)
void
CStreaming::RemoveIslandsNotUsed(eLevelName level)
{
#ifdef MIAMI
int i;
if(pIslandLODindustEntity == nil)
for(i = CPools::GetBuildingPool()->GetSize()-1; i >= 0; i--){
@ -1168,7 +1020,6 @@ CStreaming::RemoveIslandsNotUsed(eLevelName level)
if(building->GetModelIndex() == islandLODsubInd) pIslandLODsubIndEntity = building;
if(building->GetModelIndex() == islandLODsubCom) pIslandLODsubComEntity = building;
}
#endif
switch(level){
case LEVEL_INDUSTRIAL:
@ -1400,43 +1251,6 @@ CStreaming::IsObjectInCdImage(int32 id)
return ms_aInfoForModel[id].GetCdPosnAndSize(posn, size);
}
#ifndef MIAMI
void
CStreaming::HaveAllBigBuildingsLoaded(eLevelName level)
{
int i, n;
CEntity *e;
if(ms_hasLoadedLODs)
return;
if(level == LEVEL_INDUSTRIAL){
if(ms_aInfoForModel[islandLODcomInd].m_loadState != STREAMSTATE_LOADED ||
ms_aInfoForModel[islandLODsubInd].m_loadState != STREAMSTATE_LOADED)
return;
}else if(level == LEVEL_COMMERCIAL){
if(ms_aInfoForModel[islandLODindust].m_loadState != STREAMSTATE_LOADED ||
ms_aInfoForModel[islandLODsubCom].m_loadState != STREAMSTATE_LOADED)
return;
}else if(level == LEVEL_SUBURBAN){
if(ms_aInfoForModel[islandLODindust].m_loadState != STREAMSTATE_LOADED ||
ms_aInfoForModel[islandLODcomSub].m_loadState != STREAMSTATE_LOADED)
return;
}
n = CPools::GetBuildingPool()->GetSize()-1;
for(i = n; i >= 0; i--){
e = CPools::GetBuildingPool()->GetSlot(i);
if(e && e->bIsBIGBuilding && e->m_level == level &&
ms_aInfoForModel[e->GetModelIndex()].m_loadState != STREAMSTATE_LOADED)
return;
}
RemoveUnusedBigBuildings(level);
ms_hasLoadedLODs = true;
}
#endif
void
CStreaming::SetModelIsDeletable(int32 id)
{
@ -1669,7 +1483,6 @@ CStreaming::RemoveCurrentZonesModels(void)
ms_loadedGangCars = 0;
}
#ifdef MIAMI
void
CStreaming::LoadBigBuildingsWhenNeeded(void)
{
@ -1705,7 +1518,6 @@ CStreaming::LoadBigBuildingsWhenNeeded(void)
CTimer::Resume();
DMAudio.SetEffectsFadeVol(127);
}
#endif
// Find starting offset of the cdimage we next want to read
@ -2235,10 +2047,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float
if(xmin < pos.x && pos.x < xmax &&
ymin < pos.y && pos.y < ymax &&
(CVector2D(x, y) - pos).MagnitudeSqr() < lodDistSq)
#ifdef GTA_ZONECULL
if(CRenderer::IsEntityCullZoneVisible(e))
#endif
RequestModel(e->GetModelIndex(), 0);
RequestModel(e->GetModelIndex(), 0);
}
}
}
@ -2261,10 +2070,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list)
(!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff()))
#ifdef GTA_ZONECULL
if(CRenderer::IsEntityCullZoneVisible(e))
#endif
RequestModel(e->GetModelIndex(), 0);
RequestModel(e->GetModelIndex(), 0);
}
}
}
@ -2687,17 +2493,7 @@ CStreaming::LoadScene(const CVector &pos)
RemoveModel(si - ms_aInfoForModel);
}
CRenderer::m_loadingPriority = false;
#ifdef GTA_ZONECULL
CCullZones::ForceCullZoneCoors(pos);
#endif
DeleteAllRwObjects();
#ifndef MIAMI
AddModelsToRequestList(pos);
CRadar::StreamRadarSections(pos);
RemoveUnusedBigBuildings(level);
RequestBigBuildings(level);
LoadAllRequestedModels(false);
#else
if(level == LEVEL_NONE)
level = CGame::currLevel;
CGame::currLevel = level;
@ -2711,13 +2507,12 @@ CStreaming::LoadScene(const CVector &pos)
AddModelsToRequestList(pos);
CRadar::StreamRadarSections(pos);
// TODO: stream zone vehicles
// TODO(MIAMI): stream zone vehicles
LoadAllRequestedModels(false);
// TODO: InstanceLoadedModels
// TODO(MIAMI): InstanceLoadedModels
for(int i = 0; i < NUMSTREAMINFO; i++)
ms_aInfoForModel[i].m_flags &= ~STREAMFLAGS_20;
#endif
debug("End load scene\n");
}

View File

@ -4,12 +4,8 @@
enum {
STREAM_OFFSET_TXD = MODELINFOSIZE,
#ifndef MIAMI
NUMSTREAMINFO = STREAM_OFFSET_TXD+TXDSTORESIZE
#else
STREAM_OFFSET_COL = STREAM_OFFSET_TXD+TXDSTORESIZE,
NUMSTREAMINFO = STREAM_OFFSET_COL+COLSTORESIZE
#endif
};
enum StreamFlags
@ -19,9 +15,7 @@ enum StreamFlags
STREAMFLAGS_DEPENDENCY = 0x04, // Is this right?
STREAMFLAGS_PRIORITY = 0x08,
STREAMFLAGS_NOFADE = 0x10,
#ifdef MIAMI
STREAMFLAGS_20 = 0x20,
#endif
STREAMFLAGS_20 = 0x20, // TODO(MIAMI): what's this
STREAMFLAGS_CANT_REMOVE = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED,
STREAMFLAGS_KEEP_IN_MEMORY = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED|STREAMFLAGS_DEPENDENCY,
@ -102,9 +96,6 @@ public:
static int32 ms_lastVehicleDeleted;
static CDirectory *ms_pExtraObjectsDir;
static int32 ms_numPriorityRequests;
#ifndef MIAMI
static bool ms_hasLoadedLODs;
#endif
static int32 ms_currentPedGrp;
static int32 ms_lastCullZone;
static uint16 ms_loadedGangs;
@ -125,28 +116,20 @@ public:
static bool FinishLoadingLargeFile(int8 *buf, int32 streamId);
static bool HasModelLoaded(int32 id) { return ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED; }
static bool HasTxdLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_TXD); }
#ifdef MIAMI
static bool HasColLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_COL); }
#endif
static bool CanRemoveModel(int32 id) { return (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0; }
static bool CanRemoveTxd(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_TXD); }
#ifdef MIAMI
static bool CanRemoveCol(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_COL); }
#endif
static void RequestModel(int32 model, int32 flags);
static void ReRequestModel(int32 model) { RequestModel(model, ms_aInfoForModel[model].m_flags); }
static void RequestTxd(int32 txd, int32 flags) { RequestModel(txd + STREAM_OFFSET_TXD, flags); }
static void ReRequestTxd(int32 txd) { ReRequestModel(txd + STREAM_OFFSET_TXD); }
#ifdef MIAMI
static void RequestCol(int32 col, int32 flags) { RequestModel(col + STREAM_OFFSET_COL, flags); }
static void ReRequestCol(int32 col) { ReRequestModel(col + STREAM_OFFSET_COL); }
#endif
static void RequestSubway(void);
static void RequestBigBuildings(eLevelName level);
#ifdef MIAMI
static void RequestBigBuildings(eLevelName level, const CVector &pos);
static void InstanceBigBuildings(eLevelName level, const CVector &pos);
#endif
static void RequestIslands(eLevelName level);
static void RequestSpecialModel(int32 modelId, const char *modelName, int32 flags);
static void RequestSpecialChar(int32 charId, const char *modelName, int32 flags);
@ -155,9 +138,7 @@ public:
static void DecrementRef(int32 id);
static void RemoveModel(int32 id);
static void RemoveTxd(int32 id) { RemoveModel(id + STREAM_OFFSET_TXD); }
#ifdef MIAMI
static void RemoveCol(int32 id) { RemoveModel(id + STREAM_OFFSET_COL); }
#endif
static void RemoveUnusedBuildings(eLevelName level);
static void RemoveBuildings(eLevelName level);
static void RemoveUnusedBigBuildings(eLevelName level);
@ -172,9 +153,6 @@ public:
static bool IsTxdUsedByRequestedModels(int32 txdId);
static bool AddToLoadedVehiclesList(int32 modelId);
static bool IsObjectInCdImage(int32 id);
#ifndef MIAMI
static void HaveAllBigBuildingsLoaded(eLevelName level);
#endif
static void SetModelIsDeletable(int32 id);
static void SetModelTxdIsDeletable(int32 id);
static void SetMissionDoesntRequireModel(int32 id);
@ -183,9 +161,7 @@ public:
static void StreamVehiclesAndPeds(void);
static void StreamZoneModels(const CVector &pos);
static void RemoveCurrentZonesModels(void);
#ifdef MIAMI
static void LoadBigBuildingsWhenNeeded(void);
#endif
static int32 GetCdImageOffset(int32 lastPosn);
static int32 GetNextFileOnCd(int32 position, bool priority);

View File

@ -7,57 +7,44 @@ enum Config {
MAX_CDIMAGES = 8, // additional cdimages
MAX_CDCHANNELS = 5,
#ifndef MIAMI
MODELINFOSIZE = 5500,
TXDSTORESIZE = 850,
#else
MODELINFOSIZE = 6500,
TXDSTORESIZE = 1385,
COLSTORESIZE = 31,
#endif
EXTRADIRSIZE = 128,
CUTSCENEDIRSIZE = 512,
SIMPLEMODELSIZE = 5000,
MLOMODELSIZE = 1,
MLOINSTANCESIZE = 1,
TIMEMODELSIZE = 30,
SIMPLEMODELSIZE = 5000, // only 3885 in VC???
TIMEMODELSIZE = 385,
CLUMPMODELSIZE = 5,
PEDMODELSIZE = 90,
VEHICLEMODELSIZE = 120,
XTRACOMPSMODELSIZE = 2,
TWODFXSIZE = 2000,
WEAPONMODELSIZE = 37,
PEDMODELSIZE = 130,
VEHICLEMODELSIZE = 120, // only 110 in VC???
TWODFXSIZE = 2000, // only 1210 in VC???
MAXVEHICLESLOADED = 50, // 70 on mobile
NUMOBJECTINFO = 168, // object.dat
// Pool sizes
NUMPTRNODES = 30000, // 26000 on PS2
NUMENTRYINFOS = 5400, // 3200 on PS2
NUMPEDS = 140, // 90 on PS2
NUMVEHICLES = 110, // 70 on PS2
NUMBUILDINGS = 5500, // 4915 on PS2
NUMTREADABLES = 1214,
NUMOBJECTS = 450,
NUMDUMMIES = 2802, // 2368 on PS2
NUMAUDIOSCRIPTOBJECTS = 256,
NUMCUTSCENEOBJECTS = 50,
NUMPTRNODES = 50000,
NUMENTRYINFOS = 5400, // only 3200 in VC???
NUMPEDS = 140,
NUMVEHICLES = 110,
NUMBUILDINGS = 7000,
NUMTREADABLES = 1214, // 1 in VC
NUMOBJECTS = 460,
NUMDUMMIES = 2802, // 2340 in VC
NUMAUDIOSCRIPTOBJECTS = 256, // 192 in VC
NUMCUTSCENEOBJECTS = 50, // does not exist in VC
// TODO(MIAMI): colmodel pool
NUMTEMPOBJECTS = 30,
// Path data
#ifndef MIAMI
NUM_PATHNODES = 4930,
NUM_CARPATHLINKS = 2076,
NUM_MAPOBJECTS = 1250,
NUM_PATHCONNECTIONS = 10260,
#else
NUM_PATHNODES = 9650,
NUM_CARPATHLINKS = 3500,
NUM_MAPOBJECTS = 1250,
NUM_PATHCONNECTIONS = 20400,
#endif
// Link list lengths
NUMALPHALIST = 20,
@ -123,11 +110,7 @@ enum Config {
NUMMODELSPERPEDGROUP = 8,
NUMSHOTINFOS = 100,
#ifndef MIAMI
NUMROADBLOCKS = 600,
#else
NUMROADBLOCKS = 300,
#endif
NUMVISIBLEENTITIES = 2000,
NUMINVISIBLEENTITIES = 150,
@ -160,12 +143,6 @@ enum Config {
//#define GTA_PS2
//#define GTA_XBOX
#ifndef MIAMI
#define GTA_TRAIN // This game has trains
#define GTA_BRIDGE // This game has the bridge
#define GTA_ZONECULL // This game culls by zones
#endif
// This enables things from the PS2 version on PC
#define GTA_PS2_STUFF

View File

@ -333,8 +333,6 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Render", "Show Ped Paths", &gbShowPedPaths, nil);
DebugMenuAddVarBool8("Render", "Show Car Paths", &gbShowCarPaths, nil);
DebugMenuAddVarBool8("Render", "Show Car Path Links", &gbShowCarPathsLinks, nil);
DebugMenuAddVarBool8("Render", "Show Ped Road Groups", &gbShowPedRoadGroups, nil);
DebugMenuAddVarBool8("Render", "Show Car Road Groups", &gbShowCarRoadGroups, nil);
DebugMenuAddVarBool8("Render", "Show Collision Lines", &gbShowCollisionLines, nil);
DebugMenuAddVarBool8("Render", "Show Collision Polys", &gbShowCollisionPolys, nil);
DebugMenuAddVarBool8("Render", "Don't render Buildings", &gbDontRenderBuildings, nil);

View File

@ -34,25 +34,20 @@ class CPool
int m_allocPtr;
public:
// TODO(MIAMI): remove ctor without name argument
CPool(int size){
// TODO: use new here
m_entries = (U*)malloc(sizeof(U)*size);
m_flags = (Flags*)malloc(sizeof(Flags)*size);
m_size = size;
#ifndef MIAMI
m_allocPtr = 0;
#else
m_allocPtr = -1;
#endif
for(int i = 0; i < size; i++){
m_flags[i].id = 0;
m_flags[i].free = 1;
}
}
#ifdef MIAMI
CPool(int size, const char *name)
: CPool(size) {}
#endif
~CPool() {
Flush();
}

View File

@ -52,9 +52,7 @@ CEntity::CEntity(void)
bRenderScorched = false;
bHasBlip = false;
bIsBIGBuilding = false;
#ifdef MIAMI
bStreamBIGBuilding = false;
#endif
bRenderDamaged = false;
bBulletProof = false;
@ -63,10 +61,6 @@ CEntity::CEntity(void)
bMeleeProof = false;
bOnlyDamagedByPlayer = false;
bStreamingDontDelete = false;
#ifdef GTA_ZONECULL
bZoneCulled = false;
bZoneCulled2 = false;
#endif
bRemoveFromWorld = false;
bHasHitWall = false;
@ -153,17 +147,6 @@ CEntity::GetIsOnScreenComplex(void)
return TheCamera.IsBoxVisible(boundBox, &TheCamera.GetCameraMatrix());
}
bool
CEntity::GetIsOnScreenAndNotCulled(void)
{
#ifdef GTA_ZONECULL
return GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(this);
#else
return GetIsOnScreen();
#endif
}
void
CEntity::Add(void)
{
@ -348,11 +331,9 @@ CEntity::SetupBigBuilding(void)
bStreamingDontDelete = true;
bUsesCollision = false;
m_level = CTheZones::GetLevelFromPosition(GetPosition());
#ifdef MIAMI
if(mi->m_lodDistances[0] <= 2000.0f)
bStreamBIGBuilding = true;
// TODO: the stuff down there isn't right yet
#endif
// TODO(MIAMI): the stuff down there isn't right yet
if(m_level == LEVEL_NONE){
if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){
mi->SetTexDictionary("generic");
@ -975,10 +956,6 @@ CEntity::SaveEntityFlags(uint8*& buf)
if (bMeleeProof) tmp |= BIT(27);
if (bOnlyDamagedByPlayer) tmp |= BIT(28);
if (bStreamingDontDelete) tmp |= BIT(29);
#ifdef GTA_ZONECULL
if (bZoneCulled) tmp |= BIT(30);
if (bZoneCulled2) tmp |= BIT(31);
#endif
WriteSaveBuf<uint32>(buf, tmp);
@ -1030,10 +1007,6 @@ CEntity::LoadEntityFlags(uint8*& buf)
bMeleeProof = !!(tmp & BIT(27));
bOnlyDamagedByPlayer = !!(tmp & BIT(28));
bStreamingDontDelete = !!(tmp & BIT(29));
#ifdef GTA_ZONECULL
bZoneCulled = !!(tmp & BIT(30));
bZoneCulled2 = !!(tmp & BIT(31));
#endif
tmp = ReadSaveBuf<uint32>(buf);

View File

@ -59,25 +59,19 @@ public:
uint32 bRenderScorched : 1;
uint32 bHasBlip : 1;
uint32 bIsBIGBuilding : 1; // Set if this entity is a big building
#ifdef MIAMI
uint32 bStreamBIGBuilding : 1; // set when draw dist <= 2000
#endif
uint32 bRenderDamaged : 1; // use damaged LOD models for objects with applicable damage
// flagsC
uint32 bRenderDamaged : 1; // use damaged LOD models for objects with applicable damage
uint32 bBulletProof : 1;
uint32 bFireProof : 1;
uint32 bCollisionProof : 1;
uint32 bMeleeProof : 1;
uint32 bOnlyDamagedByPlayer : 1;
uint32 bStreamingDontDelete : 1; // Dont let the streaming remove this
#ifdef GTA_ZONECULL
uint32 bZoneCulled : 1;
uint32 bZoneCulled2 : 1; // only treadables+10m
#endif
uint32 bRemoveFromWorld : 1; // remove this entity next time it should be processed
// flagsD
uint32 bRemoveFromWorld : 1; // remove this entity next time it should be processed
uint32 bHasHitWall : 1; // has collided with a building (changes subsequent collisions)
uint32 bImBeingRendered : 1; // don't delete me because I'm being rendered
uint32 bTouchingWater : 1; // used by cBuoyancy::ProcessBuoyancy
@ -85,20 +79,17 @@ public:
uint32 bDrawLast : 1; // draw object last
uint32 bNoBrightHeadLights : 1;
uint32 bDoNotRender : 1;
uint32 bDistanceFade : 1; // Fade entity because it is far away
// flagsE
uint32 bDistanceFade : 1; // Fade entity because it is far away
uint32 m_flagE2 : 1;
// TODO(MIAMI)
uint16 m_scanCode;
uint16 m_randomSeed;
int16 m_modelIndex;
#ifndef MIAMI
uint16 m_level; // int16
#else
int8 m_level;
int8 m_area;
#endif
CReference *m_pFirstReference;
public:
@ -156,7 +147,6 @@ public:
bool GetIsTouching(CVector const &center, float r);
bool GetIsOnScreen(void);
bool GetIsOnScreenComplex(void);
bool GetIsOnScreenAndNotCulled(void);
bool IsVisible(void) { return m_rwObject && bIsVisible && GetIsOnScreen(); }
bool IsVisibleComplex(void) { return m_rwObject && bIsVisible && GetIsOnScreenComplex(); }
int16 GetModelIndex(void) const { return m_modelIndex; }

View File

@ -263,23 +263,11 @@ CPhysical::AddCollisionRecord(CEntity *ent)
}
}
//--MIAMI: done
void
CPhysical::AddCollisionRecord_Treadable(CEntity *ent)
{
if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){
#ifndef MIAMI
CTreadable *t = (CTreadable*)ent;
if(t->m_nodeIndices[PATH_PED][0] >= 0 ||
t->m_nodeIndices[PATH_PED][1] >= 0 ||
t->m_nodeIndices[PATH_PED][2] >= 0 ||
t->m_nodeIndices[PATH_PED][3] >= 0)
m_treadable[PATH_PED] = t;
if(t->m_nodeIndices[PATH_CAR][0] >= 0 ||
t->m_nodeIndices[PATH_CAR][1] >= 0 ||
t->m_nodeIndices[PATH_CAR][2] >= 0 ||
t->m_nodeIndices[PATH_CAR][3] >= 0)
m_treadable[PATH_CAR] = t;
#endif
}
}

View File

@ -8,12 +8,5 @@ public:
static void *operator new(size_t);
static void operator delete(void*, size_t);
#ifndef MIAMI
int16 m_nodeIndices[2][12]; // first car, then ped
#endif
bool GetIsATreadable(void) { return true; }
};
#ifndef MIAMI
static_assert(sizeof(CTreadable) == 0x94, "CTreadable: error");
#endif

View File

@ -1,39 +0,0 @@
#include "common.h"
#include "VisibilityPlugins.h"
#include "ModelInfo.h"
void
CMloModelInfo::ConstructClump()
{
m_clump = RpClumpCreate();
RwFrame *mainFrame = RwFrameCreate();
RwFrameSetIdentity(mainFrame);
RpClumpSetFrame(m_clump, mainFrame);
for (int i = firstInstance; i < lastInstance; i++) {
int modelId = CModelInfo::GetMloInstanceStore().store[i].m_modelIndex;
RwMatrix *attMat = CModelInfo::GetMloInstanceStore().store[i].GetMatrix().m_attachment;
CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(modelId);
if (minfo->m_atomics[0] != nil) {
RpAtomic *newAtomic = RpAtomicClone(minfo->m_atomics[0]);
RwFrame *newFrame = RwFrameCreate();
if (newAtomic != nil && newFrame != nil) {
*RwFrameGetMatrix(newFrame) = *attMat;
RpAtomicSetFrame(newAtomic, newFrame);
RwFrameAddChild(mainFrame, newFrame);
RpClumpAddAtomic(m_clump, newAtomic);
} else {
debug("Failed to allocate memory while creating template MLO.\n");
}
}
}
if (RpClumpGetNumAtomics(m_clump) != 0) {
CVisibilityPlugins::SetClumpModelInfo(m_clump, this);
} else {
RpClumpDestroy(m_clump);
m_clump = nil;
}
}

View File

@ -1,14 +0,0 @@
#pragma once
#include "ClumpModelInfo.h"
class CMloModelInfo : public CClumpModelInfo
{
public:
float field_34; // draw distance?
int firstInstance;
int lastInstance;
public:
CMloModelInfo(void) : CClumpModelInfo(MITYPE_MLO) {}
void ConstructClump();
};

View File

@ -8,13 +8,10 @@
CBaseModelInfo *CModelInfo::ms_modelInfoPtrs[MODELINFOSIZE];
CStore<CSimpleModelInfo, SIMPLEMODELSIZE> CModelInfo::ms_simpleModelStore;
CStore<CMloModelInfo, MLOMODELSIZE> CModelInfo::ms_mloModelStore;
CStore<CInstance, MLOINSTANCESIZE> CModelInfo::ms_mloInstanceStore;
CStore<CTimeModelInfo, TIMEMODELSIZE> CModelInfo::ms_timeModelStore;
CStore<CClumpModelInfo, CLUMPMODELSIZE> CModelInfo::ms_clumpModelStore;
CStore<CPedModelInfo, PEDMODELSIZE> CModelInfo::ms_pedModelStore;
CStore<CVehicleModelInfo, VEHICLEMODELSIZE> CModelInfo::ms_vehicleModelStore;
CStore<CXtraCompsModelInfo, XTRACOMPSMODELSIZE> CModelInfo::ms_xtraCompsModelStore;
CStore<C2dEffect, TWODFXSIZE> CModelInfo::ms_2dEffectStore;
void
@ -26,11 +23,8 @@ CModelInfo::Initialise(void)
for(i = 0; i < MODELINFOSIZE; i++)
ms_modelInfoPtrs[i] = nil;
ms_2dEffectStore.clear();
ms_mloInstanceStore.clear();
ms_xtraCompsModelStore.clear();
ms_simpleModelStore.clear();
ms_timeModelStore.clear();
ms_mloModelStore.clear();
ms_clumpModelStore.clear();
ms_pedModelStore.clear();
ms_vehicleModelStore.clear();
@ -90,8 +84,6 @@ CModelInfo::ShutDown(void)
int i;
for(i = 0; i < ms_simpleModelStore.allocPtr; i++)
ms_simpleModelStore.store[i].Shutdown();
for(i = 0; i < ms_mloInstanceStore.allocPtr; i++)
ms_mloInstanceStore.store[i].Shutdown();
for(i = 0; i < ms_timeModelStore.allocPtr; i++)
ms_timeModelStore.store[i].Shutdown();
for(i = 0; i < ms_clumpModelStore.allocPtr; i++)
@ -100,18 +92,11 @@ CModelInfo::ShutDown(void)
ms_vehicleModelStore.store[i].Shutdown();
for(i = 0; i < ms_pedModelStore.allocPtr; i++)
ms_pedModelStore.store[i].Shutdown();
for(i = 0; i < ms_xtraCompsModelStore.allocPtr; i++)
ms_xtraCompsModelStore.store[i].Shutdown();
for(i = 0; i < ms_mloInstanceStore.allocPtr; i++)
ms_mloInstanceStore.store[i].Shutdown();
for(i = 0; i < ms_2dEffectStore.allocPtr; i++)
ms_2dEffectStore.store[i].Shutdown();
ms_2dEffectStore.clear();
ms_simpleModelStore.clear();
ms_mloInstanceStore.clear();
ms_mloModelStore.clear();
ms_xtraCompsModelStore.clear();
ms_timeModelStore.clear();
ms_pedModelStore.clear();
ms_clumpModelStore.clear();
@ -128,18 +113,6 @@ CModelInfo::AddSimpleModel(int id)
return modelinfo;
}
CMloModelInfo *
CModelInfo::AddMloModel(int id)
{
CMloModelInfo *modelinfo;
modelinfo = CModelInfo::ms_mloModelStore.alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
modelinfo->firstInstance = 0;
modelinfo->lastInstance = 0;
return modelinfo;
}
CTimeModelInfo*
CModelInfo::AddTimeModel(int id)
{
@ -200,7 +173,6 @@ CModelInfo::GetModelInfo(const char *name, int *id)
return nil;
}
#ifdef MIAMI
CBaseModelInfo*
CModelInfo::GetModelInfo(const char *name, int minIndex, int maxIndex)
{
@ -212,7 +184,6 @@ CModelInfo::GetModelInfo(const char *name, int minIndex, int maxIndex)
}
return nil;
}
#endif
bool
CModelInfo::IsBoatModel(int32 id)
@ -228,32 +199,6 @@ CModelInfo::IsBikeModel(int32 id)
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE;
}
#ifndef MIAMI
void
CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level)
{
int i;
CBaseModelInfo *mi;
CColModel *colmodel;
for(i = 0; i < MODELINFOSIZE; i++){
mi = GetModelInfo(i);
if(mi){
colmodel = mi->GetColModel();
if(colmodel && colmodel->level != LEVEL_NONE && colmodel->level != level)
colmodel->RemoveCollisionVolumes();
}
}
}
#endif
void
CModelInfo::ConstructMloClumps()
{
for (int i = 0; i < ms_mloModelStore.allocPtr; i++)
ms_mloModelStore.store[i].ConstructClump();
}
void
CModelInfo::ReInit2dEffects()
{

View File

@ -3,52 +3,41 @@
#include "2dEffect.h"
#include "BaseModelInfo.h"
#include "SimpleModelInfo.h"
#include "MloModelInfo.h"
#include "TimeModelInfo.h"
#include "ClumpModelInfo.h"
#include "PedModelInfo.h"
#include "VehicleModelInfo.h"
#include "XtraCompsModelInfo.h"
#include "Instance.h"
class CModelInfo
{
static CBaseModelInfo *ms_modelInfoPtrs[MODELINFOSIZE];
static CStore<CSimpleModelInfo, SIMPLEMODELSIZE> ms_simpleModelStore;
static CStore<CMloModelInfo, MLOMODELSIZE> ms_mloModelStore;
static CStore<CInstance, MLOINSTANCESIZE> ms_mloInstanceStore;
static CStore<CTimeModelInfo, TIMEMODELSIZE> ms_timeModelStore;
static CStore<CClumpModelInfo, CLUMPMODELSIZE> ms_clumpModelStore;
static CStore<CPedModelInfo, PEDMODELSIZE> ms_pedModelStore;
static CStore<CVehicleModelInfo, VEHICLEMODELSIZE> ms_vehicleModelStore;
static CStore<C2dEffect, TWODFXSIZE> ms_2dEffectStore;
static CStore<CXtraCompsModelInfo, XTRACOMPSMODELSIZE> ms_xtraCompsModelStore;
public:
static void Initialise(void);
static void ShutDown(void);
static CSimpleModelInfo *AddSimpleModel(int id);
static CMloModelInfo *AddMloModel(int id);
static CTimeModelInfo *AddTimeModel(int id);
static CClumpModelInfo *AddClumpModel(int id);
static CPedModelInfo *AddPedModel(int id);
static CVehicleModelInfo *AddVehicleModel(int id);
static CStore<C2dEffect, TWODFXSIZE> &Get2dEffectStore(void) { return ms_2dEffectStore; }
static CStore<CInstance, MLOINSTANCESIZE> &GetMloInstanceStore(void) { return ms_mloInstanceStore; }
static CBaseModelInfo *GetModelInfo(const char *name, int *id);
static CBaseModelInfo *GetModelInfo(int id){
return ms_modelInfoPtrs[id];
}
#ifdef MIAMI
static CBaseModelInfo *GetModelInfo(const char *name, int minIndex, int maxIndex);
#endif
static bool IsBoatModel(int32 id);
static bool IsBikeModel(int32 id);
static void RemoveColModelsFromOtherLevels(eLevelName level);
static void ConstructMloClumps();
static void ReInit2dEffects();
};

View File

@ -130,7 +130,6 @@ CSimpleModelInfo::GetAtomicFromDistance(float dist)
return nil;
}
#ifdef MIAMI
RpAtomic*
CSimpleModelInfo::GetFirstAtomicFromDistance(float dist)
{
@ -138,7 +137,6 @@ CSimpleModelInfo::GetFirstAtomicFromDistance(float dist)
return m_atomics[0];
return nil;
}
#endif
void
CSimpleModelInfo::FindRelatedModel(void)

View File

@ -40,9 +40,7 @@ public:
float GetNearDistance(void);
float GetLargestLodDistance(void);
RpAtomic *GetAtomicFromDistance(float dist);
#ifdef MIAMI
RpAtomic *GetFirstAtomicFromDistance(float dist); // inline
#endif
RpAtomic *GetFirstAtomicFromDistance(float dist);
void FindRelatedModel(void);
void SetupBigBuilding(void);

View File

@ -1,12 +0,0 @@
#pragma once
#include "ClumpModelInfo.h"
class CXtraCompsModelInfo : public CClumpModelInfo
{
int field_34;
public:
CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; }
void SetClump(RpClump*) {};
void Shutdown(void) {};
};

View File

@ -187,11 +187,6 @@ CCivilianPed::CivilianAI(void)
void
CCivilianPed::ProcessControl(void)
{
#ifndef MIAMI
if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory)
return;
#endif
CPed::ProcessControl();
if (bWasPostponed)

View File

@ -425,14 +425,9 @@ CCopPed::CopAI(void)
#ifdef VC_PED_PORTS
float dotProd;
if (m_nRoadblockNode != -1) {
#ifndef MIAMI
CTreadable *roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_nRoadblockNode]];
dotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockRoad->GetPosition(), GetPosition() - roadBlockRoad->GetPosition());
#else
// TODO: check this, i'm only getting this compile here....
// TODO(MIAMI): check this, i'm only getting this compile here....
CPathNode *roadBlockNode = &ThePaths.m_pathNodes[CRoadBlocks::RoadBlockNodes[m_nRoadblockNode]];
dotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockNode->GetPosition(), GetPosition() - roadBlockNode->GetPosition());
#endif
} else
dotProd = -1.0f;
@ -565,11 +560,6 @@ CCopPed::CopAI(void)
void
CCopPed::ProcessControl(void)
{
#ifndef MIAMI
if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory)
return;
#endif
CPed::ProcessControl();
if (bWasPostponed)
return;
@ -717,7 +707,7 @@ CCopPed::ProcessControl(void)
return;
bool dontShoot = false;
if (GetIsOnScreenAndNotCulled()) {
if (GetIsOnScreen()) {
if (((CTimer::GetFrameCounter() + m_randomSeed) & 0x1F) == 17) {
CEntity *foundBuilding = nil;
CColPoint foundCol;

View File

@ -44,11 +44,6 @@ CEmergencyPed::InRange(CPed *victim)
void
CEmergencyPed::ProcessControl(void)
{
#ifndef MIAMI
if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory)
return;
#endif
CPed::ProcessControl();
if (bWasPostponed)
return;

View File

@ -9397,11 +9397,6 @@ CPed::ProcessControl(void)
CColPoint foundCol;
CEntity *foundEnt = nil;
#ifndef MIAMI
if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory)
return;
#endif
int alpha = CVisibilityPlugins::GetClumpAlpha(GetClump());
if (!bFadeOut) {
if (alpha < 255) {

View File

@ -858,90 +858,6 @@ CPopulation::AddPedInCar(CVehicle* car)
void
CPopulation::MoveCarsAndPedsOutOfAbandonedZones()
{
#ifndef MIAMI
eLevelName level;
int zone;
int frame = CTimer::GetFrameCounter() & 7;
if (frame == 1) {
int movedVehicleCount = 0;
int poolSize = CPools::GetVehiclePool()->GetSize();
for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex);
if (veh && veh->m_nZoneLevel == LEVEL_NONE && veh->IsCar()) {
if(veh->GetStatus() != STATUS_ABANDONED && veh->GetStatus() != STATUS_WRECKED && veh->GetStatus() != STATUS_PLAYER &&
veh->GetStatus() != STATUS_PLAYER_REMOTE) {
CVector vehPos(veh->GetPosition());
CPopulation::FindCollisionZoneForCoors(&vehPos, &zone, &level);
// Level 0 is transition zones, and we don't wanna touch cars on transition zones.
if (level != LEVEL_NONE && level != CCollision::ms_collisionInMemory && vehPos.z > -4.0f) {
if (veh->bIsLocked || !veh->CanBeDeleted()) {
switch (movedVehicleCount & 3) {
case 0:
veh->SetPosition(RegenerationPoint_a);
break;
case 1:
veh->SetPosition(RegenerationPoint_b);
break;
case 2:
veh->SetPosition(RegenerationPoint_a.x, RegenerationPoint_b.y, RegenerationPoint_a.z);
break;
case 3:
veh->SetPosition(RegenerationPoint_b.x, RegenerationPoint_a.y, RegenerationPoint_a.z);
break;
default:
break;
}
veh->GetMatrix().GetPosition().z += (movedVehicleCount / 4) * 7.0f;
veh->GetMatrix().GetForward() = RegenerationForward;
((CAutomobile*)veh)->PlaceOnRoadProperly();
CCarCtrl::JoinCarWithRoadSystem(veh);
CTheScripts::ClearSpaceForMissionEntity(veh->GetPosition(), veh);
++movedVehicleCount;
} else {
CWorld::Remove(veh);
delete veh;
}
}
}
}
}
} else if (frame == 5) {
int poolSize = CPools::GetPedPool()->GetSize();
for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex);
if (ped && ped->m_nZoneLevel == LEVEL_NONE && !ped->bInVehicle) {
CVector pedPos(ped->GetPosition());
CPopulation::FindCollisionZoneForCoors(&pedPos, &zone, &level);
// Level 0 is transition zones, and we don't wanna touch peds on transition zones.
if (level != LEVEL_NONE && level != CCollision::ms_collisionInMemory && pedPos.z > -4.0f) {
if (ped->CanBeDeleted()) {
CWorld::Remove(ped);
delete ped;
} else if (ped->m_nPedType != PEDTYPE_PLAYER1 && ped->m_nPedType != PEDTYPE_PLAYER2) {
ped->SetPosition(RegenerationPoint_a);
bool foundGround;
float groundZ = CWorld::FindGroundZFor3DCoord(ped->GetPosition().x, ped->GetPosition().y,
ped->GetPosition().z + 2.0f, &foundGround);
if (foundGround) {
ped->GetMatrix().GetPosition().z = 1.0f + groundZ;
//ped->GetPosition().z += 0.0f;
CTheScripts::ClearSpaceForMissionEntity(ped->GetPosition(), ped);
}
}
}
}
}
}
#endif
}
void

View File

@ -20,8 +20,6 @@
#include "PointLights.h"
#include "Renderer.h"
bool gbShowPedRoadGroups;
bool gbShowCarRoadGroups;
bool gbShowCollisionPolys;
bool gbShowCollisionLines;
bool gbShowCullZoneDebugStuff;
@ -193,23 +191,7 @@ CRenderer::RenderRoads(void)
for(i = 0; i < ms_nNoOfVisibleEntities; i++){
t = (CTreadable*)ms_aVisibleEntityPtrs[i];
if(t->IsBuilding() && t->GetIsATreadable()){
#ifndef MASTER
#ifndef MIAMI
if(gbShowCarRoadGroups || gbShowPedRoadGroups){
int ind = 0;
if(gbShowCarRoadGroups)
ind += ThePaths.m_pathNodes[t->m_nodeIndices[PATH_CAR][0]].group;
if(gbShowPedRoadGroups)
ind += ThePaths.m_pathNodes[t->m_nodeIndices[PATH_PED][0]].group;
SetAmbientColoursToIndicateRoadGroup(ind);
}
#endif
#endif
RenderOneRoad(t);
#ifndef MASTER
if(gbShowCarRoadGroups || gbShowPedRoadGroups)
ReSetAmbientAndDirectionalColours();
#endif
}
}
}
@ -328,153 +310,6 @@ enum Visbility
int32
CRenderer::SetupEntityVisibility(CEntity *ent)
{
#ifndef MIAMI
CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex);
CTimeModelInfo *ti;
int32 other;
float dist;
bool request = true;
if (mi->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)mi;
other = ti->GetOtherTimeModel();
if(CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff())){
// don't fade in, or between time objects
if(CANTIMECULL)
ti->m_alpha = 255;
}else{
// Hide if possible
if(CANTIMECULL)
return VIS_INVISIBLE;
// can't cull, so we'll try to draw this one, but don't request
// it since what we really want is the other one.
request = false;
}
}else{
if (mi->GetModelType() != MITYPE_SIMPLE) {
if(FindPlayerVehicle() == ent &&
TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON){
// Player's vehicle in first person mode
if(TheCamera.Cams[TheCamera.ActiveCam].DirectionWasLooking == LOOKING_FORWARD ||
ent->GetModelIndex() == MI_RHINO ||
ent->GetModelIndex() == MI_COACH ||
TheCamera.m_bInATunnelAndABigVehicle){
ent->bNoBrightHeadLights = true;
}else{
m_pFirstPersonVehicle = (CVehicle*)ent;
ent->bNoBrightHeadLights = false;
}
return VIS_OFFSCREEN;
}else{
// All sorts of Clumps
if(ent->m_rwObject == nil || !ent->bIsVisible)
return VIS_INVISIBLE;
if(!ent->GetIsOnScreen())
return VIS_OFFSCREEN;
if(ent->bDrawLast){
dist = (ent->GetPosition() - ms_vecCameraPosition).Magnitude();
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
ent->bDistanceFade = false;
return VIS_INVISIBLE;
}else
return VIS_VISIBLE;
}
return VIS_INVISIBLE;
}
if(ent->IsObject() &&
((CObject*)ent)->ObjectCreatedBy == TEMP_OBJECT){
if(ent->m_rwObject == nil || !ent->bIsVisible)
return VIS_INVISIBLE;
return ent->GetIsOnScreen() ? VIS_VISIBLE : VIS_OFFSCREEN;
}
}
// Simple ModelInfo
dist = (ent->GetPosition() - ms_vecCameraPosition).Magnitude();
// This can only happen with multi-atomic models (e.g. railtracks)
// but why do we bump up the distance? can only be fading...
if(LOD_DISTANCE + STREAM_DISTANCE < dist && dist < mi->GetLargestLodDistance())
dist = mi->GetLargestLodDistance();
if(ent->IsObject() && ent->bRenderDamaged)
mi->m_isDamaged = true;
RpAtomic *a = mi->GetAtomicFromDistance(dist);
if(a){
mi->m_isDamaged = false;
if(ent->m_rwObject == nil)
ent->CreateRwObject();
assert(ent->m_rwObject);
RpAtomic *rwobj = (RpAtomic*)ent->m_rwObject;
// Make sure our atomic uses the right geometry and not
// that of an atomic for another draw distance.
if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj))
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
mi->IncreaseAlpha();
if(ent->m_rwObject == nil || !ent->bIsVisible)
return VIS_INVISIBLE;
if(!ent->GetIsOnScreen()){
mi->m_alpha = 255;
return VIS_OFFSCREEN;
}
if(mi->m_alpha != 255){
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
ent->bDistanceFade = true;
return VIS_INVISIBLE;
}
if(mi->m_drawLast || ent->bDrawLast){
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
ent->bDistanceFade = false;
return VIS_INVISIBLE;
}
return VIS_VISIBLE;
}
// Object is not loaded, figure out what to do
if(mi->m_noFade){
mi->m_isDamaged = false;
// request model
if(dist - STREAM_DISTANCE < mi->GetLargestLodDistance() && request)
return VIS_STREAMME;
return VIS_INVISIBLE;
}
// We might be fading
a = mi->GetAtomicFromDistance(dist - FADE_DISTANCE);
mi->m_isDamaged = false;
if(a == nil){
// request model
if(dist - FADE_DISTANCE - STREAM_DISTANCE < mi->GetLargestLodDistance() && request)
return VIS_STREAMME;
return VIS_INVISIBLE;
}
if(ent->m_rwObject == nil)
ent->CreateRwObject();
assert(ent->m_rwObject);
RpAtomic *rwobj = (RpAtomic*)ent->m_rwObject;
if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj))
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
mi->IncreaseAlpha();
if(ent->m_rwObject == nil || !ent->bIsVisible)
return VIS_INVISIBLE;
if(!ent->GetIsOnScreen()){
mi->m_alpha = 255;
return VIS_OFFSCREEN;
}else{
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
ent->bDistanceFade = true;
return VIS_OFFSCREEN; // Why this?
}
#else
CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex);
CTimeModelInfo *ti;
int32 other;
@ -625,95 +460,11 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
ent->bDistanceFade = true;
return VIS_OFFSCREEN; // Why this?
}
#endif
}
int32
CRenderer::SetupBigBuildingVisibility(CEntity *ent)
{
#ifndef MIAMI
CSimpleModelInfo *mi = (CSimpleModelInfo *)CModelInfo::GetModelInfo(ent->GetModelIndex());
CTimeModelInfo *ti;
int32 other;
if (mi->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)mi;
other = ti->GetOtherTimeModel();
// Hide objects not in time range if possible
if(CANTIMECULL)
if(!CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff()))
return VIS_INVISIBLE;
// Draw like normal
} else if (mi->GetModelType() == MITYPE_VEHICLE)
return ent->IsVisible() ? VIS_VISIBLE : VIS_INVISIBLE;
float dist = (ms_vecCameraPosition-ent->GetPosition()).Magnitude();
CSimpleModelInfo *nonLOD = mi->GetRelatedModel();
// Find out whether to draw below near distance.
// This is only the case if there is a non-LOD which is either not
// loaded or not completely faded in yet.
if(dist < mi->GetNearDistance() && dist < LOD_DISTANCE + STREAM_DISTANCE){
// No non-LOD or non-LOD is completely visible.
if(nonLOD == nil ||
nonLOD->GetRwObject() && nonLOD->m_alpha == 255)
return VIS_INVISIBLE;
// But if it is a time object, we'd rather draw the wrong
// non-LOD than the right LOD.
if (nonLOD->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)nonLOD;
other = ti->GetOtherTimeModel();
if(other != -1 && CModelInfo::GetModelInfo(other)->GetRwObject())
return VIS_INVISIBLE;
}
}
RpAtomic *a = mi->GetAtomicFromDistance(dist);
if(a){
if(ent->m_rwObject == nil)
ent->CreateRwObject();
assert(ent->m_rwObject);
RpAtomic *rwobj = (RpAtomic*)ent->m_rwObject;
// Make sure our atomic uses the right geometry and not
// that of an atomic for another draw distance.
if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj))
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
if(!ent->IsVisibleComplex())
return VIS_INVISIBLE;
if(mi->m_drawLast){
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
ent->bDistanceFade = false;
return VIS_INVISIBLE;
}
return VIS_VISIBLE;
}
if(mi->m_noFade){
ent->DeleteRwObject();
return VIS_INVISIBLE;
}
// get faded atomic
a = mi->GetAtomicFromDistance(dist - FADE_DISTANCE);
if(a == nil){
ent->DeleteRwObject();
return VIS_INVISIBLE;
}
// Fade...
if(ent->m_rwObject == nil)
ent->CreateRwObject();
assert(ent->m_rwObject);
RpAtomic *rwobj = (RpAtomic*)ent->m_rwObject;
if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj))
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
if(ent->IsVisibleComplex())
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
return VIS_INVISIBLE;
#else
CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex);
CTimeModelInfo *ti;
int32 other;
@ -827,7 +578,6 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
}else
mi->m_alpha = 255;
return VIS_INVISIBLE;
#endif
}
void
@ -974,11 +724,7 @@ CRenderer::ScanWorld(void)
}
ScanSectorPoly(poly, 3, ScanSectorList);
#ifndef MIAMI
ScanBigBuildingList(CWorld::GetBigBuildingList(CCollision::ms_collisionInMemory));
#else
ScanBigBuildingList(CWorld::GetBigBuildingList(CGame::currLevel));
#endif
ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_NONE));
}
}
@ -1223,13 +969,6 @@ CRenderer::ScanBigBuildingList(CPtrList &list)
CPtrNode *node;
CEntity *ent;
#ifndef MIAMI
for(node = list.first; node; node = node->next){
ent = (CEntity*)node->item;
if(!ent->bZoneCulled && SetupBigBuildingVisibility(ent) == VIS_VISIBLE)
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
}
#else
// TODO(MIAMI): some flags and such
for(node = list.first; node; node = node->next){
ent = (CEntity*)node->item;
@ -1243,7 +982,6 @@ CRenderer::ScanBigBuildingList(CPtrList &list)
break;
}
}
#endif
}
void

View File

@ -2,8 +2,6 @@
class CEntity;
extern bool gbShowPedRoadGroups;
extern bool gbShowCarRoadGroups;
extern bool gbShowCollisionPolys;
extern bool gbShowCollisionLines;
extern bool gbShowCullZoneDebugStuff;

View File

@ -614,16 +614,6 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump)
return true;
}
bool
CVisibilityPlugins::MloVisibilityCB(RpClump *clump)
{
RwFrame *frame = RpClumpGetFrame(clump);
CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame);
if (sq(modelInfo->field_34) < GetDistanceSquaredFromCamera(frame))
return false;
return CVisibilityPlugins::FrustumSphereCB(clump);
}
bool
CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
{

View File

@ -543,13 +543,6 @@ RestoreForStartLoad()
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().z);
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel);
#ifndef MIAMI
CCollision::SortOutCollisionAfterLoad();
CStreaming::RequestBigBuildings(CGame::currLevel);
CStreaming::LoadAllRequestedModels(false);
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
CGame::TidyUpMemory(true, false);
#endif
if (CloseFile(file)) {
return true;

View File

@ -229,12 +229,6 @@ CAutomobile::ProcessControl(void)
colModel = GetColModel();
bWarnedPeds = false;
#ifndef MIAMI
// skip if the collision isn't for the current level
if(colModel->level > LEVEL_NONE && colModel->level != CCollision::ms_collisionInMemory)
return;
#endif
// Improve grip of vehicles in certain cases
bool strongGrip1 = false;
bool strongGrip2 = false;

View File

@ -109,11 +109,6 @@ CBoat::GetComponentWorldPosition(int32 component, CVector &pos)
void
CBoat::ProcessControl(void)
{
#ifndef MIAMI
if(m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory)
return;
#endif
bool onLand = m_fDamageImpulse > 0.0f && m_vecDamageNormal.z > 0.1f;
PruneWakeTrail();

View File

@ -99,9 +99,7 @@ CVehicle::CVehicle(uint8 CreatedBy)
m_bSirenOrAlarm = 0;
m_nCarHornTimer = 0;
m_nCarHornPattern = 0;
#ifdef MIAMI
bParking = false;
#endif
m_nAlarmState = 0;
m_nDoorLock = CARLOCK_UNLOCKED;
m_nLastWeaponDamage = -1;
@ -121,9 +119,7 @@ CVehicle::CVehicle(uint8 CreatedBy)
AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds();
AutoPilot.m_bStayInCurrentLevel = false;
AutoPilot.m_bIgnorePathfinding = false;
#ifdef MIAMI
AutoPilot.m_nSwitchDistance = 20;
#endif
}
CVehicle::~CVehicle()