A Diablo II library for core and simple client functionality, written in Rust for performance, safety and re-usability

Related tags

Utilities libd2
Overview

A Diablo II (Legacy) Library

A Diablo II library for core and simple client functionality, written in Rust for performance, safety and re-usability.

This effort is very much WIP, so it is not available on crates.io yet.

If you are interested in Diablo II and/or Rust, this might be fun!

Goals

  • cross platform without runtime/VM requirement
  • provide game internal data structures and methods
  • savegame load/save support (for e.g. character editors, armory-style webpages)
  • implement the network protocol as fully supported as possible (i.e. however much is known publically)
  • reproduce game state as accurately as possible/needed

Milestones

  1. network protocol support
    • D2GS (plain)
    • D2GS (compressed)
    • BNCS (It if is used in D2R at all)
    • MCP Realm Logon
  2. Game State Data Structures.
    • Items and Buffers (Ground, Inventory, Stash, Cube, Belt)
    • Players (WIP)
    • Players Quest Progression
    • NPCs (WIP)
    • Party/Hostile
    • Game Quest Progression
    • Maps (generate from game seed, take from d2bs)
    • Pathing(?)
  3. Client object
    • shadow client (packet listener w/ game update loop WIP)
    • active client / protocol state machine

How to Build

Building on windows requires some extra steps, otherwise it should be smooth sailing.
At this early stage I haven't created any bindings, but Python/TypeScript would be useful to many people, I guess.

Linux

Tested with Diablo 2 (Legacy) and WINE cargo build --release

Mac Os

cargo build --release (not tested yet)

Windows

You will need to install ncap or the WinPcap Developers Pack as per the libpnet build instructions for Windows (I tested the latter). Then point your user environment variable LIB (create if nonexistent) to the folder where to find Packet.lib i.e. WpdPack/Lib/x64/ from the WinPcap Developers Pack you just downloaded. Then cargo build --release This will get the project building.
Currently, in order to find the internet-connected network interface, it is necessary to disable disconnected-but-enabled interfaces (such as virtual adaperts for VPN).

Usage

One simple use case that is supported now is launching a shadow client to sniff d2gs packets.
Put the following code in your main.rs and run it. Then start up your D2 or D2R game client, join a game and watch the game packets flow.

use libd2r::Client;

fn main() {
    let mut client = Client::new();
    client.start()
}

Please note that currently it does not fill any internal game data structures (state update handling is still WIP). It will just filter, decode and print packets. Also, make sure to not have multiple game clients running as currently their packages will be indistinguishable in the output.

Contributing

This is quite the challenge so any help is appreciated!
There is quite a bit of awesome code out there, but scattered across various sources.
Maybe you want to help translating this d2r savegame utility from go (for D2R save files)?
Or help with the map generation from game seed? It exists in several projects (d2bs, opendiablo, opend2, ...) and shouldn't have changed for D2R.

Disclaimer

Little of this works yet and most probably never will. Unless you feel like contributing, which is welcome, it is mostly an exercise.
Here are some great resources on the original game:

You might also like...
A random.org client library for Rust

random.org A https://random.org client library. The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random

A high-performance SPSC bounded circular buffer of bytes

Cueue A high performance, single-producer, single-consumer, bounded circular buffer of contiguous elements, that supports lock-free atomic batch opera

Monorep for fnRPC (high performance serverless rpc framework)

fnrpc Monorep for fnRPC (high performance serverless rpc framework) cli Cli tool help build and manage functions Create RPC functions Create & Manage

High-performance BitTorrent tracker compatible with UNIT3D tracker software

UNIT3D-Announce High-performance backend BitTorrent tracker compatible with UNIT3D tracker software. Usage # Clone this repository $ git clone https:/

A high-performance Lambda authorizer for API Gateway that can validate OIDC tokens
A high-performance Lambda authorizer for API Gateway that can validate OIDC tokens

oidc-authorizer A high-performance token-based API Gateway authorizer Lambda that can validate OIDC-issued JWT tokens. 🤌 Use case This project provid

Let Tauri's transparent background rendering window be stacked on Bevy's rendering window in real time to run the game with native-level performance!

Native Bevy with Tauri HUD DEMO 将 Tauri 的透明背景渲染窗口实时叠在 Bevy 的渲染窗口上,以使用原生级别性能运行游戏! Let Tauri's transparent background rendering window be stacked on Bev

Verbump - A simple utility written in rust to bump and manage git semantic version tags.

Verbump - A simple utility written in rust to bump and manage git semantic version tags.

A simple, efficient Rust library for handling asynchronous job processing and task queuing.

job_queue Setup cargo add job_queue Usage Create a job use job_queue::{Error, Job, typetag, async_trait, serde}; #[derive(Debug, serde::Deserialize,

Simple ray tracer written in Rust
Simple ray tracer written in Rust

Simple ray tracer written in Rust from scratch I've just finished my first semester at the Faculty of Applied Mathematics and Computer Science at the

Owner
null
Alternative future adapters that provide cancel safety.

cancel-safe-futures Alternative futures adapters that are more cancel-safe. What is this crate? The futures library contains many adapters that make w

Oxide Computer Company 12 Jul 2, 2023
Unlock vGPU functionality for consumer grade GPUs

Rust-based vgpu_unlock Unlock vGPU functionality for consumer-grade NVIDIA GPUs. This tool is to be used with the kernel patches from the main vgpu_un

Matt Bilker 169 Jan 5, 2023
mach-dump can parse Mach-O core dumps taken with lldb from macOS and iOS devices.

mach-dump mach-dump can parse Mach-O core dumps taken with lldb from macOS and iOS devices. It has no external dependencies. Example use std::path::Pa

Tobi 8 Sep 16, 2022
Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc.

cargo-xbuild Cargo-xbuild is a wrapper for cargo build, which cross compiles the sysroot crates core, compiler_builtins, and alloc for custom targets.

Rust OSDev 241 Dec 30, 2022
Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Jerel Unruh 70 Dec 13, 2022
syncmap is a fast, concurrent cache library built with a focus on performance and correctness.

syncmap syncmap syncmap is a fast, concurrent cache library syncmap is a fast, concurrent cache library built with a focus on performance and correctn

Behrouz R.Farsi 15 Dec 2, 2022
Simple git/hg tui client focused on keyboard shortcuts

verco A simple Git/Hg tui client focused on keyboard shortcuts Screenshots Platforms This project uses Cargo and pure Rust stable and works on latest

Matheus Lessa Rodrigues 214 Dec 26, 2022
Dead simple, minimal SPDX License generator library written in Rust.

lice Dead simple, minimal SPDX License generator library written in Rust. Lice is in beta Install | User Docs | Crate Docs | Reference | Contributing

refcell.eth 9 Oct 22, 2023
High-performance, Reliable ChatGLM SDK natural language processing in Rust-Lang

RustGLM for ChatGLM Rust SDK - 中文文档 High-performance, high-quality Experience and Reliable ChatGLM SDK natural language processing in Rust-Language 1.

Blueokanna 3 Feb 29, 2024
High-performance QEMU memory and instruction tracing

Cannoli Cannoli is a high-performance tracing engine for qemu-user. It can record a trace of both PCs executed, as well as memory operations. It consi

Margin Research 412 Oct 18, 2023