diff --git a/D2tweaks.vcxproj b/D2tweaks.vcxproj index 9c6b36d..fae16f5 100644 --- a/D2tweaks.vcxproj +++ b/D2tweaks.vcxproj @@ -47,12 +47,12 @@ true - ..\..\Diablo II\MODS\ironman-dev + ..\..\Diablo II\MODS\ironman-dev\ $(SolutionDir)Build\$(Configuration)\ true - ..\..\Diablo II\MODS\ironman-dev + ..\..\Diablo II\MODS\ironman-dev\ $(SolutionDir)Build\$(Configuration)\ diff --git a/build/Debug/D2tweaks.ilk b/build/Debug/D2tweaks.ilk index 323d9dc..faa5867 100644 Binary files a/build/Debug/D2tweaks.ilk and b/build/Debug/D2tweaks.ilk differ diff --git a/build/Debug/D2tweaks.log b/build/Debug/D2tweaks.log index 1d5232a..80bf905 100644 --- a/build/Debug/D2tweaks.log +++ b/build/Debug/D2tweaks.log @@ -1,3 +1,2 @@ -C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(517,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory. - ui_manager.cpp + ui_manager.cpp D2tweaks.vcxproj -> D:\Diablo II\MODS\ironman-dev\D2tweaks.dll diff --git a/build/Debug/D2tweaks.tlog/CL.command.1.tlog b/build/Debug/D2tweaks.tlog/CL.command.1.tlog index 92e6efc..c3aef5c 100644 Binary files a/build/Debug/D2tweaks.tlog/CL.command.1.tlog and b/build/Debug/D2tweaks.tlog/CL.command.1.tlog differ diff --git a/build/Debug/D2tweaks.tlog/CL.read.1.tlog b/build/Debug/D2tweaks.tlog/CL.read.1.tlog index 25d39e6..9664f2a 100644 Binary files a/build/Debug/D2tweaks.tlog/CL.read.1.tlog and b/build/Debug/D2tweaks.tlog/CL.read.1.tlog differ diff --git a/build/Debug/D2tweaks.tlog/CL.write.1.tlog b/build/Debug/D2tweaks.tlog/CL.write.1.tlog index 182bd6e..73a6bf3 100644 Binary files a/build/Debug/D2tweaks.tlog/CL.write.1.tlog and b/build/Debug/D2tweaks.tlog/CL.write.1.tlog differ diff --git a/build/Debug/src/d2tweaks/client/client.obj b/build/Debug/src/d2tweaks/client/client.obj index 9495228..2512122 100644 Binary files a/build/Debug/src/d2tweaks/client/client.obj and b/build/Debug/src/d2tweaks/client/client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/auto_gold_pickup/auto_gold_pickup_client.obj b/build/Debug/src/d2tweaks/client/modules/auto_gold_pickup/auto_gold_pickup_client.obj index 42e681d..a148a3f 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/auto_gold_pickup/auto_gold_pickup_client.obj and b/build/Debug/src/d2tweaks/client/modules/auto_gold_pickup/auto_gold_pickup_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/auto_item_pickup/auto_item_pickup_client.obj b/build/Debug/src/d2tweaks/client/modules/auto_item_pickup/auto_item_pickup_client.obj index 7e6bac6..89982ef 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/auto_item_pickup/auto_item_pickup_client.obj and b/build/Debug/src/d2tweaks/client/modules/auto_item_pickup/auto_item_pickup_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/autosort/autosort_client.obj b/build/Debug/src/d2tweaks/client/modules/autosort/autosort_client.obj index c7390a6..b629645 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/autosort/autosort_client.obj and b/build/Debug/src/d2tweaks/client/modules/autosort/autosort_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/damage_display/damage_display_client.obj b/build/Debug/src/d2tweaks/client/modules/damage_display/damage_display_client.obj index b4dc86b..3ef60be 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/damage_display/damage_display_client.obj and b/build/Debug/src/d2tweaks/client/modules/damage_display/damage_display_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/item_drop_message/item_drop_message_client.obj b/build/Debug/src/d2tweaks/client/modules/item_drop_message/item_drop_message_client.obj index f2b330d..d0f4c48 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/item_drop_message/item_drop_message_client.obj and b/build/Debug/src/d2tweaks/client/modules/item_drop_message/item_drop_message_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/item_move/item_move_client.obj b/build/Debug/src/d2tweaks/client/modules/item_move/item_move_client.obj index a8bb239..ccf9d04 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/item_move/item_move_client.obj and b/build/Debug/src/d2tweaks/client/modules/item_move/item_move_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter.obj b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter.obj index 698fe42..7a545cc 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter.obj and b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.obj b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.obj index ae82a89..1342611 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.obj and b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.obj b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.obj index 122bd92..ec48c2c 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.obj and b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/small_patches/small_patches.obj b/build/Debug/src/d2tweaks/client/modules/small_patches/small_patches.obj index a9915e4..1d3a4a1 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/small_patches/small_patches.obj and b/build/Debug/src/d2tweaks/client/modules/small_patches/small_patches.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/test/test.obj b/build/Debug/src/d2tweaks/client/modules/test/test.obj index d818224..da5da99 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/test/test.obj and b/build/Debug/src/d2tweaks/client/modules/test/test.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/trader_update/trader_update_client.obj b/build/Debug/src/d2tweaks/client/modules/trader_update/trader_update_client.obj index 83619d5..60ab557 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/trader_update/trader_update_client.obj and b/build/Debug/src/d2tweaks/client/modules/trader_update/trader_update_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/transmute/transmute_client.obj b/build/Debug/src/d2tweaks/client/modules/transmute/transmute_client.obj index 6e25106..752a258 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/transmute/transmute_client.obj and b/build/Debug/src/d2tweaks/client/modules/transmute/transmute_client.obj differ diff --git a/build/Debug/src/d2tweaks/common/asset_manager.obj b/build/Debug/src/d2tweaks/common/asset_manager.obj index daad80c..0a1c490 100644 Binary files a/build/Debug/src/d2tweaks/common/asset_manager.obj and b/build/Debug/src/d2tweaks/common/asset_manager.obj differ diff --git a/build/Debug/src/d2tweaks/common/common.obj b/build/Debug/src/d2tweaks/common/common.obj index 67c729b..8f78fd8 100644 Binary files a/build/Debug/src/d2tweaks/common/common.obj and b/build/Debug/src/d2tweaks/common/common.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/auto_gold_pickup/auto_gold_pickup_server.obj b/build/Debug/src/d2tweaks/server/modules/auto_gold_pickup/auto_gold_pickup_server.obj index 11978b9..a51b8e7 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/auto_gold_pickup/auto_gold_pickup_server.obj and b/build/Debug/src/d2tweaks/server/modules/auto_gold_pickup/auto_gold_pickup_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/auto_item_pickup/auto_item_pickup_server.obj b/build/Debug/src/d2tweaks/server/modules/auto_item_pickup/auto_item_pickup_server.obj index 88d6e90..0c779e3 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/auto_item_pickup/auto_item_pickup_server.obj and b/build/Debug/src/d2tweaks/server/modules/auto_item_pickup/auto_item_pickup_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/autosort/autosort_server.obj b/build/Debug/src/d2tweaks/server/modules/autosort/autosort_server.obj index 00f7a08..e17d7d8 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/autosort/autosort_server.obj and b/build/Debug/src/d2tweaks/server/modules/autosort/autosort_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/damage_display/damage_display_server.obj b/build/Debug/src/d2tweaks/server/modules/damage_display/damage_display_server.obj index e44cc71..f6d8a23 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/damage_display/damage_display_server.obj and b/build/Debug/src/d2tweaks/server/modules/damage_display/damage_display_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/identify_on_pickup/identify_on_pickup_server.obj b/build/Debug/src/d2tweaks/server/modules/identify_on_pickup/identify_on_pickup_server.obj index dbee4a8..31e637c 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/identify_on_pickup/identify_on_pickup_server.obj and b/build/Debug/src/d2tweaks/server/modules/identify_on_pickup/identify_on_pickup_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/item_drop_message/item_drop_message_server.obj b/build/Debug/src/d2tweaks/server/modules/item_drop_message/item_drop_message_server.obj index e6d1141..730ebf8 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/item_drop_message/item_drop_message_server.obj and b/build/Debug/src/d2tweaks/server/modules/item_drop_message/item_drop_message_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/item_move/item_move_server.obj b/build/Debug/src/d2tweaks/server/modules/item_move/item_move_server.obj index 704f61f..f6d1a95 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/item_move/item_move_server.obj and b/build/Debug/src/d2tweaks/server/modules/item_move/item_move_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/server_module.obj b/build/Debug/src/d2tweaks/server/modules/server_module.obj index a133908..22385f6 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/server_module.obj and b/build/Debug/src/d2tweaks/server/modules/server_module.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/test/test.obj b/build/Debug/src/d2tweaks/server/modules/test/test.obj index a1d96e1..ea55b1e 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/test/test.obj and b/build/Debug/src/d2tweaks/server/modules/test/test.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/trader_update/trader_update_server.obj b/build/Debug/src/d2tweaks/server/modules/trader_update/trader_update_server.obj index 179b865..65f8e2e 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/trader_update/trader_update_server.obj and b/build/Debug/src/d2tweaks/server/modules/trader_update/trader_update_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/transmute/transmute_server.obj b/build/Debug/src/d2tweaks/server/modules/transmute/transmute_server.obj index a42909f..00ab895 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/transmute/transmute_server.obj and b/build/Debug/src/d2tweaks/server/modules/transmute/transmute_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/server.obj b/build/Debug/src/d2tweaks/server/server.obj index 280fc10..420ec1a 100644 Binary files a/build/Debug/src/d2tweaks/server/server.obj and b/build/Debug/src/d2tweaks/server/server.obj differ diff --git a/build/Debug/src/d2tweaks/ui/controls/button.obj b/build/Debug/src/d2tweaks/ui/controls/button.obj index 3103aad..b5d26aa 100644 Binary files a/build/Debug/src/d2tweaks/ui/controls/button.obj and b/build/Debug/src/d2tweaks/ui/controls/button.obj differ diff --git a/build/Debug/src/d2tweaks/ui/controls/checkbox.obj b/build/Debug/src/d2tweaks/ui/controls/checkbox.obj index 149dfe5..0be0ef5 100644 Binary files a/build/Debug/src/d2tweaks/ui/controls/checkbox.obj and b/build/Debug/src/d2tweaks/ui/controls/checkbox.obj differ diff --git a/build/Debug/src/d2tweaks/ui/controls/image.obj b/build/Debug/src/d2tweaks/ui/controls/image.obj index 325288f..a740a99 100644 Binary files a/build/Debug/src/d2tweaks/ui/controls/image.obj and b/build/Debug/src/d2tweaks/ui/controls/image.obj differ diff --git a/build/Debug/src/d2tweaks/ui/controls/label.obj b/build/Debug/src/d2tweaks/ui/controls/label.obj index e5ec723..3c9be0b 100644 Binary files a/build/Debug/src/d2tweaks/ui/controls/label.obj and b/build/Debug/src/d2tweaks/ui/controls/label.obj differ diff --git a/build/Debug/src/d2tweaks/ui/menu.obj b/build/Debug/src/d2tweaks/ui/menu.obj index 7798f30..f03c179 100644 Binary files a/build/Debug/src/d2tweaks/ui/menu.obj and b/build/Debug/src/d2tweaks/ui/menu.obj differ diff --git a/build/Debug/src/d2tweaks/ui/ui_manager.obj b/build/Debug/src/d2tweaks/ui/ui_manager.obj index 0d3ed93..527f148 100644 Binary files a/build/Debug/src/d2tweaks/ui/ui_manager.obj and b/build/Debug/src/d2tweaks/ui/ui_manager.obj differ diff --git a/build/Debug/src/diablo2/d2client.obj b/build/Debug/src/diablo2/d2client.obj index 903ac8c..ea95943 100644 Binary files a/build/Debug/src/diablo2/d2client.obj and b/build/Debug/src/diablo2/d2client.obj differ diff --git a/build/Debug/src/diablo2/d2common.obj b/build/Debug/src/diablo2/d2common.obj index 4ddc74e..312d79d 100644 Binary files a/build/Debug/src/diablo2/d2common.obj and b/build/Debug/src/diablo2/d2common.obj differ diff --git a/build/Debug/src/diablo2/d2game.obj b/build/Debug/src/diablo2/d2game.obj index 35ac064..250f47a 100644 Binary files a/build/Debug/src/diablo2/d2game.obj and b/build/Debug/src/diablo2/d2game.obj differ diff --git a/build/Debug/src/diablo2/d2lang.obj b/build/Debug/src/diablo2/d2lang.obj index 193b5bb..527eb36 100644 Binary files a/build/Debug/src/diablo2/d2lang.obj and b/build/Debug/src/diablo2/d2lang.obj differ diff --git a/build/Debug/src/diablo2/d2net.obj b/build/Debug/src/diablo2/d2net.obj index cafc3e3..50e4f3b 100644 Binary files a/build/Debug/src/diablo2/d2net.obj and b/build/Debug/src/diablo2/d2net.obj differ diff --git a/build/Debug/src/diablo2/utils/screen.obj b/build/Debug/src/diablo2/utils/screen.obj index 1b19d82..aa4489a 100644 Binary files a/build/Debug/src/diablo2/utils/screen.obj and b/build/Debug/src/diablo2/utils/screen.obj differ diff --git a/build/Debug/src/main.obj b/build/Debug/src/main.obj index 73c19bc..362db51 100644 Binary files a/build/Debug/src/main.obj and b/build/Debug/src/main.obj differ diff --git a/build/Debug/vc143.pdb b/build/Debug/vc143.pdb index 790e130..d65fa4f 100644 Binary files a/build/Debug/vc143.pdb and b/build/Debug/vc143.pdb differ diff --git a/include/d2tweaks/client/client.h b/include/d2tweaks/client/client.h index bda2581..cf65567 100644 --- a/include/d2tweaks/client/client.h +++ b/include/d2tweaks/client/client.h @@ -28,6 +28,9 @@ extern int randStatBool; extern bool m_stats_enabled; +extern bool m_help_enabled; + + namespace diablo2 { namespace structures { struct unit; diff --git a/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h b/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h index 2d2d19b..1b8adc9 100644 --- a/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h +++ b/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h @@ -17,6 +17,7 @@ namespace d2_tweaks { class loot_filter_settings_toggle_menu final : public ui::menu, singleton { ui::controls::button* m_toggle_filter_settings_btn; ui::controls::button* m_btn_toggle_stats; + ui::controls::button* m_btn_toggle_help; menu* m_filter_settings_menu; bool m_show; public: @@ -24,6 +25,7 @@ namespace d2_tweaks { void toggle_filter_settings_click(); void toggle_stats_settings_click(); + void toggle_help_click(); void draw() override; diff --git a/include/d2tweaks/common/protocol.h b/include/d2tweaks/common/protocol.h index 8d49e83..e5d153e 100644 --- a/include/d2tweaks/common/protocol.h +++ b/include/d2tweaks/common/protocol.h @@ -235,6 +235,7 @@ namespace d2_tweaks { struct item_move_cs : packet_header { uint32_t item_guid; + const char* item_code; uint8_t target_page; uint32_t bag_guid = 0; bool updateBag; diff --git a/include/diablo2/d2client.h b/include/diablo2/d2client.h index 3c2a340..ce34e68 100644 --- a/include/diablo2/d2client.h +++ b/include/diablo2/d2client.h @@ -86,5 +86,10 @@ namespace diablo2 { static bool is_gamble_open(); static uint8_t current_interact_menu(); static void resync_vendor_inventory(structures::unit* ptNPC); + + static int32_t send_to_server_9(BYTE type, DWORD num, DWORD unk1); + + + }; } \ No newline at end of file diff --git a/include/diablo2/d2game.h b/include/diablo2/d2game.h index 6217b56..4a43f1e 100644 --- a/include/diablo2/d2game.h +++ b/include/diablo2/d2game.h @@ -47,5 +47,6 @@ namespace diablo2 { static void update_inventory_items(structures::game* game, structures::unit* player); static uint32_t __fastcall diablo2::d2_game::transmogrify(diablo2::structures::game* game, diablo2::structures::unit* player); + }; } diff --git a/src/d2tweaks/client/modules/autosort/autosort_client.cpp b/src/d2tweaks/client/modules/autosort/autosort_client.cpp index 826c598..325b4a2 100644 --- a/src/d2tweaks/client/modules/autosort/autosort_client.cpp +++ b/src/d2tweaks/client/modules/autosort/autosort_client.cpp @@ -4,7 +4,6 @@ #include - #include #include #include @@ -20,7 +19,6 @@ #include #include - #include #include #include @@ -45,10 +43,19 @@ #include #include - #include #include +#include + +#include +#include +#include + +#include +#include +#include + MODULE_INIT(autosort) enum ColorEnum { @@ -88,7 +95,6 @@ std::map fontMap = { {13, diablo2::ui_font_t::UI_FONT_INGAMECHAT} }; - class inventory_sort_menu : public d2_tweaks::ui::menu { d2_tweaks::common::asset* m_buttons_img; @@ -115,8 +121,6 @@ public: m_sort_cube_btn = get_button("m_sort_cube_btn", std::bind(&inventory_sort_menu::sort_cube_click, this)); } - - // Function to find the Diablo II window handle HWND FindDiabloIIWindow() { return FindWindow(NULL, "Diablo II"); @@ -132,11 +136,81 @@ public: ReleaseDC(hwnd, hdc); } - - - int statsFont = GetPrivateProfileIntA("Options", "statsFont", 0, "./d2tweaks.ini"); + ULONGLONG lastSendTime = GetTickCount64(); + + + // Function to split a string into words + std::vector split(const std::string& s, char delim) { + std::stringstream ss(s); + std::string item; + std::vector tokens; + while (getline(ss, item, delim)) { + tokens.push_back(item); + } + return tokens; + } + + std::wstring stringToWstring(const std::string& str) { + std::wstring_convert> converter; + return converter.from_bytes(str); + } + + // Function to justify a line of text + void justifyLine(const std::vector& words, int start, int end, int maxLineLength, int& xPos, int yPos, int padding) { + int lineLength = 0; + for (int i = start; i <= end; i++) { + lineLength += words[i].length() * 8; // Assuming each character has a width of 8 pixels + } + + int numSpaces = end - start; + int extraSpaces = maxLineLength - lineLength - padding * 2; + + int spaceWidth = 8; + int extraSpacePerGap = numSpaces > 0 ? extraSpaces / numSpaces : 0; + int remainingSpaces = numSpaces > 0 ? extraSpaces % numSpaces : 0; + + for (int i = start; i <= end; i++) { + diablo2::d2_win::draw_boxed_text(const_cast(stringToWstring(words[i]).c_str()), xPos + padding, yPos, 0, 0, diablo2::UI_COLOR_WHITE); // Assuming paletteIndex, transTbl, and color are 0 + xPos += words[i].length() * 8 + spaceWidth + extraSpacePerGap + padding; + + if (remainingSpaces > 0) { + xPos += 1; // Add an extra pixel for the remaining spaces + remainingSpaces--; + } + } + } + + // Function to draw justified text inside a box with padding + void drawJustifiedTextInBox(const std::string& text, int boxX, int boxY, int boxWidth, int boxHeight, int padding) { + std::vector words = split(text, ' '); + int maxLineLength = boxWidth; + int xPos = boxX + padding; + int yPos = boxY + padding; + + for (size_t i = 0; i < words.size(); ) { + int start = i; + int end = i; + int lineLength = 0; + + // Find the end index for the current line + while (end < words.size() && lineLength + words[end].length() <= maxLineLength) { + lineLength += words[end].length(); + if (end > start) { + lineLength++; // Add space width + } + end++; + } + + justifyLine(words, start, end - 1, maxLineLength, xPos, yPos, padding); + yPos += 16; // Assuming each line is 16 pixels tall + xPos = boxX + padding; + i = end; + } + } + + void draw() override { @@ -157,16 +231,12 @@ public: // Initialize statValue int32_t statValue = 0; - if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH)) { diablo2::d2_gfx::draw_filled_rect(130, 48, 640, 155, 5, 50); } - - if (m_stats_enabled) { for (const auto& stat : stats) { - double param = 6; int32_t spirits = diablo2::d2_common::get_stat(player, static_cast(185), NULL); @@ -175,7 +245,7 @@ public: switch (stat.stat) { // 2. (statValue <- this is probably op stat1 ? * baseValue <- this is probably op base ) / 2 ^ param - // (op stat1 value * base stat value) / (2 ^ param) + // (op stat1 value * base stat value) / (2 ^ param) // let's try this fucking thing case 190: { @@ -229,7 +299,6 @@ public: // By default, get player stats statValue = diablo2::d2_common::get_stat(player, static_cast(stat.stat), NULL); break; - } } @@ -273,7 +342,6 @@ public: diablo2::d2_common::set_stat(player, static_cast(randStat), 0, 0); diablo2::d2_common::set_stat(player, static_cast(randStatBool), 0, 0); } - } */ auto statValueStr = std::to_wstring(statValue); @@ -301,175 +369,185 @@ public: && !diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_HELP) && !diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_MERC) && !diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_SCROLL)) { - // Draw stats diablo2::d2_win::set_current_font(fontMap[statsFont]); // Set font to FONT16 diablo2::d2_win::draw_text(const_cast(statText.c_str()), stat.x1, stat.y1 + textOffset, stat.colorStat, 0); diablo2::d2_win::set_current_font(fontMap[statsFont]); // Set font to FONT16 diablo2::d2_win::draw_text(const_cast(statValueStr.c_str()), stat.x2, stat.y2 + textOffset, stat.colorStatValue, 0); - - - //diablo2::d2_win::draw_boxed_text(const_cast(statText.c_str()), stat.x1, stat.y1 + textOffset, 1, 0, stat.colorStat); - //diablo2::d2_win::draw_boxed_text(const_cast(statValueStr.c_str()), stat.x2, stat.y2 + textOffset, 1, 4, stat.colorStatValue); - - // diablo2::d2_win::set_current_font(diablo2::UI_FONT_16); // Set font to FONT16 - - - //diablo2::structures::d2_cmp::init_gfx_data(&g_gfxdata); - - //diablo2::d2_gfx::draw_image(&g_gfxdata, 200, 200, 1, 5, 0); - - // instead try to load direct jpg with gdi and insetad ofloading jpg file, specify it bb64 encoded and decode it. - - diablo2::ui_color_t::UI_COLOR_WHITE; - - - // print player health, mana, and stamina bars, lastexp, nextexp, and level - // Get current HP, Mana, and Stamina along with their maximum values - int statHP = diablo2::d2_common::get_stat(player, static_cast(6), NULL) / 256; - int statMaxHP = diablo2::d2_common::get_stat(player, static_cast(7), NULL) / 256; - int statMana = diablo2::d2_common::get_stat(player, static_cast(8), NULL) / 256; - int statMaxMana = diablo2::d2_common::get_stat(player, static_cast(9), NULL) / 256; - int statStamina = diablo2::d2_common::get_stat(player, static_cast(10), NULL) / 256; - int statMaxStamina = diablo2::d2_common::get_stat(player, static_cast(11), NULL) / 256; - - // Convert the integer values to wide character strings - std::wstring strHP = std::to_wstring(statHP); - std::wstring strMaxHP = std::to_wstring(statMaxHP); - std::wstring strMana = std::to_wstring(statMana); - std::wstring strMaxMana = std::to_wstring(statMaxMana); - std::wstring strStamina = std::to_wstring(statStamina); - std::wstring strMaxStamina = std::to_wstring(statMaxStamina); - - diablo2::d2_win::set_current_font(diablo2::UI_FONT_16); // Set font to FONT16 - - // Calculate the percentages of current HP, Mana, and Stamina - float healthPercentage = static_cast(statHP) / static_cast(statMaxHP); - float manaPercentage = static_cast(statMana) / static_cast(statMaxMana); - float staminaPercentage = static_cast(statStamina) / static_cast(statMaxStamina); - - - - int sHeight = 768; - int sWidth = 1280; - - int sHCenter = sHeight / 2; - int sWCenter = sWidth / 2; - - //spdlog::info("healthPercentage: {}", healthPercentage); - - - // Define default bar color - DWORD barColor = 0; - - // Determine bar color based on health percentage - if (healthPercentage > .80) { - barColor = 118; - } - else if (healthPercentage > .50) { - barColor = 13; - } - else { - barColor = 5; - } - - //spdlog::info("barColor: {}", barColor); - - - - // Define the dimensions for the bars - int barWidth = 200; // Width of the bars - int barHeight = 16; // Height of the bars - - // Define the coordinates for the bars - int barX = sWCenter - 100; // Left coordinate of the bars - int barY_HP = 654; // Top coordinate of the HP bar - int barY_Mana = barY_HP + barHeight + 4; // Top coordinate of the Mana bar with separator - int barY_Stamina = barY_Mana + barHeight + 4; // Top coordinate of the Stamina bar with separator - - std::wstring life = L"L: " + strHP + L" / " + strMaxHP; - std::wstring mana = L"M: " + strMana + L" / " + strMaxMana; - std::wstring stamina = L"" + strStamina + L" / " + strMaxStamina; - - int lifeWidth = diablo2::d2_win::get_text_pixel_width(const_cast(life.c_str())); - int manaWidth = diablo2::d2_win::get_text_pixel_width(const_cast(mana.c_str())); - int staminaWidth = diablo2::d2_win::get_text_pixel_width(const_cast(stamina.c_str())); - - - // Calculate the filled widths of the bars - int filledHPWidth = static_cast(healthPercentage * barWidth); - int filledManaWidth = static_cast(manaPercentage * barWidth); - int filledStaminaWidth = static_cast(staminaPercentage * barWidth); - - // at 345 we need to minus the width of the text - sWCenter = barX + 100 - (diablo2::d2_win::get_text_pixel_width(const_cast(mana.c_str())) / 2); - - HWND diabloIIWnd = FindDiabloIIWindow(); - - // Draw the filled HP bar - diablo2::d2_gfx::draw_filled_rect(barX, barY_HP, barX + filledHPWidth, barY_HP + barHeight, barColor, 255); - //DrawFilledRect(diabloIIWnd, barX, barY_HP, barX + filledHPWidth, barY_HP + barHeight, RGB(255, 0, 0)); // Red color for HP - - diablo2::d2_win::draw_text(const_cast(life.c_str()), sWCenter, barY_HP + 15, stat.colorStatValue, 0); - - - - // Draw the filled Mana bar - diablo2::d2_gfx::draw_filled_rect(barX, barY_Mana, barX + filledManaWidth, barY_Mana + barHeight, 140, 255); - //DrawFilledRect(diabloIIWnd, barX, barY_Mana, barX + filledManaWidth, barY_Mana + barHeight, RGB(100, 100, 255)); // Blue color for Mana - diablo2::d2_win::draw_text(const_cast(mana.c_str()), sWCenter, barY_Mana + 15, stat.colorStatValue, 0); - - /* - // Define the number of separators - int numColors = 256; - int numColumns = 4; - int colorsPerColumn = numColors / numColumns; - int separatorHeight = 1; // Height of each separator - int columnOffset = 200; // Offset for each column - - // Iterate over each column - for (int column = 0; column < numColumns; ++column) { - // Calculate the starting X coordinate for this column - int columnX = barX + (column * columnOffset); - - // Draw the filled Mana bars for this column - for (int i = 0; i < colorsPerColumn; ++i) { - int colorIndex = column * colorsPerColumn + i; - int separatorY = barY_Mana + barHeight + i * (separatorHeight + barHeight); - - // Draw the filled Mana bar - diablo2::d2_gfx::draw_filled_rect(columnX, separatorY, columnX + filledManaWidth, separatorY + barHeight, colorIndex, 255); - - // Draw the index number at the same coordinates as the bar - std::wstring indexStr = std::to_wstring(colorIndex); - diablo2::d2_win::draw_text(const_cast(indexStr.c_str()), columnX - 20, separatorY, diablo2::UI_COLOR_DARK_GOLD, 0); - } - } - */ - - - - - - // Draw the filled Stamina bar - // diablo2::d2_gfx::draw_filled_rect(barX, barY_Stamina, barX + filledStaminaWidth, barY_Stamina + barHeight, 12, 255); - //DrawFilledRect(diabloIIWnd, barX, barY_Stamina, barX + filledStaminaWidth, barY_Stamina + barHeight, RGB(255, 255, 0)); // Green color for Stamina - - int statLevel = diablo2::d2_common::get_stat(player, static_cast(12), NULL); - int statLastExp = diablo2::d2_common::get_stat(player, static_cast(29), NULL); - int statNextExp = diablo2::d2_common::get_stat(player, static_cast(30), NULL); - - diablo2::d2_win::set_current_font(diablo2::UI_FONT_16); // Set font to FONT16 - - - - - - } + + //diablo2::d2_win::draw_boxed_text(const_cast(statText.c_str()), stat.x1, stat.y1 + textOffset, 1, 0, stat.colorStat); + //diablo2::d2_win::draw_boxed_text(const_cast(statValueStr.c_str()), stat.x2, stat.y2 + textOffset, 1, 4, stat.colorStatValue); + + // diablo2::d2_win::set_current_font(diablo2::UI_FONT_16); // Set font to FONT16 + + //diablo2::structures::d2_cmp::init_gfx_data(&g_gfxdata); + + //diablo2::d2_gfx::draw_image(&g_gfxdata, 200, 200, 1, 5, 0); + + // instead try to load direct jpg with gdi and insetad ofloading jpg file, specify it bb64 encoded and decode it. + } + + + + } + + if (m_help_enabled) { + + const int windowWidth = 1280; + const int windowHeight = 768; + + const int boxWidth = 1000; + const int boxHeight = 680; + + const int boxX = (windowWidth - boxWidth) / 2; + const int boxY = (windowHeight - boxHeight) / 2; + + const std::string helpText = "This is a sample help screen! You can put help text in here!?"; + + // Draw filled background box + diablo2::d2_gfx::draw_filled_rect(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0, 255); + + + // Draw justified text inside the box with padding + drawJustifiedTextInBox(helpText, boxX, boxY, boxWidth, boxHeight, 0); + + + } + + + diablo2::ui_color_t::UI_COLOR_WHITE; + + // print player health, mana, and stamina bars, lastexp, nextexp, and level + // Get current HP, Mana, and Stamina along with their maximum values + int statHP = diablo2::d2_common::get_stat(player, static_cast(6), NULL) / 256; + int statMaxHP = diablo2::d2_common::get_stat(player, static_cast(7), NULL) / 256; + int statMana = diablo2::d2_common::get_stat(player, static_cast(8), NULL) / 256; + int statMaxMana = diablo2::d2_common::get_stat(player, static_cast(9), NULL) / 256; + int statStamina = diablo2::d2_common::get_stat(player, static_cast(10), NULL) / 256; + int statMaxStamina = diablo2::d2_common::get_stat(player, static_cast(11), NULL) / 256; + + // Convert the integer values to wide character strings + std::wstring strHP = std::to_wstring(statHP); + std::wstring strMaxHP = std::to_wstring(statMaxHP); + std::wstring strMana = std::to_wstring(statMana); + std::wstring strMaxMana = std::to_wstring(statMaxMana); + std::wstring strStamina = std::to_wstring(statStamina); + std::wstring strMaxStamina = std::to_wstring(statMaxStamina); + + diablo2::d2_win::set_current_font(diablo2::UI_FONT_16); // Set font to FONT16 + + // Calculate the percentages of current HP, Mana, and Stamina + float healthPercentage = static_cast(statHP) / static_cast(statMaxHP); + float manaPercentage = static_cast(statMana) / static_cast(statMaxMana); + float staminaPercentage = static_cast(statStamina) / static_cast(statMaxStamina); + + int sHeight = 768; + int sWidth = 1280; + + int sHCenter = sHeight / 2; + int sWCenter = sWidth / 2; + + //spdlog::info("healthPercentage: {}", healthPercentage); + + // Define default bar color + DWORD barColor = 0; + + // Determine bar color based on health percentage + if (healthPercentage > .80) { + barColor = 118; + } + else if (healthPercentage > .50) { + barColor = 13; + } + else { + barColor = 5; + } + + //spdlog::info("barColor: {}", barColor); + + // Define the dimensions for the bars + int barWidth = 200; // Width of the bars + int barHeight = 16; // Height of the bars + + // Define the coordinates for the bars + int barX = 245; // Left coordinate of the bars + int barY_HP = 728; // Top coordinate of the HP bar + int barY_Mana = barY_HP + barHeight + 4; // Top coordinate of the Mana bar with separator + int barY_Stamina = barY_Mana + barHeight + 4; // Top coordinate of the Stamina bar with separator + + std::wstring life = strHP + L" / " + strMaxHP; + std::wstring mana = strMana + L" / " + strMaxMana; + std::wstring stamina = strStamina + L" / " + strMaxStamina; + + // Calculate the filled widths of the bars + int filledHPWidth = static_cast(healthPercentage * barWidth); + int filledManaWidth = static_cast(manaPercentage * barWidth); + int filledStaminaWidth = static_cast(staminaPercentage * barWidth); + + // at 345 we need to minus the width of the text + sWCenter = barX + 100 - (diablo2::d2_win::get_text_pixel_width(const_cast(mana.c_str())) / 2); + + HWND diabloIIWnd = FindDiabloIIWindow(); + + // Draw the filled HP bar + diablo2::d2_gfx::draw_filled_rect(barX, barY_HP, barX + filledHPWidth, barY_HP + barHeight, barColor, 255); + //DrawFilledRect(diabloIIWnd, barX, barY_HP, barX + filledHPWidth, barY_HP + barHeight, RGB(255, 0, 0)); // Red color for HP + diablo2::d2_win::draw_text(const_cast(life.c_str()), sWCenter, barY_HP + 15, diablo2::UI_COLOR_WHITE, 0); + + // Draw the filled Mana bar + diablo2::d2_gfx::draw_filled_rect(barX, barY_Mana, barX + filledManaWidth, barY_Mana + barHeight, 140, 255); + //DrawFilledRect(diabloIIWnd, barX, barY_Mana, barX + filledManaWidth, barY_Mana + barHeight, RGB(100, 100, 255)); // Blue color for Mana + diablo2::d2_win::draw_text(const_cast(mana.c_str()), sWCenter, barY_Mana + 15, diablo2::UI_COLOR_WHITE, 0); + + /* + // Define the number of separators + int numColors = 256; + int numColumns = 4; + int colorsPerColumn = numColors / numColumns; + int separatorHeight = 1; // Height of each separator + int columnOffset = 200; // Offset for each column + + // Iterate over each column + for (int column = 0; column < numColumns; ++column) { + // Calculate the starting X coordinate for this column + int columnX = barX + (column * columnOffset); + + // Draw the filled Mana bars for this column + for (int i = 0; i < colorsPerColumn; ++i) { + int colorIndex = column * colorsPerColumn + i; + int separatorY = barY_Mana + barHeight + i * (separatorHeight + barHeight); + + // Draw the filled Mana bar + diablo2::d2_gfx::draw_filled_rect(columnX, separatorY, columnX + filledManaWidth, separatorY + barHeight, colorIndex, 255); + + // Draw the index number at the same coordinates as the bar + std::wstring indexStr = std::to_wstring(colorIndex); + diablo2::d2_win::draw_text(const_cast(indexStr.c_str()), columnX - 20, separatorY, diablo2::UI_COLOR_DARK_GOLD, 0); } } + */ + + // Draw the filled Stamina bar + // diablo2::d2_gfx::draw_filled_rect(barX, barY_Stamina, barX + filledStaminaWidth, barY_Stamina + barHeight, 12, 255); + //DrawFilledRect(diabloIIWnd, barX, barY_Stamina, barX + filledStaminaWidth, barY_Stamina + barHeight, RGB(255, 255, 0)); // Green color for Stamina + + int statLevel = diablo2::d2_common::get_stat(player, static_cast(12), NULL); + int statLastExp = diablo2::d2_common::get_stat(player, static_cast(29), NULL); + int statNextExp = diablo2::d2_common::get_stat(player, static_cast(30), NULL); + + diablo2::d2_win::set_current_font(diablo2::UI_FONT_16); // Set font to FONT16 + + + + + + + + + + if (!should_draw()) { m_sort_inventory_btn->set_enabled(false); m_sort_inventory_btn->set_visible(false); @@ -546,12 +624,9 @@ private: } }; - void d2_tweaks::client::modules::autosort::init_early() { - } - void d2_tweaks::client::modules::autosort::init() { char acPathToIni[MAX_PATH] = { 0 }; const char* pcIniFile = "\\d2tweaks.ini"; @@ -583,5 +658,4 @@ void d2_tweaks::client::modules::autosort::handle_packet(common::packet_header* diablo2::d2_common::inv_add_item(player->inventory, item, inventorySort->tx, inventorySort->ty, inventoryIndex, true, item->item_data->page); diablo2::d2_common::inv_update_item(player->inventory, item, true); -} - +} \ No newline at end of file diff --git a/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp b/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp index 8c10528..4c6306e 100644 --- a/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp +++ b/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp @@ -9,7 +9,24 @@ #include #include + +#include + +#include +#include +#include + +#include +#include +#include + +#include // For system function + +#include // For ShellExecute + +using namespace d2_tweaks::client::modules; bool m_stats_enabled = false; +bool m_help_enabled = false; d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settings_toggle_menu(token) { m_show = false; @@ -39,6 +56,11 @@ d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settin m_btn_toggle_stats->set_on_click(std::bind(&loot_filter_settings_toggle_menu::toggle_stats_settings_click, this)); + m_btn_toggle_help = static_cast(get_control("m_toggle_help")); + m_btn_toggle_help->set_enabled(true); + m_btn_toggle_help->set_visible(true); + m_btn_toggle_help->set_on_click(std::bind(&loot_filter_settings_toggle_menu::toggle_help_click, this)); + } void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_filter_settings_click() { @@ -55,6 +77,23 @@ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_stats_ m_stats_enabled = !m_stats_enabled; } +void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_help_click() { + //m_help_enabled = !m_help_enabled; + // Open the default OS browser to the URL + const std::string url = "https://im.stoned.io"; +#ifdef _WIN32 + // For Windows + ShellExecute(nullptr, "open", url.c_str(), nullptr, nullptr, SW_SHOWNORMAL); +#elif defined __linux__ || defined __APPLE__ + // For Linux and macOS + system(("xdg-open " + url).c_str()); +#else + // Unsupported platform + // You can add handling for other platforms here +#endif + +} + void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::draw() { m_btn_toggle_stats->set_enabled(diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_INTERFACE)); m_btn_toggle_stats->set_visible(diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_INTERFACE)); diff --git a/src/d2tweaks/server/modules/item_move/item_move_server.cpp b/src/d2tweaks/server/modules/item_move/item_move_server.cpp index 5674acf..84a258f 100644 --- a/src/d2tweaks/server/modules/item_move/item_move_server.cpp +++ b/src/d2tweaks/server/modules/item_move/item_move_server.cpp @@ -13,6 +13,64 @@ #include +#include +#include +#include + +#include // For std::setw +#include +#include +#include // For std::invalid_argument + +#include // Include Windows API header for MessageBox + +// Define your deserialization method for the item structure +diablo2::structures::unit unserialize_item(const std::string& itemcode, std::ifstream& file) { + // Read each line from the file + std::string line; + while (std::getline(file, line)) { + // Split the line into item code and serialized data + std::istringstream iss(line); + std::string code; + std::getline(iss, code, ':'); + if (code == itemcode) { + // Found matching item code, extract serialized data + std::string serializedData; + std::getline(iss, serializedData); + // Convert serialized data from hexadecimal string to binary + std::istringstream hexStream(serializedData); + diablo2::structures::unit item; + for (size_t i = 0; i < sizeof(item); ++i) { + int byte; + if (!(hexStream >> std::hex >> byte)) { + throw std::invalid_argument("Error reading serialized data"); + } + reinterpret_cast(&item)[i] = static_cast(byte); + } + return item; + } + } + // Item code not found + throw std::invalid_argument("Item code not found"); +} + +#include // For std::setw + +void serialize_item(const std::string& itemcode, const diablo2::structures::unit& item, std::ofstream& file) { + // Write item code + file << itemcode << ":"; + + // Write serialized data + for (size_t i = 0; i < sizeof(item); ++i) { + file << std::hex << std::setw(2) << std::setfill('0') << static_cast(reinterpret_cast(&item)[i]); + } + + // Add a newline after each item + file << std::endl; +} + + + MODULE_INIT(item_move) void d2_tweaks::server::modules::item_move::init() { @@ -35,7 +93,13 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g static auto& instance = singleton::instance(); const auto itemMove = static_cast(packet); + const auto key = static_cast(packet)->item_code; + + // Display key in a message box + MessageBox(NULL, key, "Item code", MB_OK | MB_ICONINFORMATION); + const auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item + const char* itemcode = itemMove->item_code; const auto bag = instance.get_server_unit(game, itemMove->bag_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item D2PropertyStrc itemProperty = {}; @@ -49,6 +113,9 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g if (item == nullptr) return true; //block further packet processing + + + const auto inventoryIndex = diablo2::d2_common::get_inventory_index(player, itemMove->target_page, game->item_format == 101); uint32_t tx, ty; @@ -75,6 +142,22 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g diablo2::d2_net::send_to_client(1, client->client_id, &resp, sizeof resp); + + if (itemMove->updateBag == 1) { + + // Serialize item data into binary file + std::string playerName = player->player_data->name; + std::string fileName = "./Save/" + playerName + ".boh"; + std::ofstream outFile(fileName, std::ios::binary); + if (!outFile) { + std::cerr << "Error opening file: " << fileName << std::endl; + return false; + } + + serialize_item(itemcode, *item, outFile); + outFile.close(); + } + return true; } diff --git a/src/d2tweaks/ui/ui_manager.cpp b/src/d2tweaks/ui/ui_manager.cpp index 40834a0..72fdd46 100644 --- a/src/d2tweaks/ui/ui_manager.cpp +++ b/src/d2tweaks/ui/ui_manager.cpp @@ -62,6 +62,16 @@ #include #include +#include // For std::setw +#include +#include +#include // For std::invalid_argument + +#include +#include +#include +using namespace std; + diablo2::structures::unit* g_item1; static LRESULT(__stdcall* g_wnd_proc_original)(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); @@ -127,6 +137,8 @@ struct D2InventoryGridInfoStrc WORD pad0x16; //0x16 }; + + LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static auto& instance = singleton::instance(); @@ -462,9 +474,10 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH) || diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_CUBE) || diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_INVENTORY)) { for (const auto& gem : gemTypes) { // Accessing key and value - const std::string& key = gem.first; + const std::string& _key = gem.first; + const char* key = gem.first.c_str(); const GemType& value = gem.second; - if (strncmp(normCode, key.c_str(), 3) == 0) { + if (strncmp(normCode, key, 3) == 0) { D2PropertyStrc itemProperty = {}; itemProperty.nProperty = value.rowID - 3; itemProperty.nLayer = 0; @@ -475,12 +488,15 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, static d2_tweaks::common::item_move_cs packet; packet.item_guid = g_hoverItem->guid; + packet.item_code = key; packet.bag_guid = gemBagGuid; packet.updateBag = 1; packet.prop = itemProperty.nProperty; packet.val = itemProperty.nMin; packet.target_page = 99; diablo2::d2_client::send_to_server(&packet, sizeof packet); + + } } } diff --git a/src/diablo2/d2client.cpp b/src/diablo2/d2client.cpp index 9c27b30..5c6f60e 100644 --- a/src/diablo2/d2client.cpp +++ b/src/diablo2/d2client.cpp @@ -109,6 +109,13 @@ int32_t diablo2::d2_client::send_to_server_7(BYTE type, DWORD num, DWORD unk1, D return send_to_server_7(type, num, unk1, unk2); } +//D2FUNC(D2CLIENT, SendToServer9, void, __fastcall, (BYTE type, DWORD num, DWORD unk1), 0xDA40) // Interact + +int32_t diablo2::d2_client::send_to_server_9(BYTE type, DWORD num, DWORD unk1) { + static wrap_func_fast send_to_server_9(0xDA40, get_base()); + return send_to_server_9(type, num, unk1); +} + uint32_t diablo2::d2_client::screen_height() { return *reinterpret_cast(get_base() + 0xD40F0); } diff --git a/src/diablo2/d2net.cpp b/src/diablo2/d2net.cpp index 53c684e..ca15bbe 100644 --- a/src/diablo2/d2net.cpp +++ b/src/diablo2/d2net.cpp @@ -15,3 +15,4 @@ int32_t diablo2::d2_net::send_to_client(int32_t queue, int32_t clientId, void* p static wrap_func_std_import send_to_client(10006, get_base()); return send_to_client(queue, clientId, packet, size); } +