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

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

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();
}