forked from jewalky/a2mgr
-
Notifications
You must be signed in to change notification settings - Fork 3
/
chat.cpp
243 lines (220 loc) · 3.86 KB
/
chat.cpp
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#include "utils.h"
#include "config.h"
void _declspec(naked) CHAT_wmCharHandler(void)
{
_asm {
push ebp
mov ebp, esp
push ecx
mov [ebp - 4], ecx
cmp [ebp + 8], 0x20
jb wch_skip
cmp [ebp + 8], 0x7F
jz wch_skip
mov edx, 0x43D664
jmp edx
wch_skip:
mov edx, 0x43D680
jmp edx
}
}
char *__stdcall conv_double_tilde(char *str)
{
static char tilda_buf[4000];
char *t = tilda_buf;
while (*str && t < (tilda_buf + sizeof(tilda_buf) - 3))
{
*t++ = *str;
if (*str == '~')
*t++ = *str;
str++;
}
*t = 0;
return tilda_buf;
}
void _declspec(naked) CHAT_tilde0(void)
{
__asm
{
mov eax, [ecx]
push eax
call conv_double_tilde
push eax
mov edx, 0x043D97C
jmp edx
}
}
void _declspec(naked) CHAT_tilde1(void)
{
__asm
{
mov eax, [ecx]
push eax
call conv_double_tilde
push eax
mov edx, 0x0402710
jmp edx
}
}
void _declspec(naked) CHAT_tilde2(void)
{
__asm
{
mov eax, [ecx]
push eax
call conv_double_tilde
push eax
mov edx, 0x0402764
jmp edx
}
}
void _declspec(naked) CHAT_convWinToDos(void)
{
__asm
{
xor edx, edx
mov dl, [ebp + 8]
cmp edx, 0xA8
jnz w2d_n1
mov edx, 0xF0
mov [ebp + 8], dl
jmp w2d_skip
w2d_n1:
cmp edx, 0xB8
jnz w2d_n2
mov edx, 0xF1
mov [ebp + 8], dl
jmp w2d_skip
w2d_n2:
mov ecx, 0x047A127
jmp ecx
w2d_skip:
mov edx, 0x047A162
jmp edx
}
}
void _declspec(naked) CHAT_convDosToIdx(void)
{
__asm
{
xor eax, eax
mov al, [ebp + 8]
cmp eax, 0xF0
jnz d2a_n1
mov eax, 192+32
mov [ebp + 8], al
jmp d2a_skip
d2a_n1:
cmp eax, 0xF1
jnz d2a_n2
mov eax, 105+32
mov [ebp + 8], al
jmp d2a_skip
d2a_n2:
mov ecx, 0x0461DBE
jmp ecx
d2a_skip:
mov edx, 0x0461E10
jmp edx
}
}
char pr_c_2_str[] = "%s\n";
int _declspec(naked) CHAT_logStrings(char *s, int unk_1, int unk_2) {
__asm
{
push ebp
mov ebp, esp
sub esp, 4
push dword ptr [ebp+0x10]
push dword ptr [ebp+0x0C]
push dword ptr [ebp+8]
call sub_4021FE
mov [ebp-4], eax
push dword ptr [ebp+8]
push offset pr_c_2_str
call log_format
mov eax, [ebp-4]
mov esp, ebp
pop ebp
retn 0Ch
sub_4021FE:
push ebp
mov ebp, esp
push 0xFFFFFFFF
push 0x005C479E
mov edx, 0x00402208
jmp edx
}
}
#include "zxmgr.h"
char * _stdcall chatAddStringCpp(char *msg, int type)
{
if (g_altchat)
{
static char chatBuf[3000];
if (type == 1)
{
// àëÿ
char* str_type = zxmgr::GetPatchString(223);
static char chatB2[128];
chatB2[127] = 0;
_snprintf(chatB2, 127, "[%s] ", str_type);
strcpy(chatBuf, chatB2);
strncat(chatBuf, msg, sizeof(chatBuf)-1);
return chatBuf;
}
else if (type == 2)
{
// ïðèâàò
char* str_type = zxmgr::GetPatchString(224);
static char chatB2[128];
chatB2[127] = 0;
_snprintf(chatB2, 127, "[%s] ", str_type);
strcpy(chatBuf, chatB2);
strncat(chatBuf, msg, sizeof(chatBuf)-1);
return chatBuf;
}
else if (type == 3)
{
// âîïëü
char* str_type = zxmgr::GetPatchString(225);
static char chatB2[128];
chatB2[127] = 0;
_snprintf(chatB2, 127, "[%s] ", str_type);
strcpy(chatBuf, chatB2);
strncat(chatBuf, msg, sizeof(chatBuf)-1);
return chatBuf;
}
}
return msg;
}
void _declspec(naked) CHAT_prependType_part1()
{
__asm
{
mov ecx, [ebp-0x77C] // second byte
push ecx
push eax
call chatAddStringCpp
push eax
mov ecx, [ebp-0x11BF0]
add ecx, 0xA28
mov edx, 0x0413F93
jmp edx
}
}
void _declspec(naked) CHAT_prependType_part2()
{
__asm
{
mov ecx, [ebp-0x77C] // second byte
push ecx
push eax
call chatAddStringCpp
push eax
mov ecx, [ebp-0x11BF0]
add ecx, 0xA28
mov edx, 0x413E04
jmp edx
}
}