rodecomp/Source/Contents/RobeOpacity.cpp
ragnarok-clanker b496a618dc Decompile 2 functions in Source/Contents/RobeOpacity.cpp, Source/Contents/RobeTopLayer.cpp, ...
Batch #1582 by eAthena: 0 byte-identical, 2 confirmed by peer review.

- fn_23486 CSession::GetRobeAlpha: logic confirmed by peer review
- fn_24176 CSession::IsTopLayerRobe: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
Adds to the build: Source/Contents/RobeOpacity.cpp, Source/Contents/RobeTopLayer.cpp
2026-10-28 19:10:37 +00:00

34 lines
883 B
C++

#include "Client/Session.h"
#include <cstdlib>
#include <windows.h>
#include <timeapi.h>
// OFFSET: 0x00DE3C10
// FUNCTION: fn_23486
int CSession::GetRobeAlpha(int robeId) {
const RobeAlpha& alpha = this->m_robeAlpha.find(robeId)->second;
const int to = alpha.to;
const int period = alpha.period;
const int range = std::abs(to - alpha.from);
if (range == 0) {
return to;
}
const int base = to < alpha.from ? to : alpha.from;
const int half = static_cast<int>(static_cast<float>(period) * 0.5f);
int phase = timeGetTime() % period;
if (phase > half) {
phase = period - phase;
}
const int value = static_cast<int>(static_cast<float>(phase) / static_cast<float>(half) * static_cast<float>(range) + static_cast<float>(base));
int result = 0;
if (value >= 0) {
result = value;
}
if (result > 255) {
result = 255;
}
return result;
}