void PasteSmartBrokenWall( INT32 iMapIndex ) { UINT16 usNewWallIndex; LEVELNODE *pWall; UINT32 uiTileType; UINT16 usWallType; UINT16 usIndex; UINT16 usWallOrientation; pWall = GetVerticalWall( iMapIndex ); if( pWall ) { GetTileType( pWall->usIndex, &uiTileType ); usWallType = (UINT16)uiTileType; if( uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR ) { usWallType = SearchForWallType( iMapIndex ); } GetWallOrientation( pWall->usIndex, &usWallOrientation ); usIndex = CalcSmartBrokenWallIndex( usWallOrientation ); if( usIndex == 0xffff ) { AddToUndoList( iMapIndex ); RemoveStruct( iMapIndex, pWall->usIndex ); } else { AddToUndoList( iMapIndex ); GetTileIndexFromTypeSubIndex( usWallType, usIndex, &usNewWallIndex ); ReplaceStructIndex( iMapIndex, pWall->usIndex, usNewWallIndex ); } } pWall = GetHorizontalWall( iMapIndex ); if( pWall ) { GetTileType( pWall->usIndex, &uiTileType ); usWallType = (UINT16)uiTileType; if( uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR ) { //We want to be able to replace doors with a window, however, the doors do not //contain the wall type, so we have to search for the nearest wall to extract it. usWallType = SearchForWallType( iMapIndex ); } GetWallOrientation( pWall->usIndex, &usWallOrientation ); usIndex = CalcSmartBrokenWallIndex( usWallOrientation ); if( usIndex == 0xffff ) { AddToUndoList( iMapIndex ); RemoveStruct( iMapIndex, pWall->usIndex ); } else { AddToUndoList( iMapIndex ); GetTileIndexFromTypeSubIndex( usWallType, usIndex, &usNewWallIndex ); ReplaceStructIndex( iMapIndex, pWall->usIndex, usNewWallIndex ); } //Calculate the new graphic for the window type selected. } }
void PasteSmartDoor( INT32 iMapIndex ) { LEVELNODE *pWall = NULL; UINT16 usTileIndex; UINT16 usDoorType; UINT16 usIndex; UINT16 usWallOrientation; if( pWall = GetVerticalWall( iMapIndex ) ) { GetWallOrientation( pWall->usIndex, &usWallOrientation ); usIndex = CalcSmartDoorIndex( usWallOrientation ); usDoorType = CalcSmartDoorType(); AddToUndoList( iMapIndex ); GetTileIndexFromTypeSubIndex( usDoorType, usIndex, &usTileIndex ); ReplaceStructIndex( iMapIndex, pWall->usIndex, usTileIndex ); } if( pWall = GetHorizontalWall( iMapIndex ) ) { GetWallOrientation( pWall->usIndex, &usWallOrientation ); usIndex = CalcSmartDoorIndex( usWallOrientation ); usDoorType = CalcSmartDoorType(); AddToUndoList( iMapIndex ); GetTileIndexFromTypeSubIndex( usDoorType, usIndex, &usTileIndex ); ReplaceStructIndex( iMapIndex, pWall->usIndex, usTileIndex ); } }
//Specialized function that will delete only the TOP_RIGHT oriented wall in the gridno to the left //and the TOP_LEFT oriented wall in the gridno up one as well as the other building information at this //gridno. void EraseFloorOwnedBuildingPieces( UINT32 iMapIndex ) { LEVELNODE *pStruct = NULL; UINT32 uiTileType; UINT16 usWallOrientation; if( !gfBasement && !FloorAtGridNo( iMapIndex ) ) { //We don't have ownership issues if there isn't a floor here. return; } EraseBuilding( iMapIndex ); //FIRST, SEARCH AND DESTROY FOR A LEFT NEIGHBORING TILE WITH A TOP_RIGHT ORIENTED WALL pStruct = gpWorldLevelData[ iMapIndex - 1 ].pStructHead; while( pStruct != NULL ) { if ( pStruct->usIndex != NO_TILE ) { GetTileType( pStruct->usIndex, &uiTileType ); if ( uiTileType >= FIRSTWALL && uiTileType <= LASTWALL || uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR ) { GetWallOrientation( pStruct->usIndex, &usWallOrientation ); if( usWallOrientation == INSIDE_TOP_RIGHT || usWallOrientation == OUTSIDE_TOP_RIGHT ) { AddToUndoList( iMapIndex - 1 ); RemoveStruct( iMapIndex - 1, pStruct->usIndex ); RemoveAllShadowsOfTypeRange( iMapIndex - 1, FIRSTWALL, LASTWALL ); break; //otherwise, it'll crash because pStruct is toast. } } } pStruct = pStruct->pNext; } //FINALLY, SEARCH AND DESTROY FOR A TOP NEIGHBORING TILE WITH A TOP_LEFT ORIENTED WALL pStruct = gpWorldLevelData[ iMapIndex - WORLD_COLS ].pStructHead; while( pStruct != NULL ) { if ( pStruct->usIndex != NO_TILE ) { GetTileType( pStruct->usIndex, &uiTileType ); if ( uiTileType >= FIRSTWALL && uiTileType <= LASTWALL || uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR ) { GetWallOrientation( pStruct->usIndex, &usWallOrientation ); if( usWallOrientation == INSIDE_TOP_LEFT || usWallOrientation == OUTSIDE_TOP_LEFT ) { AddToUndoList( iMapIndex - WORLD_COLS ); RemoveStruct( iMapIndex - WORLD_COLS , pStruct->usIndex ); RemoveAllShadowsOfTypeRange( iMapIndex - WORLD_COLS, FIRSTWALL, LASTWALL ); break; //otherwise, it'll crash because pStruct is toast. } } } pStruct = pStruct->pNext; } }
BOOLEAN CalcBrokenWallInfoUsingSmartMethod( INT32 iMapIndex, UINT16 *pusWallType, UINT16 *pusIndex ) { LEVELNODE *pWall = NULL; UINT32 uiTileType; UINT16 usWallOrientation; if( gubBrokenWallUIValue == 2 ) //the hole in the wall { *pusWallType = 0xffff; *pusIndex = 0xffff; //but it won't draw it. return TRUE; } pWall = GetVerticalWall( iMapIndex ); if( pWall ) { GetTileType( pWall->usIndex, &uiTileType ); *pusWallType = (UINT16)uiTileType; if( uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR ) { //We want to be able to replace doors with a walltype, however, the doors do not //contain the wall type, so we have to search for the nearest wall to extract it. *pusWallType = SearchForWallType( iMapIndex ); } GetWallOrientation( pWall->usIndex, &usWallOrientation ); *pusIndex = CalcSmartBrokenWallIndex( usWallOrientation ) - 1; return TRUE; } pWall = GetHorizontalWall( iMapIndex ); if( pWall ) { GetTileType( pWall->usIndex, &uiTileType ); *pusWallType = (UINT16)uiTileType; if( uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR ) { //We want to be able to replace doors with a walltype, however, the doors do not //contain the wall type, so we have to search for the nearest wall to extract it. *pusWallType = SearchForWallType( iMapIndex ); } GetWallOrientation( pWall->usIndex, &usWallOrientation ); *pusIndex = CalcSmartBrokenWallIndex( usWallOrientation ) - 1; return TRUE; } return FALSE; }
BOOLEAN CalcDoorInfoUsingSmartMethod( INT32 iMapIndex, UINT16 *pusDoorType, UINT16 *pusIndex ) { LEVELNODE *pWall = NULL; UINT16 usWallOrientation; pWall = GetVerticalWall( iMapIndex ); if( pWall ) { GetWallOrientation( pWall->usIndex, &usWallOrientation ); *pusIndex = CalcSmartDoorIndex( usWallOrientation ) - 1; *pusDoorType = CalcSmartDoorType(); return TRUE; } pWall = GetHorizontalWall( iMapIndex ); if( pWall ) { GetWallOrientation( pWall->usIndex, &usWallOrientation ); *pusIndex = CalcSmartDoorIndex( usWallOrientation ) - 1; *pusDoorType = CalcSmartDoorType(); return TRUE; } return FALSE; }