Skip to content

fxckdead/l2_middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

45 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

L2 Middlewares

A modern C++20 TCP server implementation for Lineage 2 game emulation, featuring separate Login and Game server components.

๐Ÿš€ Features

  • Login Server: Handles client authentication, server list, and session management
  • Game Server: Manages character selection, world entry, and game logic
  • Modern C++20: Built with modern C++ standards and best practices
  • Cross-platform: Windows and Linux support
  • Encrypted Communication: RSA, Blowfish, and XOR encryption support
  • Modular Architecture: Clean separation between Core, Login, and Game components

๐Ÿ“‹ Prerequisites

Required Software

  • CMake 3.21+ - Build system
  • C++20 compatible compiler:
    • Windows: Visual Studio 2019+ or MinGW-w64
    • Linux: GCC 10+ or Clang 12+
  • vcpkg - C++ package manager
  • Ninja - Build generator (recommended)

Install vcpkg

If you don't have vcpkg installed:

Windows

# Clone vcpkg
git clone https://github.com/Microsoft/vcpkg.git C:\vcpkg
cd C:\vcpkg

# Bootstrap vcpkg
.\bootstrap-vcpkg.bat

# Set environment variable (add to your system PATH)
setx VCPKG_ROOT "C:\vcpkg"

Linux/macOS

# Clone vcpkg
git clone https://github.com/Microsoft/vcpkg.git ~/vcpkg
cd ~/vcpkg

# Bootstrap vcpkg
./bootstrap-vcpkg.sh

# Add to your shell profile (.bashrc, .zshrc, etc.)
export VCPKG_ROOT=~/vcpkg
export PATH=$VCPKG_ROOT:$PATH

Install Ninja (Optional but Recommended)

Windows

# Using chocolatey
choco install ninja

# Or download from https://github.com/ninja-build/ninja/releases

Linux

# Ubuntu/Debian
sudo apt install ninja-build

# CentOS/RHEL
sudo yum install ninja-build

# Arch Linux
sudo pacman -S ninja

๐Ÿ”ง Installation

1. Clone the Repository

git clone [email protected]:fxckdead/l2_middleware.git
cd l2middlewares

2. Install Dependencies

Dependencies are automatically managed by vcpkg. The project requires:

  • boost-asio - Asynchronous networking
  • openssl - Cryptographic functions
  • nlohmann-json - JSON parsing (if needed)

vcpkg will automatically install these when you build the project.

๐Ÿ—๏ธ Build Instructions

The project uses CMake presets for easy building. You can build in Debug or Release mode.

Option 1: Using CMake Presets (Recommended)

Debug Build

# Configure
cmake --preset debug

# Build everything
cmake --build --preset debug

# Or build specific components
cmake --build --preset login-debug    # Login server only
cmake --build --preset game-debug     # Game server only
cmake --build --preset core-debug     # Core library only

Release Build

# Configure
cmake --preset release

# Build everything
cmake --build --preset release

# Or build specific components
cmake --build --preset login-release  # Login server only
cmake --build --preset game-release   # Game server only
cmake --build --preset core-release   # Core library only

Option 2: Manual CMake Build

# Create build directory
mkdir build && cd build

# Configure (Debug)
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake

# Or configure (Release)
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake

# Build
cmake --build . --parallel

Build Outputs

After successful build, executables will be available in:

  • build/debug/out/ or build/release/out/
  • l2_login_server - Login server executable
  • l2_game_server - Game server executable

๐ŸŽฎ Running the Servers

Login Server

./build/debug/out/l2_login_server
# or
./build/release/out/l2_login_server

Game Server

./build/debug/out/l2_game_server
# or  
./build/release/out/l2_game_server

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ core/                          # Shared components
โ”‚   โ”œโ”€โ”€ encryption/               # RSA, Blowfish, XOR encryption
โ”‚   โ”œโ”€โ”€ network/                  # Base networking classes
โ”‚   โ”œโ”€โ”€ packets/                  # Base packet interfaces
โ”‚   โ””โ”€โ”€ utils/                    # Utilities (session keys, etc.)
โ”œโ”€โ”€ login/                        # Login server
โ”‚   โ”œโ”€โ”€ server/                   # Server management
โ”‚   โ”œโ”€โ”€ network/                  # Login connection handling
โ”‚   โ”œโ”€โ”€ packets/                  # Login-specific packets
โ”‚   โ”‚   โ”œโ”€โ”€ requests/            # Client โ†’ Server packets
โ”‚   โ”‚   โ””โ”€โ”€ responses/           # Server โ†’ Client packets
โ”‚   โ””โ”€โ”€ data/                     # Data structures
โ””โ”€โ”€ game/                         # Game server
    โ”œโ”€โ”€ server/                   # Game server management
    โ”œโ”€โ”€ network/                  # Game connection handling
    โ””โ”€โ”€ packets/                  # Game-specific packets
        โ”œโ”€โ”€ requests/            # Client โ†’ Server packets
        โ””โ”€โ”€ responses/           # Server โ†’ Client packets

๐Ÿ”ง Development

Adding New Packets

  1. Create packet classes in src/login/packets/ or src/game/packets/
  2. Update the respective PacketFactory
  3. Add handler methods in connection classes
  4. Update CMakeLists.txt with new source files

Key Files to Understand

  • src/login/network/login_client_connection.cpp - Login client interactions
  • src/game/network/game_client_connection.cpp - Game client interactions
  • src/login/packets/packet_factory.cpp - Login packet creation
  • src/game/packets/packet_factory.cpp - Game packet creation

๐Ÿ› Troubleshooting

Common Build Issues

  1. vcpkg not found: Ensure VCPKG_ROOT environment variable is set
  2. Missing dependencies: Run vcpkg install in project directory
  3. Compiler version: Ensure C++20 support (GCC 10+, MSVC 2019+, Clang 12+)
  4. CMake version: Requires CMake 3.21 or newer

Runtime Issues

  1. Port conflicts: Ensure ports 2106 (login) and 7777 (game) are available
  2. Encryption errors: Check RSA key generation and client compatibility
  3. Connection issues: Verify firewall settings

๐Ÿค Contributing

This is just a Toy project, maybe if I'm able to make it work with basic features I will accept PRs!

About

Lineage 2 implementation of login and gamer server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published