mirror of
https://gitlab.com/hashborgir/d2tweaks-rnd2k.git
synced 2024-11-30 12:45:58 +00:00
page 99 problem fixed, need to clean code
This commit is contained in:
parent
dc76f5627b
commit
43defeb6d8
@ -56,7 +56,7 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
|
||||
// Display key in a message box
|
||||
//MessageBox(NULL, key, "Item code", MB_OK | MB_ICONINFORMATION);
|
||||
|
||||
auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item
|
||||
const auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item
|
||||
|
||||
const auto record = diablo2::d2_common::get_item_record(item->data_record_index);
|
||||
|
||||
@ -93,62 +93,43 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
|
||||
diablo2::d2_game::QUESTS_CreateItem(game, player, reverseDWORD(itemMove->iCode), 1, diablo2::structures::ITEMQUAL_NORMAL, true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (itemMove->tmog == 1) {
|
||||
// here we need to add item to inventory
|
||||
else if (itemMove->tmog == 1) {
|
||||
const auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item
|
||||
diablo2::d2_game::D2GAME_Transmogrify_6FC4A660(game, player, item);
|
||||
diablo2::d2_game::QUESTS_CreateItem(game, player, reverseDWORD('gfv '), 1, diablo2::structures::ITEMQUAL_NORMAL, true);
|
||||
}
|
||||
else if (itemMove->updateBag == 1) {
|
||||
D2PropertyStrc itemProperty = {};
|
||||
itemProperty.nProperty = itemMove->prop;
|
||||
itemProperty.nLayer = 0;
|
||||
itemProperty.nMin = itemMove->val;
|
||||
itemProperty.nMax = itemMove->val;
|
||||
diablo2::d2_common::add_property(bag, &itemProperty, 1);
|
||||
|
||||
const auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, item);
|
||||
|
||||
diablo2::d2_game::D2GAME_Transmogrify_6FC4A660(game, player, item);
|
||||
}
|
||||
else {
|
||||
if (item == nullptr)
|
||||
return true; //block further packet processing
|
||||
|
||||
diablo2::d2_game::QUESTS_CreateItem(game, player, reverseDWORD('gfv '), 1, diablo2::structures::ITEMQUAL_NORMAL, true);
|
||||
}
|
||||
else {
|
||||
D2PropertyStrc itemProperty = {};
|
||||
itemProperty.nProperty = itemMove->prop;
|
||||
itemProperty.nLayer = 0;
|
||||
itemProperty.nMin = itemMove->val;
|
||||
itemProperty.nMax = itemMove->val;
|
||||
diablo2::d2_common::add_property(bag, &itemProperty, 1);
|
||||
const auto inventoryIndex = diablo2::d2_common::get_inventory_index(player, itemMove->target_page, game->item_format == 101);
|
||||
uint32_t tx, ty;
|
||||
if (!find_free_space(player->inventory, item, inventoryIndex, itemMove->target_page, tx, ty))
|
||||
return true; //block further packet processing
|
||||
|
||||
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;
|
||||
|
||||
if (!find_free_space(player->inventory, item, inventoryIndex, itemMove->target_page, tx, ty))
|
||||
return true; //block further packet processing
|
||||
|
||||
//diablo2::d2_common::set_unit_mode(item, 0); // mode 4 - ïðåäìåò íåëüçÿ âçÿòü ìûøêîé èç èíâåíòàðÿ, mode 0 - îáû÷íûé ðåæèì
|
||||
|
||||
// here we need to remove the item if item data page is 99
|
||||
//if (itemMove->target_page == 99) {
|
||||
// diablo2::d2_common::inv_remove_item(player->inventory, item);
|
||||
//}
|
||||
|
||||
|
||||
item->item_data->page = itemMove->target_page;
|
||||
|
||||
//if (itemMove->target_page != 99) {
|
||||
|
||||
diablo2::d2_common::inv_add_item(player->inventory, item, tx, ty, inventoryIndex, false, item->item_data->page);
|
||||
diablo2::d2_common::inv_update_item(player->inventory, item, false);
|
||||
diablo2::d2_game::update_inventory_items(game, player);
|
||||
//}
|
||||
//send update packet
|
||||
resp.item_guid = itemMove->item_guid;
|
||||
resp.target_page = itemMove->target_page;
|
||||
resp.tx = tx;
|
||||
resp.ty = ty;
|
||||
|
||||
const auto client = player->player_data->net_client;
|
||||
|
||||
diablo2::d2_net::send_to_client(1, client->client_id, &resp, sizeof resp);
|
||||
|
||||
return true;
|
||||
}
|
||||
item->item_data->page = itemMove->target_page;
|
||||
diablo2::d2_common::inv_add_item(player->inventory, item, tx, ty, inventoryIndex, false, item->item_data->page);
|
||||
diablo2::d2_common::inv_update_item(player->inventory, item, false);
|
||||
diablo2::d2_game::update_inventory_items(game, player);
|
||||
resp.item_guid = itemMove->item_guid;
|
||||
resp.target_page = itemMove->target_page;
|
||||
resp.tx = tx;
|
||||
resp.ty = ty;
|
||||
const auto client = player->player_data->net_client;
|
||||
diablo2::d2_net::send_to_client(1, client->client_id, &resp, sizeof resp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool d2_tweaks::server::modules::item_move::find_free_space(diablo2::structures::inventory* inv,
|
||||
|
@ -40,8 +40,6 @@
|
||||
#include <vector>
|
||||
#include <CommCtrl.h> // Include for edit control
|
||||
|
||||
#include "d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h"
|
||||
|
||||
// Define a static variable to keep track of the last time the stash window was toggled
|
||||
static std::chrono::steady_clock::time_point lastToggleTime;
|
||||
|
||||
@ -513,6 +511,10 @@ bool isStoneCode(const char* normCode) {
|
||||
}
|
||||
|
||||
void sendPacketAndUpdateProperty(int gemBagGuid, uint32_t iCode, int prop, int val, int item_guid, diablo2::structures::unit* gemBag) {
|
||||
|
||||
// get item using item guid
|
||||
|
||||
|
||||
// Create the packet
|
||||
static d2_tweaks::common::item_move_cs packet;
|
||||
packet.bag_guid = gemBagGuid;
|
||||
@ -545,13 +547,6 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
block = true; // block the game from processing this key
|
||||
}
|
||||
|
||||
// Send transmute packet
|
||||
if (wParam == 'E') {
|
||||
// send packet from server to client
|
||||
block = true; // block the game from processing this key
|
||||
}
|
||||
|
||||
|
||||
if (wParam == 'V') {
|
||||
// Define a cooldown duration in milliseconds
|
||||
constexpr int cooldownDuration = 500; // Adjust this value as needed
|
||||
@ -811,6 +806,8 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
packet.target_page = 99;
|
||||
diablo2::d2_client::send_to_server(&packet, sizeof packet);
|
||||
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
|
||||
// Clear the hovered item after processing
|
||||
(*reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4)) = nullptr;
|
||||
}
|
||||
@ -880,6 +877,8 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
packet.target_page = 99;
|
||||
diablo2::d2_client::send_to_server(&packet, sizeof packet);
|
||||
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
|
||||
// Clear the hovered item after processing
|
||||
(*reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4)) = nullptr;
|
||||
}
|
||||
@ -1195,51 +1194,63 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
if (strncmp(normCode, "rvs", 3) == 0) {
|
||||
// Create the packet
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'rvs ', 396, 1, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
if (strncmp(normCode, "rvl", 3) == 0) {
|
||||
// Create the packet
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'rvl ', 396, 3, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
|
||||
if (strncmp(normCode, "hp1", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'hp1 ', 397, 1, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
if (strncmp(normCode, "mp1", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'mp1 ', 398, 1, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
if (strncmp(normCode, "hp2", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'hp2 ', 397, 3, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
if (strncmp(normCode, "mp2", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'mp2 ', 398, 3, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
if (strncmp(normCode, "hp3", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'hp3 ', 397, 9, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
if (strncmp(normCode, "mp3", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'mp3 ', 398, 9, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
if (strncmp(normCode, "hp4", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'hp4 ', 397, 27, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
if (strncmp(normCode, "mp4", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'mp4 ', 398, 27, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
if (strncmp(normCode, "hp5", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'hp5 ', 397, 81, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
if (strncmp(normCode, "mp5", 3) == 0) {
|
||||
sendPacketAndUpdateProperty(gemBagGuid, 'mp5 ', 398, 81, g_hoverItem->guid, gemBag);
|
||||
diablo2::d2_common::inv_remove_item(player->inventory, g_hoverItem);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user