MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / IsSpriteInteractedWithPaletteSet

Function IsSpriteInteractedWithPaletteSet

src/openrct2/interface/Viewport.cpp:1544–1604  ·  view source on GitHub ↗

* rct2: 0x00679074 */

Source from the content-addressed store, hash-verified

1542 * rct2: 0x00679074
1543 */
1544 static bool IsSpriteInteractedWithPaletteSet(
1545 RenderTarget& rt, ImageId imageId, const ScreenCoordsXY& coords, const PaletteMap& paletteMap, const uint8_t imageType)
1546 {
1547 PROFILED_FUNCTION();
1548
1549 const G1Element* g1 = GfxGetG1Element(imageId);
1550 if (g1 == nullptr)
1551 {
1552 return false;
1553 }
1554
1555 ZoomLevel zoomLevel = rt.zoom_level;
1556 ScreenCoordsXY interactionPoint{ rt.WorldX(), rt.WorldY() };
1557 ScreenCoordsXY origin = coords;
1558
1559 if (rt.zoom_level > ZoomLevel{ 0 })
1560 {
1561 if (g1->flags.has(G1Flag::noZoomDraw))
1562 {
1563 return false;
1564 }
1565
1566 while (g1->flags.has(G1Flag::hasZoomSprite) && zoomLevel > ZoomLevel{ 0 })
1567 {
1568 imageId = imageId.WithIndex(imageId.GetIndex() - g1->zoomedOffset);
1569 g1 = GfxGetG1Element(imageId);
1570 if (g1 == nullptr || g1->flags.has(G1Flag::noZoomDraw))
1571 {
1572 return false;
1573 }
1574 zoomLevel = zoomLevel - 1;
1575 interactionPoint.x >>= 1;
1576 interactionPoint.y >>= 1;
1577 origin.x >>= 1;
1578 origin.y >>= 1;
1579 }
1580 }
1581
1582 origin.x += g1->xOffset;
1583 origin.y += g1->yOffset;
1584 interactionPoint -= origin;
1585
1586 if (interactionPoint.x < 0 || interactionPoint.y < 0 || interactionPoint.x >= g1->width
1587 || interactionPoint.y >= g1->height)
1588 {
1589 return false;
1590 }
1591
1592 if (g1->flags.has(G1Flag::hasRLECompression))
1593 {
1594 return IsPixelPresentRLE(g1->offset, interactionPoint.x, interactionPoint.y);
1595 }
1596
1597 if (!g1->flags.has(G1Flag::one))
1598 {
1599 return IsPixelPresentBMP(imageType, g1, interactionPoint.x, interactionPoint.y, paletteMap);
1600 }
1601

Callers 1

IsSpriteInteractedWithFunction · 0.85

Calls 9

GfxGetG1ElementFunction · 0.85
IsPixelPresentRLEFunction · 0.85
IsPixelPresentBMPFunction · 0.85
AssertFunction · 0.85
WorldXMethod · 0.80
WorldYMethod · 0.80
WithIndexMethod · 0.80
hasMethod · 0.65
GetIndexMethod · 0.45

Tested by

no test coverage detected