summaryrefslogtreecommitdiffstats
path: root/pacman-c++/common/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++/common/util.h')
-rw-r--r--pacman-c++/common/util.h39
1 files changed, 39 insertions, 0 deletions
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 @@
1#ifndef UTIL_H
2#define UTIL_H
3
4#include "constants.h"
5#include "actor.h"
6#include "pacman.pb.h"
7
8extern "C" {
9#include "enet/enet.h"
10}
11
12namespace Util
13{
14 Transmission::map_t createUninitialisedMap();
15 Transmission::map_t createDemoMap();
16 void placeActors(Transmission::map_t map, unsigned int players, const Color::Color *colors);
17 void fillPoints(Transmission::map_t map, Transmission::field_t type = Transmission::point);
18 Transmission::map_t createEmptyMap();
19 void deleteMap(Transmission::map_t map);
20
21 Transmission::field_t actorMovementToTransmission(Actor::Movement mov,
22 Transmission::field_t def = Transmission::none);
23 Actor::Movement transmissionMovementToActor(Transmission::field_t field,
24 Actor::Movement def = Actor::None);
25 const QString colorToString(Color::Color color);
26
27 /* send packet with error check and flush */
28 QSharedPointer<QByteArray> createPacket(const ::google::protobuf::MessageLite& packet);
29 bool sendPacket(QByteArray *data, ENetPeer *peer, ENetHost *host);
30 bool sendPacket(const ::google::protobuf::MessageLite& packet, ENetPeer *peer, ENetHost *host);
31 QSharedPointer<QByteArray> receivePacket(ENetPacket *packet);
32
33 int floorLog2(unsigned int n);
34
35#if 0
36 void hexdump(void *pAddressIn, long lSize);
37#endif
38}
39#endif // UTIL_H