From 0beda54c8d03274adc7dc0111e09bfc7da541b07 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 26 Jul 2015 09:50:16 +0000 Subject: [PATCH] Fix: constructing/deconstructing a fortifiaction only worked if the tileset was part of the additonal tileset, not if it was a part of GENERIC 1 git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7938 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Handle Items.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 9fadd5e7..05f9b1a3 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -6878,7 +6878,8 @@ BOOLEAN BuildFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *pO // search wether structure exists in the current tilesets. If not, well, too bad for (UINT32 uiType = 0; uiType < giNumberOfTileTypes; ++uiType) { - if( gTilesets[ giCurrentTilesetID ].TileSurfaceFilenames[ uiType ][0] ) + // if tileset is from the current tileset, check that + if ( gTilesets[ giCurrentTilesetID ].TileSurfaceFilenames[ uiType ][0] ) { if ( structureconstructindex >= 0 ) { @@ -6889,6 +6890,15 @@ BOOLEAN BuildFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *pO } } } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[uiType][0] ) + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[uiType], gStructureConstruct[structureconstructindex].szTileSetName, 10 ) ) + { + usUseObjIndex = uiType; + break; + } + } } if ( !usUseObjIndex ) @@ -6981,8 +6991,21 @@ BOOLEAN RemoveFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *p // item we have in our hand must be one with which we can deconstruct this if ( pObj->usItem == gStructureDeconstruct[i].usDeconstructItem ) { - // Check if we are a sandbag or a earth pile - if ( !_strnicmp( gTilesets[ giCurrentTilesetID ].TileSurfaceFilenames[ uiTileType ], gStructureDeconstruct[i].szTileSetName, 11) ) + // if tileset is from the current tileset, check that + BOOLEAN found = FALSE; + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[uiTileType][0] ) + { + if ( !_strnicmp( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[uiTileType], gStructureDeconstruct[i].szTileSetName, 11 ) ) + found = TRUE; + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[uiTileType][0] ) + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[uiTileType], gStructureDeconstruct[i].szTileSetName, 11 ) ) + found = TRUE; + } + + if ( found ) { // we have to check wether this specific structure can be removed. Just checking the tileset name won't be enough. // For example, we could have a set consisting of crates and piles of earth, which we want to remove via applying a shovel on it.