Praefectus is a non-steplocking variant of the Lockstep Protocol, suitable for use in totally decentralised, real-time, networked applications, in particular real-time games.
The protocol makes logic cheats (eg, speed hacks) impossible, and reduces the viability of delayed-action and lookahead cheats. In the absence of Sybil attacks, it is additionally possible to guarantee that lookahead cheats are impossible.
There is also a simple game built on top of the praefectus library. It's not very fun, though, given the time constraints on the project.
libpraefectus itself has been tested to work correctly on the following platforms:
- FreeBSD 10.x, amd64 and x86
- OpenBSD 5.5, amd64
- DragonFly(BSD) 3.8, 4.0 amd64
- Debian Jessie, amd64 and x86
- Ubuntu 14.04 amd64
There is code to support Windows; in theory, it should work, but this has not yet been tested.
For the library, a C89 compiler, asn1c
, autotools (including libtool),
pkg-config
, the GMP library, and a C library including the BSD extensions. On
GNU systems, libbsd[-dev] provides this. The example game also requires SDL2.x
and a C99 compiler.
If you want to run the unit tests, also make sure check
/libcheck
are
installed, and that $CC
is a relatively recent version of GCC (clang can't
compile the tests).
For Debianoids, including Ubuntu, you can get all the dependencies via
sudo apt-get install build-essential libbsd-dev libsdl2-dev asn1c \
autoconf automake libtool libgmp-dev
To build, run
autoreconf -i
./configure
make
If you want to build the demo game, run ./configure --enable-demos
instead of
just ./configure
.
make install
will install things, but unless you really like playing a square
in space, there isn't much utility to this.
To run unit tests, make sure check is installed (sudo apt-get install check
on Debianoids), rerun ./configure
if necessary, then run make check
.
libpraefectus can be installed as a normal shared library with make install
,
which should make it possible to link against it with -lpraefectus
and to
include its headers as #include <libpraefectus/system.h>
and so forth. Note
that you will need to have $PREFIX/libpraefectus/asn1-support
directly on
your include path since some of the generated files depend on that.
The shared library route is not always the best approach. If your project uses Autotools as its build system, it is often easier to simply embed praefectus as a submodule and link statically.
The contents of src/praefectus/game will likely help understand how things fit together, as it's a pretty simple yet interesting stack.
libpraefectus is pretty big, but pretty much all the public APIs are fairly well-documented. You'll want to start learning how objects and events work first. The context system describes how these fit together, though your application won't touch contexts directly unless you're doing something truly unusual.
The concept of event voting is described in transactor.h. Your application will likely need to handle this itself at least partially at some point (though likely via a higher-level interface), but you don't need to understand this immediately.
The top-level API is the system API. You need to provide the glue to the lower layers to this API; it's recommended you at least start with the basic implementation and adapt/extend it as necessary.
Headers whose names begin with hyphens do not have anything resembling a stable API. Other headers are unlikely to have incompatible API or ABI changes, though the library is still in a somewhat developmental stage, so this is not yet guaranteed.
For actual networking, you probably want the UDP message bus. If you want to use something that's not UDP, you need to implement that yourself.