diff --git a/Source/Client/Session.h b/Source/Client/Session.h index 51779629..2470eafd 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -1,5 +1,6 @@ #ifndef RAGNAROK_SOURCE_CLIENT_SESSION_H #define RAGNAROK_SOURCE_CLIENT_SESSION_H +#include "Render/Renderer.h" #include "Contents/InstantVar.h" #include "Contents/Items/ItemInfo.h" @@ -995,6 +996,7 @@ public: void SetUnknown7EC8(std::uint32_t value); void NotifyUnknown7F94Name(std::uint32_t id, const char* name); void sub_DE3D90(char* text); + void sub_DE4FF0(); std::pair GetShopEntry(unsigned int index, int key); bool HasUnknown809C(std::string name); void SetUnknown16EC(std::uint32_t value); @@ -1170,4 +1172,27 @@ static_assert(offsetof(CSession, unknown_7F94) == 0x7F94); static_assert(offsetof(CSession, unknown_8148) == 0x8148); #endif + +// INLINED +inline __declspec(noinline) void CSession::sub_DE4FF0() { + const float scaleX = static_cast(g_renderer->viewport.width) / 1280.0f; + const float scaleY = static_cast(g_renderer->viewport.height - 17) / 1024.0f; + + for (int i = 0; i < this->m_mapPosListCount; ++i) { + for (std::pair& entry : this->m_mapPosLists[i]) { + entry.second.rect.left = static_cast(static_cast(entry.second.rect.left) * scaleX + 0.5); + entry.second.rect.top = static_cast(static_cast(entry.second.rect.top) * scaleY + 0.5) + 17; + entry.second.rect.right = static_cast(static_cast(entry.second.rect.right) * scaleX + 0.5); + entry.second.rect.bottom = static_cast(static_cast(entry.second.rect.bottom) * scaleY + 0.5) + 17; + } + } + + for (std::pair& entry : this->m_mapPosBounds) { + entry.second.rect.left = static_cast(static_cast(entry.second.rect.left) * scaleX + 0.5); + entry.second.rect.top = static_cast(static_cast(entry.second.rect.top) * scaleY + 0.5) + 17; + entry.second.rect.right = static_cast(static_cast(entry.second.rect.right) * scaleX + 0.5); + entry.second.rect.bottom = static_cast(static_cast(entry.second.rect.bottom) * scaleY + 0.5) + 17; + } +} + #endif diff --git a/Source/Contents/WorldView/WorldViewData.cpp b/Source/Contents/WorldView/WorldViewData.cpp index ad7ca3e7..d057e04f 100644 --- a/Source/Contents/WorldView/WorldViewData.cpp +++ b/Source/Contents/WorldView/WorldViewData.cpp @@ -101,7 +101,7 @@ void CWorldViewWorld::AddField(int mapId, const char* name, CWorldViewField* fie // OFFSET: 0x006137B0 // FUNCTION: fn_04351 -bool CWorldViewWorld::LoadTexture() { +__declspec(noinline) bool CWorldViewWorld::LoadTexture() { std::string path = "유저인터페이스\\"; path += this->imageName; this->texture = g_texMgr.Load(path.c_str(), 0, true, true, false); @@ -316,6 +316,31 @@ bool CWorldViewMgr::ScaleToScreen() { return true; } +// GLOBAL: gl_25167 +static int gl_25167 = 0; + +// OFFSET: 0x006168F0 +// FUNCTION: fn_04375 +void CWorldViewMgr::sub_6168F0() { + const int width = g_renderer->viewport.width; + if (width > 640) { + if (width <= 800) { + this->screenScale = 1; + } else { + this->screenScale = (width > 1024) + 2; + } + } + + for (std::vector::iterator it = this->worlds.begin(); it != this->worlds.end(); ++it) { + (*it)->LoadTexture(); + } + + if (gl_25167 == 0) { + gl_25167 = this->ScaleToScreen(); + g_session.sub_DE4FF0(); + } +} + // OFFSET: 0x00616970 // FUNCTION: fn_04376 unsigned int CWorldViewMgr::FindWorld(int mapId) { diff --git a/Source/Contents/WorldView/WorldViewData.h b/Source/Contents/WorldView/WorldViewData.h index 3782dc78..df5ed5fb 100644 --- a/Source/Contents/WorldView/WorldViewData.h +++ b/Source/Contents/WorldView/WorldViewData.h @@ -89,6 +89,7 @@ public: CWorldViewMgr(); bool ScaleToScreen(); + void sub_6168F0(); unsigned int FindWorld(int mapId); void ResetSelection(); bool SelectField(const char* name);