Jump to content

I'm rebuilding the Metin2 server (TMP4) in Rust – here's where I am


Recommended Posts

Hi everyone! πŸ‘‹

I'd like to share a project I'm working on: a complete rewrite of the TMP4 game server in the Rust programming language.

Β 

What is this, in simple words?

A Metin2 private server has two parts:

The client: the game you launch on your PC.

The server: the program that handles accounts, monsters, fights, items, quests and saving your character.

TMP4 is a well-known server base written in C++. I'm rewriting that server in Rust, a modern and safer language.

Same client: you keep the normal, unmodified TMP4 client and play as usual.

Same data: maps, quests, items, monsters and the MySQL database all come from TMP4.

Same behaviour: every system is copied from the original TMP4 code, with the same formulas, drops and messages.

The goal is to reach 100% of what TMP4 does first, then improve from there.

Β 

TMP4 vs Rust: stability and security

Β 

Bad packets sent by cheaters

❌ TMP4: a badly formed packet can crash the server

βœ… Rust: every packet is checked. All 55 client packet types were tested with random garbage, and nothing crashed.

Β 

Memory bugs (a classic source of crashes and exploits)

❌ TMP4: possible anywhere in the code, and compiler warnings are turned off

βœ… Rust: impossible by design. Only 4 small "unsafe" spots exist, all in the Lua quest bridge.

Β 

Database hacking (SQL injection)

❌ TMP4: about 30 database queries are built by hand from text

βœ… Rust: every query is protected automatically

Passwords

❌ TMP4: old MySQL hashing

βœ… Rust: modern hashing (argon2)

Β 

A bug during one player's action

❌ TMP4: can take the whole server down

βœ… Rust: only that player is disconnected, and everyone else keeps playing

Β 

Item duplication when saving

🟑 TMP4: depends on a separate cache program

βœ… Rust: every item keeps a fixed ID, and saves stay safe even when many players log out at once (0 errors in my tests)

Β 

Where it runs

❌ TMP4: FreeBSD only, 32 bits, so 4 GB of memory at most

βœ… Rust: Windows and Linux, 64 bits

Β 

How to build it

❌ TMP4: complex Makefiles and old libraries

βœ… Rust: one command, cargo build

Β 

Β 

Is it fast?

I tested it with 500 fake players (bots) on one PC with a Ryzen 9 (8 cores). The server, the database and the bots all ran on that same PC.

I made the test hard on purpose: around 250 players packed into each starting village, all walking, attacking and chatting at the same time.

βœ… 11 ms reaction time for 95% of actions (anything under 50 ms feels instant)

βœ… 29 ms at worst

βœ… About 300 MB of memory used

βœ… 0 disconnects or errors

βœ… 1.6 seconds to start with all 65 maps and ~52,000 monsters

βœ… 7.5 ms to save a character with 100 itemsΒ 

⚠️ To be honest: I couldn't run the original TMP4 on the same PC, because it needs 32-bit FreeBSD. So there is no measured speed comparison yet. A fair side-by-side test on the same hardware is planned.

Β 

What already works?

βœ… done Β· 🟑 partly done Β· ❌ not yet

Β 

Login and characters

βœ… Login, character creation / deletion / rename, empire choice

βœ… Guild emblems (upload and display)

Β 

The world

βœ… All 65 maps, walls, safe zones in towns, portals

βœ… All monster spawns (~52,000 monsters)

βœ… Monsters chase you and use skills

βœ… Archers and mages attack from range

βœ… Bosses have their special abilities

βœ… Dungeons: flame dungeon, catacombs, devil tower, spider queen, heaven's cave…

Β 

Quests

βœ… All 237 TMP4 quests work, from the tutorial to the level 99+ story

Your character

βœ… Stats, all bonuses, buffs, level-up, exp

βœ… All 77 skills, including training up to Perfect Master

βœ… PvP duels, PK mode, alignment

βœ… Polymorph (marbles), horse (visible, feed it, ride it), pets

Β 

Items

βœ… Inventory with real item sizes, belt inventory

βœ… Drops, upgrades +0 to +9, bonuses up to 7, stones in sockets

βœ… NPC shops, your own private shop, trading, storage, item mall

βœ… Crafting (cube), full Dragon Soul, fishing, mining

Β 

Playing with others

βœ… Party with exp sharing and roles

βœ… Guild ranks, skills and exp donations

βœ… Guild wars with scores, spectators and bets

βœ… Guild land and buildings

βœ… Friends list, private messages, shout

βœ… Marriage: engagement, wedding ceremony, couple bonuses

Β 

Events

βœ… GM event flags (bonus exp / drop / gold)

βœ… Event drops (Halloween, Easter, Christmas…)

βœ… OX quiz, duel arena, three-kingdoms war

βœ… Castle siege, Blue Dragon boss

🟑 Monarch (emperor) system: written, being integrated and tested

Β 

Server administration

🟑 GM commands: the main ones work, some specialised ones are still missing

❌ Full action logs (gold, item and login history)

❌ Account and IP bans

❌ All of TMP4's configuration options

❌ Multi-channel: each channel is separate for now, so you can't whisper a friend on another channel yet

Β 

How do I know it works?

βœ… About 2,100 automatic tests

