Giter Site home page Giter Site logo

mir2x's Introduction

mir2x

Coverity Scan Build Status Appveyor Build Status Travis CI Build Status Gitter chat

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
  • monoserver
  • pkgviewer
  • animaker
  • mapeditor

Notes

  • This repo uses C++20 coroutine, developer needs a compiler supports c++20 to build.
  • 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 monoserver 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

YouTube links: 1 2 3

vokoscreen-2022-04-09_00-26-06.mp4

An IME for SDL fullscreen mode:

ime.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.

Building from source

mir2x game is developed for Linux-only environment, however I finished all coding and testing with Windows WSL, 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-dev
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 monoserver, 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
$ ./monoserver

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

$ cd mir2x/b/install/client
$ ./client

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.
  • libpng - The official PNG reference library patched with APNG support.
  • 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.

mir2x's People

Contributors

ahe01 avatar amdmi3 avatar etorth avatar zoand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mir2x's Issues

Hello, I reported this error while executing make and I don't know how to handle it

CMake Error at /mir2x/build/phmap-prefix/src/phmap-stamp/phmap-build-.cmake:49 (message):
Command failed: 2

'make'

See also

/mir2x/build/phmap-prefix/src/phmap-stamp/phmap-build-*.log

phmap-build-err.log:
/usr/bin/ld: CMakeFiles/ex_mt_word_counter.dir/examples/mt_word_counter.cc.o: in function main': mt_word_counter.cc:(.text.startup+0x743): undefined reference to pthread_create'
/usr/bin/ld: mt_word_counter.cc:(.text.startup+0xd06): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[5]: *** [CMakeFiles/ex_mt_word_counter.dir/build.make:97:ex_mt_word_counter] 错误 1
make[4]: *** [CMakeFiles/Makefile2:1067:CMakeFiles/ex_mt_word_counter.dir/all] 错误 2
make[3]: *** [Makefile:146:all] 错误 2

test account can not login in.

Hello, Etorth,

Thanks for your good project. i installed and started the game, but after learning "治愈术",the client crashed, then i cannot not login in any more via 'test' account , any idea about the issue?
"Caught exception: In file skillboard.cpp:528, function: setMagicLevel: no magic icon for magic: 治愈术

Client doesn't start

Server is started, client fails, and I must confess I do not understand the reason.

~/GitHub/mir2x/b/install/client$ ./client 
* This is the initialization of Log functionality
* For info/debug/warning/fatal messages.
* Log file: [/tmp/mir2x-client-v01.g3log.20210113-161520.log]
* Log functionality established!
* All messges will be redirected to the log after this line
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  152 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  100
  Current serial number in output stream:  101
g3log g3FileSink shutdown at: 16:15:20 713983
Log file at: [/tmp/mir2x-client-v01.g3log.20210113-161520.log]

~/GitHub/mir2x/b/install/client$ cat /tmp/mir2x-client-v01.g3log.20210113-161520.log
g3log g3FileSink shutdown at: 16:15:20 713983

WSL编译libpinyin依赖问题

在编译的时候,需要依赖libpinyin,通过client目录下的CMakeLists.txt中的注释,我clone了libpinyin,并进行编译,但是后面make的时候出现找不到glib.h,我添加了glib-2.0,但是后面仍旧提示包含头文件错误,我的libpinyin或者glib库版本有问题?大佬能否告知应该选择那个版本的libpinyin或者glib库?
这是我的报错信息:
In file included from /usr/include/glib-2.0/glib/galloca.h:34,
from /usr/include/glib-2.0/glib.h:32,
from /usr/local/libpinyin/include/libpinyin-2.8.1/novel_types.h:29,
from /usr/local/libpinyin/include/libpinyin-2.8.1/pinyin.h:26,
from /mnt/f/Dev/mir2x/client/src/ime.cpp:8:
/usr/include/glib-2.0/glib/gtypes.h:34:10: fatal error: glibconfig.h: No such file or directory
34 | #include <glibconfig.h>
| ^~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [client/src/CMakeFiles/client.dir/build.make:566: client/src/CMakeFiles/client.dir/ime.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1369: client/src/CMakeFiles/client.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

二进制文件

那个二进制文件好像无法下载啊 大佬可否留个QQ 好交流啊

client res error

client

		g3log created log at: Tue May 31 11:43:07 2022
		LOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL FILE->FUNCTION:LINE] message

		(uuu*: microseconds fractions of the seconds value)

2022/05/31 11:43:07 638619	INFO [initview.cpp->void InitView::addIVLog(int, const char*, ...):203]	[000%]Loading root/texture/itemDB
2022/05/31 11:43:07 638609	INFO [initview.cpp->void InitView::addIVLog(int, const char*, ...):203]	[000%]Loading root/texture/progUseDB
2022/05/31 11:43:07 638726	INFO [initview.cpp->void InitView::addIVLog(int, const char*, ...):203]	[000%]Loading root/texture/mapDB

server

		g3log created log at: Tue May 31 11:49:23 2022
		LOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL FILE->FUNCTION:LINE] message

		(uuu*: microseconds fractions of the seconds value)

