summaryrefslogtreecommitdiff
path: root/src/mumblemanager.h
blob: d2372e631ab8693c99bc5e6f0edde27cbdf8d8bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 *  Code taken from: http://mumble.sourceforge.net/Link
 *
 *  All code listed below is in the public domain and can be used, shared or
 *  modified freely
 *
 *  Copyright (C) 2011-2019  The ManaPlus Developers
 */

#ifndef MUMBLEMANAGER_H
#define MUMBLEMANAGER_H

#ifdef USE_MUMBLE

#include <string>
#if defined (__FreeBSD__) || (defined __DragonFly__)
#include <sys/stat.h>
#endif  // defined (__FreeBSD__) || (defined __DragonFly__)

#include "localconsts.h"

struct LinkedMem final
{
    LinkedMem() :
        uiVersion(0U),
        uiTick(0U),
        fAvatarPosition(),
        fAvatarFront(),
        fAvatarTop(),
        name(),
        fCameraPosition(),
        fCameraFront(),
        fCameraTop(),
        identity(),
        context_len(0U),
        context(),
        description()
    { }

    A_DELETE_COPY(LinkedMem)

    uint32_t uiVersion;
    uint32_t uiTick;
    float fAvatarPosition[3];
    float fAvatarFront[3];
    float fAvatarTop[3];
    wchar_t name[256];
    float fCameraPosition[3];
    float fCameraFront[3];
    float fCameraTop[3];
    wchar_t identity[256];
    uint32_t context_len;
    char context[256];
    wchar_t description[2048];
};

class MumbleManager final
{
    public:
        MumbleManager();

        A_DELETE_COPY(MumbleManager)

        ~MumbleManager();

        void init();

        void setPlayer(const std::string &userName);

        void setAction(const int action);

        void setPos(const int tileX, const int tileY, const int direction);

        void setMap(const std::string &mapName);

        void setServer(const std::string &serverName);

    private:
        static uint16_t getMapId(std::string mapName) A_WARN_UNUSED;

        void setMapBase(uint16_t mapid);

        LinkedMem *mLinkedMem;
        LinkedMem mLinkedMemCache;
        float mMapBase[3];
};

extern MumbleManager *mumbleManager;

#endif  // USE_MUMBLE
#endif  // MUMBLEMANAGER_H