small streaming fixes

This commit is contained in:
aap 2020-08-20 23:45:05 +02:00
parent 73dd29ea3a
commit dace79c7c3

View File

@ -273,8 +273,12 @@ CStreaming::Shutdown(void)
{ {
RwFreeAlign(ms_pStreamingBuffer[0]); RwFreeAlign(ms_pStreamingBuffer[0]);
ms_streamingBufferSize = 0; ms_streamingBufferSize = 0;
if(ms_pExtraObjectsDir) if(ms_pExtraObjectsDir){
delete ms_pExtraObjectsDir; delete ms_pExtraObjectsDir;
#ifdef FIX_BUGS
ms_pExtraObjectsDir = nil;
#endif
}
} }
void void
@ -1191,7 +1195,7 @@ found:
if(id == -1) if(id == -1)
return false; // still no luck return false; // still no luck
ms_lastVehicleDeleted = id; ms_lastVehicleDeleted = id;
// this is more that we wanted actually // this is more than we wanted actually
ms_numVehiclesLoaded++; ms_numVehiclesLoaded++;
}else }else
RemoveModel(id); RemoveModel(id);
@ -1384,17 +1388,16 @@ CStreaming::StreamZoneModels(const CVector &pos)
// unload pevious group // unload pevious group
if(ms_currentPedGrp != -1) if(ms_currentPedGrp != -1)
for(i = 0; i < NUMMODELSPERPEDGROUP; i++){ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1){
break;
SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
} }
}
ms_currentPedGrp = info.pedGroup; ms_currentPedGrp = info.pedGroup;
for(i = 0; i < NUMMODELSPERPEDGROUP; i++){ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1)
break;
RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DONT_REMOVE); RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DONT_REMOVE);
} }
} }
@ -1593,8 +1596,6 @@ CStreaming::GetNextFileOnCd(int32 lastPosn, bool priority)
* Files larger than the buffer size can only be loaded by channel 0, * Files larger than the buffer size can only be loaded by channel 0,
* which then uses both buffers, while channel 1 is idle. * which then uses both buffers, while channel 1 is idle.
* ms_bLoadingBigModel is set to true to indicate this state. * ms_bLoadingBigModel is set to true to indicate this state.
*
* TODO: two-part files
*/ */
// Make channel read from disc // Make channel read from disc
@ -1935,7 +1936,7 @@ CStreaming::UpdateMemoryUsed(void)
// empty // empty
} }
#define STREAM_DIST (2*SECTOR_SIZE_X) #define STREAM_DIST 80.0f
void void
CStreaming::AddModelsToRequestList(const CVector &pos) CStreaming::AddModelsToRequestList(const CVector &pos)
@ -2232,7 +2233,7 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
assert(ymin <= ymax); assert(ymin <= ymax);
// Delete a block of sectors that we know is behind the camera // Delete a block of sectors that we know is behind the camera
if(TheCamera.GetForward().x > 0){ if(TheCamera.GetForward().x > 0.0f){
// looking east // looking east
xmax = Max(ix - 2, 0); xmax = Max(ix - 2, 0);
xmin = Max(ix - 10, 0); xmin = Max(ix - 10, 0);
@ -2254,7 +2255,7 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
} }
// Now a block that intersects with the camera's frustum // Now a block that intersects with the camera's frustum
if(TheCamera.GetForward().x > 0){ if(TheCamera.GetForward().x > 0.0f){
// looking east // looking east
xmax = Max(ix + 10, 0); xmax = Max(ix + 10, 0);
xmin = Max(ix - 2, 0); xmin = Max(ix - 2, 0);
@ -2296,7 +2297,7 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
assert(xmin <= xmax); assert(xmin <= xmax);
// Delete a block of sectors that we know is behind the camera // Delete a block of sectors that we know is behind the camera
if(TheCamera.GetForward().y > 0){ if(TheCamera.GetForward().y > 0.0f){
// looking north // looking north
ymax = Max(iy - 2, 0); ymax = Max(iy - 2, 0);
ymin = Max(iy - 10, 0); ymin = Max(iy - 10, 0);
@ -2318,7 +2319,7 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
} }
// Now a block that intersects with the camera's frustum // Now a block that intersects with the camera's frustum
if(TheCamera.GetForward().y > 0){ if(TheCamera.GetForward().y > 0.0f){
// looking north // looking north
ymax = Max(iy + 10, 0); ymax = Max(iy + 10, 0);
ymin = Max(iy - 2, 0); ymin = Max(iy - 2, 0);