diff --git a/Source/Client/Session.h b/Source/Client/Session.h index 2470eafd..dcb2a3c7 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -598,6 +598,7 @@ public: bool LoadExceptionMinimapNameTable(); bool LoadMapNameTable(); bool LoadMapPosTable(); + bool ScaleMapPositions(); bool LoadFogParameters(); void ClearHomunStatus(); std::pair* InsertPair(int key, int value); diff --git a/Source/Contents/MapNameTable.cpp b/Source/Contents/MapNameTable.cpp index a7a977c4..cf3ed5ba 100644 --- a/Source/Contents/MapNameTable.cpp +++ b/Source/Contents/MapNameTable.cpp @@ -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(g_renderer->viewport.width) / 1280.0f; + const float scaleY = static_cast(g_renderer->viewport.height - 17) * 0.0009765625f; + for (int index = 0; index < this->m_mapPosListCount; ++index) { + for (std::map::iterator it = this->m_mapPosLists[index].begin(); it != this->m_mapPosLists[index].end(); ++it) { + MapPosRect& rect = it->second.rect; + rect.left = static_cast(static_cast(rect.left) * scaleX + 0.5); + rect.top = static_cast(static_cast(rect.top) * scaleY + 0.5) + 17; + rect.right = static_cast(static_cast(rect.right) * scaleX + 0.5); + rect.bottom = static_cast(static_cast(rect.bottom) * scaleY + 0.5) + 17; + } + } + + for (std::map::iterator it = this->m_mapPosBounds.begin(); it != this->m_mapPosBounds.end(); ++it) { + MapPosRect& rect = it->second.rect; + rect.left = static_cast(static_cast(rect.left) * scaleX + 0.5); + rect.top = static_cast(static_cast(rect.top) * scaleY + 0.5) + 17; + rect.right = static_cast(static_cast(rect.right) * scaleX + 0.5); + rect.bottom = static_cast(static_cast(rect.bottom) * scaleY + 0.5) + 17; + } + + return true; +}