From 56b6f54e3aa7918a6f75fe56ca6920acece07ef5 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 22:22:36 +0000 Subject: [PATCH] Maintenance: Replace raw address calls in UILapineBoxWnd.cpp and WindowOverlay.cpp with declared functions: 0x00602620 CanUseIngredie Batch #8889 by ragnarok-clanker: forced by an admin (2 lower score(s), 9 changed function(s)); checked with 177 compiled unit(s), including every includer of Source/UI/Window/UIFrameWnd.h. --- Source/UI/UILapineBoxWnd.cpp | 38 +++++++++++++---------------------- Source/UI/Window/UIFrameWnd.h | 8 ++++++++ Source/UI/WindowOverlay.cpp | 17 +++------------- 3 files changed, 25 insertions(+), 38 deletions(-) diff --git a/Source/UI/UILapineBoxWnd.cpp b/Source/UI/UILapineBoxWnd.cpp index 07b7ec2e8..7d9bd5a3c 100644 --- a/Source/UI/UILapineBoxWnd.cpp +++ b/Source/UI/UILapineBoxWnd.cpp @@ -26,17 +26,6 @@ #include #include -typedef bool(__thiscall* AddMaterialSlotFn)(UILapineBoxWnd*, int, int); -typedef void(__thiscall* ReadMaterialFn)(UILapineBoxWnd*, void*, int, int); -typedef void(__thiscall* MaterialPositionFn)(UILapineBoxWnd*, void*, int); -typedef void(__thiscall* ReturnMaterialFn)(UILapineBox_IngredientListWnd*, int); -typedef bool(__thiscall* CheckMaterialFn)(UILapineBox_IngredientListWnd*, int); -typedef void(__thiscall* FillItemIdsFn)(CSession*, std::vector*, int, unsigned char); -typedef void(__thiscall* LayoutChildFn)(UILapineBox_IngredientListWnd*, UIWindow*, int, int); -typedef int(__thiscall* ScrollWndSendMsgFn)(UILapineBox_IngredientListWnd*, UIWindow*, int, std::intptr_t, std::intptr_t, std::intptr_t, std::intptr_t); -typedef void(__thiscall* BeginItemOnModeFn)(CGameMode*, int, ITEM_INFO*, int, int); -typedef void(__thiscall* CloseNotifyFn)(UIWindowMgr*, int); -typedef int(__thiscall* BuildItemNameFn)(UIFrameWnd*, const ITEM_INFO*, int*, std::vector*, char**, std::size_t*, char**, char, char); namespace { struct RandomCombineItemPacket { @@ -57,7 +46,7 @@ UILapineBoxWnd::UILapineBoxWnd() // FUNCTION: fn_04160 void UIIngredientInfoWnd::Click(int, int) { if (this->insufficient == 1) { - reinterpret_cast(0x00602620)(static_cast(this->parent), this->item.unknown_0000[1]); + static_cast(this->parent)->CanUseIngredient(this->item.unknown_0000[1]); return; } @@ -70,7 +59,7 @@ void UIIngredientInfoWnd::Click(int, int) { UILapineBoxWnd* box = static_cast(list->parent); if (box->items.size() < static_cast(box->maxItems)) { if (list->SendMsg(list, 0x68, id, 0, 0, 0) >= 0) { - reinterpret_cast(0x00601D20)(box, id, this->quantity); + box->AddIngredient(id, this->quantity); } } } @@ -106,7 +95,7 @@ void UIIngredientInfoWnd::Slot28(int x, int y) { int tipX = 0; int tipY = -20; this->ToScreen(tipX, tipY); - (*reinterpret_cast(0x013495BC))->Show(this->tooltip.c_str(), tipX, tipY, -1, 0, 1); + reinterpret_cast(g_modeMgr.gameMode)->Show(this->tooltip.c_str(), tipX, tipY, -1, 0, 1); } } @@ -115,10 +104,10 @@ void UIIngredientInfoWnd::Slot28(int x, int y) { void UILapineBoxWnd::DropMaterial(int x, int y) { alignas(ITEM_INFO) unsigned char storage[sizeof(ITEM_INFO)]; ITEM_INFO& item = *reinterpret_cast(storage); - reinterpret_cast(0x00602410)(this, &item, x, y); + this->ReadMaterial(&item, x, y); if (item.unknown_0000[1] != 0) { - if (reinterpret_cast(0x00602030)(this->ingredientList, item.unknown_0000[1]) == 1) { + if (this->ingredientList->AddIngredient(item.unknown_0000[1]) == 1) { this->SendMsg(this, 0x68, item.unknown_0000[1], 0, 0, 0); } } @@ -135,10 +124,11 @@ void UILapineBoxWnd::DragIngredient(int x, int y) { alignas(ITEM_INFO) unsigned char storage[sizeof(ITEM_INFO)]; ITEM_INFO& item = *reinterpret_cast(storage); - reinterpret_cast(0x00602410)(this, &item, x, y); + this->ReadMaterial(&item, x, y); if (item.unknown_0000[1] != 0) { - reinterpret_cast(0x00CFE140)(static_cast(g_modeMgr.GetGameMode()), 0x1A, &item, item.quantity, -1); + ItemDescriptions descriptions{g_itemDescriptions}; + static_cast(g_modeMgr.GetGameMode())->drag.BeginItem(*reinterpret_cast(&g_windowMgr), descriptions, 0x1A, item, item.quantity, -1); } item.~ITEM_INFO(); @@ -151,7 +141,7 @@ void UILapineBoxWnd::Slot28(int x, int y) { alignas(ITEM_INFO) unsigned char storage[sizeof(ITEM_INFO)]; ITEM_INFO& item = *reinterpret_cast(storage); - reinterpret_cast(0x00602410)(this, &item, x, y); + this->ReadMaterial(&item, x, y); if (item.unknown_0000[1] != 0) { int tipX = 0; @@ -160,7 +150,7 @@ void UILapineBoxWnd::Slot28(int x, int y) { for (int index = 0; index < count; ++index) { if (this->items[index].unknown_0000[1] == item.unknown_0000[1]) { int position[2] = {0, 0}; - reinterpret_cast(0x006024F0)(this, position, index); + this->MaterialPosition(position, index); tipX = position[0]; tipY = position[1] - 0x14; break; @@ -168,7 +158,7 @@ void UILapineBoxWnd::Slot28(int x, int y) { } this->ToScreen(tipX, tipY); - (*reinterpret_cast(0x013495BC))->Show(item.unknown_0044.c_str(), tipX, tipY, -1, 0, 1); + reinterpret_cast(g_modeMgr.gameMode)->Show(item.unknown_0044.c_str(), tipX, tipY, -1, 0, 1); } item.~ITEM_INFO(); @@ -382,7 +372,7 @@ int UILapineBoxWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std: return UIFrameWnd::SendMsg(sender, message, a, b, c, d); } } else if (a == 0xC9) { - reinterpret_cast(0x00A8CF20)(&g_windowMgr, 0x122); + g_windowMgr.CloseWindow(0x122); } else if (a == 0x1F7) { const int count = static_cast(this->items.size()); const int length = count * 4 + 8; @@ -414,7 +404,7 @@ int UILapineBoxWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std: if (entry->selected == 1) { if (entry != nullptr && entry->insufficient != 1) { if (this->ingredientList->SendMsg(this, 0x68, entry->item.unknown_0000[1], 0, 0, 0) >= 0) { - reinterpret_cast(0x00601D20)(this, entry->item.unknown_0000[1], entry->quantity); + this->AddIngredient(entry->item.unknown_0000[1], entry->quantity); } } break; @@ -599,7 +589,7 @@ void UIIngredientInfoWnd::sub_6028C0(std::uint32_t id) { std::size_t remaining = sizeof(name); char* cursor = name; int highlightColor; - reinterpret_cast(0x008DA690)(this, &this->item, &highlightColor, &breaks, &cursor, &remaining, &highlight, 1, 0); + this->BuildItemName(&this->item, &highlightColor, &breaks, &cursor, &remaining, &highlight, 1, 0); if (this->item.identified == 1) { const int count = this->item.unknown_0098; diff --git a/Source/UI/Window/UIFrameWnd.h b/Source/UI/Window/UIFrameWnd.h index da6d108c6..742afe585 100644 --- a/Source/UI/Window/UIFrameWnd.h +++ b/Source/UI/Window/UIFrameWnd.h @@ -50,6 +50,14 @@ public: void DrawTextLines(int x, int y, int family, int lineHeight, const FrameTextLines& lines); int DrawItemName(int x, int y, int width, const ITEM_INFO* item, int unused, int family, int height); int DrawWrappedItemName(int x, int y, int width, const ITEM_INFO* item, int unused, int family, int lineHeight); + int BuildItemName( + const ITEM_INFO* item, int* highlightColor, std::vector* breaks, char** cursor, std::size_t* remaining, char** highlight, char withSlots, + char withOptions + ); + void DrawItemNameText( + const void* info, const char* text, const char* highlight, std::uint32_t color, std::uint32_t highlightColor, int width, + const std::vector* breaks + ); void SplitHighlightText( const char* text, const char* highlight, const int& highlightColor, const int& color, const std::vector& breaks, std::vector>& segments diff --git a/Source/UI/WindowOverlay.cpp b/Source/UI/WindowOverlay.cpp index d2c19d830..644978678 100644 --- a/Source/UI/WindowOverlay.cpp +++ b/Source/UI/WindowOverlay.cpp @@ -109,11 +109,6 @@ namespace { int height; int family; }; - - using BuildItemNameFn = int(__thiscall*)(UIFrameWnd*, const ITEM_INFO*, int*, std::vector*, char**, std::size_t*, char**, char, char); - using DrawItemNameTextFn = void(__thiscall*)( - UIFrameWnd*, const ItemNameTextInfo*, const char*, const char*, std::uint32_t, std::uint32_t, int, const std::vector* - ); } // OFFSET: 0x008D17C0 @@ -125,9 +120,7 @@ int UIFrameWnd::DrawItemName(int x, int y, int width, const ITEM_INFO* item, int char* cursor = buffer; std::size_t remaining = sizeof(buffer); char* highlight = nullptr; - reinterpret_cast(0x008DA690)( - this, item, &highlightColor, &breaks, &cursor, &remaining, &highlight, 1, 0 - ); + this->BuildItemName(item, &highlightColor, &breaks, &cursor, &remaining, &highlight, 1, 0); std::uint32_t color = ItemCardColor(item); if (color == 0x00ADFF2F) { @@ -136,9 +129,7 @@ int UIFrameWnd::DrawItemName(int x, int y, int width, const ITEM_INFO* item, int color = (color >> 16 & 0xFF) | (color & 0x0000FF00) | ((color & 0xFF) << 16); const ItemNameTextInfo info = {x, y, height, family}; - reinterpret_cast(0x0090A2E0)( - this, &info, buffer, highlight, color, static_cast(highlightColor), width, &breaks - ); + this->DrawItemNameText(&info, buffer, highlight, color, static_cast(highlightColor), width, &breaks); return x; } @@ -151,9 +142,7 @@ int UIFrameWnd::DrawWrappedItemName(int x, int y, int width, const ITEM_INFO* it std::vector breaks; std::size_t remaining = sizeof(buffer); int highlightColor; - reinterpret_cast(0x008DA690)( - this, item, &highlightColor, &breaks, &cursor, &remaining, &highlight, 1, 0 - ); + this->BuildItemName(item, &highlightColor, &breaks, &cursor, &remaining, &highlight, 1, 0); std::uint32_t color = ItemCardColor(item); if (color == 0x00ADFF2F) {