Improved code to avoid dangerous locations.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8756 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-02-16 14:08:47 +00:00
parent 8e9f9cb8a1
commit 0330e6c1a8
5 changed files with 227 additions and 114 deletions
+53
View File
@@ -1478,6 +1478,59 @@ BOOLEAN RemoveStruct( INT32 iMapIndex, UINT16 usIndex )
return( FALSE );
}
BOOLEAN FindStruct(INT32 sSpot, INT8 bLevel, UINT16 usIndex)
{
if (TileIsOutOfBounds(sSpot))
return FALSE;
LEVELNODE *pStruct = NULL;
LEVELNODE *pOldStruct = NULL;
if (bLevel == 0)
{
pStruct = gpWorldLevelData[sSpot].pStructHead;
}
else
{
pStruct = gpWorldLevelData[sSpot].pOnRoofHead;
}
// Look through all structs
while (pStruct != NULL)
{
if (pStruct->usIndex == usIndex)
{
return(TRUE);
}
pOldStruct = pStruct;
pStruct = pStruct->pNext;
}
return FALSE;
}
BOOLEAN FindStructFlag(INT32 sSpot, INT8 bLevel, UINT32 uiFlag)
{
if (bLevel > 0)
return FALSE;
if (TileIsOutOfBounds(sSpot))
return FALSE;
STRUCTURE * pStructure;
pStructure = FindStructure(sSpot, uiFlag);
if (pStructure)
{
return TRUE;
}
return FALSE;
}
// same as RemoveStruct(...), except that this focuses on .pOnRoofHead instead of .pStructHead
BOOLEAN RemoveOnRoofStruct( INT32 iMapIndex, UINT16 usIndex )
{