From b08965ec9c583d5ff518010587bb5ac36c464aff Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Tue, 10 Nov 2026 17:39:08 +0000 Subject: [PATCH] Decompile fn_16922 (UIWindow::AddSpriteCellOverlay) Batch #16229 by youko: 0 byte-identical, 1 confirmed by peer review. - fn_16922 UIWindow::AddSpriteCellOverlay: logic confirmed by peer review Peer-reviewed-by: Yommy, gordaoprogramas, bgamez23 Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/WindowSprite.cpp | 105 +++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 40 deletions(-) diff --git a/Source/UI/WindowSprite.cpp b/Source/UI/WindowSprite.cpp index 8f679d0ed..93ed8d7dd 100644 --- a/Source/UI/WindowSprite.cpp +++ b/Source/UI/WindowSprite.cpp @@ -26,8 +26,7 @@ void UIWindow::AddSpriteCellOverlay( float top = static_cast(cell->y) * scale * cell->scaleY; float bottom = static_cast((static_cast(image->doubleHeight) + 1) * image->height - 1 + cell->y) * scale * cell->scaleY * extentScale; - record.u0 = 0.0f; - record.v0 = 0.0f; + record.u0 = record.v0 = 0.0f; CTexture* texture; if (cell->imageType == 0) { texture = g_renderer->atlas.Find(image, palette, record); @@ -41,66 +40,92 @@ void UIWindow::AddSpriteCellOverlay( } primitive->texture = texture; - RenderVertex* vertices = primitive->quad; + float x0; + float y0; + float x1; + float y1; + float x2; + float y2; + float x3; + float y3; if (angle != 0.0f) { const float cosine = ClientCosine(static_cast(angle)); const float sine = ClientSine(static_cast(angle)); - const int farX = (static_cast(image->doubleWidth) + 1) * image->width + cell->x; - const float startX = static_cast((cell->mirrored & 1) ? farX : cell->x) * scale + static_cast(x); - const float endX = static_cast((cell->mirrored & 1) ? cell->x : farX) * scale + static_cast(x) + 1.0f; const float upper = static_cast(cell->y) * scale + static_cast(y); const float lower = static_cast((static_cast(image->doubleHeight) + 1) * image->height + cell->y) * scale + static_cast(y) + 1.0f; + const int width = image->width; + float startX; + float endX; + if (cell->mirrored & 1) { + startX = static_cast((static_cast(image->doubleWidth) + 1) * width + cell->x) * scale + static_cast(x); + endX = static_cast(cell->x) * scale + static_cast(x) + 1.0f; + } else { + startX = static_cast(cell->x) * scale + static_cast(x); + endX = static_cast((static_cast(image->doubleWidth) + 1) * width + cell->x) * scale + static_cast(x) + 1.0f; + } const float halfWidth = (endX - startX) * 0.5f; const float halfHeight = (lower - upper) * 0.5f; const float centerX = startX + halfWidth; const float centerY = upper + halfHeight; - const float minX = -halfWidth; - const float minY = -halfHeight; - - vertices[0].x = minX * cosine - minY * sine + centerX + 0.5f; - vertices[0].y = minY * cosine + minX * sine + centerY + 0.5f; - vertices[1].x = halfWidth * cosine - minY * sine + centerX + 0.5f; - vertices[1].y = minY * cosine + halfWidth * sine + centerY + 0.5f; - vertices[2].x = minX * cosine - halfHeight * sine + centerX + 0.5f; - vertices[2].y = halfHeight * cosine + minX * sine + centerY + 0.5f; - vertices[3].x = halfWidth * cosine - halfHeight * sine + centerX + 0.5f; - vertices[3].y = halfHeight * cosine + halfWidth * sine + centerY + 0.5f; + x0 = (-halfWidth) * cosine - (-halfHeight) * sine + centerX; + y0 = (-halfWidth) * sine + (-halfHeight) * cosine + centerY; + x1 = halfWidth * cosine - (-halfHeight) * sine + centerX; + y1 = halfWidth * sine + (-halfHeight) * cosine + centerY; + x2 = (-halfWidth) * cosine - halfHeight * sine + centerX; + y2 = (-halfWidth) * sine + halfHeight * cosine + centerY; + x3 = halfWidth * cosine - halfHeight * sine + centerX; + y3 = halfWidth * sine + halfHeight * cosine + centerY; } else { - if (cell->mirrored & 1) { - const float swap = left; - left = right; - right = swap; + if (!(cell->mirrored & 1)) { + x0 = left; + x1 = right; + } else { + x0 = right; + x1 = left; } - left += static_cast(x); - right += static_cast(x); - top += static_cast(y); - bottom += static_cast(y); - - vertices[0].x = left + 0.5f; - vertices[0].y = top + 0.5f; - vertices[1].x = right + 0.5f; - vertices[1].y = top + 0.5f; - vertices[2].x = left + 0.5f; - vertices[2].y = bottom + 0.5f; - vertices[3].x = right + 0.5f; - vertices[3].y = bottom + 0.5f; + x0 += static_cast(x); + x1 += static_cast(x); + y0 = static_cast(y) + top; + y2 = static_cast(y) + bottom; + y1 = y0; + x2 = x0; + x3 = x1; + y3 = y2; } - for (RenderVertex& vertex : primitive->quad) { - vertex.z = 0.000001f; - vertex.rhw = 0.999999f; - vertex.diffuse = color; - } + RenderVertex* vertices = primitive->quad; + vertices[0].x = x0 + 0.5f; + vertices[0].y = y0 + 0.5f; + vertices[1].x = x1 + 0.5f; + vertices[1].y = y1 + 0.5f; + vertices[2].x = x2 + 0.5f; + vertices[2].y = y2 + 0.5f; + vertices[3].x = x3 + 0.5f; + vertices[3].y = y3 + 0.5f; + + vertices[0].z = 0.000001f; + vertices[0].rhw = 0.999999f; vertices[0].u = record.u0; + vertices[0].diffuse = color; vertices[0].v = record.v0; + vertices[1].z = 0.000001f; + vertices[1].rhw = 0.999999f; vertices[1].u = record.u1; + vertices[1].diffuse = color; vertices[1].v = record.v0; + vertices[2].z = 0.000001f; + vertices[2].rhw = 0.999999f; vertices[2].u = record.u0; + vertices[2].diffuse = color; vertices[2].v = record.v1; + vertices[3].z = 0.000001f; + vertices[3].rhw = 0.999999f; vertices[3].u = record.u1; + vertices[3].diffuse = color; vertices[3].v = record.v1; - this->m_overlayPrimitives.push_back(primitive); + std::vector& overlays = this->m_overlayPrimitives; + overlays.push_back(primitive); } // OFFSET: 0x00A7A5C0