rodecomp/Source/Contents/Ground/GroundWaterState.cpp
ragnarok-clanker 87bb32cef8 Decompile 48 functions in Source/Client/ModeFade.cpp, Source/Client/ModeFade.h, ...
Batch #2457 by ragnarok-clanker: 0 byte-identical, 48 confirmed by peer review.

- fn_00152 TextureCache::TextureCache: logic confirmed by peer review
- fn_01952 DrawAlphaRectangle: logic confirmed by peer review
- fn_01953 DrawBlendedRectangle: logic confirmed by peer review
- fn_01954 DrawTexturedRectangle: logic confirmed by peer review
- fn_01955 DrawTextureRegion: logic confirmed by peer review
- fn_02237 CRendererDX9::SaveLogo: logic confirmed by peer review
- fn_02353 CRenderSystemDX9::CRenderSystemDX9: logic confirmed by peer review
- fn_02447 TextureCache::~TextureCache: logic confirmed by peer review (already on main)
- fn_02449 TextureCache::Upload: logic confirmed by peer review
- fn_02451 TextureCache::Clear: logic confirmed by peer review (already on main)
- fn_02452 TextureCache::Remove: logic confirmed by peer review (already on main)
- fn_02453 TextureCache::Default: logic confirmed by peer review
- fn_02454 TextureCache::Load: logic confirmed by peer review (already on main)
- fn_02455 TextureCache::Create: logic confirmed by peer review
- fn_02456 TextureCache::Reload: logic confirmed by peer review
- fn_02457 TextureCache::ClearUnused: logic confirmed by peer review
- fn_07897 EZeffectClip::Texture: logic confirmed by peer review
- fn_07898 EZeffectClip::Texture: logic confirmed by peer review
- fn_07958 C3dAnimModelRes::Load: logic confirmed by peer review
- fn_07996 ModelNode::~ModelNode: logic confirmed by peer review
- fn_08010 C3dGrannyModelRes::CreateTexture: logic confirmed by peer review
- fn_08020 C3dModelResV2::ReadVersion1: logic confirmed by peer review
- fn_08021 C3dModelResV2::ReadVersion2: logic confirmed by peer review
- fn_08022 C3dModelResV2::ReadVersion3: logic confirmed by peer review
- fn_09166 BinkMovies::Update: logic confirmed by peer review
- fn_10122 UIRPData::DrawNamed: logic confirmed by peer review
- fn_12091 UIWhisperWnd::Slot43: logic confirmed by peer review
- fn_17556 GroundGeometry::Build: logic confirmed by peer review
- fn_17565 GroundGeometry::BuildLightmaps: logic confirmed by peer review
- fn_17581 GroundWaterState::Update: logic confirmed by peer review
- fn_17587 GroundGeometry::DrawGrid: logic confirmed by peer review
- fn_17599 GroundWaterState::Import: logic confirmed by peer review
- fn_17842 ModeFade::Draw: logic confirmed by peer review
- fn_17847 FadeOutMode: logic confirmed by peer review
- fn_20019 CRagEffect::Blessing: logic confirmed by peer review
- fn_20023 CRagEffect::Bottom: logic confirmed by peer review
- fn_20024 CRagEffect::BowlingBash: logic confirmed by peer review
- fn_20025 CRagEffect::CartRevolution: logic confirmed by peer review
- fn_20042 CRagEffect::Entry: logic confirmed by peer review
- fn_20054 CRagEffect::FrostDiver: logic confirmed by peer review
- fn_20058 CRagEffect::GrimTooth: logic confirmed by peer review
- fn_20066 CRagEffect::Hit4: logic confirmed by peer review
- fn_20088 UpdatePartyEffect: logic confirmed by peer review
- fn_20105 CRagEffect::SonicBlowHit: logic confirmed by peer review
- fn_20109 CRagEffect::SprayPond: logic confirmed by peer review
- fn_20124 CRagEffect::Yufitel: logic confirmed by peer review
- fn_20132 CRagEffect::AirTexture: logic confirmed by peer review
- fn_20133 CRagEffect::AttackEnergy2: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
2026-10-29 18:23:21 +00:00

93 lines
3.2 KiB
C++

#include "Contents/Ground/GroundWaterState.h"
#include "Render/Textures/TextureCache.h"
#include "Resource/World/GroundResource.h"
#include "Utility/Math/ScalarConversion.h"
#include <algorithm>
#include <cstdio>
// INLINED
GroundWaterState::GroundWaterState() : level(0.0f), animation(3), pitch(50), phase(2), type(0), height(1.0f), columns(1), rows(1), partitioned(false) {
}
// OFFSET: 0x00AC3320
// FUNCTION: fn_17600
void GroundWaterState::Set(float newLevel, int newType, int newAnimation, int newPitch, int newPhase, float newHeight) {
this->animation = newAnimation;
this->pitch = newPitch;
this->level = newLevel;
this->height = newHeight;
this->phase = newPhase % 360;
this->type = newType;
}
// OFFSET: 0x00AC30D0
// FUNCTION: fn_17599
bool GroundWaterState::Import(const CGndRes& resource) {
if (resource.major == 1 && resource.minor >= 8) {
this->columns = resource.waterWidth;
this->rows = resource.waterHeight;
this->levels = resource.waterHeights;
this->surfaces.resize(resource.water.size());
for (std::size_t index = 0; index < resource.water.size(); ++index) {
const GroundWaterParameters& parameters = resource.water[index].parameters;
this->surfaces[index] = {parameters.level, parameters.type, parameters.height, parameters.speed, parameters.pitch, parameters.animation, 0, 0.0f,
nullptr};
}
this->animation = resource.waterDefault.animation;
this->pitch = TruncateToInt(resource.waterDefault.pitch);
this->phase = TruncateToInt(resource.waterDefault.speed) % 360;
this->type = resource.waterDefault.type;
this->height = resource.waterDefault.height;
} else {
this->surfaces.push_back(
{this->level, this->type, this->height, static_cast<float>(this->phase), static_cast<float>(this->pitch), this->animation, 0, 0.0f, nullptr}
);
this->levels.push_back(this->level);
}
this->Update();
this->partitioned = this->levels.size() > 1;
return this->partitioned;
}
// OFFSET: 0x00AC1390
// FUNCTION: fn_17580
float GroundWaterState::Level(int width, int height, int column, int row) const {
const int cellWidth = width / this->columns;
const int cellHeight = height / this->rows;
const int x = std::min(column / cellWidth, this->columns - 1);
const int z = std::min(row / cellHeight, this->rows - 1);
const unsigned index = static_cast<unsigned>(x) + static_cast<unsigned>(z) * static_cast<unsigned>(this->columns);
return index < this->levels.size() ? this->levels[index] : 0.0f;
}
// OFFSET: 0x00AC1430
// FUNCTION: fn_17581
void GroundWaterState::Update() {
// STATIC: 0x01159248
constexpr char format[] = "워터\\water%d%02d.jpg";
char name[32]{};
for (GroundWaterSurface& surface : this->surfaces) {
++surface.frame;
const int end = surface.animation * 32;
if (end <= surface.frame) {
surface.frame = 0;
}
const int image = (surface.frame / surface.animation) % 32;
_snprintf_s(name, sizeof(name), _TRUNCATE, format, surface.type, image);
surface.texture = g_texMgr.Load(name, 0, false, true, false);
const float phase = surface.speed + surface.phase;
surface.phase = phase;
if (phase > 180.0f) {
surface.phase = phase - 360.0f;
}
}
}