forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinv.cpp
More file actions
3327 lines (3246 loc) · 70.9 KB
/
inv.cpp
File metadata and controls
3327 lines (3246 loc) · 70.9 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
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//HEADER_GOES_HERE
#include "../types.h"
int invflag;
void *pInvCels;
int drawsbarflag; // idb
int sgdwLastTime; // check name
InvXY InvRect[73] =
{
{ 452, 31 }, // helmet
{ 480, 31 }, // helmet
{ 452, 59 }, // helmet
{ 480, 59 }, // helmet
{ 365, 205 }, // left ring
{ 567, 205 }, // right ring
{ 524, 59 }, // amulet
{ 337, 104 }, // left hand
{ 366, 104 }, // left hand
{ 337, 132 }, // left hand
{ 366, 132 }, // left hand
{ 337, 160 }, // left hand
{ 366, 160 }, // left hand
{ 567, 104 }, // right hand
{ 596, 104 }, // right hand
{ 567, 132 }, // right hand
{ 596, 132 }, // right hand
{ 567, 160 }, // right hand
{ 596, 160 }, // right hand
{ 452, 104 }, // chest
{ 480, 104 }, // chest
{ 452, 132 }, // chest
{ 480, 132 }, // chest
{ 452, 160 }, // chest
{ 480, 160 }, // chest
{ 337, 250 }, // inv row 1
{ 366, 250 }, // inv row 1
{ 394, 250 }, // inv row 1
{ 423, 250 }, // inv row 1
{ 451, 250 }, // inv row 1
{ 480, 250 }, // inv row 1
{ 509, 250 }, // inv row 1
{ 538, 250 }, // inv row 1
{ 567, 250 }, // inv row 1
{ 596, 250 }, // inv row 1
{ 337, 279 }, // inv row 2
{ 366, 279 }, // inv row 2
{ 394, 279 }, // inv row 2
{ 423, 279 }, // inv row 2
{ 451, 279 }, // inv row 2
{ 480, 279 }, // inv row 2
{ 509, 279 }, // inv row 2
{ 538, 279 }, // inv row 2
{ 567, 279 }, // inv row 2
{ 596, 279 }, // inv row 2
{ 337, 308 }, // inv row 3
{ 366, 308 }, // inv row 3
{ 394, 308 }, // inv row 3
{ 423, 308 }, // inv row 3
{ 451, 308 }, // inv row 3
{ 480, 308 }, // inv row 3
{ 509, 308 }, // inv row 3
{ 538, 308 }, // inv row 3
{ 567, 308 }, // inv row 3
{ 596, 308 }, // inv row 3
{ 337, 336 }, // inv row 4
{ 366, 336 }, // inv row 4
{ 394, 336 }, // inv row 4
{ 423, 336 }, // inv row 4
{ 451, 336 }, // inv row 4
{ 480, 336 }, // inv row 4
{ 509, 336 }, // inv row 4
{ 538, 336 }, // inv row 4
{ 567, 336 }, // inv row 4
{ 596, 336 }, // inv row 4
{ 205, 385 }, // belt
{ 234, 385 }, // belt
{ 263, 385 }, // belt
{ 292, 385 }, // belt
{ 321, 385 }, // belt
{ 350, 385 }, // belt
{ 379, 385 }, // belt
{ 408, 385 } // belt
};
/* rdata */
int AP2x2Tbl[10] = { 8, 28, 6, 26, 4, 24, 2, 22, 0, 20 }; // weak
void __cdecl FreeInvGFX()
{
void *v0; // ecx
v0 = pInvCels;
pInvCels = 0;
mem_free_dbg(v0);
}
void __cdecl InitInv()
{
char v0; // al
char *v1; // ecx
v0 = plr[myplr]._pClass;
switch ( v0 )
{
case UI_WARRIOR:
v1 = "Data\\Inv\\Inv.CEL";
LABEL_7:
pInvCels = LoadFileInMem(v1, 0);
break;
case UI_ROGUE:
v1 = "Data\\Inv\\Inv_rog.CEL";
goto LABEL_7;
case UI_SORCERER:
v1 = "Data\\Inv\\Inv_Sor.CEL";
goto LABEL_7;
}
invflag = 0;
drawsbarflag = 0;
}
void __fastcall InvDrawSlotBack(int X, int Y, int W, int H)
{
unsigned char *v4; // edi
int v5; // edx
int v6; // ecx
unsigned char v7; // al
unsigned char v8; // al
v4 = (unsigned char *)gpBuffer + screen_y_times_768[Y] + X;
v5 = (unsigned short)H;
do
{
v6 = (unsigned short)W;
do
{
v7 = *v4;
if ( *v4 < 0xB0u )
goto LABEL_9;
if ( v7 > 0xBFu )
{
if ( v7 < 0xF0u )
goto LABEL_9;
v8 = v7 - 80;
}
else
{
v8 = v7 - 16;
}
*v4 = v8;
LABEL_9:
++v4;
--v6;
}
while ( v6 );
v4 = &v4[-(unsigned short)W - 768];
--v5;
}
while ( v5 );
}
void __cdecl DrawInv()
{
int v0; // ecx
int v1; // eax
int v2; // esi
int v3; // ebp
char v4; // cl
int v5; // ecx
int v6; // eax
int v7; // edi
int v8; // edx
char v9; // cl
int v10; // ecx
int v11; // eax
int v12; // edi
int v13; // edx
char v14; // cl
int v15; // ecx
int v16; // eax
int v17; // esi
int v18; // edx
char v19; // cl
int v20; // ecx
int v21; // eax
int v22; // esi
int v23; // edi
int v24; // ebp
char v25; // cl
char *v26; // ecx
int v27; // ebp
int v28; // eax
int v29; // esi
int v30; // edi
char v31; // cl
int v32; // ecx
int v33; // eax
int v34; // esi
int v35; // edi
char v36; // cl
signed int v37; // esi
signed int v38; // edi
int v39; // ecx
char v40; // al
int v41; // eax
int v42; // ebp
int v43; // ecx
int v44; // esi
char v45; // al
int v46; // ecx
int v47; // edx
int screen_y; // [esp+10h] [ebp-A8h]
int screen_ya; // [esp+10h] [ebp-A8h]
int screen_yb; // [esp+10h] [ebp-A8h]
signed int screen_yc; // [esp+10h] [ebp-A8h]
signed int screen_yd; // [esp+10h] [ebp-A8h]
int screen_ye; // [esp+10h] [ebp-A8h]
signed int screen_x; // [esp+14h] [ebp-A4h]
int invtest[40]; // [esp+18h] [ebp-A0h]
CelDecodeOnly(384, 511, pInvCels, 1, 320);
if ( plr[myplr].InvBody[0]._itype != -1 )
{
InvDrawSlotBack(517, 219, 56, 56);
v0 = myplr;
v1 = myplr;
v2 = plr[myplr].InvBody[0]._iCurs + 12;
v3 = InvItemWidth[v2];
if ( !pcursinvitem )
{
v4 = -59;
if ( plr[v1].InvBody[0]._iMagical )
v4 = -75;
if ( !plr[v1].InvBody[0]._iStatFlag )
v4 = -27;
CelDecodeClr(v4, 517, 219, (char *)pCursCels, v2, v3, 0, 8);
v0 = myplr;
}
if ( plr[v0].InvBody[0]._iStatFlag )
CelDrawHdrOnly(517, 219, (char *)pCursCels, v2, v3, 0, 8);
else
CelDrawHdrLightRed(517, 219, (char *)pCursCels, v2, v3, 0, 8, 1);
}
if ( plr[myplr].InvBody[1]._itype != -1 )
{
InvDrawSlotBack(432, 365, 28, 28);
v5 = myplr;
v6 = myplr;
v7 = plr[myplr].InvBody[1]._iCurs + 12;
v8 = InvItemWidth[v7];
screen_y = InvItemWidth[v7];
if ( pcursinvitem == 1 )
{
v9 = -59;
if ( plr[v6].InvBody[1]._iMagical )
v9 = -75;
if ( !plr[v6].InvBody[1]._iStatFlag )
v9 = -27;
CelDecodeClr(v9, 432, 365, (char *)pCursCels, v7, v8, 0, 8);
v5 = myplr;
v8 = screen_y;
}
if ( plr[v5].InvBody[1]._iStatFlag )
CelDrawHdrOnly(432, 365, (char *)pCursCels, v7, v8, 0, 8);
else
CelDrawHdrLightRed(432, 365, (char *)pCursCels, v7, v8, 0, 8, 1);
}
if ( plr[myplr].InvBody[2]._itype != -1 )
{
InvDrawSlotBack(633, 365, 28, 28);
v10 = myplr;
v11 = myplr;
v12 = plr[myplr].InvBody[2]._iCurs + 12;
v13 = InvItemWidth[v12];
screen_ya = InvItemWidth[v12];
if ( pcursinvitem == 2 )
{
v14 = -59;
if ( plr[v11].InvBody[2]._iMagical )
v14 = -75;
if ( !plr[v11].InvBody[2]._iStatFlag )
v14 = -27;
CelDecodeClr(v14, 633, 365, (char *)pCursCels, v12, v13, 0, 8);
v10 = myplr;
v13 = screen_ya;
}
if ( plr[v10].InvBody[2]._iStatFlag )
CelDrawHdrOnly(633, 365, (char *)pCursCels, v12, v13, 0, 8);
else
CelDrawHdrLightRed(633, 365, (char *)pCursCels, v12, v13, 0, 8, 1);
}
if ( plr[myplr].InvBody[3]._itype != -1 )
{
InvDrawSlotBack(589, 220, 28, 28);
v15 = myplr;
v16 = myplr;
v17 = plr[myplr].InvBody[3]._iCurs + 12;
v18 = InvItemWidth[v17];
screen_yb = InvItemWidth[v17];
if ( pcursinvitem == 3 )
{
v19 = -59;
if ( plr[v16].InvBody[3]._iMagical )
v19 = -75;
if ( !plr[v16].InvBody[3]._iStatFlag )
v19 = -27;
CelDecodeClr(v19, 589, 220, (char *)pCursCels, v17, v18, 0, 8);
v15 = myplr;
v18 = screen_yb;
}
if ( plr[v15].InvBody[3]._iStatFlag )
CelDrawHdrOnly(589, 220, (char *)pCursCels, v17, v18, 0, 8);
else
CelDrawHdrLightRed(589, 220, (char *)pCursCels, v17, v18, 0, 8, 1);
}
if ( plr[myplr].InvBody[4]._itype != -1 )
{
InvDrawSlotBack(401, 320, 56, 84);
v20 = myplr;
v21 = myplr;
v22 = plr[myplr].InvBody[4]._iCurs + 12;
v23 = InvItemWidth[v22];
v24 = v23 != 28 ? 401 : 415;
screen_yc = InvItemHeight[v22] != 84 ? 306 : 320;
if ( pcursinvitem == 4 )
{
v25 = -59;
if ( plr[v21].InvBody[4]._iMagical )
v25 = -75;
if ( !plr[v21].InvBody[4]._iStatFlag )
v25 = -27;
CelDecodeClr(v25, v24, screen_yc, (char *)pCursCels, v22, v23, 0, 8);
v20 = myplr;
}
if ( plr[v20].InvBody[4]._iStatFlag )
CelDrawHdrOnly(v24, screen_yc, (char *)pCursCels, v22, v23, 0, 8);
else
CelDrawHdrLightRed(v24, screen_yc, (char *)pCursCels, v22, v23, 0, 8, 1);
if ( plr[myplr].InvBody[4]._iLoc == ILOC_TWOHAND )
{
InvDrawSlotBack(631, 320, 56, 84);
light_table_index = 0;
cel_transparency_active = 1;
v26 = &gpBuffer->row[160].pixels[581];
if ( v23 != 28 )
v26 = &gpBuffer->row[160].pixels[567];
CelDecodeHdrLightTrans(v26, (char *)pCursCels, v22, v23, 0, 8);
cel_transparency_active = 0;
}
}
if ( plr[myplr].InvBody[5]._itype != -1 )
{
InvDrawSlotBack(631, 320, 56, 84);
v27 = myplr;
v28 = myplr;
v29 = plr[myplr].InvBody[5]._iCurs + 12;
v30 = InvItemWidth[v29];
screen_yd = InvItemHeight[v29] != 84 ? 306 : 320;
if ( pcursinvitem == 5 )
{
v31 = -59;
if ( plr[v28].InvBody[5]._iMagical )
v31 = -75;
if ( !plr[v28].InvBody[5]._iStatFlag )
v31 = -27;
CelDecodeClr(v31, v30 != 28 ? 633 : 645, screen_yd, (char *)pCursCels, v29, v30, 0, 8);
v27 = myplr;
}
screen_x = v30 != 28 ? 633 : 645;
if ( plr[v27].InvBody[5]._iStatFlag )
CelDrawHdrOnly(screen_x, screen_yd, (char *)pCursCels, v29, v30, 0, 8);
else
CelDrawHdrLightRed(screen_x, screen_yd, (char *)pCursCels, v29, v30, 0, 8, 1);
}
if ( plr[myplr].InvBody[6]._itype != -1 )
{
InvDrawSlotBack(517, 320, 56, 84);
v32 = myplr;
v33 = myplr;
v34 = plr[myplr].InvBody[6]._iCurs + 12;
v35 = InvItemWidth[v34];
if ( pcursinvitem == 6 )
{
v36 = -59;
if ( plr[v33].InvBody[6]._iMagical )
v36 = -75;
if ( !plr[v33].InvBody[6]._iStatFlag )
v36 = -27;
CelDecodeClr(v36, 517, 320, (char *)pCursCels, v34, v35, 0, 8);
v32 = myplr;
}
if ( plr[v32].InvBody[6]._iStatFlag )
CelDrawHdrOnly(517, 320, (char *)pCursCels, v34, v35, 0, 8);
else
CelDrawHdrLightRed(517, 320, (char *)pCursCels, v34, v35, 0, 8, 1);
}
v37 = 0;
do
{
if ( plr[myplr].InvGrid[v37] )
InvDrawSlotBack(InvRect[v37 + 25].X + 64, InvRect[v37 + 25].Y + 159, 28, 28);
++v37;
}
while ( v37 < 40 );
v38 = 0;
do
{
v39 = 21720 * myplr;
v40 = plr[myplr].InvGrid[v38];
if ( v40 > 0 )
{
v41 = v40 - 1;
invtest[v38] = 1;
v42 = v41;
v43 = 368 * v41 + v39;
v44 = *(int *)((char *)&plr[0].InvList[0]._iCurs + v43) + 12;
screen_ye = InvItemWidth[v44];
if ( pcursinvitem == v41 + 7 )
{
v45 = -59;
if ( *(&plr[0].InvList[0]._iMagical + v43) )
v45 = -75;
if ( !*(int *)((char *)&plr[0].InvList[0]._iStatFlag + v43) )
v45 = -27;
CelDecodeClr(
v45,
InvRect[v38 + 25].X + 64,
InvRect[v38 + 25].Y + 159,
(char *)pCursCels,
v44,
screen_ye,
0,
8);
}
v46 = InvRect[v38 + 25].X + 64;
v47 = InvRect[v38 + 25].Y + 159;
if ( plr[myplr].InvList[v42]._iStatFlag )
CelDrawHdrOnly(v46, v47, (char *)pCursCels, v44, screen_ye, 0, 8);
else
CelDrawHdrLightRed(v46, v47, (char *)pCursCels, v44, screen_ye, 0, 8, 1);
}
++v38;
}
while ( v38 < 40 );
}
// 4B8CB8: using guessed type char pcursinvitem;
// 69BEF8: using guessed type int light_table_index;
// 69CF94: using guessed type int cel_transparency_active;
// 41B8C4: using guessed type int var_A0[40];
void __cdecl DrawInvBelt()
{
int v0; // ebx
signed int v1; // esi
int v2; // ecx
int v3; // eax
int v4; // edi
char v5; // cl
int v6; // edx
bool v7; // zf
int v8; // ecx
int v9; // eax
unsigned char v10; // edx
signed int v11; // [esp+4h] [ebp-Ch]
int frame_width; // [esp+8h] [ebp-8h]
int v13; // [esp+Ch] [ebp-4h]
v0 = 0;
if ( !talkflag )
{
DrawPanelBox(205, 21, 0xE8u, 0x1Cu, 269, 517);
v11 = 0;
v13 = 0;
do
{
if ( *(int *)((char *)&plr[myplr].SpdList[0]._itype + v0) != -1 )
{
v1 = v11;
InvDrawSlotBack(InvRect[v11 + 65].X + 64, InvRect[v11 + 65].Y + 159, 28, 28);
v2 = myplr;
v3 = v0 + 21720 * myplr;
v4 = *(int *)((char *)&plr[0].SpdList[0]._iCurs + v3) + 12;
frame_width = InvItemWidth[v4];
if ( pcursinvitem == v11 + 47 )
{
v5 = -59;
if ( *(&plr[0].SpdList[0]._iMagical + v3) )
v5 = -75;
if ( !*(int *)((char *)&plr[0].SpdList[0]._iStatFlag + v3) )
v5 = -27;
CelDecodeClr(
v5,
InvRect[v1 + 65].X + 64,
InvRect[v1 + 65].Y + 159,
(char *)pCursCels,
v4,
frame_width,
0,
8);
v2 = myplr;
}
v0 = v13;
v6 = InvRect[v1 + 65].Y + 159;
v7 = *(int *)((char *)&plr[v2].SpdList[0]._iStatFlag + v13) == 0;
v8 = InvRect[v1 + 65].X;
if ( v7 )
CelDrawHdrLightRed(v8 + 64, v6, (char *)pCursCels, v4, frame_width, 0, 8, 1);
else
CelDrawHdrOnly(v8 + 64, v6, (char *)pCursCels, v4, frame_width, 0, 8);
v9 = v13 + 21720 * myplr;
if ( AllItemsList[*(int *)((char *)&plr[0].SpdList[0].IDidx + v9)].iUsable
&& *(int *)((char *)&plr[0].SpdList[0]._iStatFlag + v9)
&& *(int *)((char *)&plr[0].SpdList[0]._itype + v9) != 11 )
{
v10 = fontframe[fontidx[(unsigned char)(v11 + 49)]];
CPrintString(
screen_y_times_768[InvRect[v1 + 65].Y + 159]
- fontkern[v10]
+ InvRect[v1 + 65].X
+ 92,
v10,
0);
}
}
++v11;
v0 += 368;
v13 = v0;
}
while ( v11 < 8 );
}
}
// 4B8960: using guessed type int talkflag;
// 4B8CB8: using guessed type char pcursinvitem;
int __fastcall AutoPlace(int pnum, int ii, int sx, int sy, int saveflag)
{
__int64 v5; // rax
int v6; // ebx
signed int v7; // edx
signed int v8; // eax
signed int v9; // esi
int j; // edi
int v11; // eax
signed int v12; // esi
signed int v13; // ecx
int v14; // edi
char *v15; // ecx
char v16; // dl
signed int v18; // [esp+Ch] [ebp-Ch]
int p; // [esp+10h] [ebp-8h]
int v20; // [esp+14h] [ebp-4h]
int i; // [esp+14h] [ebp-4h]
p = pnum;
v5 = ii;
v6 = 1;
v18 = v5 % 10;
v7 = 10 * (unsigned __int64)(v5 / 10);
v8 = v7;
if ( v7 < 0 )
v8 = 0;
v20 = 0;
if ( sy <= 0 )
{
LABEL_16:
if ( saveflag )
{
v11 = pnum;
qmemcpy(
&plr[pnum].InvList[plr[pnum]._pNumInv],
&plr[pnum].HoldItem,
sizeof(plr[pnum].InvList[plr[pnum]._pNumInv]));
++plr[v11]._pNumInv;
v12 = v7;
if ( v7 < 0 )
v12 = 0;
for ( i = 0; i < sy; ++i )
{
v13 = v18;
if ( v18 < 0 )
v13 = 0;
v14 = 0;
if ( sx > 0 )
{
v15 = &plr[v11].InvGrid[v13 + v12];
do
{
if ( v14 || i != sy - 1 )
v16 = -_LOBYTE(plr[v11]._pNumInv);
else
v16 = plr[v11]._pNumInv;
*v15++ = v16;
++v14;
}
while ( v14 < sx );
}
v12 += 10;
}
CalcPlrScrolls(p);
}
}
else
{
while ( v6 )
{
if ( v8 >= 40 )
v6 = 0;
v9 = v18;
if ( v18 < 0 )
v9 = 0;
for ( j = 0; j < sx; ++j )
{
if ( !v6 )
break;
v6 = 0;
if ( v9 < 10 )
_LOBYTE(v6) = plr[pnum].InvGrid[v9 + v8] == 0;
++v9;
}
v8 += 10;
if ( ++v20 >= sy )
{
if ( !v6 )
return v6;
goto LABEL_16;
}
}
}
return v6;
}
int __fastcall SpecialAutoPlace(int pnum, int ii, int sx, int sy, int saveflag)
{
__int64 v5; // rax
int v6; // ebx
signed int v7; // edx
signed int v8; // eax
signed int v9; // esi
int j; // edi
signed int v11; // ecx
int *v12; // eax
int v13; // eax
signed int v14; // esi
signed int v15; // ecx
int v16; // edi
char *v17; // ecx
char v18; // dl
signed int v20; // [esp+Ch] [ebp-Ch]
int p; // [esp+10h] [ebp-8h]
int v22; // [esp+14h] [ebp-4h]
int i; // [esp+14h] [ebp-4h]
p = pnum;
v5 = ii;
v6 = 1;
v20 = v5 % 10;
v7 = 10 * (unsigned __int64)(v5 / 10);
v8 = v7;
if ( v7 < 0 )
v8 = 0;
v22 = 0;
if ( sy <= 0 )
{
LABEL_25:
if ( saveflag )
{
v13 = p;
qmemcpy(&plr[p].InvList[plr[p]._pNumInv], &plr[p].HoldItem, sizeof(plr[p].InvList[plr[p]._pNumInv]));
++plr[v13]._pNumInv;
v14 = v7;
if ( v7 < 0 )
v14 = 0;
for ( i = 0; i < sy; ++i )
{
v15 = v20;
if ( v20 < 0 )
v15 = 0;
v16 = 0;
if ( sx > 0 )
{
v17 = &plr[v13].InvGrid[v15 + v14];
do
{
if ( v16 || i != sy - 1 )
v18 = -_LOBYTE(plr[v13]._pNumInv);
else
v18 = plr[v13]._pNumInv;
*v17++ = v18;
++v16;
}
while ( v16 < sx );
}
v14 += 10;
}
CalcPlrScrolls(p);
}
return v6;
}
while ( v6 )
{
if ( v8 >= 40 )
v6 = 0;
v9 = v20;
if ( v20 < 0 )
v9 = 0;
for ( j = 0; j < sx; ++j )
{
if ( !v6 )
break;
v6 = 0;
if ( v9 < 10 )
_LOBYTE(v6) = plr[pnum].InvGrid[v9 + v8] == 0;
++v9;
}
v8 += 10;
if ( ++v22 >= sy )
{
if ( v6 )
goto LABEL_25;
break;
}
}
if ( sx <= 1 && sy <= 1 )
{
v11 = 0;
v12 = &plr[p].SpdList[0]._itype;
while ( *v12 != -1 )
{
++v11;
v12 += 92;
if ( v11 >= 8 )
goto LABEL_24;
}
v6 = 1;
goto LABEL_25;
}
v6 = 0;
LABEL_24:
if ( v6 )
goto LABEL_25;
return v6;
}
int __fastcall GoldAutoPlace(int pnum)
{
int v1; // ebp
int v2; // edi
int v3; // ecx
int *v4; // esi
int v5; // eax
int v6; // edi
int *v7; // esi
int v8; // eax
signed int v9; // ebx
char *v10; // edx
int v11; // eax
int v12; // ecx
int pnuma; // [esp+10h] [ebp-4h]
pnuma = pnum;
v1 = pnum;
v2 = 0;
v3 = 0;
if ( plr[v1]._pNumInv <= 0 )
{
LABEL_14:
v6 = 0;
if ( plr[v1]._pNumInv <= 0 )
{
LABEL_28:
v9 = 39;
do
{
if ( v3 )
break;
v10 = &plr[0].InvGrid[10 * (v9 / 10) + v1 * 21720 + v9 % 10];
if ( !*v10 )
{
v11 = v1 * 21720 + 368 * plr[v1]._pNumInv;
qmemcpy((char *)plr[0].InvList + v11, &plr[v1].HoldItem, 0x170u);
++plr[v1]._pNumInv;
*v10 = plr[v1]._pNumInv;
v12 = plr[v1].HoldItem._ivalue;
if ( v12 < 2500 )
{
if ( v12 > 1000 )
*(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 5;
else
*(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 4;
}
else
{
*(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 6;
}
plr[v1]._pGold = CalculateGold(pnuma);
v3 = 1;
}
--v9;
}
while ( v9 >= 0 );
}
else
{
v7 = &plr[v1].InvList[0]._ivalue;
while ( !v3 )
{
if ( *(v7 - 47) == 11 && *v7 < 5000 )
{
v8 = plr[v1].HoldItem._ivalue + *v7;
if ( v8 <= 5000 )
{
*v7 = v8;
if ( v8 < 2500 )
{
if ( v8 > 1000 )
*(v7 - 1) = 5;
else
*(v7 - 1) = 4;
}
else
{
*(v7 - 1) = 6;
}
plr[v1]._pGold = CalculateGold(pnuma);
v3 = 1;
}
}
++v6;
v7 += 92;
if ( v6 >= plr[v1]._pNumInv )
{
if ( v3 )
return v3;
goto LABEL_28;
}
}
}
}
else
{
v4 = &plr[v1].InvList[0]._ivalue;
while ( !v3 )
{
if ( *(v4 - 47) == 11 )
{
v5 = *v4 + plr[v1].HoldItem._ivalue;
if ( v5 <= 5000 )
{
*v4 = v5;
if ( v5 < 2500 )
{
if ( v5 > 1000 )
*(v4 - 1) = 5;
else
*(v4 - 1) = 4;
}
else
{
*(v4 - 1) = 6;
}
plr[v1]._pGold = CalculateGold(pnuma);
v3 = 1;
}
}
++v2;
v4 += 92;
if ( v2 >= plr[v1]._pNumInv )
{
if ( v3 )
return v3;
goto LABEL_14;
}
}
}
return v3;
}
int __fastcall WeaponAutoPlace(int pnum)
{
int v1; // edi
int v2; // eax
int v3; // ecx
ItemStruct *v4; // esi
ItemStruct *v5; // edi
int result; // eax
v1 = pnum;
if ( plr[pnum].HoldItem._iLoc == ILOC_TWOHAND )
{
if ( plr[v1].InvBody[4]._itype != -1 || plr[v1].InvBody[5]._itype != -1 )
return 0;
LABEL_12:
NetSendCmdChItem(1u, 4u);
v4 = &plr[v1].HoldItem;
v5 = &plr[v1].InvBody[4];
goto LABEL_13;
}
v2 = plr[v1].InvBody[4]._itype;
if ( v2 != -1 && plr[v1].InvBody[4]._iClass == 1 )
return 0;
v3 = plr[v1].InvBody[5]._itype;
if ( v3 != -1 && plr[v1].InvBody[5]._iClass == 1 )
return 0;
if ( v2 == -1 )
goto LABEL_12;
if ( v3 == -1 && plr[v1].InvBody[4]._iLoc != ILOC_TWOHAND )
{
NetSendCmdChItem(1u, 5u);
v4 = &plr[v1].HoldItem;
v5 = &plr[v1].InvBody[5];
LABEL_13:
result = 1;
qmemcpy(v5, v4, sizeof(ItemStruct));
return result;
}
return 0;
}
int __fastcall SwapItem(ItemStruct *a, ItemStruct *b)
{
int v2; // eax
ItemStruct h; // [esp+8h] [ebp-170h]
qmemcpy(&h, a, sizeof(h));
v2 = h._iCurs;
qmemcpy(a, b, sizeof(ItemStruct));
qmemcpy(b, &h, sizeof(ItemStruct));
return v2 + 12;
}
void __fastcall CheckInvPaste(int pnum, int mx, int my)
{
int v3; // ebx
int v4; // edi
int v5; // eax
int v6; // esi
signed int v7; // edi
int v8; // edx
int v9; // edx
signed int v10; // edi
char v11; // al
signed int v12; // ecx
int v13; // eax
int v14; // eax
char *v15; // edi
int v16; // esi
int v17; // ecx
int v18; // edx
char v19; // al
int v20; // ecx
int v21; // esi
ItemStruct *v22; // edi
ItemStruct *v23; // ecx
int v24; // eax
int v25; // eax
int v26; // edx
ItemStruct *v27; // esi
int v28; // eax
int v29; // ecx
int v30; // esi
int v31; // eax
int v32; // eax
int v33; // ecx
int v34; // eax
int v35; // ecx
char *v36; // eax
int v37; // edx
int v38; // ecx
int v39; // edi
int v40; // esi
int v41; // ebx
int v42; // edx
int v43; // eax
int v44; // eax
signed int v45; // ecx
int v46; // edx
char *v47; // eax
int v48; // edi
int v49; // eax
int v50; // ecx
char *v51; // esi
char v52; // cl
int v53; // ecx
int v54; // eax
int v55; // edi
int v56; // edx
int v57; // esi
int v58; // ebx
int v59; // eax
int v60; // esi
ItemStruct tempitem; // [esp+Ch] [ebp-190h]
int v62; // [esp+17Ch] [ebp-20h]
int p; // [esp+180h] [ebp-1Ch]
int v64; // [esp+184h] [ebp-18h]
int v65; // [esp+188h] [ebp-14h]
int v66; // [esp+18Ch] [ebp-10h]
int v67; // [esp+190h] [ebp-Ch]
int v68; // [esp+194h] [ebp-8h]