mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Merged New Inventory Project into main branch
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+37
-36
@@ -23,15 +23,15 @@
|
||||
UINT32 guiNumTileCacheStructs = 0;
|
||||
UINT32 guiMaxTileCacheSize = 50;
|
||||
UINT32 guiCurTileCacheSize = 0;
|
||||
INT32 giDefaultStructIndex = -1;
|
||||
INT32 giDefaultStructIndex = -1;
|
||||
|
||||
TILE_CACHE_ELEMENT *gpTileCache = NULL;
|
||||
TILE_CACHE_STRUCT *gpTileCacheStructInfo = NULL;
|
||||
|
||||
|
||||
|
||||
BOOLEAN InitTileCache( )
|
||||
{
|
||||
BOOLEAN InitTileCache( )
|
||||
{
|
||||
UINT32 cnt;
|
||||
GETFILESTRUCT FileInfo;
|
||||
INT16 sFiles = 0;
|
||||
@@ -84,13 +84,13 @@ BOOLEAN InitTileCache( )
|
||||
#ifdef JA2TESTVERSION
|
||||
if ( gpTileCacheStructInfo[ cnt ].pStructureFileRef == NULL )
|
||||
{
|
||||
SET_ERROR( "Cannot load tilecache JSD: %s", gpTileCacheStructInfo[ cnt ].Filename );
|
||||
SET_ERROR( "Cannot load tilecache JSD: %s", gpTileCacheStructInfo[ cnt ].Filename );
|
||||
}
|
||||
#endif
|
||||
if ( _stricmp( gpTileCacheStructInfo[ cnt ].zRootName, "l_dead1" ) == 0 )
|
||||
{
|
||||
giDefaultStructIndex = cnt;
|
||||
}
|
||||
if ( _stricmp( gpTileCacheStructInfo[ cnt ].zRootName, "l_dead1" ) == 0 )
|
||||
{
|
||||
giDefaultStructIndex = cnt;
|
||||
}
|
||||
|
||||
cnt++;
|
||||
}
|
||||
@@ -130,12 +130,12 @@ void DeleteTileCache( )
|
||||
INT16 FindCacheStructDataIndex( STR8 cFilename )
|
||||
{
|
||||
UINT32 cnt;
|
||||
|
||||
|
||||
for ( cnt = 0; cnt < guiNumTileCacheStructs; cnt++ )
|
||||
{
|
||||
if ( _stricmp( gpTileCacheStructInfo[ cnt ].zRootName, cFilename ) == 0 )
|
||||
{
|
||||
return( (INT16)cnt );
|
||||
return( (INT16)cnt );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ INT32 GetCachedTile( const STR8 cFilename )
|
||||
{
|
||||
UINT32 cnt;
|
||||
UINT32 ubLowestIndex = 0;
|
||||
INT16 sMostHits = (INT16)15000;
|
||||
INT16 sMostHits = (INT16)15000;
|
||||
|
||||
// Check to see if surface exists already
|
||||
for ( cnt = 0; cnt < guiCurTileCacheSize; cnt++ )
|
||||
@@ -155,9 +155,9 @@ INT32 GetCachedTile( const STR8 cFilename )
|
||||
{
|
||||
if ( _stricmp( gpTileCache[ cnt ].zName, cFilename ) == 0 )
|
||||
{
|
||||
// Found surface, return
|
||||
gpTileCache[ cnt ].sHits++;
|
||||
return( (INT32)cnt );
|
||||
// Found surface, return
|
||||
gpTileCache[ cnt ].sHits++;
|
||||
return( (INT32)cnt );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,11 +168,11 @@ INT32 GetCachedTile( const STR8 cFilename )
|
||||
// cache out least used file
|
||||
for ( cnt = 0; cnt < guiCurTileCacheSize; cnt++ )
|
||||
{
|
||||
if ( gpTileCache[ cnt ].sHits < sMostHits )
|
||||
{
|
||||
if ( gpTileCache[ cnt ].sHits < sMostHits )
|
||||
{
|
||||
sMostHits = gpTileCache[ cnt ].sHits;
|
||||
ubLowestIndex = cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bump off lowest index
|
||||
@@ -209,7 +209,7 @@ INT32 GetCachedTile( const STR8 cFilename )
|
||||
// ATE: Add z-strip info
|
||||
if ( gpTileCache[ cnt ].sStructRefID != -1 )
|
||||
{
|
||||
AddZStripInfoToVObject( gpTileCache[ cnt ].pImagery->vo, gpTileCacheStructInfo[ gpTileCache[ cnt ].sStructRefID ].pStructureFileRef, TRUE, 0 );
|
||||
AddZStripInfoToVObject( gpTileCache[ cnt ].pImagery->vo, gpTileCacheStructInfo[ gpTileCache[ cnt ].sStructRefID ].pStructureFileRef, TRUE, 0 );
|
||||
}
|
||||
|
||||
if ( gpTileCache[ cnt ].pImagery->pAuxData != NULL )
|
||||
@@ -247,17 +247,17 @@ BOOLEAN RemoveCachedTile( INT32 iCachedTile )
|
||||
{
|
||||
if ( cnt == (UINT32)iCachedTile )
|
||||
{
|
||||
// Found surface, decrement hits
|
||||
gpTileCache[ cnt ].sHits--;
|
||||
// Found surface, decrement hits
|
||||
gpTileCache[ cnt ].sHits--;
|
||||
|
||||
// Are we at zero?
|
||||
if ( gpTileCache[ cnt ].sHits == 0 )
|
||||
{
|
||||
// Are we at zero?
|
||||
if ( gpTileCache[ cnt ].sHits == 0 )
|
||||
{
|
||||
DeleteTileSurface( gpTileCache[ cnt ].pImagery );
|
||||
gpTileCache[ cnt ].pImagery = NULL;
|
||||
gpTileCache[ cnt ].sStructRefID = -1;
|
||||
return( TRUE );;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,7 +315,7 @@ STRUCTURE_FILE_REF *GetCachedTileStructureRefFromFilename( const STR8 cFilename
|
||||
|
||||
|
||||
void CheckForAndAddTileCacheStructInfo( LEVELNODE *pNode, INT16 sGridNo, UINT16 usIndex, UINT16 usSubIndex )
|
||||
{
|
||||
{
|
||||
STRUCTURE_FILE_REF *pStructureFileRef;
|
||||
|
||||
pStructureFileRef = GetCachedTileStructureRef( usIndex );
|
||||
@@ -323,22 +323,22 @@ void CheckForAndAddTileCacheStructInfo( LEVELNODE *pNode, INT16 sGridNo, UINT16
|
||||
if ( pStructureFileRef != NULL)
|
||||
{
|
||||
if ( !AddStructureToWorld( sGridNo, 0, &( pStructureFileRef->pDBStructureRef[ usSubIndex ] ), pNode ) )
|
||||
{
|
||||
if ( giDefaultStructIndex != -1 )
|
||||
{
|
||||
pStructureFileRef = gpTileCacheStructInfo[ giDefaultStructIndex ].pStructureFileRef;
|
||||
{
|
||||
if ( giDefaultStructIndex != -1 )
|
||||
{
|
||||
pStructureFileRef = gpTileCacheStructInfo[ giDefaultStructIndex ].pStructureFileRef;
|
||||
|
||||
if ( pStructureFileRef != NULL)
|
||||
{
|
||||
AddStructureToWorld( sGridNo, 0, &( pStructureFileRef->pDBStructureRef[ usSubIndex ] ), pNode );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( pStructureFileRef != NULL)
|
||||
{
|
||||
AddStructureToWorld( sGridNo, 0, &( pStructureFileRef->pDBStructureRef[ usSubIndex ] ), pNode );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CheckForAndDeleteTileCacheStructInfo( LEVELNODE *pNode, UINT16 usIndex )
|
||||
{
|
||||
{
|
||||
STRUCTURE_FILE_REF *pStructureFileRef;
|
||||
|
||||
if ( usIndex >= TILE_CACHE_START_INDEX )
|
||||
@@ -380,3 +380,4 @@ void GetRootName( STR8 pDestStr, const STR8 pSrcStr )
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user