-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathCommsManager.h
More file actions
83 lines (69 loc) · 2.1 KB
/
Copy pathCommsManager.h
File metadata and controls
83 lines (69 loc) · 2.1 KB
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
#pragma once
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2025 The MMapper Authors
#include <QString>
#include <QObject>
#include <QSet>
#include <QPair>
#include "../global/utils.h"
class GmcpMessage;
enum class NODISCARD CommType {
TELL,
WHISPER,
GROUP,
SAY,
EMOTE,
NARRATE,
YELL,
PRAY,
SHOUT,
SING,
ASK,
SOCIAL
};
enum class NODISCARD CommCategory {
DIRECT, // tells, whispers
LOCAL, // say, emote, social
GLOBAL // narrate, yell, pray, shout, sing, ask (questions)
};
enum class NODISCARD TalkerType {
YOU, // Messages sent by the player (talker: "you")
PLAYER, // Regular player (no talker-type specified)
NPC, // NPC (talker-type: "npc")
ALLY, // Ally (talker-type: "ally")
NEUTRAL, // Neutral (talker-type: "neutral")
ENEMY // Enemy (talker-type: "enemy")
};
struct NODISCARD CommMessage final
{
CommType type = CommType::SAY;
CommCategory category = CommCategory::LOCAL;
QString sender;
QString message;
QString timestamp;
TalkerType talkerType = TalkerType::PLAYER;
};
class CommsManager final : public QObject
{
Q_OBJECT
public:
explicit CommsManager(QObject *parent);
~CommsManager() override;
DELETE_CTORS_AND_ASSIGN_OPS(CommsManager);
public slots:
void slot_parseGmcpInput(const GmcpMessage &msg);
void slot_parseRawGameText(const QString &rawText);
signals:
void sig_newMessage(const CommMessage &msg);
void sig_log(const QString &module, const QString &message);
private:
void parseCommChannelText(const GmcpMessage &msg);
void parseFallbackYell(const QString &rawText);
CommType getCommTypeFromChannel(const QString &channel);
CommCategory getCategoryFromType(CommType type);
void trackYellMessage(const QString &sender, const QString &message);
bool isRecentYellDuplicate(const QString &sender, const QString &message) const;
// Track recent GMCP yells to avoid duplicates from fallback parsing
// Format: "sender|message" -> timestamp (in msecs since epoch)
QHash<QString, qint64> m_recentYells;
};