2022/05/31 11:49:23 939640	INFO [actorpool.cpp->ActorPool::ActorPool(int, int):78]	Server FPS: 10
2022/05/31 11:49:48 447546	INFO [monoserver.cpp->void MonoServer::CreateDBConnection():371]	Connect to database mir2x.db3 successfully
2022/05/31 11:49:48 448267	WARNING [main.cpp->int main(int, char**):125]	Exception in main thread: std::bad_alloc

SDL package linkage during build (Arch Linux)

Hi,

It seems that my platform perhaps requires an extra package check statement to properly link the SDL2 libraries. Without it, SDL2_INCLUDE_DIRS and SDL2_LIBRARIES are empty:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c822ad33..ef87d3c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -136,6 +136,7 @@ IF(WIN32)
     FIND_PACKAGE(FreeType REQUIRED)
 ELSE()
     FIND_PACKAGE(SDL2 REQUIRED)
+    pkg_check_modules(SDL2 REQUIRED sdl2)
 ENDIF()
 
 MESSAGE(STATUS "SDL2 found: SDL2_INCLUDE_DIRS: ${SDL2_INCLUDE_DIRS}, SDL2_LIBRARIES: ${SDL2_LIBRARIES}")

git clone failed with git-lfs over its data quota

Hello, when i try to git clone the code, it says "This repository is over its data quota.Account responsible for LFS bandwidth should purchase more data packs to restore access"
Could you give an another way to download the gif and map resource files?
Thanks~

server launch exception bad_alloc

`└─# cat /tmp/mir2x-monoserver-v01.g3log.20211105-095720.log
g3log created log at: Fri Nov 05 09:57:20 2021
LOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL FILE->FUNCTION:LINE] message

            (uuu*: microseconds fractions of the seconds value)

2021/11/05 09:57:20 936691 INFO [actorpool.cpp->ActorPool:78] Server FPS: 10
2021/11/05 09:57:24 451103 INFO [monoserver.cpp->createDefaultDatabase:360] Create default sqlite3 database done
2021/11/05 09:57:24 451208 INFO [monoserver.cpp->CreateDBConnection:371] Connect to database mir2x.db3 successfully
2021/11/05 09:57:24 461429 WARNING [main.cpp->main:125] Exception in main thread: std::bad_alloc
`

no NPC name display

Hello, etorth

There is something wrong about display of npc name, even if i ran the client with --always-draw-name option, there is still no display. also the f'loating damage number is “+58”, “+8” which should be “-58”,“-8”.
could you please give some suggestions about the issue.
my environment is ubuntu os, any font need to be installed?

error: ‘FILE’ in namespace ‘std’ does not name a type

Hi,

I'm hitting an error during make.

In file included from /home/mike/src/Applications/mir2x/client/src/pngtexdb.hpp:24,
                 from /home/mike/src/Applications/mir2x/client/src/inventoryboard.cpp:19:
/home/mike/src/Applications/mir2x/common/src/zsdb.hpp:76:14: error: ‘FILE’ in namespace ‘std’ does not name a type
   76 |         std::FILE *m_fp;
      |              ^~~~
compilation terminated due to -Wfatal-errors.
make[2]: *** [client/src/CMakeFiles/client.dir/build.make:303: client/src/CMakeFiles/client.dir/inventoryboard.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1108: client/src/CMakeFiles/client.dir/all] Error 2
make: *** [Makefile:171: all] Error 2

Arch Linux, amd64.

Resources are always loading on Ubuntu 20.04.

I build the repo source code on Ubuntu 20.04 successfully. Then I run client --server-ip=192.9.241.118. However, the client is always displayed "[000%]root/texture/**DB". Am I probably doing something wrong at any step?

关于使用zsdb打包资源的看法

// 对于PNG 文件 单个文件压缩是没有意义的,他本身就已经压缩过,所以再压缩反而使文件变大 更让资源加载变的更慢
我个人写了一个大包代码,只是简单的大包成一个文件,测试 proguse.zsdb 比压缩后还小3M

server failed to launch

After clicking "Server-> Launch"

Failed to load mapbindbn. Is there some map preparation needed?

Log:

2019/10/13 10:01:31 772788      INFO [monoserver.cpp->CreateDBConnection:223]   Connect to SQLite3 Database (mir2x) successfully

2019/10/13 10:01:31 773379      WARNING [monoserver.cpp->LoadMapBinDBN:241]     Failed to load mapbindbn

2019/10/13 10:01:31 773482      INFO [actorpool.cpp->Launch:638]        Actor thread 0 launched

Compilation failed !

I suppose this is a simple dependency issue, but I didn't found what is missing, can you help me ?

