JSPM

  • Created
  • Published
  • Downloads 214
  • Score
    100M100P100Q50248F
  • License Apache-2.0

Pure C library for building simple and elegant cross-platform multiplayer client-server solutions.

Package Exports

  • librg.c

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (librg.c) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

librg
build status version discord license

Making multi-player simpler since 2017. Single-header cross-platform world replication library in pure C99.
Built with love using zpl • Brought to you by @inlife, @zaklaus and other contributors

Introduction

librg is a lightweight library that can be used to serve as a middleware between data-transferring libraries (networking, file-streaming, etc.) and core application/game logic.

Main responsibilities of the library include:

  • entity tracking (tracks which entity belongs to what world, and what states do they have)
  • owner tracking (tracks which participant owns what entity)
  • area of interest management (controls what can and cannot be seen a participant)
  • world replication (re-creates a limited representation in a destination world of what is considered visible to a participant in the source world)

The library was born to solve complexities of setting up and managing the flow of multi-player games and dedicated game servers. It came a long way of stripping out things that were non-essential, slowly sculpting in its current form, which you are able to see and use today.

Features

  • cross-platform support
  • lightweight, single-header
  • compile- and run-time configurable
  • written in C99 (portability reasons)
  • no external dependencies
  • built-in unit test coverage

F.A.Q.

Question: Is this a networking library?

Answer: Not really, no. It is intended to be used with netwoking in mind, but it does not have any networking capabilities on its own.

Question: Can I use any networking library with it?

Anwser: Yes. All you need is an ability to read data to and from the buffer, and most libraries do support that.

Question: The repository contains a bunch of *.h and *.c files, and yet you suggest it is a single-header library, how is that possible?

Answer: The library is spread into multiple files so it is easier to work with it while developing, however each time a new release is created, a "bundled" version of the header file is created and pushed directly to the releases page.

Question: You've mentioned entities in the description above, does it mean I would need to use another entity system?

Answer: No, the library does not manage nor actually create its own entities, it rather expects you to provide your entity/object id to attach some internal data onto it, which in context of the library we call "tracking".

Documentation

To read detailed documentation about the library, see examples and quick start guide, please visit our documentation page.

Additionally you can check code/apps folder for actual code examples.

Migration

If you've used the library before version v6.0.0, it is recommended to read the migration guide located here.

Support

We are testing the library for various platforms. This table provides some sort of description for compatibility. If you have tested it, and your result is different from the one in the table, please feel free to describe the issue in the issues.

Platform / Result Windows macOS Linux iOS Android Raspberry Pi OpenBSD FreeBSD Emscripten
clang clang gcc, clang gcc, clang gcc, clang
msvc, mingw gcc, clang gcc, clang emcc

Legend:

  • ❔ - Library was not tested on this platform/compiler yet
  • ✅ - Library successfully compiles and all tests are executed properly

Development

If you wish to contribute, add new feature, optimizations, or overall improvements, here are the instructions on how to do that:

  1. Clone the repo, f.e.: git clone https://github.com/zpl-c/librg.git
  2. Run make to build all projects, and verify everything works
  3. Develop a feature, add tests for it in code/tests/
  4. And eventually run make test again to check

In case you are working from Windows, and/or are not able to use make, you can also use built-in cmake config file to generate a Visual Studio solution, to do that:

  1. mkdir build
  2. cd build
  3. cmake ../misc -G"Visual Studio 16 2019" (or any configuration you have)
  4. cmake --open . (opens VS with the solution)
  5. And repeat steps from above