Initial commit

This commit is contained in:
Hash Borgir
2024-04-16 21:45:38 -06:00
commit 3159020c38
533 changed files with 135446 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
#pragma once
#include <cstdint>
#include <fw/singleton.h>
#include <diablo2/d2win.h>
#include <string>
#include <vector>
#include <diablo2/structures/gfxdata.h>
// Define the structure to hold stat information
struct StatEntry {
std::wstring stat_display_string;
diablo2::ui_color_t colorStat, colorStatValue;
int x1, y1, x2, y2, is_item_stat, item_type_id, stat = 0; // x1,y1 stat_display_string | x2,y2 statValue
};
extern std::vector<StatEntry> globalStatsVector; // Declaration of the global variable
extern diablo2::structures::gfxdata g_gfxdata; // global gfxdata
extern int randStat;
extern int randStatRangeLow;
extern int randStatRangeHigh;
extern int randStatBool;
namespace diablo2 {
namespace structures {
struct unit;
}
}
namespace d2_tweaks {
namespace common {
struct packet_header;
enum packet_types_cs_t;
enum message_types_t;
}
namespace client {
namespace modules {
class client_module;
}
class client : public singleton<client> {
uint8_t m_module_id_counter;
uint8_t m_tick_handler_id_counter;
modules::client_module* m_modules[0xFF]{ nullptr }; //max 255 modules atm.
modules::client_module* m_tick_handlers[0xFF]{ nullptr }; //max 255 handlers
modules::client_module* m_packet_handlers[0xFF]{ nullptr }; //max 255 handlers because of one-byte packet header
modules::client_module* m_packet_cs_handlers[0xFF]{ nullptr }; //max 255 handlers because of one-byte packet header
public:
explicit client(token);
void init();
void register_module(modules::client_module* module);
void register_tick_handler(modules::client_module* module);
void register_packet_handler(common::message_types_t type, modules::client_module* module);
void register_packet_cs_handler(common::packet_types_cs_t packet, common::message_types_t type, modules::client_module* module);
static diablo2::structures::unit* get_client_unit(uint32_t type, uint32_t guid);
private:
//static void __fastcall game_loop_start();
static void __fastcall handle_standart_packet(common::packet_header* packet, size_t size);
static void __fastcall handle_cs_packet(common::packet_header* packet, size_t size);
static void __fastcall handle_packet(common::packet_header* packet, size_t size);
static void __fastcall game_tick();
static int32_t __stdcall draw_game_ui();
};
}
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include <d2tweaks/client/modules/client_module.h>
namespace d2_tweaks {
namespace ui {
namespace controls {
class label;
}
}
namespace client {
namespace modules {
class auto_gold_pickup final : public client_module {
public:
void init() override;
void init_early() override;
void handle_packet(common::packet_header* packet) override;
void tick() override;
};
}
}
}

View File

@@ -0,0 +1,17 @@
#pragma once
#include <d2tweaks/client/modules/client_module.h>
namespace d2_tweaks {
namespace client {
namespace modules {
class auto_item_pickup final : public client_module {
public:
void init() override;
void init_early() override;
void handle_packet(common::packet_header* packet) override;
void tick() override;
};
}
}
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <d2tweaks/client/modules/client_module.h>
//Inventory auto sort module client side
namespace d2_tweaks {
namespace client {
namespace modules {
class autosort final : public client_module {
public:
void init() override;
void init_early() override;
void handle_packet(common::packet_header* packet) override;
};
}
}
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include <cstdint>
#define MODULE_INIT(module_name) static d2_tweaks::client::modules::module_name g_instance;
namespace d2_tweaks {
namespace common {
struct packet_header;
}
namespace client {
namespace modules {
class client_module {
public:
virtual ~client_module() = default;
client_module();
virtual void init() = 0;
virtual void init_early() = 0;
virtual void draw_ui();
virtual void tick();
virtual void handle_packet(common::packet_header* packet);
virtual void handle_cs_packet(common::packet_header* packet);
};
}
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include <d2tweaks/client/modules/client_module.h>
//Display damage client side
namespace d2_tweaks {
namespace client {
namespace modules {
class damage_display final : public client_module {
public:
void init() override;
void init_early() override;
void handle_packet(common::packet_header* packet) override;
void tick() override;
};
}
}
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <d2tweaks/client/modules/client_module.h>
namespace d2_tweaks {
namespace client {
namespace modules {
class item_drop_message final : public client_module {
public:
void init() override;
void init_early() override;
void handle_packet(common::packet_header* packet) override;
static void GamePacketReceivedInterceptASM();
static void __fastcall GamePacketReceivedIntercept(uint8_t* packet, size_t size);
};
}
}
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <d2tweaks/client/modules/client_module.h>
//Item moving between inventory pages (cube, inventory and stash) by ctrl+click client side
namespace d2_tweaks {
namespace client {
namespace modules {
class item_move final : public client_module {
public:
void init() override;
void init_early() override;
void handle_packet(common::packet_header* packet) override;
};
}
}
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include <d2tweaks/client/modules/client_module.h>
namespace d2_tweaks {
namespace client {
namespace modules {
class loot_filter final : public client_module {
public:
void init() override;
void init_early() override;
};
}
}
}

View File

@@ -0,0 +1,37 @@
#pragma once
#include <diablo2/structures/item_data.h>
#include <cstring>
namespace d2_tweaks {
namespace client {
namespace modules {
struct loot_filter_settings {
size_t size; //struct size
bool alt_only;
bool show_gold;
bool show_runes;
bool show_gems;
bool quality_settings[static_cast<size_t>(diablo2::structures::item_quality_t::ITEM_QUALITY_COUNT)];
char reserved[1004];
static loot_filter_settings& get();
static void save(const char* name);
static void load(const char* name);
static void remove(const char* name);
private:
loot_filter_settings() : size(sizeof(loot_filter_settings)),
alt_only(false), show_gold(true), show_runes(true), show_gems(true), reserved{}
{
memset(quality_settings, 0x1, sizeof quality_settings);
}
};
}
}
}

View File

@@ -0,0 +1,67 @@
#pragma once
#include <fw/singleton.h>
#include <d2tweaks/ui/menu.h>
namespace diablo2 {
namespace structures {
struct unit;
enum class item_quality_t : unsigned;
}
}
namespace d2_tweaks {
namespace ui {
namespace controls {
class checkbox;
}
}
namespace client {
namespace modules {
class loot_filter_settings_menu final : public ui::menu, singleton<loot_filter_settings_menu> {
ui::controls::checkbox* m_altonly;
ui::controls::checkbox* m_show_gold;
ui::controls::checkbox* m_show_runes;
ui::controls::checkbox* m_show_gems;
void(__fastcall* m_draw_dropped_items_names_original)(void*, void*);
void(__fastcall* m_handle_dropped_items_original)(void*, void*);
public:
explicit loot_filter_settings_menu(token);
void reload_settings();
void draw() override;
private:
void register_misc_checkboxes();
void register_quality_checkboxes();
void update_alt_only(bool value);
void update_show_gold(bool value);
void update_show_runes(bool value);
void update_show_gems(bool value);
void update_quality_allowance(bool value, diablo2::structures::item_quality_t quality);
void register_quality_checkbox(const std::string& name, diablo2::structures::item_quality_t quality);
void setup_hooks();
void setup_alt_hook() const;
static bool is_gold(diablo2::structures::unit* item);
static bool is_rune(diablo2::structures::unit* item);
static bool is_gem(diablo2::structures::unit* item);
static bool __fastcall check_alt_item(diablo2::structures::unit* unit);
//draw labels over dropped items
static void __fastcall draw_dropped_items_names(diablo2::structures::unit* unit, void* edx);
//handle hovering over item and actual click
static void __fastcall handle_dropped_items(diablo2::structures::unit* unit, void* edx);
};
}
}
}

View File

@@ -0,0 +1,32 @@
#pragma once
#include <fw/singleton.h>
#include <d2tweaks/ui/menu.h>
namespace d2_tweaks {
namespace ui {
namespace controls {
class button;
}
}
}
namespace d2_tweaks {
namespace client {
namespace modules {
class loot_filter_settings_toggle_menu final : public ui::menu, singleton<loot_filter_settings_toggle_menu> {
ui::controls::button* m_toggle_filter_settings_btn;
menu* m_filter_settings_menu;
bool m_show;
public:
explicit loot_filter_settings_toggle_menu(token);
void toggle_filter_settings_click();
void draw() override;
bool key_event(uint32_t key, bool up) override;
};
}
}
}

View File

@@ -0,0 +1,17 @@
#pragma once
#include <d2tweaks/client/modules/client_module.h>
//Client side patches that are too small to implement as separate modules
namespace d2_tweaks {
namespace client {
namespace modules {
class small_patches final : public client_module {
public:
void init() override;
void init_early() override;
};
}
}
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <d2tweaks/client/modules/client_module.h>
//Test client side module
namespace d2_tweaks {
namespace client {
namespace modules {
class test final : public client_module {
public:
void init() override;
void init_early() override;
void handle_packet(common::packet_header* packet) override;
};
}
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include <cstdint>
#include <d2tweaks/client/modules/client_module.h>
namespace d2_tweaks {
namespace client {
namespace modules {
class trader_update final : public client_module {
public:
void init() override;
void init_early() override;
void handle_packet(common::packet_header* packet) override;
void handle_cs_packet(common::packet_header* packet) override;
void tick() override;
};
}
}
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <cstdint>
#include <d2tweaks/client/modules/client_module.h>
namespace d2_tweaks {
namespace client {
namespace modules {
class transmute final : public client_module {
public:
void init() override;
void init_early() override;
void handle_packet(common::packet_header* packet) override;
void tick() override;
};
}
}
}