-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathChatMsgs.cpp
More file actions
128 lines (98 loc) · 3.27 KB
/
ChatMsgs.cpp
File metadata and controls
128 lines (98 loc) · 3.27 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "StdAfx.h"
#include "PhysicsObj.h"
#include "Monster.h"
#include "Player.h"
//Network access.
#include "Client.h"
#include "BinaryWriter.h"
#include "ChatMsgs.h"
#define MESSAGE_BEGIN(x) BinaryWriter *x = new BinaryWriter
#define MESSAGE_END(x) return x
BinaryWriter *LocalChat(const char *szText, const char *szName, DWORD dwSourceID, long lColor)
{
MESSAGE_BEGIN(LocalChat);
LocalChat->WriteDWORD(0x02BB);
LocalChat->WriteString(szText);
LocalChat->WriteString(szName);
LocalChat->WriteDWORD(dwSourceID);
LocalChat->WriteLong(lColor);
MESSAGE_END(LocalChat);
}
BinaryWriter *EmoteChat(const char* szText, const char* szName, DWORD dwSourceID)
{
MESSAGE_BEGIN(EmoteChat);
EmoteChat->WriteDWORD(0x1E0);
EmoteChat->WriteDWORD(dwSourceID);
EmoteChat->WriteString(szName);
EmoteChat->WriteString(szText);
MESSAGE_END(EmoteChat);
}
//0x5719F5DB
BinaryWriter *DirectChat(const char* szText, const char* szName, DWORD dwSourceID, DWORD dwDestID, long lColor)
{
//Fake-tells: bit 10 must be set.
//Envoy: bit 21 must be set.
//Example:
//Step 1. Take a DWORD of any value. (entirely random if you wish, it doesn't matter.)
//Step 2. Remove bits 10 and 21 from that DWORD.
//Step 3. If FAKE-tell: set bit 10 (other don't.) These tells will never be drawn to the chat.
//Step 4. If Envoy: set bit 21 (otherwise don't.) These tells will be prefixed with '+Envoy'.
//Step 5. Now take the DWORD and XOR it against the source player's GUID.
//The final result will be the magic number.
#define RANDOM_LONG() ((rand() << 30) | (rand()<<15) | rand()) // RAND_MAX=7fff
BOOL bFakeTell = FALSE;
BOOL bEnvoy = FALSE;
DWORD dwMagicValue;
dwMagicValue = RANDOM_LONG(); //Step 1
dwMagicValue &= ~((1 << 10) | (1 << 21)); //Step 2
if (bFakeTell) //Step 3
dwMagicValue |= 1 << 10;
if (bEnvoy) //Step 4
dwMagicValue |= 1 << 21;
dwMagicValue ^= dwSourceID; //Step 5
MESSAGE_BEGIN(DirectChat);
DirectChat->WriteDWORD(0x2BD);
DirectChat->WriteString(szText);
DirectChat->WriteString(szName);
DirectChat->WriteDWORD(dwSourceID);
DirectChat->WriteDWORD(dwDestID);
DirectChat->WriteLong(lColor);
DirectChat->WriteDWORD(dwMagicValue);
MESSAGE_END(DirectChat);
}
BinaryWriter *ActionChat(const char* szText, const char* szName, DWORD dwSourceID)
{
MESSAGE_BEGIN(EmoteChat);
EmoteChat->WriteDWORD(0x1E2);
EmoteChat->WriteDWORD(dwSourceID);
EmoteChat->WriteString(szName);
EmoteChat->WriteString(szText);
MESSAGE_END(EmoteChat);
}
BinaryWriter *ServerText(const char *szText, long lColor)
{
MESSAGE_BEGIN(ServerText);
ServerText->WriteDWORD(0xF7E0);
ServerText->WriteString(szText);
ServerText->WriteLong(lColor);
MESSAGE_END(ServerText);
}
BinaryWriter *ServerBroadcast(const char *szSource, const char *szText, long lColor)
{
// Using string class to prevent from static buffer collisions.
std::string strBroadcast;
strBroadcast = "Broadcast from ";
strBroadcast += szSource;
strBroadcast += "> ";
strBroadcast += szText;
MESSAGE_END(ServerText(strBroadcast.c_str(), lColor));
}
BinaryWriter *ChannelChat(DWORD dwChannel, const char* szName, const char* szText)
{
MESSAGE_BEGIN(ChannelChat);
ChannelChat->WriteDWORD(0x14A);
ChannelChat->WriteDWORD(dwChannel);
ChannelChat->WriteString(szName);
ChannelChat->WriteString(szText);
MESSAGE_END(ChannelChat);
}