SkillAgentSearch skills...

Mir2x

open source MMORPG game

Install / Use

/learn @etorth/Mir2x
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

mir2x

<a href="https://scan.coverity.com/projects/etorth-mir2x"> <img alt="Coverity Scan Build Status" src="https://scan.coverity.com/projects/9270/badge.svg"/> </a> <a href="https://ci.appveyor.com/project/etorth/mir2x"> <img alt="Appveyor Build Status" src="https://ci.appveyor.com/api/projects/status/github/etorth/mir2x?svg=true"/> </a> <a href="https://travis-ci.org/github/etorth/mir2x"> <img alt="Travis CI Build Status" src="https://travis-ci.org/etorth/mir2x.svg?branch=master"/> </a> <a href="https://gitter.im/mir2x/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link"> <img alt="Gitter chat" src="https://badges.gitter.im/org.png"/> </a>

mir2x is an experimental project that verifies actor-model based parallelism for MMORPG, it's c/s based with various platforms supported and contains all need components for game players and developers:

  • client
  • server
  • pkgviewer
  • animaker
  • mapeditor

Notes

  • This repo uses C++ coroutine to implement actor model, requires compiler to support c++23.
  • This repo uses classic v1.45 mir2 as a reference implementation, you can try the original game:
    • Install win-xp to host and run the game server/client, tested on real machine or virtualbox machine.
    • Install server/client from mir2-v1.45.
    • Change screen resolution to 16bit mode to run the game.

Public Server

  • Check the tutorial here for how to run the server with Oracle Cloud as a public server.
  • You can try the public test server 192.9.241.118 by
    client --server-ip=192.9.241.118 # not maintained recently
    

YouTube links: 1 2 3

https://user-images.githubusercontent.com/1754214/162589720-7dd9453b-55e4-4119-a1ee-c879093cf017.mp4

An IME for SDL fullscreen mode:

https://user-images.githubusercontent.com/1754214/213572554-785e826c-226d-43fa-a196-ee4f92112db2.mp4

Windows

For windows please download binaries from appveyor

https://ci.appveyor.com/project/etorth/mir2x/build/artifacts

If complains missing dll, you may need to copy .dll files from mir2x/bin to mir2x/client and mir2x/server.

If running on WSL/WSL2, check the following to configure PulseAudio to support sound effect, the sound may get played with noticable delay. <img src="https://github.com/etorth/mir2x/raw/master/readme/pulseaudio.png"/>

Building from source

mir2x game is developed mainly in WSL2, please refer here how to setup and run everything on windows. mir2x requires cmake v3.12 and gcc support c++20 to run. Mir2x needs some pre-installed packages before compile:

libsdl2-compat-dev # legacy libsdl2-dev package has bugs
libsdl2-image-dev
libsdl2-mixer-dev
libsdl2-ttf-dev
libsdl2-gfx-dev
liblua5.4-dev
libfltk1.3-dev

Cmake complains if libs are missing. After install all these dependencies, clone and compile the repo. By default cmake tries to install in /usr/local. use ``CMAKE_INSTALL_PREFIX" to customize.

$ git clone https://github.com/etorth/mir2x.git
$ cd mir2x
$ mkdir b
$ cd b
$ cmake .. -DCMAKE_INSTALL_PREFIX=install
$ make
$ make install

First time run

To start the monoserver, find a linux machine to host the server, I tried to host it on Oracle Cloud Infrastructure, it works perfectly with the always-free plan. Click menu server/launch to start the service before start client:

$ cd mir2x/b/install/server
$ ./server --auto-launch

Start client, currently you can use default account (id = test, pwd = 123456) to try it:

$ cd mir2x/b/install/client
$ ./client --server-ip=localhost --auto-login=test:123456

Code style

Global variables:

  1. no globals of builtin types, they are lacking of multithread access control.
  2. no globals of class instances, use pointer instead, for better construction/destruction control.
  3. all member functions of globals should be:
    • simple
    • thread-safe
    • atomic operations
  4. name all global pointers as g_XXXX and use them by extern, and
    • allocate them at beginning of main()
    • remain valid during the whole run, and ONLY free them at process exit.

Error handling:

  1. use exception for good/bad path control, force catch at exit of main() or clone().
  2. do strict parameters checking before doing actual logic, no assumptions.
  3. let the crash happen ASAP if any fatal error detected

General rules:

  1. make all member functions self-contained, avoid first/second half logic.
  2. don't do optimization too early, perfer simple/clear logic.

Packages

mir2x uses a number of open source projects to work properly, and of course itself is open source with a public repository on github, please remind me if I missed anything.

  • SDL2 - A cross-platform development library designed to provide a hardware abstraction layer.
  • FLTK - A cross-platform C++ GUI toolkit for UNIX®/Linux® (X11), Microsoft® Windows®, and MacOS® X.
  • asio - A cross-platform C++ library for network and low-level I/O programming.
  • g3log - An asynchronous, "crash safe", logger that is easy to use.
  • lua - A powerful, efficient, lightweight, embeddable scripting language.
  • sol2 - A fast, simple C++ and Lua binding.
  • tinyxml2 - A simple, small, efficient, C++ XML parser.
  • utf8-cpp - A simple, portable and lightweigt C++ library for UTF-8 string handling.
  • ThreadPool - A simple C++11 Thread Pool implementation.
  • SQLiteCpp - SQLiteC++ (SQLiteCpp) is a smart and easy to use C++ SQLite3 wrapper.

running WSL2

wsl2 sucks! if in WSL2 you can ping 8.8.8.8 but can not ping google.com, that means you DNS is wrong.

  1. in windows run

    ipconfig
    

    You will see line as Ethernet adapter vEthernet (WSL (Hyper-V firewall)), the IPv4 Address of this section is used as your DNS in WSL2 /etc/resolv.conf, everytime when WSL2 reboots, it automatically create this /etc/resolv.conf, you need to disable the automagicall overwrite, there is comment in file /etc/resolv.conf explaining how to do it.

  2. in windows run

    ipconfig /all
    

    You will find the section Wireless LAN adapter Wi-Fi, inside the section find DNS Server and copy all IPs to /etc/resolv.conf, reboot WSL2, it should be good now.

Related Skills

View on GitHub
GitHub Stars490
CategoryDevelopment
Updated14h ago
Forks209

Languages

C++

Security Score

85/100

Audited on Apr 2, 2026

No findings