- Bugfix: Finding and swapping shadow tiles when swapping a structure tile (by Realist)

o example: When cutting a fence tile, the proper shadow tile was not swapped and correctly updated

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5465 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2012-08-13 08:51:48 +00:00
parent 3cf0e5210c
commit ef981b5342
+22
View File
@@ -3599,6 +3599,8 @@ LEVELNODE * FindLevelNodeBasedOnStructure( INT32 sGridNo, STRUCTURE * pStructure
return( NULL );
}
// WANNE: Old JA2 vanilla version to find the shadow tile
/*
LEVELNODE * FindShadow( INT32 sGridNo, UINT16 usStructIndex )
{
LEVELNODE * pLevelNode;
@@ -3621,7 +3623,27 @@ LEVELNODE * FindShadow( INT32 sGridNo, UINT16 usStructIndex )
pLevelNode = pLevelNode->pNext;
}
return( pLevelNode );
}
*/
// WANNE: Improved v1.13 version to find the shadow tile. (by Realist)
// This should fix the bug, finding and swapping shadows when swapping structures
// e.g: When curring a fence tile, the shadow tile was not swapped. Now it should be fixed.
LEVELNODE* FindShadow(INT32 sGridNo, UINT16 usStructIndex)
{
TILE_ELEMENT const * const te = &gTileDatabase[usStructIndex];
if (te->uiFlags & HAS_SHADOW_BUDDY && te->sBuddyNum != -1)
{
LEVELNODE* pLevelNode;
for (pLevelNode = gpWorldLevelData[sGridNo].pShadowHead; pLevelNode != NULL; pLevelNode = pLevelNode->pNext)
{
if (pLevelNode->usIndex == te->sBuddyNum)
{
return pLevelNode;
}
}
}
return NULL;
}