[ 32%] No install step for 'sol2'
[ 33%] Completed 'sol2'
[ 33%] Built target sol2
Scanning dependencies of target mir2x_3rds
[ 33%] Built target mir2x_3rds
Scanning dependencies of target common
[ 33%] Building CXX object common/src/CMakeFiles/common.dir/colorf.cpp.o
c++: error: unrecognized command line option ‘-fcoroutines’
make[2]: *** [common/src/CMakeFiles/common.dir/build.make:63: common/src/CMakeFiles/common.dir/colorf.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1111: common/src/CMakeFiles/common.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

Filtering content stuck

This repo has used LFG to storage big files.
Do not clone with --recursive that will cause you stuck in "Filtering content ..."
Just clone and pull or lfg pull.

Can I compile it on a Mac

When I compile it in the Mac13.0 environment, I am prompted with an error:

【clang-11: error: unknown argument: '-fcoroutines'】

How can I resolve this error

编译流程出问题

[ 62%] Building CXX object server/src/CMakeFiles/monoserver.dir/actormonitortable.cpp.o
In file included from /home/make/500GB/mir3.git.all/mir2x/server/src/podmonitortable.hpp:25,
                 from /home/make/500GB/mir3.git.all/build/server/src/podmonitorwindow.hpp:7,
                 from /home/make/500GB/mir3.git.all/mir2x/server/src/actormonitortable.cpp:27:
/home/make/500GB/mir3.git.all/mir2x/server/src/fltableimpl.hpp:21:10: 致命错误:Fl/Fl_Table_Row.H:没有那个文件或目录
   21 | #include <Fl/Fl_Table_Row.H>
      |          ^~~~~~~~~~~~~~~~~~~
编译中断。

查了下

fltk /usr/include/FL/Fl_Table_Row.H
...这cmake生成的文件看不明白。

clang: fatal error: unknown argument: '-fcoroutines'

[ 31%] Built target mir2x_3rds
[ 32%] Building CXX object common/src/CMakeFiles/common.dir/colorf.cpp.o
clang: fatal error: unknown argument: '-fcoroutines'
make[2]: *** [common/src/CMakeFiles/common.dir/build.make:63:common/src/CMakeFiles/common.dir/colorf.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:1189:common/src/CMakeFiles/common.dir/all] 错误 2
make: *** [Makefile:152:all] 错误 2
root@wikeyi-Parallels-Virtual-Platform:/mir2x/b# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.2.0-5ubuntu1
20.04' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04)

编译错误

我在WSL1中编译,使用的是gcc12.3版本,编译出错,下面是cmake输出,还请大佬指导一下
` In file included from /mnt/f/Dev/mir2x/common/src/luaf.hpp:10,
[build] from /mnt/f/Dev/mir2x/common/src/luaf.cpp:1:

[build] /mnt/f/Dev/mir2x/common/src/strf.hpp: In instantiation of ‘std::string str_any(const T&) [with T = std::variant<luaf::luaNil, std::unordered_map<luaf::luaVarWrapper, luaf::luaVarWrapper, luaf::_details::_luaVarWrapperHash, std::equal_toluaf::luaVarWrapper, std::allocator<std::pair<const luaf::luaVarWrapper, luaf::luaVarWrapper> > >, long long int, double, bool, std::__cxx11::basic_string<char, std::char_traits, std::allocator > >; std::string = std::__cxx11::basic_string]’:

[build] /mnt/f/Dev/mir2x/common/src/strf.hpp:371:94: required from ‘std::string str_any(const std::vector<T, Args ...>&) [with T = std::variant<luaf::luaNil, std::unordered_map<luaf::luaVarWrapper, luaf::luaVarWrapper, luaf::_details::_luaVarWrapperHash, std::equal_toluaf::luaVarWrapper, std::allocator<std::pair<const luaf::luaVarWrapper, luaf::luaVarWrapper> > >, long long int, double, bool, std::__cxx11::basic_string<char, std::char_traits, std::allocator > >; Args = {std::allocator<std::variant<luaf::luaNil, std::unordered_map<luaf::luaVarWrapper, luaf::luaVarWrapper, luaf::_details::_luaVarWrapperHash, std::equal_toluaf::luaVarWrapper, std::allocator<std::pair<const luaf::luaVarWrapper, luaf::luaVarWrapper> > >, long long int, double, bool, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >}; std::string = std::__cxx11::basic_string]’

[build] /mnt/f/Dev/mir2x/common/src/luaf.cpp:232:25: required from here

[build] /mnt/f/Dev/mir2x/common/src/strf.hpp:348:49: error: no match for ‘operator<<’ (operand types are ‘std::stringstream’ {aka ‘std::__cxx11::basic_stringstream’} and ‘const std::variant<luaf::luaNil, std::unordered_map<luaf::luaVarWrapper, luaf::luaVarWrapper, luaf::_details::_luaVarWrapperHash, std::equal_toluaf::luaVarWrapper, std::allocator<std::pair<const luaf::luaVarWrapper, luaf::luaVarWrapper> > >, long long int, double, bool, std::__cxx11::basic_string<char, std::char_traits, std::allocator > >’)

[build] 348 | return dynamic_cast<std::stringstream &>(ss << t).str();

[build] | ~~~^~~~
[build] compilation terminated due to -Wfatal-errors.`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.