diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 36d44e500..00600d848 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -6878,6 +6878,32 @@ void SoldierStealItemFromSoldier( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, SetCustomizableTimerCallbackAndDelay( 1000, CheckForPickedOwnership, TRUE ); } +INT16 GetTileSetTindexToTileSetName( INT32 asTileSetId, std::string aTileSetName ) +{ + // search wether structure exists in the current tilesets. If not, well, too bad + for ( INT16 iType = 0; iType < giNumberOfTileTypes; ++iType ) + { + // if tileset is from the current tileset, check that + if ( gTilesets[asTileSetId].TileSurfaceFilenames[iType][0] ) + { + if ( !strcmp( aTileSetName.c_str( ), gTilesets[asTileSetId].TileSurfaceFilenames[iType] ) ) + { + return iType; + } + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[iType][0] ) + { + if ( !strcmp( aTileSetName.c_str( ), gTilesets[0].TileSurfaceFilenames[iType] ) ) + { + return iType; + } + } + } + + return -1; +} + // can we construct a structure with this item? BOOLEAN IsStructureConstructItem(UINT16 usItem, INT32 sGridNo, SOLDIERTYPE* pSoldier) { diff --git a/Tactical/Handle Items.h b/Tactical/Handle Items.h index 95bf10838..885e885cb 100644 --- a/Tactical/Handle Items.h +++ b/Tactical/Handle Items.h @@ -207,7 +207,8 @@ UINT8 StealItems(SOLDIERTYPE* pSoldier,SOLDIERTYPE* pOpponent, UINT8* ubIndexRet BOOLEAN MarblesExistAtLocation( INT32 sGridNo, UINT8 ubLevel, INT32 * piItemIndex ); -// Flugente: build an deconstruct structures +// Flugente: build and deconstruct structures +INT16 GetTileSetTindexToTileSetName( INT32 asTileSetId, std::string aTileSetName ); BOOLEAN IsStructureConstructItem( UINT16 usItem, INT32 sGridNo, SOLDIERTYPE* pSoldier ); // can we construct a structure with this item? BOOLEAN IsStructureDeconstructItem( UINT16 usItem, INT32 sGridNo, SOLDIERTYPE* pSoldier ); // can we remove a structure with this item? BOOLEAN BuildFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *pObj ); // build a structure, return true if sucessful