rodecomp/Source/Contents/Sprites/SpriteRobeCommands.cpp
ragnarok-clanker bb4f6ae541 Confirm 2 functions in Source/Contents/Sprites/SpriteRobe.cpp, Source/Contents/Sprites/SpriteRobeCommands.cpp
Batch #18082 by eAthena: 0 byte-identical, 2 confirmed by peer review.

- fn_10104 CCharacterRender::RenderRobe: logic confirmed by peer review (already on main)
- fn_10105 CCharacterRender::RenderRobeCommands: logic confirmed by peer review (already on main)

Peer-reviewed-by: Yommy, KWDev, bibinir
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-12 09:01:31 +00:00

96 lines
3.6 KiB
C++

#include "Client/Mode/CGameMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Client/Session/Session.h"
#include "Contents/Actors/CharacterRender.h"
#include "Contents/Camera/Camera.h"
#include "Render/DeviceContext/DCSurface.h"
#include "Render/Primitives/RenderPrimitive.h"
#include "Render/Drawing/SpriteGeometry.h"
#include "Render/Primitives/SpriteQuad.h"
#include "Render/Textures/SpritePixels.h"
#include "Resource/ResourceMgr.h"
#include "Resource/Sprites/ActionResource.h"
#include "Resource/Sprites/SpriteResource.h"
#include <list>
#include <string>
#include <windows.h>
template __declspec(noinline) void std::list<CharacterRenderDrawItem>::push_back(const CharacterRenderDrawItem&);
struct CharacterRenderDrawItem {
int flags;
RenderCommand* command;
};
// OFFSET: 0x0080DF70
// FUNCTION: fn_10105
void CCharacterRender::RenderRobeCommands(
std::list<CharacterRenderDrawItem>& commands, bool drawOnTop, const void*, int& layer, const float* position, float x, float y, float scale,
float shift, float
) {
if (this->robe < 1 || this->isHelmRobe == 1 || (this->actionIndex >= 64 && this->actionIndex <= 71)
|| (this->bodyBlend == -1 && this->bodyCellX == -1 && this->bodyCellY == -1)) {
return;
}
if (this->DrawOnTop() == drawOnTop) {
std::string sprName = g_session.GetRobeSprName(
this->job, this->headJob, this->appearance[0], this->robe, this->riding, this->bodyCostume
);
std::string actName = g_session.GetRobeActName(
this->job, this->headJob, this->appearance[0], this->robe, this->riding, this->bodyCostume
);
if (!ResourceMgr::Instance().Exists(sprName) || !ResourceMgr::Instance().Exists(actName)) {
return;
}
CSprRes* sprite = static_cast<CSprRes*>(ResourceMgr::Instance().Load(sprName));
CActRes* act = static_cast<CActRes*>(ResourceMgr::Instance().Load(actName));
const ActionFrame& actionFrame = act->Frame(this->actionIndex, this->frameIndex);
for (int index = 0; index < actionFrame.cellCount; ++index) {
const SpriteFrameCell& cell = act->Frame(this->actionIndex, this->frameIndex).Cell(index);
if (cell.image == -1) {
continue;
}
reinterpret_cast<unsigned char*>(&const_cast<SpriteFrameCell&>(cell).color)[3] =
static_cast<unsigned char>(g_session.GetRobeAlpha(this->robe));
const SpriteRleImage* image = sprite->images[cell.imageType][cell.image];
SpriteQuad quad;
tagRECT bounds;
SpriteColor color;
float bottomDepth;
float topDepth;
this->ProjectCell(
layer, layer, scale, cell, x, y, position, shift, bottomDepth, topDepth, *image, reinterpret_cast<SpriteCellQuad&>(quad), bounds, color, 0, 0,
!drawOnTop
);
const float bottom = bottomDepth;
const float top = topDepth;
if (!drawOnTop && static_cast<CGameMode*>(g_modeMgr.GetGameMode())->camera->camera.pitch >= -40.0f) {
quad.bottomRhw = bottom - 0.0000065f;
quad.topRhw = top - 0.0000065f;
}
if (this->actionIndex >= 58 && this->actionIndex <= 61) {
quad.bottomRhw = quad.bottomRhw + 0.0000065f;
quad.topRhw = quad.topRhw + 0.0000065f;
}
if (drawOnTop && g_session.IsTopLayerRobe(this->robe)) {
const float bias = g_cameraDistance < 320.0f ? 0.000251f : 0.00011f;
quad.bottomRhw = bottom + bias;
quad.topRhw = top + bias;
}
quad.image = image;
CharacterRenderDrawItem item;
item.flags = 1;
item.command = BuildSpriteQuad(*GetRenderSystemHolder()->system, quad, sprite->palette, 1, 0.0f, 0.0f);
commands.push_back(item);
}
}
++layer;
}