saving added gems to .boh file working

This commit is contained in:
Hash Borgir 2024-04-28 14:15:06 -06:00
parent 87d4758efc
commit 78fcd692b2
5 changed files with 45 additions and 7 deletions

BIN
D2tweaks.aps Normal file

Binary file not shown.

View File

@ -279,6 +279,7 @@
<ClInclude Include="include\diablo2\utils\screen.h" />
<ClInclude Include="include\fw\pool.h" />
<ClInclude Include="include\fw\singleton.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="vendor\D2Template\D2Template.h" />
<ClInclude Include="vendor\D2Template\D2TemplateConstants.h" />
<ClInclude Include="vendor\D2Template\D2TemplateDataTables.h" />

14
resource.h Normal file
View File

@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by D2tweaks.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -96,7 +96,7 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
const auto key = static_cast<common::item_move_cs*>(packet)->item_code;
// Display key in a message box
MessageBox(NULL, key, "Item code", MB_OK | MB_ICONINFORMATION);
//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;
@ -148,7 +148,8 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
// 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);
// Open file in append mode
std::ofstream outFile(fileName, std::ios::binary | std::ios::app);
if (!outFile) {
std::cerr << "Error opening file: " << fileName << std::endl;
return false;
@ -158,6 +159,7 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
outFile.close();
}
return true;
}

View File

@ -58,18 +58,17 @@
#include <random>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <iomanip> // For std::setw
#include <sstream>
#include <string>
#include <stdexcept> // For std::invalid_argument
#include <iostream>
#include <vector>
#include <string>
#include <CommCtrl.h> // Include for edit control
using namespace std;
diablo2::structures::unit* g_item1;
@ -137,6 +136,12 @@ struct D2InventoryGridInfoStrc
WORD pad0x16; //0x16
};
// Declare a variable to hold the handle to the edit box control
HWND g_hEditBox = nullptr;
// Declare a variable to store the input text
std::vector<char> g_inputText(256, '\0'); // Adjust the size according to your needs
LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
@ -366,6 +371,19 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
const auto record = diablo2::d2_common::get_item_record(g_hoverItem->data_record_index);
char* normCode = record->string_code;
if (strncmp(normCode, "ib1", 3) == 0) {
// display Messagebox with normCode
//MessageBoxA(0, normCode, "normCode", 0);
// we need to accept user input here
// we need to get the user input and store it in a variable
// we need to use win32 api to get the user input using editbox control, simple inputbox, not using resources.rc
}
const auto player = diablo2::d2_client::get_local_player();
auto pInventory = player->inventory;
@ -397,7 +415,7 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
int rowID;
};
std::unordered_map<std::string, GemType> gemTypes = {
static std::unordered_map<std::string, GemType> gemTypes = {
{"gcv", {1, 382}}, // Chipped Amethyst
{"gcw", {1, 383}}, // Chipped Diamond
{"gcg", {1, 384}}, // Chipped Emerald
@ -477,7 +495,8 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
for (const auto& gem : gemTypes) {
// Accessing key and value
const std::string& _key = gem.first;
key = gem.first.c_str();
key = gem.first.c_str();
const GemType& value = gem.second;
if (strncmp(normCode, key, 3) == 0) {
D2PropertyStrc itemProperty = {};
@ -488,6 +507,8 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
diablo2::d2_common::add_property(gemBag, &itemProperty, 0);
diablo2::d2_client::play_sound(record->drop_sound, nullptr, 0, 0, 0);
//MessageBoxA(0, key, "key", 0);
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = g_hoverItem->guid;
packet.item_code = key;