From e5e26a3bfcff1608b9002d92c6fabc6db4abbddc Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Tue, 10 Nov 2026 22:45:52 +0000 Subject: [PATCH] Decompile 4 functions in Source/Contents/Effects/Particle.cpp, Source/Resource/EZeffectResource.cpp, ... Batch #16509 by eAthena: 0 byte-identical, 4 confirmed by peer review. - fn_07898 EZeffectClip::Texture: logic confirmed by peer review - fn_18825 CEZ2STRParticle::RenderBillboard: logic confirmed by peer review - fn_18826 CEZ2STRParticle::RenderScreen: logic confirmed by peer review - fn_18827 CEZ2STRParticle::RenderGround: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, Yommy, br4yan Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/Effects/Particle.cpp | 30 ++++++++++++++-------------- Source/Resource/EZeffectResource.cpp | 28 +++++++++++++------------- Source/Resource/EZeffectResource.h | 3 ++- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Source/Contents/Effects/Particle.cpp b/Source/Contents/Effects/Particle.cpp index cab7e8876..66a15c379 100644 --- a/Source/Contents/Effects/Particle.cpp +++ b/Source/Contents/Effects/Particle.cpp @@ -35,15 +35,15 @@ static __forceinline void SetClipCorners(RenderVertex* vertices, const EZeffectT vertices[1].x = transform.ax[0]; vertices[2].x = transform.ax[2]; vertices[3].x = transform.ax[1]; - vertices[1].u = vertices[0].u = transform.u; - vertices[3].u = vertices[2].u = transform.us + transform.u; + vertices[0].u = vertices[1].u = transform.u; + vertices[2].u = vertices[3].u = transform.us + transform.u; } else { vertices[0].x = transform.ax[2]; vertices[1].x = transform.ax[1]; vertices[2].x = transform.ax[3]; vertices[3].x = transform.ax[0]; - vertices[1].u = vertices[0].u = transform.us + transform.u; - vertices[3].u = vertices[2].u = transform.u; + vertices[0].u = vertices[1].u = transform.us + transform.u; + vertices[2].u = vertices[3].u = transform.u; } if (transform.ay[2] > transform.ay[1]) { @@ -51,32 +51,32 @@ static __forceinline void SetClipCorners(RenderVertex* vertices, const EZeffectT vertices[1].y = transform.ay[0]; vertices[2].y = transform.ay[2]; vertices[3].y = transform.ay[1]; - vertices[3].v = vertices[1].v = transform.v; - vertices[2].v = vertices[0].v = transform.vs + transform.v; + vertices[1].v = vertices[3].v = transform.v; + vertices[0].v = vertices[2].v = transform.vs + transform.v; } else { vertices[0].y = transform.ay[0]; vertices[1].y = transform.ay[3]; vertices[2].y = transform.ay[1]; vertices[3].y = transform.ay[2]; - vertices[2].v = vertices[0].v = transform.v; - vertices[3].v = vertices[1].v = transform.vs + transform.v; + vertices[0].v = vertices[2].v = transform.v; + vertices[1].v = vertices[3].v = transform.vs + transform.v; } } // INLINED static __forceinline std::uint32_t ClipColor(const EZeffectTransform& transform, float alpha) { - return ((((static_cast(transform.crA * alpha) << 8) + static_cast(transform.crR)) << 8) + static_cast(transform.crG)) << 8 | + return (((((static_cast(transform.crA * alpha) << 8) + static_cast(transform.crR)) << 8) + static_cast(transform.crG)) << 8) + static_cast(transform.crB); } // INLINED -static __forceinline CTexture* ClipTexture(EZeffectClip* clip, const EZeffectTransform& transform, const std::string& prefix) { +static __forceinline CTexture* ClipTexture(EZeffectClip* clip, const EZeffectTransform& transform, const CEZ2STRParticle& particle) { const int frame = static_cast(transform.aniframe); - if (prefix.size() == 0) { + if (particle.m_texturePrefix.size() == 0) { return clip->Texture(frame < 0 ? 0 : frame); } - return clip->Texture(frame < 0 ? 0 : frame, prefix.c_str()); + return clip->Texture(frame < 0 ? 0 : frame, particle.m_texturePrefix); } // OFFSET: 0x00B3C440 @@ -468,7 +468,7 @@ void CEZ2STRParticle::RenderBillboard(EZeffectClip* clip, EZeffectTransform* tra RenderVertex* vertices = primitive->vertices; SetClipCorners(vertices, *transform); - CTexture* texture = ClipTexture(clip, *transform, this->m_texturePrefix); + CTexture* texture = ClipTexture(clip, *transform, *this); const float scaleU = static_cast(texture->ImageWidth()) / static_cast(texture->TextureWidth()); const float scaleV = static_cast(texture->ImageHeight()) / static_cast(texture->TextureHeight()); @@ -600,7 +600,7 @@ void CEZ2STRParticle::RenderScreen(EZeffectClip* clip, EZeffectTransform* transf vertices[i].y -= this->m_screenShiftY; } - CTexture* texture = ClipTexture(clip, *transform, this->m_texturePrefix); + CTexture* texture = ClipTexture(clip, *transform, *this); const float depth = static_cast(index) * 1e-05f; const float scaleU = static_cast(texture->ImageWidth()) / static_cast(texture->TextureWidth()); const float scaleV = static_cast(texture->ImageHeight()) / static_cast(texture->TextureHeight()); @@ -628,7 +628,7 @@ void CEZ2STRParticle::RenderGround(EZeffectClip* clip, EZeffectTransform* transf RenderVertex* vertices = primitive->vertices; SetClipCorners(vertices, *transform); - CTexture* texture = ClipTexture(clip, *transform, this->m_texturePrefix); + CTexture* texture = ClipTexture(clip, *transform, *this); const float scaleU = static_cast(texture->ImageWidth()) / static_cast(texture->TextureWidth()); const float scaleV = static_cast(texture->ImageHeight()) / static_cast(texture->TextureHeight()); diff --git a/Source/Resource/EZeffectResource.cpp b/Source/Resource/EZeffectResource.cpp index 105eb8971..7af94a19e 100644 --- a/Source/Resource/EZeffectResource.cpp +++ b/Source/Resource/EZeffectResource.cpp @@ -121,26 +121,26 @@ CTexture* EZeffectClip::Texture(int index) { // OFFSET: 0x0074D9A0 // FUNCTION: fn_07898 -CTexture* EZeffectClip::Texture(int index, const char* prefix) { - if (index >= this->textureCount) { - return g_texMgr.Default(); - } +CTexture* EZeffectClip::Texture(int index, const std::string& prefix) { + if (index < this->textureCount) { + if (!this->textures[index]) { + std::string path = std::format("effect\\{}{}", prefix, this->names[index]); - if (!this->textures[index]) { - std::string path = std::format("effect\\{}{}", prefix, this->names[index]); + if (path.find_last_of('.') == std::string::npos) { + path.append(".bmp", 4); + } - if (path.find_last_of('.') == std::string::npos) { - path.append(".bmp", 4); + this->textures[index] = g_texMgr.Load(path.c_str(), 1, false, true, false); + + if (this->textures[index]) { + this->textures[index]->Retain(); + } } - this->textures[index] = g_texMgr.Load(path.c_str(), 1, false, true, false); - - if (this->textures[index]) { - this->textures[index]->Retain(); - } + return this->textures[index]; } - return this->textures[index]; + return g_texMgr.Default(); } // INLINED diff --git a/Source/Resource/EZeffectResource.h b/Source/Resource/EZeffectResource.h index eea1f1763..3d4470927 100644 --- a/Source/Resource/EZeffectResource.h +++ b/Source/Resource/EZeffectResource.h @@ -6,6 +6,7 @@ #include #include +#include class CTexture; @@ -45,7 +46,7 @@ struct EZeffectClip { EZeffectClip(); ~EZeffectClip(); CTexture* Texture(int index); - CTexture* Texture(int index, const char* prefix); + CTexture* Texture(int index, const std::string& prefix); /* 0000 */ int textureCount; /* 0004 */ int textureState;