Skip to content

A multi-player network Bomberman game written in C++ using boost::asio and boost::tfl for (very!) elegant serialization

Notifications You must be signed in to change notification settings

eerio/network-bomberman

Repository files navigation

Multiplayer, network Bomberman

This repository contains an implementation of the Bomberman game which I have developed as part of my Computer Networks course at the University of Warsaw (MIMUW). It uses Boost::ASIO for the networking part and Boost::PFR for reflecion, which I have used for an elegant serialization implementation.

Please take a look at the below code for serialization:

template <typename ... Ts>
streamable_buffer& operator<<(streamable_buffer& stream, std::variant<Ts ...>& variant) {
std::visit([&stream](auto&& x){ stream << x; }, variant);
return stream;
}
template <is_class Compound>
streamable_buffer& operator<<(streamable_buffer& stream, Compound obj) {
if constexpr (requires {obj.msg_id;}) {
stream << obj.msg_id;
}
boost::pfr::for_each_field(
obj,
[&stream](const auto& elt) { stream << elt; }
);
return stream;
}
It relies on reflection heavily: notably, it uses the boost::pfr::for_each_field, which is easy to do in Python, but certainly not in C++ :) (but I heard that there is a plan to add reflection to the C++ standard). Using the functions from this file (serialization.hpp), you can serialize std::vector, std::map, std::string, std::variant and simple custom structs using just the good old << operator (e.g. buffer << struct_representing_my_message).

The repository doesn't contain a GUI - we have been provided an implementation of it, authored by the problem's creator. The main files are robots-client.cpp and robots-server.cpp.

About

A multi-player network Bomberman game written in C++ using boost::asio and boost::tfl for (very!) elegant serialization

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published