-
Notifications
You must be signed in to change notification settings - Fork 13
/
GameFilter.cpp
220 lines (174 loc) · 3.67 KB
/
GameFilter.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
#include "stdafx.h"
#ifdef MODULE_GAMEFILTER
// 4*eax+6FA2A900
static D2EditBox *pD2FilterBox = NULL ;
static DWORD pdwGamelist[1000] = {0, };
static char szFilter[30];
static int mGames = 0;
static int mGameShows = 0 ;
BOOL fQuickRefresh = 0;
BOOL fAddlistProc = 0;
void ResetGameList(){
memset(pdwGamelist , 0 , sizeof(pdwGamelist) ) ;
mGames = 0;
mGameShows = 0;
}
BOOL __fastcall D2MCPPacketHandler_05_Patch(BYTE* aPacket){
//刷新列表时会将游戏列表重新发一次
if(pD2FilterBox){
DWORD dwIndex = *(DWORD*)&aPacket[3];
BYTE nPlayers = aPacket[7];
fAddlistProc = TRUE ;
if ( !dwIndex || nPlayers==0 ){
fAddlistProc = FALSE;
return TRUE;
}
for(int i =0 ; i<mGames ; i ++ ){
if ( pdwGamelist[i] == dwIndex ) return TRUE;
}
char szTemp[30] ;
strncpy(szTemp , (char*)&aPacket[12] , 29);
_strupr(szTemp);
if( szFilter[0] && !strstr(szTemp ,szFilter) ){
mGames++;
return FALSE;
}else{
pdwGamelist[mGames++] = dwIndex;
mGameShows++;
return TRUE;
}
}
return TRUE;
}
void __declspec(naked) D2MCPPacketHandler_05_Patch_ASM()
{
__asm{
pop eax //ret addr
push ecx
push esi
push eax //push ret addr
push ecx
push edx
call D2MCPPacketHandler_05_Patch
test eax , eax
pop edx
pop ecx
mov eax, dword ptr [ecx+0x8]
jz noadd
ret
noadd:
add dword ptr [esp] , 0x45
ret
}
}
BOOL __stdcall Filterbox_ReturnHandler(wchar_t* wText)
{
wchar_t *p = wText;
int i = 0 ;
while(*p){
szFilter[i++] = (char)*(p++);
}
szFilter[i] = '\0';
_strupr(szFilter);
fQuickRefresh = 1;
return TRUE;
}
BOOL __stdcall Filterbox_InputHandler(D2EditBox* pBox, DWORD dwLength, char *pChar)
{
return TRUE;
}
void CreateFilterBox(){
if ( !pD2FilterBox ){
ResetGameList();
pD2FilterBox = D2CreateEditBox(599, 185, 145, 41, 7, 18,
D2LoadUiImage("DATA\\GLOBAL\\UI\\FrontEnd\\textbox2"),
(DWORD)Filterbox_ReturnHandler, 0, 0,
p_D2EditboxPreferences);
if (pD2FilterBox) {
D2SetEditBoxProc( pD2FilterBox , Filterbox_InputHandler);
pD2FilterBox->dwMaxLength = 6;
//(pD2FilterBox->fnCallBack)( pD2FilterBox );
}
}
}
void __declspec(naked) CreateGameBoxPatch_ASM()
{
__asm{
push esi
push eax
call CreateFilterBox
pop eax
pop esi
mov edx, 0x10
ret
}
}
void __stdcall DestroyGamelistPatch( D2EditBox* pListBox ){
if( pListBox && pD2FilterBox ){
ResetGameList();
D2DestroyEditBox(pD2FilterBox);
pD2FilterBox = NULL;
}
D2DestroyListBox( pListBox );
}
void __declspec(naked) GameListRefreshTimePatch_ASM()
{
__asm{
cmp eax, 0x3A98 //原始判断,15秒
jb mytest
jmp refresh
mytest:
cmp eax , 0x5DC
jb norefresh
cmp [fAddlistProc] , 1 //还在加载
je norefresh
cmp [fQuickRefresh] , 0
je norefresh
refresh:
mov [fQuickRefresh] , 0
pushad
call ResetGameList
popad
ret
norefresh:
add dword ptr [esp] , 0x16
ret
}
}
void DrawGameListPatch(){
if ( (*p_D2GameListControl) && pD2FilterBox ){
wchar_t wszTemp[200];
DWORD dwOldFone = D2SetTextFont(1);
if( szFilter[0] ){
wsprintfW2( wszTemp , " %d / %d (*%s*)" , mGameShows , mGames ,szFilter );
}else{
wsprintfW( wszTemp , L" %d / %d " , mGameShows , mGames );
}
D2DrawText(L"Filter", 545, 170, 4, -1);
D2DrawText(wszTemp, 424, 190, 4, -1);
if ( fAddlistProc ){
static int loading = 50;
int max = loading/50 ;
for( int i = 0 ; i< max ;i++ ){
wszTemp[i] = L'.';
}
wszTemp[max] = L'\0';
D2DrawText(wszTemp, 424, 170, 4, -1);
loading++;
if( loading>600 ) loading = 50;
}
D2SetTextFont(dwOldFone);
}
}
void __declspec(naked) DrawGameListPatch_ASM()
{
__asm{
push esi
call DrawGameListPatch
pop esi
mov esi, dword ptr [esi+0x3C]
test esi, esi
ret
}
}
#endif