summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/FileLoader.cpp8
-rw-r--r--src/core/Pools.cpp1
-rw-r--r--src/core/Streaming.cpp32
-rw-r--r--src/core/config.h2
-rw-r--r--src/core/main.cpp27
-rw-r--r--src/peds/PedAttractor.cpp19
-rw-r--r--src/rw/MemoryHeap.h1
7 files changed, 73 insertions, 17 deletions
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index d66a1b88..dd313f79 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -98,10 +98,13 @@ CFileLoader::LoadLevel(const char *filename)
}else if(strncmp(line, "IPL", 3) == 0){
if(!objectsLoaded){
LoadingScreenLoadingFile("Collision");
- POP_MEMID();
+ PUSH_MEMID(MEMID_WORLD);
CObjectData::Initialise("DATA\\OBJECT.DAT");
CStreaming::Init();
+ POP_MEMID();
+ PUSH_MEMID(MEMID_COLLISION);
CColStore::LoadAllCollision();
+ POP_MEMID();
for(int i = 0; i < MODELINFOSIZE; i++)
if(CModelInfo::GetModelInfo(i))
CModelInfo::GetModelInfo(i)->ConvertAnimFileIndex();
@@ -110,12 +113,15 @@ CFileLoader::LoadLevel(const char *filename)
PUSH_MEMID(MEMID_WORLD);
LoadingScreenLoadingFile(line + 4);
LoadScene(line + 4);
+ POP_MEMID();
}else if(strncmp(line, "SPLASH", 6) == 0){
#ifndef DISABLE_LOADING_SCREEN
LoadSplash(GetRandomSplashScreen());
#endif
+#ifndef GTA_PS2
}else if(strncmp(line, "CDIMAGE", 7) == 0){
CdStreamAddImage(line + 8);
+#endif
}
}
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index f3aeda8c..dfc7a82f 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -29,6 +29,7 @@ CAudioScriptObjectPool *CPools::ms_pAudioScriptObjectPool;
CColModelPool *CPools::ms_pColModelPool;
#if defined GTA_PS2 && !defined MASTER // or USE_CUSTOM_ALLOCATOR
+// not in VC. perhaps ifdef'ed away
#define CHECKMEM(msg) CMemCheck::AllocateMemCheckBlock(msg)
#else
#define CHECKMEM(msg)
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index afc6704d..8c1b839c 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -480,6 +480,14 @@ GetObjectName(int streamId)
return objname;
}
+#ifdef USE_CUSTOM_ALLOCATOR
+RpAtomic*
+RegisterAtomicMemPtrsCB(RpAtomic *atomic, void *data)
+{
+ // empty because we expect models to be pre-instanced
+ return atomic;
+}
+#endif
bool
CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
@@ -514,9 +522,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
// Set Txd and anims to use
CTxdStore::AddRef(mi->GetTxdSlot());
+#if GTA_VERSION > GTAVC_PS2
if(animId != -1)
CAnimManager::AddAnimBlockRef(animId);
- CTxdStore::SetCurrentTxd(mi->GetTxdSlot());
+#endif
PUSH_MEMID(MEMID_STREAM_MODELS);
CTxdStore::SetCurrentTxd(mi->GetTxdSlot());
@@ -542,8 +551,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
// Txd and anims no longer needed unless we only read part of the file
if(ms_aInfoForModel[streamId].m_loadState != STREAMSTATE_STARTED){
CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot());
+#if GTA_VERSION > GTAVC_PS2
if(animId != -1)
CAnimManager::RemoveAnimBlockRefWithoutDelete(animId);
+#endif
}
if(!success){
@@ -580,7 +591,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
return false;
}
}else if(streamId >= STREAM_OFFSET_COL && streamId < STREAM_OFFSET_ANIM){
- if(!CColStore::LoadCol(streamId-STREAM_OFFSET_COL, mem.start, mem.length)){
+ PUSH_MEMID(MEMID_STREAM_COLLISION);
+ bool success = CColStore::LoadCol(streamId-STREAM_OFFSET_COL, mem.start, mem.length);
+ POP_MEMID();
+ if(!success){
debug("Failed to load %s.col\n", CColStore::GetColName(streamId - STREAM_OFFSET_COL));
RemoveModel(streamId);
ReRequestModel(streamId);
@@ -595,8 +609,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
RwStreamClose(stream, &mem);
return false;
}
+ PUSH_MEMID(MEMID_STREAM_ANIMATION);
CAnimManager::LoadAnimFile(stream, true, nil);
CAnimManager::CreateAnimAssocGroups();
+ POP_MEMID();
}
RwStreamClose(stream, &mem);
@@ -678,8 +694,10 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
POP_MEMID();
mi->RemoveRef();
CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot());
+#if GTA_VERSION > GTAVC_PS2
if(mi->GetAnimFileIndex() != -1)
CAnimManager::RemoveAnimBlockRefWithoutDelete(mi->GetAnimFileIndex());
+#endif
}else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){
// Txd
CTxdStore::AddRef(streamId - STREAM_OFFSET_TXD);
@@ -693,7 +711,7 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
RwStreamClose(stream, &mem);
- ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; // only done if success on PS2
+ ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED;
#ifndef USE_CUSTOM_ALLOCATOR
ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE;
#endif
@@ -701,11 +719,11 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
if(!success){
RemoveModel(streamId);
ReRequestModel(streamId);
- UpdateMemoryUsed(); // directly after pop on PS2
+ UpdateMemoryUsed();
return false;
}
- UpdateMemoryUsed(); // directly after pop on PS2
+ UpdateMemoryUsed();
endTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond();
timeDiff = endTime - startTime;
@@ -2471,7 +2489,9 @@ CStreaming::UpdateMemoryUsed(void)
ms_memoryUsed =
gMainHeap.GetMemoryUsed(MEMID_STREAM) +
gMainHeap.GetMemoryUsed(MEMID_STREAM_MODELS) +
- gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES);
+ gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES) +
+ gMainHeap.GetMemoryUsed(MEMID_STREAM_COLLISION) +
+ gMainHeap.GetMemoryUsed(MEMID_STREAM_ANIMATION);
#endif
}
diff --git a/src/core/config.h b/src/core/config.h
index 7e7292a3..7742999f 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -7,7 +7,7 @@ enum Config {
MAX_CDIMAGES = 8, // additional cdimages
MAX_CDCHANNELS = 5,
- MODELINFOSIZE = 6500,
+ MODELINFOSIZE = 6500, // 4900 on PS2
TXDSTORESIZE = 1385,
COLSTORESIZE = 31,
EXTRADIRSIZE = 256,
diff --git a/src/core/main.cpp b/src/core/main.cpp
index b0aeeb1b..f21bec34 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -891,7 +891,7 @@ return;
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
- sprintf(gString, "Render List: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_RENDERLIST), gMainHeap.GetMemoryUsed(MEMID_RENDERLIST));
+ sprintf(gString, "PreAlloc: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_PRE_ALLOC), gMainHeap.GetMemoryUsed(MEMID_PRE_ALLOC));
AsciiToUnicode(gString, gUString);
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
@@ -916,11 +916,31 @@ return;
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
+ sprintf(gString, "Streamed LODs: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_STREAM_LODS), gMainHeap.GetMemoryUsed(MEMID_STREAM_LODS));
+ AsciiToUnicode(gString, gUString);
+ CFont::PrintString(24.0f, y, gUString);
+ y += 12.0f;
+
sprintf(gString, "Streamed Textures: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_STREAM_TEXUTRES), gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES));
AsciiToUnicode(gString, gUString);
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
+ sprintf(gString, "Streamed Collision: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_STREAM_COLLISION), gMainHeap.GetMemoryUsed(MEMID_STREAM_COLLISION));
+ AsciiToUnicode(gString, gUString);
+ CFont::PrintString(24.0f, y, gUString);
+ y += 12.0f;
+
+ sprintf(gString, "Streamed Animation: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_STREAM_ANIMATION), gMainHeap.GetMemoryUsed(MEMID_STREAM_ANIMATION));
+ AsciiToUnicode(gString, gUString);
+ CFont::PrintString(24.0f, y, gUString);
+ y += 12.0f;
+
+ sprintf(gString, "Ped Attr: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_PED_ATTR), gMainHeap.GetMemoryUsed(MEMID_PED_ATTR));
+ AsciiToUnicode(gString, gUString);
+ CFont::PrintString(24.0f, y, gUString);
+ y += 12.0f;
+
sprintf(gString, "Animation: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_ANIMATION), gMainHeap.GetMemoryUsed(MEMID_ANIMATION));
AsciiToUnicode(gString, gUString);
CFont::PrintString(24.0f, y, gUString);
@@ -950,11 +970,6 @@ return;
AsciiToUnicode(gString, gUString);
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
-
- sprintf(gString, "Frontend: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_FRONTEND), gMainHeap.GetMemoryUsed(MEMID_FRONTEND));
- AsciiToUnicode(gString, gUString);
- CFont::PrintString(24.0f, y, gUString);
- y += 12.0f;
#endif
y = 132.0f;
diff --git a/src/peds/PedAttractor.cpp b/src/peds/PedAttractor.cpp
index 05e72ed3..eeb65398 100644
--- a/src/peds/PedAttractor.cpp
+++ b/src/peds/PedAttractor.cpp
@@ -4,6 +4,7 @@
#include "General.h"
#include "Vehicle.h"
#include "World.h"
+#include "MemoryHeap.h"
const int gcMaxSizeOfAtmQueue = 1;
const int gcMaxSizeOfSeatQueue = 1;
@@ -18,8 +19,18 @@ std::vector<CVector> CPedShelterAttractor::ms_displacements;
CPedAttractorManager* GetPedAttractorManager()
{
- static CPedAttractorManager manager;
- return &manager;
+// mobile just has a static here:
+/*
+ static CPedAttractorManager pedAttrMgr;
+ return &pedAttrMgr;
+*/
+ static CPedAttractorManager *pedAttrMgr;
+ if(pedAttrMgr == nil){
+ PUSH_MEMID(MEMID_PED_ATTR);
+ pedAttrMgr = new CPedAttractorManager;
+ POP_MEMID();
+ }
+ return pedAttrMgr;
}
CVehicleToEffect::CVehicleToEffect(CVehicle* pVehicle) : m_pVehicle(pVehicle)
@@ -100,8 +111,10 @@ const C2dEffect* CPedAttractorManager::GetEffectForIceCreamVan(CVehicle* pVehicl
return assoc->ChooseEffect(pos);
}
}
+ PUSH_MEMID(MEMID_PED_ATTR);
CVehicleToEffect effect(pVehicle);
vVehicleToEffect.push_back(effect);
+ POP_MEMID();
return effect.ChooseEffect(pos);
}
@@ -645,6 +658,7 @@ CPedAttractor* CPedAttractorManager::RegisterPed(CPed* pPed, C2dEffect* pEffect,
pRegisteredAttractor->RegisterPed(pPed);
return pRegisteredAttractor;
}
+ PUSH_MEMID(MEMID_PED_ATTR);
switch (pEffect->pedattr.type) {
case ATTRACTOR_ATM: vecAttractors.push_back(new CPedAtmAttractor(pEffect, matrix, gcMaxSizeOfAtmQueue, 1.0f, 30000.0f, 3000.0f, 0.2f, 0.15f, 0.1f, 0.1f)); break;
case ATTRACTOR_SEAT: vecAttractors.push_back(new CPedSeatAttractor(pEffect, matrix, gcMaxSizeOfSeatQueue, 1.0f, 30000.0f, 3000.0f, 0.125f, 0.1f, 0.1f, 0.1f)); break;
@@ -653,6 +667,7 @@ CPedAttractor* CPedAttractorManager::RegisterPed(CPed* pPed, C2dEffect* pEffect,
case ATTRACTOR_SHELTER: vecAttractors.push_back(new CPedShelterAttractor(pEffect, matrix, gcMaxSizeOfShelterQueue, 1.0f, 30000.0f, 3000.0f, 0.5f, 6.28f, 0.1f, 0.1f)); break;
case ATTRACTOR_ICECREAM: vecAttractors.push_back(new CPedIceCreamAttractor(pEffect, matrix, gcMaxSizeOfIceCreamQueue, 1.0f, 30000.0f, 3000.0f, 0.2f, 0.3f, 0.1f, 0.1f)); break;
}
+ POP_MEMID();
if (pRegisteredAttractor)
pRegisteredAttractor->RegisterPed(pPed);
return pRegisteredAttractor;
diff --git a/src/rw/MemoryHeap.h b/src/rw/MemoryHeap.h
index 38a8ba2b..1a9a51f8 100644
--- a/src/rw/MemoryHeap.h
+++ b/src/rw/MemoryHeap.h
@@ -17,7 +17,6 @@
enum {
MEMID_FREE,
- // IDs from LCS:
MEMID_GAME = 1, // "Game"
MEMID_WORLD = 2, // "World"
MEMID_ANIMATION = 3, // "Animation"