-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathPartyHelp.cpp
165 lines (127 loc) · 3.05 KB
/
PartyHelp.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
#include "stdafx.h"
#ifdef MODULE_PARTYHELP
static MyTimer stTimer[8];
void ResponseInvite(){
if (tAutoParty.isOn){
for (int i=0; i<8 ; i++ ){
if ( stTimer[i].fEnable == TRUE ){
if ( GetTickCount()-stTimer[i].dwTimer>mAutoPartyDelays){
BYTE acceptInvite[6] = {0x5E,0x08};
*(DWORD*)&acceptInvite[2] =stTimer[i].dwValue;
D2SendPacket(sizeof(acceptInvite), 0, acceptInvite);
memset( stTimer , 0 , sizeof(stTimer));
return;
}
}
}
}
}
BOOL CheckInvite() {
if ( dwPlayerId==1 )return TRUE;
for (RosterUnit *pUnit = PLAYERLIST; pUnit; pUnit = pUnit->pNext)
{
if (pUnit->dwUnitId<dwPlayerId) return FALSE; //自己不是最小编号,放弃邀请权利
}
return TRUE;
}
void InviteAll() {
for (RosterUnit *pUnit = PLAYERLIST; pUnit; pUnit = pUnit->pNext)
{
if (pUnit->dwUnitId==dwPlayerId || pUnit->dwPartyFlags)
continue;
BYTE InvitePlayer[6] = {0x5E,0x06};
*(DWORD*)&InvitePlayer[2] = pUnit->dwUnitId;
D2SendPacket(sizeof(InvitePlayer), 0, InvitePlayer);
}
}
void PermitAll() {
for (RosterUnit *pUnit = PLAYERLIST; pUnit; pUnit = pUnit->pNext)
{
if (pUnit->dwUnitId==dwPlayerId )
continue;
BYTE PermitPlayer[7] = {0x5D,0x01,0x01};
*(DWORD*)&PermitPlayer[3] = pUnit->dwUnitId;
D2SendPacket(sizeof(PermitPlayer), 0, PermitPlayer);
}
}
void __stdcall AutoParty(BYTE *aPacket)
{
if ( tAutoParty.isOn && aPacket[1] == 0x07 && aPacket[2] == 0x02 && aPacket[7] == 0x05 )
{
// Player Is Asking To Party With You
// Player ID = aPacket[3~6]
// Send packet back: 5E 08 xx xx xx xx
for (int i=0; i<8 ; i++ ){
if ( stTimer[i].fEnable == FALSE ){
stTimer[i].dwValue = *(DWORD*)&aPacket[3];
stTimer[i].dwTimer = GetTickCount();
stTimer[i].fEnable = TRUE;
break;
}
}
}
else if(aPacket[1] == 0x03 || aPacket[1] == 0x00)
{
if( CheckInvite() ) fCanInvite = TRUE; //有玩家离开游戏
}
}
void __declspec(naked) RecvCommand_5A_Patch_ASM()
{
__asm
{
pop eax //ret code
sub esp, 0x28
push esi
push edi
push eax //ret code
push ecx
push ecx;
call AutoParty;
pop ecx
ret
}
}
void __stdcall AutoInvite(BYTE *aPacket)
{
if (tAutoInvite.isOn && fCanInvite )
{
//自动邀请
DWORD recPlayerId= *(DWORD*)&aPacket[3];
if (recPlayerId==dwPlayerId) return;
BYTE InvitePlayer[6] = {0x5E,0x06};
InvitePlayer[2] = aPacket[3];
InvitePlayer[3] = aPacket[4];
InvitePlayer[4] = aPacket[5];
InvitePlayer[5] = aPacket[6];
D2SendPacket(sizeof(InvitePlayer), 0, InvitePlayer);
}
if ( tAutoPermit.isOn && fCanPermit ){
//自动开锁
DWORD recPlayerId= *(DWORD*)&aPacket[3];
if (recPlayerId==dwPlayerId) return;
BYTE PermitPlayer[7] = {0x5D,0x01,0x01};
PermitPlayer[3] = aPacket[3];
PermitPlayer[4] = aPacket[4];
PermitPlayer[5] = aPacket[5];
PermitPlayer[6] = aPacket[6];
D2SendPacket(sizeof(PermitPlayer), 0, PermitPlayer);
}
}
void __declspec(naked) RecvCommand_5B_Patch_ASM()
{
__asm
{
//ecx = cmdbuf
pop eax
push esi
push eax //ret code
push ecx
push ecx
call AutoInvite
pop ecx
lea esi, dword ptr [ecx+22]
mov eax, esi
ret
}
}
#endif