- Joined
- Feb 25, 2009
- Messages
- 498
- Reaction score
- 217
4Dev
4Story 5.0, rebuilt from the ground up
4 months · 117 commits · 5 servers rewritten · ~80,000 lines of new C# · 1,100+ automated tests
4Story 5.0, rebuilt from the ground up
4 months · 117 commits · 5 servers rewritten · ~80,000 lines of new C# · 1,100+ automated tests
I'm sharing it because I think too many peoples are buying shits with lot of backdoor and come on discord to cry and ask me help for sources I don't understand
Just want to create a new standard with so many changes that everybody will be up to date and happy to have a good server running for 0$.
To view the content, you need to sign in or register
| Before | After | |
|---|---|---|
| 14.1 s | 4.0 s | |
| 154 MB | 4.3 MB (-97%) | |
| 859 ms | 31 ms (27x faster) | |
| 25% of a core | 1% | |
| 234.7 ms | 0.042 ms (5,600x faster) | |
| - | 240 MB RAM, 0 disconnects | |
| - | ~85 KB | |
| Direct3D 9 + D3DX | bgfx (by default) | |
| everywhere | gone (-560 KB) | |
| ~36 s | bulk loads + indexes |
- Login, World, Map, Patch and Control servers are all rewritten from scratch. They are byte-compatible with the original client and run on the original databases, unchanged.
- No more Windows services, registry keys or ODBC: one docker compose up boots the database and the whole cluster, on Windows or Linux.
- The map server alone is a port of ~54,000 lines of C++. Packet layouts were checked field by field against the original code.
- It has ~940 tests; the world server has 128.
Combat: skills, crits, blocks, buffs and debuffs, loop skills, multi-missile skills, a data-driven monster AI covering all 3,536 monsters
6,261 quests, loot, party exp, trade, personal shops, mail, crafting, cabinet
Evocator: every summon, monster taming, summons fighting in PvP
200+ mounts (imported from 4Classic, 4Genesis and 4Revelation), pets and companions
PvP: points, ladder, honour titles, duels
All 25 territories: 12 forts, 4 castles (god balls and towers), 8 mission wars, sky garden
Guilds: cabinet, board, fame, recruiting, mercenaries, castle guards, guild level and guild skills
380+ costumes: 7 from the official Gameforge client, 133 from 4Genesis, 90 from 4Revelation, with wings, auras and chakras
- Sky garden only gave a result for the first war after a server start.
- Every other fort war lost its "defended" result.
- Anyone could accept a resurrection to refill to full HP/MP, even alive.
- Deleted companions came back from the dead.
- Every Summoner character creation failed.
- Guild level and exp were never saved.
- Guild skills were deleted on the next update.
- A second audit of the guild port against the C++ fixed invite, kick, duty and peerage checks, and the founder was never saved as a member.
- …and dozens more.
- TBot logs in, creates characters and plays: parties, mail, pets, duels, PvP, a full castle war, a guild's whole life.
- Each run makes hundreds of byte-level checks, and the stress mode drives 400 players.
- Builds on VS 2026, CMake and clang-cl. GPU skinning, 16x anisotropic filtering, longer view distance.
New render layer: the client now draws through bgfx (a shader that emulates the old fixed-function pipeline). D3DX replaced by our own math header.
No more MFC: the app and window run on plain Win32, and the core classes are rewritten (byte-identical file format).
SDL3 integration in progress, the next step towards 64-bit and Linux.- Audio now runs on miniaudio; settings live in config.ini instead of the registry.
Item Browser (web): every item with its correct icon (7,099 of 7,706).
UI Editor (web): edit the game UI visually and save back byte-identical.
ClassicPort, OfficialPort and GenesisPort: break the 4Classic, 4Genesis and 4Revelation asset encryption and import their content.
To view the content, you need to sign in or register
It's WIP. I do not provide any help to setup ! (for now)
Full changelog in the next post
June 15 → October 17, 2026. [C++] marks a bug that was already in the original game.
| Server | Lines | Tests | Handlers | Port |
|---|---|---|---|---|
| Map | 48.5k | ~940 | ~273 | 5816 |
| World | 19.2k | 138 | ~194 (all) | 3816 |
| Control | 3.7k | 17 | 64 (all) | 3615 |
| Login | 2.9k | 17 | 13 (all) | 4816 |
| Patch | 1.5k | 14 | 9 (all) | 3715 |
- Every server: .NET Generic Host, Serilog, async sockets and Microsoft.Data.SqlClient. No ATL, registry or ODBC DSN.
- Each one runs as a console exe (win-x64 / linux-x64) or in Docker.
- They use the original databases and stored procedures unchanged, and stay byte-compatible with the original client.
- Not ported: the relay plane (there is no relay server in this release).
Network & world
- Encrypted client listener plus a world link that reconnects. One serialized game task, so no locks.
- Full 10-step enter handshake. Runs without a DB (synthesized character).
- Movement, jump and block, with a speed-hack kick.
- 3×3 cell visibility grid (64-unit cells), with enter/leave diffs.
- Chat: near chat and whispers handled locally, everything else relayed to the world. Sender spoofing is refused.
- Inventory, gear, skills, buffs and hotkeys loaded and serialized in the C++ byte order.
- Stat engine: 6 primary stats, HP/MP, melee/ranged/magic AP, DP, levels, attack speed, crit. The CHARSTATINFO packet (87 bytes) matches exactly.
- Moving items: move, split, swap, merge, drop. Equipping checks class, slot, level and wrap. Two-handed weapons evict the off-hand item.
- Potions, three-tier money, repair (single, equipped, all), NPC buy/sell, country-gated NPCs.
- Spawns from 4 charts: 18,346 points and 18,823 slots. Weighted type pick, scatter radius, respawn on death.
- Two-packet attack (skill use, then defend). The server recalculates damage and never trusts client numbers.
- Skill cost, cooldowns and group delays. Skill-data scaling, physical/magic and melee/ranged.
- Hit, miss and crit (+20–40%). Shield block, magic block, MP damage, lifedrain, HP/MP transfer.
- Buff engine: stacking rules, expiry, dispel, cure. Buffs are saved and restored at relog.
- Regen every 3 s. Battle mode. Monsters hit players. Player death and revival (town 30%, on the spot 40%).
- Roam, chase and leash. A real hate table: warriors generate ×1.5, and a newcomer needs 10% more hate to take the target.
- Aggro on sight.
- Data-driven AI engine (TAICHART): 14 triggers, 15 opcodes, 3 condition kinds. 2 scripts cover 3,192 aggressive and 344 passive monsters.
- Kill ownership at 10% damage. EXP formula, level-ups, anti-farm rule (no EXP at 10+ levels above, no drops at 25+).
- Money and item drops on corpses. Party EXP bonus and party loot.
- Quests: 6,261 quests, 5,712 conditions, 4,322 rewards, 10,687 terms. 18 subtypes. Timers, quest spawns, drops.
- Map switches and gates, with quest hooks.
- Cabinet (3×16 slots), atomic trade, personal shop.
- Character, quests and the full inventory, saved every 30 min, on logout and on shutdown, off-thread.
- Item changes are also saved within 1 tick, so a crash no longer loses up to 30 min of items.
- float vs double pow made stats and defence off by one.
- The equip-level (ELD) check let any level wear any gear.
- Monster DP was missing a term.
- Wrong hit and perform flags, damage-map truncation, client-echoed values.
- The .NET config duplicated channel 1, which doubled every monster (36,692 spawns).
- Quest spawns never expire.
- Free NPC buy through the quest-id path.
- Party cap: the client shows 6, the server allows 7.
- Revive without being dead.
- Buying from your own shop.
- Repair is free when the level chart row is missing.
- The AI "change host" condition always passes. Kept on purpose, since monster behaviour is balanced around it.
Party, mail, teleport, crafting
- Party relay with HP bars. Invites to dead players answer "busy". Only the leader can kick.
- Mail: normal (100 copper), package (300), bill (900). Unpaid bills go back after 3 days. A failed send no longer eats the postage.
- Long-range teleports through the world, with a loading screen.
- Upgrade (purify, gems, appearance, options, wrap, ELD, dye…), refine with 1–3 materials, gamble box.
- Hotkeys saved. Extra bags. Return point.
- Death penalty: 0.3% of base stats per step, recovering over time. Priest resurrection asks the dead player first.
- [C++] Refining with no material divided by zero.
- [C++] Accessory option search could loop forever.
- [C++] A living player could accept a resurrection and refill to full.
- [C++] Death penalty could wrap below 0.
- Mounts: timed or permanent, renewal, list at login. Calling and riding are shown to everyone. Saddles. Teleport dismounts you.
- Companions: 5 slots, species taken from the rune chart, levels 1–20, upgrade points up to 30, food and exp caps, gear, bonus reroll.
- Companions lose stamina and gain exp every 60 s, give owner stat bonuses, and earn a PvP bonus.
- [C++] A deleted companion came back at the next login.
- [C++] Deleting with no companion summoned produced a bogus slot.
- [C++] Stamina above 32,767 broke the whole companion save.
- Placed objects (rain, crystals, eyes, fireworks…) and main summons (rituals, mine, doppelganger).
- Summons cast their own skills with their own pools and cooldowns, using 55% of their owner's gear. Auto-AI summons deal ×3.
- The owner gets kill credit and hate. Monsters can target and kill summons. The Protection Crystal aura buffs everyone in range.
- Taming: Enslave Monster (617) on a corpse, Evocate Monster (618) to call it. The tamed monster comes back at login.
- Summons are saved at logout with their remaining life and buffs.
- Skill learning costs gold and skill points, with level, tab, parent and class checks. One-skill and full reset scrolls.
- 17 weapon masteries gate equipment. 73 weapon-bound buffs drop when the weapon is unequipped.
- Skill items, random skills (doubt potion, metamorphosis, lucky bag), loop/channelled skills, multi-missiles.
- Item use delays enforced. Stance rules.
- Buffs and debuffs on monsters and summons: DP down, AP and crit up, disarm, break armour, immunities.
- Buff erasers on attack and on hit, enemy dispel, damage share with your summon.
- Cooldown fix: before it, every skill cooldown showed as 0 on the client.
- [C++] A missing skill level row crashed the C++ handler.
- Corpse loot with a one-looter lock, hunter-mode party loot, take-all.
- NPC shops by class and country, PvP-point shops, conditional teleporters.
- Money pouches, special boxes, exp books.
- Exp boosts and premium (+20% for 4 h a day), saved across logout.
- Name change (umlauts allowed, no duplicates). Country change (level 9, or 130–179 via Broa). Daily aid country.
- Face, hair, race and sex change. Helmet hide. Profile comment. Target query. Inspect a player on another map server.
- Real defence, blocks and buffs in PvP. Debuffs land on players.
- Points: total and useable. Level-gap rules. The same victim 3 times in 600 s pays nothing. Party partners in view get 12 points.
- Last 10 kills and deaths recorded.
- Duel on map 0: 10 s countdown, knockout heals both, draw after 5 min. Enemies can break a duel up.
- Monthly ladder (33 slots per country, warlord, heroes) and titles (honour, gold, kills, win rate, quests, tournaments).
- Summons in PvP: they can be hit and killed, and their kills count for their owner.
- Zone buffs, item level cap, peace zones, war phases with news, war-info window.
- Mission wars (8): suspended spawns, gatekeeper capture, 200 PvP points plus a reward item.
- Sky garden: 3 points, the boss kill wins instantly, 360 PvP points, side-based portals.
- Forts (12): gates, a boss after the first gate falls, capture by top guild damage, points and records.
- Fort owners get their own NPCs and portals (6001–6015) and discounts on shops, skills, repair and crafting.
- Castles (4): sign-up, 1,800 power (+ a share of 800 from forts), 2 god balls per side moving 1 power per second.
- Castle respawn timers 15/15/20 s, 5 min carry limit. Mailed rewards, plus 2,000 stat exp on capture.
- [C++] Sky garden "occupied" flag was never reset, so only the first war after a start had a result.
- [C++] Every other defended fort war had no result.
- [C++] Players saw the wrong castle on enter.
- Port fixes: character position was never loaded, and hits could land on a monster on another map.
- G1: found, invite, leave, kick, disband, duties, peerages, guild window.
- G2: cabinet (grows with level), contribution, board, fame (30,000 PvP points), country-filtered recruiting, point log, PvP record.
- G3: mercenary ads, contracts and expiry mail. PvP point rewards. Castle guard shop with refund on failure.
- G4: guild level from member count, 10 guild skills (member, vice-chief and chief sets), 300 PvP points per 31-day renewal, guild-wide cooldowns.
- [C++] Cabinet layout mismatch between map and world.
- [C++] A partial cabinet take-out reused the item ID.
- [C++] Guild skills stayed after leaving the guild.
- [C++] Guild skills were deleted on the next update.
- [C++] Guild skill level was raised before checking the point.
- [C++] Guild cooldowns missed members already online.
- World checks on invite, kick, duty and peerage now match the original.
- The founder is saved as a member. Board article title and length limits. Wanted ads expire.
- PvP week record, guild exp floor, cloak reset.
- Mail texts sent as net strings. Castle guard shop crash fixed.
- 15 added: 7 official FR costumes and 8 orphans. Costumes take up to 4 magic options.
- 4Genesis: 133 costumes (incl. 6 wings with effects) and 13 mounts.
- 4Revelation: 90 costumes and effects (hats, outfits, effect wings, chakras, 14 auras and effect sets) and 65 mounts.
- Auras that 4Revelation hard-coded in its exe are now a data table in the client.
| Metric | Before | After |
|---|---|---|
| Idle CPU | 0.24 core | 0.014 core (-94%) |
| CPU with 40 bots | 0.35 core | 0.12 core (-66%) |
| Respawn tick | 234.7 ms, 147 KB allocated | 0.042 ms, 0 B |
| Cost per monster death | 5.5 ms + 640 KB | ~0 |
| Large-object heap | 6↔26 MB | 6.9 MB stable |
| GC committed | 80 MB | 61 MB |
| Peak RSS (40 bots) | 227 MB | 193 MB |
- One ordered game task with a 1 s scheduler. Every handler is isolated, so a bad packet can't crash the server. Boot loads are best-effort.
- Login handshake (fixed the stuck loading screen), main-server hand-off, map-drop cleanup, teleports, solo instances.
- World chat, TMS group chat, warlord and GM announcements.
- Party (round-robin loot, member recall), corps (orders, enemy list), arena.
- Friends and groups, soulmates (search, silence period, level-gap break).
- Guilds: core, cabinet, contribution, board, fame, recruiting, mercenaries, level, skills, 7-day disband grace.
- Monthly ladder and fame ranking, month rollover.
- BoW: solo and guild queues, rebalance, live score.
- Battle Royale: premades, voting, class-balanced teams.
- Tournaments: brackets, seeding, betting, payback.
- Fort, castle, mission and sky garden scheduling. Defender pick with the original tie-breaks. Captures relayed to every map.
- PvP routing, nation balance, level and country sync.
- Pets, mounts and summons with world-unique IDs.
- Cross-server inspect, mail, look and name changes.
- Cash mall gifts and sales, events, lottery, quarter draw, rock-paper-scissors, meeting room.
- GM tools: teleport, chat ban, item search, tournament admin, cash shop stop/resume.
- Party notices and guild answers reached the wrong player.
- Contribution would have drained the treasury, and its save wrote the wrong totals.
- Volunteer accept/refuse was inverted. Guild country was never set. Guild level never changed.
- Mercenary contracts never expired after a restart.
- Castle captures never reached the maps (missing proc).
- Maps got no war state on connect.
- Two control message IDs were swapped. 10+ guild packet layouts corrected.
Login
- 13 messages and 15 procs. The asymmetric RC4+XOR cipher has golden-vector tests and is reused by every other tool.
- Multi-world ready. Clears stale sessions on shutdown.
- Fixed the "Duplicate" login lock and the client freeze when character creation fails.
- 9/9 handlers on the 8-byte plaintext protocol. Runs without a DB. Checked live byte-exact.
- [C++] SM_QUITSERVICE was dead code. The download URL was hard-coded.
- 64/64 handlers: operator login, 1 s service monitor, GM relays, event engine, patch management.
- The Windows-only parts (services, perf counters, SMB) sit behind interfaces, so it runs cross-platform.
- Audit fixed 4 wire defects.
- [C++] Lottery and gift-time parsing were broken.
- [C++] Chat-ban counter could underflow.
- [C++] Dead localhost gate.
- Load timing logs. Startup lost ~36 s to N+1 queries (quest tree, spawns, drops, portals, NPC lists, topology); these are now 10 bulk loads plus 6 indexes.
- [C++] Companion runes never got a species, so creation silently failed or crashed the client. Fixed with a new rune chart and stamping at item creation.
- Retargeted to VS 2026 / SDK 10.0.26100. Source tree converted to UTF-8.
- A temporary "C++ Test" world was used for side-by-side comparison with the C# servers.
- Stack: SQL Server 2022 (host port 11433), an importer job, then login, world, map, patch and control.
- 5 multi-stage Dockerfiles. Configuration through env vars. Secrets in .env only.
- Importer: restores the .bak baselines once, applies each migration exactly once (tracked), retries a failed migration, and waits for the DBs to be ONLINE.
- Test account
- Local network config
- Map server load indexes
- [C++] Missing companion species (Easter Squirrel, Humpty Dumpty)
- Companion rune chart (44 rows)
- 31 missing mount and pet items
- [C++] Summoner character creation (TCreateRecallMon)
- [C++] Char ID reseeded past ~88k orphan rows
- Evocate Monster summon lasts until it dies
- 4Classic mounts
- Remove Red Fox
- Remove 5 unfinished mounts
- Renumber Classic mounts (40–49 and 55–123)
- 15 costumes
- [C++] Missing TSaveGuildStats proc
- [C++] Guild skills: chart, table and save proc
- 4Genesis costumes, mounts and wings
- Remove a duplicate 4Genesis mount
- 4Revelation costumes, effects and mounts
- TSaveChar wiped player buffs.
- TSaveRecallMon inserted an empty row.
- TSaveRecallMaintain cleared player buffs.
- Headless .NET client: login, create character, enter, play.
- Scenarios:
- features: ~108 byte-level checks.
- castle: 15/15.
- guild: 29/29, guild skills 59/59.
- guild tactics.
- stress.
- Bugs it found:
- Broadcasts were encrypted in place per recipient.
- Party notices went to the wrong player.
- Logout saves deadlocked; all saves now go through one ordered DB queue.
- Wrong bag type constant.
| Bots | Map RAM | Map CPU | Login p50/p95 | Enter p95 |
|---|---|---|---|---|
| 5 | 138 MB | 0.03 | 203/227 ms | - |
| 100 | 183 MB | 0.2 | 55/85 ms | 77 ms |
| 200 | 210 MB | 0.5 | 59/73 ms | 63 ms |
| 400 | 240 MB | ~2 | 74/128 ms | 73 ms |
- Test conditions: ~18,800 live monsters, debug logging on.
- 0 server kicks; ~4,000 moves per second at 400 players.
- Remaining bottleneck: SQL lock waits on the login DB during burst logins.
| Step | Before | After |
|---|---|---|
| Exe checksum (8-byte reads) | 1,164 ms | 4 ms |
| Loading screen (11,210 redraws) | 2,923 ms | 62 ms |
| Animations / meshes / objects | 2,685 / 1,395 / 2,112 ms | 48 / 86 / 38 ms |
| D3D init (DxDiag removed) | ~2,300 ms | ~250 ms |
| Animations + meshes, cold (prefetch) | 2,131 ms | 484 ms |
| UI parse (TIF v2) | 859 ms | 31 ms |
- 64 KB buffered reader. 2 prefetch threads (~734 MB).
- Shorter intro. Loading image 3.1 MB → 270 KB.
- GPU skinning (vs_3_0 shader with a fallback). No more software/hardware vertex-processing switching.
- Far clip 300 → 700. Anisotropic filtering up to 16x. Gamma, brightness and contrast hooks. Desktop resolution on first boot.
- Monster name grouping ("Name xN"). Fixed monsters vanishing beyond ~7 units on modern GPUs.
- Multi-world fix (character list and creation always targeted world 1). Evocator UI fixes. Auto-registered custom icons. Null-SFX mount crash fixed.
- VS2017 → VS 2026 (v145), SDK 10.0.26100. Build scripts.
- CMake + clang-cl builds (MSBuild parity: 5,942,272 vs 5,943,296 bytes). Clang-only crashes fixed.
- miniaudio replaces DirectSound and the old MP3 decoder.
- select() polling replaces WSAAsyncSelect in the network sessions.
- Keyboard and mouse go through one input layer (CTachyonInput).
- Render layer between the engine and Direct3D 9, then a bgfx backend: a fixed-function emulation shader, render targets, screenshots. bgfx is now the default; D3D9 stays as a fallback.
- D3DX math replaced by an own header.
- MFC removed: app and main window on plain Win32, CFile/CArchive/CFileFind/exceptions rewritten in TAfx.h (CArchive format byte-identical to MFC, verified both ways). Exe -560 KB. The embedded IE web view and the two debug dialogs are gone.
- SDL3 3.4 vendored as a static library (window, events, text input). Integration in progress.
- Fixed sounds replayed right after their end being skipped.
- 357 files converted CP949 → UTF-8. Korean strings stay byte-identical in the exe.
- zlib 1.2.11 → 1.3.2 (CVE-2018-25032 fixed). zlib.dll 166 → 78 KB.
- Settings moved from the registry to config.ini. Fixed: the launcher wrote a different registry key than the client read.
- TClientCmd.tif v2 with shared image lists: 154 MB → 4.3 MB, identical over 823,839 nodes.
- C++ launcher upgraded from VS2008, broken machine-specific paths fixed, moved to config.ini.
- TLauncher.Net: C# patch + launch core that shares its protocol code with the patch server, and starts the client elevated.
- TLauncher.Wpf: skinned WPF launcher with a settings window.
- Item Browser(React + Prisma)
- Reverse-engineered the full 5-file icon chain: 7,099 of 7,706 items get the right icon.
- DB vs client diff. Generates SQL for missing items.
- UI Editor(React)
- Byte-identical .tif round-trip (318 frames, 74 fonts). 472 texture pages baked.
- Drag, resize, undo/redo, save in place.
- ClassicPort
- Decodes the scrambled 4Classic formats (TOB, TMH, TAC, TTX…).
- 79 mounts imported; 65,148 records merged byte-identically.
- OfficialPort: 7 official costumes (29 meshes, 13 textures × 3 LODs).
- GenesisPort
- 4Genesis: cracked the TCE1 asset encryption (FNV-1a + SplitMix64) and decrypted the full client. 444 textures, 226 meshes, 85 animations, 16 effects imported.
- 4Revelation (x64 client): cracked 4 ciphers (CTST tables, per-type XOR packs, PNG icon pages, ETIF UI file). 48,411 records read back with 0 unexpected.
- All ported icons merged into the main icon atlas; the loose custom PNGs are gone.
- TifDedupe (v1 → v2 converter), TCMLParser (UI compiler, writes v2), Happy (rebuilt).
- GAME_FILES.md: every Game/ file mapped to its loader.
- Client:
bgfx
→ drop MFC
→ SDL3 (in progress) → own CString/CRect/CTime → 64-bit → Linux. - Map server: send batching and GC tuning.
- Login DB under burst load.
- Client frame limiter.
Link=>
To view the content, you need to sign in or register
Last edited:

