MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / DrawCell

Function DrawCell

Source/engine/render/scrollrt.cpp:536–641  ·  view source on GitHub ↗

* @brief Render a cell * @param out Target buffer * @param tilePosition dPiece coordinates * @param targetBufferPosition Target buffer coordinates */

Source from the content-addressed store, hash-verified

534 * @param targetBufferPosition Target buffer coordinates
535 */
536void 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.

Callers 1

DrawDungeonFunction · 0.85

Calls 7

GetPauseTRNFunction · 0.85
TileHasAnyFunction · 0.85
RenderTileFunction · 0.85
IsPositionInPathMethod · 0.80
hasValueMethod · 0.80
dataMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected