- Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathControl.cpp
More file actions
Latest commit
588 lines (519 loc) · 23.3 KB
/
Copy pathControl.cpp
File metadata and controls
588 lines (519 loc) · 23.3 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
#include"Control.h"
#include"D2Ptrs.h"
#include"D2Helpers.h"
#include"Helpers.h"
#include"Constants.h"
Control* findControl(int Type, int LocaleID, int Disabled, int PosX, int PosY, int SizeX, int SizeY) {
if (ClientState() != ClientStateMenu)
returnNULL;
wchar_t* localeStr = NULL;
if (LocaleID >= 0) {
localeStr = _wcsdup(D2LANG_GetLocaleText((WORD)LocaleID));
if (!localeStr)
returnNULL;
Control* res = findControl(Type, localeStr, Disabled, PosX, PosY, SizeX, SizeY);
free(localeStr);
return res;
}
returnNULL;
}
Control* findControl(int Type, constwchar_t* Text, int Disabled, int PosX, int PosY, int SizeX, int SizeY) {
if (ClientState() != ClientStateMenu)
returnNULL;
if (Type == -1 && Text == NULL && Disabled == -1 && PosX == -1 && PosY == -1 && SizeX == -1 && SizeY == -1)
return *p_D2WIN_FirstControl;
BOOL bFound = FALSE;
for (Control* pControl = *p_D2WIN_FirstControl; pControl; pControl = pControl->pNext) {
if (Type >= 0 && static_cast<int>(pControl->dwType) == Type)
bFound = TRUE;
elseif (Type >= 0 && static_cast<int>(pControl->dwType) != Type) {
bFound = FALSE;
continue;
}
if (Disabled >= 0 && static_cast<int>(pControl->dwDisabled) == Disabled) {
if (pControl->dwType == CONTROL_BUTTON && pControl->unkState == 1) {
bFound = FALSE;
continue;
}
bFound = TRUE;
} elseif (Disabled >= 0 && static_cast<int>(pControl->dwDisabled) != Disabled) {
bFound = FALSE;
continue;
}
if (PosX >= 0 && static_cast<int>(pControl->dwPosX) == PosX)
bFound = TRUE;
elseif (PosX >= 0 && static_cast<int>(pControl->dwPosX) != PosX) {
bFound = FALSE;
continue;
}
if (PosY >= 0 && static_cast<int>(pControl->dwPosY) == PosY)
bFound = TRUE;
elseif (PosY >= 0 && static_cast<int>(pControl->dwPosY) != PosY) {
bFound = FALSE;
continue;
}
if (SizeX >= 0 && static_cast<int>(pControl->dwSizeX) == SizeX)
bFound = TRUE;
elseif (SizeX >= 0 && static_cast<int>(pControl->dwSizeX) != SizeX) {
bFound = FALSE;
continue;
}
if (SizeY >= 0 && static_cast<int>(pControl->dwSizeY) == SizeY)
bFound = TRUE;
elseif (SizeY >= 0 && static_cast<int>(pControl->dwSizeY) != SizeY) {
bFound = FALSE;
continue;
}
if (Text && pControl->dwType == CONTROL_BUTTON) {
if (!pControl->wText2)
returnNULL;
if (wcscmp(pControl->wText2, Text) == 0) {
bFound = TRUE;
} else {
bFound = FALSE;
continue;
}
}
if (Text && pControl->dwType == CONTROL_TEXTBOX) {
if (pControl->pFirstText != NULL && pControl->pFirstText->wText[0] != NULL) {
if (!pControl->pFirstText->wText[0])
returnNULL;
if (wcsstr(Text, pControl->pFirstText->wText[0]) != 0) {
bFound = TRUE;
} else {
bFound = FALSE;
continue;
}
} else {
bFound = FALSE;
continue;
}
}
if (bFound)
return pControl;
}
returnNULL;
}
boolclickControl(Control* pControl, int x, int y) {
if (ClientState() != ClientStateMenu)
returnfalse;
if (pControl) {
if (x == -1)
x = pControl->dwPosX + (pControl->dwSizeX / 2);
if (y == -1)
y = pControl->dwPosY - (pControl->dwSizeY / 2);
Sleep(100);
SendMouseClick(x, y, 0);
Sleep(100);
SendMouseClick(x, y, 1);
Sleep(100);
returntrue;
}
returnfalse;
}
BOOLOOG_CreateCharacter(constwchar_t* szCharacter, int type, bool hardcore, bool ladder) {
if (OOG_GetLocation() != OOG_CHAR_SELECT || wcslen(szCharacter) > 15 || type > 6 || type < 0)
returnFALSE;
// click the create character button
Control* ctrl = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 33, 528, 168, 60);
if (ctrl)
clickControl(ctrl);
// TODO: replace with real time checking code
int i = 0;
while ((OOG_GetLocation() != OOG_CHARACTER_CREATE) && i++ < 30)
Sleep(100);
int locs[7][5] = {
{100, 337, 80, 330, 4011}, // amazon
{626, 353, 600, 300, 4010}, // sorceress
{301, 333, 300, 330, 4009}, // necromancer
{521, 339, 500, 330, 4008}, // paladin
{400, 330, 390, 330, 4007}, // barbarian
{720, 370, 700, 370, 4012}, // druid
{232, 364, 200, 300, 4013}, // assassin
};
ctrl = findControl(CONTROL_IMAGE, (constwchar_t*)NULL, -1, locs[type][0], locs[type][1], 88, 184);
if (ctrl) {
clickControl(ctrl, locs[type][2], locs[type][3]);
Sleep(500);
clickControl(ctrl, locs[type][2], locs[type][3]);
}
// verify that the correct type got selected
ctrl = findControl(CONTROL_TEXTBOX, (constwchar_t*)NULL, -1, 0, 180, 800, 100);
wchar_t* name = D2LANG_GetLocaleText((WORD)locs[type][4]);
if (_wcsicmp(name, ctrl->pFirstText->wText[0]) != 0)
returnFALSE; // something bad happened?
// set the name
// ctrl = findControl();
// still need to find the name editbox, set the name, and click the various
// checkboxes and the ok button
returnFALSE;
}
BOOLOOG_SelectCharacter(constwchar_t* szCharacter) {
if (ClientState() != ClientStateMenu)
returnNULL;
// Select the first control on the character selection screen.
Control* pControl = findControl(CONTROL_TEXTBOX, (constwchar_t*)NULL, -1, 237, 178, 72, 93);
ControlText* cText;
while (pControl != NULL) {
if (pControl->dwType == CONTROL_TEXTBOX && pControl->pFirstText != NULL && pControl->pFirstText->pNext != NULL)
cText = pControl->pFirstText->pNext;
else
cText = NULL;
if (cText != NULL) {
if (!cText->wText[0])
returnFALSE;
wchar_t* cLine = _wcsdup(cText->wText[0]);
wchar_t* cCharacter = _wcsdup(szCharacter);
StringToLower(cLine);
StringToLower(cCharacter);
if (wcslen(cLine) == wcslen(cCharacter) && wcsstr(cLine, cCharacter) != NULL) {
free(cLine);
free(cCharacter);
if (!clickControl(pControl))
returnFALSE;
// OK Button
// Bobode Sleep(7000);
pControl = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 627, 572, 128, 35);
if (pControl) {
if (!clickControl(pControl))
returnFALSE;
returnTRUE;
} else
returnFALSE;
} else {
free(cLine);
free(cCharacter);
}
}
pControl = pControl->pNext;
}
returnFALSE;
}
voidSetControlText(Control* pControl, constwchar_t* Text) {
if (ClientState() != ClientStateMenu)
return;
if (pControl && Text) {
D2WIN_SetControlText(pControl, Text);
}
}
BOOLOOG_SelectGateway(constwchar_t* szGateway, size_t strSize) {
if (ClientState() != ClientStateMenu)
returnFALSE;
if (wcsstr(szGateway, L"ERROR"))
returnFALSE;
// Select the gateway control.
Control* pControl = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 264, 391, 272, 25);
// if the control exists and has the text label, check if it matches the selected gateway
if (pControl && pControl->wText2) {
wchar_t* wzLine = _wcsdup(pControl->wText2);
wchar_t* wzGate = _wcsdup(szGateway);
StringToLower(wzLine);
StringToLower(wzGate);
if (wcsstr(wzLine, wzGate)) {
// gateway is correct, do nothing and return true
free(wzLine);
free(wzGate);
returnTRUE;
} else {
free(wzLine);
// gateway is NOT correct, change gateway to selected gateway if it exists
// open the gateway select screen
if (!clickControl(pControl))
returnFALSE;
int index = 0;
bool gatefound = false;
// loop here till we find the right gateway if we can
pControl = findControl(CONTROL_TEXTBOX, (constwchar_t*)NULL, -1, 257, 500, 292, 160);
ControlText* cText;
if (pControl && pControl->pFirstText) {
cText = pControl->pFirstText;
while (cText) {
wchar_t* wzGatelist = _wcsdup(cText->wText[0]);
if (!wzGatelist) {
free(wzGate);
returnFALSE;
}
StringToLower(wzGatelist);
if (wcsstr(wzGatelist, wzGate)) {
// chosen gateway IS in the list and matches, cleanup and break the loop
free(wzGatelist);
free(wzGate);
gatefound = true;
break;
}
free(wzGatelist);
index++;
cText = cText->pNext;
}
if (gatefound) {
// click the correct gateway using the control plus a default x and a y based on (index*24)+12
if (!clickControl(pControl, -1, 344 + ((index * 24) + 12))) {
free(wzGate);
returnFALSE;
}
}
}
free(wzGate);
// OK Button, gateway select screen
pControl = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 281, 538, 96, 32);
if (pControl) {
if (!clickControl(pControl))
returnFALSE;
} else
returnFALSE;
returnTRUE;
}
}
returnFALSE;
}
OOG_Location OOG_GetLocation(void) {
if (ClientState() != ClientStateMenu)
returnOOG_NONE;
if (findControl(CONTROL_BUTTON, 5103, -1, 330, 416, 128, 35))
returnOOG_MAIN_MENU_CONNECTING; // 21 Connecting to Battle.net
elseif (findControl(CONTROL_BUTTON, 5102, -1, 335, 412, 128, 35))
returnOOG_LOGIN_ERROR; // 10 Login Error
elseif (findControl(CONTROL_BUTTON, 5102, -1, 351, 337, 96, 32)) // 5102 =OK
{
if (findControl(CONTROL_TEXTBOX, 5351, -1, 268, 320, 264, 120))
returnOOG_LOST_CONNECTION; // 17 lost connection
elseif (findControl(CONTROL_TEXTBOX, 5347, -1, 268, 320, 264, 120))
returnOOG_DISCONNECTED; // 14 Disconnected
elseif (findControl(6, (constwchar_t*)NULL, -1, 265, 206, 272, 35))
returnOOG_UNABLE_TO_CONNECT_TCPIP;
else
returnOOG_CHARACTER_CREATE_ALREADY_EXISTS; // 30 Character Create - Dupe Name
} elseif (findControl(CONTROL_BUTTON, 5103, -1, 351, 337, 96, 32)) // 5103 = CANCEL
{
if (findControl(CONTROL_TEXTBOX, 5243, -1, 268, 300, 264, 100))
returnOOG_CHARACTER_SELECT_PLEASE_WAIT; // 16 char select please wait...
if (findControl(CONTROL_TEXTBOX, (constwchar_t*)NULL, -1, 268, 320, 264, 120))
returnOOG_PLEASE_WAIT; // 25 "Please Wait..."single player already exists also
} elseif (findControl(CONTROL_BUTTON, 5103, -1, 433, 433, 96, 32)) {
if (findControl(CONTROL_TEXTBOX, (constwchar_t*)NULL, -1, 427, 234, 300, 100))
returnOOG_INLINE; // 2 waiting in line
elseif (findControl(CONTROL_TEXTBOX, 10018, -1, 459, 380, 150, 12))
returnOOG_CREATE; // 4 Create game
elseif (findControl(CONTROL_BUTTON, 5119, -1, 594, 433, 172, 32))
returnOOG_JOIN; // 5 Join Game
elseif (findControl(CONTROL_BUTTON, 5102, -1, 671, 433, 96, 32))
returnOOG_CHANNEL; // 7 "Channel List"
else
returnOOG_LADDER; // 6 "Ladder"
} elseif (findControl(CONTROL_BUTTON, 5101, -1, 33, 572, 128, 35)) // 5101 = EXIT
{
if (findControl(CONTROL_BUTTON, 5288, -1, 264, 484, 272, 35))
returnOOG_LOGIN; // 9 Login
if (findControl(CONTROL_BUTTON, 5102, -1, 495, 438, 96, 32))
returnOOG_CHARACTER_SELECT_CHANGE_REALM; // 43 char select change realm
if (findControl(CONTROL_BUTTON, 5102, -1, 627, 572, 128, 35) && findControl(CONTROL_BUTTON, 10832, -1, 33, 528, 168, 60)) // 10832=create new
{
if (findControl(CONTROL_BUTTON, 10018, -1, 264, 297, 272, 35)) // NORMAL
returnOOG_DIFFICULTY; // 20 single char Difficulty
Control* pControl = findControl(CONTROL_TEXTBOX, (constwchar_t*)NULL, -1, 37, 178, 200, 92);
if (pControl && pControl->pFirstText && pControl->pFirstText->pNext)
returnOOG_CHAR_SELECT; // 12 char select
else {
if (findControl(CONTROL_TEXTBOX, 11162, -1, 45, 318, 531, 140) || findControl(CONTROL_TEXTBOX, 11066, -1, 45, 318, 531, 140))
returnOOG_REALM_DOWN;
// Look for CONNECTING... string
elseif (findControl(CONTROL_TEXTBOX, 11065, -1, 0x2D, 0x13E, 0x213, 0x8C))
returnOOG_CONNECTING;
else
returnOOG_CHARACTER_SELECT_NO_CHARS; // 42 char info not loaded
}
}
if (findControl(CONTROL_BUTTON, 5101, -1, 33, 572, 128, 35)) // 5101=Exit
{
if (findControl(CONTROL_BUTTON, 5102, 0, 627, 572, 128, 35)) // 5102=ok
returnOOG_CHARACTER_CREATE; // 29 char create screen with char selected
else {
if (findControl(CONTROL_TEXTBOX, 5226, -1, 321, 448, 300, 32))
returnOOG_NEW_ACCOUNT; // 32 create new bnet account
else
returnOOG_NEW_CHARACTER; // 15 char create screen no char selected
}
}
}
if (findControl(CONTROL_BUTTON, 5102, -1, 335, 450, 128, 35)) {
if (findControl(CONTROL_TEXTBOX, 5200, -1, 162, 270, 477, 50))
returnOOG_CDKEY_IN_USE; // 19 CD-KEY in use
elseif (findControl(CONTROL_TEXTBOX, 5190, -1, 162, 420, 477, 100)) // 5190="If using a modem"
returnOOG_UNABLE_TO_CONNECT; // 11 unable to connect
else
returnOOG_INVALID_CDKEY; // 22 invalid CD-KEY
} elseif (findControl(CONTROL_TEXTBOX, 5159, -1, 438, 300, 326, 150))
returnOOG_GAME_DOES_NOT_EXIST; // 28 game doesn't exist
elseif (findControl(CONTROL_TEXTBOX, 5161, -1, 438, 300, 326, 150))
returnOOG_GAME_IS_FULL; // 38 Game is full
elseif (findControl(CONTROL_TEXTBOX, 5138, -1, 438, 300, 326, 150))
returnOOG_GAME_EXIST; // 26 Game already exists
elseif (findControl(CONTROL_TEXTBOX, 5139, -1, 438, 300, 326, 150))
returnOOG_SERVER_DOWN; // 24 server down
elseif (findControl(CONTROL_BUTTON, 5106, -1, 264, 324, 272, 35)) // 5106="SINGLE PLAYER"
returnOOG_MAIN_MENU; // 8 Main Menu
elseif (findControl(CONTROL_BUTTON, 11126, -1, 27, 480, 120, 20)) // 11126=ENTER CHAT
returnOOG_LOBBY; // 1 base bnet
elseif (findControl(CONTROL_BUTTON, 5308, -1, 187, 470, 80, 20)) // 5308="HELP"
returnOOG_CHAT; // 3 chat bnet
elseif (findControl(CONTROL_TEXTBOX, 21882, -1, 100, 580, 600, 80))
returnOOG_D2SPLASH; // 18 Spash
elseif (findControl(CONTROL_BUTTON, 5102, -1, 281, 538, 96, 32))
returnOOG_GATEWAY; // 27 select gateway
elseif (findControl(CONTROL_BUTTON, 5181, -1, 525, 513, 128, 35))
returnOOG_AGREE_TO_TERMS; // 31 agree to terms
elseif (findControl(CONTROL_BUTTON, 5102, -1, 525, 513, 128, 35))
returnOOG_PLEASE_READ; // 33 please read
elseif (findControl(CONTROL_BUTTON, 11097, -1, 265, 527, 272, 35))
returnOOG_REGISTER_EMAIL; // 34 register email
elseif (findControl(CONTROL_BUTTON, 5101, -1, 33, 578, 128, 35))
returnOOG_CREDITS; // 35 Credits
elseif (findControl(CONTROL_BUTTON, 5103, -1, 334, 488, 128, 35))
returnOOG_CINEMATICS; // 36 Cinematics
elseif (findControl(CONTROL_BUTTON, 5116, -1, 264, 350, 272, 35))
returnOOG_OTHER_MULTIPLAYER; // 39 other multi player
elseif (findControl(CONTROL_BUTTON, 5103, -1, 281, 337, 96, 32))
returnOOG_ENTER_IP_ADDRESS; // 41 enter ip
elseif (findControl(CONTROL_BUTTON, 5118, -1, 265, 206, 272, 35))
returnOOG_TCP_IP; // 40 tcp-ip
returnOOG_NONE;
}
boolOOG_CreateGame(constwchar_t* name, constwchar_t* pass, int difficulty) {
if (ClientState() != ClientStateMenu)
returnFALSE;
// reject name/password combinations over 15 characters
if (!name || !pass || wcslen(name) > 15 || wcslen(pass) > 15)
returnFALSE;
Control* pControl = NULL;
// Battle.net/open game creation
OOG_Location loc = OOG_GetLocation();
if (!(loc == OOG_LOBBY || loc == OOG_CHAT || loc == OOG_DIFFICULTY || loc == OOG_CREATE))
returnFALSE;
if (loc == OOG_DIFFICULTY) {
// just click the difficulty button
Control *normal = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 264, 297, 272, 35),
*nightmare = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 264, 340, 272, 35),
*hell = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 264, 383, 272, 35);
switch (difficulty) {
case0: // normal button
if (normal->dwDisabled != 0x0d || !clickControl(normal))
returnFALSE;
break;
case1: // nightmare button
if (nightmare->dwDisabled != 0x0d || !clickControl(nightmare))
returnFALSE;
break;
case2: // hell button
if (hell->dwDisabled != 0x0d || !clickControl(hell))
returnFALSE;
break;
case3: // hardest difficulty available
if (hell->dwDisabled != 0x0d) {
if (!clickControl(hell))
returnFALSE;
} elseif (nightmare->dwDisabled != 0x0d) {
if (!clickControl(nightmare))
returnFALSE;
} elseif (normal->dwDisabled != 0x0d) {
if (!clickControl(normal))
returnFALSE;
}
break;
default:
returnFALSE;
}
} else {
// Create button
if (loc != OOG_CREATE) {
pControl = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 533, 469, 120, 20);
if (!pControl || !clickControl(pControl))
returnFALSE;
Sleep(100);
}
if (OOG_GetLocation() == OOG_CREATE) {
// Game name edit box
if (name)
SetControlText(findControl(1, (constwchar_t*)NULL, -1, 432, 162, 158, 20), name);
else
returnFALSE;
Sleep(100);
// Password edit box
if (pass)
SetControlText(findControl(1, (constwchar_t*)NULL, -1, 432, 217, 158, 20), pass);
else
returnFALSE;
Sleep(100);
Control *normal = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 430, 381, 16, 16),
*nightmare = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 555, 381, 16, 16),
*hell = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 698, 381, 16, 16);
switch (difficulty) {
case0: // normal button
if (normal->dwDisabled == 0x4 || !clickControl(normal))
returnFALSE;
break;
case1: // nightmare button
if (nightmare->dwDisabled == 0x4 || !clickControl(nightmare))
returnFALSE;
break;
case2: // hell button
if (hell->dwDisabled == 0x4 || !clickControl(hell))
returnFALSE;
break;
case3: // hardest difficulty available
if (hell->dwDisabled != 0x4) {
if (!clickControl(hell))
returnFALSE;
} elseif (nightmare->dwDisabled != 0x4) {
if (!clickControl(nightmare))
returnFALSE;
} elseif (normal->dwDisabled != 0x4) {
if (!clickControl(normal))
returnFALSE;
}
break;
default:
returnFALSE;
}
// Create Game Button
pControl = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 594, 433, 172, 32);
if (!pControl || !clickControl(pControl))
returnFALSE;
}
}
returnTRUE;
}
boolOOG_JoinGame(constwchar_t* name, constwchar_t* pass) {
if (ClientState() != ClientStateMenu)
returnFALSE;
// reject name/password combinations over 15 characters
if (wcslen(name) > 15 || wcslen(pass) > 15)
returnFALSE;
Control* pControl = NULL;
// Battle.net/open lobby/chat area
if (!(OOG_GetLocation() == OOG_LOBBY || OOG_GetLocation() == OOG_CHAT || OOG_GetLocation() == OOG_JOIN))
returnFALSE;
// JOIN button
if (OOG_GetLocation() != OOG_JOIN) {
pControl = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 652, 469, 120, 20);
if (!pControl || !clickControl(pControl))
returnFALSE;
Sleep(100);
}
if (OOG_GetLocation() == OOG_JOIN) {
// Game name edit box
if (name)
SetControlText(findControl(1, (constwchar_t*)NULL, -1, 432, 148, 155, 20), name);
else
returnFALSE;
// Password edit box
if (pass)
SetControlText(findControl(1, (constwchar_t*)NULL, -1, 606, 148, 155, 20), pass);
else
returnFALSE;
// Join Game Button
pControl = findControl(CONTROL_BUTTON, (constwchar_t*)NULL, -1, 594, 433, 172, 32);
if (!pControl || !clickControl(pControl))
returnFALSE;
}
returnTRUE;
}