Giter VIP home page Giter VIP logo

mir2x's Introduction

mir2x

Coverity Scan Build Status

mir2x is a c/s based mir2ei implementation with various platforms supported. It contains all need components for game players and developers:

  • client
  • monoserver
  • pkgviewer
  • animaker
  • mapeditor
  • dbcreator

image image

Building from source

mir2x requires cmake v3+ and gcc support c++14 to run. Mir2x needs some pre-installed packages before compile:

libsdl2-dev
libsdl2-image-dev
libsdl2-ttf-dev
libsdl2-mixer-dev
libpng-dev
liblua5.3-dev
libmysqlclient-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=${PWD}/install
$ make
$ make install

First time run

The above steps install binaries in mir2x/b/install. Before run the server/client you need to start mysql server on your host. Then create the default database:

$ cd mir2x/b/install/tools/dbcreator/
$ ./main.sh

Start the monoserver, 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. don't use global of build-in type or struct since no multithread control.
  2. don't use global of class instanse since confusing construction/distruction.

actually:

  1. only use class pointer;
  2. only reference it by ``extern g_VarXXX";
  3. no local function for operation on global variable only, means:
  4. all operations over global variables should be self-contained;
  5. all global variable pointers stay valid during the whole procedure;

Since I already have a powerful log system, I won't use exception. If un-recoverable error happens

  1. log system record the detailed info by LOGTYPE_FATAL;
  2. then just let it crash, or use exit(0) to do forced kill;

The function who throws always think it's a fatal error so it just throw, but how to handle this ``fatal" error or do catch sub-clause really takes it as fatal is decided not by the thrower, but the catcher.

For modules like mapeditor which doesn't have a log system, always put assertion to check parameters. If functions invoked with invalid parameters, fail assertion and let it crash.

General rules for functions:

  1. put strict parameters check above doing actual logic;
  2. take invalid argument as severe error, just log the error and let it crash;
  3. never give assumption for argument;
  4. try best to make each memeber function self-contained to avoid first-half / second-half splitted functions;

General rules for classes:

  1. an object should be in legal state when created, by factory method or constructor;
  2. an object should stay valid if no input provided;
  3. put strict parameters check when provide input to objects, and reject immedately if not valid;
  4. avoid to do state validation outside an object;
  5. external call of member function should never break current object, keep log instead;

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.
  • theron - A lightweight C++ concurrency library based on the Actor Model.
  • 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.
  • mariadb - A community-developed fork of the MySQL relational database management system.
  • luasql - LuaSQL is a simple interface from Lua to a DBMS.
  • 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.
  • libzip - C library for reading, creating, and modifying zip archives.
  • ThreadPool - A simple C++11 Thread Pool implementation
  • astar-algorithm - Implementation of the A* algorithm in C++ and C#

mir2x's People

Contributors

ahe01 avatar amdmi3 avatar etorth avatar

Watchers

 avatar  avatar

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.