βœ… Many of them simulate real players connecting with the real TMP4 data: dungeons, weddings, guild wars, fishing, trading, logging out and back in

βœ… Every change must pass all of them before it goes in

Β 

What's next?

Finish integrating the monarch system

Remaining GM commands, logs, bans and config options

Multi-channel

A fair speed comparison against TMP4 on the same PC

An open test with real players

Questions, ideas and feedback are very welcome, especially if you know TMP4's weird little behaviours! πŸ™‚

Edited by Matamune
edit space

Update i add a complete web dashboard for the serverfiles with some nocode feature for make quest and "plugin"

What's in it: Operations β€’ Dashboard: live stats per channel (players online per map and empire, tick times, queue depth), with graphs. β€’ Players: search, kick, temp or permanent bans with a reason, and an inventory viewer that works even when they're offline. β€’ Announcements: to all channels or a single map. β€’ Plugins: status per channel, perf per event, enable, disable, reload, deploy and uninstall. There's also a "Test" mode that simulates an event without actually giving anything to anyone. β€’ Event flags manager. Content creation (no-code) β€’ Quest editor: opens all the existing TMP4 quests and saves them back byte-for-byte identical when you don't change anything. β€’ Two views: Cards, where each line reads as plain English-style sentences for beginners, and a Blueprint node graph like Unreal. β€’ Plus diff, history, a state graph and a dialogue preview. β€’ It warns you when another quest or plugin already reacts to the same event, for example "this mob already drops that item in quest X". β€’ Plugin editor: same Cards/Blueprint approach. It generates Lua plugins with hot reload, and comes with templates like a world boss, daily login rewards, weekend double drop and an /online command. Game data (inspired by metin2.tools, but wired to the live server) β€’ Proto editor: items and mobs, with real icons, filters, bulk edit and TXT/SQL import/export. β€’ Drops and chests: mob_drop_item, common drops and special_item_group, showing the real drop %. It can also answer "who gives this item?" and run a loot simulator. β€’ NPC shops: shown in the real in-game 5Γ—8 window with icons. β€’ Regen editor: spawn zones drawn on the real map images pulled from the client packs, drag and resize with the mouse, with live mobs and players shown on top. β€’ Damage calculator: uses the server's actual combat code, not a reimplementation, and can compare two builds step by step. β€’ PNG β†’ TGA icon converter. β€’ Client assets: reads the client's .eix/.epk packs directly to extract maps, item and skill icons. Every change is validated, versioned (history and rollback) and hot-reloaded on every channel, so no restart is needed.

  • Metin2 Dev 1
On 10/2/2026 at 5:41 AM, Matamune said:

Update i add a complete web dashboard for the serverfiles with some nocode feature for make quest and "plugin"

What's in it: Operations β€’ Dashboard: live stats per channel (players online per map and empire, tick times, queue depth), with graphs. β€’ Players: search, kick, temp or permanent bans with a reason, and an inventory viewer that works even when they're offline. β€’ Announcements: to all channels or a single map. β€’ Plugins: status per channel, perf per event, enable, disable, reload, deploy and uninstall. There's also a "Test" mode that simulates an event without actually giving anything to anyone. β€’ Event flags manager. Content creation (no-code) β€’ Quest editor: opens all the existing TMP4 quests and saves them back byte-for-byte identical when you don't change anything. β€’ Two views: Cards, where each line reads as plain English-style sentences for beginners, and a Blueprint node graph like Unreal. β€’ Plus diff, history, a state graph and a dialogue preview. β€’ It warns you when another quest or plugin already reacts to the same event, for example "this mob already drops that item in quest X". β€’ Plugin editor: same Cards/Blueprint approach. It generates Lua plugins with hot reload, and comes with templates like a world boss, daily login rewards, weekend double drop and an /online command. Game data (inspired by metin2.tools, but wired to the live server) β€’ Proto editor: items and mobs, with real icons, filters, bulk edit and TXT/SQL import/export. β€’ Drops and chests: mob_drop_item, common drops and special_item_group, showing the real drop %. It can also answer "who gives this item?" and run a loot simulator. β€’ NPC shops: shown in the real in-game 5Γ—8 window with icons. β€’ Regen editor: spawn zones drawn on the real map images pulled from the client packs, drag and resize with the mouse, with live mobs and players shown on top. β€’ Damage calculator: uses the server's actual combat code, not a reimplementation, and can compare two builds step by step. β€’ PNG β†’ TGA icon converter. β€’ Client assets: reads the client's .eix/.epk packs directly to extract maps, item and skill icons. Every change is validated, versioned (history and rollback) and hot-reloaded on every channel, so no restart is needed.

What API are you using for the dashboard live stats?
Those functions on a dashboard are useful stuff.

On 10/6/2026 at 11:39 AM, friendtm said:

What API are you using for the dashboard live stats?
Those functions on a dashboard are useful stuff.

Β No external API, it's all homemade. Each game channel exposes its own stats (players, per map, tick time, memory) on a local-only JSON port. The admin panel polls every channel every 5 s, keeps a short history, and the dashboard page fetches that from the panel's /api/metrics on a timer. No websocket, no third-party service.

  • Flame 1

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Γ—
Γ—
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.