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,19 @@
#pragma once
#include <d2tweaks/server/modules/server_module.h>
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class auto_gold_pickup final : public server_module {
public:
void init() override;
void tick(diablo2::structures::game* game, diablo2::structures::unit* unit) override;
bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) override;
bool au_pickup_gold(diablo2::structures::game* game, diablo2::structures::unit* unit, diablo2::structures::unit* item);
};
}
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include <d2tweaks/server/modules/server_module.h>
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class auto_item_pickup final : public server_module {
public:
void init() override;
void tick(diablo2::structures::game* game, diablo2::structures::unit* unit) override;
bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) override;
bool au_pickup_item(diablo2::structures::game* game, diablo2::structures::unit* unit, uint32_t guid);
};
}
}
}

View File

@@ -0,0 +1,35 @@
#pragma once
#include <cstdint>
#include <d2tweaks/server/modules/server_module.h>
//Inventory auto sort module server side
namespace diablo2 {
namespace structures {
struct game;
struct inventory;
struct unit;
}
}
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class autosort final : public server_module {
public:
void init() override;
bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player,
common::packet_header* packet) override;
private:
bool sort(diablo2::structures::game* game, diablo2::structures::unit* player, uint8_t page);
bool find_free_space(diablo2::structures::inventory* inv,
diablo2::structures::unit* item, int32_t inventoryIndex, char page, uint32_t& x, uint32_t& y, bool isCharmZone);
};
}
}
}

View File

@@ -0,0 +1,32 @@
#pragma once
#include <cstdint>
#include <d2tweaks/server/modules/server_module.h>
//Display damage server side
namespace diablo2 {
namespace structures {
struct inventory;
struct game;
struct unit;
}
}
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class damage_display final : public server_module {
public:
void init() override;
bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player,
common::packet_header* packet) override;
void tick(diablo2::structures::game* game, diablo2::structures::unit* unit) override;
};
}
}
}

View File

@@ -0,0 +1,16 @@
#pragma once
#include <d2tweaks/server/modules/server_module.h>
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class identify_on_pickup final : public server_module {
public:
void init() override;
};
}
}
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <d2tweaks/server/modules/server_module.h>
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class item_drop_message final : public server_module {
public:
void init() override;
void tick(diablo2::structures::game* game, diablo2::structures::unit* unit) override;
bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) override;
};
}
}
}

View File

@@ -0,0 +1,34 @@
#pragma once
#include <cstdint>
#include <d2tweaks/server/modules/server_module.h>
//Item moving between inventory pages (cube, inventory and stash) by ctrl+click server side
namespace diablo2 {
namespace structures {
struct inventory;
struct game;
struct unit;
}
}
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class item_move final : public server_module {
public:
void init() override;
bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player,
common::packet_header* packet) override;
private:
bool find_free_space(diablo2::structures::inventory* inv,
diablo2::structures::unit* item, int32_t inventoryIndex, char page, uint32_t& x, uint32_t& y);
};
}
}
}

View File

@@ -0,0 +1,38 @@
#pragma once
#include <stdint.h>
#define MODULE_INIT(module_name) static d2_tweaks::server::modules::module_name g_instance;
namespace diablo2 {
namespace structures {
struct game;
struct unit;
}
}
namespace d2_tweaks {
namespace common {
struct packet_header;
}
namespace server {
namespace modules {
class server_module {
public:
virtual ~server_module() = default;
server_module();
virtual void init() = 0;
/**
* \brief
* \param game
* \param player
* \param packet
* \return true - block further packet processing, false - pass packet to game
*/
virtual bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet);
virtual void tick(diablo2::structures::game* game, diablo2::structures::unit* unit);
};
}
}
}

View File

@@ -0,0 +1,16 @@
#pragma once
#include <d2tweaks/server/modules/server_module.h>
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class test final : public server_module {
public:
void init() override;
};
}
}
}

View File

@@ -0,0 +1,32 @@
#pragma once
#include <cstdint>
#include <d2tweaks/server/modules/server_module.h>
namespace diablo2 {
namespace structures {
struct inventory;
struct game;
struct unit;
}
}
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class trader_update final : public server_module {
public:
void init() override;
void tick(diablo2::structures::game* game, diablo2::structures::unit* unit) override;
bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) override;
//private:
// bool find_free_space(diablo2::structures::inventory* inv, diablo2::structures::unit* item, int32_t inventoryIndex, char page, uint32_t& x, uint32_t& y);
// bool send_to_cube(diablo2::structures::game* game, diablo2::structures::unit* player, diablo2::structures::unit* item);
// bool move_item_to(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet);
};
}
}
}

View File

@@ -0,0 +1,32 @@
#pragma once
#include <cstdint>
#include <d2tweaks/server/modules/server_module.h>
namespace diablo2 {
namespace structures {
struct inventory;
struct game;
struct unit;
}
}
namespace d2_tweaks {
namespace server {
class server;
namespace modules {
class transmute final : public server_module {
public:
void init() override;
void tick(diablo2::structures::game* game, diablo2::structures::unit* unit) override;
bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) override;
private:
bool find_free_space(diablo2::structures::inventory* inv, diablo2::structures::unit* item, int32_t inventoryIndex, char page, uint32_t& x, uint32_t& y);
bool send_to_cube(diablo2::structures::game* game, diablo2::structures::unit* player, diablo2::structures::unit* item);
bool move_item_to(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet);
};
}
}
}

View File

@@ -0,0 +1,55 @@
#pragma once
#include <cstdint>
#include <fw/singleton.h>
#include <d2tweaks/common/protocol.h>
#include <functional>
namespace diablo2 {
namespace structures {
enum class unit_type_t;
struct game;
struct inventory;
struct unit;
struct net_client;
}
}
namespace d2_tweaks {
namespace common {
struct packet_header;
}
namespace server {
namespace modules {
class server_module;
}
class server : public singleton<server> {
uint8_t m_module_id_counter;
uint8_t m_tick_handler_id_counter;
modules::server_module* m_modules[0xFF]{ nullptr }; //max 255 modules atm.
modules::server_module* m_tick_handlers[0xFF]{ nullptr }; //max 255 modules atm.
modules::server_module* m_packet_handlers[0xFF]{ nullptr }; //max 255 handlers because of one-byte packet header
public:
explicit server(token);
void init();
void send_packet(diablo2::structures::net_client* client, common::packet_header* packet, size_t size);
bool handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet);
void register_module(modules::server_module* module);
void register_tick_handler(modules::server_module* module);
void register_packet_handler(common::message_types_t type, modules::server_module* module);
diablo2::structures::unit* get_server_unit(diablo2::structures::game* game, uint32_t guid, diablo2::structures::unit_type_t type);
void iterate_server_units(diablo2::structures::game* game, diablo2::structures::unit_type_t type,
const std::function<bool(diablo2::structures::unit*)>& cb);
private:
static int32_t __fastcall net_tick(diablo2::structures::game* game, diablo2::structures::unit* unit, int32_t a3, int32_t a4);
};
}
}