mirror of
https://github.com/GTAmodding/re3.git
synced 2025-07-15 20:24:08 +00:00
merge attempt
This commit is contained in:
commit
8d1996833b
68 changed files with 2149 additions and 316 deletions
|
@ -34,6 +34,7 @@
|
|||
#include "Script.h"
|
||||
#include "MemoryMgr.h"
|
||||
#include "MemoryHeap.h"
|
||||
#include "Font.h"
|
||||
|
||||
//--MIAMI: file done (possibly bugs)
|
||||
|
||||
|
@ -291,12 +292,22 @@ CStreaming::Shutdown(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef MASTER
|
||||
uint64 timeProcessingTXD;
|
||||
uint64 timeProcessingDFF;
|
||||
#endif
|
||||
|
||||
void
|
||||
CStreaming::Update(void)
|
||||
{
|
||||
CStreamingInfo *si, *prev;
|
||||
bool requestedSubway = false;
|
||||
|
||||
#ifndef MASTER
|
||||
timeProcessingTXD = 0;
|
||||
timeProcessingDFF = 0;
|
||||
#endif
|
||||
|
||||
UpdateMemoryUsed();
|
||||
|
||||
if(ms_channelError != -1){
|
||||
|
@ -334,6 +345,10 @@ CStreaming::Update(void)
|
|||
CColStore::EnsureCollisionIsInMemory(FindPlayerCoors());
|
||||
}
|
||||
|
||||
// TODO: PrintRequestList
|
||||
//if (CPad::GetPad(1)->GetLeftShoulder2JustDown() && CPad::GetPad(1)->GetRightShoulder1() && CPad::GetPad(1)->GetRightShoulder2())
|
||||
// PrintRequestList();
|
||||
|
||||
for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){
|
||||
prev = si->m_prev;
|
||||
if((si->m_flags & (STREAMFLAGS_KEEP_IN_MEMORY|STREAMFLAGS_PRIORITY)) == 0)
|
||||
|
@ -503,6 +518,8 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
|
|||
CAnimManager::AddAnimBlockRef(animId);
|
||||
CTxdStore::SetCurrentTxd(mi->GetTxdSlot());
|
||||
|
||||
PUSH_MEMID(MEMID_STREAM_MODELS);
|
||||
CTxdStore::SetCurrentTxd(mi->GetTxdSlot());
|
||||
if(mi->IsSimple()){
|
||||
success = CFileLoader::LoadAtomicFile(stream, streamId);
|
||||
// TODO(MIAMI)? complain if file is not pre-instanced. we hardly are interested in that
|
||||
|
@ -514,7 +531,12 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
|
|||
ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_STARTED;
|
||||
}else{
|
||||
success = CFileLoader::LoadClumpFile(stream, streamId);
|
||||
#ifdef USE_CUSTOM_ALLOCATOR
|
||||
if(success)
|
||||
RpClumpForAllAtomics((RpClump*)mi->GetRwObject(), RegisterAtomicMemPtrsCB, nil);
|
||||
#endif
|
||||
}
|
||||
POP_MEMID();
|
||||
UpdateMemoryUsed();
|
||||
|
||||
// Txd and anims no longer needed unless we only read part of the file
|
||||
|
@ -540,12 +562,14 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
|
|||
return false;
|
||||
}
|
||||
|
||||
PUSH_MEMID(MEMID_STREAM_TEXUTRES);
|
||||
if(ms_bLoadingBigModel || cdsize > 200){
|
||||
success = CTxdStore::StartLoadTxd(streamId - STREAM_OFFSET_TXD, stream);
|
||||
if(success)
|
||||
ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_STARTED;
|
||||
}else
|
||||
success = CTxdStore::LoadTxd(streamId - STREAM_OFFSET_TXD, stream);
|
||||
POP_MEMID();
|
||||
UpdateMemoryUsed();
|
||||
|
||||
if(!success){
|
||||
|
@ -605,7 +629,9 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
|
|||
// Mark objects as loaded
|
||||
if(ms_aInfoForModel[streamId].m_loadState != STREAMSTATE_STARTED){
|
||||
ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED;
|
||||
#ifndef USE_CUSTOM_ALLOCATOR
|
||||
ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE;
|
||||
#endif
|
||||
}
|
||||
|
||||
endTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond();
|
||||
|
@ -640,10 +666,16 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
|
|||
if(streamId < STREAM_OFFSET_TXD){
|
||||
// Model
|
||||
mi = CModelInfo::GetModelInfo(streamId);
|
||||
PUSH_MEMID(MEMID_STREAM_MODELS);
|
||||
CTxdStore::SetCurrentTxd(mi->GetTxdSlot());
|
||||
success = CFileLoader::FinishLoadClumpFile(stream, streamId);
|
||||
if(success)
|
||||
if(success){
|
||||
#ifdef USE_CUSTOM_ALLOCATOR
|
||||
RpClumpForAllAtomics((RpClump*)mi->GetRwObject(), RegisterAtomicMemPtrsCB, nil);
|
||||
#endif
|
||||
success = AddToLoadedVehiclesList(streamId);
|
||||
}
|
||||
POP_MEMID();
|
||||
mi->RemoveRef();
|
||||
CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot());
|
||||
if(mi->GetAnimFileIndex() != -1)
|
||||
|
@ -651,24 +683,29 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
|
|||
}else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){
|
||||
// Txd
|
||||
CTxdStore::AddRef(streamId - STREAM_OFFSET_TXD);
|
||||
PUSH_MEMID(MEMID_STREAM_TEXUTRES);
|
||||
success = CTxdStore::FinishLoadTxd(streamId - STREAM_OFFSET_TXD, stream);
|
||||
POP_MEMID();
|
||||
CTxdStore::RemoveRefWithoutDelete(streamId - STREAM_OFFSET_TXD);
|
||||
}else{
|
||||
assert(0 && "invalid streamId");
|
||||
}
|
||||
|
||||
RwStreamClose(stream, &mem);
|
||||
ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED;
|
||||
|
||||
ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; // only done if success on PS2
|
||||
#ifndef USE_CUSTOM_ALLOCATOR
|
||||
ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE;
|
||||
#endif
|
||||
|
||||
if(!success){
|
||||
RemoveModel(streamId);
|
||||
ReRequestModel(streamId);
|
||||
UpdateMemoryUsed();
|
||||
UpdateMemoryUsed(); // directly after pop on PS2
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateMemoryUsed();
|
||||
UpdateMemoryUsed(); // directly after pop on PS2
|
||||
|
||||
endTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond();
|
||||
timeDiff = endTime - startTime;
|
||||
|
@ -2417,19 +2454,25 @@ CStreaming::FlushRequestList(void)
|
|||
void
|
||||
CStreaming::ImGonnaUseStreamingMemory(void)
|
||||
{
|
||||
// empty
|
||||
PUSH_MEMID(MEMID_STREAM);
|
||||
}
|
||||
|
||||
void
|
||||
CStreaming::IHaveUsedStreamingMemory(void)
|
||||
{
|
||||
POP_MEMID();
|
||||
UpdateMemoryUsed();
|
||||
}
|
||||
|
||||
void
|
||||
CStreaming::UpdateMemoryUsed(void)
|
||||
{
|
||||
// empty
|
||||
#ifdef USE_CUSTOM_ALLOCATOR
|
||||
ms_memoryUsed =
|
||||
gMainHeap.GetMemoryUsed(MEMID_STREAM) +
|
||||
gMainHeap.GetMemoryUsed(MEMID_STREAM_MODELS) +
|
||||
gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define STREAM_DIST 80.0f
|
||||
|
@ -3043,3 +3086,71 @@ CStreaming::UpdateForAnimViewer(void)
|
|||
CStreaming::RetryLoadFile(CStreaming::ms_channelError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CStreaming::PrintStreamingBufferState()
|
||||
{
|
||||
char str[128];
|
||||
wchar wstr[128];
|
||||
uint32 offset, size;
|
||||
|
||||
CTimer::Stop();
|
||||
int i = 0;
|
||||
while (i < NUMSTREAMINFO) {
|
||||
while (true) {
|
||||
int j = 0;
|
||||
DoRWStuffStartOfFrame(50, 50, 50, 0, 0, 0, 255);
|
||||
CPad::UpdatePads();
|
||||
CSprite2d::InitPerFrame();
|
||||
CFont::InitPerFrame();
|
||||
DefinedState();
|
||||
|
||||
CRect unusedRect(0, 0, RsGlobal.maximumWidth, RsGlobal.maximumHeight);
|
||||
CRGBA unusedColor(255, 255, 255, 255);
|
||||
CFont::SetFontStyle(FONT_BANK);
|
||||
CFont::SetBackgroundOff();
|
||||
CFont::SetWrapx(DEFAULT_SCREEN_WIDTH);
|
||||
CFont::SetScale(0.5f, 0.75f);
|
||||
CFont::SetCentreOff();
|
||||
CFont::SetCentreSize(DEFAULT_SCREEN_WIDTH);
|
||||
CFont::SetJustifyOff();
|
||||
CFont::SetColor(CRGBA(200, 200, 200, 200));
|
||||
CFont::SetBackGroundOnlyTextOff();
|
||||
int modelIndex = i;
|
||||
if (modelIndex < NUMSTREAMINFO) {
|
||||
int y = 24;
|
||||
for ( ; j < 34 && modelIndex < NUMSTREAMINFO; modelIndex++) {
|
||||
CStreamingInfo *streamingInfo = &ms_aInfoForModel[modelIndex];
|
||||
CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelIndex);
|
||||
if (streamingInfo->m_loadState != STREAMSTATE_LOADED || !streamingInfo->GetCdPosnAndSize(offset, size))
|
||||
continue;
|
||||
|
||||
if (modelIndex >= STREAM_OFFSET_TXD)
|
||||
sprintf(str, "txd %s, refs %d, size %dK, flags 0x%x", CTxdStore::GetTxdName(modelIndex - STREAM_OFFSET_TXD),
|
||||
CTxdStore::GetNumRefs(modelIndex - STREAM_OFFSET_TXD), 2 * size, streamingInfo->m_flags);
|
||||
else
|
||||
sprintf(str, "model %d,%s, refs%d, size%dK, flags%x", modelIndex, modelInfo->GetName(), modelInfo->GetNumRefs(), 2 * size,
|
||||
streamingInfo->m_flags);
|
||||
AsciiToUnicode(str, wstr);
|
||||
CFont::PrintString(24.0f, y, wstr);
|
||||
y += 12;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
if (CPad::GetPad(1)->GetCrossJustDown())
|
||||
i = modelIndex;
|
||||
|
||||
if (!CPad::GetPad(1)->GetTriangleJustDown())
|
||||
break;
|
||||
|
||||
i = 0;
|
||||
CFont::DrawFonts();
|
||||
DoRWStuffEndOfFrame();
|
||||
}
|
||||
CFont::DrawFonts();
|
||||
DoRWStuffEndOfFrame();
|
||||
}
|
||||
CTimer::Update();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue