From ef981b5342b90d221e5e46c87f8c2ffae817bf12 Mon Sep 17 00:00:00 2001 From: Wanne Date: Mon, 13 Aug 2012 08:51:48 +0000 Subject: [PATCH] - 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 --- TileEngine/worldman.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/TileEngine/worldman.cpp b/TileEngine/worldman.cpp index b4e939c9..dfc9b7ed 100644 --- a/TileEngine/worldman.cpp +++ b/TileEngine/worldman.cpp @@ -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; }