Skip to content

An attempt to migrate CrystalM2 from GDI+ to the FNA framework and run it on Linux#1176

Draft
AuroraRAS wants to merge 26 commits into
Suprcode:masterfrom
AuroraRAS:4L
Draft

An attempt to migrate CrystalM2 from GDI+ to the FNA framework and run it on Linux#1176
AuroraRAS wants to merge 26 commits into
Suprcode:masterfrom
AuroraRAS:4L

Conversation

@AuroraRAS
Copy link
Copy Markdown

This project successfully completed full testing of compiling and running CrystalM2 locally on Linux. It includes a client using the FNA framework and a headless server, both of which do not rely on GDI+, Direct3D 9, or the Wine adapter layer, running directly on a Fedora 44 Linux distribution.

The Cross-platformPortingExperience.md file contains details of the various difficulties encountered during the project migration and their solutions.

The image below shows the state of this project running in a real Linux environment.

Screenshot From 2026-05-21 10-56-52 Screenshot From 2026-05-21 10-51-27

Note:
The project contains a significant amount of code generated by Vibe Coding; please assess the risks yourself before using it in a production environment.

AuroraRAS added 6 commits May 21, 2026 11:17
…configurations alongside engine-side feature additions
We have identified and fixed the runtime error that occurred when hiding the game interface (camera mode).
…ro base stats configurations

We resolved the issue where mouse-hover tooltips (such as for active buff icons) and the debug overlay did not render on the Linux FNA client. Additionally, we conducted a heuristic search and resolved three other platform-gap issues on FNA/Linux.
In the FNA (Linux) version of the client, pressing Ctrl, Alt, or Shift to bind a key combination (e.g., Ctrl + A) immediately binds the hotkey as Ctrl + LControlKey, Alt + LMenu, or Shift + LShiftKey without waiting for the rest of the key combination.
1. Rebirth3 Red Square Rendering Correction
2. Missing Minimap/Poison Indicator Dots & Blending Rate Fixes
We implemented global opacity and grayscale rendering support in the FNA graphics renderer to resolve visual parity regressions under the FNA port.
@liaojiaao
Copy link
Copy Markdown

liaojiaao commented May 21, 2026

Interesting, but it needs careful testing.

AuroraRAS added 4 commits May 22, 2026 00:04
The inventory item and message lines render depth issue has been resolved for the FNA client target.
I have fixed the issue where the headless server console input shifts to the right when handling double-width characters (like Chinese characters in player names).
We investigated and resolved two rendering/focus issues in the text input area of the ChatDialog under the FNA client.
@AuroraRAS
Copy link
Copy Markdown
Author

AuroraRAS commented May 22, 2026

The previous day, I focused on fixing various minor issues with the project. These mostly manifested as rendering problems in the FNA client version and minor glitches in the command-line interaction of the headless server.

The current game appearance is as follows:
Screenshot From 2026-05-22 11-04-20

If you encounter any problems compiling this version of Crystal, please let me know, and I will do my best to help.

Clone the codes and checkout 4L version:

git clone https://github.com/AuroraRAS/Crystal.git
cd Crystal
git checkout 4L

FNA is a third-party framework; please obtain it from its official repository using the following command:

cd Crystal/Client/
git clone --recursive https://github.com/FNA-XNA/FNA

Commands for compiling the client and server:

cd Crystal
dotnet build Client/Client.csproj -f net10.0 -c Release
dotnet build Server.Headless/Server.Headless.csproj -f net10.0 -c Release

AuroraRAS added 16 commits May 22, 2026 18:32
We have completed the implementation to allow independent window scaling (forcing 100%, 200%, or other custom scales) under Linux/Wayland, decoupling it from the GNOME system scale of 150%.
I have successfully fixed the file deletion issue during the automatic update process of the Linux FNA client.
I have successfully updated the client and server regex patterns and network action handler to support optional @ prefixes in NPC dialogue links (e.g., <Candle/candle>).
Resolve the issue where clicking options that open sub-panels (e.g. <Crafting/@craft>) in the NPC dialogue box closes the dialog box immediately instead of displaying the pane.
We implemented the changes from the approved plan to resolve the newbie guild initialization, NPC parameter mapping, and lag issues.

Changes Made
1. Newbie Guild Initialization
Added an ownerless constructor in Server/MirDatabase/GuildInfo.cs to support creating system-owned guilds.
Added logic in Server/MirEnvir/Envir.cs inside LoadGuilds() to check for the existence of Settings.NewbieGuild. If it does not exist, a new instance is created and registered with a unique guild index.
2. Newbie Guild Parameter Mapping in NPC Scripts
Modified Server/MirObjects/NPC/NPCSegment.cs:
CheckType.InGuild: If the script specifies "NewbieGuild", we map it to Settings.NewbieGuild (the custom configured name, like "NewB"). We also perform case-insensitive checks.
ActionType.AddToGuild: If the script instructs "AddToGuild NewbieGuild", we map it to the actual configured guild Settings.NewbieGuild.
ActionType.RemoveFromGuild: Updated string comparison with Settings.NewbieGuild to be case-insensitive.
3. Buff Lag Fix
Modified ProcessBuffs() in Server/MirObjects/HumanObject.cs to add tracking for the active BuffType.Newbie using a local flag newbie.
BuffType.Newbie is now properly updated in the loop and flagged for removal if conditions are no longer met.
The AddBuff(BuffType.Newbie, ...) call is now guarded by !newbie so it is not invoked on every single server tick, preventing flooding the client with buff packets and avoiding lag (5 FPS).
We have implemented a system-level check during the compilation of the FNA client (net10.0 on Linux) to check for the presence of libFNA3D. If not found on the system, it will automatically build it from source and copy the binaries to the build and publish output directories.
…ctory

We updated the FNA (Linux) version of the client to handle resource, configuration, screenshot, and log files using the current working directory (Directory.GetCurrentDirectory()), rather than using the program's binary execution directory (AppContext.BaseDirectory / AppDomain.CurrentDomain.BaseDirectory).
I have implemented and validated case-insensitive file system resolution for the headless server. Under Linux, filesystem paths are case-sensitive. The database directory contains files (e.g. maps and drop files) with uppercase characters in their names, while the game server loaded them using lowercase filenames. This caused all maps with mixed-casing to fail to load.
We have consolidated the isolated Linux file system compatibility layers (VFS, path normalization/backslash replacement, and regex-based case-insensitive pattern matching for filenames) into the Shared project. Both the client and server projects now delegate their file resolution calls to the new unified Shared.Vfs.VfsManager.
We have resolved the unnatural text alignment for the HP and MP values in the MainDialog health/mana orb under the FNA version of the client for both HPMP display modes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants