From ce48af53646cd9e7ec762fc1ac176b3aa620b11d Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 5 May 2011 00:57:07 +0200 Subject: - refactorized the whole project and made a few subprojects - replaced tcp with enet - added connect dialog - some smaller bugfixes --- pacman-c++/common/util.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pacman-c++/common/util.h (limited to 'pacman-c++/common/util.h') diff --git a/pacman-c++/common/util.h b/pacman-c++/common/util.h new file mode 100644 index 0000000..1ec82b3 --- /dev/null +++ b/pacman-c++/common/util.h @@ -0,0 +1,39 @@ +#ifndef UTIL_H +#define UTIL_H + +#include "constants.h" +#include "actor.h" +#include "pacman.pb.h" + +extern "C" { +#include "enet/enet.h" +} + +namespace Util +{ + Transmission::map_t createUninitialisedMap(); + Transmission::map_t createDemoMap(); + void placeActors(Transmission::map_t map, unsigned int players, const Color::Color *colors); + void fillPoints(Transmission::map_t map, Transmission::field_t type = Transmission::point); + Transmission::map_t createEmptyMap(); + void deleteMap(Transmission::map_t map); + + Transmission::field_t actorMovementToTransmission(Actor::Movement mov, + Transmission::field_t def = Transmission::none); + Actor::Movement transmissionMovementToActor(Transmission::field_t field, + Actor::Movement def = Actor::None); + const QString colorToString(Color::Color color); + + /* send packet with error check and flush */ + QSharedPointer createPacket(const ::google::protobuf::MessageLite& packet); + bool sendPacket(QByteArray *data, ENetPeer *peer, ENetHost *host); + bool sendPacket(const ::google::protobuf::MessageLite& packet, ENetPeer *peer, ENetHost *host); + QSharedPointer receivePacket(ENetPacket *packet); + + int floorLog2(unsigned int n); + +#if 0 + void hexdump(void *pAddressIn, long lSize); +#endif +} +#endif // UTIL_H -- cgit v1.2.3