rodecomp/Source/UI/MiniPartyPlacement.cpp
ragnarok-clanker 3ddb52d9c1 Decompile 2 functions in Source/UI/MiniPartyPlacement.cpp, Source/UI/MiniPartyUsableArea.cpp, ...
Batch #11595 by cremane: 1 byte-identical, 1 confirmed by peer review.

- fn_07657 CMiniPartyWndAreaMgr::FindFreeCell: logic confirmed by peer review
- fn_17166 UIWindowMgr::GetMiniPartyUsableArea: byte-identical

Peer-reviewed-by: Yommy, KWDev
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-05 03:47:55 +00:00

68 lines
2 KiB
C++

#include "UI/MiniPartyPlacement.h"
#include "UI/MiniPartyGrid.h"
#include "UI/Window/MiniPartyWndAreaMgr.h"
#include "UI/Window/UIWindow.h"
#include "UI/Window/UIWindowMgr.h"
// OFFSET: 0x00737680
// FUNCTION: fn_07650
CMiniPartyWndSortArea::CMiniPartyWndSortArea(const RECT& bounds) {
SetRect(&this->area, 0, 0, g_windowMgr.unknown_047C, g_windowMgr.unknown_0480);
this->columns = (this->area.right - this->area.left) / g_miniPartyCellWidth;
this->rows = (this->area.bottom - this->area.top) / g_miniPartyCellHeight;
const RECT target = bounds;
for (int index = 0; index < this->columns * this->rows; ++index) {
const int x = this->area.left + g_miniPartyCellWidth * (index / this->rows);
const int y = this->area.top + g_miniPartyCellHeight * (index % this->rows);
if (target.left <= x && x + g_miniPartyCellWidth <= target.right && target.top <= y && y + g_miniPartyCellHeight <= target.bottom) {
this->cells.push_back(index);
}
}
}
// OFFSET: 0x00737830
// FUNCTION: fn_07651
void __stdcall Nullsub228() {
}
// OFFSET: 0x00A91870
// FUNCTION: fn_17165
UIWindow* UIWindowMgr::FindSnapExcludedWindow(int cell) {
for (UIWindow* window : this->snapExcluded) {
if (*reinterpret_cast<int*>(reinterpret_cast<char*>(window) + 0x104) == cell) {
return window;
}
}
return nullptr;
}
// OFFSET: 0x00737B00
// FUNCTION: fn_07657
int CMiniPartyWndAreaMgr::FindFreeCell() {
CMiniPartyWndSortArea area(g_windowMgr.GetMiniPartyUsableArea());
const std::list<int> cells = area.GetCells();
for (std::vector<int>::iterator it = this->available.begin(); it != this->available.end(); ++it) {
const std::list<int>::const_iterator found = std::find(cells.begin(), cells.end(), *it);
if (found == cells.end()) {
continue;
}
const UIWindow* const window = g_windowMgr.FindSnapExcludedWindow(*it);
if (window == nullptr) {
return *it;
}
}
return -1;
}
// OFFSET: 0x00737D40
// FUNCTION: fn_07658
std::list<int> CMiniPartyWndSortArea::GetCells() const {
return this->cells;
}