diff --git a/Source/Contents/MapNameTable.cpp b/Source/Contents/MapNameTable.cpp index e2737591..e57f9708 100644 --- a/Source/Contents/MapNameTable.cpp +++ b/Source/Contents/MapNameTable.cpp @@ -167,27 +167,31 @@ bool CSession::LoadMapPosTable() { return true; } +// INLINED +static __forceinline void ScaleMapRect(MapPosRect* rect) { + if (!rect) { + return; + } + + const float scaleX = static_cast(g_renderer->viewport.width) / 1280.0f; + const float scaleY = static_cast(g_renderer->viewport.height - 17) * 0.0009765625f; + 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; +} + // 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; + ScaleMapRect(&it->second.rect); } } 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; + ScaleMapRect(&it->second.rect); } return true;