Decompile fn_45471 (CSession::ScaleMapPositions)

Batch #8601 by dori: 0 byte-identical, 1 confirmed by peer review.

- fn_45471 CSession::ScaleMapPositions: logic confirmed by peer review

Peer-reviewed-by: gordaoprogramas, System4z, Montyla
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-10-31 19:38:16 +00:00
commit 4912ab0924
2 changed files with 28 additions and 0 deletions

View file

@ -2,6 +2,7 @@
#include "Contents/MapInfoMgr.h"
#include "File/CommonObject.h"
#include "File/File.h"
#include "Render/Renderer.h"
#include "Resource/Bitmap/BitmapResource.h"
#include "Utility/Cipher/XorBytes.h"
@ -191,3 +192,29 @@ bool CSession::LoadMapPosTable() {
file.Close();
return true;
}
// OFFSET: 0x00DE4FF0
// FUNCTION: fn_45471
bool CSession::ScaleMapPositions() {
const float scaleX = static_cast<float>(g_renderer->viewport.width) / 1280.0f;
const float scaleY = static_cast<float>(g_renderer->viewport.height - 17) * 0.0009765625f;
for (int index = 0; index < this->m_mapPosListCount; ++index) {
for (std::map<std::string, MapPosEntry>::iterator it = this->m_mapPosLists[index].begin(); it != this->m_mapPosLists[index].end(); ++it) {
MapPosRect& rect = it->second.rect;
rect.left = static_cast<int>(static_cast<float>(rect.left) * scaleX + 0.5);
rect.top = static_cast<int>(static_cast<float>(rect.top) * scaleY + 0.5) + 17;
rect.right = static_cast<int>(static_cast<float>(rect.right) * scaleX + 0.5);
rect.bottom = static_cast<int>(static_cast<float>(rect.bottom) * scaleY + 0.5) + 17;
}
}
for (std::map<int, MapPosEntry>::iterator it = this->m_mapPosBounds.begin(); it != this->m_mapPosBounds.end(); ++it) {
MapPosRect& rect = it->second.rect;
rect.left = static_cast<int>(static_cast<float>(rect.left) * scaleX + 0.5);
rect.top = static_cast<int>(static_cast<float>(rect.top) * scaleY + 0.5) + 17;
rect.right = static_cast<int>(static_cast<float>(rect.right) * scaleX + 0.5);
rect.bottom = static_cast<int>(static_cast<float>(rect.bottom) * scaleY + 0.5) + 17;
}
return true;
}