feat: server-synced bag sort, fix world map continent bounds, update docs

Inventory sort: clicking "Sort Bags" now generates CMSG_SWAP_ITEM packets
to move items server-side (one swap per frame to avoid race conditions).
Client-side sort runs immediately for visual preview; server swaps follow.
New Inventory::computeSortSwaps() computes minimal swap sequence using
selection-sort permutation on quality→itemId→stackCount comparator.

World map: fix continent bounds derivation that used intersection (max/min)
instead of union (min/max) of child zone bounds, causing continent views
to display zoomed-in/clipped.

Update README.md and docs/status.md with current features, release info,
and known gaps (v1.8.2-preview, 664 opcode handlers, NPC voices, bag
independence, CharSections auto-detect, quest GO server limitation).
This commit is contained in:
Kelsi 2026-03-24 09:24:09 -07:00
parent 62e99da1c2
commit c18720f0f0
7 changed files with 145 additions and 22 deletions

View file

@ -1138,12 +1138,30 @@ void InventoryScreen::renderBagWindow(const char* title, bool& isOpen,
ImGui::Spacing();
ImGui::Separator();
// Sort Bags button — client-side reorder by quality/type
if (ImGui::SmallButton("Sort Bags")) {
inventory.sortBags();
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Sort all bag slots by quality (highest first),\nthen by item ID, then by stack size.");
// Sort Bags button — compute swaps, apply client-side preview, queue server packets
{
bool sorting = !sortSwapQueue_.empty();
if (sorting) ImGui::BeginDisabled();
if (ImGui::SmallButton(sorting ? "Sorting..." : "Sort Bags")) {
// Compute the swap operations before modifying local state
auto swaps = inventory.computeSortSwaps();
// Apply local preview immediately
inventory.sortBags();
// Queue server-side swaps (one per frame)
for (auto& s : swaps)
sortSwapQueue_.push_back(s);
}
if (sorting) ImGui::EndDisabled();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
ImGui::SetTooltip("Sort all bag slots by quality (highest first),\nthen by item ID, then by stack size.");
}
// Process one queued swap per frame
if (!sortSwapQueue_.empty() && gameHandler_) {
auto op = sortSwapQueue_.front();
sortSwapQueue_.pop_front();
gameHandler_->swapContainerItems(op.srcBag, op.srcSlot, op.dstBag, op.dstSlot);
}
}
if (moneyCopper > 0) {