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
//! Decodes the Message Events.
//! These are stored in an embedded file in the MPQ file called 'replay.message.events'
//! Somehow it should 4 bits instead of 3 bits for the GameEMessageId...
//! In our code it translates to 3 bits needed to represent 5 possible enum variants.
use serde::{Deserialize, Serialize};
use std::str::Utf8Error;
/// A list of errors when handling MessageEvents
#[derive(Debug, thiserror::Error)]
pub enum MessageEventError {
/// An error to be used in TryFrom, when converting from protocol-specific types into our
/// consolidated-types
#[error("Unsupported Event Type")]
UnsupportedEventType,
/// Conversion to UTF-8 failed, from the `Vec<u8>` "name" fields in the proto fields
#[error("Utf8 conversion error")]
Utf8Error(#[from] Utf8Error),
}
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct MessageEvent {
pub delta: i64,
pub user_id: i64,
pub event: ReplayMessageEvent,
}
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub enum ReplayMessageEvent {
EChat(ChatMessage),
/*EPing(GameSPingMessage),
ELoadingProgress(GameSLoadingProgressMessage),
EServerPing(GameSServerPingMessage),
EReconnectNotify(GameSReconnectNotifyMessage),*/
}
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct ChatMessage {
pub m_recipient: GameEMessageRecipient,
pub m_string: String,
}
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub enum GameEMessageRecipient {
EAll,
EAllies,
EIndividual,
EBattlenet,
EObservers,
}