mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Add a function for finding last matching structure
This commit is contained in:
@@ -1428,6 +1428,7 @@ STRUCTURE * SwapStructureForPartnerForcingGraphicalChange( INT32 sGridNo, STRUCT
|
||||
}
|
||||
#endif
|
||||
|
||||
// Finds the first structure with matching flag
|
||||
STRUCTURE * FindStructure( INT32 sGridNo, UINT32 fFlags )
|
||||
{
|
||||
// finds a structure that matches any of the given flags
|
||||
@@ -1451,6 +1452,33 @@ STRUCTURE * FindStructure( INT32 sGridNo, UINT32 fFlags )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
// Finds the last structure with matching flag
|
||||
STRUCTURE* FindLastStructure(INT32 sGridNo, UINT32 fFlags)
|
||||
{
|
||||
// finds a structure that matches any of the given flags
|
||||
STRUCTURE* pCurrent;
|
||||
STRUCTURE* pLastMatch = nullptr;
|
||||
|
||||
//bug fix for win98 crash when traveling between sectors
|
||||
if ( TileIsOutOfBounds(sGridNo) )
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
pCurrent = gpWorldLevelData[sGridNo].pStructureHead;
|
||||
while ( pCurrent != NULL )
|
||||
{
|
||||
if ( (pCurrent->fFlags & fFlags) != 0 )
|
||||
{
|
||||
pLastMatch = pCurrent;
|
||||
//return(pCurrent);
|
||||
}
|
||||
pCurrent = pCurrent->pNext;
|
||||
}
|
||||
|
||||
return(pLastMatch);
|
||||
}
|
||||
|
||||
STRUCTURE * FindNextStructure( STRUCTURE * pStructure, UINT32 fFlags )
|
||||
{
|
||||
STRUCTURE * pCurrent;
|
||||
|
||||
@@ -47,6 +47,7 @@ BOOLEAN DeleteStructureFromWorld( STRUCTURE * pStructure );
|
||||
// functions to find a structure in a location
|
||||
//
|
||||
STRUCTURE * FindStructure( INT32 sGridNo, UINT32 fFlags );
|
||||
STRUCTURE* FindLastStructure(INT32 sGridNo, UINT32 fFlags);
|
||||
STRUCTURE * FindNextStructure( STRUCTURE * pStructure, UINT32 fFlags );
|
||||
STRUCTURE * FindStructureByID( INT32 sGridNo, UINT16 usStructureID );
|
||||
STRUCTURE * FindBaseStructure( STRUCTURE * pStructure );
|
||||
|
||||
Reference in New Issue
Block a user