* @brief Render a cell * @param out Target buffer * @param tilePosition dPiece coordinates * @param targetBufferPosition Target buffer coordinates */
| 534 | * @param targetBufferPosition Target buffer coordinates |
| 535 | */ |
| 536 | void DrawCell(const Surface &out, Point tilePosition, Point targetBufferPosition) |
| 537 | { |
| 538 | const uint16_t levelPieceId = dPiece[tilePosition.x][tilePosition.y]; |
| 539 | const MICROS *pMap = &DPieceMicros[levelPieceId]; |
| 540 | |
| 541 | const uint8_t *tbl = LightTables[LightTableIndex].data(); |
| 542 | #ifdef _DEBUG |
| 543 | if (DebugPath && MyPlayer->IsPositionInPath(tilePosition)) |
| 544 | tbl = GetPauseTRN(); |
| 545 | #endif |
| 546 | |
| 547 | bool transparency = TileHasAny(levelPieceId, TileProperties::Transparent) && TransList[dTransVal[tilePosition.x][tilePosition.y]]; |
| 548 | #ifdef _DEBUG |
| 549 | if ((SDL_GetModState() & KMOD_ALT) != 0) |
| 550 | transparency = false; |
| 551 | #endif |
| 552 | const bool foliage = !TileHasAny(levelPieceId, TileProperties::Solid); |
| 553 | |
| 554 | const auto getFirstTileMaskLeft = [=](TileType tile) -> MaskType { |
| 555 | if (transparency) { |
| 556 | switch (tile) { |
| 557 | case TileType::LeftTrapezoid: |
| 558 | case TileType::TransparentSquare: |
| 559 | return TileHasAny(levelPieceId, TileProperties::TransparentLeft) |
| 560 | ? MaskType::Left |
| 561 | : MaskType::Solid; |
| 562 | case TileType::LeftTriangle: |
| 563 | return MaskType::Solid; |
| 564 | default: |
| 565 | return MaskType::Transparent; |
| 566 | } |
| 567 | } |
| 568 | if (foliage) |
| 569 | return MaskType::LeftFoliage; |
| 570 | return MaskType::Solid; |
| 571 | }; |
| 572 | |
| 573 | const auto getFirstTileMaskRight = [=](TileType tile) -> MaskType { |
| 574 | if (transparency) { |
| 575 | switch (tile) { |
| 576 | case TileType::RightTrapezoid: |
| 577 | case TileType::TransparentSquare: |
| 578 | return TileHasAny(levelPieceId, TileProperties::TransparentRight) |
| 579 | ? MaskType::Right |
| 580 | : MaskType::Solid; |
| 581 | case TileType::RightTriangle: |
| 582 | return MaskType::Solid; |
| 583 | default: |
| 584 | return MaskType::Transparent; |
| 585 | } |
| 586 | } |
| 587 | if (foliage) |
| 588 | return MaskType::RightFoliage; |
| 589 | return MaskType::Solid; |
| 590 | }; |
| 591 | |
| 592 | // The first micro tile may be rendered with a foliage mask. |
| 593 | // Only `TransparentSquare` tiles are rendered when `foliage` is true. |
no test coverage detected