Compare commits
46
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa0afefe86 | ||
|
|
5b7442ea37 | ||
|
|
c979b53762 | ||
|
|
a7152750fb | ||
|
|
d1c1572ddb | ||
|
|
792d4d50b3 | ||
|
|
0b995c480d | ||
|
|
85b831db91 | ||
|
|
d63781e5fd | ||
|
|
f8bb455d9f | ||
|
|
65db9fc365 | ||
|
|
275c7e5211 | ||
|
|
32831010c0 | ||
|
|
abda2c1cda | ||
|
|
2016f20d58 | ||
|
|
ec60c38492 | ||
|
|
5b8cc3069f | ||
|
|
bce34954d9 | ||
|
|
71c299c98f | ||
|
|
2048808c75 | ||
|
|
ff6163a685 | ||
|
|
0b9c2bb6b0 | ||
|
|
ac4a05a0c3 | ||
|
|
d7d0de3ae9 | ||
|
|
b625ba5695 | ||
|
|
e097b927de | ||
|
|
c9268424ab | ||
|
|
3c0141d639 | ||
|
|
3222614dd2 | ||
|
|
972c200cd0 | ||
|
|
a28393b16b | ||
|
|
c6813cd653 | ||
|
|
22228857ff | ||
|
|
e313d9ea85 | ||
|
|
f09ffd8a35 | ||
|
|
6199b2cbff | ||
|
|
fb066e7046 | ||
|
|
c30258ef5e | ||
|
|
14c4491469 | ||
|
|
5ad07886ea | ||
|
|
89261fdf8a | ||
|
|
38b62cfdbd | ||
|
|
cd395c73b7 | ||
|
|
7f4e8b3f76 | ||
|
|
1bdaae8807 | ||
|
|
69e335ba9c |
@@ -1,4 +1,5 @@
|
||||
# Local metadata and generated build output
|
||||
/build/
|
||||
.DS_Store
|
||||
._*
|
||||
__pycache__/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,217 @@
|
||||
1 3 0 71500 75 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
2 3 0 71501 149 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
3 3 0 71502 349 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
4 3 0 71503 75 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
5 3 0 71504 149 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
6 3 0 71505 349 0 0000-00-00 00:00:00 0000-00-00 00:00:00 7 0 0 -1
|
||||
7 3 0 71506 75 0 0000-00-00 00:00:00 0000-00-00 00:00:00 5 0 0 -1
|
||||
8 3 0 71507 149 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
9 3 0 71508 349 0 0000-00-00 00:00:00 0000-00-00 00:00:00 12 0 0 -1
|
||||
10 3 0 71509 75 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
11 3 0 71510 149 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
12 3 0 71511 349 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
13 3 2 53002 75 0 0000-00-00 00:00:00 0000-00-00 00:00:00 5 0 0 -1
|
||||
14 3 2 53003 149 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
15 3 2 53004 349 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
16 3 2 53005 75 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
17 3 2 53006 149 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
18 3 2 53007 349 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
19 3 2 53008 75 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
20 3 2 53009 149 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
21 3 2 53010 349 0 0000-00-00 00:00:00 0000-00-00 00:00:00 9 0 0 -1
|
||||
22 3 2 53011 75 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
23 3 2 53012 149 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
24 3 2 53013 349 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
25 7 0 54706 69 0 0000-00-00 00:00:00 0000-00-00 00:00:00 12 0 0 -1
|
||||
26 7 0 54707 69 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
27 7 0 54708 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 38 0 0 -1
|
||||
28 7 0 54709 69 0 0000-00-00 00:00:00 0000-00-00 00:00:00 65 0 0 -1
|
||||
29 7 0 54710 49 0 0000-00-00 00:00:00 0000-00-00 00:00:00 29 0 0 -1
|
||||
30 7 0 54711 39 0 0000-00-00 00:00:00 0000-00-00 00:00:00 12 0 0 -1
|
||||
31 3 1 55402 140 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
32 3 1 55405 140 0 0000-00-00 00:00:00 0000-00-00 00:00:00 7 0 0 -1
|
||||
33 3 1 55407 140 0 0000-00-00 00:00:00 0000-00-00 00:00:00 5 0 0 -1
|
||||
34 1 0 55001 15 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
35 1 0 55036 20 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
36 1 0 55034 39 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
37 1 0 55033 90 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
38 1 0 55009 10 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
39 4 0 25163 2 0 0000-00-00 00:00:00 0000-00-00 00:00:00 11 0 0 -1
|
||||
40 4 0 25164 4 0 0000-00-00 00:00:00 0000-00-00 00:00:00 11 0 0 -1
|
||||
41 4 0 25165 5 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
42 4 0 25166 6 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
43 4 0 25167 8 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
44 4 0 25168 8 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
45 4 0 25169 10 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
48 1 0 71035 4 0 0000-00-00 00:00:00 0000-00-00 00:00:00 6 0 0 -1
|
||||
49 1 0 30250 10 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
50 1 0 70028 90 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
51 2 1 41119 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
52 2 1 41120 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
53 2 1 41121 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
54 2 1 41122 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
55 2 2 45005 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
56 2 2 45006 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
57 2 2 45057 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 6 0 0 -1
|
||||
58 2 2 45058 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
59 2 0 40129 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
60 2 0 40130 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
61 2 0 40131 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
62 2 0 40132 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 5 0 0 -1
|
||||
63 2 0 40133 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
64 2 0 40134 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
65 2 0 40445 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 13 0 0 -1
|
||||
66 2 0 40446 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
67 2 0 40447 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
68 2 0 40448 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 6 0 0 -1
|
||||
69 2 0 40449 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
70 2 0 40450 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
71 1 0 72319 4 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
72 1 0 72320 2 0 0000-00-00 00:00:00 0000-00-00 00:00:00 7 0 0 -1
|
||||
73 1 0 53998 39 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
74 1 0 53999 69 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
75 6 0 71097 39 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
76 1 0 85009 40 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
77 1 0 71153 19 0 0000-00-00 00:00:00 0000-00-00 00:00:00 48 0 0 -1
|
||||
78 5 1 54003 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 9 0 0 -1
|
||||
79 5 1 54006 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
80 5 1 54009 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
81 5 1 54012 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
82 5 1 54015 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 6 0 0 -1
|
||||
83 5 1 54018 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
84 5 1 54021 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 11 0 0 -1
|
||||
85 5 1 54024 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 7 0 0 -1
|
||||
86 5 1 54027 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
87 5 2 54030 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
88 5 2 54033 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
89 5 2 54036 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
90 5 2 54039 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
91 5 2 54042 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
92 5 2 54045 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
93 5 2 54048 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
94 5 2 54051 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
95 5 2 54054 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
96 5 2 54057 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
97 5 2 54060 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
98 5 2 54063 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
99 5 2 54066 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
100 5 2 54069 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 11 0 0 -1
|
||||
101 5 2 54072 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
102 5 2 54075 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 11 0 0 -1
|
||||
103 5 2 54078 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 12 0 0 -1
|
||||
104 5 0 54081 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
105 5 0 54084 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
106 5 0 54087 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
107 5 0 54090 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
108 5 0 54093 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
109 5 0 54096 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
110 5 0 54099 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
111 5 0 54102 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 6 0 0 -1
|
||||
112 5 0 54105 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
113 5 0 54108 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
114 5 0 54111 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
115 5 0 54114 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 17 0 0 -1
|
||||
116 5 0 54117 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 33 0 0 -1
|
||||
117 5 0 54120 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 12 0 0 -1
|
||||
118 5 0 54123 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 27 0 0 -1
|
||||
123 0 1 54712 349 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
124 0 1 54713 120 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
125 0 1 54714 549 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
126 0 1 54715 49 0 0000-00-00 00:00:00 0000-00-00 00:00:00 19 0 0 -1
|
||||
127 0 1 54716 79 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
128 0 1 54717 159 0 0000-00-00 00:00:00 0000-00-00 00:00:00 13 0 0 -1
|
||||
129 2 3 86004 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
130 2 3 86008 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
131 2 3 86014 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
132 2 3 86018 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
133 2 3 86024 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
134 2 3 86028 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
135 2 3 86034 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
136 2 3 86038 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
137 2 3 86044 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
138 2 3 86048 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
139 2 3 86054 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
140 2 3 86058 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
141 1 0 71221 39 0 2022-05-27 23:59:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
142 1 0 55008 49 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
143 1 0 55035 9 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
144 6 0 100001 9 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
145 6 0 100002 17 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
146 6 0 77913 69 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
147 6 0 77914 299 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
148 6 0 77915 549 0 0000-00-00 00:00:00 0000-00-00 00:00:00 5 0 0 -1
|
||||
149 6 0 100500 4 0 0000-00-00 00:00:00 0000-00-00 00:00:00 5 0 0 -1
|
||||
150 1 0 6884 8 0 0000-00-00 00:00:00 0000-00-00 00:00:00 534 0 0 -1
|
||||
153 1 0 70043 10 0 0000-00-00 00:00:00 0000-00-00 00:00:00 39 0 0 -1
|
||||
154 1 0 72067 5 0 0000-00-00 00:00:00 0000-00-00 00:00:00 6 0 0 -1
|
||||
155 1 0 72068 49 0 0000-00-00 00:00:00 0000-00-00 00:00:00 5 0 0 -1
|
||||
170 1 0 70002 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 12 0 0 -1
|
||||
171 2 4 71233 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
172 2 4 71234 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
173 2 4 71235 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
174 2 4 71236 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
175 2 4 71249 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
176 2 4 71248 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
177 2 4 71254 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
178 2 4 71255 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
179 2 4 71246 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
180 2 4 71247 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
181 2 4 71252 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
182 2 4 71253 99 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
183 5 3 54126 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
184 5 3 54129 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
185 5 3 54132 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
186 5 3 54135 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
187 5 3 54138 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
188 5 3 54141 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
189 5 3 54144 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
190 5 3 54147 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
191 5 3 54150 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
192 5 3 54153 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
193 5 3 54156 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 13 0 0 -1
|
||||
194 5 3 54159 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 16 0 0 -1
|
||||
195 5 3 54162 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 19 0 0 -1
|
||||
197 5 3 54168 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
198 5 3 54171 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
199 5 3 54174 60 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
200 0 2 71230 149 0 2022-09-30 23:59:00 0000-00-00 00:00:00 7 0 0 -1
|
||||
201 0 2 55406 149 0 2022-09-30 23:59:00 0000-00-00 00:00:00 8 0 0 -1
|
||||
202 5 4 54177 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
203 5 4 54180 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 11 0 0 -1
|
||||
204 5 4 54183 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 13 0 0 -1
|
||||
205 5 4 54186 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
206 5 4 54189 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
207 5 4 54192 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
208 5 4 54195 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
209 5 4 54198 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
210 5 4 54201 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
211 5 4 54204 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
212 5 4 54207 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
213 5 4 54210 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
214 5 4 54213 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
215 5 4 54216 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 10 0 0 -1
|
||||
216 5 4 54219 50 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
217 5 5 54222 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
218 5 5 54225 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
219 5 5 54228 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4 0 0 -1
|
||||
220 5 5 54231 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
221 5 5 54234 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
222 5 5 54237 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
223 5 5 54240 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
224 5 5 54243 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 0 0 -1
|
||||
225 5 5 54246 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
226 5 5 54249 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
227 5 5 54252 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 3 0 0 -1
|
||||
228 5 5 54255 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
229 5 5 54258 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
230 5 5 54261 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
231 5 5 54264 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
232 5 5 54267 45 0 0000-00-00 00:00:00 0000-00-00 00:00:00 2 0 0 -1
|
||||
233 1 0 39063 19 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
234 1 0 39064 19 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
235 1 0 71136 29 0 0000-00-00 00:00:00 0000-00-00 00:00:00 12 0 0 -1
|
||||
236 0 0 25159 149 0 2022-10-25 23:59:59 0000-00-00 00:00:00 0 0 0 -1
|
||||
237 0 0 20059 149 0 2022-10-31 23:59:59 0000-00-00 00:00:00 0 0 0 -1
|
||||
240 1 0 77921 1 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
241 1 0 77922 2 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
242 1 0 77923 5 0 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 -1
|
||||
|
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"source_archive": "AVA2/2. Backup SF+SRC and SQL/MYSQL56.tgz",
|
||||
"archive_sha256": "0a578f4036fff69c36d0ad0d4d6692d267284be10689105a173ac30337ec0787",
|
||||
"source_table": "player.ishop_data",
|
||||
"format": "native MyISAM recovered in isolated reference schema; sorted by id; dates preserved",
|
||||
"rows": 217,
|
||||
"tsv_sha256": "7e2fc0ccb630168b0466d097eaa9b41858df1ea0e67ab7b7fad2ba17fc975276"
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
{
|
||||
"count": 49,
|
||||
"scope": "Existing implemented item systems only. Does not authorize production deployment.",
|
||||
"products": [
|
||||
{
|
||||
"id": 3,
|
||||
"vnum": 71502,
|
||||
"original_price": 349,
|
||||
"basis": "ported mount costume and mount skin; game/src/port_mount.cpp, client MountScript and staged model resources"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"vnum": 71505,
|
||||
"original_price": 349,
|
||||
"basis": "ported mount costume and mount skin; game/src/port_mount.cpp, client MountScript and staged model resources"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"vnum": 71508,
|
||||
"original_price": 349,
|
||||
"basis": "ported mount costume and mount skin; game/src/port_mount.cpp, client MountScript and staged model resources"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"vnum": 71511,
|
||||
"original_price": 349,
|
||||
"basis": "ported mount costume and mount skin; game/src/port_mount.cpp, client MountScript and staged model resources"
|
||||
},
|
||||
{
|
||||
"id": 78,
|
||||
"vnum": 54003,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 79,
|
||||
"vnum": 54006,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 80,
|
||||
"vnum": 54009,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 81,
|
||||
"vnum": 54012,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 82,
|
||||
"vnum": 54015,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 83,
|
||||
"vnum": 54018,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 84,
|
||||
"vnum": 54021,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 85,
|
||||
"vnum": 54024,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 86,
|
||||
"vnum": 54027,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 87,
|
||||
"vnum": 54030,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 88,
|
||||
"vnum": 54033,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 89,
|
||||
"vnum": 54036,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 90,
|
||||
"vnum": 54039,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 91,
|
||||
"vnum": 54042,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 92,
|
||||
"vnum": 54045,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 93,
|
||||
"vnum": 54048,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 94,
|
||||
"vnum": 54051,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 95,
|
||||
"vnum": 54054,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 96,
|
||||
"vnum": 54057,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 97,
|
||||
"vnum": 54060,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 98,
|
||||
"vnum": 54063,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 99,
|
||||
"vnum": 54066,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 100,
|
||||
"vnum": 54069,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 101,
|
||||
"vnum": 54072,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 102,
|
||||
"vnum": 54075,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 103,
|
||||
"vnum": 54078,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 170,
|
||||
"vnum": 70002,
|
||||
"original_price": 99,
|
||||
"basis": "AVA2 third-hand pickup status; docs/AVA2-CHEST-PICKUP.md in metin2-client"
|
||||
},
|
||||
{
|
||||
"id": 172,
|
||||
"vnum": 71234,
|
||||
"original_price": 99,
|
||||
"basis": "ported mount costume and mount skin; game/src/port_mount.cpp, client MountScript and staged model resources"
|
||||
},
|
||||
{
|
||||
"id": 177,
|
||||
"vnum": 71254,
|
||||
"original_price": 99,
|
||||
"basis": "ported mount costume and mount skin; game/src/port_mount.cpp, client MountScript and staged model resources"
|
||||
},
|
||||
{
|
||||
"id": 183,
|
||||
"vnum": 54126,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 184,
|
||||
"vnum": 54129,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 185,
|
||||
"vnum": 54132,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 186,
|
||||
"vnum": 54135,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 187,
|
||||
"vnum": 54138,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 188,
|
||||
"vnum": 54141,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 189,
|
||||
"vnum": 54144,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 190,
|
||||
"vnum": 54147,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 191,
|
||||
"vnum": 54150,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 192,
|
||||
"vnum": 54153,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 193,
|
||||
"vnum": 54156,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 194,
|
||||
"vnum": 54159,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 195,
|
||||
"vnum": 54162,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 197,
|
||||
"vnum": 54168,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 198,
|
||||
"vnum": 54171,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
},
|
||||
{
|
||||
"id": 199,
|
||||
"vnum": 54174,
|
||||
"original_price": 60,
|
||||
"basis": "ported body/hair/mount-skin fixed enchants; game/src/port_costume_attr.cpp and make_items.ENCHANT_KEEP"
|
||||
}
|
||||
],
|
||||
"candidates_pending_acceptance": [
|
||||
{
|
||||
"id": 144,
|
||||
"vnum": 100001,
|
||||
"original_price": 9,
|
||||
"basis": "dragon soul time charge (percent); game/src/char_item.cpp USE_TIME_CHARGE_PER and item.cpp GiveMoreTime_Per",
|
||||
"status": "pending_real_behavior_and_platform_acceptance"
|
||||
},
|
||||
{
|
||||
"id": 145,
|
||||
"vnum": 100002,
|
||||
"original_price": 17,
|
||||
"basis": "dragon soul time charge (fixed); game/src/char_item.cpp USE_TIME_CHARGE_FIX and item.cpp GiveMoreTime_Fix",
|
||||
"status": "pending_real_behavior_and_platform_acceptance"
|
||||
},
|
||||
{
|
||||
"id": 149,
|
||||
"vnum": 100500,
|
||||
"original_price": 4,
|
||||
"basis": "dragon soul strength refine material (holly bean); game/src/DragonSoul.cpp DSManager::DoRefineStrength",
|
||||
"status": "pending_real_behavior_and_platform_acceptance"
|
||||
},
|
||||
{
|
||||
"id": 233,
|
||||
"vnum": 39063,
|
||||
"original_price": 19,
|
||||
"basis": "gaya market refresh item; game/src/port_gaya.cpp and char_item.cpp USE_RESET_GAYA_SHOP",
|
||||
"status": "pending_real_behavior_and_platform_acceptance"
|
||||
},
|
||||
{
|
||||
"id": 234,
|
||||
"vnum": 39064,
|
||||
"original_price": 19,
|
||||
"basis": "gaya market slot unlock item; game/src/port_gaya.cpp and char_item.cpp USE_EXPAND_GAYA_SHOP",
|
||||
"status": "pending_real_behavior_and_platform_acceptance"
|
||||
},
|
||||
{
|
||||
"id": 240,
|
||||
"vnum": 77921,
|
||||
"original_price": 1,
|
||||
"basis": "copper treasure key for box 77918; game/src/char_item.cpp single-count decrement",
|
||||
"status": "pending_real_behavior_and_platform_acceptance"
|
||||
},
|
||||
{
|
||||
"id": 241,
|
||||
"vnum": 77922,
|
||||
"original_price": 2,
|
||||
"basis": "silver treasure key for box 77919; game/src/char_item.cpp single-count decrement",
|
||||
"status": "pending_real_behavior_and_platform_acceptance"
|
||||
},
|
||||
{
|
||||
"id": 242,
|
||||
"vnum": 77923,
|
||||
"original_price": 5,
|
||||
"basis": "gold treasure key for box 77920; game/src/char_item.cpp single-count decrement",
|
||||
"status": "pending_real_behavior_and_platform_acceptance"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
# 属性锁定:聊天链接和活动洗练槽
|
||||
|
||||
2026-10-18,接续其他视图提示。客户端完整说明见 `metin2-client/docs/AVA2-ATTR-LOCK-SNAPSHOTS.md`。
|
||||
|
||||
`port_attr_lock.cpp` 的 `PortAttrLockSend` 通过现有服务端命令发送 `AttrLockItem window cell vnum mask`,顺序紧随自有物品设置/删除/更新、锁定变更或switchbot物品更新。只给 `SwitchbotHelper::IsClientSupported` 识别的新客户端发送,只支持本人 INVENTORY/EQUIPMENT/SWITCHBOT。SQL失败返回mask=-1,不能伪装成未锁定。
|
||||
|
||||
`/attr_lock_sync` 在客户端进入游戏后一秒触发,只同步本人背包/装备及五个有效洗练槽,不接受目标角色参数。两秒限频,跳过多格物品占位格;结束返回 `AttrLockSync`。客户端最多重试三次,断线清缓存,防止加载界面丢命令和重登残留。经典物品封包、锁定规则和数据库结构均不变。
|
||||
|
||||
客户端以属性/孔快照匹配缓存;聊天链接保留发送时的七属性槽和 `mtlock1:mask` 后缀,并支持转发。活动槽保留原“正在自动洗练”说明,追加黄色 `<<锁定属性>>`,停止后恢复普通提示。
|
||||
|
||||
验证:
|
||||
|
||||
- `python3 tests/features/test_attr_lock_snapshots.py` 编译真实发送和同步函数,覆盖版本/窗口、删除、addon锁定组、SQL失败、多格去重和限频。
|
||||
- `python3 tests/features/test_attr_lock_views.py` 原视图权限/归属检查回归通过。
|
||||
- 客户端132项测试、macOS和Android离线构建通过。macOS/sbtest首次登录同步、聊天链接/转发、实际自动洗练、停止/移回和同进程重登通过;手机真机暂停。
|
||||
- 证据:客户端 `build/parity-acceptance-20261018/lock-snapshots-proof-accepted.log`、`lock-snapshots-{link,active,moved,relogin}.json`。测试驱动不进入发行包。
|
||||
|
||||
仅部署sbtest:`game.ava2-parity` SHA256 `8622d6bcd5077609015bf8556bc094236e3100a4d6ed6ee490b3e55f372960a2`。备份与夹具在 `/root/deploy-features/20261018-ava2-parity/attr-snapshots`,其中 `game-before` 为上一轮测试二进制;SQL恢复必须先停止sbtest以刷新缓存。正式服game仍 `40335e41…`,没有修改正式库或服务进程。
|
||||
|
||||
验收后停止sbtest缓存并恢复测试武器原属性/背包159格、原无锁状态及902个71084,原装备1900000015仍为装备槽4;`attr-snapshots/cleanup-result.json` 已保存核对结果。最终中文说明框实际宽348、最长文字308,40像素余量通过。
|
||||
@@ -1,6 +1,6 @@
|
||||
# PORT attribute lock
|
||||
|
||||
AVA2 `ENABLE_LOCK_ATTR`, rebuilt for this server's item layout. Up to two of the five normal attribute slots keep their type and value when the item is rerolled. Source: `src/server/game/src/port_attr_lock.{h,cpp}`, `CItem::ChangeAttribute` / `CopyAttributeTo` (item_attribute.cpp), the cache fields in item.h/item.cpp, the boot hook in main.cpp, and the `lock` verb of `mt_switchbot` (port_switchbot.h).
|
||||
AVA2 `ENABLE_LOCK_ATTR`, rebuilt for this server's item layout. Up to two of the five normal attribute slots keep their type and value when the item is rerolled. Source: `src/server/game/src/port_attr_lock.{h,cpp}`, `CItem::ChangeAttribute` / `CopyAttributeTo` (item_attribute.cpp), the cache fields in item.h/item.cpp, and the boot hook in main.cpp. The `lock` verb of the v1 `mt_switchbot` command was removed with the AVA2 switchbot port (FEATURE-SWITCHBOT.md). Locks are now set only by using 50348 (lock) / 50349 (unlock) on the item. `UseItemEx` passes the material to `PortAttrLockUse`, which reads the 1-based slot from the material's socket 0 and consumes one material on success.
|
||||
|
||||
## Storage
|
||||
|
||||
@@ -24,7 +24,6 @@ CREATE TABLE IF NOT EXISTS mt_item_attr_lock (item_id INT UNSIGNED NOT NULL PRIM
|
||||
|
||||
- Only the five normal slots can be locked; the rare slots 5/6 are not affected. The item must sit in the inventory, not be equipped or in an exchange, not be a costume, and have an attribute set. The slot must hold an attribute.
|
||||
- At most 2 lock groups, and at least one filled slot must stay unlocked. On items with an addon type (`sAddonType`, weapons whose slots 0/1 are the skill / normal hit bonus pair), slots 0 and 1 lock and unlock together and count as one group.
|
||||
- The bot's own item cannot be locked or unlocked while the bot is rolling it (`running`).
|
||||
- Locking is free. AVA2 consumes 50348/50349 per lock or unlock; those vnums do not exist in 203 `item_proto`.
|
||||
- `CItem::ChangeAttribute` (scroll rerolls, the switchbot, the GM command):
|
||||
1. take the effective mask: stored mask ∩ filled slots, with the addon pair kept whole;
|
||||
@@ -36,15 +35,9 @@ CREATE TABLE IF NOT EXISTS mt_item_attr_lock (item_id INT UNSIGNED NOT NULL PRIM
|
||||
With no lock, the effective mask is 0 and the sequence equals the original. The attribute count is kept, and the rare slots are untouched.
|
||||
- Adding an attribute (71085) and rare-attribute scrolls do not look at the lock.
|
||||
|
||||
## Protocol (part of mt_switchbot v1)
|
||||
## Protocol
|
||||
|
||||
```
|
||||
/mt_switchbot 1 lock CELL SLOT toggle the lock on normal slot SLOT (0..4)
|
||||
MTSB1 lock CELL VNUM MASK effective mask; also sent after every attrs_end
|
||||
MTSB1 error lock CODE item equipped no_attr busy running slot max db rate invalid
|
||||
```
|
||||
|
||||
`slot` means out of range or empty. `max` means a third group, or every filled slot locked. `db` means the write failed. Older servers never send a `lock` line, so the client shows no lock buttons there.
|
||||
No dedicated packet. The v1 `/mt_switchbot 1 lock CELL SLOT` / `MTSB1 lock` lines were removed together with that command. What remains is the item-use path above. AVA2's UI for picking the slot and showing the lock in the tooltip is still open (metin2-client docs/AVA2-PARITY-PLAN.md).
|
||||
|
||||
## Verification
|
||||
|
||||
@@ -58,7 +51,7 @@ MTSB1 error lock CODE item equipped no_attr busy running slot max
|
||||
- there is no DB lookup when there are no attributes;
|
||||
- every toggle, effective-mask and group-count rule holds.
|
||||
- It also checks the boot hook, the Makefile, the cache initialisation and that `CopyAttributeTo` copies the lock.
|
||||
- `tests/features/test_switchbot.py` covers the `lock` verb (toggle, `slot`, `max`, `db`, `running`, `no_attr`, `item`, `invalid`, the addon pair) and the lock line after `attrs_end`.
|
||||
- `tests/features/test_switchbot.py` checks that the v1 command (and with it the `lock` verb) is gone.
|
||||
- FreeBSD: full rebuild of game in `/root/metin2-features-dev` (log `attrlock-build.log`; `item.h` changed, so every .cpp was touched).
|
||||
- Live on 2026-10-15, channel-5 test core (13040) with the isolated binary, macOS client, [SA]Admin, armour 11209 (item 20000178, 5 attributes), scroll 71084:
|
||||
- the first boot created the table;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# AVA2 属性锁定选择与展示
|
||||
|
||||
2026-10-18;首次选择与自有提示验收使用 sbtest game `a324f3d0646ce8e8579c34237bbdc54855be2d5578f54476a27005f0af364765`;后续其他视图验收和当前版本见下节。正式服未变更。
|
||||
|
||||
补齐 AVA2 char_item.cpp 的材料使用契约:无目标使用 50348/50349 进入选择 quest,socket 0 保存1~5;拖放时锁定或解锁。选择返回按 ID 重新解析物品,校验所有者、库存与交易/角色状态。选择不扣材料,锁定只有持久保存成功才扣一张;数据库读取失败拒绝覆盖已有状态。处理放在时装/护符专用分支之前。独立 mt_item_attr_lock 表及现有 ChangeAttribute 保留算法继续使用。
|
||||
|
||||
`/attr_lock_info TOKEN WINDOW CELL` 只读查询自己的背包、装备或洗练槽(每秒限频),含请求序号和 vnum 的响应让客户端拒绝过时提示;SQL 错误发未知掩码而非未锁定。
|
||||
|
||||
两种材料原型从 AVA2 客户端 DumpProto 读取并只合并两行;归档没有材料的选择 quest,中文 attr_lock.quest 根据 C++ 契约补齐。安装器和详细验证见客户端 tools/server/ava2-attr-lock/README.md。
|
||||
|
||||
已实际验证选择4、掩码8、锁定消耗4→3、洗练卷20→19且第4条保持、重复锁定不消耗、重启测试 db/auth/game 和客户端后读回、取消不消耗、解锁4→3。备份为 /root/deploy-features/20261018-ava2-parity/backup-attr-lock 和 backup-attr-lock-install-recheck;QA 专属夹具保存在该目录 private-attr-lock-*,勿纳入发布包。
|
||||
|
||||
直接函数测试 test_attr_lock_use.py 与原 ChangeAttribute 测试 test_attr_lock.py 通过。该次验收未覆盖其他视图,后续见下节。客户端脚本在 OnUpdate 内操作重新登录的早期崩溃及后续帧间驱动重登结果见客户端独立调查记录,不将其扩大为全部物理输入通过。
|
||||
|
||||
## 其他视图只读提示
|
||||
|
||||
源码提交5b8cc30:扩展 `/attr_lock_info token context cell vid`,101/102为当前双方交易,103为当前玩家商店,104/105为自己的已加载仓库/商城仓库,106仅允许现有GM权限查看穿戴槽。除106外vid必须为0。保留原自有物品三参数请求及回复格式,不修改七属性基础包或锁定存储。
|
||||
|
||||
交易按显示格查找,校验互相关联的交易和物品所有者;商店校验访客、在售ID/vnum、所有者和原隐藏高价值物品规则;仓库校验真实容量。SQL失败仍返回未知掩码,查询限频仍每秒一次。
|
||||
|
||||
test_attr_lock_views.py直接编译运行实际函数,覆盖显示格与内部索引不同、访客/归属、关闭容器、隐藏商品、GM权限、非法参数、限频和SQL失败。macOS两个普通QA角色真实验证双方交易、摆摊预览及价格12345保留、商店、NPC仓库和商城仓库的mask8高亮;普通角色查询他人装备被拒绝。随后仅在common_sb临时授权QA角色,真实view_equip验证他人已装备武器高亮。客户端126项回归及macOS/Android离线编译通过;手机按用户要求暂停。
|
||||
|
||||
测试后移除新增账号、角色、物品和临时GM行,恢复主QA两件武器的原装备/背包槽及测试武器无锁状态,备份位于 `/root/deploy-features/20261018-ava2-parity/attr-views`。原CONFIG逐字节一致,sbtest已重启,当前game SHA256为 `03a7b74a1ba440c5af3344441a9bd00413a4aa5a6719fdc2f3f231758260603f`,正式服仍40335e41…。
|
||||
|
||||
聊天链接和活动洗练槽的动态锁定提示仍待做;不能据此认定整个AVA2提示能力已完成。正式服未部署本轮变更。
|
||||
@@ -0,0 +1,16 @@
|
||||
# AVA2 原生批量开箱
|
||||
|
||||
2026-10-18:测试服接入;正式服未部署。客户端完整记录见 metin2-client/docs/AVA2-CHEST-PICKUP.md。
|
||||
|
||||
来源:AVA2 FILES+SRC.tgz 的 game/src/char_item.cpp,ENABLE_MULTI_CHEST 的 OpenChest、GiveItemFromSpecialItemGroupNew、AutoGiveItemChest;cmd_general.cpp 的 chest_drop 和 chestdrop;GC66 DWORD 长度预览布局。
|
||||
|
||||
- 原生入口 `/chest_drop <window> <cell> <count>`,仅普通背包合法格,最多 1000、且只消费该格当前数量。原始基础物品封包仍是 BYTE 数量,单堆仍为 200,没有扩大成 1000。
|
||||
- 独立批量发奖,不再逐次 UseItem。保留特殊组金币/经验/异常效果及批次堆叠、延后更新/任务拾取回调。`/mt_chest` 保留为旧端兼容。
|
||||
- 交易、锁定、装备、死亡/观察/传送、商店/仓库/合成等状态拒绝;保留基础服等级、竞技场与龙魂资格检查。新堆与已有堆都检查孔值后合并。
|
||||
- 适配当前 200 堆叠:大数量奖励分堆,非堆叠逐个创建,MAKECOUNT 的最小量不会使剩余计数下溢;提示汇报实际创建数量。背包不足延续 AVA2 部分成功消耗语义,不把物品掉在地上。
|
||||
- `/chestdrop <vnum>` 只查询有效宝箱组。GC66 帧有 8190 行/65535 字节边界;客户端校验实际长度。
|
||||
- 物品 CItem 延后更新标志在 Initialize 重置。Makefile 为新 include 添加显式依赖,避免旧 Depend 漏编。
|
||||
|
||||
验证:`python3 tests/features/test_ava2_chest.py` 编译并执行真实 include;覆盖余量、合并、孔隔离、满包、状态、等级/龙魂、450 个奖励拆堆、非堆叠及 MAKECOUNT。另保留原 `/mt_chest` 测试。FreeBSD 隔离编译通过;普通 QA 在 sbtest 的真实窗口滑块开启 5 个,背包回调整叠开启其余 15 个。物理按键和 Android 真机仍未验收。
|
||||
|
||||
测试构建与原型备份在 /root/deploy-features/20261018-ava2-parity。回退:停止 sbtest,恢复 backup-pickup-proto 中 conf/db 两套原型(70002),game 链接恢复 sbtest/game.ava2-stones,重启测试 db/auth/channel5。没有操作正式服 share/bin/game。
|
||||
@@ -0,0 +1,38 @@
|
||||
# AVA2 drop tables
|
||||
|
||||
203 drops what AVA2 drops. Tables: `tools/ava2-drops/make_drops.py`. Code: `ITEM_MANAGER::ReadCommonDropNewItemFile` (item_manager_read_tables.cpp), the common-drop block and `GetDropPct` in item_manager.cpp, the load in input_db.cpp. The items AVA2 drops that 40250 lacks come from metin2-client `tools/server/ava2-items` and must be installed in the same deploy (the readers fail on an unknown item vnum and the core stops).
|
||||
|
||||
## Tables
|
||||
|
||||
Built by `make_drops.py <AVA2 locale dir> <203 locale dir> <out dir> <item_proto.txt>...`, the protos being every row the db will load (live item_proto.txt + ava2-items' items-server.tsv).
|
||||
|
||||
| File | Content |
|
||||
|---|---|
|
||||
| mob_drop_item.txt | AVA2's 247 `drop` groups. Entries with an unknown item are removed and the rest renumbered: the reader stops at the first missing index. |
|
||||
| common_drop_new.txt | AVA2's 26 level-range common groups (new file, see below). |
|
||||
| special_item_group.txt | 203's groups; AVA2's groups replace those of the same box vnum (50011, 50082, 50186, 50255) and AVA2-only boxes are added. 50035 keeps 203's group: it is the children's day box on 203 but a GM box on AVA2. |
|
||||
| common_drop_item.txt, etc_drop_item.txt | empty, as on AVA2. |
|
||||
|
||||
`report.json` lists group counts, removed items and replaced boxes.
|
||||
|
||||
## common_drop_new.txt
|
||||
|
||||
```
|
||||
Group <name>
|
||||
{
|
||||
map_index 0 # 0 = every map, otherwise the maps listed
|
||||
level_range <min> <max> # killer level
|
||||
<n> <item vnum> <count> <pct> # pct as a float, chance = pct / 100
|
||||
}
|
||||
```
|
||||
|
||||
A group drops when the monster level is within 20 of the killer, the killer level is in `level_range` and the map matches. Each entry is rolled against `GetDropPct`'s range (base 4,000,000) with probability `pct × 40000`. A missing file is logged and skipped; a parse error or unknown item fails the boot like the other drop files.
|
||||
|
||||
## Changes to the drop code (from AVA2)
|
||||
|
||||
- `GetDropPct`: premium item or glove doubles the drop rate, otherwise +50%; the permanent glove adds 100 (50 with premium) to the denominator bonus. `iRandRange = 4000000 * 100 / (100 + priv + bonus)`; 203 had an operator-precedence bug that fixed the divisor at 100.
|
||||
- PC-bang bonus removed. The event-manager bonus is not ported (203 has no ENABLE_EVENT_MANAGER).
|
||||
- A mob with two `drop` groups no longer reads an uninitialised group pointer.
|
||||
- special_item_group.txt groups may have up to 1023 entries (AVA2's cofreskindop boxes have 267).
|
||||
|
||||
The wiki (`/mt_features ... mob`) lists common_drop_new rows as rule 0 (FEATURE-QUERY-PROTOCOL.md). Not ported: AVA2's `/reload y`; quest-script and hardcoded drops are not compared.
|
||||
@@ -0,0 +1,17 @@
|
||||
# AVA2 原生换线
|
||||
|
||||
来源为 AVA2 启用的 `cmd.cpp move_channel → do_cmd(SCMD_CHANGE_CHANNEL) → timed_event → CHARACTER::MoveChannel`,不是同归档中已注释的另一套 `do_change_channel`。3秒倒计时,重复命令取消;结束时再校验任务、角色、物品操作、地图和对端可用性。
|
||||
|
||||
现有 `WarpSet(x,y,map)` 保留原签名,新增4参重载选择目标频道。普通传送继续走原路径。换线共享原保存/移除实体/GC Warp/P2P switchbot交接,避免另写一套传送清理顺序;不发送 VALID_LOGOUT。
|
||||
|
||||
AVA2 原端口步长100不适合203。`ava2_channel` 通过已有 GG relay 的保留名字 `#ava2_channels` 发送版本化快照,只接收已登记P2P对端身份匹配的频道和P2P端口。游戏端口来自该核心,地图来自 MAP_ALLOW。5秒心跳,30秒过期,断开删除,歧义归属拒绝;范围为1..7频道,99不可切。不会读取玩家输入的IP/端口。
|
||||
|
||||
配套客户端扩展命令:`ChannelList <current> <csv>`、`ChannelEndpoint <target> <ipv4> <gameport>`、`ChannelError unavailable`;频道标题仍发送 AVA2 原 `UpdateServerInfo`。列表只读,每角色每秒最多一次。私人地图没有跨频道路线,保留本频道条目,客户端不会回落到旧退出重登UI。
|
||||
|
||||
离线路由检查:`python3 tests/features/test_ava2_channel_registry.py`。编译必须显式指定隔离的 BINDIR 与 GAMEDIR,默认 Makefile 会部署正式二进制,不可直接裸跑。
|
||||
|
||||
macOS/sbtest已验证5:13040→6:13050→5续洗,active始终1、两套目标表和锁定第4条保持,71084消耗1034→976→919。正常退出重登保留频道6与auth11040;辅助核心关闭后列表移除6,旧目标请求被拒绝。同频道、未开放频道、倒计时取消和任务选择中的拒绝已通过。
|
||||
|
||||
测试版本game hash为2575de51a19dd080f6ecbff2cea8a549df1d8fd66be867bc483a412287fc9114。恢复原CONFIG逐字节核对,辅助13050/14050关闭,sbtest db/auth/core已重启;正式服game仍40335e41…,原15000/11000监听保持。备份、测试日志在 /root/deploy-features/20261018-ava2-parity/native-channel,不提交CONFIG/凭据。
|
||||
|
||||
当前变更仅部署sbtest,不能据此认定正式服已有原生换线。Android仅离线编译,用户暂停手机验收。
|
||||
@@ -0,0 +1,15 @@
|
||||
# AVA2 CG235 拾取
|
||||
|
||||
2026-10-18:仅 sbtest。客户端记录见 metin2-client/docs/AVA2-CHEST-PICKUP.md。
|
||||
|
||||
移植来源为 AVA2 ItemsPickup / CheckItemCanGet、70002 USE_SPECIAL 分支、char.h eAutomaticPickUP。CG235 固定头 5 字节(BYTE + DWORD count)后接 VID 数组与常规序列字节。客户端原版候选收集与 500ms 节流;服务端最多 4096 个 VID,先校验完整帧,再检查地面/距离/所有权/角色状态/分类。
|
||||
|
||||
bit0 开启,1–18 是原版忽略分类。修正原版 CHESTS 使用 ITEM_METIN 的误写为 ITEM_GIFTBOX;未移植职业、时装和稀有度能力不伪造为已支持。原有 /mt_pickup 仅兼容旧端。
|
||||
|
||||
`/setpickupmode <mode> <rarity>` 更新,空参数读取,`PickUPMode` 回传。当前选定的基础 DB 结构不扩大,设置持久化到 `ava2_pickup.mode` / `.rarity` quest 标记;PC 未加载时拒绝读写默认值,QuestLoad/延后登录事件完成后主动同步。冷重启验证曾暴露“初始读取早于 flags 加载”的竞态,现已修复。
|
||||
|
||||
70002 原型恢复 ITEM_USE/USE_SPECIAL;使用后消耗一颗并持久化 705 affect,30 天;已有状态重复使用不消耗。此处按原版只实现状态和键触发批量拾取,不声称周期无人操作拾取。稀有度过滤仅保存配置,稀有度物品系统及界面按钮尚未开放。
|
||||
|
||||
验证:`python3 tests/features/test_ava2_pickup.py` 执行真实封包解析和分类函数,覆盖截断、计数溢出、开关、距离/所有权、宝箱/灵石独立过滤。真实客户端 CG235 验证忽略灵石时只取回药水、取消过滤后取回灵石;激活/重复不消耗及测试 db/auth/core 冷重启后模式、剩余状态、图标和道具数量恢复通过。
|
||||
|
||||
没有正式服部署,未做 Android 真机或跨核心设置同步验收。备份和回滚同 FEATURE-AVA2-CHEST.md。构建必须覆盖 BINDIR 与 GAMEDIR,不能使用默认正式服输出路径。
|
||||
@@ -0,0 +1,14 @@
|
||||
# AVA2 spirit stones (staged on sbtest)
|
||||
|
||||
The stone catalogue and portable generator are in the sibling metin2-client repository:
|
||||
`tools/server/ava2-stones/README.md`. That directory includes the complete source audit, generated patch interface, read-only owned-item impact audit and test results.
|
||||
|
||||
The 138 source ITEM_METIN rows include 20 ordinary +0..+5 chains, special stones and the broken-stone marker. Unsupported wolfman stones and original empty-attribute placeholders are explicitly disabled in the staged data, rather than silently converted to sword resistance or usable zero-effect stones. Existing custom +6 rows remain compatible until a separately backed-up inventory/socket migration.
|
||||
|
||||
This server change aligns the actual ITEM_METIN branch with AVA2's default (ENABLE_ADDSTONE_FAILURE is disabled): insertion always succeeds, and exactly one stone is consumed. Existing destination, wear-flag, duplicate-family and socket checks remain. The selected 40250-compatible three-socket packet format remains unchanged.
|
||||
|
||||
`python3 tests/features/test_stone_socket.py` compiles and executes the actual branch with lightweight dependencies. It verifies success, one-per-stack and last-item removal, duplicate family, equipped/exchange refusal, target type and socket eligibility. Full FreeBSD compilation also succeeded. The staged binary hash is 4b335083a26116771e18c97b3a41b039e1ff28efe93e957494fc62b6c5dfe94d.
|
||||
|
||||
Ordinary QA1017, isolated player_sb/account_sb, confirmed insertion and stack decrement, actual casting-speed +35 and max-HP +1200 deltas, and all three new exclusive-family pairs. The original test equipment was re-equipped after the probes. No production binary, owned item or socket was changed.
|
||||
|
||||
For isolated gmake builds, override both BINDIR and GAMEDIR: the old Makefile automatically moves its output into GAMEDIR after linking. The sbtest proto backups and test fixture backups are under /root/deploy-features/20261017-ava2-stones/.
|
||||
@@ -0,0 +1,17 @@
|
||||
# AVA2 原生追踪和门票商店
|
||||
|
||||
2026-10-18,feature/ava2-unlock;仅 sbtest,正式服 game SHA256 仍为 `40335e41d466fd7379c805749978ad6df9c82f5673a3e5b8881b3bee8767663d`。
|
||||
|
||||
实现为 `new_mob_timer.*`(AVA2 刷新日历和首领状态)、`ava2_track.*`(八副本)、`ava2_track_commands.h`(查询/传送)、`ava2_ticket_shop.*`(原 shop12)。详尽来源、联机证据和未闭合范围见客户端 `docs/AVA2-TRACK.md`。
|
||||
|
||||
`d.track_update` 支持原任务的一参数调用;quest DB 载入完成后补发早期查询。首领 P2P 使用已有变长 relay,避免修改所有 GG 固定包;owner 心跳过期后停止显示其存活。未知/未开放地图不报存活。原日历按星期取模;65535 为存活标记,普通同值倒计时发送 65536。
|
||||
|
||||
八副本优先原冷却标记,重返为次选。203 旧地下墓穴 last_exit_time、火焰 exit_time、蜘蛛 retry_limit_time 也读取;旧蓝龙冷却通过无副作用的现行 Lua settings 读取,正在任务内或缺配置报不可用。读 Lua 的公共实现提取为 `port_dungeon_settings.h`,现有只读副本查询继续复用。
|
||||
|
||||
shop12 不占已有 shop manager ID,只有八个原始报价;使用原 CShop 的同步发奖/空格检查,成功才扣材料,金币价格为零。禁止卖出和任意商店 ID 远程打开;客户端追加 GC_SHOP 子包并校验长度,不改变旧子包。协议和客户端必须一起更新。
|
||||
|
||||
测试:`python3 tests/features/test_ava2_track.py`、`test_ava2_dungeon_track.py`、`test_ava2_ticket_shop.py`。FreeBSD 编译必须同时指定 BINDIR 与 GAMEDIR,默认 Makefile 输出会覆盖生产目录。
|
||||
|
||||
本批追踪部署时的 game SHA256:`8640644b94005a463e9e8244e6c414f1700ab675950e7bd3b0958bee289b1119`。部署及构建日志在 `/root/deploy-features/20261018-ava2-parity/`,此次兼容读取前的 game 备份为 `game-before-legacy-track`。只可用 sbtest stop/restart 脚本切换,不能用生产重启脚本。
|
||||
|
||||
尚未完成:八副本原版任务/门票/等级全量迁移、真实跨核心故障切换、Android 触控、全套资源缺口修复、正式服发布。冷却状态不能替代入口 NPC 的队伍/门票/房间权限检查。
|
||||
@@ -0,0 +1,140 @@
|
||||
# AVA2 items: unlocking the locked systems
|
||||
|
||||
The 478 AVA2 drop items come from metin2-client `tools/server/ava2-items` (see FEATURE-AVA2-DROPS.md). Items of systems 40250 lacks were imported as ITEM_NONE. This branch turns them back into usable items one system at a time. Each phase keeps the AVA2 row (type, subtype, values, applies) once the server and client understand it.
|
||||
|
||||
| Phase | Items | State |
|
||||
|---|---|---|
|
||||
| P1 boxes and keys | 77918–77920 boxes, 77921–77923 keys (`ITEM_TREASURE_BOX` / `ITEM_TREASURE_KEY`, value0 3–5) | done |
|
||||
| P2 stones | 28444 破碑之石+4 (`APPLY_ATTBONUS_STONE`), 28445 Boss stone (`APPLY_ATTBONUS_BOSS`) | done |
|
||||
| P3 dragon armor | 21210–21219 暗龙 (warrior), 21230– 风龙 (assassin), 21250– 魔龙 (sura), 21270– 神龙 (shaman), +0..+9 | done (client) |
|
||||
| P4 sash | 85004 领主 / 85008 大师 / 85014 王朝 / 85018 皇家 披风 (`COSTUME_SASH`, grade 4) | done, not deployed |
|
||||
| P5 mounts | 71502 / 71505 / 71508 / 71511 坐骑时装 (`COSTUME_MOUNT`), 71234 / 71254 坐骑外观 (`COSTUME_MOUNT_SKIN`) + mobs 32012 / 32028 | done, not deployed |
|
||||
| P6 costume enchants | 54001–54078 时装 / 发型强化石, 54124–54174 坐骑外观强化石 (`USE_CHANGE_ATTRIBUTE`); weapon / sash-skin / effect ranges and 53996 stay locked | done, not deployed |
|
||||
| P7 talismans | 护符 chains 9600–10950 (`ARMOR_PENDANT`, +0..+200 per element), 71301 / 71302 / 53996 / 53997 talisman attribute items | done, not deployed |
|
||||
| P8 new rings | 戒指 chains 19500 红宝石 / 19520 石榴石 / 19540 祖母绿 / 19560 蓝宝石 (`ITEM_NEW_RINGS`, +0..+9) | done, not deployed |
|
||||
|
||||
## P1: boxes and keys
|
||||
|
||||
40250 already has both types. A key opens a box when their value0 match (char_item.cpp, `ITEM_TREASURE_KEY`); the box then hands out its special_item_group group (live since the drops deploy). 203's own boxes use value0 0–2, so AVA2's 3–5 don't clash.
|
||||
|
||||
## P2: stone and Boss bonus
|
||||
|
||||
The points exist from the biolog port (POINT_ATTBONUS_STONE 240, POINT_ATTBONUS_BOSS 241, damage in battle.cpp); the apply types did not.
|
||||
|
||||
- `APPLY_ATTBONUS_STONE = 139`, `APPLY_ATTBONUS_BOSS = 140` (common/length.h), the same numbers as AVA2 and the client (`ItemData.h`). 92–138 are reserved for AVA2 applies not ported yet: `aApplyInfo` maps them to POINT_NONE and ProtoReader's `arApplyType` names them `APPLY_RESERVED_<n>`, so array index = apply number.
|
||||
- `CHARACTER::ApplyPoint` handles both like the other additive applies.
|
||||
- ProtoReader is in the db, so **the db binary must be redeployed with the game**; an old db rejects the items' `APPLY_ATTBONUS_*` columns.
|
||||
- The two stones share AVA2's stone family 31 (value5), so a weapon holds only one of them. The 7 guardian weapons keep their AVA2 `APPLY_ATTBONUS_BOSS 5`.
|
||||
|
||||
Test: `tests/features/test_applies.py` (numbering in length.h, constants.cpp, ProtoReader and the client header).
|
||||
|
||||
## P3: dragon armor
|
||||
|
||||
Ordinary `ARMOR_BODY` items; the server needed nothing. All ten refine steps are imported so the refine chain (refine sets 81–89, 203's own costs) works; +9 ends the chain.
|
||||
|
||||
The look is armor shape 32 (value3). The 40250 race msm stop at shape 30, and they cannot be patched from a pack (a bare file name always comes from the root pack). The client therefore registers the shape after each race msm load: script `mt_shapes` (metin2-client `src/platform/ScriptLib/ArmorShapesScript.inc`). The models `<race>_7_1.gr2` (+ LODs, skin) ship in the ava2items pack.
|
||||
|
||||
**Open:** AVA2 requires level 115–120. 203 caps at MAX_LEVEL 105, so nobody can wear the armor, nor the guardian weapons (level 120) already live.
|
||||
|
||||
## P4: sash
|
||||
|
||||
AVA2's sash (acce) system, ported from `Srcs/Server` (`#ifdef __SASH_SYSTEM__`) into `game/src/port_sash.cpp`.
|
||||
|
||||
- Item: `ITEM_COSTUME` / `COSTUME_SASH = 3` (ProtoReader `arSub28`, so **the db binary changes too**). value0 = grade (the four imported sashes are grade 4); socket0 = absorption %, socket1 = vnum of the absorbed weapon/armor. An unrolled grade-4 sash gets 11–25 % on first equip/creation (`SASH_GRADE_4_ABS_*`), combining caps at 19 %.
|
||||
- Slot `WEAR_COSTUME_SASH = 24`; `PART_SASH` follows `PART_HAIR`. The part is not stored in the player table: `SetPlayerProto` clears it and the equipped sash sets it to vnum − 85000, +1000 once absorption reaches 19 % (the client shows the glow above 86000).
|
||||
- **Protocol:** `CHR_EQUIPPART_SASH` is a fifth `awPart` WORD in GC_CHARACTER_ADD / ADD2 / UPDATE, `HEADER_CG_SASH = 211`, `HEADER_GC_SASH = 215`. Old clients break; the server and the client deploy together.
|
||||
- Absorbed bonuses: the sash adds the absorbed item's applies, attributes and (weapons) attack values scaled by absorption, `int(v*abs/100 + .5)` (+1 when positive), in `CItem::ModifyPoints` and battle.cpp. `MTSASH <code>` chat commands report window errors and results to the client (`mt_sash`).
|
||||
- Combine: two sashes of the same grade, price 100k/200k/300k/500k by grade, success 80/70/50/30 %. Absorb: sash + weapon/armor, the material is destroyed.
|
||||
- Window: quest `sash` on 王铁匠 20016 (203 has no NPC 60003), `pc.open_sash(true)` combine / `(false)` absorb: metin2-client `tools/server/sash` (installs `pc.open_sash` into quest_functions).
|
||||
- Client: `src/platform/ScriptLib/SashScript.inc` (`mt_sash`: windows, costume slot, tooltips), models + `item_scale.txt` + effects in the ava2items pack.
|
||||
|
||||
Test: `tests/features/test_sash.py` (numbering, packet layout shared with the client header, quest hook).
|
||||
|
||||
## P5: mount costume and mount skin
|
||||
|
||||
AVA2's `ENABLE_MOUNT_COSTUME_SYSTEM` + `ENABLE_MOUNT_SKIN`, ported 1:1 into `game/src/port_mount.cpp`. They ride on the 40250 horse: the worn costume only changes the horse race.
|
||||
|
||||
- Items: `ITEM_COSTUME` / `COSTUME_MOUNT = 2` and `COSTUME_MOUNT_SKIN = 4` (AVA2 numbers the skin 7; ProtoReader `arSub28` gains `COSTUME_MOUNT_SKIN`, so **the db binary changes again**). value0 = horse race.
|
||||
- 71502 狮子 20113 (怪物强悍 +30 %), 71505 野猪 20110 (破碑 +30 %), 71508 狼 20111 (Boss +30 %), 71511 20112 (双倍经验 30 %).
|
||||
- The applies count while the costume is worn.
|
||||
- Skins 71234 蓝色巴里 → 32012, 71254 白色冬日羊驼 → 32028.
|
||||
- Both subtypes return no attribute set (`GetAttributeSetIndex` −1, the sash too), so they cannot be rerolled.
|
||||
- Slots `WEAR_COSTUME_MOUNT = 25` and `WEAR_COSTUME_MOUNT_SKIN = 26`.
|
||||
- `GetMyHorseVnum`: the worn skin's value0, else the worn mount's value0, else the horse-level race.
|
||||
- Summoning and riding still need horse level ≥ 1, as on AVA2; equipping without a horse says `MTMOUNT need_horse`.
|
||||
- Riding uses horse stamina.
|
||||
- Hooks follow AVA2:
|
||||
- Equipping re-summons.
|
||||
- Taking the mount off sends the horse away; taking the skin off re-summons.
|
||||
- A skin needs a worn mount (`need_mount`). Neither piece changes while riding (`riding`). The mount stays while a skin is worn (`has_skin`).
|
||||
- A worn mount is summoned on login.
|
||||
- `/user_horse_back` also takes the mount off.
|
||||
- Mobs 32012 / 32028 come from the AVA2 mob_proto rows (`mobs-server.tsv`, installed by `install_items.py … <mobs-server.tsv>`).
|
||||
- Client:
|
||||
- RaceManager `__IsNewMountRace` (32000–32100 → `npc_mount`).
|
||||
- `mt_mount` (`MountScript.inc`) registers the npclist rows, adds the costume window slots and renders the `MTMOUNT` messages.
|
||||
- The models ship in the ava2items pack (`MOUNT_MOBS`).
|
||||
|
||||
Test: `tests/features/test_mount.py`.
|
||||
|
||||
## P6: costume enchants
|
||||
|
||||
AVA2's `ENABLE_SPECIAL_COSTUME_ATTR`, in `game/src/port_costume_attr.cpp`. The items are `ITEM_USE` / `USE_CHANGE_ATTRIBUTE`. value0 is the apply type and value1 the value; AVA2 apply numbers equal 203's (P2 aligned 139/140). value2 is the target mask `1 << bonus flag`.
|
||||
|
||||
- Unlocked ranges (make_items `ENCHANT_KEEP`):
|
||||
- 54001–54027 时装 (mask 2, body);
|
||||
- 54028–54078 发型 (4, hair);
|
||||
- 54124–54174 坐骑外观 (16, mount skin).
|
||||
- Still locked, since the target systems don't exist here: 54079– weapon costume (8), 54175– sash skin (32), 54220– effect (64). 53996 became a talisman item in P7.
|
||||
- `CItem::IsCostumeEnchant` (vnum 54001–54267 with a nonzero value2) is checked first in the change/add-attribute case of `UseItemEx`, before the 40250 costume refusal. So an enchant never reaches the reroll code, and dragged onto gear it is refused (`MTCATTR target`).
|
||||
- `CostumeEnchantUse` follows AVA2's checks:
|
||||
- target kind and mask (`target`);
|
||||
- apply none (`none`);
|
||||
- not while worn (`equipped`, the 40250 switcher rule);
|
||||
- at most 3 attributes (`full`);
|
||||
- no duplicate apply (`has`).
|
||||
- Then `AddAttribute`, consume one, `ItemLog COSTUME_ENCHANT`, `done`.
|
||||
- The switchbot never uses enchants: it only looks up the switcher vnums in FEATURE-SWITCHBOT.md.
|
||||
- Client `mt_costume_attr` (`CostumeAttrScript.inc`):
|
||||
- marks matching costumes as usable drop targets (the 40250 inventory already sends every `USE_CHANGE_ATTRIBUTE` drop);
|
||||
- adds the attribute and targets to the enchant tooltip;
|
||||
- renders `MTCATTR`.
|
||||
|
||||
Test: `tests/features/test_costume_attr.py`.
|
||||
|
||||
## P7: talismans
|
||||
|
||||
AVA2's `ITEM_TALISMAN_EQUIPMENT` + `ELEMENT_NEW_BONUSES`, in `game/src/port_pendant.cpp`.
|
||||
|
||||
- Item: `ITEM_ARMOR` / `ARMOR_PENDANT = 7` (ProtoReader `arSub2`, so **the db binary changes again**), worn in `WEAR_PENDANT = 27`. The AVA2 wear flag `WEAR_PENDANT` does not exist here: `FindEquipCell` sends every talisman to the slot before the wear-flag check.
|
||||
- Six chains of 201 items (+0..+200), fire 9600, ice 9830, earth 10060, dark 10290, wind 10520, elect 10750. Each carries `APPLY_ENCHANT_<element>` = its step; the level limit rises from 20 to 60 along the chain.
|
||||
- Refine sets 440–499 (fragment 96001–96006 + 30031 + 33031 ×10, 50000 yang, 100 %) are SQL rows: metin2-client `tools/server/pendant` (`install.sh`, then restart the db).
|
||||
- Applies `APPLY_ENCHANT_ELEC..DARK = 123..128` (AVA2 numbers; the db names are AVA2's, `APPLY_ENCHANT_ELECT` first) → `POINT_ENCHANT_* = 242..247`.
|
||||
- Damage (battle.cpp `CalcAttBonus`): against a monster with `RACE_FLAG_ATT_<element>`, attack +point %, so a +200 talisman triples the attack on those monsters (×(1+200/100)), which is AVA2's own balance. Each flag is its own `if`, as on AVA2. AVA2 leaves out ICE; we include it, since 203 has 83 ice monsters and an ice talisman chain.
|
||||
- Attributes:
|
||||
- The pool is AVA2's item_attr pendant column (20 rows, levels 1–5), kept in a table in `port_pendant.cpp` instead of a new item_attr column (that would change the db boot packet).
|
||||
- `GetAttributeSetIndex` stays −1. So talismans drop without attributes, and the 40250 switchers and the attribute lock refuse them. The switchbot rolls them with 71302 only (pseudo attribute set 9).
|
||||
- 71302 rerolls all attributes (needs at least one; levels 0/10/40/35/15 %). 71301 adds one up to 5, always succeeding (levels 40/50/10 %). No duplicates.
|
||||
- **Deviation:** AVA2's 53996 / 53997 are generic switcher / adder items, a free 40250 gear reroll. Here they work like 71302 / 71301, as their zh names (护符附魔道具 / 护符加持道具) say.
|
||||
- Not while worn (`equipped`), like the 40250 switcher. Any other attribute item dropped on a talisman, or a talisman item dropped on anything else, gets `target`.
|
||||
- Messages: `MTPENDANT target|equipped|empty|changed|full|added` (client `mt_pendant`). `ItemLog PENDANT_CHANGE` / `PENDANT_ADD`.
|
||||
- Not ported: AVA2's element target packet (`ELEMENT_TARGET`, the element icon over the target HP bar).
|
||||
- Client: `ItemData.h` / `PythonItemModule` constants, `c_Equipment_Pendant`, apply texts, and `mt_pendant` (`PendantScript.inc`: the equipment slot under the earring, item drop targets, messages).
|
||||
|
||||
Test: `tests/features/test_pendant.py`; `test_applies.py` covers the 123–128 numbering.
|
||||
|
||||
## P8: new rings
|
||||
|
||||
AVA2's `ENABLE_NEW_RINGS`, in `game/src/port_rings.cpp`.
|
||||
|
||||
- Item: `ITEM_NEW_RINGS = 36` (`ITEM_SHINING = 35` is reserved for the AVA2 numbering and not ported). It is a new ProtoReader type, so **the db binary changes again**. Worn in `WEAR_RINGS_1 = 28` / `WEAR_RINGS_2 = 29`: `FindEquipCell` takes ring slot 1 when free, else slot 2. Rings have no wear flag.
|
||||
- Four chains of 10 (+0..+9). Each step carries a stat (INT / DEX / STR / CON) and a resist against one class. Level limit 90 (203's MAX_LEVEL is 105). They reuse 203's refine sets 46–54, which already have AVA2's materials, so no refine SQL is needed.
|
||||
- Sockets: rings are socket accessories (`IsAccessoryForSocket`). Drills add sockets (up to 3). As with every socket or attribute item in 40250, the ring must not be worn. Each family takes its AVA2 jewel (`CanPutInto`): 19500 → 50635, 19520 → 50636, 19540 → 50637, 19560 → 50638 (19220 → 50634 is in the table, but that family is not imported).
|
||||
- Attributes:
|
||||
- The pool is AVA2's `item_attr_rings` (20 rows, levels 1–5), kept as a table in `port_rings.cpp`. `GetAttributeSetIndex` stays −1, and `PutAttributeWithLevel` branches to the ring pool.
|
||||
- The 40250 switchers and adders (`USE_CHANGE_ATTRIBUTE`, `USE_ADD_ATTRIBUTE`, `USE_ADD_ATTRIBUTE2`) accept rings, with the usual not-while-worn rule. 71151 / 71152 (weapon / armor only) refuse them, by design.
|
||||
- The switchbot rolls rings from this pool (pseudo attribute set 8). The rare (6th / 7th) attributes skip rings. AVA2's `item_attr_rare_rings` is not ported.
|
||||
- Rings drop without attributes: `AlterToMagicItem` only handles weapons and armor.
|
||||
- Client: `ITEM_TYPE_RINGS`, `c_Equipment_Rings1/2` (253 / 254), and `mt_rings` (`RingsScript.inc`). That module adds the two slots beside the shoes, the accessory tooltip (applies, attributes, jewel sockets) and the drop targets for drills, jewels, switchers and adders.
|
||||
|
||||
Test: `tests/features/test_rings.py`.
|
||||
@@ -0,0 +1,111 @@
|
||||
# PORT battle pass
|
||||
|
||||
A monthly mission pass, ported from AVA2's `ENABLE_BATTLE_PASS` (the window behind `uibattlepassex.py`). A season is a time window with up to ten missions. Each mission has its own reward, and a final reward unlocks once every mission is done. The pass is free for every player; AVA2 sold a ticket item (25150–25161), and this port has none.
|
||||
|
||||
Source:
|
||||
- `src/server/game/src/port_battlepass.h`: config, per-player state and bag fit; standard C++ only.
|
||||
- `port_battlepass_runtime.h`: game side, included only by cmd_general.cpp.
|
||||
- `port_battlepass_hooks.h`: hook declarations for the other files.
|
||||
|
||||
Tables: `tools/battlepass/schema.sql`. Season file: `tools/battlepass/port_battlepass.tsv`. Test: `tests/features/test_battlepass.py`.
|
||||
|
||||
## Season file
|
||||
|
||||
The file is `<locale base>/port_battlepass.tsv`, for example `share/locale/newcibn/port_battlepass.tsv`. Every core checks it at most once every 5 s and reloads it when its mtime, size or inode changes, the same rule the event calendar uses. Replace it atomically with a temporary file and `mv`.
|
||||
|
||||
```
|
||||
MTBATTLEPASS 1
|
||||
season ID START END unix seconds, [START, END)
|
||||
mission SLOT TYPE SUB TARGET [VNUM COUNT]x0..3
|
||||
final VNUM COUNT [VNUM COUNT]x0..5
|
||||
```
|
||||
|
||||
- Any error disables the whole file; the game logs `PORT_BP: port_battlepass.tsv disabled: line N: why`. Errors include:
|
||||
- a bad number or a duplicate slot;
|
||||
- overlapping seasons;
|
||||
- a season without missions;
|
||||
- a sub on a type that takes none.
|
||||
- Slot numbers are 1..10. A season ID must never be reused: progress and claims are stored per season ID.
|
||||
- A reward must be a bag item:
|
||||
- not a dragon soul stone;
|
||||
- size 1..3;
|
||||
- at most 24 stacks per claim.
|
||||
|
||||
A bad reward is caught when someone claims it: the answer is `config`, `sys_err` logs it, and the slot stays claimable after the file is fixed.
|
||||
|
||||
| Type | Counts | SUB |
|
||||
|---|---|---|
|
||||
| 1 | monster kills (not boss, not stone) | mob vnum or 0 |
|
||||
| 2 | boss kills (rank ≥ boss) | mob vnum or 0 |
|
||||
| 3 | metin stone kills | stone vnum or 0 |
|
||||
| 4 | seconds online | 0 |
|
||||
| 5 | fish caught | item vnum or 0 |
|
||||
| 6 | successful refines | resulting item vnum or 0 |
|
||||
| 7 | levels gained | 0 |
|
||||
| 8 | gold paid to NPC shops | 0 |
|
||||
| 9 | items sold to NPC shops | item vnum (required) |
|
||||
|
||||
A kill counts for the player that `CHARACTER::Reward` gives the quest kill event to, which is the `DistributeExp` attacker. As in AVA2, it counts only when the monster is within 20 levels of the player. A party member who is not that attacker gets nothing. Type 9 needs a vnum because selling any item could be farmed with cheap shop items.
|
||||
|
||||
The shipped file has seasons 202610–202712 (through 2028-01-01), starting at local midnight on the first of each month (Europe/Berlin, the server's zone). Each has:
|
||||
- eight missions, rewards taken from 40250 items;
|
||||
- a final reward of the three pearls and 70024.
|
||||
|
||||
The targets follow the scale of AVA2's month 10 (`player.battle_pass`).
|
||||
|
||||
## Storage
|
||||
|
||||
```
|
||||
player.mt_battlepass_progress (pid, season, slot, value, target) PRIMARY KEY (pid, season, slot)
|
||||
player.mt_battlepass_claim (pid, season, slot, claimed_at) PRIMARY KEY (pid, season, slot); slot 0 = final
|
||||
```
|
||||
|
||||
**Counting.** Events are counted in memory, as the delta per slot. `CHARACTER::SaveReal`, which covers the periodic save, logout and warp, adds play time, then queues one upsert on the game's ordered SQL connection:
|
||||
|
||||
`value = LEAST(value + delta, target)`
|
||||
|
||||
Because the write adds, a core does not need to have read the row first. Two cores that both see the player during a warp add their own deltas, with no overwrite.
|
||||
|
||||
**Loading.** At the first event or `/mt_bp`, a `FuncQuery` reads the stored values and claims. Flushes queued after that read are added on top. A generation number drops the answers of a session that has already ended.
|
||||
|
||||
**Season change.** The counts of the old season are written while that season is still in the file. The new season then loads its own rows.
|
||||
|
||||
**Claims.** A claim checks four things before writing anything:
|
||||
1. the state is loaded;
|
||||
2. the mission is complete;
|
||||
3. the slot is not claimed yet;
|
||||
4. all the stacks fit in the bag. The fit is first-fit in `GetEmptyInventory` order, and a size-2 or size-3 item stays inside one 45-cell page.
|
||||
|
||||
Only then does it run `INSERT IGNORE` into the claim table synchronously. Only the request whose insert affected a row creates the items, into the cells checked before. A double click, a retry or another core finds the row already there and gets `claimed`. Each item gets an `MT_BP_CLAIM` item log with the hint `SEASON SLOT`, and the character is saved right away.
|
||||
|
||||
Known limits:
|
||||
- If the core crashes between the claim row and the item save, that reward is lost. The claim row and the item log are there for a GM to compensate.
|
||||
- While a warp is in flight, the window can show slightly less progress than is stored. Nothing is lost or counted twice.
|
||||
|
||||
## Protocol
|
||||
|
||||
```
|
||||
/mt_bp 1 info | 1 claim SLOT | 1 close
|
||||
MTBP1 season ID START END NOW COUNT
|
||||
MTBP1 mission SLOT TYPE SUB TARGET VALUE CLAIMED [VNUM COUNT]...
|
||||
MTBP1 final CLAIMED ALLDONE [VNUM COUNT]...
|
||||
MTBP1 end
|
||||
MTBP1 none no season running (or no valid file)
|
||||
MTBP1 progress SLOT VALUE pushed while the window is open
|
||||
MTBP1 done SLOT a mission was finished (always sent)
|
||||
MTBP1 claimed SLOT the reward is in the bag; a full info follows
|
||||
MTBP1 error loading|slot|claimed|incomplete|space|config|db|rate|invalid
|
||||
```
|
||||
|
||||
- `info` before the load is answered as soon as the load arrives.
|
||||
- A `done` for a mission that an event finished before the load is sent when the load arrives.
|
||||
- `info` and `claim` share a 300 ms gap per player (`rate`).
|
||||
- A wrong version, more than three tokens, or a token longer than 10 characters gets no answer.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Apply `tools/battlepass/schema.sql` once.
|
||||
2. Copy `port_battlepass.tsv` to the locale base directory.
|
||||
3. Restart the cores with the new binary.
|
||||
|
||||
Without the file, every `/mt_bp` answers `none` and nothing is counted or written.
|
||||
@@ -1,6 +1,6 @@
|
||||
# PORT batch chest opening, v1
|
||||
|
||||
Date: 2026-10-15. AVA2-style batch opening of gift boxes (reference: AVA2 `ENABLE_MULTI_CHEST`, `/chest_drop`, `CHARACTER::OpenChest`). Source: `src/server/game/src/port_chest.h` (header-only, included from `cmd_general.cpp`), command `mt_chest` (cmd.cpp). It reuses the quiet-INFO hook (`m_portQuietInfo` / `m_portLastInfo`) added for the switchbot. No packet header, no DB schema, no char.h/item.h change.
|
||||
Date: 2026-10-15. AVA2-style batch opening of gift boxes (reference: AVA2 `ENABLE_MULTI_CHEST`, `/chest_drop`, `CHARACTER::OpenChest`). Source: `src/server/game/src/port_chest.h` (header-only, included from `cmd_general.cpp`), command `mt_chest` (cmd.cpp). It reuses the quiet-INFO hook (`m_portQuietInfo` / `m_portLastInfo`) (char.cpp; first added for the v1 switchbot, which no longer uses it). No packet header, no DB schema, no char.h/item.h change.
|
||||
|
||||
AVA2 rewrote the drop loop (`GiveItemFromSpecialItemGroupNew`, `AutoGiveItemChest`, cap 1000). That rewrite is not ported. Here every box goes through the original `CHARACTER::UseItem` → `UseItemEx` `ITEM_GIFTBOX` path, one box at a time, so the original checks, the `special_item_group` roll, gold/exp, `ItemLog` and consumption stay exactly as they are.
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Level cap 120 + AVA2 105–120 content
|
||||
|
||||
The user decided on 2026-10-16:
|
||||
- raise the level cap from 105 to 120;
|
||||
- for 105–119, use a geometric exp curve that stays under the DWORD limit;
|
||||
- keep the level-delta exp/drop table (`aiPercentByDeltaLev*`) unchanged;
|
||||
- port AVA2's new maps and dungeons, with drops for their monsters.
|
||||
|
||||
## Why the cap alone is not enough
|
||||
|
||||
- **Exp curve.** On the newcibn locale `exp_table` = `exp_table_common`. Its 105–119 entries only moved from 2.33e9 to 2.49e9, so every level cost about the same as 104. AVA2 climbs to 2.05e10, but its table is DWORD, so from 107 on it wraps: 4.37e9 becomes about 7.5e7. That is not copied.
|
||||
- **No monsters.** On 203 the highest normal monster that spawns is level 103 (6006); bosses and stones top out at 105. `PERCENT_LVDELTA` applies to exp, drop chance and gold alike. A player 12 levels above the monster gets 20%, and 15 or more levels above gets 1%. So without new monsters, 105–120 cannot be levelled.
|
||||
- **AVA2 has the content.** 445 monster/stone vnums are AVA2-only, and 348 of them are level 100 or higher. AVA2 also re-levels 47 shared monsters, for example 2493 from 97 to 105 and 3091 from 105 to 115.
|
||||
|
||||
## Phases
|
||||
|
||||
| | What | Where |
|
||||
|---|---|---|
|
||||
| L1 | `MAX_LEVEL: 120`; exp table 105–119 = 2.33e9 → 4.2e9 geometric (constants.cpp); `player.exp` / `player_deleted.exp` → `INT UNSIGNED`. Points are already DWORD on the server, and the client reads exp unsigned. | server, `tools/server/level-120` (client repo) |
|
||||
| L2 | Monsters: AVA2-only rows from AVA2 `db/mob_proto.txt` (not `share/conf`, which is an older copy), zh names, client mob models/motions (Monster, Monster2, NPC2 packs), `npclist`. | server proto + client pack |
|
||||
| L3 | Maps, 100+ first: `plechito_desert_map_01` (101–115), `metin2_map_elemental_04_rework` (103–112), Yohara `eastplain_01–03` + `empirecastle` (85–125), `metin2_map_dawnmist_dungeon_01` (120). Server map dir + index + MAP_ALLOW on a core; client map pack, atlas, minimap, zh map names; reach them through the travel ring / NPC like AVA2's `anillotp` / `tp_npc1`. | both |
|
||||
| L4 | Dungeons: `flame` (107–120, our 351 retuned), `snow` (`n_snow_dungeon_01` 352, 100–120), `meleylair` (212, 113–123, level ≥ 110), `shipdefense` (`defensawe_hydra` 355, 100–120). They need quest functions we lack: `d.global_warp_all_to_base`, `d.mission_notice`, `d.track_update`, `d.spawn_mob_new`, `d.new_kill_all`, `game.check_event`, `npc.set_meley_hp`, `npc.set_protect_flag2`, `npc.set_protect_time`, `npc.get_protect_time`, `npc.set_statu_affect`, `npc.set_statu_clear_aff`, `npc.show_statu`, `npc.dead_by_vnum`. AVA2's `when X.chat.lc_quest("…")` and `lc_quest` strings must become zh literals for our qc. | both |
|
||||
| L5 | Drops: AVA2 gives only 8 of the new monsters drops (203 already has those groups), so the rest are designed in the client repo's `tools/server/ava2-maps/drops_maps.tsv` (tiers normal / elite / boss / stone / gold, plus per-map and per-vnum-range rows) and written by `make_drops_maps.py`. Every drop item must exist in item_proto first, otherwise the core won't boot. | server |
|
||||
| L6 | Test on the sbtest cluster, then deploy with the rest of feature/ava2-unlock (needs approval). | 203 |
|
||||
|
||||
Later, below 105 or separate systems: summer maps `a1/c1_summer`, `metin2_12zi_stage` (zodiac, C++), `kingdoomswar`, `battlefied`. The plechi dungeons (slime/duratus/gold/nightmare/troll/elephant) have maps but no quest in AVA2's quest_list, so they are skipped.
|
||||
|
||||
## Open
|
||||
|
||||
- Whether to take AVA2's new levels for the 47 shared monsters.
|
||||
- Which 203 core carries the new maps. The cores are i386 and each uses about 400 MB.
|
||||
|
||||
## Status
|
||||
|
||||
- L1 done on sbtest (2026-10-16). Exp table 106–120 in constants.cpp. The exp sum in `CHARACTER::PointChange(POINT_EXP)` is now 64-bit, as are the death exp-loss product (char_battle.cpp) and the quest reward check (questpc.cpp). Before that fix, 3.67e9 + 2e9 at level 119 wrapped to 1375032704. Tested with `/set exp` on [SA]Admin:
|
||||
- 105 → 106 at 2.33e9;
|
||||
- 3375032704 (> 2^31) saved to `player_sb.player` and survived `restart.sh`;
|
||||
- +2e9 at 119 → 120;
|
||||
- no more gain at 120.
|
||||
The live schema change and live `MAX_LEVEL: 120` are not applied.
|
||||
- L2/L3 on sbtest (2026-10-17): the 10 maps of `tools/server/ava2-maps/README.md` (client repo) are installed in channel5's own locale/data farm (`sbtest_locale.sh`) and reachable with `/warp x y` (global metres; `/goto #index` does not reach them). Hydra is moved from AVA2's 972800,153600 to 3276800,0, so AVA2 quest coordinates shift by (+2304000, −153600); its entry is `/warp 33089 116`. Mob models render.
|
||||
- Client fix found on the way: after `/warp`, a timer chat (`/bio status`, `/server_bonuses`) sent between the new socket coming online and the core's GC_PHASE reached the core's handshake phase and got the connection closed ("Handshake phase does not handle packet 3"). The client now leaves the "Game" phase on GC_WARP and drops chat outside it.
|
||||
- L5 on sbtest (2026-10-17): 99 drop groups appended (107 generated, the 8 existing kept). A kill test on plechito (`/m` + `/weaken all` + auto hunt) dropped the tier items, the lv115 armor, and the flame/hydra boss materials.
|
||||
- L4 on sbtest (2026-10-17): AVA2's snow / ship defence / Meley quests ported as `snow_dungeon`, `ShipDefense`, `MeleyDungeon` by the client repo's `tools/server/ava2-dungeons` (`make_quests.py` + `install.sh`, see its README). Server side: `port_ava2_dungeon.cpp` (the `d.*` / `npc.*` functions AVA2's quests call), `QUEST_ATTACK_EVENT` (`<vnum>.attack`, Meley's HP phases), the Meley and hydra HP helpers. `d.track_update`, `game.check_event` and the battle pass calls were dropped from the quests instead of ported. The game build is installed only as sbtest's `game.switchbot` (previous one kept as `game.switchbot.pre-l4`). Entry test on the Mac client (key + `/warp` to the NPC + quest dialog → solo → yes): all three dungeons warp in (352, 355, 212), the key is used, the dungeon timers and mob spawns start, and syserr shows no quest errors. Meley full run (2026-10-17, solo GM at level 120 with a temporary sbtest-only damage/HP buff quest, since removed): all 9 floors, the floor-10 chest, and the exit warp back to map 62 (5986,6573) in 837 s; the 3 h cooldown flag is written. Fixes found on the way: `char_battle.cpp` never lets a hit take a dragon statue (6230) below 1 HP, so only the quest's `npc.dead_by_vnum` kills it (AVA2 has the same stuck-lair bug on floor 8); the client's autohunt now skips a target that is hit but takes no damage for 4 s (it stays skipped for 60 s). The client's `mt_dungeon_timer` shows the AVA2 dungeon timer (boss portrait, floor/wave, countdown) in place of the minimap, plus the hydra mast HP bar.
|
||||
- Snow / ship / party runs (2026-10-17), with the fixes they needed:
|
||||
- QUEST_INFO desync: `SendQuestInfoPakcet` sent the header before the optional fields were added, so `qi.size` was short and the client read the rest as a new packet ("Unknown packet header: 212"). The fields are now built first. The client also takes the full size from the flags.
|
||||
- Hydra 6812 (KING, MAGIC) never took damage. The deck stops a player about 620 from its centre, and `battle_melee_attack` allowed only 300 (AVA2 600, still short of 620), so the server dropped every hit as VICTIM_FAR. For a non-PC victim of rank BOSS or higher the limit is now 800. The client gives a boss the 500 centre test of a huge race, like AVA2's `IsBoss()`.
|
||||
- Client autohunt: large targets (defending reach as body size, walk straight at a body in reach when the planner finds no path), escalating skip for a target it keeps stalling on, a new anchor after a teleport (snow floor changes move the player more than 2000), and the immune skip only counts an explicit 0-damage packet.
|
||||
- The snow driver used GM `/purge all` on floors 1/3/4 when a floor was still open after 300 s. This is a test accelerator for floors with 100+ mobs, not autohunt.
|
||||
- Party skill power crash: `CTableBySkill::GetSkillPowerByLevelFromType` indexed its table with `job * 2 + skill_group - 1` and only rejected skill_group 0. [SA]Admin has skill_group 50 (one live row has it too), so the party update event (`CParty::ComputeRolePoint`) crashed the core as soon as that character was in a party. Out-of-range skill groups and levels now return 0.
|
||||
- Results (sbtest, 2026-10-17, Mac client, autohunt):
|
||||
- Ship defence (test character): waves 1→3, the hydra dies, chest 9018 spawns, exit to CapeDragonHead in 450 s, the key is used.
|
||||
- Meley (test character): floors 1→10, the chest, exit to map 62 in 1362 s.
|
||||
- Snow ([SA]Admin): floors 1→10, Nemere dies, exit to map 61 in 3303 s. Floors 1/3/4 needed GM `/purge all` (see above). The quest's `item.remove()` takes the whole stack of seal keys 30331/30333 (same in AVA2), so the driver handed them out one at a time.
|
||||
- Party entry ([SA]Admin leads, Test joins): snow, ship and Meley all take both members in, and each member's key is used.
|
||||
- Deploy package: `/root/deploy-features/20261017-lv120` on 203 (`sh deploy.sh check|go|rollback`).
|
||||
- Follow-ups: client models/motions missing for the hydra chest (race 9018), `defensewave_hydra_boss` drop and minihydra `special_attack1`; autohunt is slow on floors with 200+ mobs; the new maps are reachable only by `/warp` (no travel NPC yet); the sash quest is not deployed; `new_quest_lv52` already raises `is_destination_village` Lua errors on live (questlib.lua's `dofile(GFquestlib.lua)` is commented out).
|
||||
@@ -0,0 +1,15 @@
|
||||
# AVA2 原生战令、百科查询与活动日历
|
||||
|
||||
使用原生 `uiBattlePassEx`、`uiWiki` / `WikiUI`、Worldard `uiDropItem` 与 `uiEventCalendarNew`,客户端原件哈希及平台适配见对应客户端 `docs/AVA2-NATIVE-SYSTEMS.md`。
|
||||
|
||||
- `/battle_pass info|activate CELL VNUM|reward|close` 使用当前战令赛季和原有领取主键,映射九种已接入的任务。原生模式任务完成自动发奖,满包待重试;最终奖励需点击。旧 `/mt_bp` 保留。SQL 使用配置的 PLAYER_SQL 数据库,不硬编码 player;不要把sbtest进度写入生产。
|
||||
- CG215(6字节)/GC220(114字节):子类型0打开、1反查怪物、6查询怪物掉落、7查询宝箱、8反查宝箱、9/10反查强化家族。GC子类型2打开、3行、4清空、5完成、6拒绝/超限错误。只读当前加载表,单次上限4096行。
|
||||
- `/event_manager info`:AVA2新日历原39号与经典SHOP_SIGN冲突,移到214号,5字节动态头和81字节事件记录。仅对客户端标记mt20261019以上下发新增二进制包。保持经典封包布局。
|
||||
- 日历和真实掉落读取同一个 `port_events.tsv`;UTC开始含、结束不含,并检查频道与帝国。月光宝箱映射AVA2事件8,圣诞袜映射扩展20。目前只接入这两种真实活动,其他活动不会因新窗口出现而自动生效。
|
||||
- 空文件不是有效排期;没有活动时使用 `MTCALENDAR 1` 加换行。没有文件或文件错误时明确显示不可用,不伪造活动。
|
||||
|
||||
测试:30组服务端功能脚本;原战令测试新增自动领奖/重复领取/满包/旧数据;新增 `tests/features/test_native_queries.py` 直接编译实际处理器,验证宽度、正反查、限流、超限、旧客户端与活动作用域。FreeBSD隔离构建及macOS/sbtest已联机验证。测试账号原有物品、任务和战令数据已备份恢复。
|
||||
|
||||
部署工具 `tools/native-systems/deploy.py`:`check`只读;`deploy --candidate PATH --sha256 HASH` 验证候选后备份、优雅停止正式game/auth、更换共享game、恢复13个核心和auth,db保持运行;`rollback --backup DIR` 恢复备份程序。回滚保留已经取得的进度/领取主键,避免再次支付奖励;不回退玩家经济数据。
|
||||
|
||||
203正式服已于2026-10-19 08:31:54(CEST,UTC+02)更新。game SHA256:a8d606ea88731cb5b7bffabbe8ddc78ef806205f6c8a352d78ba6d46a1c6b2f3。备份:`/root/backup-native-systems/20261019-083154`,auth、13个核心和原db运行,sbtest已恢复。生产排期初始化为空,不发布测试活动。首次优雅停止因换页超过55秒,旧程序未替换;旧核心正常退出后重新部署成功,等待窗口已延长至300秒。保留原motion accumulation警告,没有新增PORT_BP/查询/Lua错误。客户端必须同时更新可执行文件及ava2items/wiki资源包。
|
||||
@@ -1,6 +1,6 @@
|
||||
# PORT batch pickup, v1
|
||||
|
||||
AVA2-style batch pickup (reference: AVA2 `do_pickup_all`). One command picks up every ground item the character owns within the normal pickup distance, filtered by category. Source: `src/server/game/src/port_pickup.h`, command `mt_pickup` (cmd.cpp), throttle field `m_portPickupLastCommand` in char.h. It reuses the quiet-INFO hook (`m_portQuietInfo`) added for the switchbot. No packet header, no DB schema, no affect. AVA2's `HEADER_CG_ITEMS_PICKUP` packet and its premium automatic pickup (`AFFECT_AUTO_PICK_UP`, item 70002) are not ported.
|
||||
AVA2-style batch pickup (reference: AVA2 `do_pickup_all`). One command picks up every ground item the character owns within the normal pickup distance, filtered by category. Source: `src/server/game/src/port_pickup.h`, command `mt_pickup` (cmd.cpp), throttle field `m_portPickupLastCommand` in char.h. It reuses the quiet-INFO hook (`m_portQuietInfo`) (char.cpp; first added for the v1 switchbot, which no longer uses it). No packet header, no DB schema, no affect. AVA2's `HEADER_CG_ITEMS_PICKUP` packet and its premium automatic pickup (`AFFECT_AUTO_PICK_UP`, item 70002) are not ported.
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ MTF1 end REQUEST ROW_COUNT
|
||||
MTF1 error REQUEST ERROR
|
||||
```
|
||||
|
||||
MASK: 1 mob drops, 2 chest preview, 4 own stats, 8 item sources, 16 dungeon snapshots, 32 scheduled calendar, 64 switchbot (separate `/mt_switchbot` / `MTSB1` protocol, see FEATURE-SWITCHBOT.md), 256 world bosses (see FEATURE-BOSS-TRACK.md). The current mask is 511. Unknown capability bits are ignored; unknown versions are rejected. Capability advertises the query implementation; missing quest/config can still return unsupported/schedule_unavailable. The client negotiates before business queries; old servers time out to unsupported, not an empty result.
|
||||
MASK: 1 mob drops, 2 chest preview, 4 own stats, 8 item sources, 16 dungeon snapshots, 32 scheduled calendar, 64 was the v1 switchbot (`/mt_switchbot` / `MTSB1`) and is no longer advertised, because the AVA2 switchbot uses its own packets (FEATURE-SWITCHBOT.md), 256 world bosses (see FEATURE-BOSS-TRACK.md). The current mask is 959. Unknown capability bits are ignored; unknown versions are rejected. Capability advertises the query implementation; missing quest/config can still return unsupported/schedule_unavailable. The client negotiates before business queries; old servers time out to unsupported, not an empty result.
|
||||
|
||||
Each drop/chest/source page contains at most 8 rows, with consecutive absolute indices. TOTAL is capped at 4096; stats are one complete bounded snapshot (currently the named keys in kPortStats, less than 128). Client commits only a complete, matching begin/rows/end sequence. Unknown/stale request IDs cannot overwrite the current selection. Each line is bounded below 512 bytes; rows contain IDs and values, not server-provided script/names/markup.
|
||||
|
||||
@@ -39,7 +39,7 @@ Rules:
|
||||
|
||||
| RULE | Meaning of MIN/MAX and weights |
|
||||
|---|---|
|
||||
| 0 | rank common drop; MIN/MAX = eligible player levels |
|
||||
| 0 | rank common drop (common_drop_item.txt) or level-range common drop (common_drop_new.txt, MIN/MAX clipped to monster level ±20); MIN/MAX = eligible player levels |
|
||||
| 1 | independent monster drop group; weight is original configured threshold, not final probability |
|
||||
| 2 | weighted kill group; MIN = original kill-per-drop parameter; weight/group total describe the conditional selection |
|
||||
| 3 | level group; MIN = player minimum level; original denominator 1,000,000 |
|
||||
|
||||
+70
-74
@@ -1,93 +1,89 @@
|
||||
# PORT switchbot (automatic attribute change), v1
|
||||
# PORT switchbot (自动洗练), AVA2 port
|
||||
|
||||
AVA2-style automatic rerolling (reference: AVA2 `new_switchbot.cpp` / `uiswitchbot.py`), rebuilt so that the server stays authoritative and the existing reroll path is unchanged. Source: `src/server/game/src/port_switchbot.h`, command `mt_switchbot` (cmd.cpp), quiet-INFO hook in `CHARACTER::ChatPacket` (char.cpp), fields in char.h. No attribute lock, no DB schema, no packet header, no P2P transfer.
|
||||
AVA2 `ENABLE_SWITCHBOT` ported 1:1 (reference: AVA2 `game/src/new_switchbot.{h,cpp}`, client `PythonSwitchbot.cpp` and `root/uiswitchbot.py`). Classes, API, packets, the window and the 0.1 s roll speed are AVA2's. It replaces the v1 `/mt_switchbot` chat protocol (`MTSB1`, query capability bit 64). That command and its lock verb are gone.
|
||||
|
||||
## Rules
|
||||
Source:
|
||||
- `src/server/game/src/port_switchbot.{h,cpp}`: `SwitchbotHelper`, `CSwitchbot`, `CSwitchbotManager`, `PortSwitchbotBoot`.
|
||||
- `common/length.h`: `SWITCHBOT = 7` in `EWindows` (GROUND is now 8), `SWITCHBOT_SLOT_COUNT 6 / _REAL 5 / ALTERNATIVE_COUNT 2 / NORM_ATTR_NUM 5`, `TItemPos::IsSwitchbotPosition`.
|
||||
- `common/tables.h`: the switchbot tables.
|
||||
|
||||
- Each roll calls the original `CHARACTER::UseItem(scroll cell, target cell)`. All checks, probabilities, the addon handling, `ItemLog CHANGE_ATTRIBUTE` and scroll consumption are the manual path's. That includes the 71151/76023 restriction (weapon/body, level limit <= 40) and the GM quest flag. A roll counts only when exactly one scroll of the chosen vnum was consumed. Otherwise the bot stops with `rejected` and resends the original INFO line once.
|
||||
- The per-roll INFO lines (`属性已变更`) are held back while the bot calls UseItem (`m_portQuietInfo`); all other chat types pass through.
|
||||
- Only `ITEM_USE / USE_CHANGE_ATTRIBUTE` scrolls are accepted. `USE_CHANGE_ATTRIBUTE2` has no handler in this server's UseItemEx.
|
||||
- Target item: inventory cell, not costume, attribute set != -1, at least one attribute, not equipped or in an exchange. It is bound by item ID.
|
||||
- One bot per character. One roll every 250 ms (`PASSES_PER_SEC(1)/4`). Limit 1..1000 rolls.
|
||||
- Targets: up to 2 alternatives, each 1..5 distinct (apply, minimum). An alternative matches when every target is found among the 5 normal attribute slots with value >= minimum. Any matching alternative stops the bot (AVA2 CheckItem semantics). The bot also checks before it starts, so an item that already matches consumes nothing.
|
||||
- Allowed targets are the applies the attribute table can roll for this item's set, excluding the item's base proto applies. The maximum is `lValues[min(maxLevelBySet,5)-1]`. Items with an addon type also allow skill damage 30 / normal hit 65, the item_addon bounds.
|
||||
- Every tick re-checks the state and stops with a reason. This replaces AVA2's hooks into every move/trade path.
|
||||
- Character gone, VID changed (logout or warp) or descriptor lost: the bot is erased silently.
|
||||
- `busy`: dead, warping, `!CanHandleItem()`, exchange, own shop, shop, safebox or cube open.
|
||||
- `item_gone`: the item is missing, has another owner, has left the inventory window or is equipped.
|
||||
- `no_scroll`, `limit`, `matched`, `rejected`, `stopped`.
|
||||
- No offline rolling. Rolls stop when the player leaves, and every completed roll has already been saved and logged by the original path.
|
||||
## Window and items
|
||||
|
||||
## Protocol (CHAT_TYPE_COMMAND, version 1)
|
||||
- Items placed in the `SWITCHBOT` window (cells 0..4) are kept in `m_pointsInstant.pSwitchbotItems` and saved with `window = 'SWITCHBOT'`. The db loads, saves and deletes that window with SAFEBOX and DRAGON_SOUL_INVENTORY (three queries in `ClientManagerPlayer.cpp`).
|
||||
- At boot (game cores only), `PortSwitchbotBoot` adds `'SWITCHBOT'` to the `player.item.window` enum if it is missing. The deploy SQL carries the same ALTER.
|
||||
- `MoveItem` only accepts `SwitchbotHelper::IsValidItem` items into the window. That is AVA2's list: weapons, rings, and armour (body, head, shield, wrist, shoes, necklace, earrings, talisman). Cell 5 is rejected. The move hooks send:
|
||||
- `switchbot_error active` when the item is moved out of a running slot;
|
||||
- `switchbot_error invalid` when the item is not valid for the switchbot.
|
||||
- Drop, give, exchange and safebox refuse switchbot cells: the item has to go back to the inventory first. Shops sell only from the inventory.
|
||||
|
||||
Requests (250 ms per-character throttle; tokens <= 10 chars, <= 30 tokens):
|
||||
## Rolling
|
||||
|
||||
```
|
||||
/mt_switchbot 1 attrs CELL
|
||||
/mt_switchbot 1 start CELL SCROLL_VNUM LIMIT N1 (APPLY MIN)*N1 [N2 (APPLY MIN)*N2]
|
||||
/mt_switchbot 1 stop
|
||||
/mt_switchbot 1 status
|
||||
/mt_switchbot 1 lock CELL SLOT (attribute lock, see FEATURE-ATTR-LOCK.md)
|
||||
```
|
||||
- `CSwitchbot::SwitchItems` runs every 0.1 s (`c_fSpeed`). Each active slot takes one switcher per pass.
|
||||
- A slot finishes when one configured alternative fully matches within the first 5 attributes (AVA2 `CheckItem`). An alternative that isn't configured counts as a match.
|
||||
- Deviations from AVA2 (also listed at the top of `port_switchbot.cpp`):
|
||||
- Cell 5 (AVA2's hidden switcher cell) is never used. Switchers come from the inventory, skipping stacks that are being exchanged, locked or sold in the player's shop.
|
||||
- Which switcher is used follows the manual path:
|
||||
- a talisman takes only 71302;
|
||||
- a weapon or body armour with no level limit above 40 takes 71151 / 76023 first;
|
||||
- everything else takes 71084, then 39028.
|
||||
- A slot whose item has no attributes stops instead of rolling.
|
||||
- Every roll is written to ItemLog as `SWITCHBOT`, with the item id as the hint.
|
||||
- End and stop messages are server commands, which the client turns into localized text:
|
||||
- `switchbot_end <slot>`
|
||||
- `switchbot_stop noattr <slot>`
|
||||
- `switchbot_stop nochanger <slot>`
|
||||
|
||||
Replies:
|
||||
The slot is 0-based. AVA2 sent the locale ids `864` / `865` with slot+1.
|
||||
- Leaving the core deletes the table once it has been sent on. A logout that unregisters the last active slot also stops the event.
|
||||
- The attribute list has two pseudo sets after `ATTRIBUTE_SET_MAX_NUM`: 8 = rings (`port_rings.cpp`) and 9 = talismans (`port_pendant.cpp`).
|
||||
- Warp: `CHARACTER::WarpSet` sends the table over P2P (`HEADER_GG_SWITCHBOT 31`, `TPacketGGSwitchbot`) before `GC_WARP`. The target core keeps it, and `EnterGame` re-registers the slots whose item is still there and restarts the event.
|
||||
|
||||
```
|
||||
MTSB1 attrs CELL VNUM COUNT
|
||||
MTSB1 attr INDEX APPLY MAX (COUNT rows, INDEX 0..COUNT-1)
|
||||
MTSB1 attrs_end CELL COUNT
|
||||
MTSB1 state ACTIVE CELL VNUM ROLLS LIMIT SCROLL SCROLLS REASON
|
||||
MTSB1 lock CELL VNUM MASK (after every attrs_end, and as the reply to lock)
|
||||
MTSB1 error VERB CODE
|
||||
```
|
||||
## Protocol
|
||||
|
||||
`REASON` is one of `running matched limit no_scroll item_gone rejected busy stopped idle`. Error codes:
|
||||
Header numbers, subheaders and field order are AVA2's. The structs are `pack(1)`, and their sizes are pinned with `static_assert` in `port_switchbot.cpp` and in the client (`Packet.h`, `PythonSwitchbot.h`).
|
||||
|
||||
| Code | Meaning |
|
||||
| --- | --- |
|
||||
| `rate` | throttled |
|
||||
| `invalid` | malformed |
|
||||
| `item` | no item in that cell |
|
||||
| `equipped` | equipped or in an exchange |
|
||||
| `no_attr` | the item cannot be rerolled |
|
||||
| `scroll` | the scroll is missing or the wrong type |
|
||||
| `target` | the apply is not allowed, above the maximum or a duplicate |
|
||||
| `running` | this character already has a bot |
|
||||
| `busy` | see the busy states above |
|
||||
| Packet | Header | Layout |
|
||||
| --- | --- | --- |
|
||||
| CG | 171, dynamic | `BYTE header, int size, BYTE subheader, BYTE slot` (7) + `START`: `TSwitchbotAttributeAlternativeTable[2]` (15 each) / `STOP` |
|
||||
| GC | 171, dynamic | same 7-byte head + `UPDATE`: `TSwitchbotTable` (220) / `UPDATE_ITEM`: `TSwitchbotUpdateItem` (40: slot, vnum, count, 3 sockets, 7 attributes) / `SEND_ATTRIBUTE_INFORMATION`: `TSwitchbottAttributeTable[n]` (9) |
|
||||
| GG | 31 | `TPacketGGSwitchbot` (223) |
|
||||
|
||||
A state line is pushed after every roll and when the bot stops. When the reason is `item_gone`, CELL and VNUM are 0.
|
||||
CG is registered in `packet_info.cpp` with `Set(..., true)` and GG with `Set(..., false)`. The 40250 base packets are unchanged.
|
||||
|
||||
Capability: the MTF1 cap mask advertises bit 64 (63 -> 127). Clients that don't know it ignore it, and the client also times out to "unsupported" against old servers.
|
||||
**Version gate.** The client is built with `LOCALE_SERVICE_EUROPE`, so every locale sends `CG_CLIENT_VERSION2`. The new client's timestamp is `1215955205 mt20261016`. 203 is a europe locale and checks the version with `atoi`, which still reads 1215955205. Before `EnterGame` sends anything, it checks `SwitchbotHelper::IsClientSupported`, which looks for `mt<date>` in the timestamp with date >= `PORT_SWITCHBOT_CLIENT_VERSION`. An older client sends `1215955205` only and gets no GC_SWITCHBOT packet. It can't fill the window either. (The non-EU branch sends `mt20261016`.)
|
||||
|
||||
## Verification
|
||||
|
||||
- `tests/features/test_switchbot.py` compiles the production header against stubs of the UseItem/ChatPacket contract. It covers the allowed list (proto exclusion, set filter, level cap, addon), validation, two alternatives, the already-matched start, quiet INFO, limit, `no_scroll`, `rejected` (INFO resent once), `item_gone`, `busy`, stop/status/idle and silent erase on a VID change.
|
||||
- `tests/features/test_queries.py` was updated for cap mask 127.
|
||||
- FreeBSD build of the whole game target on 203 in `/root/metin2-features-dev` (BINDIR=GAMEDIR=`/root/metin2-features-dev/bin`), log `/root/metin2-features-dev/switchbot-build.log`, with no warnings from the new code. The live `/usr/metin2` binary was not replaced and no service was restarted.
|
||||
- Live test on 2026-10-15. 203 ran an extra core (`/usr/metin2/server/channel5/first`: CHANNEL 5, PORT 13040, P2P 14040, MAP_ALLOW 1 21 41) with its `game` symlinked to the isolated binary. The macOS native client (`--live-server 192.168.21.203:11000:13040`) drove [SA]Admin, sword 279, scroll 71084:
|
||||
- `attrs` returned 14 rows for the sword (18 for armor 12019), received complete.
|
||||
- limit 10 → `limit` after 10 rolls. State lines arrived about every 0.24 s (about 4 rolls/s); the scroll count fell 200 → 190.
|
||||
- Two alternatives with minimum 1 → `matched` after 18 rolls.
|
||||
- Start on an item that already matches → `matched` with 0 rolls and no scroll used.
|
||||
- Moving the item 33 → 90 mid-run → the run continued, the state line reported cell 90, and `stop` → `stopped`.
|
||||
- Client exit mid-run (8 rolls) → `log.log` stopped at the exit second. The CHANGE_ATTRIBUTE row count (72 = 10+18+12+12+12+8) stayed the same 20 s later.
|
||||
- Opening a private shop mid-run → `busy` about 1 s after the shop opened (6 rolls). The character needs a shop bundle (50200 or 71049); without one `OpenMyShop` returns before setting `m_pkMyShop`, so no shop opens and the bot correctly keeps rolling.
|
||||
- 76014 with 6 scrolls and limit 10 → `no_scroll` after 6 rolls.
|
||||
- 71151 on the level-90 sword (the original path allows limit level <= 40) → `rejected` with 0 rolls and the scroll kept.
|
||||
- Every roll wrote one `CHANGE_ATTRIBUTE` row. The core's syserr shows no new errors; the `new_quest_lv52` LUA_ERROR also appears on the live cores.
|
||||
- Live acceptance on CH1 (13000) after the deploy, sword 279 and scroll 71084:
|
||||
- two alternatives with minimum 1 → `matched` after 2 rolls;
|
||||
- three attributes at the maximum with limit 10 → `limit` after 10 rolls, scrolls 157 → 147;
|
||||
- `stop` after 1 s → `stopped` after 4 rolls.
|
||||
- Not done yet: Android device validation.
|
||||
- `tests/features/test_switchbot.py` checks:
|
||||
- the window enum, headers, subheaders, struct fields and sizes, on both the server and the client;
|
||||
- the window hooks, the P2P hand-over, the boot ALTER and the switcher choice;
|
||||
- the version gate;
|
||||
- that `/mt_switchbot` is gone.
|
||||
- Client: `metin2-client/tests/wiki/test_switchbot.py` checks that the window script is AVA2 `uiswitchbot.py` verbatim, plus its glue.
|
||||
- Live-tested on 203 on 2026-10-16 with the Mac client and a script driver. Weapons ran on channel5 against the live db. Rings and talismans ran on the isolated sbtest cluster (`metin2-client/tools/server/sbtest`), which has the unlocked protos. Results:
|
||||
- Move in, drag back, start/stop, auto-finish on target, refusal to move out while active, refusal of an invalid item; about 12 rolls/s, ItemLog matches the switchers consumed.
|
||||
- Rings roll from the ring pool with 71084; talismans roll from the talisman pool with 71302 only.
|
||||
- Relog keeps the items (from the db cache, and from MySQL after a restart). The bot stops and the targets are cleared, as in AVA2 (`UnregisterItem` on logout).
|
||||
- Same-core map change (1 → 21 → 1) keeps rolling with the targets kept; it only pauses during the warp.
|
||||
- Cross-core map hand-over was not tested in that initial run; see the later dual-core acceptance below.
|
||||
- The initial 2026-10-16 deployment note is superseded: on 2026-10-17 the live binary was confirmed to contain CSwitchbotManager/switchbot_end and the SWITCHBOT DB window. This does not deploy the later sbtest changes or prove live cross-channel operation.
|
||||
|
||||
## Production deployment
|
||||
## 2026-10-18 补充验收
|
||||
|
||||
- 2026-10-15 14:51, approved by the user. The 203 live cores now run main `3b7e158` (`game` sha256 `0d798ec0…`, the binary the channel-5 core was tested with). The db binary is unchanged. Live `/usr/metin2/src` was at `4577d86`, so the deploy also shipped `1a36719` (query protocol and calendar drop gates; the gates stay inert without `port_events.tsv`).
|
||||
- Package `/root/deploy-features/20261015-features` (`deploy.sh check|go|rollback`, `SHA256SUMS`). The previous `game`/`db` are in `/root/backup-bin/20261015-145122` (recorded in `LAST_BACKUP`), and the replaced `/usr/metin2/src` files are in `src-before/`. `sh deploy.sh rollback` restores both.
|
||||
- The first `go` stopped at `rebuild.sh stop_server` ("server still running" after about 38 s, cores still exiting) before any backup or copy; the second `go` succeeded. `start.sh` was answered with `1`, which starts only CH1 and game99, so CH2–CH4 were started afterwards with each `run.sh` in the `start.sh` order. The channel-5 test core was restarted too, giving the pre-deploy layout of 14 cores plus db and auth. The new syserr entries contain only the existing `new_quest_lv52` LUA_ERROR (present since 2026-09-21).
|
||||
独立 sbtest 的 QA1017,武器起初无类型9;所有备选均只设释放速度9≥1。未手动停止,实际消耗13个71084后,最终含 (9,10),active=0、finished=1,约1.315秒。客户端证据 switchbot-cast-natural.json。跨频道换线仍未验收,不能将本项扩大解释为全部洗练场景通过。
|
||||
|
||||
## Open items
|
||||
## 双核心地图传送验收
|
||||
|
||||
- Attribute lock: done separately in `FEATURE-ATTR-LOCK.md` (table `mt_item_attr_lock`, applied inside `CItem::ChangeAttribute`, so every bot roll keeps the locked slots). The bot's own item cannot be locked or unlocked while it rolls.
|
||||
- In 203 `player.item_proto`, 71084, 71151, 76014, 76023 and 39028 are USE/USE_CHANGE_ATTRIBUTE (subtype 18); 71302 (the AVA2 talisman scroll) does not exist. The bot accepts any `USE_CHANGE_ATTRIBUTE` scroll and leaves item rules to the original path.
|
||||
2026-10-18:临时测试核心13040/P2P14040载入地图1/62,独立13041/P2P14041载入地图61,均为频道5、仅连接db15040。原生追踪传送1→61→62,两次跨核心日志确认;两边均 active=1、两个备选目标相同,第4条锁定属性 (4,6) 不变,71084总数2069→1811→1595。已停止洗练、退回物品并解锁。
|
||||
|
||||
验收后恢复 channel5/first 原CONFIG(逐字节核对),关闭辅助核心并重启sbtest,QA1017离线位置恢复主城。生产game仍为40335e41…,正式服配置未改。日志和配置备份在 /root/deploy-features/20261018-ava2-parity/crosscore;不向版本库提交CONFIG或凭据。
|
||||
|
||||
此项仅验证同频道跨核心地图传送。该次测试时客户端换线仍使用退出重登;后续原生跨频道验收见下节。
|
||||
|
||||
## 原生跨频道续洗验收
|
||||
|
||||
2026-10-18,sbtest临时频道5:13040和频道6:13050均仅加载地图1。按 AVA2 启用的 do_cmd→MoveChannel、MoveChannelDialog 完成5→6→5,无额外人工查询辅助,active全程为1、两套目标表相同,第4条锁定属性 (4,6) 保持,71084总数1034→976→919。往返后主动停止,武器返回背包159格并解锁,数据库锁表记录为0。
|
||||
|
||||
同频道、未开放频道、倒计时取消和任务选择中拒绝均通过;另测换到6后退出重登仍在6/auth11040,回5后关闭辅助核心,列表只剩5且拒绝旧目标6。详见 FEATURE-AVA2-NATIVE-CHANNEL.md。恢复两个原CONFIG并关闭辅助核心,sbtest已重启;正式服game仍40335e41…,本轮换线没有正式部署,Android真机按用户要求暂停。
|
||||
|
||||
2026-10-18 后续:聊天链接和活动洗练槽已补锁定快照并通过sbtest联机验证;见 `FEATURE-ATTR-LOCK-SNAPSHOTS.md`。经典七属性封包保持不变,正式服部署与Android真机验收仍待做。
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
# PORT VIP card
|
||||
|
||||
A card extends all seven original premium services of the account. 40250 has the services but no in-game way to grant them. Source: `src/server/game/src/port_premium.h`, the hook in `CHARACTER::UseItem` (char_item.cpp), the enter-game refresh in input_login.cpp, `CHARACTER::PortSetPremiumTime` (char.h) and `/mt_vip` (cmd_general.cpp, cmd.cpp). Item data (size, flags, names, shop): metin2-client `tools/server/vip-card`.
|
||||
|
||||
## Services
|
||||
|
||||
`account.account` holds one end time per service. The game keeps them in `m_aiPremiumTimes` and shows affect `AFFECT_PREMIUM_START + i` (500..506) as the icon.
|
||||
|
||||
| i | Premium | Column | Effect on newcibn |
|
||||
|---|---|---|---|
|
||||
| 0 | `PREMIUM_EXP` | `silver_expire` | monster exp ×1.2 × `mob_exp_buyer`/100 (char_battle.cpp) |
|
||||
| 1 | `PREMIUM_ITEM` | `gold_expire` | item drop rate |
|
||||
| 2 | `PREMIUM_SAFEBOX` | `safebox_expire` | safebox size 3 (input_db.cpp) |
|
||||
| 3 | `PREMIUM_AUTOLOOT` | `autoloot_expire` | gold goes straight to the bag (char_battle.cpp) |
|
||||
| 4 | `PREMIUM_FISH_MIND` | `fish_mind_expire` | fishing |
|
||||
| 5 | `PREMIUM_MARRIAGE_FAST` | `marriage_fast_expire` | marriage love points |
|
||||
| 6 | `PREMIUM_GOLD` | `money_drop_rate_expire` | gold drop rate |
|
||||
|
||||
## Cards
|
||||
|
||||
| Vnum | Days |
|
||||
|---|---|
|
||||
| 38001 | 7 |
|
||||
| 38002 | 30 |
|
||||
|
||||
Both are unused `ITEM_NONE` rows in 40250. `PortVipUseCard` runs in `UseItem` after the sex check, before any type handling, so the item type does not matter.
|
||||
|
||||
When a card is used:
|
||||
|
||||
1. The card is refused, and not consumed, in two cases:
|
||||
- the player used a card or `/mt_vip` less than 1 s ago (`rate`);
|
||||
- for any service, the remaining time plus the card would exceed 400 days (`full`). The `int` end times stay far below 2038.
|
||||
2. Otherwise one card is consumed, with an `MT_VIP_CARD` item log whose hint is the number of days.
|
||||
3. One `UPDATE` moves every column to `GREATEST(UNIX_TIMESTAMP(col), UNIX_TIMESTAMP()) + days × 86400`. A service that has expired restarts from now; a running one is extended.
|
||||
|
||||
## Freshness
|
||||
|
||||
Auth reads the columns only at login and passes them to the db core's `CLoginData`. Every later player load, such as a warp or a core change, fills `TPlayerTable.aiPremiumTimes` from that login-time copy. So after a card, and on every enter-game, the game reads the row itself.
|
||||
|
||||
`PortVipRefresh` handles this:
|
||||
- It queues `SELECT UNIX_TIMESTAMP(col)... FROM account.account WHERE id=` through `DBManager::FuncQuery`. That is the same ordered queue and connection as the card's `UPDATE`, so the read sees the update.
|
||||
- The answer finds the player again by PID and checks the account ID; if the player has left, nothing happens.
|
||||
- For each service whose end changed, it sets `m_aiPremiumTimes[i]`, then either adds the affect with the remaining duration or removes it if the service has expired.
|
||||
- It logs `PORT_VIP: <name> type <i> end <unix>`.
|
||||
|
||||
The db core is not changed.
|
||||
|
||||
## Protocol
|
||||
|
||||
```
|
||||
/mt_vip 1 status ask for the remaining time
|
||||
MTVIP1 times R0 R1 R2 R3 R4 R5 R6 remaining seconds per service (0 = none), PREMIUM_EXP .. PREMIUM_GOLD
|
||||
MTVIP1 added VNUM DAYS a card was consumed; a times line follows once the row is read back
|
||||
MTVIP1 error CODE rate full invalid
|
||||
```
|
||||
|
||||
- `status` and card use share the 1 s throttle per player.
|
||||
- A wrong version, or more than three tokens, gets no answer; an old client never sends one.
|
||||
- The client (metin2-client `src/platform/ScriptLib/VipScript.inc`, module `mt_vip`) treats a `status` with no answer within 3 s as a server without the feature.
|
||||
|
||||
## Exp bonus
|
||||
|
||||
On newcibn the premium exp branch multiplies by 1.2 and then by `GetMobExpRate`, which returns event flag `mob_exp_buyer` (default 100). `/e mob_exp_buyer 167` gives 1.2 × 1.67 ≈ 2.0, that is +100 %. Event flags live in `player.quest` (pid 0) and every core shares them, so the flag is set once, by a GM, at deploy.
|
||||
|
||||
## Verification
|
||||
|
||||
- `tests/features/test_vip.py` checks the wiring:
|
||||
- the command entry is at the end of `cmd_info`;
|
||||
- the include is outside the `__AUCTION__` block;
|
||||
- the hook sits between the sex check and the summon-item block;
|
||||
- the refresh runs after the login affect loop.
|
||||
- It also compiles the production header against a stub account table, the ordered SQL queue and the affects. It covers:
|
||||
- a 7-day card, the read-back and the icons;
|
||||
- the gap refusal, then a 30-day card stacked onto the current end;
|
||||
- the 400-day cap: no card consumed, no query;
|
||||
- other items left untouched;
|
||||
- the enter-game refresh over stale values;
|
||||
- a service expired by hand, and the `status` command;
|
||||
- a player who leaves before the answer, and a missing account row.
|
||||
- Live test, channel5 (2026-10-15), Admin account with all expire values reset to 0:
|
||||
- 38002 (30 days) set all seven columns to now + 30 days, added affects 500..506 and returned `times 2592000…`.
|
||||
- Two 38001 used through the inventory right-click, 2 s apart, extended to 44 days.
|
||||
- A same-map `/warp` reloaded the player with the login-time 30 days. The refresh logged the seven `PORT_VIP` corrections to 44 days, and the panel showed "剩余 43 天 23 小时" for every service.
|
||||
- Earlier, with premium, autoloot gold went straight to the bag; without it, the gold stayed on the ground.
|
||||
|
||||
## Production deployment
|
||||
|
||||
- Deployed 2026-10-16 (server clock 2026-10-15 20:44) with the user's approval, 0 players online. Server main 69e335b, which includes the `/m` command-prefix fix 3590a06. Game sha256 `8d0bf9f0…` (the channel-5 tested binary); db unchanged.
|
||||
- Package: `/root/deploy-features/20261016-vip` (metin2-client `tools/server` at main 32372c2a).
|
||||
- Binary backup: `/root/backup-bin/20261015-204352`.
|
||||
- Rollback: `sh /root/deploy-features/20261016-vip/deploy.sh rollback`. The data backups are in `/root/backup-vip-card/20261015-204353` and `/root/backup-npcshop/item_mall-20261015-204353`.
|
||||
- `/usr/metin2/src` was synced with the six changed files.
|
||||
- `deploy.sh go` stops every core, then installs the game. It runs `vip-card/install.sh` and the item-mall shop install while the db core is down, since db reads `item_proto.txt` at boot. Then it starts db alone, waits for port 15000, and starts auth, CH1–CH4, game99 and channel5: 14 game, 1 db, 1 auth.
|
||||
- At boot the db core rewrites `player.item_proto` from the txt, with `locale_name` `Noname` for every item; names come from `item_names.txt`. Both cards: size 1, flag 8196, antiflag 256.
|
||||
- `/e mob_exp_buyer 167` was set from CH1. Every core logged `QUEST eventflag mob_exp_buyer 167`, and the row is in `player.quest` (pid 0).
|
||||
- CH1 (13000) acceptance:
|
||||
- `/m 101` spawned and `/purge` removed it.
|
||||
- 9010 (map a1) lists 38001/38002. A buyer from another empire pays the original triple price (shop.cpp), 15 000 000 for a 7-day card.
|
||||
- Two 38001 bought: each takes one cell (a shop buy never merges), and dragging one onto the other gives a stack of 2.
|
||||
- Using one: `added 38001 7`, then `times 4400055…`. The panel shows 50 days 22 hours for all seven services.
|
||||
- syserr only has the pre-existing `new_quest_lv52` LUA_ERROR.
|
||||
@@ -33,6 +33,21 @@ public:
|
||||
|
||||
/// 발렌타인 사랑의 팬던트
|
||||
static const bool IsLovePendant(DWORD vnum) { return 71145 == vnum; }
|
||||
|
||||
#if defined(ENABLE_ATTR_6TH_7TH) || defined(__BL_67_ATTR__)
|
||||
static DWORD Get67MaterialVnum(const int iLevelLimit)
|
||||
{
|
||||
if (iLevelLimit >= 0 && iLevelLimit <= 45)
|
||||
return 39070;
|
||||
if (iLevelLimit >= 46 && iLevelLimit <= 75)
|
||||
return 39071;
|
||||
if (iLevelLimit >= 76 && iLevelLimit <= 105)
|
||||
return 39072;
|
||||
if (iLevelLimit >= 106 && iLevelLimit <= 120)
|
||||
return 39073;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class CMobVnumHelper
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#pragma pack(push,1)
|
||||
struct Ava2ShopRequest {
|
||||
uint8_t operation; uint32_t account,player,product,count,expectedVnum; int64_t expectedTotal; char token[33],name[25],ip[16];
|
||||
};
|
||||
struct Ava2ShopReply { uint32_t account,player,size; };
|
||||
struct Ava2ShopProduct {
|
||||
uint32_t id,vnum; int64_t price; int32_t top; uint8_t discount;
|
||||
int32_t expiry,added; int64_t sold; int32_t weekly,monthly,stock;
|
||||
};
|
||||
struct Ava2ShopLog {
|
||||
uint32_t account; char name[25],date[21]; int32_t time; char ip[16];
|
||||
uint32_t product,vnum; int32_t count; int64_t price;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(Ava2ShopRequest)==103,"itemshop request");
|
||||
static_assert(sizeof(Ava2ShopProduct)==49,"native TIShopData");
|
||||
static_assert(sizeof(Ava2ShopLog)==90,"native TIShopLogData");
|
||||
|
||||
inline bool Ava2ShopTotal(int64_t unit,uint32_t count,uint8_t discount,int64_t& total) {
|
||||
if(unit<0 || unit>1000000000000LL || count<1 || count>20 || discount>100)return false;
|
||||
total=unit*int64_t(count)*(100-discount)/100;return true;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
// Internal game/db protocol only. No client-supplied identity or price is trusted.
|
||||
namespace PortEconomy {
|
||||
constexpr uint8_t Header = 77;
|
||||
enum Operation : uint8_t { List=1, Buy, Refund, Claim, Cancel, Withdraw, GayaBuy, GayaRefresh, GayaExpand, Status, GayaRetire, UiStatus };
|
||||
// Reserved terminal generation: preserve the catalogue as an audit tombstone.
|
||||
constexpr uint64_t RetiredGeneration=INT64_MAX;
|
||||
constexpr int64_t GoldLimit=2000000000000000LL;
|
||||
#pragma pack(push,1)
|
||||
struct Offer { uint32_t vnum=0,count=0;int32_t price=0;uint8_t bought=0; };
|
||||
#pragma pack(pop)
|
||||
struct Reward {
|
||||
uint32_t id=0,vnum=0,count=0;
|
||||
int32_t sockets[3]={};uint8_t types[7]={};int16_t values[7]={};uint8_t extra[69]={};
|
||||
};
|
||||
struct Request {
|
||||
uint32_t version=1,account=0,player=0;
|
||||
uint8_t operation=0;
|
||||
char token[33]={};
|
||||
alignas(8) uint64_t reference=0;
|
||||
alignas(8) int64_t price=0;
|
||||
alignas(8) int64_t expectedGold=0;
|
||||
int32_t expectedGem=0,expectedOpen=0,deadline=0,nextDeadline=0;
|
||||
uint32_t item=0,itemVnum=0,itemCount=0;
|
||||
alignas(8) uint64_t generation=0;
|
||||
uint8_t slot=0,rewardCount=0;
|
||||
Offer offers[27],nextOffers[27];
|
||||
Reward rewards[10];
|
||||
Request() { std::memset(this,0,sizeof(*this));version=1; }
|
||||
};
|
||||
struct Reply { uint32_t account,player;uint8_t ok;char message[240]; };
|
||||
static_assert(sizeof(Offer)==13 && sizeof(Reward)==116,"stable item/offer records");
|
||||
static_assert(sizeof(Request)==1976 && sizeof(Reply)==252,"stable internal request/reply layout");
|
||||
static_assert(sizeof(Request)<8192,"bounded durable request");
|
||||
inline bool Token(const char* s) {
|
||||
if(s[32])return false;
|
||||
for(unsigned i=0;i<32;++i)if(!((s[i]>='0'&&s[i]<='9')||(s[i]>='a'&&s[i]<='f')))return false;
|
||||
return true;
|
||||
}
|
||||
inline bool Offers(const Offer* offers) {
|
||||
for(unsigned i=0;i<27;++i) {
|
||||
const auto& o=offers[i];
|
||||
if(!o.vnum || !o.count || o.count>2000 || o.price<1 || o.price>1000000 || o.bought>1)return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
inline bool Valid(const Request& r) {
|
||||
if(r.version!=1 || !r.player || !r.account || !Token(r.token) || r.operation<List || r.operation>UiStatus ||
|
||||
r.expectedGold<0 || r.expectedGold>GoldLimit || r.expectedGem<0 || r.expectedGem>1000000 ||
|
||||
r.expectedOpen<0 || r.expectedOpen>18 || r.rewardCount>10)return false;
|
||||
if(r.operation==UiStatus && (r.reference>1000000 || r.slot>2 || !r.generation || r.generation>UINT32_MAX))return false;
|
||||
if(r.operation==Status && r.reference>1000000)return false;
|
||||
if(r.operation!=GayaBuy && r.rewardCount)return false;
|
||||
if(r.operation==List && (!r.item || !r.itemVnum || !r.itemCount || r.price<1 || r.price>GoldLimit))return false;
|
||||
if((r.operation==Buy || r.operation==Refund || r.operation==Claim || r.operation==Cancel) && !r.reference)return false;
|
||||
if(r.operation==GayaBuy && (r.slot>=27 || !Offers(r.offers) || !r.rewardCount))return false;
|
||||
if(r.operation==GayaRefresh && (!Offers(r.nextOffers) || r.nextDeadline<=0 || (r.item && !r.itemCount)))return false;
|
||||
if(r.operation==GayaExpand && (!r.item || !r.itemCount || r.expectedOpen>=18))return false;
|
||||
for(unsigned i=0;i<r.rewardCount;++i) {
|
||||
if(!r.rewards[i].id || !r.rewards[i].vnum || !r.rewards[i].count || r.rewards[i].count>2000)return false;
|
||||
for(unsigned j=0;j<i;++j)if(r.rewards[j].id==r.rewards[i].id)return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
inline std::string Hex(const void* data,size_t size) {
|
||||
const auto* p=static_cast<const unsigned char*>(data);static const char hex[]="0123456789abcdef";
|
||||
std::string out;out.reserve(size*2);
|
||||
for(size_t i=0;i<size;++i){out+=hex[p[i]>>4];out+=hex[p[i]&15];}return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
#include "economy_store.h"
|
||||
#include <mysql/mysql.h>
|
||||
#include <mysql/errmsg.h>
|
||||
|
||||
namespace PortEconomy {
|
||||
// Use only on the DB main thread's direct connection. Automatic reconnection
|
||||
// remains off for the entire lifetime, including ambiguous COMMIT recovery.
|
||||
class Mysql {
|
||||
MYSQL* connection;
|
||||
bool active=false;
|
||||
bool pinned=false;
|
||||
unsigned previousTimeout=0;
|
||||
unsigned long thread=0;
|
||||
public:
|
||||
uint64_t affected=0,inserted=0;
|
||||
std::function<void(const std::string&)> afterStatement;
|
||||
explicit Mysql(MYSQL* handle):connection(handle) {
|
||||
// Reconnect only BEFORE entering the pinned transaction scope. Without
|
||||
// this step a dead direct handle could keep pending orders retrying
|
||||
// forever when no unrelated legacy query happens to reconnect it.
|
||||
my_bool allowReconnect=true;
|
||||
if(mysql_options(connection,MYSQL_OPT_RECONNECT,&allowReconnect)!=0 || mysql_ping(connection)!=0)return;
|
||||
my_bool reconnect=false;pinned=mysql_options(connection,MYSQL_OPT_RECONNECT,&reconnect)==0;
|
||||
thread=mysql_thread_id(connection);
|
||||
Rows rows;uint64_t value=0;
|
||||
if(Query("SELECT @@session.innodb_lock_wait_timeout",rows)&&rows.size()==1&&Number(rows[0][0],value,UINT32_MAX))previousTimeout=static_cast<unsigned>(value);
|
||||
}
|
||||
~Mysql(){Rollback();if(previousTimeout){Rows rows;Query("SET SESSION innodb_lock_wait_timeout="+std::to_string(previousTimeout),rows);}my_bool reconnect=true;mysql_options(connection,MYSQL_OPT_RECONNECT,&reconnect);}
|
||||
bool Query(const std::string& sql,Rows& rows) {
|
||||
rows.clear();affected=0;inserted=0;
|
||||
if(!pinned || mysql_thread_id(connection)!=thread || mysql_real_query(connection,sql.data(),static_cast<unsigned long>(sql.size())))return false;
|
||||
MYSQL_RES* result=mysql_store_result(connection);
|
||||
if(result) {
|
||||
MYSQL_ROW row;const unsigned fields=mysql_num_fields(result);
|
||||
while((row=mysql_fetch_row(result))) {
|
||||
const unsigned long* lengths=mysql_fetch_lengths(result);std::vector<std::string> values;
|
||||
for(unsigned i=0;i<fields;++i)values.emplace_back(row[i]?std::string(row[i],lengths[i]):std::string());
|
||||
rows.push_back(std::move(values));
|
||||
}
|
||||
const bool ok=mysql_errno(connection)==0;mysql_free_result(result);if(!ok)return false;
|
||||
} else if(mysql_field_count(connection))return false;
|
||||
affected=mysql_affected_rows(connection);inserted=mysql_insert_id(connection);
|
||||
if(afterStatement)afterStatement(sql);
|
||||
return mysql_thread_id(connection)==thread;
|
||||
}
|
||||
bool Begin(){Rows rows;if(active||!previousTimeout||!Query("SET SESSION innodb_lock_wait_timeout=3",rows)||!Query("START TRANSACTION",rows))return false;active=true;return true;}
|
||||
bool Commit(){Rows rows;if(!active||!Query("COMMIT",rows))return false;active=false;return true;}
|
||||
void Rollback(){if(active){Rows rows;Query("ROLLBACK",rows);active=false;}}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
#pragma once
|
||||
#include "economy.h"
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
namespace PortEconomy {
|
||||
using Rows=std::vector<std::vector<std::string>>;
|
||||
inline bool Number(const std::string& s,uint64_t& out,uint64_t max=UINT64_MAX) {
|
||||
if(s.empty())return false;uint64_t n=0;
|
||||
for(char c:s){if(c<'0'||c>'9'||uint64_t(c-'0')>max||n>(max-uint64_t(c-'0'))/10)return false;n=n*10+uint64_t(c-'0');}
|
||||
out=n;return true;
|
||||
}
|
||||
// DB must supply Query(sql, rows), affected and inserted, plus Begin/Commit/Rollback.
|
||||
// This store NEVER runs against an online character or an undrained cache. The
|
||||
// DB coordinator owns that fence; game processes never execute these mutations.
|
||||
template<class DB> class Store {
|
||||
DB& db;
|
||||
std::function<unsigned(uint32_t)> size;
|
||||
std::string outcome;
|
||||
uint64_t reference=0;
|
||||
bool sqlOK=true;
|
||||
static std::string N(uint64_t n){return std::to_string(n);}
|
||||
bool Q(const std::string& sql,Rows& rows){if(!sqlOK)return false;sqlOK=db.Query(sql,rows);return sqlOK;}
|
||||
bool Run(const std::string& sql){Rows rows;return Q(sql,rows);}
|
||||
bool One(const std::string& sql,Rows& rows){return Q(sql,rows)&&rows.size()==1;}
|
||||
bool Change(const std::string& sql){return Run(sql)&&db.affected==1;}
|
||||
bool Reject(const char* why){outcome=why;return false;}
|
||||
bool Quest(uint32_t pid,const char* state,uint64_t& value) {
|
||||
Rows rows;if(!Q("SELECT lValue FROM quest WHERE dwPID="+N(pid)+" AND szName='gem' AND szState='"+state+"' FOR UPDATE",rows))return false;
|
||||
value=0;return rows.empty()||(rows.size()==1&&Number(rows[0][0],value,INT32_MAX));
|
||||
}
|
||||
bool SetQuest(uint32_t pid,const char* state,uint64_t value){
|
||||
return Run("INSERT INTO quest(dwPID,szName,szState,lValue) VALUES("+N(pid)+",'gem','"+state+"',"+N(value)+") ON DUPLICATE KEY UPDATE lValue=VALUES(lValue)");
|
||||
}
|
||||
bool Catalog(const Request& r,Offer* offers,uint64_t& generation,int32_t& deadline) {
|
||||
Rows rows;if(!Q("SELECT generation,deadline,offers FROM port_economy_gaya WHERE pid="+N(r.player)+" FOR UPDATE",rows))return false;
|
||||
if(rows.empty()) {
|
||||
if(r.generation || !Offers(r.offers) || r.deadline<0)return Reject("catalog_changed");
|
||||
std::memcpy(offers,r.offers,sizeof(r.offers));generation=0;deadline=r.deadline;return true;
|
||||
}
|
||||
uint64_t time=0;
|
||||
if(rows.size()!=1 || !Number(rows[0][0],generation) || !Number(rows[0][1],time,INT32_MAX) || rows[0][2].size()!=sizeof(r.offers))return Reject("catalog_corrupt");
|
||||
std::memcpy(offers,rows[0][2].data(),sizeof(r.offers));deadline=static_cast<int32_t>(time);
|
||||
if(!Offers(offers) || generation!=r.generation || deadline!=r.deadline || std::memcmp(offers,r.offers,sizeof(r.offers)))return Reject("catalog_changed");
|
||||
return true;
|
||||
}
|
||||
bool SaveCatalog(uint32_t pid,const Offer* offers,uint64_t generation,int32_t deadline) {
|
||||
if(generation>=RetiredGeneration-1 || !Offers(offers) || deadline<0)return Reject("catalog_corrupt");
|
||||
return Run("INSERT INTO port_economy_gaya(pid,generation,deadline,offers) VALUES("+N(pid)+","+N(generation+1)+","+N(static_cast<uint32_t>(deadline))+",X'"+Hex(offers,27*sizeof(Offer))+"') ON DUPLICATE KEY UPDATE generation=VALUES(generation),deadline=VALUES(deadline),offers=VALUES(offers)");
|
||||
}
|
||||
// Mall uses a 5x9 grid per page, three pages. Retain original item IDs and
|
||||
// every stored item column. Unknown sizes and malformed grids fail closed.
|
||||
bool MallCell(uint32_t account,uint32_t vnum,unsigned& cell) {
|
||||
const unsigned height=size(vnum);if(height<1 || height>3)return Reject("item_proto");
|
||||
std::array<bool,135> used={};Rows rows;
|
||||
if(!Q("SELECT pos,vnum FROM item WHERE owner_id="+N(account)+" AND window='MALL' FOR UPDATE",rows))return false;
|
||||
for(const auto& row:rows) {
|
||||
uint64_t pos=0,id=0;if(!Number(row[0],pos,134)||!Number(row[1],id,UINT32_MAX))return Reject("mall_corrupt");
|
||||
const unsigned h=size(static_cast<uint32_t>(id));if(h<1 || h>3 || (pos%45)/5+h>9)return Reject("mall_corrupt");
|
||||
for(unsigned j=0;j<h;++j){const size_t at=static_cast<size_t>(pos)+5*j;if(used[at])return Reject("mall_corrupt");used[at]=true;}
|
||||
}
|
||||
for(unsigned pos=0;pos<135;++pos) {
|
||||
if((pos%45)/5+height>9)continue;bool free=true;
|
||||
for(unsigned j=0;j<height;++j)if(used[pos+5*j])free=false;
|
||||
if(free){cell=pos;return true;}
|
||||
}
|
||||
return Reject("mall_full");
|
||||
}
|
||||
bool Deliver(uint32_t item,uint32_t account,uint32_t vnum) {
|
||||
unsigned cell=0;if(!MallCell(account,vnum,cell))return false;
|
||||
// Copy all columns by ordinal: readiness checks exact custody/item schema.
|
||||
if(!Change("INSERT INTO item SELECT * FROM port_economy_custody WHERE id="+N(item)))return false;
|
||||
return Change("UPDATE item SET owner_id="+N(account)+",window='MALL',pos="+N(cell)+" WHERE id="+N(item))&&
|
||||
Change("DELETE FROM port_economy_custody WHERE id="+N(item));
|
||||
}
|
||||
bool Consume(const Request& r,uint32_t vnum) {
|
||||
Rows rows;uint64_t count=0;
|
||||
if(!One("SELECT count FROM item WHERE id="+N(r.item)+" AND owner_id="+N(r.player)+" AND window='INVENTORY' AND pos<225 AND vnum="+N(vnum)+" FOR UPDATE",rows)||!Number(rows[0][0],count,2000)||!count||count!=r.itemCount)return Reject("consumable_changed");
|
||||
if(count==1)return Change("DELETE FROM item WHERE id="+N(r.item));
|
||||
return Change("UPDATE item SET count=count-1 WHERE id="+N(r.item));
|
||||
}
|
||||
bool Apply(const Request& r,uint64_t gold) {
|
||||
const std::string pid=N(r.player),aid=N(r.account);
|
||||
Rows rows;uint64_t a=0,b=0,c=0,d=0;
|
||||
switch(r.operation) {
|
||||
case List:
|
||||
if(!One("SELECT id FROM item WHERE id="+N(r.item)+" AND owner_id="+pid+" AND window='INVENTORY' AND vnum="+N(r.itemVnum)+" AND count="+N(r.itemCount)+" AND pos<225 FOR UPDATE",rows))return Reject("item_changed");
|
||||
if(!Change("INSERT INTO port_economy_custody SELECT * FROM item WHERE id="+N(r.item))||!Change("DELETE FROM item WHERE id="+N(r.item)))return false;
|
||||
if(!Change("INSERT INTO port_economy_listings(owner,account,item,price,state) VALUES("+pid+","+aid+","+N(r.item)+","+N(static_cast<uint64_t>(r.price))+",'OPEN')"))return false;
|
||||
reference=db.inserted;return reference!=0;
|
||||
case Buy:
|
||||
if(!One("SELECT owner,item,price,state FROM port_economy_listings WHERE id="+N(r.reference)+" FOR UPDATE",rows)||
|
||||
!Number(rows[0][0],a,UINT32_MAX)||!Number(rows[0][1],b,UINT32_MAX)||!Number(rows[0][2],c,GoldLimit)||rows[0][3]!="OPEN"||a==r.player||!c||c>gold||r.price!=static_cast<int64_t>(c))return Reject("listing_changed");
|
||||
if(!Change("UPDATE player SET gold=gold-"+N(c)+" WHERE id="+pid+" AND gold>="+N(c))||
|
||||
!Change("INSERT INTO port_economy_orders(request,listing,buyer,account,price,state) VALUES('"+std::string(r.token)+"',"+N(r.reference)+","+pid+","+aid+","+N(c)+",'READY')"))return false;
|
||||
reference=db.inserted;
|
||||
return Change("UPDATE port_economy_listings SET state='RESERVED',active_order="+N(reference)+" WHERE id="+N(r.reference));
|
||||
case Refund: case Claim:
|
||||
if(!One("SELECT listing,price,state FROM port_economy_orders WHERE id="+N(r.reference)+" AND buyer="+pid+" AND account="+aid+" FOR UPDATE",rows)||
|
||||
!Number(rows[0][0],a)||!Number(rows[0][1],b,GoldLimit))return Reject("order_missing");
|
||||
if(rows[0][2]==(r.operation==Claim?"CLAIMED":"REFUNDED")){reference=r.reference;return true;}
|
||||
if(rows[0][2]!="READY")return Reject("order_terminal");
|
||||
if(!One("SELECT owner,item,active_order FROM port_economy_listings WHERE id="+N(a)+" AND state='RESERVED' FOR UPDATE",rows)||
|
||||
!Number(rows[0][0],c,UINT32_MAX)||!Number(rows[0][1],d,UINT32_MAX)||rows[0][2]!=N(r.reference))return Reject("custody_changed");
|
||||
if(r.operation==Refund) {
|
||||
if(gold>uint64_t(GoldLimit)-b)return Reject("gold_limit");
|
||||
if(!Change("UPDATE player SET gold=gold+"+N(b)+" WHERE id="+pid)||!Change("UPDATE port_economy_listings SET state='OPEN',active_order=0 WHERE id="+N(a)))return false;
|
||||
} else {
|
||||
if(!One("SELECT vnum FROM port_economy_custody WHERE id="+N(d)+" FOR UPDATE",rows))return Reject("custody_missing");
|
||||
uint64_t vnum=0;if(!Number(rows[0][0],vnum,UINT32_MAX)||!Deliver(static_cast<uint32_t>(d),r.account,static_cast<uint32_t>(vnum)))return false;
|
||||
if(!Run("INSERT INTO port_economy_credit(pid,amount) VALUES("+N(c)+",0) ON DUPLICATE KEY UPDATE pid=VALUES(pid)")||
|
||||
!One("SELECT amount FROM port_economy_credit WHERE pid="+N(c)+" FOR UPDATE",rows)||!Number(rows[0][0],c,GoldLimit)||c>uint64_t(GoldLimit)-b)return Reject("seller_credit_limit");
|
||||
// Owner was decoded above; use the immutable listing relationship.
|
||||
if(!Change("UPDATE port_economy_credit SET amount=amount+"+N(b)+" WHERE pid=(SELECT owner FROM port_economy_listings WHERE id="+N(a)+")")||
|
||||
!Change("UPDATE port_economy_listings SET state='SOLD' WHERE id="+N(a)))return false;
|
||||
}
|
||||
reference=r.reference;
|
||||
return Change("UPDATE port_economy_orders SET state='"+std::string(r.operation==Claim?"CLAIMED":"REFUNDED")+"' WHERE id="+N(r.reference));
|
||||
case Cancel:
|
||||
if(!One("SELECT item FROM port_economy_listings WHERE id="+N(r.reference)+" AND owner="+pid+" AND state='OPEN' FOR UPDATE",rows)||!Number(rows[0][0],a,UINT32_MAX))return Reject("listing_changed");
|
||||
if(!One("SELECT vnum FROM port_economy_custody WHERE id="+N(a)+" FOR UPDATE",rows)||!Number(rows[0][0],b,UINT32_MAX)||!Deliver(static_cast<uint32_t>(a),r.account,static_cast<uint32_t>(b)))return false;
|
||||
reference=r.reference;return Change("UPDATE port_economy_listings SET state='CANCELLED' WHERE id="+N(r.reference));
|
||||
case Withdraw:
|
||||
if(!One("SELECT amount FROM port_economy_credit WHERE pid="+pid+" FOR UPDATE",rows)||!Number(rows[0][0],a,GoldLimit)||!a)return Reject("no_credit");
|
||||
if(gold>uint64_t(GoldLimit)-a)return Reject("gold_limit");
|
||||
return Change("UPDATE player SET gold=gold+"+N(a)+" WHERE id="+pid)&&Change("UPDATE port_economy_credit SET amount=0 WHERE pid="+pid);
|
||||
case GayaRetire: {
|
||||
// Explicit retirement never destroys a positive wallet, custody,
|
||||
// refundable order or seller credit. Keep offers/deadline for audit.
|
||||
if(!Quest(r.player,"points",a)||!Quest(r.player,"open_slot",b)||
|
||||
a!=static_cast<uint64_t>(r.expectedGem)||b!=static_cast<uint64_t>(r.expectedOpen))return Reject("wallet_changed");
|
||||
if(a)return Reject("gaya_balance_remaining");
|
||||
if(!One("SELECT (EXISTS(SELECT 1 FROM port_economy_listings WHERE owner="+pid+" AND state IN('OPEN','RESERVED')))+(EXISTS(SELECT 1 FROM port_economy_orders WHERE buyer="+pid+" AND state='READY'))+(EXISTS(SELECT 1 FROM port_economy_credit WHERE pid="+pid+" AND amount<>0))",rows)||rows[0][0]!="0")return Reject("assets_remaining");
|
||||
if(!One("SELECT generation,deadline,offers FROM port_economy_gaya WHERE pid="+pid+" FOR UPDATE",rows)||
|
||||
!Number(rows[0][0],c,RetiredGeneration)||rows[0][2].size()!=sizeof(r.offers))return Reject("catalog_corrupt");
|
||||
Offer retained[27];std::memcpy(retained,rows[0][2].data(),sizeof(retained));
|
||||
if(!Offers(retained))return Reject("catalog_corrupt");
|
||||
reference=c;
|
||||
if(c==RetiredGeneration)return true;
|
||||
return Change("UPDATE port_economy_gaya SET generation="+N(RetiredGeneration)+" WHERE pid="+pid);
|
||||
}
|
||||
case GayaBuy: case GayaRefresh: case GayaExpand: {
|
||||
if(!Q("SELECT generation FROM port_economy_gaya WHERE pid="+pid+" FOR UPDATE",rows))return false;
|
||||
if(!rows.empty()&&(!Number(rows[0][0],a,RetiredGeneration)||a==RetiredGeneration))return Reject("gaya_retired");
|
||||
uint64_t gem=0,open=0,generation=0;int32_t deadline=0;Offer offers[27];
|
||||
if(!Quest(r.player,"points",gem)||!Quest(r.player,"open_slot",open)||gem!=static_cast<uint64_t>(r.expectedGem)||open!=static_cast<uint64_t>(r.expectedOpen))return Reject("wallet_changed");
|
||||
if(r.operation==GayaExpand) {
|
||||
if(open>=18||!Consume(r,39064))return Reject("consumable_changed");
|
||||
return SetQuest(r.player,"open_slot",open+1);
|
||||
}
|
||||
if(!Catalog(r,offers,generation,deadline))return false;
|
||||
if(r.operation==GayaRefresh) {
|
||||
if(r.nextDeadline<deadline || (!r.item && r.nextDeadline==deadline))return Reject("refresh_changed");
|
||||
if(r.item) {if(!Consume(r,39063))return false;}
|
||||
else {if(!One("SELECT UNIX_TIMESTAMP()",rows)||!Number(rows[0][0],a)||uint64_t(deadline)>a)return Reject("refresh_early");}
|
||||
for(const auto& offer:r.nextOffers)if(offer.bought)return Reject("catalog_changed");
|
||||
return SaveCatalog(r.player,r.nextOffers,generation,r.nextDeadline)&&SetQuest(r.player,"left_time",static_cast<uint32_t>(r.nextDeadline));
|
||||
}
|
||||
auto& offer=offers[r.slot];
|
||||
if(offer.bought|| (r.slot>=9 && open<uint64_t(r.slot-8)) || gem<static_cast<uint32_t>(offer.price))return Reject("offer_unavailable");
|
||||
uint64_t total=0;
|
||||
for(unsigned i=0;i<r.rewardCount;++i) {
|
||||
const auto& reward=r.rewards[i];if(reward.vnum!=offer.vnum)return Reject("reward_changed");total+=reward.count;
|
||||
unsigned cell=0;if(!MallCell(r.account,reward.vnum,cell))return false;
|
||||
std::string columns="id,owner_id,window,pos,count,vnum",values=N(reward.id)+","+aid+",'MALL',"+N(cell)+","+N(reward.count)+","+N(reward.vnum);
|
||||
for(unsigned j=0;j<3;++j){columns+=",socket"+N(j);values+=","+std::to_string(reward.sockets[j]);}
|
||||
for(unsigned j=0;j<7;++j){columns+=",attrtype"+N(j)+",attrvalue"+N(j);values+=","+N(reward.types[j])+","+std::to_string(reward.values[j]);}
|
||||
columns+=",port_extra";values+=",X'"+Hex(reward.extra,sizeof(reward.extra))+"'";
|
||||
if(!Change("INSERT INTO item("+columns+") VALUES("+values+")"))return false;
|
||||
}
|
||||
if(total!=offer.count)return Reject("reward_changed");
|
||||
offer.bought=1;
|
||||
return SetQuest(r.player,"points",gem-static_cast<uint32_t>(offer.price))&&SaveCatalog(r.player,offers,generation,deadline);
|
||||
}
|
||||
default:return Reject("invalid_operation");
|
||||
}
|
||||
}
|
||||
public:
|
||||
Store(DB& database,std::function<unsigned(uint32_t)> itemSize):db(database),size(itemSize){}
|
||||
// Readiness is checked on every entry, so a missing/nontransactional table
|
||||
// never silently downgrades a payment to autocommit.
|
||||
bool Ready() {
|
||||
Rows rows;sqlOK=true;
|
||||
if(!One("SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=DATABASE() AND ENGINE='InnoDB' AND TABLE_NAME IN ('player','item','quest','port_economy_custody','port_economy_requests','port_economy_pending','port_economy_listings','port_economy_orders','port_economy_credit','port_economy_gaya','port_economy_version','port_economy_account_lock','port_economy_item_reservations')",rows)||rows[0][0]!="13")return false;
|
||||
if(!One("SELECT version FROM port_economy_version WHERE id=1",rows)||rows[0][0]!="1")return false;
|
||||
Rows item,custody;
|
||||
return Q("SHOW COLUMNS FROM item",item)&&Q("SHOW COLUMNS FROM port_economy_custody",custody)&&item==custody;
|
||||
}
|
||||
bool Enqueue(const Request& r) {
|
||||
if(!Valid(r)||(r.operation==Status||r.operation==UiStatus)||!Ready()||!db.Begin())return false;
|
||||
Rows rows;bool success=false;
|
||||
const std::string token=r.token,body=Hex(&r,sizeof(r));
|
||||
if(Q("SELECT account,pid,body FROM port_economy_requests WHERE token='"+token+"' FOR UPDATE",rows)) {
|
||||
if(!rows.empty())success=rows.size()==1&&rows[0][0]==N(r.account)&&rows[0][1]==N(r.player)&&rows[0][2].size()==sizeof(r)&&!std::memcmp(rows[0][2].data(),&r,sizeof(r));
|
||||
else {
|
||||
success=true;
|
||||
for(unsigned i=0;i<r.rewardCount && success;++i) {
|
||||
Rows existing;
|
||||
success=Q("SELECT id FROM item WHERE id="+N(r.rewards[i].id)+" UNION ALL SELECT id FROM port_economy_custody WHERE id="+N(r.rewards[i].id),existing)&&existing.empty()&&
|
||||
Change("INSERT INTO port_economy_item_reservations(id,request) VALUES("+N(r.rewards[i].id)+",'"+token+"')");
|
||||
}
|
||||
success=success&&Change("INSERT INTO port_economy_pending(pid,token) VALUES("+N(r.player)+",'"+token+"')")&&
|
||||
Change("INSERT INTO port_economy_requests(token,account,pid,body,state,result,reference) VALUES('"+token+"',"+N(r.account)+","+N(r.player)+",X'"+body+"','PENDING','queued',0)");
|
||||
}
|
||||
}
|
||||
if(success&&db.Commit())return true;db.Rollback();return false;
|
||||
}
|
||||
enum Result { Retry, None, Settled };
|
||||
bool Abort(uint32_t pid,uint32_t account) {
|
||||
if(!Ready()||!db.Begin())return false;
|
||||
Rows rows;
|
||||
bool done=One("SELECT r.token FROM port_economy_pending p JOIN port_economy_requests r ON r.token=p.token WHERE p.pid="+N(pid)+" AND r.pid="+N(pid)+" AND r.account="+N(account)+" AND r.state='PENDING' FOR UPDATE",rows)&&
|
||||
Change("UPDATE port_economy_requests SET state='DONE',result='save_failed' WHERE pid="+N(pid)+" AND account="+N(account)+" AND state='PENDING'")&&
|
||||
Run("DELETE FROM port_economy_pending WHERE pid="+N(pid));
|
||||
if(done&&db.Commit())return true;db.Rollback();return false;
|
||||
}
|
||||
Result Settle(uint32_t pid,uint32_t account) {
|
||||
if(!Ready()||!db.Begin())return Retry;
|
||||
Rows rows;Request r;uint64_t gold=0;
|
||||
if(!Q("SELECT token FROM port_economy_pending WHERE pid="+N(pid)+" FOR UPDATE",rows)){db.Rollback();return Retry;}
|
||||
if(rows.empty()){db.Rollback();return None;}
|
||||
const std::string token=rows[0][0];
|
||||
if(!One("SELECT body FROM port_economy_requests WHERE token='"+token+"' AND account="+N(account)+" AND pid="+N(pid)+" AND state='PENDING' FOR UPDATE",rows)||rows[0][0].size()!=sizeof(r)){db.Rollback();return Retry;}
|
||||
std::memcpy(&r,rows[0][0].data(),sizeof(r));
|
||||
if(!Valid(r)||r.player!=pid||r.account!=account||std::string(r.token)!=token){db.Rollback();return Retry;}
|
||||
if(!Run("INSERT INTO port_economy_account_lock(account) VALUES("+N(account)+") ON DUPLICATE KEY UPDATE account=VALUES(account)")||!One("SELECT account FROM port_economy_account_lock WHERE account="+N(account)+" FOR UPDATE",rows)){db.Rollback();return Retry;}
|
||||
if(!One("SELECT gold FROM player WHERE id="+N(pid)+" AND account_id="+N(account)+" FOR UPDATE",rows)||!Number(rows[0][0],gold,GoldLimit)){db.Rollback();return Retry;}
|
||||
// A save lost before logout cannot authorize spending an older snapshot.
|
||||
outcome="ok";reference=0;
|
||||
if(gold!=static_cast<uint64_t>(r.expectedGold))outcome="wallet_changed";
|
||||
else {
|
||||
// Validation failures may happen after tentative writes (e.g. mall
|
||||
// fills midway through a multi-stack reward). Roll back to savepoint.
|
||||
if(!Run("SAVEPOINT economy_operation")){db.Rollback();return Retry;}
|
||||
if(!Apply(r,gold)) {
|
||||
if(!sqlOK){db.Rollback();return Retry;}
|
||||
if(!Run("ROLLBACK TO SAVEPOINT economy_operation")){db.Rollback();return Retry;}
|
||||
if(outcome=="ok")outcome="state_changed";reference=0;
|
||||
}
|
||||
}
|
||||
if(!Change("UPDATE port_economy_requests SET state='DONE',result='"+outcome+"',reference="+N(reference)+" WHERE token='"+token+"'")||
|
||||
!Change("DELETE FROM port_economy_pending WHERE pid="+N(pid))||!db.Commit()){db.Rollback();return Retry;}
|
||||
return Settled;
|
||||
}
|
||||
const std::string& Outcome()const{return outcome;}
|
||||
uint64_t Reference()const{return reference;}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
#include "economy_store.h"
|
||||
|
||||
namespace PortEconomy {
|
||||
// Bounded, ASCII-only presentation over the existing authenticated DB reply.
|
||||
// Build the complete snapshot before emitting any frames. No UI read mutates
|
||||
// wallets, item ownership or order state, and no display slot is an asset ID.
|
||||
constexpr unsigned ViewPageSize=20;
|
||||
inline bool SignedNumber(const std::string& text,int64_t& out,int64_t minimum,int64_t maximum) {
|
||||
const bool negative=!text.empty()&&text[0]=='-';uint64_t value=0;
|
||||
if(!Number(negative?text.substr(1):text,value,negative?static_cast<uint64_t>(-minimum):static_cast<uint64_t>(maximum)))return false;
|
||||
out=negative?-static_cast<int64_t>(value):static_cast<int64_t>(value);return out>=minimum&&out<=maximum;
|
||||
}
|
||||
inline bool HexBytes(const std::string& text,size_t bytes) {
|
||||
if(text.size()!=bytes*2)return false;
|
||||
for(char c:text)if(!((c>='0'&&c<='9')||(c>='a'&&c<='f')||(c>='A'&&c<='F')))return false;
|
||||
return true;
|
||||
}
|
||||
template<class DB> bool View(DB& db,const Request& r,std::function<unsigned(uint32_t)> height,std::vector<std::string>& frames) {
|
||||
frames.clear();Rows rows;if(!Valid(r)||r.operation!=UiStatus)return false;
|
||||
// Transaction-scoped isolation applies to this read only, not later wallet
|
||||
// settlements on the shared direct connection.
|
||||
if(!db.Query("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ",rows)||!db.Begin())return false;
|
||||
auto fail=[&](){db.Rollback();frames.clear();return false;};
|
||||
const auto pid=std::to_string(r.player),aid=std::to_string(r.account),seq=std::to_string(r.generation);
|
||||
if(!db.Query("SELECT amount FROM port_economy_credit WHERE pid="+pid,rows)||rows.size()>1)return fail();
|
||||
uint64_t credit=0;if(!rows.empty()&&!Number(rows[0][0],credit,GoldLimit))return fail();
|
||||
std::string columns="c.vnum,c.count,"+std::string(r.slot==2?"o.state":"l.state")+",c.socket0,c.socket1,c.socket2";
|
||||
for(unsigned i=0;i<7;++i)columns+=",c.attrtype"+std::to_string(i)+",c.attrvalue"+std::to_string(i);
|
||||
columns+=",HEX(c.port_extra)";
|
||||
std::string sql=r.slot==2 ? "SELECT o.id,o.price,l.owner,"+columns+" FROM port_economy_orders o JOIN port_economy_listings l ON l.id=o.listing LEFT JOIN port_economy_custody c ON c.id=l.item WHERE o.buyer="+pid+" AND o.account="+aid+" AND o.state='READY'" :
|
||||
"SELECT l.id,l.price,l.owner,"+columns+" FROM port_economy_listings l LEFT JOIN port_economy_custody c ON c.id=l.item WHERE "+
|
||||
(r.slot==1?"l.owner="+pid+" AND l.state IN('OPEN','RESERVED')":std::string("l.state='OPEN'")+(r.item?" AND l.owner="+std::to_string(r.item):""));
|
||||
sql+=" ORDER BY "+std::string(r.slot==2?"o.id":"l.id")+" DESC LIMIT 21 OFFSET "+std::to_string(r.reference*ViewPageSize);
|
||||
if(!db.Query(sql,rows)||rows.size()>ViewPageSize+1)return fail();
|
||||
const bool more=rows.size()>ViewPageSize;if(more)rows.pop_back();
|
||||
frames.push_back("MTECON1 begin "+seq+" "+std::to_string(r.slot)+" "+std::to_string(r.reference)+" "+std::to_string(rows.size())+" "+std::to_string(more)+" "+std::to_string(credit));
|
||||
for(size_t index=0;index<rows.size();++index) {
|
||||
const auto& row=rows[index];if(row.size()!=24)return fail();
|
||||
uint64_t id=0,price=0,owner=0,vnum=0,count=0;
|
||||
if(!Number(row[0],id)||!id||!Number(row[1],price,GoldLimit)||!price||!Number(row[2],owner,UINT32_MAX)||!owner||
|
||||
!Number(row[3],vnum,UINT32_MAX)||!vnum||!Number(row[4],count,2000)||!count)return fail();
|
||||
unsigned state=row[5]=="OPEN"?0:row[5]=="RESERVED"?1:row[5]=="READY"?2:3;
|
||||
const unsigned size=height(static_cast<uint32_t>(vnum));if(state==3||size<1||size>3)return fail();
|
||||
std::string item="MTECON1 row "+seq+" "+std::to_string(index)+" "+std::to_string(id)+" "+std::to_string(price)+" "+std::to_string(owner)+" "+std::to_string(state)+" "+std::to_string(vnum)+" "+std::to_string(count)+" "+std::to_string(size);
|
||||
for(unsigned i=6;i<9;++i){int64_t socket=0;if(!SignedNumber(row[i],socket,INT32_MIN,INT32_MAX))return fail();item+=" "+std::to_string(socket);}
|
||||
frames.push_back(item);
|
||||
uint8_t attrs[21]={};
|
||||
for(unsigned i=0;i<7;++i){uint64_t type=0;int64_t value=0;
|
||||
if(!Number(row[9+2*i],type,UINT8_MAX)||!SignedNumber(row[10+2*i],value,INT16_MIN,INT16_MAX))return fail();
|
||||
const auto bits=static_cast<uint16_t>(value);attrs[3*i]=static_cast<uint8_t>(type);attrs[3*i+1]=static_cast<uint8_t>(bits&255);attrs[3*i+2]=static_cast<uint8_t>(bits>>8);
|
||||
}
|
||||
std::string extra=row[23];if(extra.empty())extra=std::string(138,'0');if(!HexBytes(extra,69))return fail();
|
||||
frames.push_back("MTECON1 meta "+seq+" "+std::to_string(index)+" "+Hex(attrs,sizeof(attrs))+extra);
|
||||
}
|
||||
// A supplied receipt is scoped to the current account/player. On a fresh
|
||||
// process the latest result is informational; actionable assets come from
|
||||
// the authoritative orders/listings/credit views above.
|
||||
if(!db.Query("SELECT state,result,reference FROM port_economy_requests WHERE pid="+pid+" AND account="+aid+
|
||||
(std::string(r.token)==std::string(32,'0')?" ORDER BY created_at DESC,token DESC LIMIT 1":" AND token='"+std::string(r.token)+"'"),rows)||rows.size()>1)return fail();
|
||||
if(!rows.empty()) {
|
||||
uint64_t reference=0;
|
||||
if(rows[0].size()!=3||!Number(rows[0][2],reference)||rows[0][1].size()>64||(rows[0][0]!="DONE"&&rows[0][0]!="PENDING"))return fail();
|
||||
frames.push_back("MTECON1 result "+seq+" "+rows[0][0]+" "+(rows[0][1].empty()?std::string("00"):Hex(rows[0][1].data(),rows[0][1].size()))+" "+std::to_string(reference));
|
||||
}
|
||||
frames.push_back("MTECON1 end "+seq);
|
||||
for(const auto& frame:frames)if(frame.size()>=sizeof(Reply::message))return fail();
|
||||
if(!db.Commit())return fail();return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
#pragma once
|
||||
#include <cerrno>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <fcntl.h>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// A separate lifetime lock survives replacement of the catalogue inode. Wallet
|
||||
// and item persistence are separate: this file is not an economic transaction.
|
||||
class PortGayaCatalogFile {
|
||||
int directory_=-1, lock_=-1;
|
||||
bool healthy_=false;
|
||||
std::string name_, error_;
|
||||
bool Fail(const char* reason) { healthy_=false;error_=reason;return false; }
|
||||
static uint32_t Hash(const std::string& s) {
|
||||
uint32_t h=2166136261u;for(unsigned char c:s){h^=c;h*=16777619u;}return h;
|
||||
}
|
||||
static bool Number(const std::string& s,uint64_t maximum,uint64_t& out) {
|
||||
if(s.empty())return false;
|
||||
uint64_t n=0;
|
||||
for(char c:s){if(c<'0'||c>'9'||uint64_t(c-'0')>maximum||n>(maximum-uint64_t(c-'0'))/10)return false;n=n*10+uint64_t(c-'0');}
|
||||
out=n;return true;
|
||||
}
|
||||
template<class Item> static bool Valid(unsigned slot,const Item& item) {
|
||||
return slot<27 && item.itemVnum && item.itemCount>0 && item.itemCount<=2000 && item.itemPrice>0 && item.itemPrice<=1000000;
|
||||
}
|
||||
public:
|
||||
enum Result { Error, Missing, Loaded };
|
||||
PortGayaCatalogFile()=default;
|
||||
PortGayaCatalogFile(const PortGayaCatalogFile&)=delete;
|
||||
PortGayaCatalogFile& operator=(const PortGayaCatalogFile&)=delete;
|
||||
~PortGayaCatalogFile(){if(lock_>=0)close(lock_);if(directory_>=0)close(directory_);}
|
||||
bool Ready()const{return healthy_;}
|
||||
const std::string& ErrorText()const{return error_;}
|
||||
bool Open(const std::string& directory,uint32_t player) {
|
||||
if(directory_>=0 || !player)return Fail("invalid or already opened catalogue");
|
||||
// Only the configured data directory is created. Parent directories must exist.
|
||||
if(mkdir(directory.c_str(),0700)!=0 && errno!=EEXIST)return Fail("cannot create catalogue directory");
|
||||
directory_=open(directory.c_str(),O_RDONLY|O_DIRECTORY|O_NOFOLLOW);
|
||||
if(directory_<0)return Fail("cannot open catalogue directory");
|
||||
name_=std::to_string(player);
|
||||
lock_=openat(directory_,(name_+".lock").c_str(),O_RDWR|O_CREAT|O_NOFOLLOW,0600);
|
||||
if(lock_<0)return Fail("cannot open catalogue lock");
|
||||
struct stat info={};
|
||||
if(fstat(lock_,&info)!=0 || !S_ISREG(info.st_mode) || flock(lock_,LOCK_EX|LOCK_NB)!=0)
|
||||
return Fail("catalogue already owned or invalid lock file");
|
||||
healthy_=true;return true;
|
||||
}
|
||||
template<class Item> Result Load(std::map<uint8_t,Item>& output,int& refresh) {
|
||||
if(!healthy_)return Error;
|
||||
int fd=openat(directory_,name_.c_str(),O_RDONLY|O_NOFOLLOW);
|
||||
if(fd<0){if(errno==ENOENT){output.clear();refresh=0;return Missing;}Fail("cannot read catalogue");return Error;}
|
||||
struct stat info={};
|
||||
if(fstat(fd,&info)!=0 || !S_ISREG(info.st_mode) || info.st_size<1 || info.st_size>16384){close(fd);Fail("invalid catalogue file");return Error;}
|
||||
std::string bytes;char buf[1024];bool readOK=true;
|
||||
for(;;){ssize_t n=read(fd,buf,sizeof(buf));if(n<0&&errno==EINTR)continue;if(n<0){readOK=false;break;}if(!n)break;bytes.append(buf,size_t(n));if(bytes.size()>16384){readOK=false;break;}}
|
||||
close(fd);
|
||||
if(!readOK || bytes.empty() || bytes.back()!='\n'){Fail("truncated catalogue");return Error;}
|
||||
const auto newline=bytes.find('\n');std::string header=bytes.substr(0,newline),body=bytes.substr(newline+1);
|
||||
int decodedRefresh=0;
|
||||
if(header!="index-vnum-count-price-buyed") {
|
||||
std::istringstream fields(header);std::string version,deadline,checksum,tail;uint64_t parsed=0;
|
||||
if(!(fields>>version>>deadline>>checksum) || fields>>tail || version!="gaya-v2" || !Number(deadline,INT32_MAX,parsed) || checksum!=std::to_string(Hash(body))) {
|
||||
Fail("invalid catalogue header or checksum");return Error;
|
||||
}
|
||||
decodedRefresh=static_cast<int>(parsed);
|
||||
}
|
||||
std::map<uint8_t,Item> decoded;std::istringstream rows(body);std::string line;
|
||||
while(std::getline(rows,line)) {
|
||||
std::istringstream fields(line);std::string tokens[5],tail;uint64_t values[5]={};
|
||||
if(!(fields>>tokens[0]>>tokens[1]>>tokens[2]>>tokens[3]>>tokens[4]) || fields>>tail ||
|
||||
!Number(tokens[0],26,values[0]) || !Number(tokens[1],UINT32_MAX,values[1]) ||
|
||||
!Number(tokens[2],2000,values[2]) || !Number(tokens[3],1000000,values[3]) || !Number(tokens[4],1,values[4])) {
|
||||
Fail("invalid catalogue row");return Error;
|
||||
}
|
||||
Item item={};item.itemVnum=static_cast<uint32_t>(values[1]);item.itemCount=static_cast<uint32_t>(values[2]);item.itemPrice=static_cast<int>(values[3]);item.itemBuyed=values[4]!=0;
|
||||
if(!Valid(unsigned(values[0]),item) || !decoded.emplace(uint8_t(values[0]),item).second){Fail("invalid or duplicate catalogue slot");return Error;}
|
||||
}
|
||||
if(decoded.empty()){Fail("empty catalogue");return Error;}
|
||||
output.swap(decoded);refresh=decodedRefresh;return Loaded;
|
||||
}
|
||||
template<class Item> bool Save(const std::map<uint8_t,Item>& items,int refresh) {
|
||||
if(!healthy_)return false;
|
||||
if(items.empty() || items.size()>27 || refresh<0)return Fail("invalid catalogue snapshot");
|
||||
std::ostringstream rows;
|
||||
for(const auto& row:items){if(!Valid(row.first,row.second))return Fail("invalid catalogue snapshot row");const auto& i=row.second;rows<<unsigned(row.first)<<' '<<i.itemVnum<<' '<<i.itemCount<<' '<<i.itemPrice<<' '<<(i.itemBuyed?1:0)<<'\n';}
|
||||
const std::string body=rows.str(),bytes="gaya-v2 "+std::to_string(refresh)+" "+std::to_string(Hash(body))+"\n"+body;
|
||||
const std::string temporary=name_+".tmp."+std::to_string(getpid());
|
||||
int fd=openat(directory_,temporary.c_str(),O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW,0600);
|
||||
if(fd<0)return Fail("cannot create catalogue snapshot");
|
||||
bool written=true;size_t offset=0;
|
||||
while(offset<bytes.size()){ssize_t n=write(fd,bytes.data()+offset,bytes.size()-offset);if(n<0&&errno==EINTR)continue;if(n<=0){written=false;break;}offset+=size_t(n);}
|
||||
if(written && fsync(fd)!=0)written=false;
|
||||
if(close(fd)!=0)written=false;
|
||||
if(!written){unlinkat(directory_,temporary.c_str(),0);return Fail("catalogue write/fsync failed; old snapshot retained");}
|
||||
if(renameat(directory_,temporary.c_str(),directory_,name_.c_str())!=0){unlinkat(directory_,temporary.c_str(),0);return Fail("catalogue replace failed; old snapshot retained");}
|
||||
if(fsync(directory_)!=0)return Fail("catalogue directory fsync failed; snapshot outcome requires reload");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool PortGayaNextRefresh(int64_t now,int previous,bool elapsedCadence,int& next) {
|
||||
const int64_t period=5*60*60;
|
||||
if(now<0 || now>INT32_MAX-period || previous<0)return false;
|
||||
int64_t result=now+period;
|
||||
if(elapsedCadence && previous>0) {
|
||||
if(previous>now)result=previous;
|
||||
else result=int64_t(previous)+((now-previous)/period+1)*period;
|
||||
}
|
||||
if(result>INT32_MAX)return false;
|
||||
next=static_cast<int>(result);return true;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
// Compare against bounded differences: never negate caller-supplied INT64_MIN.
|
||||
inline bool PortGoldCanChange(int64_t balance,int64_t delta,int64_t maximum) {
|
||||
return maximum>=0 && balance>=0 && balance<=maximum && delta>=-balance && delta<=maximum-balance;
|
||||
}
|
||||
inline bool PortGoldTotal(int64_t price,uint32_t count,int64_t maximum,int64_t& total) {
|
||||
if(price<=0 || !count || maximum<0 || price>maximum/int64_t(count))return false;
|
||||
total=price*int64_t(count);return true;
|
||||
}
|
||||
+107
-50
@@ -31,8 +31,8 @@ enum EItemDragonSoulSockets
|
||||
ITEM_SOCKET_DRAGON_SOUL_ACTIVE_IDX = 2,
|
||||
ITEM_SOCKET_CHARGING_AMOUNT_IDX = 2,
|
||||
};
|
||||
// 헐 이거 미친거 아니야?
|
||||
// 나중에 소켓 확장하면 어쩌려고 이지랄 -_-;;;
|
||||
// 헐 이거 미친거 아니야?
|
||||
// 나중에 소켓 확장하면 어쩌려고 이지랄 -_-;;;
|
||||
enum EItemUniqueSockets
|
||||
{
|
||||
ITEM_SOCKET_UNIQUE_SAVE_TIME = ITEM_SOCKET_MAX_NUM - 2,
|
||||
@@ -42,18 +42,18 @@ enum EItemUniqueSockets
|
||||
enum EItemTypes
|
||||
{
|
||||
ITEM_NONE, //0
|
||||
ITEM_WEAPON, //1//무기
|
||||
ITEM_ARMOR, //2//갑옷
|
||||
ITEM_USE, //3//아이템 사용
|
||||
ITEM_WEAPON, //1//무기
|
||||
ITEM_ARMOR, //2//갑옷
|
||||
ITEM_USE, //3//아이템 사용
|
||||
ITEM_AUTOUSE, //4
|
||||
ITEM_MATERIAL, //5
|
||||
ITEM_SPECIAL, //6 //스페셜 아이템
|
||||
ITEM_SPECIAL, //6 //스페셜 아이템
|
||||
ITEM_TOOL, //7
|
||||
ITEM_LOTTERY, //8//복권
|
||||
ITEM_ELK, //9//돈
|
||||
ITEM_LOTTERY, //8//복권
|
||||
ITEM_ELK, //9//돈
|
||||
ITEM_METIN, //10
|
||||
ITEM_CONTAINER, //11
|
||||
ITEM_FISH, //12//낚시
|
||||
ITEM_FISH, //12//낚시
|
||||
ITEM_ROD, //13
|
||||
ITEM_RESOURCE, //14
|
||||
ITEM_CAMPFIRE, //15
|
||||
@@ -61,23 +61,28 @@ enum EItemTypes
|
||||
ITEM_SKILLBOOK, //17
|
||||
ITEM_QUEST, //18
|
||||
ITEM_POLYMORPH, //19
|
||||
ITEM_TREASURE_BOX, //20//보물상자
|
||||
ITEM_TREASURE_KEY, //21//보물상자 열쇠
|
||||
ITEM_TREASURE_BOX, //20//보물상자
|
||||
ITEM_TREASURE_KEY, //21//보물상자 열쇠
|
||||
ITEM_SKILLFORGET, //22
|
||||
ITEM_GIFTBOX, //23
|
||||
ITEM_PICK, //24
|
||||
ITEM_HAIR, //25//머리
|
||||
ITEM_TOTEM, //26//토템
|
||||
ITEM_BLEND, //27//생성될때 랜덤하게 속성이 붙는 약물
|
||||
ITEM_COSTUME, //28//코스츔 아이템 (2011년 8월 추가된 코스츔 시스템용 아이템)
|
||||
ITEM_DS, //29 //용혼석
|
||||
ITEM_SPECIAL_DS, //30 // 특수한 용혼석 (DS_SLOT에 착용하는 UNIQUE 아이템이라 생각하면 됨)
|
||||
ITEM_EXTRACT, //31 추출도구.
|
||||
ITEM_SECONDARY_COIN, //32 ?? 명도전??
|
||||
ITEM_RING, //33 반지
|
||||
ITEM_BELT, //34 벨트
|
||||
ITEM_HAIR, //25//머리
|
||||
ITEM_TOTEM, //26//토템
|
||||
ITEM_BLEND, //27//생성될때 랜덤하게 속성이 붙는 약물
|
||||
ITEM_COSTUME, //28//코스츔 아이템 (2011년 8월 추가된 코스츔 시스템용 아이템)
|
||||
ITEM_DS, //29 //용혼석
|
||||
ITEM_SPECIAL_DS, //30 // 특수한 용혼석 (DS_SLOT에 착용하는 UNIQUE 아이템이라 생각하면 됨)
|
||||
ITEM_EXTRACT, //31 추출도구.
|
||||
ITEM_SECONDARY_COIN, //32 ?? 명도전??
|
||||
ITEM_RING, //33 반지
|
||||
ITEM_BELT, //34 벨트
|
||||
ITEM_SHINING, //35 AVA2 shining (not ported, keeps the AVA2 numbering)
|
||||
ITEM_NEW_RINGS, //36 AVA2 new rings (port_rings.cpp), worn in WEAR_RINGS_1/2
|
||||
ITEM_PET, // PORT: AVA2 growable pets, explicit item type 37.
|
||||
};
|
||||
|
||||
enum EShiningSubTypes { SHINING_WEAPON, SHINING_ARMOR, SHINING_SPECIAL };
|
||||
|
||||
enum EMetinSubTypes
|
||||
{
|
||||
METIN_NORMAL,
|
||||
@@ -106,16 +111,42 @@ enum EArmorSubTypes
|
||||
ARMOR_FOOTS,
|
||||
ARMOR_NECK,
|
||||
ARMOR_EAR,
|
||||
ARMOR_PENDANT, // 7 AVA2 talisman (ITEM_TALISMAN_EQUIPMENT), worn in WEAR_PENDANT
|
||||
ARMOR_NUM_TYPES
|
||||
};
|
||||
|
||||
enum ECostumeSubTypes
|
||||
{
|
||||
COSTUME_BODY = ARMOR_BODY, // [중요!!] ECostumeSubTypes enum value는 종류별로 EArmorSubTypes의 그것과 같아야 함.
|
||||
COSTUME_HAIR = ARMOR_HEAD, // 이는 코스츔 아이템에 추가 속성을 붙이겠다는 사업부의 요청에 따라서 기존 로직을 활용하기 위함임.
|
||||
COSTUME_BODY = ARMOR_BODY, // [중요!!] ECostumeSubTypes enum value는 종류별로 EArmorSubTypes의 그것과 같아야 함.
|
||||
COSTUME_HAIR = ARMOR_HEAD, // 이는 코스츔 아이템에 추가 속성을 붙이겠다는 사업부의 요청에 따라서 기존 로직을 활용하기 위함임.
|
||||
COSTUME_MOUNT = 2, // AVA2 mount costume (value0 = horse race)
|
||||
COSTUME_SASH = 3, // AVA2 sash (85001..85024)
|
||||
COSTUME_MOUNT_SKIN = 4, // AVA2 mount skin (value0 = horse race, needs COSTUME_MOUNT)
|
||||
COSTUME_WEAPON = 5, // PORT: preserve existing mount-skin subtype 4.
|
||||
COSTUME_NEW_SASH = 6,
|
||||
COSTUME_PET = 7,
|
||||
COSTUME_NUM_TYPES,
|
||||
};
|
||||
|
||||
enum EPetSubTypes
|
||||
{
|
||||
PET_LEVELABLE,
|
||||
PET_EGG,
|
||||
PET_TRANSPORTBOX,
|
||||
PET_PROTEIN,
|
||||
PET_CHANGE_NAME_ITEM,
|
||||
PET_DEW,
|
||||
PET_SKILL,
|
||||
PET_PRIMIUM_FEEDSTUFF,
|
||||
PET_ATTR_CHANGE,
|
||||
PET_ATTR_DETERMINE,
|
||||
PET_EXPFOOD_PER,
|
||||
PET_SKILL_DEL_BOOK,
|
||||
PET_SKILL_ALL_DEL_BOOK,
|
||||
PET_EXPFOOD,
|
||||
PET_FEEDSTUFF,
|
||||
};
|
||||
|
||||
enum EDragonSoulSubType
|
||||
{
|
||||
DS_SLOT1,
|
||||
@@ -215,8 +246,8 @@ enum EUseSubTypes
|
||||
USE_UNBIND,
|
||||
USE_TIME_CHARGE_PER,
|
||||
USE_TIME_CHARGE_FIX, // 28
|
||||
USE_PUT_INTO_BELT_SOCKET, // 29 벨트 소켓에 사용할 수 있는 아이템
|
||||
USE_PUT_INTO_RING_SOCKET, // 30 반지 소켓에 사용할 수 있는 아이템 (유니크 반지 말고, 새로 추가된 반지 슬롯)
|
||||
USE_PUT_INTO_BELT_SOCKET, // 29 벨트 소켓에 사용할 수 있는 아이템
|
||||
USE_PUT_INTO_RING_SOCKET, // 30 반지 소켓에 사용할 수 있는 아이템 (유니크 반지 말고, 새로 추가된 반지 슬롯)
|
||||
};
|
||||
|
||||
enum EExtractSubTypes
|
||||
@@ -270,7 +301,7 @@ enum EItemFlag
|
||||
{
|
||||
ITEM_FLAG_REFINEABLE = (1 << 0),
|
||||
ITEM_FLAG_SAVE = (1 << 1),
|
||||
ITEM_FLAG_STACKABLE = (1 << 2), // 여러개 합칠 수 있음
|
||||
ITEM_FLAG_STACKABLE = (1 << 2), // 여러개 합칠 수 있음
|
||||
ITEM_FLAG_COUNT_PER_1GOLD = (1 << 3),
|
||||
ITEM_FLAG_SLOW_QUERY = (1 << 4),
|
||||
ITEM_FLAG_UNUSED01 = (1 << 5), // UNUSED
|
||||
@@ -287,24 +318,24 @@ enum EItemFlag
|
||||
|
||||
enum EItemAntiFlag
|
||||
{
|
||||
ITEM_ANTIFLAG_FEMALE = (1 << 0), // 여성 사용 불가
|
||||
ITEM_ANTIFLAG_MALE = (1 << 1), // 남성 사용 불가
|
||||
ITEM_ANTIFLAG_WARRIOR = (1 << 2), // 무사 사용 불가
|
||||
ITEM_ANTIFLAG_ASSASSIN = (1 << 3), // 자객 사용 불가
|
||||
ITEM_ANTIFLAG_SURA = (1 << 4), // 수라 사용 불가
|
||||
ITEM_ANTIFLAG_SHAMAN = (1 << 5), // 무당 사용 불가
|
||||
ITEM_ANTIFLAG_GET = (1 << 6), // 집을 수 없음
|
||||
ITEM_ANTIFLAG_DROP = (1 << 7), // 버릴 수 없음
|
||||
ITEM_ANTIFLAG_SELL = (1 << 8), // 팔 수 없음
|
||||
ITEM_ANTIFLAG_EMPIRE_A = (1 << 9), // A 제국 사용 불가
|
||||
ITEM_ANTIFLAG_EMPIRE_B = (1 << 10), // B 제국 사용 불가
|
||||
ITEM_ANTIFLAG_EMPIRE_C = (1 << 11), // C 제국 사용 불가
|
||||
ITEM_ANTIFLAG_SAVE = (1 << 12), // 저장되지 않음
|
||||
ITEM_ANTIFLAG_GIVE = (1 << 13), // 거래 불가
|
||||
ITEM_ANTIFLAG_PKDROP = (1 << 14), // PK시 떨어지지 않음
|
||||
ITEM_ANTIFLAG_STACK = (1 << 15), // 합칠 수 없음
|
||||
ITEM_ANTIFLAG_MYSHOP = (1 << 16), // 개인 상점에 올릴 수 없음
|
||||
ITEM_ANTIFLAG_SAFEBOX = (1 << 17), // 창고에 넣을 수 없음
|
||||
ITEM_ANTIFLAG_FEMALE = (1 << 0), // 여성 사용 불가
|
||||
ITEM_ANTIFLAG_MALE = (1 << 1), // 남성 사용 불가
|
||||
ITEM_ANTIFLAG_WARRIOR = (1 << 2), // 무사 사용 불가
|
||||
ITEM_ANTIFLAG_ASSASSIN = (1 << 3), // 자객 사용 불가
|
||||
ITEM_ANTIFLAG_SURA = (1 << 4), // 수라 사용 불가
|
||||
ITEM_ANTIFLAG_SHAMAN = (1 << 5), // 무당 사용 불가
|
||||
ITEM_ANTIFLAG_GET = (1 << 6), // 집을 수 없음
|
||||
ITEM_ANTIFLAG_DROP = (1 << 7), // 버릴 수 없음
|
||||
ITEM_ANTIFLAG_SELL = (1 << 8), // 팔 수 없음
|
||||
ITEM_ANTIFLAG_EMPIRE_A = (1 << 9), // A 제국 사용 불가
|
||||
ITEM_ANTIFLAG_EMPIRE_B = (1 << 10), // B 제국 사용 불가
|
||||
ITEM_ANTIFLAG_EMPIRE_C = (1 << 11), // C 제국 사용 불가
|
||||
ITEM_ANTIFLAG_SAVE = (1 << 12), // 저장되지 않음
|
||||
ITEM_ANTIFLAG_GIVE = (1 << 13), // 거래 불가
|
||||
ITEM_ANTIFLAG_PKDROP = (1 << 14), // PK시 떨어지지 않음
|
||||
ITEM_ANTIFLAG_STACK = (1 << 15), // 합칠 수 없음
|
||||
ITEM_ANTIFLAG_MYSHOP = (1 << 16), // 개인 상점에 올릴 수 없음
|
||||
ITEM_ANTIFLAG_SAFEBOX = (1 << 17), // 창고에 넣을 수 없음
|
||||
};
|
||||
|
||||
enum EItemWearableFlag
|
||||
@@ -335,16 +366,16 @@ enum ELimitTypes
|
||||
LIMIT_CON,
|
||||
LIMIT_PCBANG,
|
||||
|
||||
/// 착용 여부와 상관 없이 실시간으로 시간 차감 (socket0에 소멸 시간이 박힘: unix_timestamp 타입)
|
||||
/// 착용 여부와 상관 없이 실시간으로 시간 차감 (socket0에 소멸 시간이 박힘: unix_timestamp 타입)
|
||||
LIMIT_REAL_TIME,
|
||||
|
||||
/// 아이템을 맨 처음 사용(혹은 착용) 한 순간부터 리얼타임 타이머 시작
|
||||
/// 최초 사용 전에는 socket0에 사용가능시간(초단위, 0이면 프로토의 limit value값 사용) 값이 쓰여있다가
|
||||
/// 아이템 사용시 socket1에 사용 횟수가 박히고 socket0에 unix_timestamp 타입의 소멸시간이 박힘.
|
||||
/// 아이템을 맨 처음 사용(혹은 착용) 한 순간부터 리얼타임 타이머 시작
|
||||
/// 최초 사용 전에는 socket0에 사용가능시간(초단위, 0이면 프로토의 limit value값 사용) 값이 쓰여있다가
|
||||
/// 아이템 사용시 socket1에 사용 횟수가 박히고 socket0에 unix_timestamp 타입의 소멸시간이 박힘.
|
||||
LIMIT_REAL_TIME_START_FIRST_USE,
|
||||
|
||||
/// 아이템을 착용 중일 때만 사용 시간이 차감되는 아이템
|
||||
/// socket0에 남은 시간이 초단위로 박힘. (아이템 최초 사용시 해당 값이 0이면 프로토의 limit value값을 socket0에 복사)
|
||||
/// 아이템을 착용 중일 때만 사용 시간이 차감되는 아이템
|
||||
/// socket0에 남은 시간이 초단위로 박힘. (아이템 최초 사용시 해당 값이 0이면 프로토의 limit value값을 socket0에 복사)
|
||||
LIMIT_TIMER_BASED_ON_WEAR,
|
||||
|
||||
LIMIT_MAX_NUM
|
||||
@@ -368,4 +399,30 @@ enum ERefineType
|
||||
REFINE_TYPE_BDRAGON,
|
||||
};
|
||||
|
||||
// AVA2 sash: combine two sashes of one grade into the next grade / absorb a weapon or body armor.
|
||||
enum ESashInfo
|
||||
{
|
||||
SASH_GRADE_VALUE_FIELD = 0, // item value0 = grade 1..4
|
||||
SASH_ABSORPTION_SOCKET = 0, // socket0 = absorption %
|
||||
SASH_ABSORBED_SOCKET = 1, // socket1 = vnum of the absorbed item
|
||||
SASH_GRADE_1_ABS = 1,
|
||||
SASH_GRADE_2_ABS = 5,
|
||||
SASH_GRADE_3_ABS = 10,
|
||||
SASH_GRADE_4_ABS_MIN = 11,
|
||||
SASH_GRADE_4_ABS_MAX = 25,
|
||||
SASH_GRADE_4_ABS_MAX_COMB = 19,
|
||||
SASH_GRADE_4_ABS_RANGE = 5,
|
||||
SASH_EFFECT_FROM_ABS = 19,
|
||||
SASH_CLEAN_ATTR_VALUE0 = 7,
|
||||
SASH_WINDOW_MAX_MATERIALS = 2,
|
||||
SASH_GRADE_1_PRICE = 100000,
|
||||
SASH_GRADE_2_PRICE = 200000,
|
||||
SASH_GRADE_3_PRICE = 300000,
|
||||
SASH_GRADE_4_PRICE = 500000,
|
||||
SASH_COMBINE_GRADE_1 = 80,
|
||||
SASH_COMBINE_GRADE_2 = 70,
|
||||
SASH_COMBINE_GRADE_3 = 50,
|
||||
SASH_COMBINE_GRADE_4 = 30,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+179
-73
@@ -1,6 +1,9 @@
|
||||
#ifndef __INC_METIN_II_LENGTH_H__
|
||||
#define __INC_METIN_II_LENGTH_H__
|
||||
|
||||
// Feature-dependent wire layouts must not depend on a caller's include order.
|
||||
#include "service.h"
|
||||
|
||||
#define WORD_MAX 0xffff
|
||||
enum EMisc
|
||||
{
|
||||
@@ -11,7 +14,12 @@ enum EMisc
|
||||
PLAYER_PER_ACCOUNT = 4,
|
||||
ACCOUNT_STATUS_MAX_LEN = 8,
|
||||
CHARACTER_NAME_MAX_LEN = 24,
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
OFFLINE_SHOP_HOST_ITEM_MAX_NUM = 80,
|
||||
SHOP_SIGN_MAX_LEN = 45,
|
||||
#else
|
||||
SHOP_SIGN_MAX_LEN = 32,
|
||||
#endif
|
||||
INVENTORY_PAGE_SIZE = 45, // 5 x 9
|
||||
INVENTORY_PAGE_COUNT = 5, // MT: 40250 ships 2 pages (90 cells)
|
||||
INVENTORY_MAX_NUM = INVENTORY_PAGE_SIZE * INVENTORY_PAGE_COUNT,
|
||||
@@ -24,10 +32,10 @@ enum EMisc
|
||||
|
||||
GUILD_NAME_MAX_LEN = 12,
|
||||
|
||||
SHOP_HOST_ITEM_MAX_NUM = 40, /* 호스트의 최대 아이템 개수 */
|
||||
SHOP_GUEST_ITEM_MAX_NUM = 18, /* 게스트의 최대 아이템 개수 */
|
||||
SHOP_HOST_ITEM_MAX_NUM = 40, /* 호스트의 최대 아이템 개수 */
|
||||
SHOP_GUEST_ITEM_MAX_NUM = 18, /* 게스트의 최대 아이템 개수 */
|
||||
|
||||
SHOP_PRICELIST_MAX_NUM = 40, ///< 개인상점 가격정보 리스트에서 유지할 가격정보의 최대 갯수
|
||||
SHOP_PRICELIST_MAX_NUM = 40, ///< 개인상점 가격정보 리스트에서 유지할 가격정보의 최대 갯수
|
||||
|
||||
CHAT_MAX_LEN = 512,
|
||||
|
||||
@@ -48,6 +56,13 @@ enum EMisc
|
||||
ATTRIBUTE_MAX_VALUE = 20,
|
||||
CHARACTER_PATH_MAX_NUM = 64,
|
||||
SKILL_MAX_NUM = 255,
|
||||
|
||||
#ifdef ENABLE_NEW_PET_SYSTEM
|
||||
PET_MAX_EVOLUTION_CONST = 3,
|
||||
PET_MAX_LEVEL_CONST = 120,
|
||||
PET_APPLY_MAX_NUM = 3,
|
||||
PET_SKILLS_MAX_NUM = 15,
|
||||
#endif
|
||||
SKILLBOOK_DELAY_MIN = 64800,
|
||||
SKILLBOOK_DELAY_MAX = 108000,
|
||||
SKILL_MAX_LEVEL = 40,
|
||||
@@ -64,10 +79,11 @@ enum EMisc
|
||||
DRAGON_SOUL_REFINE_GRID_SIZE = 15,
|
||||
MAX_AMOUNT_OF_MALL_BONUS = 20,
|
||||
|
||||
WEAR_MAX_NUM = 32,
|
||||
WEAR_MAX_NUM = 40, // PORT: shop costume/pet/shining equipment.
|
||||
|
||||
//LIMIT_GOLD
|
||||
GOLD_MAX = 2000000000,
|
||||
GOLD_MAX_64 = 2000000000000000LL,
|
||||
|
||||
MAX_PASSPOD = 8 ,
|
||||
|
||||
@@ -84,21 +100,33 @@ enum EMisc
|
||||
|
||||
BELT_INVENTORY_SLOT_COUNT = BELT_INVENTORY_SLOT_WIDTH * BELT_INVENTORY_SLOT_HEIGHT,
|
||||
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
SPECIAL_INVENTORY_PAGE_COLUMN = 5,
|
||||
SPECIAL_INVENTORY_PAGE_ROW = 9,
|
||||
SPECIAL_INVENTORY_PAGE_SIZE = SPECIAL_INVENTORY_PAGE_COLUMN * SPECIAL_INVENTORY_PAGE_ROW,
|
||||
SPECIAL_INVENTORY_PAGE_COUNT = 4,
|
||||
SPECIAL_INVENTORY_MAX_NUM = SPECIAL_INVENTORY_PAGE_SIZE * SPECIAL_INVENTORY_PAGE_COUNT,
|
||||
#endif
|
||||
|
||||
#ifdef UNLOCK_INVENTORY_WORLDARD
|
||||
UNLOCK_INVENTORY_MAX = 6,
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
**** 현재까지 할당 된 아이템 영역 정리 (DB상 Item Position) ****
|
||||
**** 현재까지 할당 된 아이템 영역 정리 (DB상 Item Position) ****
|
||||
+------------------------------------------------------+ 0
|
||||
| 캐릭터 기본 인벤토리 (45칸 * 2페이지) 90칸 |
|
||||
| 캐릭터 기본 인벤토리 (45칸 * 2페이지) 90칸 |
|
||||
+------------------------------------------------------+ 225 = INVENTORY_MAX_NUM(225) MT: 5 pages; 40250 had 90 and every cell below moved by +135
|
||||
| 캐릭터 장비 창 (착용중인 아이템) 32칸 |
|
||||
| 캐릭터 장비 창 (착용중인 아이템) 32칸 |
|
||||
+------------------------------------------------------+ 257 = INVENTORY_MAX_NUM(225) + WEAR_MAX_NUM(32)
|
||||
| 용혼석 장비 창 (착용중인 용혼석) 12칸 |
|
||||
| 용혼석 장비 창 (착용중인 용혼석) 12칸 |
|
||||
+------------------------------------------------------+ 269 = 257 + DS_SLOT_MAX(6) * DRAGON_SOUL_DECK_MAX_NUM(2)
|
||||
| 용혼석 장비 창 예약 (아직 미사용) 18칸 |
|
||||
| 용혼석 장비 창 예약 (아직 미사용) 18칸 |
|
||||
+------------------------------------------------------+ 287 = 269 + DS_SLOT_MAX(6) * DRAGON_SOUL_DECK_RESERVED_MAX_NUM(3)
|
||||
| 벨트 인벤토리 (벨트 착용시에만 벨트 레벨에 따라 활성)|
|
||||
| 벨트 인벤토리 (벨트 착용시에만 벨트 레벨에 따라 활성)|
|
||||
+------------------------------------------------------+ 303 = 287 + BELT_INVENTORY_SLOT_COUNT(16) = INVENTORY_AND_EQUIP_CELL_MAX
|
||||
| 미사용 |
|
||||
| 미사용 |
|
||||
+------------------------------------------------------+ ??
|
||||
*/
|
||||
};
|
||||
@@ -133,12 +161,25 @@ enum EWearPositions
|
||||
WEAR_COSTUME_BODY, // 19
|
||||
WEAR_COSTUME_HAIR, // 20
|
||||
|
||||
WEAR_RING1, // 21 : 신규 반지슬롯1 (왼쪽)
|
||||
WEAR_RING2, // 22 : 신규 반지슬롯2 (오른쪽)
|
||||
WEAR_RING1, // 21 : 신규 반지슬롯1 (왼쪽)
|
||||
WEAR_RING2, // 22 : 신규 반지슬롯2 (오른쪽)
|
||||
|
||||
WEAR_BELT, // 23 : 신규 벨트슬롯
|
||||
WEAR_BELT, // 23 : 신규 벨트슬롯
|
||||
WEAR_COSTUME_SASH, // 24 : AVA2 sash
|
||||
WEAR_COSTUME_MOUNT, // 25 : AVA2 mount costume
|
||||
WEAR_COSTUME_MOUNT_SKIN, // 26 : AVA2 mount skin
|
||||
WEAR_PENDANT, // 27 : AVA2 talisman (ARMOR_PENDANT)
|
||||
WEAR_RINGS_1, // 28 : AVA2 new ring (ITEM_NEW_RINGS)
|
||||
WEAR_RINGS_2, // 29 : AVA2 new ring
|
||||
|
||||
WEAR_MAX = 32 //
|
||||
WEAR_COSTUME_WEAPON = 30,
|
||||
WEAR_COSTUME_PET = 31,
|
||||
WEAR_PET = 32,
|
||||
WEAR_COSTUME_NEW_SASH = 33,
|
||||
WEAR_SHINING_WEAPON = 34,
|
||||
WEAR_SHINING_ARMOR = 35,
|
||||
WEAR_SHINING_SPECIAL = 36,
|
||||
WEAR_MAX = 40 // PORT: extended appearance equipment.
|
||||
};
|
||||
|
||||
enum EDragonSoulDeckType
|
||||
@@ -147,7 +188,7 @@ enum EDragonSoulDeckType
|
||||
DRAGON_SOUL_DECK_1,
|
||||
DRAGON_SOUL_DECK_MAX_NUM = 2,
|
||||
|
||||
DRAGON_SOUL_DECK_RESERVED_MAX_NUM = 3, // NOTE: 중요! 아직 사용중이진 않지만, 3페이지 분량을 예약 해 둠. DS DECK을 늘릴 경우 반드시 그 수만큼 RESERVED에서 차감해야 함!
|
||||
DRAGON_SOUL_DECK_RESERVED_MAX_NUM = 3, // NOTE: 중요! 아직 사용중이진 않지만, 3페이지 분량을 예약 해 둠. DS DECK을 늘릴 경우 반드시 그 수만큼 RESERVED에서 차감해야 함!
|
||||
};
|
||||
|
||||
enum ESex
|
||||
@@ -169,7 +210,7 @@ enum EDirection
|
||||
DIR_MAX_NUM
|
||||
};
|
||||
|
||||
#define ABILITY_MAX_LEVEL 10 /* 기술 최대 레벨 */
|
||||
#define ABILITY_MAX_LEVEL 10 /* 기술 최대 레벨 */
|
||||
|
||||
enum EAbilityDifficulty
|
||||
{
|
||||
@@ -182,9 +223,9 @@ enum EAbilityDifficulty
|
||||
|
||||
enum EAbilityCategory
|
||||
{
|
||||
CATEGORY_PHYSICAL, /* 신체적 어빌리티 */
|
||||
CATEGORY_MENTAL, /* 정신적 어빌리티 */
|
||||
CATEGORY_ATTRIBUTE, /* 능력 어빌리티 */
|
||||
CATEGORY_PHYSICAL, /* 신체적 어빌리티 */
|
||||
CATEGORY_MENTAL, /* 정신적 어빌리티 */
|
||||
CATEGORY_ATTRIBUTE, /* 능력 어빌리티 */
|
||||
CATEGORY_NUM_TYPES
|
||||
};
|
||||
|
||||
@@ -247,6 +288,7 @@ enum EParts
|
||||
PART_WEAPON,
|
||||
PART_HEAD,
|
||||
PART_HAIR,
|
||||
PART_SASH,
|
||||
|
||||
PART_MAX_NUM,
|
||||
PART_WEAPON_SUB,
|
||||
@@ -254,13 +296,13 @@ enum EParts
|
||||
|
||||
enum EChatType
|
||||
{
|
||||
CHAT_TYPE_TALKING, /* 그냥 채팅 */
|
||||
CHAT_TYPE_INFO, /* 정보 (아이템을 집었다, 경험치를 얻었다. 등) */
|
||||
CHAT_TYPE_NOTICE, /* 공지사항 */
|
||||
CHAT_TYPE_PARTY, /* 파티말 */
|
||||
CHAT_TYPE_GUILD, /* 길드말 */
|
||||
CHAT_TYPE_COMMAND, /* 일반 명령 */
|
||||
CHAT_TYPE_SHOUT, /* 외치기 */
|
||||
CHAT_TYPE_TALKING, /* 그냥 채팅 */
|
||||
CHAT_TYPE_INFO, /* 정보 (아이템을 집었다, 경험치를 얻었다. 등) */
|
||||
CHAT_TYPE_NOTICE, /* 공지사항 */
|
||||
CHAT_TYPE_PARTY, /* 파티말 */
|
||||
CHAT_TYPE_GUILD, /* 길드말 */
|
||||
CHAT_TYPE_COMMAND, /* 일반 명령 */
|
||||
CHAT_TYPE_SHOUT, /* 외치기 */
|
||||
CHAT_TYPE_WHISPER,
|
||||
CHAT_TYPE_BIG_NOTICE,
|
||||
CHAT_TYPE_MONARCH_NOTICE,
|
||||
@@ -321,7 +363,10 @@ enum ECharType
|
||||
CHAR_TYPE_PC,
|
||||
CHAR_TYPE_POLYMORPH_PC,
|
||||
CHAR_TYPE_HORSE,
|
||||
CHAR_TYPE_GOTO
|
||||
CHAR_TYPE_GOTO,
|
||||
#ifdef ENABLE_NEW_PET_SYSTEM
|
||||
CHAR_TYPE_PET,
|
||||
#endif
|
||||
};
|
||||
|
||||
enum EBattleType
|
||||
@@ -403,40 +448,54 @@ enum EApplyTypes
|
||||
APPLY_ATTBONUS_SURA, // 61
|
||||
APPLY_ATTBONUS_SHAMAN, // 62
|
||||
APPLY_ATTBONUS_MONSTER, // 63
|
||||
APPLY_MALL_ATTBONUS, // 64 공격력 +x%
|
||||
APPLY_MALL_DEFBONUS, // 65 방어력 +x%
|
||||
APPLY_MALL_EXPBONUS, // 66 경험치 +x%
|
||||
APPLY_MALL_ITEMBONUS, // 67 아이템 드롭율 x/10배
|
||||
APPLY_MALL_GOLDBONUS, // 68 돈 드롭율 x/10배
|
||||
APPLY_MAX_HP_PCT, // 69 최대 생명력 +x%
|
||||
APPLY_MAX_SP_PCT, // 70 최대 정신력 +x%
|
||||
APPLY_SKILL_DAMAGE_BONUS, // 71 스킬 데미지 * (100+x)%
|
||||
APPLY_NORMAL_HIT_DAMAGE_BONUS, // 72 평타 데미지 * (100+x)%
|
||||
APPLY_SKILL_DEFEND_BONUS, // 73 스킬 데미지 방어 * (100-x)%
|
||||
APPLY_NORMAL_HIT_DEFEND_BONUS, // 74 평타 데미지 방어 * (100-x)%
|
||||
APPLY_PC_BANG_EXP_BONUS, // 75 PC방 아이템 EXP 보너스
|
||||
APPLY_PC_BANG_DROP_BONUS, // 76 PC방 아이템 드롭율 보너스
|
||||
APPLY_MALL_ATTBONUS, // 64 공격력 +x%
|
||||
APPLY_MALL_DEFBONUS, // 65 방어력 +x%
|
||||
APPLY_MALL_EXPBONUS, // 66 경험치 +x%
|
||||
APPLY_MALL_ITEMBONUS, // 67 아이템 드롭율 x/10배
|
||||
APPLY_MALL_GOLDBONUS, // 68 돈 드롭율 x/10배
|
||||
APPLY_MAX_HP_PCT, // 69 최대 생명력 +x%
|
||||
APPLY_MAX_SP_PCT, // 70 최대 정신력 +x%
|
||||
APPLY_SKILL_DAMAGE_BONUS, // 71 스킬 데미지 * (100+x)%
|
||||
APPLY_NORMAL_HIT_DAMAGE_BONUS, // 72 평타 데미지 * (100+x)%
|
||||
APPLY_SKILL_DEFEND_BONUS, // 73 스킬 데미지 방어 * (100-x)%
|
||||
APPLY_NORMAL_HIT_DEFEND_BONUS, // 74 평타 데미지 방어 * (100-x)%
|
||||
APPLY_PC_BANG_EXP_BONUS, // 75 PC방 아이템 EXP 보너스
|
||||
APPLY_PC_BANG_DROP_BONUS, // 76 PC방 아이템 드롭율 보너스
|
||||
|
||||
APPLY_EXTRACT_HP_PCT, // 77 사용시 HP 소모
|
||||
APPLY_EXTRACT_HP_PCT, // 77 사용시 HP 소모
|
||||
|
||||
APPLY_RESIST_WARRIOR, // 78 무사에게 저항
|
||||
APPLY_RESIST_ASSASSIN, // 79 자객에게 저항
|
||||
APPLY_RESIST_SURA, // 80 수라에게 저항
|
||||
APPLY_RESIST_SHAMAN, // 81 무당에게 저항
|
||||
APPLY_ENERGY, // 82 기력
|
||||
APPLY_DEF_GRADE, // 83 방어력. DEF_GRADE_BONUS는 클라에서 두배로 보여지는 의도된 버그(...)가 있다.
|
||||
APPLY_COSTUME_ATTR_BONUS, // 84 코스튬 아이템에 붙은 속성치 보너스
|
||||
APPLY_MAGIC_ATTBONUS_PER, // 85 마법 공격력 +x%
|
||||
APPLY_MELEE_MAGIC_ATTBONUS_PER, // 86 마법 + 밀리 공격력 +x%
|
||||
APPLY_RESIST_WARRIOR, // 78 무사에게 저항
|
||||
APPLY_RESIST_ASSASSIN, // 79 자객에게 저항
|
||||
APPLY_RESIST_SURA, // 80 수라에게 저항
|
||||
APPLY_RESIST_SHAMAN, // 81 무당에게 저항
|
||||
APPLY_ENERGY, // 82 기력
|
||||
APPLY_DEF_GRADE, // 83 방어력. DEF_GRADE_BONUS는 클라에서 두배로 보여지는 의도된 버그(...)가 있다.
|
||||
APPLY_COSTUME_ATTR_BONUS, // 84 코스튬 아이템에 붙은 속성치 보너스
|
||||
APPLY_MAGIC_ATTBONUS_PER, // 85 마법 공격력 +x%
|
||||
APPLY_MELEE_MAGIC_ATTBONUS_PER, // 86 마법 + 밀리 공격력 +x%
|
||||
|
||||
APPLY_RESIST_ICE, // 87 냉기 저항
|
||||
APPLY_RESIST_EARTH, // 88 대지 저항
|
||||
APPLY_RESIST_DARK, // 89 어둠 저항
|
||||
APPLY_RESIST_ICE, // 87 냉기 저항
|
||||
APPLY_RESIST_EARTH, // 88 대지 저항
|
||||
APPLY_RESIST_DARK, // 89 어둠 저항
|
||||
|
||||
APPLY_ANTI_CRITICAL_PCT, //90 크리티컬 저항
|
||||
APPLY_ANTI_PENETRATE_PCT, //91 관통타격 저항
|
||||
APPLY_ANTI_CRITICAL_PCT, //90 크리티컬 저항
|
||||
APPLY_ANTI_PENETRATE_PCT, //91 관통타격 저항
|
||||
|
||||
|
||||
// PORT AVA2 bonus numbering (AVA2 common/length.h): 92-138 are AVA2 applies not ported yet,
|
||||
// kept free so later ports and the client item_proto keep AVA2's numbers.
|
||||
// AVA2 ELEMENT_NEW_BONUSES: attack bonus % against monsters of the element (RACE_FLAG_ATT_*), on the talismans.
|
||||
APPLY_RESIST_MAGIC_REDUCTION = 98, // AVA2 ENABLE_MAGIC_REDUCTION_SYSTEM.
|
||||
APPLY_RESIST_HUMAN = 99, // AVA2 growing-pet skill 17.
|
||||
APPLY_ENCHANT_ELEC = 123,
|
||||
APPLY_ENCHANT_FIRE = 124,
|
||||
APPLY_ENCHANT_ICE = 125,
|
||||
APPLY_ENCHANT_WIND = 126,
|
||||
APPLY_ENCHANT_EARTH = 127,
|
||||
APPLY_ENCHANT_DARK = 128,
|
||||
APPLY_ATTBONUS_STONE = 139,
|
||||
APPLY_ATTBONUS_BOSS = 140,
|
||||
|
||||
MAX_APPLY_NUM, //
|
||||
};
|
||||
|
||||
@@ -455,6 +514,21 @@ enum EOnIdleEvents
|
||||
ON_IDLE_MAX_NUM
|
||||
};
|
||||
|
||||
// PORT: AVA2 ENABLE_SWITCHBOT (port_switchbot.cpp). Slot 5 is AVA2's hidden scroll cell; this port keeps
|
||||
// the table width but never stores an item there.
|
||||
enum SwitchbotValues
|
||||
{
|
||||
SWITCHBOT_SLOT_COUNT = 6,
|
||||
SWITCHBOT_SLOT_COUNT_REAL = 5,
|
||||
SWITCHBOT_ALTERNATIVE_COUNT = 2,
|
||||
SWITCHBOT_NORM_ATTR_NUM = 5, // AVA2 MAX_NORM_ATTR_NUM
|
||||
//1 = Switching Item
|
||||
//2 = Yang
|
||||
SWITCHBOT_PRICE_TYPE = 1,
|
||||
//Amount Swtichting Items the Yang-Price
|
||||
SWITCHBOT_PRICE_AMOUNT = 1,
|
||||
};
|
||||
|
||||
enum EWindows
|
||||
{
|
||||
RESERVED_WINDOW,
|
||||
@@ -464,6 +538,14 @@ enum EWindows
|
||||
MALL,
|
||||
DRAGON_SOUL_INVENTORY,
|
||||
BELT_INVENTORY,
|
||||
SWITCHBOT, // PORT: 7 = player.item.window enum 'SWITCHBOT' (appended after BELT_INVENTORY)
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
UPGRADE_INVENTORY, // 8
|
||||
BOOK_INVENTORY, // 9
|
||||
STONE_INVENTORY, // 10
|
||||
CHANGE_INVENTORY, // 11
|
||||
COSTUME_INVENTORY, // 12
|
||||
#endif
|
||||
#ifdef __AUCTION__
|
||||
AUCTION,
|
||||
#endif
|
||||
@@ -586,7 +668,7 @@ enum EGuildWarState
|
||||
GUILD_WAR_OVER,
|
||||
GUILD_WAR_RESERVE,
|
||||
|
||||
GUILD_WAR_DURATION = 30*60, // 1시간
|
||||
GUILD_WAR_DURATION = 30*60, // 1시간
|
||||
GUILD_WAR_WIN_POINT = 1000,
|
||||
GUILD_WAR_LADDER_HALF_PENALTY_TIME = 12*60*60,
|
||||
};
|
||||
@@ -630,13 +712,13 @@ enum EMoneyLogType
|
||||
|
||||
enum EPremiumTypes
|
||||
{
|
||||
PREMIUM_EXP, // 경험치가 1.2배
|
||||
PREMIUM_ITEM, // 아이템 드롭율이 2배
|
||||
PREMIUM_SAFEBOX, // 창고가 1칸에서 3칸
|
||||
PREMIUM_AUTOLOOT, // 돈 자동 줍기
|
||||
PREMIUM_FISH_MIND, // 고급 물고기 낚일 확률 상승
|
||||
PREMIUM_MARRIAGE_FAST, // 금실 증가 양을 빠르게합니다.
|
||||
PREMIUM_GOLD, // 돈 드롭율이 1.5배
|
||||
PREMIUM_EXP, // 경험치가 1.2배
|
||||
PREMIUM_ITEM, // 아이템 드롭율이 2배
|
||||
PREMIUM_SAFEBOX, // 창고가 1칸에서 3칸
|
||||
PREMIUM_AUTOLOOT, // 돈 자동 줍기
|
||||
PREMIUM_FISH_MIND, // 고급 물고기 낚일 확률 상승
|
||||
PREMIUM_MARRIAGE_FAST, // 금실 증가 양을 빠르게합니다.
|
||||
PREMIUM_GOLD, // 돈 드롭율이 1.5배
|
||||
PREMIUM_MAX_NUM = 9
|
||||
};
|
||||
|
||||
@@ -666,10 +748,12 @@ enum SPECIAL_EFFECT
|
||||
SE_AUTO_HPUP,
|
||||
SE_AUTO_SPUP,
|
||||
|
||||
SE_EQUIP_RAMADAN_RING, // 라마단 초승달의 반지(71135) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||
SE_EQUIP_HALLOWEEN_CANDY, // 할로윈 사탕을 착용(-_-;)한 순간에 발동하는 이펙트
|
||||
SE_EQUIP_HAPPINESS_RING, // 크리스마스 행복의 반지(71143) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||
SE_EQUIP_LOVE_PENDANT, // 발렌타인 사랑의 팬던트(71145) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||
SE_EQUIP_RAMADAN_RING, // 라마단 초승달의 반지(71135) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||
SE_EQUIP_HALLOWEEN_CANDY, // 할로윈 사탕을 착용(-_-;)한 순간에 발동하는 이펙트
|
||||
SE_EQUIP_HAPPINESS_RING, // 크리스마스 행복의 반지(71143) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||
SE_EQUIP_LOVE_PENDANT, // 발렌타인 사랑의 팬던트(71145) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||
SE_EFFECT_SASH_SUCCEDED, // AVA2 sash combine success
|
||||
SE_EFFECT_SASH_EQUIP,
|
||||
} ;
|
||||
|
||||
enum ETeenFlags
|
||||
@@ -684,10 +768,10 @@ enum ETeenFlags
|
||||
|
||||
#include "item_length.h"
|
||||
|
||||
// inventory의 position을 나타내는 구조체
|
||||
// int와의 암시적 형변환이 있는 이유는,
|
||||
// 인벤 관련된 모든 함수가 window_type은 받지 않고, cell 하나만 받았기 때문에,(기존에는 인벤이 하나 뿐이어서 inventory type이란게 필요없었기 때문에,)
|
||||
// 인벤 관련 모든 함수 호출부분을 수정하는 것이 난감하기 떄문이다.
|
||||
// inventory의 position을 나타내는 구조체
|
||||
// int와의 암시적 형변환이 있는 이유는,
|
||||
// 인벤 관련된 모든 함수가 window_type은 받지 않고, cell 하나만 받았기 때문에,(기존에는 인벤이 하나 뿐이어서 inventory type이란게 필요없었기 때문에,)
|
||||
// 인벤 관련 모든 함수 호출부분을 수정하는 것이 난감하기 떄문이다.
|
||||
|
||||
enum EDragonSoulRefineWindowSize
|
||||
{
|
||||
@@ -736,7 +820,17 @@ typedef struct SItemPos
|
||||
return cell < INVENTORY_AND_EQUIP_SLOT_MAX;
|
||||
case DRAGON_SOUL_INVENTORY:
|
||||
return cell < (DRAGON_SOUL_INVENTORY_MAX_NUM);
|
||||
// 동적으로 크기가 정해지는 window는 valid 체크를 할 수가 없다.
|
||||
case SWITCHBOT:
|
||||
return cell < SWITCHBOT_SLOT_COUNT;
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
case UPGRADE_INVENTORY:
|
||||
case BOOK_INVENTORY:
|
||||
case STONE_INVENTORY:
|
||||
case CHANGE_INVENTORY:
|
||||
case COSTUME_INVENTORY:
|
||||
return cell < SPECIAL_INVENTORY_MAX_NUM;
|
||||
#endif
|
||||
// 동적으로 크기가 정해지는 window는 valid 체크를 할 수가 없다.
|
||||
case SAFEBOX:
|
||||
case MALL:
|
||||
return false;
|
||||
@@ -775,6 +869,18 @@ typedef struct SItemPos
|
||||
return INVENTORY == window_type && cell < INVENTORY_MAX_NUM;
|
||||
}
|
||||
|
||||
bool IsSwitchbotPosition() const
|
||||
{
|
||||
return SWITCHBOT == window_type && cell < SWITCHBOT_SLOT_COUNT;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
bool IsSpecialInventoryPosition() const
|
||||
{
|
||||
return (window_type >= UPGRADE_INVENTORY && window_type <= COSTUME_INVENTORY) && (cell < SPECIAL_INVENTORY_MAX_NUM);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool operator==(const struct SItemPos& rhs) const
|
||||
{
|
||||
return (window_type == rhs.window_type) && (cell == rhs.cell);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
// The legacy offline shop has no durable, atomic custody/payment/delivery order.
|
||||
// Keep ALL mutation and startup expiry cleanup closed until the replacement has
|
||||
// passed cross-core DB-failure recovery acceptance. No event/GM flag can bypass it.
|
||||
inline bool PortOfflineShopEconomyReady() { return false; }
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
// User-authorized extension. Chance uses basis points; zero disables that source.
|
||||
struct PortPointDropRule {
|
||||
int chance, minimum, maximum, minimumLevel, maximumOverlevel, dailyCap;
|
||||
bool valid() const {
|
||||
return chance >= 0 && chance <= 10000 && minimum >= 1 && maximum >= minimum &&
|
||||
maximum <= 1000000 && minimumLevel >= 0 && maximumOverlevel >= 0 && dailyCap >= 0;
|
||||
}
|
||||
bool eligible(int targetLevel, int playerLevel) const {
|
||||
return valid() && chance > 0 && targetLevel >= minimumLevel && playerLevel > 0 &&
|
||||
(!maximumOverlevel || playerLevel - targetLevel <= maximumOverlevel);
|
||||
}
|
||||
};
|
||||
|
||||
template<class Lookup> PortPointDropRule PortPointRule(Lookup flag, bool stone) {
|
||||
const std::string prefix = stone ? "points_stone_" : "points_mob_";
|
||||
const int minimum = flag(prefix + "min");
|
||||
const int maximum = flag(prefix + "max");
|
||||
return {flag(prefix + "chance"), minimum ? minimum : 1,
|
||||
maximum ? maximum : (minimum ? minimum : 1), flag("points_min_level"),
|
||||
flag("points_max_overlevel"), flag("points_daily_cap")};
|
||||
}
|
||||
|
||||
inline uint32_t PortPointDropAmount(uint32_t requested, uint64_t earned, uint32_t cap) {
|
||||
if (!cap) return requested;
|
||||
if (earned >= cap) return 0;
|
||||
return static_cast<uint32_t>(std::min<uint64_t>(requested, cap - earned));
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
#pragma once
|
||||
#include "ava2_itemshop.h"
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <fcntl.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// A separate lifetime lock survives atomic compaction. The current data file is
|
||||
// locked too, so an already-running legacy append-only writer excludes startup.
|
||||
class PointJournal {
|
||||
struct Entry { Ava2ShopRequest request; uint64_t created; };
|
||||
int fd_=-1, lock_=-1, directory_=-1;
|
||||
bool healthy_=false;
|
||||
uint64_t bytes_=0;
|
||||
std::string name_, error_;
|
||||
std::map<std::string,Entry> pending_;
|
||||
bool Fail(const char* reason){healthy_=false;error_=reason;return false;}
|
||||
static uint32_t Hash(const std::string& data){uint32_t h=2166136261u;for(unsigned char c:data){h^=c;h*=16777619u;}return h;}
|
||||
static bool Token(const std::string& s){if(s.size()!=32)return false;for(char c:s)if(!((c>='0'&&c<='9')||(c>='a'&&c<='f')||(c>='A'&&c<='F')))return false;return true;}
|
||||
static bool Terminal(unsigned status){return status==0 || status==1 || status==2 || status==7;}
|
||||
static bool Regular(int fd){struct stat info={};return fstat(fd,&info)==0 && S_ISREG(info.st_mode);}
|
||||
static bool Unsigned(std::istringstream& in,uint64_t& value,uint64_t maximum){
|
||||
std::string text;if(!(in>>text)||text.empty())return false;value=0;
|
||||
for(unsigned char c:text){if(c<'0'||c>'9')return false;const unsigned digit=c-'0';if(value>maximum/10 || (value==maximum/10 && digit>maximum%10))return false;value=value*10+digit;}return true;
|
||||
}
|
||||
static Ava2ShopRequest Canonical(const Ava2ShopRequest& r){
|
||||
Ava2ShopRequest result={};result.operation=3;result.account=r.account;result.player=r.player;result.product=r.product;result.count=r.count;result.expectedVnum=r.expectedVnum;memcpy(result.token,r.token,32);return result;
|
||||
}
|
||||
static std::string IntentPayload(const Entry& entry){
|
||||
const auto& r=entry.request;std::ostringstream out;out<<"INTENT v2 "<<r.token<<' '<<r.account<<' '<<r.player<<' '<<r.product<<' '<<r.count<<' '<<r.expectedVnum<<' '<<entry.created;return out.str();
|
||||
}
|
||||
static std::string Record(const std::string& payload){char checksum[16];snprintf(checksum,sizeof(checksum)," %08x\n",Hash(payload));return payload+checksum;}
|
||||
static bool WriteAll(int fd,const std::string& line){
|
||||
size_t offset=0;while(offset<line.size()){const ssize_t n=write(fd,line.data()+offset,line.size()-offset);if(n<0&&errno==EINTR)continue;if(n<=0)return false;offset+=static_cast<size_t>(n);}return true;
|
||||
}
|
||||
bool Append(const std::string& payload){
|
||||
if(!healthy_)return false;const auto line=Record(payload);
|
||||
if(!WriteAll(fd_,line))return Fail("journal write failed; issuance paused; retain original journal for repair");
|
||||
if(fsync(fd_)!=0)return Fail("journal fsync failed; issuance paused; settlement may replay with same token");
|
||||
bytes_+=line.size();return true;
|
||||
}
|
||||
public:
|
||||
PointJournal()=default;
|
||||
PointJournal(const PointJournal&)=delete;
|
||||
~PointJournal(){if(fd_>=0)close(fd_);if(lock_>=0)close(lock_);if(directory_>=0)close(directory_);}
|
||||
bool Ready()const{return healthy_;}
|
||||
const std::string& Error()const{return error_;}
|
||||
bool NeedsCompaction()const{return healthy_ && bytes_>=1024*1024 && (bytes_-4096)/512>pending_.size();}
|
||||
bool Open(const std::string& path,std::map<std::string,Ava2ShopRequest>& pending){
|
||||
if(fd_>=0 || directory_>=0)return Fail("journal already open");
|
||||
const auto slash=path.rfind('/');const std::string dir=slash==std::string::npos?".":slash==0?"/":path.substr(0,slash);
|
||||
name_=slash==std::string::npos?path:path.substr(slash+1);
|
||||
if(name_.empty()||name_=="."||name_=="..")return Fail("invalid journal filename");
|
||||
if(mkdir(dir.c_str(),0700)!=0&&errno!=EEXIST)return Fail("cannot create journal directory");
|
||||
directory_=open(dir.c_str(),O_RDONLY|O_DIRECTORY|O_NOFOLLOW);if(directory_<0)return Fail("cannot open journal directory");
|
||||
const std::string lockName=name_+".lock";
|
||||
lock_=openat(directory_,lockName.c_str(),O_RDWR|O_CREAT|O_NOFOLLOW,0600);
|
||||
if(lock_<0||!Regular(lock_)||flock(lock_,LOCK_EX|LOCK_NB)!=0)return Fail("journal lock unavailable or already owned");
|
||||
fd_=openat(directory_,name_.c_str(),O_RDWR|O_CREAT|O_APPEND|O_NOFOLLOW,0600);
|
||||
if(fd_<0||!Regular(fd_))return Fail("cannot open regular journal");
|
||||
if(flock(fd_,LOCK_EX|LOCK_NB)!=0)return Fail("journal already owned by another process");
|
||||
struct stat info={};if(fstat(fd_,&info)!=0||info.st_size<0)return Fail("cannot stat journal");bytes_=static_cast<uint64_t>(info.st_size);
|
||||
if(fsync(fd_)!=0||fsync(lock_)!=0||fsync(directory_)!=0)return Fail("cannot persist journal directory entry");
|
||||
const int reader=dup(fd_);if(reader<0)return Fail("cannot duplicate journal reader");
|
||||
FILE* input=fdopen(reader,"r");if(!input){close(reader);return Fail("cannot read journal");}
|
||||
pending.clear();rewind(input);char line[512];bool valid=true;
|
||||
while(fgets(line,sizeof(line),input)){
|
||||
const size_t size=strlen(line);if(!size||line[size-1]!='\n'){valid=false;break;}
|
||||
std::string raw(line,size-1);std::istringstream fields(raw);std::string op,version,token,tail;fields>>op>>version>>token;
|
||||
if(!Token(token)||(version!="v1"&&version!="v2")){valid=false;break;}
|
||||
if(version=="v2"){
|
||||
const auto split=raw.rfind(' ');unsigned checksum=0;char extra=0;
|
||||
if(split==std::string::npos||sscanf(raw.c_str()+split+1,"%8x%c",&checksum,&extra)!=1||checksum!=Hash(raw.substr(0,split))){valid=false;break;}
|
||||
fields.clear();fields.str(raw.substr(0,split));fields>>op>>version>>token;
|
||||
}
|
||||
if(op=="INTENT"){
|
||||
Entry entry={};auto& r=entry.request;r.operation=3;uint64_t account=0,player=0,product=0,count=0,level=0;
|
||||
if(!Unsigned(fields,account,UINT32_MAX)||!Unsigned(fields,player,UINT32_MAX)||!Unsigned(fields,product,UINT32_MAX)||
|
||||
!Unsigned(fields,count,1000000)||!Unsigned(fields,level,255)||!Unsigned(fields,entry.created,UINT64_MAX)||fields>>tail||!account||!player||!product||!count||!level){valid=false;break;}
|
||||
r.account=static_cast<uint32_t>(account);r.player=static_cast<uint32_t>(player);r.product=static_cast<uint32_t>(product);r.count=static_cast<uint32_t>(count);r.expectedVnum=static_cast<uint32_t>(level);memcpy(r.token,token.c_str(),32);
|
||||
const auto found=pending_.find(token);
|
||||
if(found!=pending_.end()&&memcmp(&found->second.request,&r,sizeof(r))!=0){valid=false;break;}
|
||||
pending_[token]=entry;pending[token]=r;
|
||||
}else if(op=="DONE"){
|
||||
uint64_t status=0,granted=0,balance=0,created=0;
|
||||
if(!Unsigned(fields,status,255)||!Terminal(static_cast<unsigned>(status))||!Unsigned(fields,granted,1000000)||!Unsigned(fields,balance,INT64_MAX)||!Unsigned(fields,created,UINT64_MAX)||fields>>tail||(status!=0&&granted!=0)){valid=false;break;}
|
||||
const auto found=pending_.find(token);
|
||||
if(found!=pending_.end() && granted>found->second.request.count){valid=false;break;}
|
||||
pending_.erase(token);pending.erase(token);
|
||||
}else{valid=false;break;}
|
||||
}
|
||||
if(ferror(input))valid=false;fclose(input);
|
||||
if(!valid)return Fail("corrupt journal: preserve bytes, pause issuance and repair tail before resuming");
|
||||
healthy_=true;return true;
|
||||
}
|
||||
bool Intent(const Ava2ShopRequest& r){
|
||||
if(r.operation!=3 || r.token[32] || !Token(std::string(r.token,32)) || !r.account || !r.player || !r.product || !r.count || r.count>1000000 || !r.expectedVnum || r.expectedVnum>255){error_="invalid reward intent";return false;}
|
||||
Entry entry={Canonical(r),static_cast<uint64_t>(time(0))};const auto found=pending_.find(r.token);
|
||||
if(found!=pending_.end() && memcmp(&found->second.request,&entry.request,sizeof(r))!=0){error_="conflicting reward intent";return false;}
|
||||
if(!Append(IntentPayload(entry)))return false;pending_[r.token]=entry;return true;
|
||||
}
|
||||
bool Done(const char* token,uint8_t status,uint32_t granted,int64_t balance){
|
||||
if(!token || strnlen(token,33)!=32 || !Token(std::string(token,32)) || balance<0 || !Terminal(status) || (status!=0 && granted!=0)){error_="invalid reward completion";return false;}
|
||||
const auto found=pending_.find(token);
|
||||
if(found==pending_.end() || granted>found->second.request.count){error_="unknown or excessive reward completion";return false;}
|
||||
std::ostringstream out;out<<"DONE v2 "<<token<<' '<<unsigned(status)<<' '<<granted<<' '<<balance<<' '<<uint64_t(time(0));
|
||||
if(!Append(out.str()))return false;pending_.erase(found);return true;
|
||||
}
|
||||
bool Compact(){
|
||||
if(!healthy_)return false;
|
||||
const std::string temporary=name_+".compact."+std::to_string(getpid());
|
||||
const int next=openat(directory_,temporary.c_str(),O_RDWR|O_CREAT|O_EXCL|O_APPEND|O_NOFOLLOW,0600);
|
||||
if(next<0)return Fail("cannot create journal compact snapshot; original retained");
|
||||
uint64_t size=0;bool valid=flock(next,LOCK_EX|LOCK_NB)==0;
|
||||
for(const auto& entry:pending_){if(!valid)break;const auto line=Record(IntentPayload(entry.second));valid=WriteAll(next,line);size+=line.size();}
|
||||
if(valid)valid=fsync(next)==0;
|
||||
if(!valid){close(next);unlinkat(directory_,temporary.c_str(),0);return Fail("cannot persist journal compact snapshot; original retained");}
|
||||
if(renameat(directory_,temporary.c_str(),directory_,name_.c_str())!=0){close(next);unlinkat(directory_,temporary.c_str(),0);return Fail("cannot publish journal compact snapshot; original retained");}
|
||||
const int previous=fd_;fd_=next;bytes_=size;
|
||||
const bool synced=fsync(directory_)==0;close(previous);
|
||||
if(!synced)return Fail("journal compact directory sync failed; issuance paused; both snapshots retain pending intentions");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
// PORT: supplementary AVA2 pet/rarity state. Classic item packets retain 3 sockets / 7 attributes.
|
||||
#pragma pack(push,1)
|
||||
struct PortItemExtra {
|
||||
int32_t sockets[5];
|
||||
uint8_t types[8];
|
||||
int16_t values[8];
|
||||
char name[25];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(PortItemExtra)==69,"extended item state");
|
||||
|
||||
inline std::string PortItemExtraHex(const PortItemExtra& extra) {
|
||||
static const char digits[]="0123456789abcdef";
|
||||
const auto p=reinterpret_cast<const unsigned char*>(&extra);
|
||||
std::string result(sizeof(extra)*2,'0');
|
||||
for(unsigned i=0;i<sizeof(extra);++i){result[2*i]=digits[p[i]>>4];result[2*i+1]=digits[p[i]&15];}
|
||||
return result;
|
||||
}
|
||||
inline bool PortItemExtraRead(const char* hex,PortItemExtra& extra) {
|
||||
PortItemExtra decoded = {};
|
||||
if(!hex)return false;
|
||||
if(!*hex){extra=decoded;return true;}
|
||||
if(std::strlen(hex)!=sizeof(decoded)*2)return false;
|
||||
auto nibble=[](char c){return c>='0' && c<='9'?c-'0':c>='A' && c<='F'?c-'A'+10:c>='a' && c<='f'?c-'a'+10:-1;};
|
||||
auto p=reinterpret_cast<unsigned char*>(&decoded);
|
||||
for(unsigned i=0;i<sizeof(decoded);++i){int a=nibble(hex[2*i]),b=nibble(hex[2*i+1]);if(a<0 || b<0)return false;p[i]=static_cast<unsigned char>((a<<4)|b);}
|
||||
if(decoded.name[24]!=0)return false;
|
||||
extra=decoded;return true;
|
||||
}
|
||||
@@ -4,8 +4,17 @@
|
||||
#define ENABLE_AUTODETECT_INTERNAL_IP
|
||||
#define ENABLE_PROXY_IP
|
||||
#define ENABLE_PORT_SECURITY
|
||||
#define _IMPROVED_PACKET_ENCRYPTION_ // 패킷 암호화 개선
|
||||
#define _IMPROVED_PACKET_ENCRYPTION_
|
||||
//#define __AUCTION__
|
||||
#define __PET_SYSTEM__
|
||||
#define ENABLE_NEW_PET_SYSTEM
|
||||
#define ENABLE_ATTR_6TH_7TH
|
||||
#define __BL_67_ATTR__
|
||||
#define ENABLE_SPECIAL_STORAGE
|
||||
#define UNLOCK_INVENTORY_WORLDARD
|
||||
#define ENABLE_OFFLINESHOP_SYSTEM
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
#define ENABLE_SHOP_SEARCH_SYSTEM
|
||||
#endif
|
||||
#define __UDP_BLOCK__
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "gold_bounds.h"
|
||||
// Free NPC items are valid. Invalid or unrepresentable quotes never mutate output.
|
||||
inline bool PortShopQuote(int64_t price, bool otherEmpire, int64_t maximum, int64_t& quote) {
|
||||
const int multiplier = otherEmpire ? 3 : 1;
|
||||
if (price < 0 || maximum < 0 || price > maximum / multiplier) return false;
|
||||
quote = price * multiplier;
|
||||
return true;
|
||||
}
|
||||
inline bool PortShopSettlement(int64_t price, int rate, int64_t maximum, int64_t& tax, int64_t& proceeds) {
|
||||
if (price < 0 || price > maximum || rate < 0 || rate > 100) return false;
|
||||
// Quotient/remainder also keeps this valid if the configured maximum grows.
|
||||
tax = (price / 100) * rate + (price % 100) * rate / 100;
|
||||
proceeds = price - tax;
|
||||
return true;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef __INC_METIN_II_STL_H__
|
||||
#define __INC_METIN_II_STL_H__
|
||||
|
||||
#include <cctype>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
@@ -19,7 +20,7 @@
|
||||
inline void stl_lowers(std::string& rstRet)
|
||||
{
|
||||
for (size_t i = 0; i < rstRet.length(); ++i)
|
||||
rstRet[i] = tolower(rstRet[i]);
|
||||
rstRet[i] = static_cast<char>(std::tolower(static_cast<unsigned char>(rstRet[i])));
|
||||
}
|
||||
|
||||
struct stringhash
|
||||
|
||||
+374
-85
@@ -1,3 +1,4 @@
|
||||
#include "port_item_extra.h"
|
||||
#ifndef __INC_TABLES_H__
|
||||
#define __INC_TABLES_H__
|
||||
|
||||
@@ -6,7 +7,7 @@
|
||||
typedef DWORD IDENT;
|
||||
|
||||
/**
|
||||
* @version 05/06/10 Bang2ni - Myshop Pricelist 관련 패킷 HEADER_XX_MYSHOP_PRICELIST_XXX 추가
|
||||
* @version 05/06/10 Bang2ni - Myshop Pricelist 관련 패킷 HEADER_XX_MYSHOP_PRICELIST_XXX 추가
|
||||
*/
|
||||
enum
|
||||
{
|
||||
@@ -104,8 +105,8 @@ enum
|
||||
HEADER_GD_BILLING_CHECK = 106,
|
||||
HEADER_GD_MALL_LOAD = 107,
|
||||
|
||||
HEADER_GD_MYSHOP_PRICELIST_UPDATE = 108, ///< 가격정보 갱신 요청
|
||||
HEADER_GD_MYSHOP_PRICELIST_REQ = 109, ///< 가격정보 리스트 요청
|
||||
HEADER_GD_MYSHOP_PRICELIST_UPDATE = 108, ///< 가격정보 갱신 요청
|
||||
HEADER_GD_MYSHOP_PRICELIST_REQ = 109, ///< 가격정보 리스트 요청
|
||||
|
||||
HEADER_GD_BLOCK_CHAT = 110,
|
||||
|
||||
@@ -116,21 +117,21 @@ enum
|
||||
// END_OF_PCBANG_IP_LIST_BY_AUTH
|
||||
|
||||
HEADER_GD_HAMMER_OF_TOR = 114,
|
||||
HEADER_GD_RELOAD_ADMIN = 115, ///<운영자 정보 요청
|
||||
HEADER_GD_BREAK_MARRIAGE = 116, ///< 결혼 파기
|
||||
HEADER_GD_ELECT_MONARCH = 117, ///< 군주 투표
|
||||
HEADER_GD_CANDIDACY = 118, ///< 군주 등록
|
||||
HEADER_GD_ADD_MONARCH_MONEY = 119, ///< 군주 돈 증가
|
||||
HEADER_GD_TAKE_MONARCH_MONEY = 120, ///< 군주 돈 감소
|
||||
HEADER_GD_COME_TO_VOTE = 121, ///< 표결
|
||||
HEADER_GD_RMCANDIDACY = 122, ///< 후보 제거 (운영자)
|
||||
HEADER_GD_SETMONARCH = 123, ///<군주설정 (운영자)
|
||||
HEADER_GD_RMMONARCH = 124, ///<군주삭제
|
||||
HEADER_GD_RELOAD_ADMIN = 115, ///<운영자 정보 요청
|
||||
HEADER_GD_BREAK_MARRIAGE = 116, ///< 결혼 파기
|
||||
HEADER_GD_ELECT_MONARCH = 117, ///< 군주 투표
|
||||
HEADER_GD_CANDIDACY = 118, ///< 군주 등록
|
||||
HEADER_GD_ADD_MONARCH_MONEY = 119, ///< 군주 돈 증가
|
||||
HEADER_GD_TAKE_MONARCH_MONEY = 120, ///< 군주 돈 감소
|
||||
HEADER_GD_COME_TO_VOTE = 121, ///< 표결
|
||||
HEADER_GD_RMCANDIDACY = 122, ///< 후보 제거 (운영자)
|
||||
HEADER_GD_SETMONARCH = 123, ///<군주설정 (운영자)
|
||||
HEADER_GD_RMMONARCH = 124, ///<군주삭제
|
||||
HEADER_GD_DEC_MONARCH_MONEY = 125,
|
||||
|
||||
HEADER_GD_CHANGE_MONARCH_LORD = 126,
|
||||
HEADER_GD_BLOCK_COUNTRY_IP = 127, // 광대역 IP-Block
|
||||
HEADER_GD_BLOCK_EXCEPTION = 128, // 광대역 IP-Block 예외
|
||||
HEADER_GD_BLOCK_COUNTRY_IP = 127, // 광대역 IP-Block
|
||||
HEADER_GD_BLOCK_EXCEPTION = 128, // 광대역 IP-Block 예외
|
||||
|
||||
HEADER_GD_REQ_CHANGE_GUILD_MASTER = 129,
|
||||
|
||||
@@ -139,7 +140,7 @@ enum
|
||||
HEADER_GD_UPDATE_HORSE_NAME = 131,
|
||||
HEADER_GD_REQ_HORSE_NAME = 132,
|
||||
|
||||
HEADER_GD_DC = 133, // Login Key를 지움
|
||||
HEADER_GD_DC = 133, // Login Key를 지움
|
||||
|
||||
HEADER_GD_VALID_LOGOUT = 134,
|
||||
|
||||
@@ -155,6 +156,9 @@ enum
|
||||
|
||||
HEADER_GD_UPDATE_CHANNELSTATUS = 139,
|
||||
HEADER_GD_REQUEST_CHANNELSTATUS = 140,
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
HEADER_GD_OFFLINESHOP = 146,
|
||||
#endif
|
||||
|
||||
HEADER_GD_SETUP = 0xff,
|
||||
|
||||
@@ -202,6 +206,9 @@ enum
|
||||
HEADER_DG_PARTY_STATE_CHANGE = 63,
|
||||
HEADER_DG_PARTY_HEAL_USE = 64,
|
||||
HEADER_DG_PARTY_SET_MEMBER_LEVEL = 65,
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
HEADER_DG_OFFLINESHOP = 66,
|
||||
#endif
|
||||
|
||||
HEADER_DG_TIME = 90,
|
||||
HEADER_DG_ITEM_ID_RANGE = 91,
|
||||
@@ -257,23 +264,23 @@ enum
|
||||
HEADER_DG_WEDDING_START = 155,
|
||||
HEADER_DG_WEDDING_END = 156,
|
||||
|
||||
HEADER_DG_MYSHOP_PRICELIST_RES = 157, ///< 가격정보 리스트 응답
|
||||
HEADER_DG_RELOAD_ADMIN = 158, ///< 운영자 정보 리로드
|
||||
HEADER_DG_BREAK_MARRIAGE = 159, ///< 결혼 파기
|
||||
HEADER_DG_ELECT_MONARCH = 160, ///< 군주 투표
|
||||
HEADER_DG_CANDIDACY = 161, ///< 군주 등록
|
||||
HEADER_DG_ADD_MONARCH_MONEY = 162, ///< 군주 돈 증가
|
||||
HEADER_DG_TAKE_MONARCH_MONEY = 163, ///< 군주 돈 감소
|
||||
HEADER_DG_COME_TO_VOTE = 164, ///< 표결
|
||||
HEADER_DG_RMCANDIDACY = 165, ///< 후보 제거 (운영자)
|
||||
HEADER_DG_SETMONARCH = 166, ///<군주설정 (운영자)
|
||||
HEADER_DG_RMMONARCH = 167, ///<군주삭제
|
||||
HEADER_DG_MYSHOP_PRICELIST_RES = 157, ///< 가격정보 리스트 응답
|
||||
HEADER_DG_RELOAD_ADMIN = 158, ///< 운영자 정보 리로드
|
||||
HEADER_DG_BREAK_MARRIAGE = 159, ///< 결혼 파기
|
||||
HEADER_DG_ELECT_MONARCH = 160, ///< 군주 투표
|
||||
HEADER_DG_CANDIDACY = 161, ///< 군주 등록
|
||||
HEADER_DG_ADD_MONARCH_MONEY = 162, ///< 군주 돈 증가
|
||||
HEADER_DG_TAKE_MONARCH_MONEY = 163, ///< 군주 돈 감소
|
||||
HEADER_DG_COME_TO_VOTE = 164, ///< 표결
|
||||
HEADER_DG_RMCANDIDACY = 165, ///< 후보 제거 (운영자)
|
||||
HEADER_DG_SETMONARCH = 166, ///<군주설정 (운영자)
|
||||
HEADER_DG_RMMONARCH = 167, ///<군주삭제
|
||||
HEADER_DG_DEC_MONARCH_MONEY = 168,
|
||||
|
||||
HEADER_DG_CHANGE_MONARCH_LORD_ACK = 169,
|
||||
HEADER_DG_UPDATE_MONARCH_INFO = 170,
|
||||
HEADER_DG_BLOCK_COUNTRY_IP = 171, // 광대역 IP-Block
|
||||
HEADER_DG_BLOCK_EXCEPTION = 172, // 광대역 IP-Block 예외 account
|
||||
HEADER_DG_BLOCK_COUNTRY_IP = 171, // 광대역 IP-Block
|
||||
HEADER_DG_BLOCK_EXCEPTION = 172, // 광대역 IP-Block 예외 account
|
||||
|
||||
HEADER_DG_ACK_CHANGE_GUILD_MASTER = 173,
|
||||
|
||||
@@ -393,11 +400,12 @@ typedef struct SPlayerItem
|
||||
DWORD count;
|
||||
|
||||
DWORD vnum;
|
||||
long alSockets[ITEM_SOCKET_MAX_NUM]; // 소켓번호
|
||||
long alSockets[ITEM_SOCKET_MAX_NUM]; // 소켓번호
|
||||
|
||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||
|
||||
DWORD owner;
|
||||
PortItemExtra extra; // PORT: internal game/db state, not a classic client packet.
|
||||
} TPlayerItem;
|
||||
|
||||
typedef struct SQuickslot
|
||||
@@ -437,7 +445,7 @@ typedef struct SPlayerTable
|
||||
short st, ht, dx, iq;
|
||||
|
||||
DWORD exp;
|
||||
INT gold;
|
||||
int64_t gold;
|
||||
|
||||
BYTE dir;
|
||||
INT x, y, z;
|
||||
@@ -486,6 +494,13 @@ typedef struct SPlayerTable
|
||||
DWORD logoff_interval;
|
||||
|
||||
int aiPremiumTimes[PREMIUM_MAX_NUM];
|
||||
|
||||
#ifdef UNLOCK_INVENTORY_WORLDARD
|
||||
DWORD inventory_unlock[UNLOCK_INVENTORY_MAX];
|
||||
#endif
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
unsigned long long shopFlag;
|
||||
#endif
|
||||
} TPlayerTable;
|
||||
|
||||
typedef struct SMobSkillLevel
|
||||
@@ -608,10 +623,11 @@ typedef struct SShopItemTable
|
||||
DWORD vnum;
|
||||
BYTE count;
|
||||
|
||||
TItemPos pos; // PC 상점에만 이용
|
||||
DWORD price; // PC, shop_table_ex.txt 상점에만 이용
|
||||
BYTE display_pos; // PC, shop_table_ex.txt 상점에만 이용, 보일 위치.
|
||||
TItemPos pos; // PC 상점에만 이용
|
||||
int64_t price; // PC, shop_table_ex.txt 상점에만 이용
|
||||
BYTE display_pos; // PC, shop_table_ex.txt 상점에만 이용, 보일 위치.
|
||||
} TShopItemTable;
|
||||
static_assert(sizeof(TShopItemTable)==17,"gold64 private shop wire size");
|
||||
|
||||
typedef struct SShopTable
|
||||
{
|
||||
@@ -674,12 +690,12 @@ typedef struct SItemTable : public SEntityTable
|
||||
BYTE bSpecular;
|
||||
BYTE bGainSocketPct;
|
||||
|
||||
short int sAddonType; // 기본 속성
|
||||
short int sAddonType; // 기본 속성
|
||||
|
||||
// 아래 limit flag들은 realtime에 체크 할 일이 많고, 아이템 VNUM당 고정된 값인데,
|
||||
// 현재 구조대로 매번 아이템마다 필요한 경우에 LIMIT_MAX_NUM까지 루프돌면서 체크하는 부하가 커서 미리 저장 해 둠.
|
||||
char cLimitRealTimeFirstUseIndex; // 아이템 limit 필드값 중에서 LIMIT_REAL_TIME_FIRST_USE 플래그의 위치 (없으면 -1)
|
||||
char cLimitTimerBasedOnWearIndex; // 아이템 limit 필드값 중에서 LIMIT_TIMER_BASED_ON_WEAR 플래그의 위치 (없으면 -1)
|
||||
// 아래 limit flag들은 realtime에 체크 할 일이 많고, 아이템 VNUM당 고정된 값인데,
|
||||
// 현재 구조대로 매번 아이템마다 필요한 경우에 LIMIT_MAX_NUM까지 루프돌면서 체크하는 부하가 커서 미리 저장 해 둠.
|
||||
char cLimitRealTimeFirstUseIndex; // 아이템 limit 필드값 중에서 LIMIT_REAL_TIME_FIRST_USE 플래그의 위치 (없으면 -1)
|
||||
char cLimitTimerBasedOnWearIndex; // 아이템 limit 필드값 중에서 LIMIT_TIMER_BASED_ON_WEAR 플래그의 위치 (없으면 -1)
|
||||
|
||||
} TItemTable;
|
||||
|
||||
@@ -717,7 +733,7 @@ typedef struct SPlayerLoadPacket
|
||||
{
|
||||
DWORD account_id;
|
||||
DWORD player_id;
|
||||
BYTE account_index; /* account 에서의 위치 */
|
||||
BYTE account_index; /* account 에서의 위치 */
|
||||
} TPlayerLoadPacket;
|
||||
|
||||
typedef struct SPlayerCreatePacket
|
||||
@@ -756,7 +772,7 @@ typedef struct SSafeboxTable
|
||||
{
|
||||
DWORD dwID;
|
||||
BYTE bSize;
|
||||
DWORD dwGold;
|
||||
int64_t dwGold;
|
||||
WORD wItemCount;
|
||||
} TSafeboxTable;
|
||||
|
||||
@@ -794,9 +810,9 @@ typedef struct SEmpireSelectPacket
|
||||
typedef struct SPacketGDSetup
|
||||
{
|
||||
char szPublicIP[16]; // Public IP which listen to users
|
||||
BYTE bChannel; // 채널
|
||||
WORD wListenPort; // 클라이언트가 접속하는 포트 번호
|
||||
WORD wP2PPort; // 서버끼리 연결 시키는 P2P 포트 번호
|
||||
BYTE bChannel; // 채널
|
||||
WORD wListenPort; // 클라이언트가 접속하는 포트 번호
|
||||
WORD wP2PPort; // 서버끼리 연결 시키는 P2P 포트 번호
|
||||
long alMaps[32];
|
||||
DWORD dwLoginCount;
|
||||
BYTE bAuthServer;
|
||||
@@ -974,8 +990,8 @@ typedef struct SPacketGuildWar
|
||||
long lInitialScore;
|
||||
} TPacketGuildWar;
|
||||
|
||||
// Game -> DB : 상대적 변화값
|
||||
// DB -> Game : 토탈된 최종값
|
||||
// Game -> DB : 상대적 변화값
|
||||
// DB -> Game : 토탈된 최종값
|
||||
typedef struct SPacketGuildWarScore
|
||||
{
|
||||
DWORD dwGuildGainPoint;
|
||||
@@ -996,8 +1012,8 @@ typedef struct SRefineTable
|
||||
//DWORD result_vnum;
|
||||
DWORD id;
|
||||
BYTE material_count;
|
||||
int cost; // 소요 비용
|
||||
int prob; // 확률
|
||||
int cost; // 소요 비용
|
||||
int prob; // 확률
|
||||
TRefineMaterial materials[REFINE_MATERIAL_MAX_NUM];
|
||||
} TRefineTable;
|
||||
|
||||
@@ -1082,14 +1098,14 @@ typedef struct SPacketGDLoginByKey
|
||||
} TPacketGDLoginByKey;
|
||||
|
||||
/**
|
||||
* @version 05/06/08 Bang2ni - 지속시간 추가
|
||||
* @version 05/06/08 Bang2ni - 지속시간 추가
|
||||
*/
|
||||
typedef struct SPacketGiveGuildPriv
|
||||
{
|
||||
BYTE type;
|
||||
int value;
|
||||
DWORD guild_id;
|
||||
time_t duration_sec; ///< 지속시간
|
||||
time_t duration_sec; ///< 지속시간
|
||||
} TPacketGiveGuildPriv;
|
||||
typedef struct SPacketGiveEmpirePriv
|
||||
{
|
||||
@@ -1124,7 +1140,7 @@ typedef struct SPacketDGChangeCharacterPriv
|
||||
} TPacketDGChangeCharacterPriv;
|
||||
|
||||
/**
|
||||
* @version 05/06/08 Bang2ni - 지속시간 추가
|
||||
* @version 05/06/08 Bang2ni - 지속시간 추가
|
||||
*/
|
||||
typedef struct SPacketDGChangeGuildPriv
|
||||
{
|
||||
@@ -1132,7 +1148,7 @@ typedef struct SPacketDGChangeGuildPriv
|
||||
int value;
|
||||
DWORD guild_id;
|
||||
BYTE bLog;
|
||||
time_t end_time_sec; ///< 지속시간
|
||||
time_t end_time_sec; ///< 지속시간
|
||||
} TPacketDGChangeGuildPriv;
|
||||
|
||||
typedef struct SPacketDGChangeEmpirePriv
|
||||
@@ -1148,31 +1164,31 @@ typedef struct SPacketMoneyLog
|
||||
{
|
||||
BYTE type;
|
||||
DWORD vnum;
|
||||
INT gold;
|
||||
int64_t gold;
|
||||
} TPacketMoneyLog;
|
||||
|
||||
typedef struct SPacketGDGuildMoney
|
||||
{
|
||||
DWORD dwGuild;
|
||||
INT iGold;
|
||||
int64_t iGold;
|
||||
} TPacketGDGuildMoney;
|
||||
|
||||
typedef struct SPacketDGGuildMoneyChange
|
||||
{
|
||||
DWORD dwGuild;
|
||||
INT iTotalGold;
|
||||
int64_t iTotalGold;
|
||||
} TPacketDGGuildMoneyChange;
|
||||
|
||||
typedef struct SPacketDGGuildMoneyWithdraw
|
||||
{
|
||||
DWORD dwGuild;
|
||||
INT iChangeGold;
|
||||
int64_t iChangeGold;
|
||||
} TPacketDGGuildMoneyWithdraw;
|
||||
|
||||
typedef struct SPacketGDGuildMoneyWithdrawGiveReply
|
||||
{
|
||||
DWORD dwGuild;
|
||||
INT iChangeGold;
|
||||
int64_t iChangeGold;
|
||||
BYTE bGiveSuccess;
|
||||
} TPacketGDGuildMoneyWithdrawGiveReply;
|
||||
|
||||
@@ -1313,27 +1329,27 @@ typedef struct
|
||||
DWORD dwPID2;
|
||||
} TPacketWeddingEnd;
|
||||
|
||||
/// 개인상점 가격정보의 헤더. 가변 패킷으로 이 뒤에 byCount 만큼의 TItemPriceInfo 가 온다.
|
||||
/// 개인상점 가격정보의 헤더. 가변 패킷으로 이 뒤에 byCount 만큼의 TItemPriceInfo 가 온다.
|
||||
typedef struct SPacketMyshopPricelistHeader
|
||||
{
|
||||
DWORD dwOwnerID; ///< 가격정보를 가진 플레이어 ID
|
||||
BYTE byCount; ///< 가격정보 갯수
|
||||
DWORD dwOwnerID; ///< 가격정보를 가진 플레이어 ID
|
||||
BYTE byCount; ///< 가격정보 갯수
|
||||
} TPacketMyshopPricelistHeader;
|
||||
|
||||
/// 개인상점의 단일 아이템에 대한 가격정보
|
||||
/// 개인상점의 단일 아이템에 대한 가격정보
|
||||
typedef struct SItemPriceInfo
|
||||
{
|
||||
DWORD dwVnum; ///< 아이템 vnum
|
||||
DWORD dwPrice; ///< 가격
|
||||
DWORD dwVnum; ///< 아이템 vnum
|
||||
DWORD dwPrice; ///< 가격
|
||||
} TItemPriceInfo;
|
||||
|
||||
/// 개인상점 아이템 가격정보 리스트 테이블
|
||||
/// 개인상점 아이템 가격정보 리스트 테이블
|
||||
typedef struct SItemPriceListTable
|
||||
{
|
||||
DWORD dwOwnerID; ///< 가격정보를 가진 플레이어 ID
|
||||
BYTE byCount; ///< 가격정보 리스트의 갯수
|
||||
DWORD dwOwnerID; ///< 가격정보를 가진 플레이어 ID
|
||||
BYTE byCount; ///< 가격정보 리스트의 갯수
|
||||
|
||||
TItemPriceInfo aPriceInfo[SHOP_PRICELIST_MAX_NUM]; ///< 가격정보 리스트
|
||||
TItemPriceInfo aPriceInfo[SHOP_PRICELIST_MAX_NUM]; ///< 가격정보 리스트
|
||||
} TItemPriceListTable;
|
||||
|
||||
typedef struct
|
||||
@@ -1354,12 +1370,12 @@ typedef struct SPacketPCBangIP
|
||||
//ADMIN_MANAGER
|
||||
typedef struct TAdminInfo
|
||||
{
|
||||
int m_ID; //고유ID
|
||||
char m_szAccount[32]; //계정
|
||||
char m_szName[32]; //캐릭터이름
|
||||
char m_szContactIP[16]; //접근아이피
|
||||
char m_szServerIP[16]; //서버아이피
|
||||
int m_Authority; //권한
|
||||
int m_ID; //고유ID
|
||||
char m_szAccount[32]; //계정
|
||||
char m_szName[32]; //캐릭터이름
|
||||
char m_szContactIP[16]; //접근아이피
|
||||
char m_szServerIP[16]; //서버아이피
|
||||
int m_Authority; //권한
|
||||
} tAdminInfo;
|
||||
//END_ADMIN_MANAGER
|
||||
|
||||
@@ -1380,20 +1396,20 @@ typedef struct SPacketReloadAdmin
|
||||
|
||||
typedef struct TMonarchInfo
|
||||
{
|
||||
DWORD pid[4]; // 군주의 PID
|
||||
int64_t money[4]; // 군주의 별개 돈
|
||||
char name[4][32]; // 군주의 이름
|
||||
char date[4][32]; // 군주 등록 날짜
|
||||
DWORD pid[4]; // 군주의 PID
|
||||
int64_t money[4]; // 군주의 별개 돈
|
||||
char name[4][32]; // 군주의 이름
|
||||
char date[4][32]; // 군주 등록 날짜
|
||||
} MonarchInfo;
|
||||
|
||||
typedef struct TMonarchElectionInfo
|
||||
{
|
||||
DWORD pid; // 투표 한사람 PID
|
||||
DWORD selectedpid; // 투표 당한 PID ( 군주 참가자 )
|
||||
char date[32]; // 투표 날짜
|
||||
DWORD pid; // 투표 한사람 PID
|
||||
DWORD selectedpid; // 투표 당한 PID ( 군주 참가자 )
|
||||
char date[32]; // 투표 날짜
|
||||
} MonarchElectionInfo;
|
||||
|
||||
// 군주 출마자
|
||||
// 군주 출마자
|
||||
typedef struct tMonarchCandidacy
|
||||
{
|
||||
DWORD pid;
|
||||
@@ -1465,14 +1481,14 @@ typedef struct tNeedLoginLogInfo
|
||||
DWORD dwPlayerID;
|
||||
} TPacketNeedLoginLogInfo;
|
||||
|
||||
//독일 선물 알림 기능 테스트용 패킷 정보
|
||||
//독일 선물 알림 기능 테스트용 패킷 정보
|
||||
typedef struct tItemAwardInformer
|
||||
{
|
||||
char login[LOGIN_MAX_LEN + 1];
|
||||
char command[20]; //명령어
|
||||
unsigned int vnum; //아이템
|
||||
char command[20]; //명령어
|
||||
unsigned int vnum; //아이템
|
||||
} TPacketItemAwardInfromer;
|
||||
// 선물 알림 기능 삭제용 패킷 정보
|
||||
// 선물 알림 기능 삭제용 패킷 정보
|
||||
typedef struct tDeleteAwardID
|
||||
{
|
||||
DWORD dwID;
|
||||
@@ -1484,5 +1500,278 @@ typedef struct SChannelStatus
|
||||
BYTE bStatus;
|
||||
} TChannelStatus;
|
||||
|
||||
// PORT: AVA2 ENABLE_SWITCHBOT tables (port_switchbot.cpp). TSwitchbotTable goes to the client as is
|
||||
// (SUBHEADER_GC_SWITCHBOT_UPDATE) and between cores (HEADER_GG_SWITCHBOT): 220 bytes.
|
||||
struct TSwitchbotAttributeAlternativeTable
|
||||
{
|
||||
TPlayerItemAttribute attributes[SWITCHBOT_NORM_ATTR_NUM];
|
||||
|
||||
bool IsConfigured() const
|
||||
{
|
||||
|
||||
for (BYTE i = 0; i < SWITCHBOT_NORM_ATTR_NUM; ++i)
|
||||
{
|
||||
if (attributes[i].bType && attributes[i].sValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct TSwitchbotTable
|
||||
{
|
||||
DWORD player_id;
|
||||
bool active[SWITCHBOT_SLOT_COUNT];
|
||||
bool finished[SWITCHBOT_SLOT_COUNT];
|
||||
DWORD items[SWITCHBOT_SLOT_COUNT];
|
||||
TSwitchbotAttributeAlternativeTable alternatives[SWITCHBOT_SLOT_COUNT][SWITCHBOT_ALTERNATIVE_COUNT];
|
||||
|
||||
TSwitchbotTable() : player_id(0)
|
||||
{
|
||||
memset(&items, 0, sizeof(items));
|
||||
memset(&alternatives, 0, sizeof(alternatives));
|
||||
memset(&active, false, sizeof(active));
|
||||
memset(&finished, false, sizeof(finished));
|
||||
}
|
||||
};
|
||||
|
||||
// PORT: AVA2 declares max_value as long; int keeps the 4-byte wire width the client mirrors with LONG.
|
||||
struct TSwitchbottAttributeTable
|
||||
{
|
||||
BYTE attribute_set;
|
||||
int apply_num;
|
||||
int max_value;
|
||||
};
|
||||
|
||||
#ifdef ENABLE_NEW_PET_SYSTEM
|
||||
enum EPetOptions
|
||||
{
|
||||
EPetOption_Followable = 1 << 0,
|
||||
EPetOption_Mountable = 1 << 1,
|
||||
EPetOption_Summonable = 1 << 2,
|
||||
EPetOption_Combatable = 1 << 3,
|
||||
};
|
||||
|
||||
enum m_petMisc
|
||||
{
|
||||
NORMAL_PET = 0,
|
||||
NORMAL_LEVEL_PET = 1,
|
||||
};
|
||||
|
||||
enum EPetPointTypes
|
||||
{
|
||||
POINT_PET_DURATION = 0,
|
||||
POINT_PET_LEVEL = 1,
|
||||
POINT_PET_EXP = 2,
|
||||
POINT_PET_EVOLVE = 3,
|
||||
POINT_PET_SKILLCOUNT = 4,
|
||||
|
||||
POINT_PET_BONUS_1 = 5,
|
||||
POINT_PET_BONUS_2 = 6,
|
||||
POINT_PET_BONUS_3 = 7,
|
||||
|
||||
POINT_PET_SKILL_INDEX_1 = 100,
|
||||
POINT_PET_SKILL_INDEX_2,
|
||||
POINT_PET_SKILL_INDEX_3,
|
||||
POINT_PET_SKILL_INDEX_4,
|
||||
POINT_PET_SKILL_INDEX_5,
|
||||
POINT_PET_SKILL_INDEX_6,
|
||||
POINT_PET_SKILL_INDEX_7,
|
||||
POINT_PET_SKILL_INDEX_8,
|
||||
POINT_PET_SKILL_INDEX_9,
|
||||
POINT_PET_SKILL_INDEX_10,
|
||||
POINT_PET_SKILL_INDEX_11,
|
||||
POINT_PET_SKILL_INDEX_12,
|
||||
POINT_PET_SKILL_INDEX_13,
|
||||
POINT_PET_SKILL_INDEX_14,
|
||||
POINT_PET_SKILL_INDEX_15 = 114,
|
||||
|
||||
POINT_PET_SKILL_LEVEL_1 = 150,
|
||||
POINT_PET_SKILL_LEVEL_2,
|
||||
POINT_PET_SKILL_LEVEL_3,
|
||||
POINT_PET_SKILL_LEVEL_4,
|
||||
POINT_PET_SKILL_LEVEL_5,
|
||||
POINT_PET_SKILL_LEVEL_6,
|
||||
POINT_PET_SKILL_LEVEL_7,
|
||||
POINT_PET_SKILL_LEVEL_8,
|
||||
POINT_PET_SKILL_LEVEL_9,
|
||||
POINT_PET_SKILL_LEVEL_10,
|
||||
POINT_PET_SKILL_LEVEL_11,
|
||||
POINT_PET_SKILL_LEVEL_12,
|
||||
POINT_PET_SKILL_LEVEL_13,
|
||||
POINT_PET_SKILL_LEVEL_14,
|
||||
POINT_PET_SKILL_LEVEL_15 = 164,
|
||||
};
|
||||
|
||||
typedef struct SPetApply
|
||||
{
|
||||
BYTE bType;
|
||||
long lValue;
|
||||
} TPetApply;
|
||||
|
||||
typedef struct SPetSkill
|
||||
{
|
||||
BYTE bType;
|
||||
short sLevel;
|
||||
} TPetSkill;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
typedef struct offline_shop_item
|
||||
{
|
||||
DWORD id;
|
||||
DWORD owner_id;
|
||||
BYTE pos;
|
||||
int count;
|
||||
long long price;
|
||||
DWORD vnum;
|
||||
long alSockets[ITEM_SOCKET_MAX_NUM];
|
||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||
BYTE status;
|
||||
char szBuyerName[CHARACTER_NAME_MAX_LEN+1];
|
||||
#ifdef ENABLE_CHANGELOOK_SYSTEM
|
||||
DWORD transmutation;
|
||||
#endif
|
||||
char szOwnerName[CHARACTER_NAME_MAX_LEN+1];
|
||||
PortItemExtra extra;
|
||||
} OFFLINE_SHOP_ITEM;
|
||||
|
||||
typedef struct ShopLog {
|
||||
char name[CHARACTER_NAME_MAX_LEN+1];
|
||||
char date[25];
|
||||
DWORD itemVnum;
|
||||
DWORD itemCount;
|
||||
long long price;
|
||||
} TShopLog;
|
||||
|
||||
typedef struct SShopDecoration {
|
||||
char sign[SHOP_SIGN_MAX_LEN + 1];
|
||||
DWORD owner_id;
|
||||
BYTE vnum;
|
||||
BYTE type;
|
||||
} TShopDecoration;
|
||||
|
||||
typedef struct SGDOfflineShopCreate
|
||||
{
|
||||
DWORD owner_id;
|
||||
char owner_name[CHARACTER_NAME_MAX_LEN+1];
|
||||
char sign[SHOP_SIGN_MAX_LEN + 1];
|
||||
long x;
|
||||
long y;
|
||||
long z;
|
||||
DWORD mapindex;
|
||||
DWORD type;
|
||||
BYTE channel;
|
||||
unsigned long long slotflag;
|
||||
OFFLINE_SHOP_ITEM items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];
|
||||
long long price;
|
||||
ShopLog log[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];
|
||||
int time;
|
||||
} TOfflineShop;
|
||||
|
||||
typedef struct SOfflineShopBuy
|
||||
{
|
||||
OFFLINE_SHOP_ITEM item;
|
||||
DWORD customer_id;
|
||||
char customer_name[CHARACTER_NAME_MAX_LEN + 1];
|
||||
ShopLog log;
|
||||
int log_index;
|
||||
} TOfflineShopBuy;
|
||||
|
||||
typedef struct SOfflineShopChangeTitle
|
||||
{
|
||||
DWORD owner_id;
|
||||
char sign[SHOP_SIGN_MAX_LEN + 1];
|
||||
} TOfflineShopChangeTitle;
|
||||
|
||||
typedef struct SOfflineShopItemTable
|
||||
{
|
||||
DWORD vnum;
|
||||
int count;
|
||||
TItemPos pos;
|
||||
long long price;
|
||||
BYTE display_pos;
|
||||
} TOfflineShopItemTable;
|
||||
|
||||
typedef struct SOfflineShopAddItem
|
||||
{
|
||||
TItemPos bPos;
|
||||
BYTE bDisplayPos;
|
||||
long long lPrice;
|
||||
} TOfflineShopAddItem;
|
||||
|
||||
typedef struct SOfflineShopOpenSlot
|
||||
{
|
||||
DWORD owner_id;
|
||||
unsigned long long flag;
|
||||
} TOfflineShopOpenSlot;
|
||||
|
||||
typedef struct SOfflineShopBackItem
|
||||
{
|
||||
DWORD owner_id;
|
||||
OFFLINE_SHOP_ITEM items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];
|
||||
} TOfflineShopBackItem;
|
||||
|
||||
enum {
|
||||
// db
|
||||
CREATE_OFFLINESHOP,
|
||||
DESTROY_OFFLINESHOP,
|
||||
REMOVE_ITEM,
|
||||
ADD_ITEM,
|
||||
BUY_ITEM,
|
||||
WITHDRAW_MONEY,
|
||||
CHANGE_TITLE,
|
||||
CLEAR_LOG,
|
||||
CHANGE_DECORATION,
|
||||
CHANGE_OPEN_SLOT,
|
||||
TIME_DONE,
|
||||
GET_BACK_ITEM,
|
||||
ADD_TIME,
|
||||
};
|
||||
|
||||
struct shop_decoration {
|
||||
BYTE subheader;
|
||||
TShopDecoration decoration;
|
||||
};
|
||||
|
||||
struct shop_create {
|
||||
BYTE subheader;
|
||||
TOfflineShop offlineshop;
|
||||
};
|
||||
|
||||
struct shop_buy {
|
||||
BYTE subheader;
|
||||
TOfflineShopBuy buyItem;
|
||||
};
|
||||
|
||||
struct shop_title {
|
||||
BYTE subheader;
|
||||
TOfflineShopChangeTitle title;
|
||||
};
|
||||
|
||||
struct shop_owner {
|
||||
BYTE subheader;
|
||||
DWORD owner_id;
|
||||
};
|
||||
|
||||
struct shop_item {
|
||||
BYTE subheader;
|
||||
OFFLINE_SHOP_ITEM item;
|
||||
};
|
||||
|
||||
struct shop_slot {
|
||||
BYTE subheader;
|
||||
TOfflineShopOpenSlot ch;
|
||||
};
|
||||
|
||||
struct shop_back {
|
||||
BYTE subheader;
|
||||
TOfflineShopBackItem back;
|
||||
};
|
||||
#endif
|
||||
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <cerrno>
|
||||
#include <cstdlib>
|
||||
/*----- atoi function -----*/
|
||||
inline bool str_to_number (bool& out, const char *in)
|
||||
{
|
||||
@@ -73,10 +75,17 @@ inline bool str_to_number (unsigned long& out, const char *in)
|
||||
|
||||
inline bool str_to_number (long long& out, const char *in)
|
||||
{
|
||||
if (0==in || 0==in[0]) return false;
|
||||
|
||||
out = (long long) strtoull(in, NULL, 10);
|
||||
return true;
|
||||
if(!in || !*in)return false;
|
||||
errno=0;char* end=NULL;const long long value=strtoll(in,&end,10);
|
||||
if(errno==ERANGE || end==in || *end)return false;
|
||||
out=value;return true;
|
||||
}
|
||||
inline bool str_to_number (unsigned long long& out, const char *in)
|
||||
{
|
||||
if(!in || !*in || ((*in<'0'||*in>'9')&&*in!='+'))return false;
|
||||
errno=0;char* end=NULL;const unsigned long long value=strtoull(in,&end,10);
|
||||
if(errno==ERANGE || end==in || *end)return false;
|
||||
out=value;return true;
|
||||
}
|
||||
|
||||
inline bool str_to_number (float& out, const char *in)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
// The DB boot stream prefixes each table with two WORDs. Its transport accepts
|
||||
// an int byte length, so validate every count/product before emitting any bytes.
|
||||
class PortBootSizer {
|
||||
uint64_t bytes_;
|
||||
bool valid_;
|
||||
public:
|
||||
explicit PortBootSizer(uint64_t fixed):bytes_(fixed),valid_(fixed<=INT32_MAX){}
|
||||
bool Add(uint64_t count,uint64_t stride) {
|
||||
if(!valid_ || count>UINT16_MAX || stride>UINT16_MAX ||
|
||||
bytes_>INT32_MAX-4 || (count && stride>(INT32_MAX-4-bytes_)/count)) {
|
||||
valid_=false;return false;
|
||||
}
|
||||
bytes_+=4+count*stride;return true;
|
||||
}
|
||||
bool Valid()const{return valid_;}
|
||||
uint32_t Bytes()const{return valid_?static_cast<uint32_t>(bytes_):0;}
|
||||
};
|
||||
@@ -143,7 +143,7 @@ void AuctionManager::LoadAuctionItem()
|
||||
for (int i = 0; i < rows; ++i)
|
||||
{
|
||||
MYSQL_ROW row = mysql_fetch_row(res);
|
||||
TPlayerItem item;
|
||||
TPlayerItem item={};
|
||||
|
||||
int cur = 0;
|
||||
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
// AVA2 GC93 catalogue with transactional, replay-safe purchases.
|
||||
#include "stdafx.h"
|
||||
#include "ClientManager.h"
|
||||
#include "Config.h"
|
||||
#include "DBManager.h"
|
||||
#include "ItemAwardManager.h"
|
||||
#include "../../common/ava2_itemshop.h"
|
||||
#include "../../common/point_drop.h"
|
||||
#include <cerrno>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
namespace {
|
||||
using Query=std::unique_ptr<SQLMsg>;
|
||||
Query query(const std::string& sql) { return Query(CDBManager::instance().DirectQuery(sql.c_str(),SQL_PLAYER)); }
|
||||
bool ok(const Query& q) { return q && !q->uiSQLErrno && q->Get(); }
|
||||
bool run(const std::string& sql) { auto q=query(sql);return ok(q); }
|
||||
std::string decimal(uint64_t n) { return std::to_string(n); }
|
||||
std::string escape(const char* text) { char out[513];size_t n=strnlen(text,255);CDBManager::instance().EscapeString(out,text,n);return std::string(out); }
|
||||
std::string accountDB() {
|
||||
char a[257]={},p[257]={};
|
||||
if (!CConfig::instance().GetValue("SQL_ACCOUNT",a,256) || !CConfig::instance().GetValue("SQL_PLAYER",p,256)) return "";
|
||||
std::string ah,ad,au,ap,ph,pd,pu,pp;int aport=3306,pport=3306;
|
||||
std::istringstream as(a),ps(p);as>>ah>>ad>>au>>ap>>aport;ps>>ph>>pd>>pu>>pp>>pport;
|
||||
if (ah!=ph || aport!=pport || ad.empty()) return ""; // One MySQL connection must own the whole transaction.
|
||||
for (auto c:ad) if (!std::isalnum(static_cast<unsigned char>(c)) && c!='_') return "";
|
||||
return "`"+ad+"`";
|
||||
}
|
||||
bool transactional(const std::string& account) {
|
||||
auto q=query("SELECT COUNT(*) FROM information_schema.tables WHERE ENGINE='InnoDB' AND ((TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('ishop_data','port_itemshop_orders','item_award')) OR (TABLE_SCHEMA='"+account.substr(1,account.size()-2)+"' AND TABLE_NAME='account'))");
|
||||
if (!ok(q) || !q->Get()->uiNumRows)return false;
|
||||
return atoi(mysql_fetch_row(q->Get()->pSQLResult)[0])==4;
|
||||
}
|
||||
struct Transaction {
|
||||
bool active; MYSQL* connection; unsigned previousTimeout;
|
||||
Transaction():active(false),connection(CDBManager::instance().DirectHandle(SQL_PLAYER)),previousTimeout(50) {
|
||||
// A reconnect inside a transaction would silently resume subsequent statements in autocommit.
|
||||
my_bool reconnect=false;mysql_options(connection,MYSQL_OPT_RECONNECT,&reconnect);
|
||||
auto settings=query("SELECT @@session.innodb_lock_wait_timeout");
|
||||
if(!ok(settings) || settings->Get()->uiNumRows!=1)return;
|
||||
previousTimeout=strtoul(mysql_fetch_row(settings->Get()->pSQLResult)[0],0,10);
|
||||
active=run("SET SESSION innodb_lock_wait_timeout=3") && run("START TRANSACTION");
|
||||
}
|
||||
~Transaction(){
|
||||
if(mysql_errno(connection)!=CR_SERVER_LOST && mysql_errno(connection)!=CR_SERVER_GONE_ERROR) {
|
||||
if(active)run("ROLLBACK");
|
||||
if(mysql_errno(connection)!=CR_SERVER_LOST && mysql_errno(connection)!=CR_SERVER_GONE_ERROR)
|
||||
run("SET SESSION innodb_lock_wait_timeout="+decimal(previousTimeout));
|
||||
}
|
||||
my_bool reconnect=true;mysql_options(connection,MYSQL_OPT_RECONNECT,&reconnect);
|
||||
}
|
||||
bool commit(){if(!active || !run("COMMIT"))return false;active=false;return true;}
|
||||
};
|
||||
template<class T>void append(std::vector<char>& out,const T& value){const char* p=reinterpret_cast<const char*>(&value);out.insert(out.end(),p,p+sizeof(value));}
|
||||
void reply(CPeer* peer,DWORD handle,const Ava2ShopRequest& request,const std::vector<char>& out) {
|
||||
if (out.empty() || out.size()>32763)return;
|
||||
Ava2ShopReply h={request.account,request.player,uint32_t(out.size())};
|
||||
peer->EncodeHeader(76,handle,sizeof(h)+out.size());peer->Encode(&h,sizeof(h));peer->Encode(out.data(),out.size());
|
||||
}
|
||||
bool productNumber(const char* text,int64_t& value,int64_t minimum,int64_t maximum) {
|
||||
if(!text || !*text)return false;
|
||||
const char* digits=text;if(*digits=='-' && minimum<0)++digits;
|
||||
if(!*digits)return false;for(const char* p=digits;*p;++p)if(*p<'0'||*p>'9')return false;
|
||||
errno=0;char* end=nullptr;const long long parsed=strtoll(text,&end,10);
|
||||
if(errno==ERANGE || *end || parsed<minimum || parsed>maximum)return false;
|
||||
value=parsed;return true;
|
||||
}
|
||||
Ava2ShopProduct product(MYSQL_ROW r) {
|
||||
Ava2ShopProduct p={};int64_t n[10]={};
|
||||
const int64_t minimum[10]={1,1,0,0,0,0,0,0,0,-1};
|
||||
const int64_t maximum[10]={UINT32_MAX,UINT32_MAX,1000000000000LL,100,INT32_MAX,INT32_MAX,INT64_MAX,INT32_MAX,INT32_MAX,INT32_MAX};
|
||||
if(!r)return p;
|
||||
for(unsigned i=0;i<10;++i)if(!productNumber(r[i],n[i],minimum[i],maximum[i]))return p;
|
||||
p.id=static_cast<uint32_t>(n[0]);p.vnum=static_cast<uint32_t>(n[1]);p.price=n[2];p.discount=static_cast<uint8_t>(n[3]);p.expiry=static_cast<int32_t>(n[4]);p.added=static_cast<int32_t>(n[5]);p.sold=n[6];p.weekly=static_cast<int32_t>(n[7]);p.monthly=static_cast<int32_t>(n[8]);p.stock=static_cast<int32_t>(n[9]);return p;
|
||||
}
|
||||
const char* fields="id,itemVnum,itemPrice,discount,IFNULL(UNIX_TIMESTAMP(offerTime),0),IFNULL(UNIX_TIMESTAMP(addedTime),0),sellCount,week_limit,month_limit,maxSellCount";
|
||||
bool valid(const Ava2ShopProduct& p) {return p.id && p.vnum && p.price>=0 && p.price<=1000000000000LL && p.discount<=100 && p.weekly>=0 && p.monthly>=0 && p.stock>=-1;}
|
||||
}
|
||||
void CClientManager::Ava2ItemShop(CPeer* peer,DWORD handle,const char* data,DWORD length) {
|
||||
if (length!=sizeof(Ava2ShopRequest))return;
|
||||
Ava2ShopRequest r;memcpy(&r,data,sizeof(r));
|
||||
if (r.operation>3 || !r.account || !r.player || r.token[32] || r.name[24] || r.ip[15])return;
|
||||
if(r.operation==3) {
|
||||
// This operation has no client command. Only an authenticated game peer may report a kill.
|
||||
if(!peer->GetChannel() || strlen(r.token)!=32 || r.count<1 || r.count>1000000 || !r.expectedVnum || r.expectedVnum>255)return;
|
||||
for(char c:std::string(r.token))if(!std::isxdigit(static_cast<unsigned char>(c)))return;
|
||||
const std::string adb=accountDB(),aid=decimal(r.account);
|
||||
uint8_t status=6;uint32_t granted=0;int64_t balance=0;
|
||||
auto mob=std::find_if(m_vec_mobTable.begin(),m_vec_mobTable.end(),[&](const TMobTable& m){return m.dwVnum==r.product;});
|
||||
const bool validMob=mob!=m_vec_mobTable.end() && (mob->bType==0 || mob->bType==2);
|
||||
const auto rule=PortPointRule([&](const std::string& key){auto it=m_map_lEventFlag.find(key);return it==m_map_lEventFlag.end()?0:int(it->second);},validMob && mob->bType==2);
|
||||
// Reward replay must remain available after catalogue/mob/rule changes. Only
|
||||
// the two tables participating in this economic transaction are prerequisites.
|
||||
auto engine=adb.empty()?Query():query("SELECT COUNT(*) FROM information_schema.tables WHERE ENGINE='InnoDB' AND ((TABLE_SCHEMA=DATABASE() AND TABLE_NAME='port_point_rewards') OR (TABLE_SCHEMA='"+adb.substr(1,adb.size()-2)+"' AND TABLE_NAME='account'))");
|
||||
if(!adb.empty() && ok(engine) && engine->Get()->uiNumRows==1 && atoi(mysql_fetch_row(engine->Get()->pSQLResult)[0])==2) {
|
||||
Transaction tx;
|
||||
if(tx.active) {
|
||||
auto wallet=query("SELECT coins FROM "+adb+".account WHERE id="+aid+" FOR UPDATE");
|
||||
if(ok(wallet) && wallet->Get()->uiNumRows==0)status=2; // Deleted account: terminal, never retry a new award.
|
||||
else if(ok(wallet) && wallet->Get()->uiNumRows==1) {
|
||||
balance=strtoll(mysql_fetch_row(wallet->Get()->pSQLResult)[0],0,10);
|
||||
auto previous=query("SELECT account_id,vnum,requested,amount,player_id FROM port_point_rewards WHERE token='"+std::string(r.token)+"'");
|
||||
if(ok(previous) && previous->Get()->uiNumRows==1) {
|
||||
auto row=mysql_fetch_row(previous->Get()->pSQLResult);
|
||||
if(strtoul(row[0],0,10)==r.account && strtoul(row[1],0,10)==r.product && strtoul(row[2],0,10)==r.count && strtoul(row[4],0,10)==r.player){granted=strtoul(row[3],0,10);status=0;}else status=7;
|
||||
} else if(ok(previous)) {
|
||||
// Ownership/rules apply to new awards. They must not hide a committed token
|
||||
// after a character deletion/transfer or a live configuration change.
|
||||
auto owner=query("SELECT account_id FROM player WHERE id="+decimal(r.player));
|
||||
if(ok(owner) && (owner->Get()->uiNumRows!=1 || strtoul(mysql_fetch_row(owner->Get()->pSQLResult)[0],0,10)!=r.account))status=2;
|
||||
else if(ok(owner)) {
|
||||
if(!validMob || !rule.eligible(mob->bLevel,r.expectedVnum) || r.count<uint32_t(rule.minimum) || r.count>uint32_t(rule.maximum))status=1;
|
||||
else {
|
||||
auto dateQ=query("SELECT CURDATE()");
|
||||
if(ok(dateQ) && dateQ->Get()->uiNumRows==1) {
|
||||
const std::string rewardDay = mysql_fetch_row(dateQ->Get()->pSQLResult)[0];
|
||||
auto earned=query("SELECT COALESCE(SUM(amount),0) FROM port_point_rewards WHERE account_id="+aid+" AND reward_day='"+rewardDay+"'");
|
||||
if(ok(earned) && earned->Get()->uiNumRows==1) {
|
||||
granted=PortPointDropAmount(r.count,strtoull(mysql_fetch_row(earned->Get()->pSQLResult)[0],0,10),rule.dailyCap);
|
||||
if(balance<0 || uint64_t(balance)>uint64_t(INT64_MAX)-granted){status=1;granted=0;}
|
||||
else {
|
||||
bool success=run("UPDATE "+adb+".account SET coins=coins+"+decimal(granted)+" WHERE id="+aid);
|
||||
success=success && run("INSERT INTO port_point_rewards(token,account_id,player_id,vnum,requested,amount,reward_day) VALUES('"+std::string(r.token)+"',"+aid+","+decimal(r.player)+","+decimal(r.product)+","+decimal(r.count)+","+decimal(granted)+",'"+rewardDay+"')");
|
||||
if(success){if(tx.commit()){balance+=granted;status=0;}else status=8;}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::vector<char> out;append(out,uint8_t(9));append(out,status);out.insert(out.end(),r.token,r.token+32);append(out,granted);append(out,balance);
|
||||
reply(peer,handle,r,out);return;
|
||||
}
|
||||
auto login=GetLoginDataByAID(r.account);
|
||||
if (!login || !login->IsPlay() || login->GetConnectedPeerHandle()!=peer->GetHandle())return;
|
||||
bool owned=false;for (const auto& p:login->GetAccountRef().players)if(p.dwID==r.player)owned=true;
|
||||
if(!owned)return;
|
||||
std::vector<char> out;
|
||||
const std::string adb=accountDB(),aid=decimal(r.account);
|
||||
int64_t balance=0;
|
||||
auto wallet=adb.empty()?Query():query("SELECT coins FROM "+adb+".account WHERE id="+aid);
|
||||
if(!ok(wallet) || wallet->Get()->uiNumRows!=1) {
|
||||
append(out,uint8_t(8));reply(peer,handle,r,out);return;
|
||||
}
|
||||
balance=strtoll(mysql_fetch_row(wallet->Get()->pSQLResult)[0],0,10);
|
||||
if(r.operation==0) {
|
||||
auto rows=query(std::string("SELECT ")+fields+",categoryType,categorySubType FROM ishop_data WHERE enabled=1 ORDER BY categoryType,categorySubType,id LIMIT 511");
|
||||
if (!ok(rows) || rows->Get()->uiNumRows>510) {append(out,uint8_t(8));reply(peer,handle,r,out);return;}
|
||||
std::map<uint8_t,std::map<uint8_t,std::vector<Ava2ShopProduct>>> catalogue;
|
||||
MYSQL_ROW row;
|
||||
while((row=mysql_fetch_row(rows->Get()->pSQLResult))) {
|
||||
auto p=product(row);int64_t cat=0,sub=0;
|
||||
if(!productNumber(row[10],cat,0,7) || !productNumber(row[11],sub,0,9))continue;
|
||||
if(!valid(p) || cat<0 || cat>7 || sub<0 || sub>9 || (!m_map_itemTableByVnum.count(p.vnum) || m_map_itemTableByVnum.at(p.vnum)->bType==ITEM_NONE))continue;
|
||||
catalogue[static_cast<uint8_t>(cat)][static_cast<uint8_t>(sub)].push_back(p);
|
||||
}
|
||||
std::vector<Ava2ShopProduct*> ranked;
|
||||
for(auto& cat:catalogue)for(auto& sub:cat.second)for(auto& p:sub.second)ranked.push_back(&p);
|
||||
std::sort(ranked.begin(),ranked.end(),[](const Ava2ShopProduct* a,const Ava2ShopProduct* b){return a->sold!=b->sold?a->sold>b->sold:a->id<b->id;});
|
||||
for(size_t i=0;i<ranked.size();++i)ranked[i]->top=int32_t(i+1);
|
||||
append(out,uint8_t(0));append(out,balance);append(out,int32_t(time(0)));append(out,int32_t(catalogue.size()));
|
||||
for (auto& cat:catalogue) {
|
||||
append(out,cat.first);append(out,uint8_t(cat.second.size()));
|
||||
for(auto& sub:cat.second) {
|
||||
if(sub.second.size()>255){out.clear();append(out,uint8_t(8));reply(peer,handle,r,out);return;}
|
||||
append(out,sub.first);append(out,uint8_t(sub.second.size()));for(auto& p:sub.second)append(out,p);
|
||||
}
|
||||
}
|
||||
} else if(r.operation==1) {
|
||||
auto rows=query("SELECT player_name,created_at,UNIX_TIMESTAMP(created_at),ip,product,vnum,quantity,paid FROM port_itemshop_orders WHERE account_id="+aid+" ORDER BY id DESC LIMIT 100");
|
||||
if(!ok(rows)){append(out,uint8_t(8));reply(peer,handle,r,out);return;}
|
||||
append(out,uint8_t(1));append(out,int32_t(rows->Get()->uiNumRows));MYSQL_ROW row;
|
||||
while((row=mysql_fetch_row(rows->Get()->pSQLResult))) {
|
||||
Ava2ShopLog log={};log.account=r.account;strlcpy(log.name,row[0],sizeof(log.name));strlcpy(log.date,row[1],sizeof(log.date));log.time=atoi(row[2]);strlcpy(log.ip,row[3],sizeof(log.ip));log.product=strtoul(row[4],0,10);log.vnum=strtoul(row[5],0,10);log.count=atoi(row[6]);log.price=strtoll(row[7],0,10);append(out,log);
|
||||
}
|
||||
} else {
|
||||
if (r.count<1 || r.count>20 || strlen(r.token)!=32)return;
|
||||
for(char c:std::string(r.token))if(!std::isxdigit(static_cast<unsigned char>(c)))return;
|
||||
uint8_t status=6; // unavailable; errors always leave balance/stock/awards untouched
|
||||
if(transactional(adb)) {
|
||||
Transaction tx;
|
||||
if(tx.active) {
|
||||
auto locked=query("SELECT coins FROM "+adb+".account WHERE id="+aid+" FOR UPDATE");
|
||||
if(ok(locked) && locked->Get()->uiNumRows==1) {
|
||||
balance=strtoll(mysql_fetch_row(locked->Get()->pSQLResult)[0],0,10);
|
||||
auto previous=query("SELECT product,quantity,paid,vnum FROM port_itemshop_orders WHERE account_id="+aid+" AND token='"+r.token+"'");
|
||||
if(ok(previous) && previous->Get()->uiNumRows) {
|
||||
auto row=mysql_fetch_row(previous->Get()->pSQLResult);
|
||||
status=(strtoul(row[0],0,10)==r.product && strtoul(row[1],0,10)==r.count && strtoll(row[2],0,10)==r.expectedTotal && strtoul(row[3],0,10)==r.expectedVnum)?0:7;
|
||||
} else if(ok(previous)) {
|
||||
auto rows=query(std::string("SELECT ")+fields+" FROM ishop_data WHERE enabled=1 AND id="+decimal(r.product)+" FOR UPDATE");
|
||||
if(ok(rows) && rows->Get()->uiNumRows==1) {
|
||||
auto p=product(mysql_fetch_row(rows->Get()->pSQLResult));
|
||||
auto proto=m_map_itemTableByVnum.find(p.vnum);
|
||||
if(valid(p) && proto!=m_map_itemTableByVnum.end() && proto->second->bType!=ITEM_NONE) {
|
||||
int64_t price=0;Ava2ShopTotal(p.price,r.count,p.discount,price);
|
||||
status=0;
|
||||
if(price!=r.expectedTotal || p.vnum!=r.expectedVnum)status=9;
|
||||
else if(balance<price || balance<0)status=1;
|
||||
else if(p.stock>=0 && uint32_t(p.stock)<r.count)status=4;
|
||||
else if(p.expiry && time(0)>p.expiry)status=5;
|
||||
if(!status && (p.weekly || p.monthly)) {
|
||||
auto limits=query("SELECT IFNULL(SUM(IF(created_at>=DATE_SUB(CURDATE(),INTERVAL WEEKDAY(CURDATE()) DAY),quantity,0)),0),IFNULL(SUM(quantity),0) FROM port_itemshop_orders WHERE account_id="+aid+" AND product="+decimal(p.id)+" AND created_at>=DATE_FORMAT(NOW(),'%Y-%m-01')-INTERVAL 7 DAY");
|
||||
// Month and week are computed independently across month boundaries.
|
||||
auto month=query("SELECT IFNULL(SUM(quantity),0) FROM port_itemshop_orders WHERE account_id="+aid+" AND product="+decimal(p.id)+" AND created_at>=DATE_FORMAT(NOW(),'%Y-%m-01')");
|
||||
if(!ok(limits)||!ok(month))status=6;
|
||||
else {auto a=mysql_fetch_row(limits->Get()->pSQLResult);auto b=mysql_fetch_row(month->Get()->pSQLResult);if(p.weekly && strtoull(a[0],0,10)+r.count>uint64_t(p.weekly))status=2;else if(p.monthly && strtoull(b[0],0,10)+r.count>uint64_t(p.monthly))status=3;}
|
||||
}
|
||||
if(!status) {
|
||||
bool success=run("UPDATE "+adb+".account SET coins=coins-"+decimal(price)+" WHERE id="+aid) && run("UPDATE ishop_data SET sellCount=sellCount+"+decimal(r.count)+",maxSellCount=IF(maxSellCount<0,-1,maxSellCount-"+decimal(r.count)+") WHERE id="+decimal(p.id));
|
||||
success=success && run("INSERT INTO port_itemshop_orders(account_id,token,product,vnum,quantity,paid,player_name,ip) VALUES("+aid+",'"+r.token+"',"+decimal(p.id)+","+decimal(p.vnum)+","+decimal(r.count)+","+decimal(price)+",'"+escape(r.name)+"','"+escape(login->GetIP())+"')");
|
||||
const bool stackable=(proto->second->dwFlags&ITEM_FLAG_STACKABLE)!=0;
|
||||
for(uint32_t left=r.count;success && left;) {
|
||||
uint32_t count=stackable?left:1;left-=count;
|
||||
success=run("INSERT INTO item_award(login,vnum,count,mall,why,given_time) VALUES('"+escape(login->GetAccountRef().login)+"',"+decimal(p.vnum)+","+decimal(count)+",1,'ISHOP:"+r.token+"',NOW())");
|
||||
}
|
||||
if(success){if(tx.commit())balance-=price;else status=8;}else status=6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
append(out,uint8_t(7));out.insert(out.end(),r.token,r.token+32);append(out,status);append(out,balance);
|
||||
}
|
||||
reply(peer,handle,r,out);
|
||||
}
|
||||
@@ -138,6 +138,9 @@ void CItemCache::OnFlush()
|
||||
p->aAttr[6].bType, p->aAttr[6].sValue);
|
||||
}
|
||||
|
||||
const std::string extraHex=PortItemExtraHex(p->extra);
|
||||
iLen += snprintf(szColumns+iLen,sizeof(szColumns)-iLen,", port_extra");
|
||||
iValueLen += snprintf(szValues+iValueLen,sizeof(szValues)-iValueLen,", X'%s'",extraHex.c_str());
|
||||
char szItemQuery[QUERY_MAX_LEN + QUERY_MAX_LEN];
|
||||
snprintf(szItemQuery, sizeof(szItemQuery), "REPLACE INTO item%s (%s) VALUES(%s)", GetTablePostfix(), szColumns, szValues);
|
||||
|
||||
|
||||
+280
-223
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,19 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p
|
||||
|
||||
class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
{
|
||||
struct EconomyFence { DWORD account=0; bool primed=false,mainDone=false,asyncDone=false,failed=false; uint64_t mainFailures=0,asyncFailures=0; time_t nextAttempt=0; DWORD peer=0,handle=0; TPlayerLoadPacket load={}; };
|
||||
std::map<DWORD,std::pair<uint64_t,uint64_t>> m_economyEnqueueEpoch;
|
||||
std::map<DWORD,EconomyFence> m_economyFences;
|
||||
std::map<DWORD,DWORD> m_economyOwners;
|
||||
std::set<DWORD> m_economyClosed;
|
||||
public:
|
||||
void EconomyRequest(CPeer*,DWORD,const char*,DWORD);
|
||||
bool EconomyBeforeLoad(CPeer*,DWORD,TPlayerLoadPacket*);
|
||||
void EconomyTick();
|
||||
void EconomyMainFence(DWORD,bool);
|
||||
bool EconomySaveAllowed(CPeer*,DWORD);
|
||||
bool EconomyItemWritable(DWORD);
|
||||
bool EconomyCanDelete(DWORD);
|
||||
typedef std::list<CPeer *> TPeerList;
|
||||
typedef std::unordered_map<DWORD, CPlayerTableCache *> TPlayerTableCacheMap;
|
||||
typedef std::unordered_map<DWORD, CItemCache *> TItemCacheMap;
|
||||
@@ -40,10 +52,10 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
typedef std::unordered_map<short, BYTE> TChannelStatusMap;
|
||||
|
||||
// MYSHOP_PRICE_LIST
|
||||
/// 아이템 가격정보 리스트 요청 정보
|
||||
/// 아이템 가격정보 리스트 요청 정보
|
||||
/**
|
||||
* first: Peer handle
|
||||
* second: 요청한 플레이어의 ID
|
||||
* second: 요청한 플레이어의 ID
|
||||
*/
|
||||
typedef std::pair< DWORD, DWORD > TItemPricelistReqInfo;
|
||||
// END_OF_MYSHOP_PRICE_LIST
|
||||
@@ -69,7 +81,7 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
pAccountTable = NULL;
|
||||
player_id = dwPID;
|
||||
};
|
||||
//독일선물기능용 생성자
|
||||
//독일선물기능용 생성자
|
||||
ClientHandleInfo(DWORD argHandle, DWORD dwPID, DWORD accountId)
|
||||
{
|
||||
dwHandle = argHandle;
|
||||
@@ -108,7 +120,7 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
void SetChinaEventServer(bool flag) { m_bChinaEventServer = flag; }
|
||||
bool IsChinaEventServer() { return m_bChinaEventServer; }
|
||||
|
||||
DWORD GetUserCount(); // 접속된 사용자 수를 리턴 한다.
|
||||
DWORD GetUserCount(); // 접속된 사용자 수를 리턴 한다.
|
||||
|
||||
void SendAllGuildSkillRechargePacket();
|
||||
void SendTime();
|
||||
@@ -122,29 +134,30 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
|
||||
CItemCache * GetItemCache(DWORD id);
|
||||
void PutItemCache(TPlayerItem * pNew, bool bSkipQuery = false);
|
||||
bool ValidateLoadedExtra(const TPlayerItem& item,const char* hex) const;
|
||||
bool DeleteItemCache(DWORD id);
|
||||
|
||||
void UpdatePlayerCache();
|
||||
void UpdateItemCache();
|
||||
|
||||
// MYSHOP_PRICE_LIST
|
||||
/// 가격정보 리스트 캐시를 가져온다.
|
||||
/// 가격정보 리스트 캐시를 가져온다.
|
||||
/**
|
||||
* @param [in] dwID 가격정보 리스트의 소유자.(플레이어 ID)
|
||||
* @return 가격정보 리스트 캐시의 포인터
|
||||
* @param [in] dwID 가격정보 리스트의 소유자.(플레이어 ID)
|
||||
* @return 가격정보 리스트 캐시의 포인터
|
||||
*/
|
||||
CItemPriceListTableCache* GetItemPriceListCache(DWORD dwID);
|
||||
|
||||
/// 가격정보 리스트 캐시를 넣는다.
|
||||
/// 가격정보 리스트 캐시를 넣는다.
|
||||
/**
|
||||
* @param [in] pItemPriceList 캐시에 넣을 아이템 가격정보 리스트
|
||||
* @param [in] pItemPriceList 캐시에 넣을 아이템 가격정보 리스트
|
||||
*
|
||||
* 캐시가 이미 있으면 Update 가 아닌 replace 한다.
|
||||
* 캐시가 이미 있으면 Update 가 아닌 replace 한다.
|
||||
*/
|
||||
void PutItemPriceListCache(const TItemPriceListTable* pItemPriceList);
|
||||
|
||||
|
||||
/// Flush 시간이 만료된 아이템 가격정보 리스트 캐시를 Flush 해주고 캐시에서 삭제한다.
|
||||
/// Flush 시간이 만료된 아이템 가격정보 리스트 캐시를 Flush 해주고 캐시에서 삭제한다.
|
||||
void UpdateItemPriceListCache(void);
|
||||
// END_OF_MYSHOP_PRICE_LIST
|
||||
|
||||
@@ -162,8 +175,8 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
|
||||
void SendNotice(const char * c_pszFormat, ...);
|
||||
|
||||
char* GetCommand(char* str); //독일선물기능에서 명령어 얻는 함수
|
||||
void ItemAward(CPeer * peer, char* login); //독일 선물 기능
|
||||
char* GetCommand(char* str); //독일선물기능에서 명령어 얻는 함수
|
||||
void ItemAward(CPeer * peer, char* login); //독일 선물 기능
|
||||
|
||||
protected:
|
||||
void Destroy();
|
||||
@@ -184,9 +197,9 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
bool InitializeObjectTable();
|
||||
bool InitializeMonarch();
|
||||
|
||||
// mob_proto.txt, item_proto.txt에서 읽은 mob_proto, item_proto를 real db에 반영.
|
||||
// item_proto, mob_proto를 db에 반영하지 않아도, 게임 돌아가는데는 문제가 없지만,
|
||||
// 운영툴 등에서 db의 item_proto, mob_proto를 읽어 쓰기 때문에 문제가 발생한다.
|
||||
// mob_proto.txt, item_proto.txt에서 읽은 mob_proto, item_proto를 real db에 반영.
|
||||
// item_proto, mob_proto를 db에 반영하지 않아도, 게임 돌아가는데는 문제가 없지만,
|
||||
// 운영툴 등에서 db의 item_proto, mob_proto를 읽어 쓰기 때문에 문제가 발생한다.
|
||||
bool MirrorMobTableIntoDB();
|
||||
bool MirrorItemTableIntoDB();
|
||||
|
||||
@@ -200,6 +213,7 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
int Process();
|
||||
|
||||
void ProcessPackets(CPeer * peer);
|
||||
void Ava2ItemShop(CPeer* peer, DWORD handle, const char* data, DWORD length);
|
||||
|
||||
CLoginData * GetLoginData(DWORD dwKey);
|
||||
CLoginData * GetLoginDataByLogin(const char * c_pszLogin);
|
||||
@@ -251,20 +265,20 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
// END_PLAYER_INDEX_CREATE_BUG_FIX
|
||||
|
||||
// MYSHOP_PRICE_LIST
|
||||
/// 가격정보 로드 쿼리에 대한 Result 처리
|
||||
/// 가격정보 로드 쿼리에 대한 Result 처리
|
||||
/**
|
||||
* @param peer 가격정보를 요청한 Game server 의 peer 객체 포인터
|
||||
* @param pMsg 쿼리의 Result 로 받은 객체의 포인터
|
||||
* @param peer 가격정보를 요청한 Game server 의 peer 객체 포인터
|
||||
* @param pMsg 쿼리의 Result 로 받은 객체의 포인터
|
||||
*
|
||||
* 로드된 가격정보 리스트를 캐시에 저장하고 peer 에게 리스트를 보내준다.
|
||||
* 로드된 가격정보 리스트를 캐시에 저장하고 peer 에게 리스트를 보내준다.
|
||||
*/
|
||||
void RESULT_PRICELIST_LOAD(CPeer* peer, SQLMsg* pMsg);
|
||||
|
||||
/// 가격정보 업데이트를 위한 로드 쿼리에 대한 Result 처리
|
||||
/// 가격정보 업데이트를 위한 로드 쿼리에 대한 Result 처리
|
||||
/**
|
||||
* @param pMsg 쿼리의 Result 로 받은 객체의 포인터
|
||||
* @param pMsg 쿼리의 Result 로 받은 객체의 포인터
|
||||
*
|
||||
* 로드된 정보로 가격정보 리스트 캐시를 만들고 업데이트 받은 가격정보로 업데이트 한다.
|
||||
* 로드된 정보로 가격정보 리스트 캐시를 만들고 업데이트 받은 가격정보로 업데이트 한다.
|
||||
*/
|
||||
void RESULT_PRICELIST_LOAD_FOR_UPDATE(SQLMsg* pMsg);
|
||||
// END_OF_MYSHOP_PRICE_LIST
|
||||
@@ -344,7 +358,7 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
void SendAllLoginToBilling();
|
||||
void SendLoginToBilling(CLoginData * pkLD, bool bLogin);
|
||||
|
||||
// 결혼
|
||||
// 결혼
|
||||
void MarriageAdd(TPacketMarriageAdd * p);
|
||||
void MarriageUpdate(TPacketMarriageUpdate * p);
|
||||
void MarriageRemove(TPacketMarriageRemove * p);
|
||||
@@ -354,20 +368,20 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
void WeddingEnd(TPacketWeddingEnd * p);
|
||||
|
||||
// MYSHOP_PRICE_LIST
|
||||
// 개인상점 가격정보
|
||||
// 개인상점 가격정보
|
||||
|
||||
/// 아이템 가격정보 리스트 업데이트 패킷(HEADER_GD_MYSHOP_PRICELIST_UPDATE) 처리함수
|
||||
/// 아이템 가격정보 리스트 업데이트 패킷(HEADER_GD_MYSHOP_PRICELIST_UPDATE) 처리함수
|
||||
/**
|
||||
* @param [in] pPacket 패킷 데이터의 포인터
|
||||
* @param [in] pPacket 패킷 데이터의 포인터
|
||||
*/
|
||||
// void MyshopPricelistUpdate(const TPacketMyshopPricelistHeader* pPacket);
|
||||
void MyshopPricelistUpdate(const TItemPriceListTable* pPacket);
|
||||
|
||||
/// 아이템 가격정보 리스트 요청 패킷(HEADER_GD_MYSHOP_PRICELIST_REQ) 처리함수
|
||||
/// 아이템 가격정보 리스트 요청 패킷(HEADER_GD_MYSHOP_PRICELIST_REQ) 처리함수
|
||||
/**
|
||||
* @param peer 패킷을 보낸 Game server 의 peer 객체의 포인터
|
||||
* @param [in] dwHandle 가격정보를 요청한 peer 의 핸들
|
||||
* @param [in] dwPlayerID 가격정보 리스트를 요청한 플레이어의 ID
|
||||
* @param peer 패킷을 보낸 Game server 의 peer 객체의 포인터
|
||||
* @param [in] dwHandle 가격정보를 요청한 peer 의 핸들
|
||||
* @param [in] dwPlayerID 가격정보 리스트를 요청한 플레이어의 ID
|
||||
*/
|
||||
void MyshopPricelistRequest(CPeer* peer, DWORD dwHandle, DWORD dwPlayerID);
|
||||
// END_OF_MYSHOP_PRICE_LIST
|
||||
@@ -387,7 +401,7 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
|
||||
private:
|
||||
int m_looping;
|
||||
socket_t m_fdAccept; // 접속 받는 소켓
|
||||
socket_t m_fdAccept; // 접속 받는 소켓
|
||||
TPeerList m_peerList;
|
||||
|
||||
CPeer * m_pkAuthPeer;
|
||||
@@ -404,7 +418,7 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
typedef std::unordered_map<DWORD, CLoginData *> TLoginDataByAID;
|
||||
TLoginDataByAID m_map_pkLoginDataByAID;
|
||||
|
||||
// Login LoginData pair (실제 로그인 되어있는 계정)
|
||||
// Login LoginData pair (실제 로그인 되어있는 계정)
|
||||
typedef std::unordered_map<std::string, CLoginData *> TLogonAccountMap;
|
||||
TLogonAccountMap m_map_kLogonAccount;
|
||||
|
||||
@@ -436,14 +450,14 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
|
||||
bool m_bShutdowned;
|
||||
|
||||
TPlayerTableCacheMap m_map_playerCache; // 플레이어 id가 key
|
||||
TPlayerTableCacheMap m_map_playerCache; // 플레이어 id가 key
|
||||
|
||||
TItemCacheMap m_map_itemCache; // 아이템 id가 key
|
||||
TItemCacheSetPtrMap m_map_pkItemCacheSetPtr; // 플레이어 id가 key, 이 플레이어가 어떤 아이템 캐쉬를 가지고 있나?
|
||||
TItemCacheMap m_map_itemCache; // 아이템 id가 key
|
||||
TItemCacheSetPtrMap m_map_pkItemCacheSetPtr; // 플레이어 id가 key, 이 플레이어가 어떤 아이템 캐쉬를 가지고 있나?
|
||||
|
||||
// MYSHOP_PRICE_LIST
|
||||
/// 플레이어별 아이템 가격정보 리스트 map. key: 플레이어 ID, value: 가격정보 리스트 캐시
|
||||
TItemPriceListCacheMap m_mapItemPriceListCache; ///< 플레이어별 아이템 가격정보 리스트
|
||||
/// 플레이어별 아이템 가격정보 리스트 map. key: 플레이어 ID, value: 가격정보 리스트 캐시
|
||||
TItemPriceListCacheMap m_mapItemPriceListCache; ///< 플레이어별 아이템 가격정보 리스트
|
||||
// END_OF_MYSHOP_PRICE_LIST
|
||||
|
||||
TChannelStatusMap m_mChannelStatus;
|
||||
@@ -481,7 +495,7 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
|
||||
//BOOT_LOCALIZATION
|
||||
public:
|
||||
/* 로컬 정보 초기화
|
||||
/* 로컬 정보 초기화
|
||||
**/
|
||||
bool InitializeLocalization();
|
||||
|
||||
@@ -548,6 +562,25 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
||||
void DeleteAwardId(TPacketDeleteAwardID* data);
|
||||
void UpdateChannelStatus(TChannelStatus* pData);
|
||||
void RequestChannelStatus(CPeer* peer, DWORD dwHandle);
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
std::map<DWORD, TOfflineShop*> m_Offlineshop;
|
||||
void OfflineShopAssert(TOfflineShop* p);
|
||||
void CreateOfflineShop(TOfflineShop* p);
|
||||
void DeleteOfflineShop(DWORD ownerid);
|
||||
void RemoveItem(OFFLINE_SHOP_ITEM* item);
|
||||
void AddItem(OFFLINE_SHOP_ITEM* item);
|
||||
void BuyItem(TOfflineShopBuy* item);
|
||||
void WithdrawMoney(DWORD ch);
|
||||
void ClearLog(DWORD ch);
|
||||
void ChangeDecoration(TShopDecoration* ch);
|
||||
void ChangeTitle(TOfflineShopChangeTitle* p);
|
||||
void OpenSlot(TOfflineShopOpenSlot* p);
|
||||
void TimeDone(DWORD ch);
|
||||
void GetBackItem(DWORD p);
|
||||
void AddTime(DWORD p);
|
||||
void RecvPackets(const char* data);
|
||||
bool InitializeOfflineShop();
|
||||
#endif
|
||||
#ifdef __AUCTION__
|
||||
void EnrollInAuction (CPeer * peer, DWORD owner_id, AuctionEnrollProductInfo* data);
|
||||
void EnrollInSale (CPeer * peer, DWORD owner_id, AuctionEnrollSaleInfo* data);
|
||||
|
||||
@@ -97,6 +97,13 @@ bool CClientManager::InitializeTables()
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
if (!InitializeOfflineShop())
|
||||
{
|
||||
sys_err("InitializeOfflineShop FAILED");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -111,6 +118,7 @@ bool CClientManager::InitializeRefineTable()
|
||||
|
||||
std::unique_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (pkMsg->uiSQLErrno || !pRes || pRes->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (!pRes->uiNumRows)
|
||||
return true;
|
||||
@@ -122,7 +130,7 @@ bool CClientManager::InitializeRefineTable()
|
||||
m_pRefineTable = NULL;
|
||||
}
|
||||
|
||||
m_iRefineTableSize = pRes->uiNumRows;
|
||||
m_iRefineTableSize = static_cast<int>(pRes->uiNumRows);
|
||||
|
||||
m_pRefineTable = new TRefineTable[m_iRefineTableSize];
|
||||
memset(m_pRefineTable, 0, sizeof(TRefineTable) * m_iRefineTableSize);
|
||||
@@ -171,42 +179,42 @@ class FCompareVnum
|
||||
|
||||
bool CClientManager::InitializeMobTable()
|
||||
{
|
||||
//================== 함수 설명 ==================//
|
||||
//1. 요약 : 'mob_proto.txt', 'mob_proto_test.txt', 'mob_names.txt' 파일을 읽고,
|
||||
// (!)[mob_table] 테이블 오브젝트를 생성한다. (타입 : TMobTable)
|
||||
//2. 순서
|
||||
// 1) 'mob_names.txt' 파일을 읽어서 (a)[localMap](vnum:name) 맵을 만든다.
|
||||
// 2) 'mob_proto_test.txt'파일과 (a)[localMap] 맵으로
|
||||
// (b)[test_map_mobTableByVnum](vnum:TMobTable) 맵을 생성한다.
|
||||
// 3) 'mob_proto.txt' 파일과 (a)[localMap] 맵으로
|
||||
// (!)[mob_table] 테이블을 만든다.
|
||||
// <참고>
|
||||
// 각 row 들 중,
|
||||
// (b)[test_map_mobTableByVnum],(!)[mob_table] 모두에 있는 row는
|
||||
// (b)[test_map_mobTableByVnum]의 것을 사용한다.
|
||||
// 4) (b)[test_map_mobTableByVnum]의 row중, (!)[mob_table]에 없는 것을 추가한다.
|
||||
//3. 테스트
|
||||
// 1)'mob_proto.txt' 정보가 mob_table에 잘 들어갔는지. -> 완료
|
||||
// 2)'mob_names.txt' 정보가 mob_table에 잘 들어갔는지.
|
||||
// 3)'mob_proto_test.txt' 에서 [겹치는] 정보가 mob_table 에 잘 들어갔는지.
|
||||
// 4)'mob_proto_test.txt' 에서 [새로운] 정보가 mob_table 에 잘 들어갔는지.
|
||||
// 5) (최종) 게임 클라이언트에서 제대로 작동 하는지.
|
||||
//================== 함수 설명 ==================//
|
||||
//1. 요약 : 'mob_proto.txt', 'mob_proto_test.txt', 'mob_names.txt' 파일을 읽고,
|
||||
// (!)[mob_table] 테이블 오브젝트를 생성한다. (타입 : TMobTable)
|
||||
//2. 순서
|
||||
// 1) 'mob_names.txt' 파일을 읽어서 (a)[localMap](vnum:name) 맵을 만든다.
|
||||
// 2) 'mob_proto_test.txt'파일과 (a)[localMap] 맵으로
|
||||
// (b)[test_map_mobTableByVnum](vnum:TMobTable) 맵을 생성한다.
|
||||
// 3) 'mob_proto.txt' 파일과 (a)[localMap] 맵으로
|
||||
// (!)[mob_table] 테이블을 만든다.
|
||||
// <참고>
|
||||
// 각 row 들 중,
|
||||
// (b)[test_map_mobTableByVnum],(!)[mob_table] 모두에 있는 row는
|
||||
// (b)[test_map_mobTableByVnum]의 것을 사용한다.
|
||||
// 4) (b)[test_map_mobTableByVnum]의 row중, (!)[mob_table]에 없는 것을 추가한다.
|
||||
//3. 테스트
|
||||
// 1)'mob_proto.txt' 정보가 mob_table에 잘 들어갔는지. -> 완료
|
||||
// 2)'mob_names.txt' 정보가 mob_table에 잘 들어갔는지.
|
||||
// 3)'mob_proto_test.txt' 에서 [겹치는] 정보가 mob_table 에 잘 들어갔는지.
|
||||
// 4)'mob_proto_test.txt' 에서 [새로운] 정보가 mob_table 에 잘 들어갔는지.
|
||||
// 5) (최종) 게임 클라이언트에서 제대로 작동 하는지.
|
||||
//_______________________________________________//
|
||||
|
||||
|
||||
//===============================================//
|
||||
// 1) 'mob_names.txt' 파일을 읽어서 (a)[localMap] 맵을 만든다.
|
||||
//<(a)localMap 맵 생성>
|
||||
// 1) 'mob_names.txt' 파일을 읽어서 (a)[localMap] 맵을 만든다.
|
||||
//<(a)localMap 맵 생성>
|
||||
map<int,const char*> localMap;
|
||||
bool isNameFile = true;
|
||||
//<파일 읽기>
|
||||
//<파일 읽기>
|
||||
cCsvTable nameData;
|
||||
if(!nameData.Load("mob_names.txt",'\t'))
|
||||
{
|
||||
fprintf(stderr, "mob_names.txt 파일을 읽어오지 못했습니다\n");
|
||||
fprintf(stderr, "mob_names.txt 파일을 읽어오지 못했습니다\n");
|
||||
isNameFile = false;
|
||||
} else {
|
||||
nameData.Next(); //설명row 생략.
|
||||
nameData.Next(); //설명row 생략.
|
||||
while(nameData.Next()) {
|
||||
localMap[atoi(nameData.AsStringByIndex(0))] = nameData.AsStringByIndex(1);
|
||||
}
|
||||
@@ -215,35 +223,35 @@ bool CClientManager::InitializeMobTable()
|
||||
|
||||
|
||||
//===============================================//
|
||||
// 2) 'mob_proto_test.txt'파일과 (a)localMap 맵으로
|
||||
// (b)[test_map_mobTableByVnum](vnum:TMobTable) 맵을 생성한다.
|
||||
// 2) 'mob_proto_test.txt'파일과 (a)localMap 맵으로
|
||||
// (b)[test_map_mobTableByVnum](vnum:TMobTable) 맵을 생성한다.
|
||||
//0.
|
||||
set<int> vnumSet; //테스트용 파일 데이터중, 신규여부 확인에 사용.
|
||||
//1. 파일 읽어오기
|
||||
set<int> vnumSet; //테스트용 파일 데이터중, 신규여부 확인에 사용.
|
||||
//1. 파일 읽어오기
|
||||
bool isTestFile = true;
|
||||
cCsvTable test_data;
|
||||
if(!test_data.Load("mob_proto_test.txt",'\t'))
|
||||
{
|
||||
fprintf(stderr, "테스트 파일이 없습니다. 그대로 진행합니다.\n");
|
||||
fprintf(stderr, "테스트 파일이 없습니다. 그대로 진행합니다.\n");
|
||||
isTestFile = false;
|
||||
}
|
||||
//2. (c)[test_map_mobTableByVnum](vnum:TMobTable) 맵 생성.
|
||||
//2. (c)[test_map_mobTableByVnum](vnum:TMobTable) 맵 생성.
|
||||
map<DWORD, TMobTable *> test_map_mobTableByVnum;
|
||||
if (isTestFile) {
|
||||
test_data.Next(); //설명 로우 넘어가기.
|
||||
test_data.Next(); //설명 로우 넘어가기.
|
||||
|
||||
//ㄱ. 테스트 몬스터 테이블 생성.
|
||||
//ㄱ. 테스트 몬스터 테이블 생성.
|
||||
TMobTable * test_mob_table = NULL;
|
||||
int test_MobTableSize = test_data.m_File.GetRowCount()-1;
|
||||
test_mob_table = new TMobTable[test_MobTableSize];
|
||||
memset(test_mob_table, 0, sizeof(TMobTable) * test_MobTableSize);
|
||||
|
||||
//ㄴ. 테스트 몬스터 테이블에 값을 넣고, 맵에까지 넣기.
|
||||
//ㄴ. 테스트 몬스터 테이블에 값을 넣고, 맵에까지 넣기.
|
||||
while(test_data.Next()) {
|
||||
|
||||
if (!Set_Proto_Mob_Table(test_mob_table, test_data, localMap))
|
||||
{
|
||||
fprintf(stderr, "몹 프로토 테이블 셋팅 실패.\n");
|
||||
fprintf(stderr, "몹 프로토 테이블 셋팅 실패.\n");
|
||||
}
|
||||
|
||||
test_map_mobTableByVnum.insert(std::map<DWORD, TMobTable *>::value_type(test_mob_table->dwVnum, test_mob_table));
|
||||
@@ -254,22 +262,22 @@ bool CClientManager::InitializeMobTable()
|
||||
|
||||
}
|
||||
|
||||
// 3) 'mob_proto.txt' 파일과 (a)[localMap] 맵으로
|
||||
// (!)[mob_table] 테이블을 만든다.
|
||||
// <참고>
|
||||
// 각 row 들 중,
|
||||
// (b)[test_map_mobTableByVnum],(!)[mob_table] 모두에 있는 row는
|
||||
// (b)[test_map_mobTableByVnum]의 것을 사용한다.
|
||||
// 3) 'mob_proto.txt' 파일과 (a)[localMap] 맵으로
|
||||
// (!)[mob_table] 테이블을 만든다.
|
||||
// <참고>
|
||||
// 각 row 들 중,
|
||||
// (b)[test_map_mobTableByVnum],(!)[mob_table] 모두에 있는 row는
|
||||
// (b)[test_map_mobTableByVnum]의 것을 사용한다.
|
||||
|
||||
//1. 파일 읽기.
|
||||
//1. 파일 읽기.
|
||||
cCsvTable data;
|
||||
if(!data.Load("mob_proto.txt",'\t')) {
|
||||
fprintf(stderr, "mob_proto.txt 파일을 읽어오지 못했습니다\n");
|
||||
fprintf(stderr, "mob_proto.txt 파일을 읽어오지 못했습니다\n");
|
||||
return false;
|
||||
}
|
||||
data.Next(); //설명 row 넘어가기
|
||||
//2. (!)[mob_table] 생성하기
|
||||
//2.1 새로 추가되는 갯수를 파악
|
||||
data.Next(); //설명 row 넘어가기
|
||||
//2. (!)[mob_table] 생성하기
|
||||
//2.1 새로 추가되는 갯수를 파악
|
||||
int addNumber = 0;
|
||||
while(data.Next()) {
|
||||
int vnum = atoi(data.AsStringByIndex(0));
|
||||
@@ -279,15 +287,15 @@ bool CClientManager::InitializeMobTable()
|
||||
addNumber++;
|
||||
}
|
||||
}
|
||||
//data를 다시 첫줄로 옮긴다.(다시 읽어온다;;)
|
||||
//data를 다시 첫줄로 옮긴다.(다시 읽어온다;;)
|
||||
data.Destroy();
|
||||
if(!data.Load("mob_proto.txt",'\t'))
|
||||
{
|
||||
fprintf(stderr, "mob_proto.txt 파일을 읽어오지 못했습니다\n");
|
||||
fprintf(stderr, "mob_proto.txt 파일을 읽어오지 못했습니다\n");
|
||||
return false;
|
||||
}
|
||||
data.Next(); //맨 윗줄 제외 (아이템 칼럼을 설명하는 부분)
|
||||
//2.2 크기에 맞게 mob_table 생성
|
||||
data.Next(); //맨 윗줄 제외 (아이템 칼럼을 설명하는 부분)
|
||||
//2.2 크기에 맞게 mob_table 생성
|
||||
if (!m_vec_mobTable.empty())
|
||||
{
|
||||
sys_log(0, "RELOAD: mob_proto");
|
||||
@@ -296,18 +304,18 @@ bool CClientManager::InitializeMobTable()
|
||||
m_vec_mobTable.resize(data.m_File.GetRowCount()-1 + addNumber);
|
||||
memset(&m_vec_mobTable[0], 0, sizeof(TMobTable) * m_vec_mobTable.size());
|
||||
TMobTable * mob_table = &m_vec_mobTable[0];
|
||||
//2.3 데이터 채우기
|
||||
//2.3 데이터 채우기
|
||||
while (data.Next())
|
||||
{
|
||||
int col = 0;
|
||||
//(b)[test_map_mobTableByVnum]에 같은 row가 있는지 조사.
|
||||
//(b)[test_map_mobTableByVnum]에 같은 row가 있는지 조사.
|
||||
bool isSameRow = true;
|
||||
std::map<DWORD, TMobTable *>::iterator it_map_mobTable;
|
||||
it_map_mobTable = test_map_mobTableByVnum.find(atoi(data.AsStringByIndex(col)));
|
||||
if(it_map_mobTable == test_map_mobTableByVnum.end()) {
|
||||
isSameRow = false;
|
||||
}
|
||||
//같은 row 가 있으면 (b)에서 읽어온다.
|
||||
//같은 row 가 있으면 (b)에서 읽어온다.
|
||||
if(isSameRow) {
|
||||
TMobTable *tempTable = it_map_mobTable->second;
|
||||
|
||||
@@ -378,13 +386,13 @@ bool CClientManager::InitializeMobTable()
|
||||
|
||||
if (!Set_Proto_Mob_Table(mob_table, data, localMap))
|
||||
{
|
||||
fprintf(stderr, "몹 프로토 테이블 셋팅 실패.\n");
|
||||
fprintf(stderr, "몹 프로토 테이블 셋팅 실패.\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//셋에 vnum 추가
|
||||
//셋에 vnum 추가
|
||||
vnumSet.insert(mob_table->dwVnum);
|
||||
|
||||
|
||||
@@ -395,22 +403,22 @@ bool CClientManager::InitializeMobTable()
|
||||
//_____________________________________________________//
|
||||
|
||||
|
||||
// 4) (b)[test_map_mobTableByVnum]의 row중, (!)[mob_table]에 없는 것을 추가한다.
|
||||
//파일 다시 읽어오기.
|
||||
// 4) (b)[test_map_mobTableByVnum]의 row중, (!)[mob_table]에 없는 것을 추가한다.
|
||||
//파일 다시 읽어오기.
|
||||
test_data.Destroy();
|
||||
isTestFile = true;
|
||||
test_data;
|
||||
if(!test_data.Load("mob_proto_test.txt",'\t'))
|
||||
{
|
||||
fprintf(stderr, "테스트 파일이 없습니다. 그대로 진행합니다.\n");
|
||||
fprintf(stderr, "테스트 파일이 없습니다. 그대로 진행합니다.\n");
|
||||
isTestFile = false;
|
||||
}
|
||||
if(isTestFile) {
|
||||
test_data.Next(); //설명 로우 넘어가기.
|
||||
test_data.Next(); //설명 로우 넘어가기.
|
||||
|
||||
while (test_data.Next()) //테스트 데이터 각각을 훑어나가며,새로운 것을 추가한다.
|
||||
while (test_data.Next()) //테스트 데이터 각각을 훑어나가며,새로운 것을 추가한다.
|
||||
{
|
||||
//중복되는 부분이면 넘어간다.
|
||||
//중복되는 부분이면 넘어간다.
|
||||
set<int>::iterator itVnum;
|
||||
itVnum=vnumSet.find(atoi(test_data.AsStringByIndex(0)));
|
||||
if (itVnum != vnumSet.end()) {
|
||||
@@ -419,7 +427,7 @@ bool CClientManager::InitializeMobTable()
|
||||
|
||||
if (!Set_Proto_Mob_Table(mob_table, test_data, localMap))
|
||||
{
|
||||
fprintf(stderr, "몹 프로토 테이블 셋팅 실패.\n");
|
||||
fprintf(stderr, "몹 프로토 테이블 셋팅 실패.\n");
|
||||
}
|
||||
|
||||
sys_log(0, "MOB #%-5d %-24s %-24s level: %-3u rank: %u empire: %d", mob_table->dwVnum, mob_table->szName, mob_table->szLocaleName, mob_table->bLevel, mob_table->bRank, mob_table->bEmpire);
|
||||
@@ -447,9 +455,10 @@ bool CClientManager::InitializeShopTable()
|
||||
|
||||
std::unique_ptr<SQLMsg> pkMsg2(CDBManager::instance().DirectQuery(s_szQuery));
|
||||
|
||||
// shop의 vnum은 있는데 shop_item 이 없을경우... 실패로 처리되니 주의 요망.
|
||||
// 고처야할부분
|
||||
// shop의 vnum은 있는데 shop_item 이 없을경우... 실패로 처리되니 주의 요망.
|
||||
// 고처야할부분
|
||||
SQLResult * pRes2 = pkMsg2->Get();
|
||||
if (pkMsg2->uiSQLErrno || !pRes2 || pRes2->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (!pRes2->uiNumRows)
|
||||
{
|
||||
@@ -487,7 +496,7 @@ bool CClientManager::InitializeShopTable()
|
||||
|
||||
str_to_number(shop_table->dwNPCVnum, data[col++]);
|
||||
|
||||
if (!data[col]) // 아이템이 하나도 없으면 NULL이 리턴 되므로..
|
||||
if (!data[col]) // 아이템이 하나도 없으면 NULL이 리턴 되므로..
|
||||
continue;
|
||||
|
||||
TShopItemTable * pItem = &shop_table->items[shop_table->byItemCount];
|
||||
@@ -526,6 +535,7 @@ bool CClientManager::InitializeQuestItemTable()
|
||||
|
||||
std::unique_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (pkMsg->uiSQLErrno || !pRes || pRes->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (!pRes->uiNumRows)
|
||||
{
|
||||
@@ -560,7 +570,7 @@ bool CClientManager::InitializeQuestItemTable()
|
||||
continue;
|
||||
}
|
||||
|
||||
tbl.bType = ITEM_QUEST; // quest_item_proto 테이블에 있는 것들은 모두 ITEM_QUEST 유형
|
||||
tbl.bType = ITEM_QUEST; // quest_item_proto 테이블에 있는 것들은 모두 ITEM_QUEST 유형
|
||||
tbl.bSize = 1;
|
||||
|
||||
m_vec_itemTable.push_back(tbl);
|
||||
@@ -571,39 +581,39 @@ bool CClientManager::InitializeQuestItemTable()
|
||||
|
||||
bool CClientManager::InitializeItemTable()
|
||||
{
|
||||
//================== 함수 설명 ==================//
|
||||
//1. 요약 : 'item_proto.txt', 'item_proto_test.txt', 'item_names.txt' 파일을 읽고,
|
||||
// <item_table>(TItemTable), <m_map_itemTableByVnum> 오브젝트를 생성한다.
|
||||
//2. 순서
|
||||
// 1) 'item_names.txt' 파일을 읽어서 (a)[localMap](vnum:name) 맵을 만든다.
|
||||
// 2) 'item_proto_text.txt'파일과 (a)[localMap] 맵으로
|
||||
// (b)[test_map_itemTableByVnum](vnum:TItemTable) 맵을 생성한다.
|
||||
// 3) 'item_proto.txt' 파일과 (a)[localMap] 맵으로
|
||||
// (!)[item_table], <m_map_itemTableByVnum>을 만든다.
|
||||
// <참고>
|
||||
// 각 row 들 중,
|
||||
// (b)[test_map_itemTableByVnum],(!)[mob_table] 모두에 있는 row는
|
||||
// (b)[test_map_itemTableByVnum]의 것을 사용한다.
|
||||
// 4) (b)[test_map_itemTableByVnum]의 row중, (!)[item_table]에 없는 것을 추가한다.
|
||||
//3. 테스트
|
||||
// 1)'item_proto.txt' 정보가 item_table에 잘 들어갔는지. -> 완료
|
||||
// 2)'item_names.txt' 정보가 item_table에 잘 들어갔는지.
|
||||
// 3)'item_proto_test.txt' 에서 [겹치는] 정보가 item_table 에 잘 들어갔는지.
|
||||
// 4)'item_proto_test.txt' 에서 [새로운] 정보가 item_table 에 잘 들어갔는지.
|
||||
// 5) (최종) 게임 클라이언트에서 제대로 작동 하는지.
|
||||
//================== 함수 설명 ==================//
|
||||
//1. 요약 : 'item_proto.txt', 'item_proto_test.txt', 'item_names.txt' 파일을 읽고,
|
||||
// <item_table>(TItemTable), <m_map_itemTableByVnum> 오브젝트를 생성한다.
|
||||
//2. 순서
|
||||
// 1) 'item_names.txt' 파일을 읽어서 (a)[localMap](vnum:name) 맵을 만든다.
|
||||
// 2) 'item_proto_text.txt'파일과 (a)[localMap] 맵으로
|
||||
// (b)[test_map_itemTableByVnum](vnum:TItemTable) 맵을 생성한다.
|
||||
// 3) 'item_proto.txt' 파일과 (a)[localMap] 맵으로
|
||||
// (!)[item_table], <m_map_itemTableByVnum>을 만든다.
|
||||
// <참고>
|
||||
// 각 row 들 중,
|
||||
// (b)[test_map_itemTableByVnum],(!)[mob_table] 모두에 있는 row는
|
||||
// (b)[test_map_itemTableByVnum]의 것을 사용한다.
|
||||
// 4) (b)[test_map_itemTableByVnum]의 row중, (!)[item_table]에 없는 것을 추가한다.
|
||||
//3. 테스트
|
||||
// 1)'item_proto.txt' 정보가 item_table에 잘 들어갔는지. -> 완료
|
||||
// 2)'item_names.txt' 정보가 item_table에 잘 들어갔는지.
|
||||
// 3)'item_proto_test.txt' 에서 [겹치는] 정보가 item_table 에 잘 들어갔는지.
|
||||
// 4)'item_proto_test.txt' 에서 [새로운] 정보가 item_table 에 잘 들어갔는지.
|
||||
// 5) (최종) 게임 클라이언트에서 제대로 작동 하는지.
|
||||
//_______________________________________________//
|
||||
|
||||
|
||||
|
||||
//=================================================================================//
|
||||
// 1) 'item_names.txt' 파일을 읽어서 (a)[localMap](vnum:name) 맵을 만든다.
|
||||
// 1) 'item_names.txt' 파일을 읽어서 (a)[localMap](vnum:name) 맵을 만든다.
|
||||
//=================================================================================//
|
||||
bool isNameFile = true;
|
||||
map<int,const char*> localMap;
|
||||
cCsvTable nameData;
|
||||
if(!nameData.Load("item_names.txt",'\t'))
|
||||
{
|
||||
fprintf(stderr, "item_names.txt 파일을 읽어오지 못했습니다\n");
|
||||
fprintf(stderr, "item_names.txt 파일을 읽어오지 못했습니다\n");
|
||||
isNameFile = false;
|
||||
} else {
|
||||
nameData.Next();
|
||||
@@ -614,32 +624,32 @@ bool CClientManager::InitializeItemTable()
|
||||
//_________________________________________________________________//
|
||||
|
||||
//=================================================================//
|
||||
// 2) 'item_proto_text.txt'파일과 (a)[localMap] 맵으로
|
||||
// (b)[test_map_itemTableByVnum](vnum:TItemTable) 맵을 생성한다.
|
||||
// 2) 'item_proto_text.txt'파일과 (a)[localMap] 맵으로
|
||||
// (b)[test_map_itemTableByVnum](vnum:TItemTable) 맵을 생성한다.
|
||||
//=================================================================//
|
||||
map<DWORD, TItemTable *> test_map_itemTableByVnum;
|
||||
//1. 파일 읽어오기.
|
||||
//1. 파일 읽어오기.
|
||||
cCsvTable test_data;
|
||||
if(!test_data.Load("item_proto_test.txt",'\t'))
|
||||
{
|
||||
fprintf(stderr, "item_proto_test.txt 파일을 읽어오지 못했습니다\n");
|
||||
fprintf(stderr, "item_proto_test.txt 파일을 읽어오지 못했습니다\n");
|
||||
//return false;
|
||||
} else {
|
||||
test_data.Next(); //설명 로우 넘어가기.
|
||||
test_data.Next(); //설명 로우 넘어가기.
|
||||
|
||||
//2. 테스트 아이템 테이블 생성.
|
||||
//2. 테스트 아이템 테이블 생성.
|
||||
TItemTable * test_item_table = NULL;
|
||||
int test_itemTableSize = test_data.m_File.GetRowCount()-1;
|
||||
test_item_table = new TItemTable[test_itemTableSize];
|
||||
memset(test_item_table, 0, sizeof(TItemTable) * test_itemTableSize);
|
||||
|
||||
//3. 테스트 아이템 테이블에 값을 넣고, 맵에까지 넣기.
|
||||
//3. 테스트 아이템 테이블에 값을 넣고, 맵에까지 넣기.
|
||||
while(test_data.Next()) {
|
||||
|
||||
|
||||
if (!Set_Proto_Item_Table(test_item_table, test_data, localMap))
|
||||
{
|
||||
fprintf(stderr, "아이템 프로토 테이블 셋팅 실패.\n");
|
||||
fprintf(stderr, "아이템 프로토 테이블 셋팅 실패.\n");
|
||||
}
|
||||
|
||||
test_map_itemTableByVnum.insert(std::map<DWORD, TItemTable *>::value_type(test_item_table->dwVnum, test_item_table));
|
||||
@@ -651,25 +661,25 @@ bool CClientManager::InitializeItemTable()
|
||||
|
||||
|
||||
//========================================================================//
|
||||
// 3) 'item_proto.txt' 파일과 (a)[localMap] 맵으로
|
||||
// (!)[item_table], <m_map_itemTableByVnum>을 만든다.
|
||||
// <참고>
|
||||
// 각 row 들 중,
|
||||
// (b)[test_map_itemTableByVnum],(!)[mob_table] 모두에 있는 row는
|
||||
// (b)[test_map_itemTableByVnum]의 것을 사용한다.
|
||||
// 3) 'item_proto.txt' 파일과 (a)[localMap] 맵으로
|
||||
// (!)[item_table], <m_map_itemTableByVnum>을 만든다.
|
||||
// <참고>
|
||||
// 각 row 들 중,
|
||||
// (b)[test_map_itemTableByVnum],(!)[mob_table] 모두에 있는 row는
|
||||
// (b)[test_map_itemTableByVnum]의 것을 사용한다.
|
||||
//========================================================================//
|
||||
|
||||
//vnum들을 저장할 셋. 새로운 테스트 아이템을 판별할때 사용된다.
|
||||
//vnum들을 저장할 셋. 새로운 테스트 아이템을 판별할때 사용된다.
|
||||
set<int> vnumSet;
|
||||
|
||||
//파일 읽어오기.
|
||||
//파일 읽어오기.
|
||||
cCsvTable data;
|
||||
if(!data.Load("item_proto.txt",'\t'))
|
||||
{
|
||||
fprintf(stderr, "item_proto.txt 파일을 읽어오지 못했습니다\n");
|
||||
fprintf(stderr, "item_proto.txt 파일을 읽어오지 못했습니다\n");
|
||||
return false;
|
||||
}
|
||||
data.Next(); //맨 윗줄 제외 (아이템 칼럼을 설명하는 부분)
|
||||
data.Next(); //맨 윗줄 제외 (아이템 칼럼을 설명하는 부분)
|
||||
|
||||
if (!m_vec_itemTable.empty())
|
||||
{
|
||||
@@ -678,8 +688,8 @@ bool CClientManager::InitializeItemTable()
|
||||
m_map_itemTableByVnum.clear();
|
||||
}
|
||||
|
||||
//===== 아이템 테이블 생성 =====//
|
||||
//새로 추가되는 갯수를 파악한다.
|
||||
//===== 아이템 테이블 생성 =====//
|
||||
//새로 추가되는 갯수를 파악한다.
|
||||
int addNumber = 0;
|
||||
while(data.Next()) {
|
||||
int vnum = atoi(data.AsStringByIndex(0));
|
||||
@@ -689,14 +699,14 @@ bool CClientManager::InitializeItemTable()
|
||||
addNumber++;
|
||||
}
|
||||
}
|
||||
//data를 다시 첫줄로 옮긴다.(다시 읽어온다;;)
|
||||
//data를 다시 첫줄로 옮긴다.(다시 읽어온다;;)
|
||||
data.Destroy();
|
||||
if(!data.Load("item_proto.txt",'\t'))
|
||||
{
|
||||
fprintf(stderr, "item_proto.txt 파일을 읽어오지 못했습니다\n");
|
||||
fprintf(stderr, "item_proto.txt 파일을 읽어오지 못했습니다\n");
|
||||
return false;
|
||||
}
|
||||
data.Next(); //맨 윗줄 제외 (아이템 칼럼을 설명하는 부분)
|
||||
data.Next(); //맨 윗줄 제외 (아이템 칼럼을 설명하는 부분)
|
||||
|
||||
m_vec_itemTable.resize(data.m_File.GetRowCount() - 1 + addNumber);
|
||||
memset(&m_vec_itemTable[0], 0, sizeof(TItemTable) * m_vec_itemTable.size());
|
||||
@@ -711,16 +721,16 @@ bool CClientManager::InitializeItemTable()
|
||||
std::map<DWORD, TItemTable *>::iterator it_map_itemTable;
|
||||
it_map_itemTable = test_map_itemTableByVnum.find(atoi(data.AsStringByIndex(col)));
|
||||
if(it_map_itemTable == test_map_itemTableByVnum.end()) {
|
||||
//각 칼럼 데이터 저장
|
||||
//각 칼럼 데이터 저장
|
||||
|
||||
if (!Set_Proto_Item_Table(item_table, data, localMap))
|
||||
{
|
||||
fprintf(stderr, "아이템 프로토 테이블 셋팅 실패.\n");
|
||||
fprintf(stderr, "아이템 프로토 테이블 셋팅 실패.\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else { //$$$$$$$$$$$$$$$$$$$$$$$ 테스트 아이템 정보가 있다!
|
||||
} else { //$$$$$$$$$$$$$$$$$$$$$$$ 테스트 아이템 정보가 있다!
|
||||
TItemTable *tempTable = it_map_itemTable->second;
|
||||
|
||||
item_table->dwVnum = tempTable->dwVnum;
|
||||
@@ -777,19 +787,19 @@ bool CClientManager::InitializeItemTable()
|
||||
//_______________________________________________________________________//
|
||||
|
||||
//========================================================================//
|
||||
// 4) (b)[test_map_itemTableByVnum]의 row중, (!)[item_table]에 없는 것을 추가한다.
|
||||
// 4) (b)[test_map_itemTableByVnum]의 row중, (!)[item_table]에 없는 것을 추가한다.
|
||||
//========================================================================//
|
||||
test_data.Destroy();
|
||||
if(!test_data.Load("item_proto_test.txt",'\t'))
|
||||
{
|
||||
fprintf(stderr, "item_proto_test.txt 파일을 읽어오지 못했습니다\n");
|
||||
fprintf(stderr, "item_proto_test.txt 파일을 읽어오지 못했습니다\n");
|
||||
//return false;
|
||||
} else {
|
||||
test_data.Next(); //설명 로우 넘어가기.
|
||||
test_data.Next(); //설명 로우 넘어가기.
|
||||
|
||||
while (test_data.Next()) //테스트 데이터 각각을 훑어나가며,새로운 것을 추가한다.
|
||||
while (test_data.Next()) //테스트 데이터 각각을 훑어나가며,새로운 것을 추가한다.
|
||||
{
|
||||
//중복되는 부분이면 넘어간다.
|
||||
//중복되는 부분이면 넘어간다.
|
||||
set<int>::iterator itVnum;
|
||||
itVnum=vnumSet.find(atoi(test_data.AsStringByIndex(0)));
|
||||
if (itVnum != vnumSet.end()) {
|
||||
@@ -798,7 +808,7 @@ bool CClientManager::InitializeItemTable()
|
||||
|
||||
if (!Set_Proto_Item_Table(item_table, test_data, localMap))
|
||||
{
|
||||
fprintf(stderr, "아이템 프로토 테이블 셋팅 실패.\n");
|
||||
fprintf(stderr, "아이템 프로토 테이블 셋팅 실패.\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -815,6 +825,8 @@ bool CClientManager::InitializeItemTable()
|
||||
// InitializeQuestItemTable();
|
||||
// END_OF_QUEST_ITEM_PROTO_DISABLE
|
||||
|
||||
// Build pointers only after sorting; otherwise each key can point to another prototype.
|
||||
sort(m_vec_itemTable.begin(), m_vec_itemTable.end(), FCompareVnum());
|
||||
m_map_itemTableByVnum.clear();
|
||||
|
||||
itertype(m_vec_itemTable) it = m_vec_itemTable.begin();
|
||||
@@ -842,7 +854,6 @@ bool CClientManager::InitializeItemTable()
|
||||
|
||||
m_map_itemTableByVnum.insert(std::map<DWORD, TItemTable *>::value_type(item_table->dwVnum, item_table));
|
||||
}
|
||||
sort(m_vec_itemTable.begin(), m_vec_itemTable.end(), FCompareVnum());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -862,6 +873,7 @@ bool CClientManager::InitializeSkillTable()
|
||||
|
||||
std::unique_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (pkMsg->uiSQLErrno || !pRes || pRes->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (!pRes->uiNumRows)
|
||||
{
|
||||
@@ -875,7 +887,7 @@ bool CClientManager::InitializeSkillTable()
|
||||
m_vec_skillTable.clear();
|
||||
}
|
||||
|
||||
m_vec_skillTable.reserve(pRes->uiNumRows);
|
||||
m_vec_skillTable.reserve(static_cast<size_t>(pRes->uiNumRows));
|
||||
|
||||
MYSQL_ROW data;
|
||||
int col;
|
||||
@@ -944,6 +956,7 @@ bool CClientManager::InitializeBanwordTable()
|
||||
std::unique_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery("SELECT word FROM banword"));
|
||||
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (pkMsg->uiSQLErrno || !pRes || pRes->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (pRes->uiNumRows == 0)
|
||||
return true;
|
||||
@@ -974,6 +987,7 @@ bool CClientManager::InitializeItemAttrTable()
|
||||
|
||||
std::unique_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (pkMsg->uiSQLErrno || !pRes || pRes->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (!pRes->uiNumRows)
|
||||
{
|
||||
@@ -987,7 +1001,7 @@ bool CClientManager::InitializeItemAttrTable()
|
||||
m_vec_itemAttrTable.clear();
|
||||
}
|
||||
|
||||
m_vec_itemAttrTable.reserve(pRes->uiNumRows);
|
||||
m_vec_itemAttrTable.reserve(static_cast<size_t>(pRes->uiNumRows));
|
||||
|
||||
MYSQL_ROW data;
|
||||
|
||||
@@ -1048,6 +1062,7 @@ bool CClientManager::InitializeItemRareTable()
|
||||
|
||||
std::unique_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (pkMsg->uiSQLErrno || !pRes || pRes->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (!pRes->uiNumRows)
|
||||
{
|
||||
@@ -1061,7 +1076,7 @@ bool CClientManager::InitializeItemRareTable()
|
||||
m_vec_itemRareTable.clear();
|
||||
}
|
||||
|
||||
m_vec_itemRareTable.reserve(pRes->uiNumRows);
|
||||
m_vec_itemRareTable.reserve(static_cast<size_t>(pRes->uiNumRows));
|
||||
|
||||
MYSQL_ROW data;
|
||||
|
||||
@@ -1126,6 +1141,7 @@ bool CClientManager::InitializeLandTable()
|
||||
|
||||
std::unique_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (pkMsg->uiSQLErrno || !pRes || pRes->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (!m_vec_kLandTable.empty())
|
||||
{
|
||||
@@ -1133,7 +1149,7 @@ bool CClientManager::InitializeLandTable()
|
||||
m_vec_kLandTable.clear();
|
||||
}
|
||||
|
||||
m_vec_kLandTable.reserve(pRes->uiNumRows);
|
||||
m_vec_kLandTable.reserve(static_cast<size_t>(pRes->uiNumRows));
|
||||
|
||||
MYSQL_ROW data;
|
||||
|
||||
@@ -1229,6 +1245,7 @@ bool CClientManager::InitializeObjectProto()
|
||||
|
||||
std::unique_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (pkMsg->uiSQLErrno || !pRes || pRes->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (!m_vec_kObjectProto.empty())
|
||||
{
|
||||
@@ -1236,7 +1253,7 @@ bool CClientManager::InitializeObjectProto()
|
||||
m_vec_kObjectProto.clear();
|
||||
}
|
||||
|
||||
m_vec_kObjectProto.reserve(MAX(0, pRes->uiNumRows));
|
||||
m_vec_kObjectProto.reserve(static_cast<size_t>(pRes->uiNumRows));
|
||||
|
||||
MYSQL_ROW data;
|
||||
|
||||
@@ -1298,6 +1315,7 @@ bool CClientManager::InitializeObjectTable()
|
||||
|
||||
std::unique_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (pkMsg->uiSQLErrno || !pRes || pRes->uiNumRows > UINT16_MAX) { sys_err("boot table query failed or exceeds 16-bit wire count"); return false; }
|
||||
|
||||
if (!m_map_pkObjectTable.empty())
|
||||
{
|
||||
|
||||
@@ -435,7 +435,7 @@ void CClientManager::RESULT_LOGIN(CPeer * peer, SQLMsg * msg)
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_log(0, "RESULT_LOGIN: login success %s rows: %lu", info->pAccountTable->login, msg->Get()->uiNumRows);
|
||||
sys_log(0, "RESULT_LOGIN: login success %s rows: %llu", info->pAccountTable->login, static_cast<unsigned long long>(msg->Get()->uiNumRows));
|
||||
|
||||
if (msg->Get()->uiNumRows > 0)
|
||||
CreateAccountPlayerDataFromRes(msg->Get()->pSQLResult, info->pAccountTable);
|
||||
|
||||
@@ -0,0 +1,757 @@
|
||||
#include "stdafx.h"
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
#include "ClientManager.h"
|
||||
#include "../../common/offline_shop_safety.h"
|
||||
|
||||
void InsertImportLog(const char* logReason, TOfflineShop* p, DWORD targetPID, const char* targetName, const OFFLINE_SHOP_ITEM* item)
|
||||
{
|
||||
char szQuery[QUERY_MAX_LEN];
|
||||
snprintf(szQuery, sizeof(szQuery), "INSERT INTO offline_shop_log_important(reason, owner_id, owner, target_id, target, itemid, itemvnum, itemcount, price, date) VALUES('%s', %u, '%s', %u, '%s', %u, %u, %d, %lld, NOW())",
|
||||
logReason, p ? p->owner_id : 0, p ? p->owner_name : "Noname", targetPID, targetName, item? item->id : 0,item ? item->vnum : 0, item ? item->count : 0, item ? item->price : 0);
|
||||
std::unique_ptr<SQLMsg> pMsgPrice(CDBManager::instance().DirectQuery(szQuery));
|
||||
}
|
||||
|
||||
void CClientManager::OfflineShopAssert(TOfflineShop* p){}
|
||||
|
||||
bool CClientManager::InitializeOfflineShop()
|
||||
{
|
||||
if(!PortOfflineShopEconomyReady())return true; // Do not run legacy expiry/delete cleanup on stored custody.
|
||||
MYSQL_ROW row;
|
||||
//for (size_t j = 1; j <= channelcount; j++)
|
||||
{
|
||||
MYSQL_ROW row_item;
|
||||
char szQuery[QUERY_MAX_LEN];
|
||||
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery("SELECT * FROM offline_shop_npc"));
|
||||
if (pMsg && pMsg->Get()->uiNumRows != 0)
|
||||
{
|
||||
while (NULL != (row = mysql_fetch_row(pMsg->Get()->pSQLResult)))
|
||||
{
|
||||
TOfflineShop* offlineshop = new TOfflineShop;
|
||||
|
||||
memset(offlineshop, 0, sizeof(TOfflineShop));
|
||||
memset(&offlineshop->items, 0, sizeof(OFFLINE_SHOP_ITEM)*OFFLINE_SHOP_HOST_ITEM_MAX_NUM);
|
||||
memset(&offlineshop->log, 0, sizeof(ShopLog)*OFFLINE_SHOP_HOST_ITEM_MAX_NUM);
|
||||
|
||||
str_to_number(offlineshop->owner_id, row[0]);
|
||||
strlcpy(offlineshop->owner_name, row[1], sizeof(offlineshop->owner_name));
|
||||
strlcpy(offlineshop->sign, row[2], sizeof(offlineshop->sign));
|
||||
str_to_number(offlineshop->x, row[3]);
|
||||
str_to_number(offlineshop->y, row[4]);
|
||||
str_to_number(offlineshop->z, row[5]);
|
||||
str_to_number(offlineshop->mapindex, row[6]);
|
||||
str_to_number(offlineshop->type, row[7]);
|
||||
str_to_number(offlineshop->channel, row[8]);
|
||||
str_to_number(offlineshop->slotflag, row[9]);
|
||||
str_to_number(offlineshop->time, row[10]);
|
||||
|
||||
snprintf(szQuery, sizeof(szQuery), "SELECT shop_money FROM player WHERE id = %u", offlineshop->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsgPrice(CDBManager::instance().DirectQuery(szQuery));
|
||||
if (pMsgPrice->Get()->uiNumRows != 0)
|
||||
{
|
||||
MYSQL_ROW price = mysql_fetch_row(pMsgPrice->Get()->pSQLResult);
|
||||
str_to_number(offlineshop->price, price[0]);
|
||||
}
|
||||
else
|
||||
offlineshop->price = 0;
|
||||
|
||||
int iLen = snprintf(szQuery, sizeof(szQuery), "SELECT id,owner_id,pos,count,vnum");
|
||||
for (int j = 0; j < ITEM_SOCKET_MAX_NUM; j++)
|
||||
iLen+=snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ",socket%d",j);
|
||||
for (int j = 0; j < ITEM_ATTRIBUTE_MAX_NUM; j++)
|
||||
iLen+=snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ",attrtype%d,attrvalue%d",j,j);
|
||||
iLen+=snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ",price,status,ownername,buyername,HEX(port_extra)");
|
||||
#ifdef ENABLE_CHANGELOOK_SYSTEM
|
||||
iLen+=snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ",transmutation");
|
||||
#endif
|
||||
iLen+=snprintf(szQuery+iLen, sizeof(szQuery)-iLen, " FROM offline_shop_item WHERE owner_id = %u", offlineshop->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
int cur = 0;
|
||||
BYTE pos = 0;
|
||||
if (pMsg2 && pMsg2->Get()->uiNumRows != 0)
|
||||
{
|
||||
while (NULL != (row_item = mysql_fetch_row(pMsg2->Get()->pSQLResult)))
|
||||
{
|
||||
cur = 0;
|
||||
str_to_number(pos, row_item[2]);
|
||||
if (pos >= OFFLINE_SHOP_HOST_ITEM_MAX_NUM)
|
||||
continue;
|
||||
OFFLINE_SHOP_ITEM& item = offlineshop->items[pos];
|
||||
str_to_number(item.id, row_item[cur++]);
|
||||
str_to_number(item.owner_id, row_item[cur++]);
|
||||
str_to_number(item.pos, row_item[cur++]);
|
||||
str_to_number(item.count, row_item[cur++]);
|
||||
str_to_number(item.vnum, row_item[cur++]);
|
||||
for (int j = 0; j < ITEM_SOCKET_MAX_NUM; j++)
|
||||
str_to_number(item.alSockets[j], row_item[cur++]);
|
||||
for (int j = 0; j < ITEM_ATTRIBUTE_MAX_NUM; j++)
|
||||
{
|
||||
str_to_number(item.aAttr[j].bType, row_item[cur++]);
|
||||
str_to_number(item.aAttr[j].sValue, row_item[cur++]);
|
||||
}
|
||||
str_to_number(item.price, row_item[cur++]);
|
||||
str_to_number(item.status, row_item[cur++]);
|
||||
strlcpy(item.szOwnerName, row_item[cur++], sizeof(item.szOwnerName));
|
||||
strlcpy(item.szBuyerName, row_item[cur++], sizeof(item.szBuyerName));
|
||||
if(!PortItemExtraRead(row_item[cur++],item.extra)){sys_err("OFFLINE_EXTRA_QUARANTINE id=%u",item.id);return false;}
|
||||
#ifdef ENABLE_CHANGELOOK_SYSTEM
|
||||
str_to_number(item.transmutation, row_item[cur++]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool status = false;
|
||||
for (DWORD i = 0; i < OFFLINE_SHOP_HOST_ITEM_MAX_NUM; ++i)
|
||||
{
|
||||
if (offlineshop->items[i].vnum != 0 && offlineshop->items[i].status == 0)
|
||||
{
|
||||
status = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!status)
|
||||
{
|
||||
char szQuery[1024];
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_npc WHERE owner_id = %u", offlineshop->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_item WHERE owner_id = %u", offlineshop->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg1(CDBManager::instance().DirectQuery(szQuery));
|
||||
delete offlineshop;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int i = 0;
|
||||
snprintf(szQuery, sizeof(szQuery), "SELECT target, time, itemvnum, itemcount, price FROM offline_shop_log WHERE owner_id = %u", offlineshop->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg5(CDBManager::instance().DirectQuery(szQuery));
|
||||
if (pMsg5 && pMsg5->Get()->uiNumRows != 0)
|
||||
{
|
||||
MYSQL_ROW log_row = NULL;
|
||||
while ((log_row = mysql_fetch_row(pMsg5->Get()->pSQLResult)))
|
||||
{
|
||||
strlcpy(offlineshop->log[i].name, log_row[0], sizeof(offlineshop->log[i].name));
|
||||
strlcpy(offlineshop->log[i].date, log_row[1], sizeof(offlineshop->log[i].date));
|
||||
str_to_number(offlineshop->log[i].itemVnum, log_row[2]);
|
||||
str_to_number(offlineshop->log[i].itemCount, log_row[3]);
|
||||
str_to_number(offlineshop->log[i].price, log_row[4]);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
sys_log(0, "shop insert: owner_id: %u, owner_name: %s, sign: %s,x: %ld,y: %ld,mapIndex: %u, channel: %d",
|
||||
offlineshop->owner_id, offlineshop->owner_name, offlineshop->sign, offlineshop->x, offlineshop->y, offlineshop->mapindex, offlineshop->channel);
|
||||
|
||||
m_Offlineshop.insert(std::make_pair(offlineshop->owner_id, offlineshop));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CClientManager::CreateOfflineShop(TOfflineShop* p)
|
||||
{
|
||||
if(!PortOfflineShopEconomyReady())return;
|
||||
if (!p)
|
||||
return;
|
||||
auto it = m_Offlineshop.find(p->owner_id);
|
||||
if (it != m_Offlineshop.end())
|
||||
{
|
||||
sys_err("wtf, this guy have offlineshop???????????? owner id %d name %s", p->owner_id, p->owner_name);
|
||||
OfflineShopAssert(p);// save player items...
|
||||
return;
|
||||
}
|
||||
|
||||
int iLen = 0, iUpdateLen = 0;
|
||||
char szQuery[QUERY_MAX_LEN], szColumns[QUERY_MAX_LEN], szValues[QUERY_MAX_LEN];
|
||||
TOfflineShop* offlineshop = new TOfflineShop;
|
||||
thecore_memcpy(offlineshop, p, sizeof(TOfflineShop));
|
||||
m_Offlineshop.insert(std::make_pair(offlineshop->owner_id, offlineshop));
|
||||
|
||||
snprintf(szQuery, sizeof(szQuery), "SELECT shop_money FROM player WHERE id = %u", offlineshop->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsgPrice(CDBManager::instance().DirectQuery(szQuery));
|
||||
if (pMsgPrice->Get()->uiNumRows != 0)
|
||||
{
|
||||
MYSQL_ROW price = mysql_fetch_row(pMsgPrice->Get()->pSQLResult);
|
||||
str_to_number(offlineshop->price, price[0]);
|
||||
}
|
||||
else
|
||||
offlineshop->price = 0;
|
||||
|
||||
snprintf(szQuery, sizeof(szQuery), "INSERT INTO offline_shop_npc(owner_id, owner_name, sign, x, y, z, mapindex, type, channel, slotflag, time) VALUES(%u, '%s', '%s', %ld, %ld, %ld, %u, %d, %d, %lld, %d)",
|
||||
offlineshop->owner_id, offlineshop->owner_name, offlineshop->sign, offlineshop->x, offlineshop->y, offlineshop->z, offlineshop->mapindex, offlineshop->type, offlineshop->channel, offlineshop->slotflag, offlineshop->time);
|
||||
std::unique_ptr<SQLMsg> pMsg(CDBManager::Instance().DirectQuery(szQuery));
|
||||
for (DWORD i = 0; i < OFFLINE_SHOP_HOST_ITEM_MAX_NUM; ++i)
|
||||
{
|
||||
if (p->items[i].vnum == 0)
|
||||
continue;
|
||||
|
||||
iLen = snprintf(szColumns, sizeof(szColumns), "id,owner_id,pos,count,price,vnum");
|
||||
iUpdateLen = snprintf(szValues, sizeof(szValues), "%u,%u,%d,%d,%lld,%u", offlineshop->items[i].id, offlineshop->items[i].owner_id, offlineshop->items[i].pos, offlineshop->items[i].count, offlineshop->items[i].price, offlineshop->items[i].vnum);
|
||||
|
||||
for(BYTE j=0;j<ITEM_SOCKET_MAX_NUM;++j)
|
||||
{
|
||||
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ",socket%d",j);
|
||||
iUpdateLen += snprintf(szValues + iUpdateLen, sizeof(szValues) - iUpdateLen, ",%ld", offlineshop->items[i].alSockets[j]);
|
||||
}
|
||||
|
||||
for(BYTE j=0;j<ITEM_ATTRIBUTE_MAX_NUM;++j)
|
||||
{
|
||||
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ", attrtype%d, attrvalue%d",j,j);
|
||||
iUpdateLen += snprintf(szValues + iUpdateLen, sizeof(szValues) - iUpdateLen, ",%d,%d",offlineshop->items[i].aAttr[j].bType, offlineshop->items[i].aAttr[j].sValue);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CHANGELOOK_SYSTEM
|
||||
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ",transmutation");
|
||||
iUpdateLen += snprintf(szValues + iUpdateLen, sizeof(szValues) - iUpdateLen, ",%d", offlineshop->items[i].transmutation);
|
||||
#endif
|
||||
|
||||
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ",ownername,port_extra");
|
||||
iUpdateLen += snprintf(szValues + iUpdateLen, sizeof(szValues) - iUpdateLen, ",'%s',UNHEX('%s')", offlineshop->items[i].szOwnerName,PortItemExtraHex(offlineshop->items[i].extra).c_str());
|
||||
|
||||
snprintf(szQuery, sizeof(szQuery), "INSERT INTO offline_shop_item (%s) VALUES (%s)", szColumns, szValues);
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
}
|
||||
|
||||
memset(&offlineshop->log, 0, sizeof(ShopLog) * OFFLINE_SHOP_HOST_ITEM_MAX_NUM);
|
||||
int i = 0;
|
||||
snprintf(szQuery, sizeof(szQuery), "SELECT target, time, itemvnum, itemcount, price FROM offline_shop_log WHERE owner_id = %u", offlineshop->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg5(CDBManager::instance().DirectQuery(szQuery));
|
||||
if (pMsg5->Get()->uiNumRows != 0)
|
||||
{
|
||||
MYSQL_ROW log_row = NULL;
|
||||
while ((log_row = mysql_fetch_row(pMsg5->Get()->pSQLResult)))
|
||||
{
|
||||
strlcpy(offlineshop->log[i].name, log_row[0], sizeof(offlineshop->log[i].name));
|
||||
strlcpy(offlineshop->log[i].date, log_row[1], sizeof(offlineshop->log[i].date));
|
||||
str_to_number(offlineshop->log[i].itemVnum, log_row[2]);
|
||||
str_to_number(offlineshop->log[i].itemCount, log_row[3]);
|
||||
str_to_number(offlineshop->log[i].price, log_row[4]);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
sys_log(0, "shop insert: owner_id: %u, owner_name: %s, sign: %s,x: %ld,y: %ld,mapIndex: %u, channel: %d",
|
||||
offlineshop->owner_id, offlineshop->owner_name, offlineshop->sign, offlineshop->x, offlineshop->y, offlineshop->mapindex, offlineshop->channel);
|
||||
|
||||
// and open this comment for 12h
|
||||
/*
|
||||
int firstOffshopTime = time(0)+(60*60*12);
|
||||
if(offlineshop->time < firstOffshopTime)
|
||||
{
|
||||
offlineshop->time = firstOffshopTime;
|
||||
sys_err("shop insert: negative offshop time.... pid: %d name: %s ",offlineshop->owner_id, offlineshop->owner_name);
|
||||
}
|
||||
*/
|
||||
|
||||
shop_create n;
|
||||
n.subheader = CREATE_OFFLINESHOP;
|
||||
thecore_memcpy(&n.offlineshop, offlineshop, sizeof(n.offlineshop));
|
||||
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_create));//, 0, peer);
|
||||
}
|
||||
|
||||
void CClientManager::DeleteOfflineShop(DWORD ownerid)
|
||||
{
|
||||
if(!PortOfflineShopEconomyReady())return;
|
||||
auto it = m_Offlineshop.find(ownerid);
|
||||
if (it == m_Offlineshop.end())
|
||||
return;
|
||||
char szQuery[1024];
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_npc WHERE owner_id = %u", ownerid);
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_item WHERE owner_id = %u and status = 1", ownerid);
|
||||
std::unique_ptr<SQLMsg> pMsg1(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
delete it->second;
|
||||
it->second = NULL;
|
||||
m_Offlineshop.erase(it);
|
||||
|
||||
sys_log(0, "DeleteOfflineShop %d ",ownerid);
|
||||
|
||||
shop_owner n;
|
||||
n.subheader = DESTROY_OFFLINESHOP;
|
||||
n.owner_id = ownerid;
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_owner));
|
||||
}
|
||||
|
||||
void CClientManager::RemoveItem(OFFLINE_SHOP_ITEM* item)
|
||||
{
|
||||
if(!PortOfflineShopEconomyReady())return;
|
||||
if(!item || item->pos>=OFFLINE_SHOP_HOST_ITEM_MAX_NUM)return;
|
||||
if (!item)
|
||||
return;
|
||||
auto it = m_Offlineshop.find(item->owner_id);
|
||||
if (it == m_Offlineshop.end())
|
||||
{
|
||||
InsertImportLog("TRY_REMOVE_BUT_NOT_EXIST_SHOP", NULL, item->owner_id, item->szOwnerName, item);
|
||||
// todo player removes items...
|
||||
return;
|
||||
}
|
||||
if (it->second->items[item->pos].vnum == 0)
|
||||
{
|
||||
InsertImportLog("TRY_REMOVE_BUT_NOT_EXIST_ITEM", it->second, item->owner_id, item->szOwnerName, item);
|
||||
return;
|
||||
}
|
||||
|
||||
shop_item n;
|
||||
n.subheader = REMOVE_ITEM;
|
||||
//thecore_memcpy(&n.item, item, sizeof(n.item));
|
||||
thecore_memcpy(&n.item, &it->second->items[item->pos], sizeof(n.item));
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_item));
|
||||
|
||||
char szQuery[1024];
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_item WHERE id = %u", item->id);
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
memset(&it->second->items[item->pos], 0, sizeof(OFFLINE_SHOP_ITEM));
|
||||
sys_log(0, "RemoveItem %d -> vnum %d count %d pos %d price %lld status %d buyername %s ", item->owner_id, item->vnum, item->count, item->pos, item->price, item->status, item->szBuyerName);
|
||||
InsertImportLog("REMOVE_SUCCESFULLY", it->second, item->owner_id, item->szOwnerName, item);
|
||||
}
|
||||
|
||||
|
||||
void CClientManager::AddItem(OFFLINE_SHOP_ITEM* item)
|
||||
{
|
||||
if(!PortOfflineShopEconomyReady())return;
|
||||
if(!item || item->pos>=OFFLINE_SHOP_HOST_ITEM_MAX_NUM)return;
|
||||
if (!item)
|
||||
return;
|
||||
auto it = m_Offlineshop.find(item->owner_id);
|
||||
if (it == m_Offlineshop.end())
|
||||
{
|
||||
InsertImportLog("TRY_ADD_BUT_SHOP_NOT_EXIST", NULL, item->owner_id, item->szOwnerName, item);
|
||||
// todo player removes items...
|
||||
return;
|
||||
}
|
||||
InsertImportLog("ADD_SUCCESFULLY", it->second, item->owner_id, item->szOwnerName, item);
|
||||
thecore_memcpy(&it->second->items[item->pos], item, sizeof(OFFLINE_SHOP_ITEM));
|
||||
OFFLINE_SHOP_ITEM& newitem = it->second->items[item->pos];
|
||||
int iLen = 0, iUpdateLen = 0;
|
||||
char szQuery[QUERY_MAX_LEN], szColumns[QUERY_MAX_LEN], szValues[QUERY_MAX_LEN];
|
||||
|
||||
iLen = snprintf(szColumns, sizeof(szColumns), "id,owner_id,pos,count,price,vnum");
|
||||
iUpdateLen = snprintf(szValues, sizeof(szValues), "%u,%u,%d,%d,%lld,%u", newitem.id, newitem.owner_id, newitem.pos, newitem.count, newitem.price, newitem.vnum);
|
||||
|
||||
for(BYTE j=0;j<ITEM_SOCKET_MAX_NUM;++j)
|
||||
{
|
||||
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ",socket%d",j);
|
||||
iUpdateLen += snprintf(szValues + iUpdateLen, sizeof(szValues) - iUpdateLen, ",%ld", newitem.alSockets[j]);
|
||||
}
|
||||
|
||||
for(BYTE j=0;j<ITEM_ATTRIBUTE_MAX_NUM;++j)
|
||||
{
|
||||
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ", attrtype%d, attrvalue%d",j,j);
|
||||
iUpdateLen += snprintf(szValues + iUpdateLen, sizeof(szValues) - iUpdateLen, ",%d,%d",newitem.aAttr[j].bType, newitem.aAttr[j].sValue);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CHANGELOOK_SYSTEM
|
||||
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ",transmutation");
|
||||
iUpdateLen += snprintf(szValues + iUpdateLen, sizeof(szValues) - iUpdateLen, ",%d", newitem.transmutation);
|
||||
#endif
|
||||
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ",ownername,port_extra");
|
||||
iUpdateLen += snprintf(szValues + iUpdateLen, sizeof(szValues) - iUpdateLen, ",'%s',UNHEX('%s')", newitem.szOwnerName,PortItemExtraHex(newitem.extra).c_str());
|
||||
snprintf(szQuery, sizeof(szQuery), "INSERT INTO offline_shop_item (%s) VALUES (%s)", szColumns, szValues);
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
sys_log(0, "AddItem %d -> vnum %d count %d pos %d price %lld ", newitem.owner_id, newitem.vnum, newitem.count, newitem.pos, newitem.price);
|
||||
|
||||
shop_item n;
|
||||
n.subheader = ADD_ITEM;
|
||||
thecore_memcpy(&n.item, item, sizeof(n.item));
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_item));
|
||||
|
||||
}
|
||||
|
||||
void CClientManager::BuyItem(TOfflineShopBuy* buyItem)
|
||||
{
|
||||
if(!PortOfflineShopEconomyReady())return;
|
||||
if(!buyItem || buyItem->item.pos>=OFFLINE_SHOP_HOST_ITEM_MAX_NUM)return;
|
||||
if (!buyItem)
|
||||
return;
|
||||
auto it = m_Offlineshop.find(buyItem->item.owner_id);
|
||||
if (it == m_Offlineshop.end())
|
||||
{
|
||||
InsertImportLog("TRY_BUY_BUT_NOT_EXIST_SHOP", NULL, buyItem->customer_id, buyItem->customer_name, NULL);
|
||||
// todo player removes price...
|
||||
return;
|
||||
}
|
||||
|
||||
OFFLINE_SHOP_ITEM& item = it->second->items[buyItem->item.pos];
|
||||
|
||||
if (item.vnum == 0 || item.status != 0)
|
||||
{
|
||||
InsertImportLog("TRY_BUY_BUT_ALREADY_SELLED", it->second, buyItem->customer_id, buyItem->customer_name, &item);
|
||||
return;
|
||||
}
|
||||
|
||||
char szQuery[QUERY_MAX_LEN];
|
||||
snprintf(szQuery, sizeof(szQuery), "UPDATE player SET shop_money = shop_money + %lld WHERE id = %u", buyItem->item.price, buyItem->item.owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg1(CDBManager::instance().DirectQuery(szQuery));
|
||||
it->second->price += buyItem->item.price;
|
||||
item.status = 1;
|
||||
strlcpy(item.szBuyerName, buyItem->customer_name, sizeof(item.szBuyerName));
|
||||
|
||||
memset(&buyItem->log, 0, sizeof(buyItem->log));
|
||||
buyItem->log_index = -1;
|
||||
InsertImportLog("BUY_SUCCESFULLY", it->second, buyItem->customer_id, buyItem->customer_name, &item);
|
||||
|
||||
for (DWORD i = 0; i < OFFLINE_SHOP_HOST_ITEM_MAX_NUM; i++)
|
||||
{
|
||||
ShopLog& log = it->second->log[i];
|
||||
if (log.price != 0)
|
||||
continue;
|
||||
|
||||
time_t now = time(0);
|
||||
struct tm tstruct;
|
||||
char buf[80];
|
||||
tstruct = *localtime(&now);
|
||||
strftime(buf, sizeof(buf), "%X-%d.%m.%Y", &tstruct);
|
||||
|
||||
strlcpy(log.date, buf, sizeof(log.date));
|
||||
log.itemCount = item.count;
|
||||
log.itemVnum = item.vnum;
|
||||
strlcpy(log.name, buyItem->customer_name, sizeof(log.name));
|
||||
log.price = item.price;
|
||||
|
||||
buyItem->log_index = i;
|
||||
thecore_memcpy(&buyItem->log,&log, sizeof(buyItem->log));
|
||||
|
||||
int iLen = snprintf(szQuery, sizeof(szQuery), "INSERT INTO offline_shop_log ("
|
||||
"owner_id, target, time, itemvnum, itemcount, price"
|
||||
",item_id, pos"
|
||||
#ifdef ENABLE_CHANGELOOK_SYSTEM
|
||||
",transmutation"
|
||||
#endif
|
||||
);
|
||||
|
||||
for(BYTE j=0;j<ITEM_SOCKET_MAX_NUM;++j)
|
||||
iLen += snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ", socket%d",j);
|
||||
|
||||
for(BYTE j=0;j<ITEM_ATTRIBUTE_MAX_NUM;++j)
|
||||
iLen += snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ", attrtype%d, attrvalue%d",j,j);
|
||||
|
||||
iLen += snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ") VALUES("
|
||||
"%u, '%s', '%s', %d, %d, %lld"
|
||||
",%u, %d"
|
||||
#ifdef ENABLE_CHANGELOOK_SYSTEM
|
||||
",%d"
|
||||
#endif
|
||||
,item.owner_id, buyItem->customer_name, buf, item.vnum, item.count, item.price,
|
||||
item.id, item.pos
|
||||
#ifdef ENABLE_CHANGELOOK_SYSTEM
|
||||
,item.transmutation
|
||||
#endif
|
||||
);
|
||||
for(BYTE j=0;j<ITEM_SOCKET_MAX_NUM;++j)
|
||||
iLen += snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ", %ld",item.alSockets[j]);
|
||||
for(BYTE j=0;j<ITEM_ATTRIBUTE_MAX_NUM;++j)
|
||||
iLen += snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ", %d, %d",item.aAttr[j].bType, item.aAttr[j].sValue);
|
||||
iLen += snprintf(szQuery+iLen, sizeof(szQuery)-iLen, ")");
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
break;
|
||||
}
|
||||
snprintf(szQuery, sizeof(szQuery), "UPDATE offline_shop_item SET status = 1, buyername = '%s' WHERE id = %u and owner_id = %u", buyItem->customer_name,buyItem->item.id, buyItem->item.owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
thecore_memcpy(&buyItem->item, &item, sizeof(buyItem->item));
|
||||
sys_log(0, "BuyItem %d -> buyer name %s vnum %d count %d pos %d price %lld ", buyItem->item.owner_id, buyItem->customer_name, buyItem->item.vnum, buyItem->item.count, buyItem->item.pos, buyItem->item.price);
|
||||
|
||||
shop_buy n;
|
||||
n.subheader = BUY_ITEM;
|
||||
thecore_memcpy(&n.buyItem, buyItem, sizeof(n.buyItem));
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_buy));
|
||||
}
|
||||
|
||||
void CClientManager::WithdrawMoney(DWORD ch)
|
||||
{
|
||||
if(!PortOfflineShopEconomyReady())return;
|
||||
auto it = m_Offlineshop.find(ch);
|
||||
if (it == m_Offlineshop.end())
|
||||
// todo player removes price...
|
||||
return;
|
||||
if (it->second->price == 0)
|
||||
return;
|
||||
char szQuery[QUERY_MAX_LEN];
|
||||
snprintf(szQuery, sizeof(szQuery), "UPDATE player SET shop_money = 0 WHERE id = '%u'",ch);
|
||||
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
sys_log(0, "WithdrawMoney %d -> %lld ", ch, it->second->price);
|
||||
it->second->price = 0;
|
||||
|
||||
shop_owner n;
|
||||
n.subheader = WITHDRAW_MONEY;
|
||||
n.owner_id = ch;
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_owner));
|
||||
}
|
||||
|
||||
void CClientManager::ChangeTitle(TOfflineShopChangeTitle* p)
|
||||
{
|
||||
if (!p)
|
||||
return;
|
||||
auto it = m_Offlineshop.find(p->owner_id);
|
||||
if (it == m_Offlineshop.end())
|
||||
// todo player removes price...
|
||||
return;
|
||||
strlcpy(it->second->sign, p->sign, sizeof(it->second->sign));
|
||||
char szQuery[1024 + 1];
|
||||
snprintf(szQuery, sizeof(szQuery), "UPDATE offline_shop_npc SET sign = '%s' WHERE owner_id = '%d'", p->sign, p->owner_id);
|
||||
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
sys_log(0, "ChangeTitle %d -> %s ", p->owner_id, p->sign);
|
||||
|
||||
|
||||
shop_title n;
|
||||
n.subheader = CHANGE_TITLE;
|
||||
thecore_memcpy(&n.title, p, sizeof(n.title));
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP,&n, sizeof(shop_title));
|
||||
}
|
||||
|
||||
void CClientManager::ClearLog(DWORD ch)
|
||||
{
|
||||
auto it = m_Offlineshop.find(ch);
|
||||
if (it == m_Offlineshop.end())
|
||||
return;
|
||||
memset(&it->second->log, 0, sizeof(it->second->log));
|
||||
char szQuery[1024];
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_log WHERE owner_id = %u", it->second->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
sys_log(0, "ClearLog %d ", ch);
|
||||
|
||||
shop_owner n;
|
||||
n.subheader = CLEAR_LOG;
|
||||
n.owner_id = ch;
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_owner));
|
||||
}
|
||||
|
||||
void CClientManager::ChangeDecoration(TShopDecoration* ch)
|
||||
{
|
||||
if (!ch)
|
||||
return;
|
||||
auto it = m_Offlineshop.find(ch->owner_id);
|
||||
if (it == m_Offlineshop.end())
|
||||
return;
|
||||
it->second->type = 30000 + ch->vnum;
|
||||
strlcpy(it->second->sign, ch->sign, sizeof(it->second->sign));
|
||||
|
||||
char szQuery[1024];
|
||||
snprintf(szQuery, sizeof(szQuery), "UPDATE offline_shop_npc SET type = %d, sign = '%s' WHERE owner_id = %u", it->second->type, it->second->sign,it->first);
|
||||
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
sys_log(0, "ChangeDecoration %d -> %d %s ", ch->owner_id, 30000 + ch->vnum, ch->sign);
|
||||
|
||||
shop_decoration n;
|
||||
n.subheader = CHANGE_DECORATION;
|
||||
thecore_memcpy(&n.decoration, ch, sizeof(n.decoration));
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_decoration));
|
||||
}
|
||||
|
||||
void CClientManager::OpenSlot(TOfflineShopOpenSlot* ch)
|
||||
{
|
||||
if (!ch)
|
||||
return;
|
||||
auto it = m_Offlineshop.find(ch->owner_id);
|
||||
if (it == m_Offlineshop.end())
|
||||
return;
|
||||
it->second->slotflag = ch->flag;
|
||||
char szQuery[1024];
|
||||
snprintf(szQuery, sizeof(szQuery), "UPDATE offline_shop_npc SET slotflag = %lld WHERE owner_id = %u", ch->flag,ch->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
sys_log(0, "OpenSlot %d -> %lld ", ch->owner_id, ch->flag);
|
||||
|
||||
shop_slot n;
|
||||
n.subheader = CHANGE_OPEN_SLOT;
|
||||
thecore_memcpy(&n.ch, ch, sizeof(n.ch));
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_slot));
|
||||
|
||||
}
|
||||
|
||||
void CClientManager::TimeDone(DWORD ch)
|
||||
{
|
||||
auto it = m_Offlineshop.find(ch);
|
||||
if (it == m_Offlineshop.end())
|
||||
return;
|
||||
sys_log(0, "TimeDone %d ", ch);
|
||||
|
||||
bool status = true;
|
||||
for (DWORD i = 0; i < OFFLINE_SHOP_HOST_ITEM_MAX_NUM; ++i)
|
||||
{
|
||||
if (it->second->items[i].vnum != 0 && it->second->items[i].status == 0) {
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (status)
|
||||
{
|
||||
char szQuery[1024];
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_npc WHERE owner_id = %u", ch);
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_item WHERE owner_id = %u", ch);
|
||||
std::unique_ptr<SQLMsg> pMsg1(CDBManager::instance().DirectQuery(szQuery));
|
||||
delete it->second;
|
||||
it->second = NULL;
|
||||
m_Offlineshop.erase(it);
|
||||
|
||||
sys_log(0, "TimeDone: %d shop closed. 0 item.", ch);
|
||||
}
|
||||
else
|
||||
sys_log(0, "TimeDone: %d ", ch);
|
||||
|
||||
shop_owner n;
|
||||
n.subheader = TIME_DONE;
|
||||
n.owner_id = ch;
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_owner));
|
||||
}
|
||||
|
||||
void CClientManager::GetBackItem(DWORD ch)
|
||||
{
|
||||
auto it = m_Offlineshop.find(ch);
|
||||
if (it == m_Offlineshop.end())
|
||||
return;
|
||||
|
||||
char szQuery[1024];
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_npc WHERE owner_id = %u", ch);
|
||||
std::unique_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
snprintf(szQuery, sizeof(szQuery), "DELETE FROM offline_shop_item WHERE owner_id = %u", ch);
|
||||
std::unique_ptr<SQLMsg> pMsg1(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
shop_back n;
|
||||
n.subheader = GET_BACK_ITEM;
|
||||
n.back.owner_id = ch;
|
||||
thecore_memcpy(&n.back.items, &it->second->items, sizeof(n.back.items));
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_back));
|
||||
|
||||
delete it->second;
|
||||
it->second = NULL;
|
||||
m_Offlineshop.erase(it);
|
||||
sys_log(0, "GetBackItem %d ", ch);
|
||||
}
|
||||
|
||||
void CClientManager::AddTime(DWORD ch)
|
||||
{
|
||||
auto it = m_Offlineshop.find(ch);
|
||||
if (it == m_Offlineshop.end())
|
||||
return;
|
||||
int oldtime = it->second->time-time(0);
|
||||
int addtime = (60 * 60 * 12);
|
||||
//int newTime = MIN((60*60*24*3) - oldtime, addtime);
|
||||
it->second->time = time(0) + (oldtime+ addtime);
|
||||
sys_log(0, "AddTime %d ", ch);
|
||||
|
||||
char szQuery[1024];
|
||||
snprintf(szQuery, sizeof(szQuery), "UPDATE offline_shop_npc SET time = %d WHERE owner_id = %u", it->second->time, it->second->owner_id);
|
||||
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
shop_owner n;
|
||||
n.subheader = ADD_TIME;
|
||||
n.owner_id = ch;
|
||||
ForwardPacket(HEADER_DG_OFFLINESHOP, &n, sizeof(shop_owner));
|
||||
}
|
||||
|
||||
void CClientManager::RecvPackets(const char* data)
|
||||
{
|
||||
if(!PortOfflineShopEconomyReady())return;
|
||||
BYTE sub_header = (BYTE)*data;
|
||||
switch (sub_header)
|
||||
{
|
||||
case CREATE_OFFLINESHOP:
|
||||
{
|
||||
shop_create* p = (shop_create*)data;
|
||||
if (p)
|
||||
CreateOfflineShop(&p->offlineshop);
|
||||
}
|
||||
break;
|
||||
case DESTROY_OFFLINESHOP:
|
||||
{
|
||||
shop_owner* p = (shop_owner*)data;
|
||||
if (p)
|
||||
DeleteOfflineShop(p->owner_id);
|
||||
}
|
||||
break;
|
||||
case ADD_ITEM:
|
||||
{
|
||||
shop_item* p = (shop_item*)data;
|
||||
if (p)
|
||||
AddItem(&p->item);
|
||||
}
|
||||
break;
|
||||
case REMOVE_ITEM:
|
||||
{
|
||||
shop_item* p = (shop_item*)data;
|
||||
if (p)
|
||||
RemoveItem(&p->item);
|
||||
}
|
||||
break;
|
||||
case BUY_ITEM:
|
||||
{
|
||||
shop_buy* p = (shop_buy*)data;
|
||||
if (p)
|
||||
BuyItem(&p->buyItem);
|
||||
}
|
||||
break;
|
||||
case CHANGE_TITLE:
|
||||
{
|
||||
shop_title* p = (shop_title*)data;
|
||||
if (p)
|
||||
ChangeTitle(&p->title);
|
||||
}
|
||||
break;
|
||||
|
||||
case WITHDRAW_MONEY:
|
||||
{
|
||||
shop_owner* p = (shop_owner*)data;
|
||||
if (p)
|
||||
WithdrawMoney(p->owner_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case CLEAR_LOG:
|
||||
{
|
||||
shop_owner* p = (shop_owner*)data;
|
||||
if (p)
|
||||
ClearLog(p->owner_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case CHANGE_DECORATION:
|
||||
{
|
||||
shop_decoration* p = (shop_decoration*)data;
|
||||
if (p)
|
||||
ChangeDecoration(&p->decoration);
|
||||
}
|
||||
break;
|
||||
|
||||
case CHANGE_OPEN_SLOT:
|
||||
{
|
||||
shop_slot* p = (shop_slot*)data;
|
||||
if (p)
|
||||
OpenSlot(&p->ch);
|
||||
}
|
||||
break;
|
||||
|
||||
case TIME_DONE:
|
||||
{
|
||||
shop_owner* p = (shop_owner*)data;
|
||||
if (p)
|
||||
TimeDone(p->owner_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case GET_BACK_ITEM:
|
||||
{
|
||||
shop_owner* p = (shop_owner*)data;
|
||||
if (p)
|
||||
GetBackItem(p->owner_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD_TIME:
|
||||
{
|
||||
shop_owner* p = (shop_owner*)data;
|
||||
if (p)
|
||||
AddTime(p->owner_id);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sys_err("unkown offlineshop subheader %d", sub_header);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,22 @@ extern int g_log;
|
||||
//
|
||||
// Check all SELECT syntax on item table before change this function!!!
|
||||
//
|
||||
bool CClientManager::ValidateLoadedExtra(const TPlayerItem& item,const char* hex) const {
|
||||
auto found=m_map_itemTableByVnum.find(item.vnum);
|
||||
if(found==m_map_itemTableByVnum.end())return false;
|
||||
const auto* proto=found->second;
|
||||
if(proto->bType!=ITEM_PET || proto->bSubType!=PET_LEVELABLE)return true;
|
||||
if(!hex || strlen(hex)!=138 || item.alSockets[1]<1 || item.alSockets[1]>120 || item.alSockets[2]<0 ||
|
||||
item.extra.sockets[0]<0 || item.extra.sockets[0]>3 || item.extra.sockets[1]<0 || item.extra.sockets[1]>15)return false;
|
||||
for(unsigned i=2;i<5;++i)if(item.extra.sockets[i]<0 || item.extra.sockets[i]>20)return false;
|
||||
for(unsigned i=0;i<15;++i){
|
||||
const unsigned type=i<7?item.aAttr[i].bType:item.extra.types[i-7];
|
||||
const int value=i<7?item.aAttr[i].sValue:item.extra.values[i-7];
|
||||
if((type>29 && type!=99) || value<0 || value>20 || ((type==0||type==99)&&value!=0))return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CreateItemTableFromRes(MYSQL_RES * res, std::vector<TPlayerItem> * pVec, DWORD dwPID)
|
||||
{
|
||||
if (!res)
|
||||
@@ -32,7 +48,7 @@ bool CreateItemTableFromRes(MYSQL_RES * res, std::vector<TPlayerItem> * pVec, DW
|
||||
|
||||
int rows;
|
||||
|
||||
if ((rows = mysql_num_rows(res)) <= 0) // 데이터 없음
|
||||
if ((rows = mysql_num_rows(res)) <= 0) // 데이터 없음
|
||||
{
|
||||
pVec->clear();
|
||||
return true;
|
||||
@@ -65,6 +81,12 @@ bool CreateItemTableFromRes(MYSQL_RES * res, std::vector<TPlayerItem> * pVec, DW
|
||||
str_to_number(item.aAttr[j].sValue, row[cur++]);
|
||||
}
|
||||
|
||||
if (!PortItemExtraRead(mysql_num_fields(res)>unsigned(cur)?row[cur]:NULL,item.extra) ||
|
||||
!CClientManager::instance().ValidateLoadedExtra(item,mysql_num_fields(res)>unsigned(cur)?row[cur]:NULL)) {
|
||||
// Original bytes stay in SQL. Do not create caches or return partial inventory.
|
||||
sys_err("ITEM_EXTRA_QUARANTINE owner=%u item=%u window=%u: invalid port_extra", dwPID,item.id,item.window);
|
||||
pVec->clear();return false;
|
||||
}
|
||||
item.owner = dwPID;
|
||||
}
|
||||
|
||||
@@ -99,7 +121,7 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p
|
||||
"ht = %d, "
|
||||
"dx = %d, "
|
||||
"iq = %d, "
|
||||
"gold = %d, "
|
||||
"gold = %lld, "
|
||||
"exp = %u, "
|
||||
"stat_point = %d, "
|
||||
"skill_point = %d, "
|
||||
@@ -117,6 +139,12 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p
|
||||
"horse_hp_droptime = %u, "
|
||||
"horse_stamina = %d, "
|
||||
"horse_skill_point = %d, "
|
||||
#ifdef UNLOCK_INVENTORY_WORLDARD
|
||||
"inventory_0 = %u, inventory_1 = %u, inventory_2 = %u, inventory_3 = %u, inventory_4 = %u, inventory_5 = %u, "
|
||||
#endif
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
"shopFlag = %llu, "
|
||||
#endif
|
||||
,
|
||||
GetTablePostfix(),
|
||||
pkTab->job,
|
||||
@@ -141,7 +169,7 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p
|
||||
pkTab->ht,
|
||||
pkTab->dx,
|
||||
pkTab->iq,
|
||||
pkTab->gold,
|
||||
(long long) pkTab->gold,
|
||||
pkTab->exp,
|
||||
pkTab->stat_point,
|
||||
pkTab->skill_point,
|
||||
@@ -157,9 +185,21 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p
|
||||
pkTab->horse.sHealth,
|
||||
pkTab->horse.dwHorseHealthDropTime,
|
||||
pkTab->horse.sStamina,
|
||||
pkTab->horse_skill_point);
|
||||
pkTab->horse_skill_point
|
||||
#ifdef UNLOCK_INVENTORY_WORLDARD
|
||||
, pkTab->inventory_unlock[0]
|
||||
, pkTab->inventory_unlock[1]
|
||||
, pkTab->inventory_unlock[2]
|
||||
, pkTab->inventory_unlock[3]
|
||||
, pkTab->inventory_unlock[4]
|
||||
, pkTab->inventory_unlock[5]
|
||||
#endif
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
, pkTab->shopFlag
|
||||
#endif
|
||||
);
|
||||
|
||||
// Binary 로 바꾸기 위한 임시 공간
|
||||
// Binary 로 바꾸기 위한 임시 공간
|
||||
static char text[8192 + 1];
|
||||
|
||||
CDBManager::instance().EscapeString(text, pkTab->skills, sizeof(pkTab->skills));
|
||||
@@ -207,11 +247,12 @@ void CClientManager::PutPlayerCache(TPlayerTable * pNew)
|
||||
*/
|
||||
void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoadPacket * packet)
|
||||
{
|
||||
if(!EconomyBeforeLoad(peer,dwHandle,packet)){if(!m_economyFences.count(packet->player_id))peer->EncodeHeader(HEADER_DG_PLAYER_LOAD_FAILED,dwHandle,0);return;}
|
||||
CPlayerTableCache * c;
|
||||
TPlayerTable * pTab;
|
||||
|
||||
//
|
||||
// 한 계정에 속한 모든 캐릭터들 캐쉬처리
|
||||
// 한 계정에 속한 모든 캐릭터들 캐쉬처리
|
||||
//
|
||||
CLoginData * pLoginData = GetLoginDataByAID(packet->account_id);
|
||||
|
||||
@@ -223,12 +264,12 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// 1. 유저정보가 DBCache 에 존재 : DBCache에서
|
||||
// 2. 유저정보가 DBCache 에 없음 : DB에서
|
||||
// 1. 유저정보가 DBCache 에 존재 : DBCache에서
|
||||
// 2. 유저정보가 DBCache 에 없음 : DB에서
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
//----------------------------------
|
||||
// 1. 유저정보가 DBCache 에 존재 : DBCache에서
|
||||
// 1. 유저정보가 DBCache 에 존재 : DBCache에서
|
||||
//----------------------------------
|
||||
if ((c = GetPlayerCache(packet->player_id)))
|
||||
{
|
||||
@@ -265,16 +306,16 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
|
||||
TItemCacheSet * pSet = GetItemCacheSet(pTab->id);
|
||||
|
||||
sys_log(0, "[PLAYER_LOAD] ID %s pid %d gold %d ", pTab->name, pTab->id, pTab->gold);
|
||||
sys_log(0, "[PLAYER_LOAD] ID %s pid %d gold %lld ", pTab->name, pTab->id, (long long) pTab->gold);
|
||||
|
||||
//--------------------------------------------
|
||||
// 아이템 & AFFECT & QUEST 로딩 :
|
||||
// 아이템 & AFFECT & QUEST 로딩 :
|
||||
//--------------------------------------------
|
||||
// 1) 아이템이 DBCache 에 존재 : DBCache 에서 가져옴
|
||||
// 2) 아이템이 DBCache 에 없음 : DB 에서 가져옴
|
||||
// 1) 아이템이 DBCache 에 존재 : DBCache 에서 가져옴
|
||||
// 2) 아이템이 DBCache 에 없음 : DB 에서 가져옴
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// 1) 아이템이 DBCache 에 존재 : DBCache 에서 가져옴
|
||||
// 1) 아이템이 DBCache 에 존재 : DBCache 에서 가져옴
|
||||
/////////////////////////////////////////////
|
||||
if (pSet)
|
||||
{
|
||||
@@ -289,7 +330,7 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
CItemCache * c = *it++;
|
||||
TPlayerItem * p = c->Get();
|
||||
|
||||
if (p->vnum) // vnum이 없으면 삭제된 아이템이다.
|
||||
if (p->vnum) // vnum이 없으면 삭제된 아이템이다.
|
||||
thecore_memcpy(&s_items[dwCount++], p, sizeof(TPlayerItem));
|
||||
}
|
||||
|
||||
@@ -316,14 +357,22 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
CDBManager::instance().ReturnQuery(szQuery, QID_AFFECT, peer->GetHandle(), new ClientHandleInfo(dwHandle));
|
||||
}
|
||||
/////////////////////////////////////////////
|
||||
// 2) 아이템이 DBCache 에 없음 : DB 에서 가져옴
|
||||
// 2) 아이템이 DBCache 에 없음 : DB 에서 가져옴
|
||||
/////////////////////////////////////////////
|
||||
else
|
||||
{
|
||||
snprintf(szQuery, sizeof(szQuery),
|
||||
"SELECT id,window+0,pos,count,vnum,socket0,socket1,socket2,attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6 "
|
||||
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d)",
|
||||
GetTablePostfix(), pTab->id, SAFEBOX, DRAGON_SOUL_INVENTORY);
|
||||
"SELECT id,window+0,pos,count,vnum,socket0,socket1,socket2,attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6,HEX(port_extra) "
|
||||
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d or window = %d"
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
" or (window >= %d and window <= %d)"
|
||||
#endif
|
||||
")",
|
||||
GetTablePostfix(), pTab->id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
, UPGRADE_INVENTORY, COSTUME_INVENTORY
|
||||
#endif
|
||||
);
|
||||
|
||||
CDBManager::instance().ReturnQuery(szQuery,
|
||||
QID_ITEM,
|
||||
@@ -350,7 +399,7 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
//return;
|
||||
}
|
||||
//----------------------------------
|
||||
// 2. 유저정보가 DBCache 에 없음 : DB에서
|
||||
// 2. 유저정보가 DBCache 에 없음 : DB에서
|
||||
//----------------------------------
|
||||
else
|
||||
{
|
||||
@@ -359,7 +408,7 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
char queryStr[QUERY_MAX_LEN];
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// 캐릭터 정보 얻어오기 : 무조건 DB에서
|
||||
// 캐릭터 정보 얻어오기 : 무조건 DB에서
|
||||
//--------------------------------------------------------------
|
||||
snprintf(queryStr, sizeof(queryStr),
|
||||
"SELECT "
|
||||
@@ -367,7 +416,14 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
"gold,level,level_step,st,ht,dx,iq,exp,"
|
||||
"stat_point,skill_point,sub_skill_point,stat_reset_count,part_base,part_hair,"
|
||||
"skill_level,quickslot,skill_group,alignment,mobile,horse_level,horse_riding,horse_hp,horse_hp_droptime,horse_stamina,"
|
||||
"UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(last_play),horse_skill_point FROM player%s WHERE id=%d",
|
||||
"UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(last_play),horse_skill_point"
|
||||
#ifdef UNLOCK_INVENTORY_WORLDARD
|
||||
",inventory_0,inventory_1,inventory_2,inventory_3,inventory_4,inventory_5"
|
||||
#endif
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
",shopFlag"
|
||||
#endif
|
||||
" FROM player%s WHERE id=%d",
|
||||
GetTablePostfix(), packet->player_id);
|
||||
|
||||
ClientHandleInfo * pkInfo = new ClientHandleInfo(dwHandle, packet->player_id);
|
||||
@@ -375,24 +431,32 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
CDBManager::instance().ReturnQuery(queryStr, QID_PLAYER, peer->GetHandle(), pkInfo);
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// 아이템 가져오기
|
||||
// 아이템 가져오기
|
||||
//--------------------------------------------------------------
|
||||
snprintf(queryStr, sizeof(queryStr),
|
||||
"SELECT id,window+0,pos,count,vnum,socket0,socket1,socket2,attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6 "
|
||||
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d)",
|
||||
GetTablePostfix(), packet->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY);
|
||||
"SELECT id,window+0,pos,count,vnum,socket0,socket1,socket2,attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6,HEX(port_extra) "
|
||||
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d or window = %d"
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
" or (window >= %d and window <= %d)"
|
||||
#endif
|
||||
")",
|
||||
GetTablePostfix(), packet->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
, UPGRADE_INVENTORY, COSTUME_INVENTORY
|
||||
#endif
|
||||
);
|
||||
CDBManager::instance().ReturnQuery(queryStr, QID_ITEM, peer->GetHandle(), new ClientHandleInfo(dwHandle, packet->player_id));
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// QUEST 가져오기
|
||||
// QUEST 가져오기
|
||||
//--------------------------------------------------------------
|
||||
snprintf(queryStr, sizeof(queryStr),
|
||||
"SELECT dwPID,szName,szState,lValue FROM quest%s WHERE dwPID=%d",
|
||||
GetTablePostfix(), packet->player_id);
|
||||
CDBManager::instance().ReturnQuery(queryStr, QID_QUEST, peer->GetHandle(), new ClientHandleInfo(dwHandle, packet->player_id,packet->account_id));
|
||||
//독일 선물 기능에서 item_award테이블에서 login 정보를 얻기위해 account id도 넘겨준다
|
||||
//독일 선물 기능에서 item_award테이블에서 login 정보를 얻기위해 account id도 넘겨준다
|
||||
//--------------------------------------------------------------
|
||||
// AFFECT 가져오기
|
||||
// AFFECT 가져오기
|
||||
//--------------------------------------------------------------
|
||||
snprintf(queryStr, sizeof(queryStr),
|
||||
"SELECT dwPID,bType,bApplyOn,lApplyValue,dwFlag,lDuration,lSPCost FROM affect%s WHERE dwPID=%d",
|
||||
@@ -409,21 +473,21 @@ void CClientManager::ItemAward(CPeer * peer,char* login)
|
||||
std::set<TItemAward *> * pSet = ItemAwardManager::instance().GetByLogin(login_t);
|
||||
if(pSet == NULL)
|
||||
return;
|
||||
__typeof(pSet->begin()) it = pSet->begin(); //taken_time이 NULL인것들 읽어옴
|
||||
__typeof(pSet->begin()) it = pSet->begin(); //taken_time이 NULL인것들 읽어옴
|
||||
while(it != pSet->end() )
|
||||
{
|
||||
TItemAward * pItemAward = *(it++);
|
||||
char* whyStr = pItemAward->szWhy; //why 콜룸 읽기
|
||||
char cmdStr[100] = ""; //why콜룸에서 읽은 값을 임시 문자열에 복사해둠
|
||||
strcpy(cmdStr,whyStr); //명령어 얻는 과정에서 토큰쓰면 원본도 토큰화 되기 때문
|
||||
char* whyStr = pItemAward->szWhy; //why 콜룸 읽기
|
||||
char cmdStr[100] = ""; //why콜룸에서 읽은 값을 임시 문자열에 복사해둠
|
||||
strcpy(cmdStr,whyStr); //명령어 얻는 과정에서 토큰쓰면 원본도 토큰화 되기 때문
|
||||
char command[20] = "";
|
||||
strcpy(command,GetCommand(cmdStr)); // command 얻기
|
||||
if( !(strcmp(command,"GIFT") )) // command 가 GIFT이면
|
||||
strcpy(command,GetCommand(cmdStr)); // command 얻기
|
||||
if( !(strcmp(command,"GIFT") )) // command 가 GIFT이면
|
||||
{
|
||||
TPacketItemAwardInfromer giftData;
|
||||
strcpy(giftData.login, pItemAward->szLogin); //로그인 아이디 복사
|
||||
strcpy(giftData.command, command); //명령어 복사
|
||||
giftData.vnum = pItemAward->dwVnum; //아이템 vnum도 복사
|
||||
strcpy(giftData.login, pItemAward->szLogin); //로그인 아이디 복사
|
||||
strcpy(giftData.command, command); //명령어 복사
|
||||
giftData.vnum = pItemAward->dwVnum; //아이템 vnum도 복사
|
||||
ForwardPacket(HEADER_DG_ITEMAWARD_INFORMER,&giftData,sizeof(TPacketItemAwardInfromer));
|
||||
}
|
||||
}
|
||||
@@ -444,7 +508,7 @@ char* CClientManager::GetCommand(char* str)
|
||||
|
||||
bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab)
|
||||
{
|
||||
if (mysql_num_rows(res) == 0) // 데이터 없음
|
||||
if (mysql_num_rows(res) == 0) // 데이터 없음
|
||||
return false;
|
||||
|
||||
memset(pkTab, 0, sizeof(TPlayerTable));
|
||||
@@ -521,6 +585,13 @@ bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab)
|
||||
str_to_number(pkTab->horse.sStamina, row[col++]);
|
||||
str_to_number(pkTab->logoff_interval, row[col++]);
|
||||
str_to_number(pkTab->horse_skill_point, row[col++]);
|
||||
#ifdef UNLOCK_INVENTORY_WORLDARD
|
||||
for (int i = 0; i < UNLOCK_INVENTORY_MAX; ++i)
|
||||
str_to_number(pkTab->inventory_unlock[i], row[col++]);
|
||||
#endif
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
str_to_number(pkTab->shopFlag, row[col++]);
|
||||
#endif
|
||||
|
||||
// reset sub_skill_point
|
||||
{
|
||||
@@ -531,11 +602,11 @@ bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab)
|
||||
int max_point = pkTab->level - 9;
|
||||
|
||||
int skill_point =
|
||||
MIN(20, pkTab->skills[121].bLevel) + // SKILL_LEADERSHIP 통솔력
|
||||
MIN(20, pkTab->skills[124].bLevel) + // SKILL_MINING 채광
|
||||
MIN(10, pkTab->skills[131].bLevel) + // SKILL_HORSE_SUMMON 말소환
|
||||
MIN(20, pkTab->skills[141].bLevel) + // SKILL_ADD_HP HP보강
|
||||
MIN(20, pkTab->skills[142].bLevel); // SKILL_RESIST_PENETRATE 관통저항
|
||||
MIN(20, pkTab->skills[121].bLevel) + // SKILL_LEADERSHIP 통솔력
|
||||
MIN(20, pkTab->skills[124].bLevel) + // SKILL_MINING 채광
|
||||
MIN(10, pkTab->skills[131].bLevel) + // SKILL_HORSE_SUMMON 말소환
|
||||
MIN(20, pkTab->skills[141].bLevel) + // SKILL_ADD_HP HP보강
|
||||
MIN(20, pkTab->skills[142].bLevel); // SKILL_RESIST_PENETRATE 관통저항
|
||||
|
||||
pkTab->sub_skill_point = max_point - skill_point;
|
||||
}
|
||||
@@ -575,13 +646,13 @@ void CClientManager::RESULT_COMPOSITE_PLAYER(CPeer * peer, SQLMsg * pMsg, DWORD
|
||||
{
|
||||
sys_log(0, "QID_QUEST %u", info->dwHandle);
|
||||
RESULT_QUEST_LOAD(peer, pSQLResult, info->dwHandle, info->player_id);
|
||||
//aid얻기
|
||||
//aid얻기
|
||||
ClientHandleInfo* temp1 = info.get();
|
||||
if (temp1 == NULL)
|
||||
break;
|
||||
|
||||
CLoginData* pLoginData1 = GetLoginDataByAID(temp1->account_id); //
|
||||
//독일 선물 기능
|
||||
//독일 선물 기능
|
||||
if( pLoginData1->GetAccountRef().login == NULL)
|
||||
break;
|
||||
if( pLoginData1 == NULL )
|
||||
@@ -672,14 +743,17 @@ void CClientManager::RESULT_PLAYER_LOAD(CPeer * peer, MYSQL_RES * pRes, ClientHa
|
||||
void CClientManager::RESULT_ITEM_LOAD(CPeer * peer, MYSQL_RES * pRes, DWORD dwHandle, DWORD dwPID)
|
||||
{
|
||||
static std::vector<TPlayerItem> s_items;
|
||||
//DB에서 아이템 정보를 읽어온다.
|
||||
CreateItemTableFromRes(pRes, &s_items, dwPID);
|
||||
//DB에서 아이템 정보를 읽어온다.
|
||||
if (!CreateItemTableFromRes(pRes, &s_items, dwPID)) {
|
||||
peer->EncodeHeader(HEADER_DG_PLAYER_LOAD_FAILED, dwHandle, 0);
|
||||
return;
|
||||
}
|
||||
DWORD dwCount = s_items.size();
|
||||
|
||||
peer->EncodeHeader(HEADER_DG_ITEM_LOAD, dwHandle, sizeof(DWORD) + sizeof(TPlayerItem) * dwCount);
|
||||
peer->EncodeDWORD(dwCount);
|
||||
|
||||
//CacheSet을 만든다
|
||||
//CacheSet을 만든다
|
||||
CreateItemCacheSet(dwPID);
|
||||
|
||||
// ITEM_LOAD_LOG_ATTACH_PID
|
||||
@@ -691,7 +765,7 @@ void CClientManager::RESULT_ITEM_LOAD(CPeer * peer, MYSQL_RES * pRes, DWORD dwHa
|
||||
peer->Encode(&s_items[0], sizeof(TPlayerItem) * dwCount);
|
||||
|
||||
for (DWORD i = 0; i < dwCount; ++i)
|
||||
PutItemCache(&s_items[i], true); // 로드한 것은 따로 저장할 필요 없으므로, 인자 bSkipQuery에 true를 넣는다.
|
||||
PutItemCache(&s_items[i], true); // 로드한 것은 따로 저장할 필요 없으므로, 인자 bSkipQuery에 true를 넣는다.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,7 +773,7 @@ void CClientManager::RESULT_AFFECT_LOAD(CPeer * peer, MYSQL_RES * pRes, DWORD dw
|
||||
{
|
||||
int iNumRows;
|
||||
|
||||
if ((iNumRows = mysql_num_rows(pRes)) == 0) // 데이터 없음
|
||||
if ((iNumRows = mysql_num_rows(pRes)) == 0) // 데이터 없음
|
||||
return;
|
||||
|
||||
static std::vector<TPacketAffectElement> s_elements;
|
||||
@@ -778,6 +852,7 @@ void CClientManager::RESULT_QUEST_LOAD(CPeer * peer, MYSQL_RES * pRes, DWORD dwH
|
||||
*/
|
||||
void CClientManager::QUERY_PLAYER_SAVE(CPeer * peer, DWORD dwHandle, TPlayerTable * pkTab)
|
||||
{
|
||||
if(!EconomySaveAllowed(peer,pkTab->id))return;
|
||||
if (g_test_server)
|
||||
sys_log(0, "PLAYER_SAVE: %s", pkTab->name);
|
||||
|
||||
@@ -794,9 +869,9 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC
|
||||
{
|
||||
char queryStr[QUERY_MAX_LEN];
|
||||
int queryLen;
|
||||
int player_id;
|
||||
DWORD player_id = 0;
|
||||
|
||||
// 한 계정에 X초 내로 캐릭터 생성을 할 수 없다.
|
||||
// 한 계정에 X초 내로 캐릭터 생성을 할 수 없다.
|
||||
time_by_id_map_t::iterator it = s_createTimeByAccountID.find(packet->account_id);
|
||||
|
||||
if (it != s_createTimeByAccountID.end())
|
||||
@@ -880,17 +955,17 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC
|
||||
"skill_level, quickslot) "
|
||||
"VALUES(0, %u, '%s', %d, %d, %d, %d, %d, "
|
||||
"%d, %d, %d, %d, %d, %d, %d, "
|
||||
"%d, %d, %d, %d, %d, %d, %d, 0, %d, 0, ",
|
||||
"%d, %d, %d, %d, %d, %d, %d, 0, %lld, 0, ",
|
||||
GetTablePostfix(),
|
||||
packet->account_id, packet->player_table.name, packet->player_table.level, packet->player_table.st, packet->player_table.ht, packet->player_table.dx, packet->player_table.iq,
|
||||
packet->player_table.job, packet->player_table.voice, packet->player_table.dir, packet->player_table.x, packet->player_table.y, packet->player_table.z,
|
||||
packet->player_table.hp, packet->player_table.sp, packet->player_table.sRandomHP, packet->player_table.sRandomSP, packet->player_table.stat_point, packet->player_table.stamina, packet->player_table.part_base, packet->player_table.part_base, packet->player_table.gold);
|
||||
packet->player_table.hp, packet->player_table.sp, packet->player_table.sRandomHP, packet->player_table.sRandomSP, packet->player_table.stat_point, packet->player_table.stamina, packet->player_table.part_base, packet->player_table.part_base, (long long) packet->player_table.gold);
|
||||
|
||||
sys_log(0, "PlayerCreate accountid %d name %s level %d gold %d, st %d ht %d job %d",
|
||||
sys_log(0, "PlayerCreate accountid %d name %s level %d gold %lld, st %d ht %d job %d",
|
||||
packet->account_id,
|
||||
packet->player_table.name,
|
||||
packet->player_table.level,
|
||||
packet->player_table.gold,
|
||||
(long long) packet->player_table.gold,
|
||||
packet->player_table.st,
|
||||
packet->player_table.ht,
|
||||
packet->player_table.job);
|
||||
@@ -909,24 +984,23 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC
|
||||
if (g_test_server)
|
||||
sys_log(0, "Create_Player queryLen[%d] TEXT[%s]", queryLen, text);
|
||||
|
||||
if (pMsg2->Get()->uiAffectedRows <= 0)
|
||||
if (!pMsg2->Get()->HasAffectedRows() || !pMsg2->Get()->GetInsertID32(player_id))
|
||||
{
|
||||
peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_ALREADY, dwHandle, 0);
|
||||
sys_log(0, "ALREADY EXIST3 query: %s AffectedRows %lu", queryStr, pMsg2->Get()->uiAffectedRows);
|
||||
sys_log(0, "ALREADY EXIST3 query: %s AffectedRows %llu", queryStr, static_cast<unsigned long long>(pMsg2->Get()->uiAffectedRows));
|
||||
return;
|
||||
}
|
||||
|
||||
player_id = pMsg2->Get()->uiInsertID;
|
||||
|
||||
snprintf(queryStr, sizeof(queryStr), "UPDATE player_index%s SET pid%d=%d WHERE id=%d",
|
||||
snprintf(queryStr, sizeof(queryStr), "UPDATE player_index%s SET pid%d=%u WHERE id=%u",
|
||||
GetTablePostfix(), packet->account_index + 1, player_id, packet->account_id);
|
||||
std::unique_ptr<SQLMsg> pMsg3(CDBManager::instance().DirectQuery(queryStr));
|
||||
|
||||
if (pMsg3->Get()->uiAffectedRows <= 0)
|
||||
if (!pMsg3->Get()->HasAffectedRows())
|
||||
{
|
||||
sys_err("QUERY_ERROR: %s", queryStr);
|
||||
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM player%s WHERE id=%d", GetTablePostfix(), player_id);
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM player%s WHERE id=%u", GetTablePostfix(), player_id);
|
||||
CDBManager::instance().DirectQuery(queryStr);
|
||||
|
||||
peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
|
||||
@@ -1027,7 +1101,7 @@ void CClientManager::__QUERY_PLAYER_DELETE(CPeer* peer, DWORD dwHandle, TPlayerD
|
||||
}
|
||||
|
||||
//
|
||||
// @version 05/06/10 Bang2ni - 플레이어 삭제시 가격정보 리스트 삭제 추가.
|
||||
// @version 05/06/10 Bang2ni - 플레이어 삭제시 가격정보 리스트 삭제 추가.
|
||||
//
|
||||
void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg)
|
||||
{
|
||||
@@ -1063,13 +1137,18 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg)
|
||||
return;
|
||||
}
|
||||
|
||||
if(!EconomyCanDelete(dwPID)) {
|
||||
peer->EncodeHeader(HEADER_DG_PLAYER_DELETE_FAILED,pi->dwHandle,1);
|
||||
peer->EncodeBYTE(pi->account_index);
|
||||
delete pi;return;
|
||||
}
|
||||
char queryStr[QUERY_MAX_LEN];
|
||||
|
||||
snprintf(queryStr, sizeof(queryStr), "INSERT INTO player%s_deleted SELECT * FROM player%s WHERE id=%d",
|
||||
GetTablePostfix(), GetTablePostfix(), pi->player_id);
|
||||
std::unique_ptr<SQLMsg> pIns(CDBManager::instance().DirectQuery(queryStr));
|
||||
|
||||
if (pIns->Get()->uiAffectedRows == 0 || pIns->Get()->uiAffectedRows == (uint32_t)-1)
|
||||
if (pIns->Get()->uiAffectedRows == 0 || pIns->Get()->uiAffectedRows == UINT64_MAX)
|
||||
{
|
||||
sys_log(0, "PLAYER_DELETE FAILED %u CANNOT INSERT TO player%s_deleted", dwPID, GetTablePostfix());
|
||||
|
||||
@@ -1078,14 +1157,14 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg)
|
||||
return;
|
||||
}
|
||||
|
||||
// 삭제 성공
|
||||
// 삭제 성공
|
||||
sys_log(0, "PLAYER_DELETE SUCCESS %u", dwPID);
|
||||
|
||||
char account_index_string[16];
|
||||
|
||||
snprintf(account_index_string, sizeof(account_index_string), "player_id%d", m_iPlayerIDStart + pi->account_index);
|
||||
|
||||
// 플레이어 테이블을 캐쉬에서 삭제한다.
|
||||
// 플레이어 테이블을 캐쉬에서 삭제한다.
|
||||
CPlayerTableCache * pkPlayerCache = GetPlayerCache(pi->player_id);
|
||||
|
||||
if (pkPlayerCache)
|
||||
@@ -1094,7 +1173,7 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg)
|
||||
delete pkPlayerCache;
|
||||
}
|
||||
|
||||
// 아이템들을 캐쉬에서 삭제한다.
|
||||
// 아이템들을 캐쉬에서 삭제한다.
|
||||
TItemCacheSet * pSet = GetItemCacheSet(pi->player_id);
|
||||
|
||||
if (pSet)
|
||||
@@ -1121,7 +1200,7 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg)
|
||||
|
||||
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(queryStr));
|
||||
|
||||
if (pMsg->Get()->uiAffectedRows == 0 || pMsg->Get()->uiAffectedRows == (uint32_t)-1)
|
||||
if (pMsg->Get()->uiAffectedRows == 0 || pMsg->Get()->uiAffectedRows == UINT64_MAX)
|
||||
{
|
||||
sys_log(0, "PLAYER_DELETE FAIL WHEN UPDATE account table");
|
||||
peer->EncodeHeader(HEADER_DG_PLAYER_DELETE_FAILED, pi->dwHandle, 1);
|
||||
@@ -1132,7 +1211,15 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg)
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM player%s WHERE id=%d", GetTablePostfix(), pi->player_id);
|
||||
delete CDBManager::instance().DirectQuery(queryStr);
|
||||
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM item%s WHERE owner_id=%d AND (window < %d or window = %d)", GetTablePostfix(), pi->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY);
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM item%s WHERE owner_id=%d AND (window < %d or window = %d or window = %d"
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
" or (window >= %d and window <= %d)"
|
||||
#endif
|
||||
")", GetTablePostfix(), pi->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
, UPGRADE_INVENTORY, COSTUME_INVENTORY
|
||||
#endif
|
||||
);
|
||||
delete CDBManager::instance().DirectQuery(queryStr);
|
||||
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM quest%s WHERE dwPID=%d", GetTablePostfix(), pi->player_id);
|
||||
@@ -1157,7 +1244,7 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg)
|
||||
}
|
||||
else
|
||||
{
|
||||
// 삭제 실패
|
||||
// 삭제 실패
|
||||
sys_log(0, "PLAYER_DELETE FAIL NO ROW");
|
||||
peer->EncodeHeader(HEADER_DG_PLAYER_DELETE_FAILED, pi->dwHandle, 1);
|
||||
peer->EncodeBYTE(pi->account_index);
|
||||
@@ -1242,7 +1329,7 @@ void CClientManager::RESULT_HIGHSCORE_REGISTER(CPeer * pkPeer, SQLMsg * msg)
|
||||
|
||||
if (res->uiNumRows == 0)
|
||||
{
|
||||
// 새로운 하이스코어를 삽입
|
||||
// 새로운 하이스코어를 삽입
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "INSERT INTO highscore%s VALUES('%s', %u, %d)", GetTablePostfix(), szBoard, pi->player_id, value);
|
||||
CDBManager::instance().AsyncQuery(buf);
|
||||
@@ -1277,7 +1364,7 @@ void CClientManager::RESULT_HIGHSCORE_REGISTER(CPeer * pkPeer, SQLMsg * msg)
|
||||
CDBManager::instance().AsyncQuery(buf);
|
||||
}
|
||||
}
|
||||
// TODO: 이곳에서 하이스코어가 업데이트 되었는지 체크하여 공지를 뿌려야한다.
|
||||
// TODO: 이곳에서 하이스코어가 업데이트 되었는지 체크하여 공지를 뿌려야한다.
|
||||
delete pi;
|
||||
}
|
||||
|
||||
@@ -1285,10 +1372,10 @@ void CClientManager::InsertLogoutPlayer(DWORD pid)
|
||||
{
|
||||
TLogoutPlayerMap::iterator it = m_map_logout.find(pid);
|
||||
|
||||
// 존재하지 않을경우 추가
|
||||
// 존재하지 않을경우 추가
|
||||
if (it != m_map_logout.end())
|
||||
{
|
||||
// 존재할경우 시간만 갱신
|
||||
// 존재할경우 시간만 갱신
|
||||
if (g_log)
|
||||
sys_log(0, "LOGOUT: Update player time pid(%d)", pid);
|
||||
|
||||
|
||||
@@ -26,72 +26,48 @@ void CConfig::NextLine(FILE *fp)
|
||||
}
|
||||
}
|
||||
|
||||
bool CConfig::GetWord(FILE *fp, char *tar)
|
||||
bool CConfig::GetWord(FILE *fp, char *dest, size_t size)
|
||||
{
|
||||
int i = 0;
|
||||
int c;
|
||||
|
||||
int semicolon_mode = 0;
|
||||
|
||||
while ((c = fgetc(fp)) != EOF)
|
||||
{
|
||||
if (c == 13)
|
||||
continue;
|
||||
|
||||
if (semicolon_mode)
|
||||
{
|
||||
if (c == '"')
|
||||
{
|
||||
tar[i] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
tar[i++] = c;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
if (c == '"')
|
||||
{
|
||||
semicolon_mode = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == ' ' || c == '\t' || c == '\n')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((c == ' ' || c == '\t' || c == '\n'))
|
||||
{
|
||||
// ÅÜ.
|
||||
tar[i] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
tar[i] = c;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
return (i != 0);
|
||||
if (!fp || !dest || !size) { m_readError = true; return false; }
|
||||
size_t used = 0;
|
||||
bool quoted = false, started = false;
|
||||
dest[0] = 0;
|
||||
int c;
|
||||
while ((c = fgetc(fp)) != EOF)
|
||||
{
|
||||
if (c == 0) { m_readError = true; return false; }
|
||||
if (c == '\r') continue;
|
||||
if (!started)
|
||||
{
|
||||
if (c == ' ' || c == '\t' || c == '\n') continue;
|
||||
started = true;
|
||||
if (c == '"') { quoted = true; continue; }
|
||||
}
|
||||
if ((quoted && c == '"') || (!quoted && (c == ' ' || c == '\t' || c == '\n')))
|
||||
return true;
|
||||
if (used + 1 >= size) { m_readError = true; return false; }
|
||||
dest[used++] = static_cast<char>(c); // fgetc returned a byte, not EOF.
|
||||
dest[used] = 0;
|
||||
}
|
||||
if (ferror(fp) || quoted) m_readError = true;
|
||||
return started && !m_readError;
|
||||
}
|
||||
|
||||
bool CConfig::GetLine(FILE* fp, char*dest)
|
||||
bool CConfig::GetLine(FILE *fp, char *dest, size_t size)
|
||||
{
|
||||
int c;
|
||||
int i = 0;
|
||||
while ((c = fgetc(fp)) != EOF)
|
||||
{
|
||||
if (c == '\n')
|
||||
return true;
|
||||
dest[i] = c;
|
||||
++i;
|
||||
}
|
||||
return true;
|
||||
if (!fp || !dest || !size) { m_readError = true; return false; }
|
||||
size_t used = 0;
|
||||
dest[0] = 0;
|
||||
int c;
|
||||
while ((c = fgetc(fp)) != EOF)
|
||||
{
|
||||
if (c == '\n') return true;
|
||||
if (c == 0 || used + 1 >= size) { m_readError = true; return false; }
|
||||
dest[used++] = static_cast<char>(c);
|
||||
dest[used] = 0;
|
||||
}
|
||||
if (ferror(fp)) m_readError = true;
|
||||
return !m_readError;
|
||||
}
|
||||
|
||||
bool CConfig::LoadFile(const char* filename)
|
||||
@@ -105,8 +81,10 @@ bool CConfig::LoadFile(const char* filename)
|
||||
return false;
|
||||
|
||||
int mode = 0;
|
||||
m_readError = false;
|
||||
TValueMap staged = m_valueMap;
|
||||
|
||||
while (GetWord(fp, szTmp))
|
||||
while (GetWord(fp, szTmp, sizeof(szTmp)))
|
||||
{
|
||||
if (strcmp(szTmp, "//") == 0)
|
||||
{
|
||||
@@ -128,15 +106,15 @@ bool CConfig::LoadFile(const char* filename)
|
||||
|
||||
case 2:
|
||||
mode = 0;
|
||||
m_valueMap.insert(TValueMap::value_type(comment, szTmp));
|
||||
staged.insert(TValueMap::value_type(comment, szTmp));
|
||||
break;
|
||||
}
|
||||
|
||||
// ITEM_ID_RANGE
|
||||
if (mode == 2 && strcmp(comment, "ITEM_ID_RANGE") == 0)
|
||||
{
|
||||
GetLine(fp, szTmp);
|
||||
m_valueMap.insert(TValueMap::value_type(comment, szTmp));
|
||||
if (!GetLine(fp, szTmp, sizeof(szTmp))) break;
|
||||
staged.insert(TValueMap::value_type(comment, szTmp));
|
||||
mode = 0;
|
||||
|
||||
}
|
||||
@@ -145,8 +123,10 @@ bool CConfig::LoadFile(const char* filename)
|
||||
|
||||
|
||||
// ÆÄÀÏ ´Ý´Â ºÎºÐ.
|
||||
const bool valid = !m_readError && !ferror(fp) && mode == 0;
|
||||
fclose(fp);
|
||||
return true;
|
||||
if (valid) m_valueMap.swap(staged);
|
||||
return valid;
|
||||
}
|
||||
|
||||
std::string * CConfig::Search(const char* key)
|
||||
@@ -165,11 +145,14 @@ bool CConfig::GetParam(const char*key, int index, DWORD *Param)
|
||||
if (!pstStr)
|
||||
return false;
|
||||
|
||||
char szParam[5][32];
|
||||
if (!Param || index < 0 || index >= 5) return false;
|
||||
char szParam[5][32] = {};
|
||||
|
||||
sscanf(pstStr->c_str(), "%s %s %s %s %s", szParam[0],szParam[1],szParam[2],szParam[3],szParam[4]);
|
||||
if (sscanf(pstStr->c_str(), "%31s %31s %31s %31s %31s", szParam[0],szParam[1],szParam[2],szParam[3],szParam[4]) <= index) return false;
|
||||
|
||||
str_to_number(*Param, szParam[index]);
|
||||
unsigned long long value = 0;
|
||||
if (!str_to_number(value, szParam[index]) || value > UINT32_MAX) return false;
|
||||
*Param = static_cast<DWORD>(value);
|
||||
|
||||
sys_log(0, "GetParam %d", *Param);
|
||||
return true;
|
||||
@@ -239,12 +222,15 @@ bool CConfig::GetValue(const char * key, char *dest, size_t destSize)
|
||||
|
||||
bool CConfig::GetTwoValue(const char* key, DWORD * dest1, DWORD *dest2)
|
||||
{
|
||||
if (!GetParam(key, 0, dest1))
|
||||
DWORD first=0, second=0;
|
||||
if (!dest1 || !dest2) return false;
|
||||
if (!GetParam(key, 0, &first))
|
||||
return false;
|
||||
|
||||
if (!GetParam(key, 1, dest2))
|
||||
if (!GetParam(key, 1, &second))
|
||||
return false;
|
||||
|
||||
*dest1=first; *dest2=second;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ class CConfig : public singleton<CConfig>
|
||||
bool GetValue(const char* key, DWORD* dest);
|
||||
bool GetValue(const char* key, BYTE* dest);
|
||||
bool GetValue(const char* key, char* dest, size_t destSize);
|
||||
bool GetWord(FILE* fp, char* dest);
|
||||
bool GetLine(FILE* fp, char* dest);
|
||||
bool GetWord(FILE* fp, char* dest, size_t size);
|
||||
bool GetLine(FILE* fp, char* dest, size_t size);
|
||||
bool GetTwoValue(const char* key, DWORD * dest1, DWORD *dest2);
|
||||
void NextLine(FILE* fp);
|
||||
|
||||
@@ -29,6 +29,7 @@ class CConfig : public singleton<CConfig>
|
||||
|
||||
private:
|
||||
TValueMap m_valueMap;
|
||||
bool m_readError = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,6 +46,10 @@ class CDBManager : public singleton<CDBManager>
|
||||
|
||||
void ReturnQuery(const char * c_pszQuery, int iType, DWORD dwIdent, void * pvData, int iSlot = SQL_PLAYER);
|
||||
void AsyncQuery(const char * c_pszQuery, int iSlot = SQL_PLAYER);
|
||||
void EconomyAsyncFence(DWORD pid) { m_asyncSQL[SQL_PLAYER]->ReturnQuery("SELECT 1",reinterpret_cast<void*>(static_cast<uintptr_t>(pid))); }
|
||||
SQLMsg* PopEconomyAsyncFence() { SQLMsg* message=nullptr;return m_asyncSQL[SQL_PLAYER]->PopResult(&message)?message:nullptr; }
|
||||
uint64_t EconomyFailures(bool async) { return (async?m_asyncSQL[SQL_PLAYER]:m_mainSQL[SQL_PLAYER])->FailureEpoch(); }
|
||||
MYSQL* DirectHandle(int slot=SQL_PLAYER) { return m_directSQL[slot]->GetSQLHandle(); }
|
||||
SQLMsg * DirectQuery(const char * c_pszQuery, int iSlot = SQL_PLAYER);
|
||||
|
||||
SQLMsg * PopResult();
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
#include "stdafx.h"
|
||||
#include "ClientManager.h"
|
||||
#include "Cache.h"
|
||||
#include "QID.h"
|
||||
#include "Main.h"
|
||||
#include "../../common/economy_mysql.h"
|
||||
#include <memory>
|
||||
#include "../../common/economy_view.h"
|
||||
|
||||
namespace {
|
||||
using namespace PortEconomy;
|
||||
using Query=std::unique_ptr<SQLMsg>;
|
||||
Query query(const std::string& sql){return Query(CDBManager::instance().DirectQuery(sql.c_str()));}
|
||||
bool valid(const Query& q){return q&&!q->uiSQLErrno&&q->Get();}
|
||||
// Schema installation/removal requires a coordinated restart. An absent schema
|
||||
// is detected once without issuing failing SQL for every ordinary item save.
|
||||
int schema() {
|
||||
static int state=-1;if(state>=0)return state;
|
||||
auto q=query("SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='port_economy_version'");
|
||||
if(!valid(q)||q->Get()->uiNumRows!=1)return -1;
|
||||
MYSQL_ROW row=mysql_fetch_row(q->Get()->pSQLResult);if(!row||!row[0])return -1;
|
||||
state=std::string(row[0])=="1"?1:0;return state;
|
||||
}
|
||||
bool owns(CLoginData* login,CPeer* peer,DWORD pid,bool playing) {
|
||||
if(!login || login->GetConnectedPeerHandle()!=peer->GetHandle() || login->IsPlay()!=playing)return false;
|
||||
for(const auto& p:login->GetAccountRef().players)if(p.dwID==pid)return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CClientManager::EconomyRequest(CPeer* peer,DWORD handle,const char* data,DWORD length) {
|
||||
if(length!=sizeof(PortEconomy::Request)||!peer->GetChannel())return;
|
||||
PortEconomy::Request r;memcpy(&r,data,sizeof(r));
|
||||
if(!PortEconomy::Valid(r)||!owns(GetLoginDataByAID(r.account),peer,r.player,true))return;
|
||||
PortEconomy::Reply reply={};reply.account=r.account;reply.player=r.player;
|
||||
auto send=[&](const std::string& text,bool success){reply.ok=success;const std::string message=r.operation==PortEconomy::UiStatus&&text.find("MTECON1 ")!=0?"MTECON1 error "+std::to_string(r.generation)+" storage":text;strlcpy(reply.message,message.c_str(),sizeof(reply.message));peer->EncodeHeader(PortEconomy::Header,handle,sizeof(reply));peer->Encode(&reply,sizeof(reply));};
|
||||
if(*GetTablePostfix()||schema()!=1){send("Economy transactions require the unsuffixed player schema.",false);return;}
|
||||
PortEconomy::Mysql mysql(CDBManager::instance().DirectHandle());
|
||||
PortEconomy::Store<PortEconomy::Mysql> store(mysql,[&](uint32_t vnum){auto it=m_map_itemTableByVnum.find(vnum);return it==m_map_itemTableByVnum.end()?0u:unsigned(it->second->bSize);});
|
||||
if(!store.Ready()){send("Economy storage is unavailable; no payment was made.",false);return;}
|
||||
if(r.operation==PortEconomy::UiStatus) {
|
||||
std::vector<std::string> frames;
|
||||
if(!PortEconomy::View(mysql,r,[&](uint32_t vnum){auto it=m_map_itemTableByVnum.find(vnum);return it==m_map_itemTableByVnum.end()?0u:unsigned(it->second->bSize);},frames)) {
|
||||
send("MTECON1 error "+std::to_string(r.generation)+" storage",false);return;
|
||||
}
|
||||
for(const auto& frame:frames)send(frame,true);
|
||||
return;
|
||||
}
|
||||
if(r.operation==PortEconomy::Status) {
|
||||
PortEconomy::Rows rows;
|
||||
if(!mysql.Query("SELECT token,result,reference FROM port_economy_requests WHERE pid="+std::to_string(r.player)+" ORDER BY created_at DESC,token DESC LIMIT 3",rows)){send("Economy storage is unavailable.",false);return;}
|
||||
std::string text="Recent transactions:";
|
||||
for(const auto& row:rows)text+=" "+row[1]+" #"+row[2];send(text,true);
|
||||
if(mysql.Query("SELECT l.id,l.price,l.state,COALESCE(c.vnum,0),COALESCE(c.count,0) FROM port_economy_listings l LEFT JOIN port_economy_custody c ON c.id=l.item WHERE l.state='OPEN' OR l.owner="+std::to_string(r.player)+" ORDER BY l.id DESC LIMIT 5 OFFSET "+std::to_string(r.reference*5),rows))for(const auto& row:rows)send("Listing #"+row[0]+" vnum="+row[3]+" count="+row[4]+" price="+row[1]+" "+row[2],true);
|
||||
if(mysql.Query("SELECT id,state FROM port_economy_orders WHERE buyer="+std::to_string(r.player)+" ORDER BY id DESC LIMIT 5 OFFSET "+std::to_string(r.reference*5),rows))for(const auto& row:rows)send("Order #"+row[0]+" "+row[1],true);
|
||||
if(mysql.Query("SELECT amount FROM port_economy_credit WHERE pid="+std::to_string(r.player),rows))send("Unclaimed proceeds: "+(rows.empty()?std::string("0"):rows[0][0]),true);
|
||||
return;
|
||||
}
|
||||
if(r.operation==PortEconomy::List) {
|
||||
auto it=m_map_itemTableByVnum.find(r.itemVnum);
|
||||
if(it==m_map_itemTableByVnum.end() || (it->second->dwAntiFlags&(ITEM_ANTIFLAG_GIVE|ITEM_ANTIFLAG_MYSHOP)) || it->second->bType==ITEM_QUEST) {send("This item cannot be listed.",false);return;}
|
||||
}
|
||||
// Materialized Gaya stacks are generated by game using the normal item
|
||||
// factory. Validate proto stack limits before accepting their durable IDs.
|
||||
for(unsigned i=0;i<r.rewardCount;++i) {
|
||||
const auto& reward=r.rewards[i];auto it=m_map_itemTableByVnum.find(reward.vnum);
|
||||
if(it==m_map_itemTableByVnum.end() || reward.count>2000 || (!(it->second->dwFlags&ITEM_FLAG_STACKABLE)&&reward.count!=1)){send("Invalid reward stack.",false);return;}
|
||||
}
|
||||
if(store.Enqueue(r)) {
|
||||
m_economyOwners[r.player]=r.account;
|
||||
m_economyEnqueueEpoch.emplace(r.player,std::make_pair(CDBManager::instance().EconomyFailures(false),CDBManager::instance().EconomyFailures(true)));
|
||||
send("Transaction queued. Reconnect and select the character to settle it; use /mt_economy status for the result.",true);
|
||||
} else send("Transaction was not accepted, or another request is pending. Reconnect to recover it.",false);
|
||||
}
|
||||
|
||||
bool CClientManager::EconomyBeforeLoad(CPeer* peer,DWORD handle,TPlayerLoadPacket* packet) {
|
||||
if(*GetTablePostfix())return true;
|
||||
const int installed=schema();if(installed==0)return true;if(installed<0)return false;
|
||||
// Existing ownership checks must run before evicting or fencing any cache.
|
||||
auto* login=GetLoginDataByAID(packet->account_id);
|
||||
if(!owns(login,peer,packet->player_id,false))return false;
|
||||
for(const auto& running:m_economyFences)if(running.second.account==packet->account_id)return false;
|
||||
auto pending=query("SELECT token FROM port_economy_pending WHERE pid="+std::to_string(packet->player_id));
|
||||
if(!valid(pending))return false;
|
||||
if(!pending->Get()->uiNumRows){m_economyClosed.erase(packet->player_id);return true;}
|
||||
m_economyOwners[packet->player_id]=packet->account_id;
|
||||
m_economyClosed.insert(packet->player_id);
|
||||
EconomyFence fence;fence.account=packet->account_id;fence.peer=peer->GetHandle();fence.handle=handle;fence.load=*packet;
|
||||
auto& database=CDBManager::instance();
|
||||
auto epoch=m_economyEnqueueEpoch.find(packet->player_id);
|
||||
fence.mainFailures=epoch==m_economyEnqueueEpoch.end()?database.EconomyFailures(false):epoch->second.first;
|
||||
fence.asyncFailures=epoch==m_economyEnqueueEpoch.end()?database.EconomyFailures(true):epoch->second.second;
|
||||
m_economyFences[packet->player_id]=fence;
|
||||
// Eviction sends every dirty snapshot before the two FIFO barriers. Never
|
||||
// settle on a cached player, including caches still awaiting logout timeout.
|
||||
FlushItemCacheSet(packet->player_id);FlushPlayerCacheSet(packet->player_id);
|
||||
DeleteLogoutPlayer(packet->player_id);
|
||||
database.ReturnQuery("SELECT 1",QID_ECONOMY_FENCE,packet->player_id,nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
void CClientManager::EconomyMainFence(DWORD pid,bool failed) {
|
||||
auto it=m_economyFences.find(pid);if(it==m_economyFences.end())return;
|
||||
it->second.failed|=failed;
|
||||
if(!it->second.primed) {
|
||||
// Earlier load callbacks may themselves queue saves (e.g. mall awards).
|
||||
// A second main barrier and an async barrier follow those callbacks.
|
||||
it->second.primed=true;
|
||||
CDBManager::instance().ReturnQuery("SELECT 1",QID_ECONOMY_FENCE,pid,nullptr);
|
||||
CDBManager::instance().EconomyAsyncFence(pid);
|
||||
} else it->second.mainDone=true;
|
||||
}
|
||||
void CClientManager::EconomyTick() {
|
||||
auto& database=CDBManager::instance();
|
||||
while(SQLMsg* raw=database.PopEconomyAsyncFence()) {
|
||||
Query q(raw);DWORD pid=static_cast<DWORD>(reinterpret_cast<uintptr_t>(q->pvUserData));
|
||||
auto it=m_economyFences.find(pid);if(it!=m_economyFences.end()){it->second.asyncDone=true;it->second.failed|=q->uiSQLErrno!=0;}
|
||||
}
|
||||
for(auto it=m_economyFences.begin();it!=m_economyFences.end();) {
|
||||
auto& fence=it->second;
|
||||
if(fence.nextAttempt>time(nullptr)){++it;continue;}
|
||||
if(!fence.mainDone||!fence.asyncDone){++it;continue;}
|
||||
auto* login=GetLoginDataByAID(fence.account);
|
||||
if(login&&login->IsPlay()){++it;continue;}
|
||||
PortEconomy::Mysql mysql(database.DirectHandle());
|
||||
PortEconomy::Store<PortEconomy::Mysql> store(mysql,[&](uint32_t vnum){auto p=m_map_itemTableByVnum.find(vnum);return p==m_map_itemTableByVnum.end()?0u:unsigned(p->second->bSize);});
|
||||
const bool failed=fence.failed||database.EconomyFailures(false)!=fence.mainFailures||database.EconomyFailures(true)!=fence.asyncFailures;
|
||||
bool done=failed?store.Abort(it->first,fence.account):store.Settle(it->first,fence.account)!=PortEconomy::Store<PortEconomy::Mysql>::Retry;
|
||||
if(done) {
|
||||
m_economyEnqueueEpoch.erase(it->first);
|
||||
sys_log(0,"ECONOMY_SETTLE pid=%u outcome=%s ref=%llu",it->first,failed?"save_failed":store.Outcome().c_str(),static_cast<unsigned long long>(store.Reference()));
|
||||
EconomyFence completed=fence;it=m_economyFences.erase(it);
|
||||
if(CPeer* peer=GetPeer(completed.peer))QUERY_PLAYER_LOAD(peer,completed.handle,&completed.load);
|
||||
} else {fence.nextAttempt=time(nullptr)+5;++it;}
|
||||
}
|
||||
}
|
||||
|
||||
bool CClientManager::EconomySaveAllowed(CPeer* peer,DWORD pid) {
|
||||
if(m_economyClosed.count(pid))return false;
|
||||
auto it=m_economyOwners.find(pid);if(it==m_economyOwners.end())return true;
|
||||
return owns(GetLoginDataByAID(it->second),peer,pid,true);
|
||||
}
|
||||
bool CClientManager::EconomyItemWritable(DWORD id) {
|
||||
if(*GetTablePostfix())return true;
|
||||
const int installed=schema();if(installed==0)return true;if(installed<0)return false;
|
||||
auto q=query("SELECT id FROM port_economy_custody WHERE id="+std::to_string(id));
|
||||
if(!valid(q))return false;
|
||||
return q->Get()->uiNumRows==0;
|
||||
}
|
||||
|
||||
// Native character deletion must not strand escrow, pending refunds, proceeds
|
||||
// or a migrated catalogue outside the tables that legacy deletion cleans up.
|
||||
// Catalogue users need an explicit audited retirement, not an implicit reset.
|
||||
bool CClientManager::EconomyCanDelete(DWORD pid) {
|
||||
if(*GetTablePostfix())return true;
|
||||
const int installed=schema();if(installed==0)return true;if(installed<0)return false;
|
||||
if(m_economyFences.count(pid)||m_economyClosed.count(pid))return false;
|
||||
const std::string id=std::to_string(pid);
|
||||
auto q=query("SELECT (EXISTS(SELECT 1 FROM port_economy_pending WHERE pid="+id+"))+(EXISTS(SELECT 1 FROM port_economy_listings WHERE owner="+id+" AND state IN('OPEN','RESERVED')))+(EXISTS(SELECT 1 FROM port_economy_orders WHERE buyer="+id+" AND state='READY'))+(EXISTS(SELECT 1 FROM port_economy_credit WHERE pid="+id+" AND amount<>0))+(EXISTS(SELECT 1 FROM port_economy_gaya WHERE pid="+id+" AND generation<>"+std::to_string(PortEconomy::RetiredGeneration)+"))+(EXISTS(SELECT 1 FROM port_economy_gaya WHERE pid="+id+" AND generation="+std::to_string(PortEconomy::RetiredGeneration)+" AND EXISTS(SELECT 1 FROM quest WHERE dwPID="+id+" AND szName='gem' AND szState='points' AND lValue<>0)))");
|
||||
if(!valid(q)||q->Get()->uiNumRows!=1)return false;
|
||||
MYSQL_ROW row=mysql_fetch_row(q->Get()->pSQLResult);return row&&row[0]&&std::string(row[0])=="0";
|
||||
}
|
||||
@@ -765,9 +765,9 @@ void CGuildManager::UseSkill(DWORD GID, DWORD dwSkillVnum, DWORD dwCooltime)
|
||||
// END_OF_GUILD_SKILL_COOLTIME_BUG_FIX
|
||||
}
|
||||
|
||||
void CGuildManager::MoneyChange(DWORD dwGuild, DWORD dwGold)
|
||||
void CGuildManager::MoneyChange(DWORD dwGuild, int64_t dwGold)
|
||||
{
|
||||
sys_log(0, "GuildManager::MoneyChange %d %d", dwGuild, dwGold);
|
||||
sys_log(0, "GuildManager::MoneyChange %u %lld", dwGuild, (long long)dwGold);
|
||||
|
||||
TPacketDGGuildMoneyChange p;
|
||||
p.dwGuild = dwGuild;
|
||||
@@ -775,11 +775,11 @@ void CGuildManager::MoneyChange(DWORD dwGuild, DWORD dwGold)
|
||||
CClientManager::instance().ForwardPacket(HEADER_DG_GUILD_MONEY_CHANGE, &p, sizeof(p));
|
||||
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "UPDATE guild%s SET gold=%u WHERE id = %u", GetTablePostfix(), dwGold, dwGuild);
|
||||
snprintf(buf, sizeof(buf), "UPDATE guild%s SET gold=%lld WHERE id = %u", GetTablePostfix(), (long long)dwGold, dwGuild);
|
||||
CDBManager::instance().AsyncQuery(buf);
|
||||
}
|
||||
|
||||
void CGuildManager::DepositMoney(DWORD dwGuild, INT iGold)
|
||||
void CGuildManager::DepositMoney(DWORD dwGuild, int64_t iGold)
|
||||
{
|
||||
if (iGold <= 0)
|
||||
return;
|
||||
@@ -793,12 +793,12 @@ void CGuildManager::DepositMoney(DWORD dwGuild, INT iGold)
|
||||
}
|
||||
|
||||
it->second.gold += iGold;
|
||||
sys_log(0, "GUILD: %u Deposit %u Total %d", dwGuild, iGold, it->second.gold);
|
||||
sys_log(0, "GUILD: %u Deposit %lld Total %lld", dwGuild, (long long)iGold, (long long)it->second.gold);
|
||||
|
||||
MoneyChange(dwGuild, it->second.gold);
|
||||
}
|
||||
|
||||
void CGuildManager::WithdrawMoney(CPeer* peer, DWORD dwGuild, INT iGold)
|
||||
void CGuildManager::WithdrawMoney(CPeer* peer, DWORD dwGuild, int64_t iGold)
|
||||
{
|
||||
itertype(m_map_kGuild) it = m_map_kGuild.find(dwGuild);
|
||||
|
||||
@@ -812,7 +812,7 @@ void CGuildManager::WithdrawMoney(CPeer* peer, DWORD dwGuild, INT iGold)
|
||||
if (it->second.gold >= iGold)
|
||||
{
|
||||
it->second.gold -= iGold;
|
||||
sys_log(0, "GUILD: %u Withdraw %d Total %d", dwGuild, iGold, it->second.gold);
|
||||
sys_log(0, "GUILD: %u Withdraw %lld Total %lld", dwGuild, (long long)iGold, (long long)it->second.gold);
|
||||
|
||||
TPacketDGGuildMoneyWithdraw p;
|
||||
p.dwGuild = dwGuild;
|
||||
@@ -823,14 +823,14 @@ void CGuildManager::WithdrawMoney(CPeer* peer, DWORD dwGuild, INT iGold)
|
||||
}
|
||||
}
|
||||
|
||||
void CGuildManager::WithdrawMoneyReply(DWORD dwGuild, BYTE bGiveSuccess, INT iGold)
|
||||
void CGuildManager::WithdrawMoneyReply(DWORD dwGuild, BYTE bGiveSuccess, int64_t iGold)
|
||||
{
|
||||
itertype(m_map_kGuild) it = m_map_kGuild.find(dwGuild);
|
||||
|
||||
if (it == m_map_kGuild.end())
|
||||
return;
|
||||
|
||||
sys_log(0, "GuildManager::WithdrawMoneyReply : guild %u success %d gold %d", dwGuild, bGiveSuccess, iGold);
|
||||
sys_log(0, "GuildManager::WithdrawMoneyReply : guild %u success %d gold %lld", dwGuild, bGiveSuccess, (long long)iGold);
|
||||
|
||||
if (!bGiveSuccess)
|
||||
it->second.gold += iGold;
|
||||
@@ -1067,13 +1067,12 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p)
|
||||
|
||||
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
if (pmsg->Get()->uiAffectedRows == 0 || pmsg->Get()->uiInsertID == 0 || pmsg->Get()->uiAffectedRows == (uint32_t)-1)
|
||||
if (pmsg->Get()->uiAffectedRows == 0 || !pmsg->Get()->GetInsertID32(t.dwID) || pmsg->Get()->uiAffectedRows == UINT64_MAX)
|
||||
{
|
||||
sys_err("GuildWar: Cannot insert row");
|
||||
return false;
|
||||
}
|
||||
|
||||
t.dwID = pmsg->Get()->uiInsertID;
|
||||
|
||||
m_map_kWarReserve.insert(std::make_pair(t.dwID, new CGuildWarReserve(t)));
|
||||
|
||||
@@ -1293,7 +1292,7 @@ bool CGuildWarReserve::Bet(const char * pszLogin, DWORD dwGold, DWORD dwGuild)
|
||||
|
||||
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
if (pmsg->Get()->uiAffectedRows == 0 || pmsg->Get()->uiAffectedRows == (uint32_t)-1)
|
||||
if (pmsg->Get()->uiAffectedRows == 0 || pmsg->Get()->uiAffectedRows == UINT64_MAX)
|
||||
{
|
||||
sys_log(0, "GuildWarReserve::Bet: failed. cannot insert row to guild_war_bet table");
|
||||
return false;
|
||||
|
||||
@@ -114,7 +114,7 @@ typedef struct SGuild
|
||||
int win;
|
||||
int draw;
|
||||
int loss;
|
||||
int gold;
|
||||
int64_t gold;
|
||||
int level;
|
||||
} TGuild;
|
||||
|
||||
@@ -191,12 +191,12 @@ class CGuildManager : public singleton<CGuildManager>
|
||||
|
||||
void UseSkill(DWORD dwGuild, DWORD dwSkillVnum, DWORD dwCooltime);
|
||||
|
||||
INT GetGuildGold(DWORD dwGuild);
|
||||
void DepositMoney(DWORD dwGuild, INT lGold);
|
||||
void WithdrawMoney(CPeer* peer, DWORD dwGuild, INT lGold);
|
||||
void WithdrawMoneyReply(DWORD dwGuild, BYTE bGiveSuccess, INT lGold);
|
||||
int64_t GetGuildGold(DWORD dwGuild);
|
||||
void DepositMoney(DWORD dwGuild, int64_t lGold);
|
||||
void WithdrawMoney(CPeer* peer, DWORD dwGuild, int64_t lGold);
|
||||
void WithdrawMoneyReply(DWORD dwGuild, BYTE bGiveSuccess, int64_t lGold);
|
||||
|
||||
void MoneyChange(DWORD dwGuild, DWORD dwGold);
|
||||
void MoneyChange(DWORD dwGuild, int64_t dwGold);
|
||||
|
||||
void QueryRanking();
|
||||
void ResultRanking(MYSQL_RES * pRes);
|
||||
|
||||
@@ -28,7 +28,7 @@ void ItemAwardManager::Load(SQLMsg * pMsg)
|
||||
{
|
||||
MYSQL_RES * pRes = pMsg->Get()->pSQLResult;
|
||||
|
||||
for (uint i = 0; i < pMsg->Get()->uiNumRows; ++i)
|
||||
for (uint64_t i = 0; i < pMsg->Get()->uiNumRows; ++i)
|
||||
{
|
||||
MYSQL_ROW row = mysql_fetch_row(pRes);
|
||||
int col = 0;
|
||||
|
||||
@@ -93,20 +93,45 @@ bool CItemIDRangeManager::BuildRange(DWORD dwMin, DWORD dwMax, TItemIDRangeTable
|
||||
|
||||
snprintf(szQuery, sizeof(szQuery), "SELECT MAX(id) FROM item%s WHERE id >= %u and id <= %u", GetTablePostfix(), dwMin, dwMax);
|
||||
|
||||
if(!*GetTablePostfix()) {
|
||||
// Legacy escrow remains reserved until explicit reconciliation. Closing
|
||||
// its UI must not make those original IDs available after a DB restart.
|
||||
auto* legacy=CDBManager::instance().DirectQuery("SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='offline_shop_item'");
|
||||
if(!legacy || legacy->uiSQLErrno || !legacy->Get() || legacy->Get()->uiNumRows!=1 || !legacy->Get()->pSQLResult){delete legacy;return false;}
|
||||
row=mysql_fetch_row(legacy->Get()->pSQLResult);
|
||||
const bool hasLegacy=row && row[0] && !strcmp(row[0],"1");
|
||||
const bool noLegacy=row && row[0] && !strcmp(row[0],"0");
|
||||
delete legacy;if(!hasLegacy && !noLegacy)return false;
|
||||
SQLMsg* version=CDBManager::instance().DirectQuery("SELECT version FROM port_economy_version WHERE id=1");
|
||||
if(!version)return false;
|
||||
const bool absent=version->uiSQLErrno==ER_NO_SUCH_TABLE;
|
||||
const bool valid=!version->uiSQLErrno && version->Get() && version->Get()->uiNumRows==1;
|
||||
delete version;
|
||||
if(!absent && !valid)return false;
|
||||
const std::string bounds=" WHERE id BETWEEN "+std::to_string(dwMin)+" AND "+std::to_string(dwMax);
|
||||
std::string sources="SELECT id FROM item"+bounds;
|
||||
if(hasLegacy)sources+=" UNION ALL SELECT id FROM offline_shop_item"+bounds;
|
||||
if(valid)sources+=" UNION ALL SELECT id FROM port_economy_custody"+bounds+" UNION ALL SELECT id FROM port_economy_item_reservations"+bounds;
|
||||
snprintf(szQuery,sizeof(szQuery),"SELECT MAX(id) FROM (%s) AS allocated_ids",sources.c_str());
|
||||
}
|
||||
pMsg = CDBManager::instance().DirectQuery(szQuery);
|
||||
if(!pMsg || pMsg->uiSQLErrno || !pMsg->Get() || pMsg->Get()->uiNumRows!=1 || !pMsg->Get()->pSQLResult){delete pMsg;return false;}
|
||||
|
||||
if (pMsg != NULL)
|
||||
{
|
||||
if (pMsg->Get()->uiNumRows > 0)
|
||||
if (pMsg->Get()->uiNumRows == 1 && pMsg->Get()->pSQLResult)
|
||||
{
|
||||
row = mysql_fetch_row(pMsg->Get()->pSQLResult);
|
||||
str_to_number(dwItemMaxID, row[0]);
|
||||
unsigned long long maximum=0;
|
||||
if(!row || (row[0] && (!str_to_number(maximum,row[0]) || maximum>UINT32_MAX))){delete pMsg;return false;}
|
||||
dwItemMaxID=static_cast<DWORD>(maximum);
|
||||
}
|
||||
delete pMsg;
|
||||
}
|
||||
|
||||
if (dwItemMaxID == 0)
|
||||
dwItemMaxID = dwMin;
|
||||
else if(dwItemMaxID>=dwMax)return false;
|
||||
else
|
||||
dwItemMaxID++;
|
||||
|
||||
@@ -126,28 +151,14 @@ bool CItemIDRangeManager::BuildRange(DWORD dwMin, DWORD dwMax, TItemIDRangeTable
|
||||
|
||||
pMsg = CDBManager::instance().DirectQuery(szQuery);
|
||||
|
||||
if (pMsg != NULL)
|
||||
{
|
||||
if (pMsg->Get()->uiNumRows > 0)
|
||||
{
|
||||
DWORD count = 0;
|
||||
row = mysql_fetch_row(pMsg->Get()->pSQLResult);
|
||||
str_to_number(count, row[0]);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
sys_err("ItemIDRange: Build: %u ~ %u\thave a item", range.dwUsableItemIDMin, range.dwMax);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_log(0, "ItemIDRange: Build: %u ~ %u start:%u", range.dwMin, range.dwMax, range.dwUsableItemIDMin);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
delete pMsg;
|
||||
}
|
||||
if(!pMsg || pMsg->uiSQLErrno || !pMsg->Get() || pMsg->Get()->uiNumRows!=1 || !pMsg->Get()->pSQLResult){delete pMsg;return false;}
|
||||
row=mysql_fetch_row(pMsg->Get()->pSQLResult);
|
||||
unsigned long long count=0;
|
||||
const bool empty=row && row[0] && str_to_number(count,row[0]) && count==0;
|
||||
delete pMsg;
|
||||
if(!empty)return false;
|
||||
sys_log(0,"ItemIDRange: Build: %u ~ %u start:%u",range.dwMin,range.dwMax,range.dwUsableItemIDMin);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -38,8 +38,8 @@ SRCS = Config.cpp NetBase.cpp Peer.cpp PeerBase.cpp Main.cpp Lock.cpp DBManager.
|
||||
Cache.cpp LoginData.cpp ClientManager.cpp ClientManagerPlayer.cpp ClientManagerLogin.cpp \
|
||||
ClientManagerBoot.cpp ClientManagerParty.cpp ClientManagerGuild.cpp GuildManager.cpp HB.cpp \
|
||||
PrivManager.cpp MoneyLog.cpp ItemAwardManager.cpp ClientManagerEventFlag.cpp Marriage.cpp \
|
||||
Monarch.cpp BlockCountry.cpp ItemIDRangeManager.cpp ClientManagerHorseName.cpp version.cpp \
|
||||
AuctionManager.cpp ProtoReader.cpp CsvReader.cpp
|
||||
Monarch.cpp BlockCountry.cpp ItemIDRangeManager.cpp ClientManagerHorseName.cpp ClientManagerOfflineshop.cpp version.cpp \
|
||||
AuctionManager.cpp ProtoReader.cpp CsvReader.cpp Ava2ItemShop.cpp Economy.cpp
|
||||
|
||||
OBJS = $(SRCS:%.cpp=$(OBJDIR)/%.o)
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ namespace marriage
|
||||
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
SQLResult * pRes = pmsg->Get();
|
||||
sys_log(0, "MarriageList(size=%lu)", pRes->uiNumRows);
|
||||
sys_log(0, "MarriageList(size=%llu)", static_cast<unsigned long long>(pRes->uiNumRows));
|
||||
|
||||
if (pRes->uiNumRows > 0)
|
||||
{
|
||||
for (uint uiRow = 0; uiRow != pRes->uiNumRows; ++uiRow)
|
||||
for (uint64_t uiRow = 0; uiRow != pRes->uiNumRows; ++uiRow)
|
||||
{
|
||||
MYSQL_ROW row = mysql_fetch_row(pRes->pSQLResult);
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace marriage
|
||||
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
SQLResult* res = pmsg->Get();
|
||||
if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1)
|
||||
if (res->uiAffectedRows == 0 || res->uiAffectedRows == UINT64_MAX)
|
||||
{
|
||||
sys_err("cannot insert marriage");
|
||||
return;
|
||||
@@ -144,7 +144,7 @@ namespace marriage
|
||||
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
SQLResult* res = pmsg->Get();
|
||||
if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1)
|
||||
if (res->uiAffectedRows == 0 || res->uiAffectedRows == UINT64_MAX)
|
||||
{
|
||||
sys_err("cannot update marriage : PID:%u %u", dwPID1, dwPID2);
|
||||
return;
|
||||
@@ -190,7 +190,7 @@ namespace marriage
|
||||
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
SQLResult* res = pmsg->Get();
|
||||
if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1)
|
||||
if (res->uiAffectedRows == 0 || res->uiAffectedRows == UINT64_MAX)
|
||||
{
|
||||
sys_err("cannot delete marriage : PID:%u %u", dwPID1, dwPID2);
|
||||
return;
|
||||
@@ -234,7 +234,7 @@ namespace marriage
|
||||
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
SQLResult* res = pmsg->Get();
|
||||
if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1)
|
||||
if (res->uiAffectedRows == 0 || res->uiAffectedRows == UINT64_MAX)
|
||||
{
|
||||
sys_err("cannot change engage to marriage : PID:%u %u", dwPID1, dwPID2);
|
||||
return;
|
||||
|
||||
@@ -51,7 +51,7 @@ void CMoneyLog::Save()
|
||||
*/
|
||||
}
|
||||
|
||||
void CMoneyLog::AddLog(BYTE bType, DWORD dwVnum, int iGold)
|
||||
void CMoneyLog::AddLog(BYTE bType, DWORD dwVnum, int64_t iGold)
|
||||
{
|
||||
m_MoneyLogContainer[bType][dwVnum] += iGold;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ class CMoneyLog : public singleton<CMoneyLog>
|
||||
virtual ~CMoneyLog();
|
||||
|
||||
void Save();
|
||||
void AddLog(BYTE bType, DWORD dwVnum, int iGold);
|
||||
void AddLog(BYTE bType, DWORD dwVnum, int64_t iGold);
|
||||
|
||||
private:
|
||||
std::map<DWORD, int> m_MoneyLogContainer[MONEY_LOG_TYPE_MAX_NUM];
|
||||
std::map<DWORD, int64_t> m_MoneyLogContainer[MONEY_LOG_TYPE_MAX_NUM];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -79,6 +79,7 @@ int get_Item_Type_Value(string inputString)
|
||||
|
||||
"ITEM_RING",
|
||||
"ITEM_BELT", //35개 (EItemTypes 값으로 치면 34)
|
||||
"ITEM_SHINING", "ITEM_NEW_RINGS", "ITEM_PET", // AVA2 35 (not ported), 36 new rings
|
||||
};
|
||||
|
||||
|
||||
@@ -103,7 +104,7 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
||||
static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
|
||||
"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR"};
|
||||
static string arSub2[] = { "ARMOR_BODY", "ARMOR_HEAD", "ARMOR_SHIELD", "ARMOR_WRIST", "ARMOR_FOOTS",
|
||||
"ARMOR_NECK", "ARMOR_EAR", "ARMOR_NUM_TYPES"};
|
||||
"ARMOR_NECK", "ARMOR_EAR", "ARMOR_PENDANT", "ARMOR_NUM_TYPES"};
|
||||
static string arSub3[] = { "USE_POTION", "USE_TALISMAN", "USE_TUNING", "USE_MOVE", "USE_TREASURE_BOX", "USE_MONEYBAG", "USE_BAIT",
|
||||
"USE_ABILITY_UP", "USE_AFFECT", "USE_CREATE_STONE", "USE_SPECIAL", "USE_POTION_NODELAY", "USE_CLEAR",
|
||||
"USE_INVISIBILITY", "USE_DETACHMENT", "USE_BUCKET", "USE_POTION_CONTINUE", "USE_CLEAN_SOCKET",
|
||||
@@ -122,8 +123,10 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
||||
"RESOURCE_STONE", "RESOURCE_METIN", "RESOURCE_ORE" };
|
||||
static string arSub16[] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_3", "UNIQUE_4", "UNIQUE_5",
|
||||
"UNIQUE_6", "UNIQUE_7", "UNIQUE_8", "UNIQUE_9", "USE_SPECIAL"};
|
||||
static string arSub28[] = { "COSTUME_BODY", "COSTUME_HAIR" };
|
||||
static string arSub28[] = { "COSTUME_BODY", "COSTUME_HAIR", "COSTUME_MOUNT", "COSTUME_SASH", "COSTUME_MOUNT_SKIN", "COSTUME_WEAPON", "COSTUME_NEW_SASH", "COSTUME_PET" };
|
||||
static string arSub29[] = { "DS_SLOT1", "DS_SLOT2", "DS_SLOT3", "DS_SLOT4", "DS_SLOT5", "DS_SLOT6" };
|
||||
static string arSub35[] = { "SHINING_WEAPON", "SHINING_ARMOR", "SHINING_SPECIAL" };
|
||||
static string arSub37[] = { "PET_LEVELABLE", "PET_EGG", "PET_TRANSPORTBOX", "PET_PROTEIN", "PET_CHANGE_NAME_ITEM", "PET_DEW", "PET_SKILL", "PET_PRIMIUM_FEEDSTUFF", "PET_ATTR_CHANGE", "PET_ATTR_DETERMINE", "PET_EXPFOOD_PER", "PET_SKILL_DEL_BOOK", "PET_SKILL_ALL_DEL_BOOK", "PET_EXPFOOD", "PET_FEEDSTUFF" };
|
||||
static string arSub31[] = { "EXTRACT_DRAGON_SOUL", "EXTRACT_DRAGON_HEART" };
|
||||
|
||||
static string* arSubType[] = {0, //0
|
||||
@@ -161,6 +164,9 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
||||
0, //32
|
||||
0, //33 반지
|
||||
0, //34 벨트
|
||||
arSub35, //35 ITEM_SHINING
|
||||
0, //36 ITEM_NEW_RINGS
|
||||
arSub37, //37 ITEM_PET
|
||||
};
|
||||
static int arNumberOfSubtype[_countof(arSubType)] = {
|
||||
0,
|
||||
@@ -198,6 +204,9 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
||||
0, // 32
|
||||
0, // 33 반지
|
||||
0, // 34 벨트
|
||||
sizeof(arSub35)/sizeof(arSub35[0]), // 35
|
||||
0, // 36
|
||||
sizeof(arSub37)/sizeof(arSub37[0]), // 37
|
||||
};
|
||||
|
||||
|
||||
@@ -393,6 +402,14 @@ int get_Item_ApplyType_Value(string inputString)
|
||||
"APPLY_EXTRACT_HP_PCT", "APPLY_RESIST_WARRIOR", "APPLY_RESIST_ASSASSIN", "APPLY_RESIST_SURA", "APPLY_RESIST_SHAMAN",
|
||||
"APPLY_ENERGY", "APPLY_DEF_GRADE", "APPLY_COSTUME_ATTR_BONUS", "APPLY_MAGIC_ATTBONUS_PER", "APPLY_MELEE_MAGIC_ATTBONUS_PER",
|
||||
"APPLY_RESIST_ICE", "APPLY_RESIST_EARTH", "APPLY_RESIST_DARK", "APPLY_ANTI_CRITICAL_PCT", "APPLY_ANTI_PENETRATE_PCT",
|
||||
// PORT AVA2 numbering: 92-138 not ported yet (common/length.h)
|
||||
"APPLY_RESERVED_92", "APPLY_RESERVED_93", "APPLY_RESERVED_94", "APPLY_RESERVED_95", "APPLY_RESERVED_96", "APPLY_RESERVED_97", "APPLY_RESIST_MAGIC_REDUCTION", "APPLY_RESIST_HUMAN",
|
||||
"APPLY_RESERVED_100", "APPLY_RESERVED_101", "APPLY_RESERVED_102", "APPLY_RESERVED_103", "APPLY_RESERVED_104", "APPLY_RESERVED_105", "APPLY_RESERVED_106", "APPLY_RESERVED_107",
|
||||
"APPLY_RESERVED_108", "APPLY_RESERVED_109", "APPLY_RESERVED_110", "APPLY_RESERVED_111", "APPLY_RESERVED_112", "APPLY_RESERVED_113", "APPLY_RESERVED_114", "APPLY_RESERVED_115",
|
||||
"APPLY_RESERVED_116", "APPLY_RESERVED_117", "APPLY_RESERVED_118", "APPLY_RESERVED_119", "APPLY_RESERVED_120", "APPLY_RESERVED_121", "APPLY_RESERVED_122", "APPLY_ENCHANT_ELECT",
|
||||
"APPLY_ENCHANT_FIRE", "APPLY_ENCHANT_ICE", "APPLY_ENCHANT_WIND", "APPLY_ENCHANT_EARTH", "APPLY_ENCHANT_DARK", "APPLY_RESERVED_129", "APPLY_RESERVED_130", "APPLY_RESERVED_131",
|
||||
"APPLY_RESERVED_132", "APPLY_RESERVED_133", "APPLY_RESERVED_134", "APPLY_RESERVED_135", "APPLY_RESERVED_136", "APPLY_RESERVED_137", "APPLY_RESERVED_138",
|
||||
"APPLY_ATTBONUS_STONE", "APPLY_ATTBONUS_BOSS",
|
||||
};
|
||||
|
||||
int retInt = -1;
|
||||
|
||||
@@ -32,7 +32,8 @@ enum QID
|
||||
QID_ITEMPRICE_SAVE, ///< 21, 아이템 가격정보 저장 쿼리
|
||||
QID_ITEMPRICE_DESTROY, ///< 22, 아이템 가격정보 삭제 쿼리
|
||||
QID_ITEMPRICE_LOAD_FOR_UPDATE, ///< 23, 가격정보 업데이트를 위한 아이템 가격정보 로드 쿼리
|
||||
QID_ITEMPRICE_LOAD, ///< 24, 아이템 가격정보 로드 쿼리
|
||||
QID_ECONOMY_FENCE = 100,
|
||||
QID_ITEMPRICE_LOAD = 24, ///< 24, 아이템 가격정보 로드 쿼리
|
||||
// END_OF_MYSHOP_PRICE_LIST
|
||||
};
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ struct FWarpToHome
|
||||
if ( lpChar->GetGMLevel() != GM_PLAYER ) return;
|
||||
}
|
||||
|
||||
int nEmpire, nMapIndex, x, y;
|
||||
const BYTE nEmpire = lpChar->GetEmpire();
|
||||
int nMapIndex, x, y;
|
||||
|
||||
nEmpire = lpChar->GetEmpire();
|
||||
nMapIndex = EMPIRE_START_MAP(nEmpire);
|
||||
x = EMPIRE_START_X(nEmpire);
|
||||
y = EMPIRE_START_Y(nEmpire);
|
||||
@@ -243,7 +243,7 @@ bool CBattleArena::Start(int nEmpire)
|
||||
m_nEmpire = nEmpire;
|
||||
|
||||
char szBuf[1024];
|
||||
snprintf(szBuf, sizeof(szBuf), LC_TEXT("%s의 성으로 몬스터들이 진군하고 있습니다."), EMPIRE_NAME(m_nEmpire));
|
||||
snprintf(szBuf, sizeof(szBuf), LC_TEXT("%s의 성으로 몬스터들이 진군하고 있습니다."), EMPIRE_NAME(static_cast<BYTE>(nEmpire)));
|
||||
BroadcastNotice(szBuf);
|
||||
BroadcastNotice(LC_TEXT("10분 뒤 성을 공격할 예정입니다."));
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ CPPFILE = BattleArena.cpp FSM.cpp MarkConvert.cpp MarkImage.cpp MarkManager.cpp
|
||||
desc_client.cpp desc_manager.cpp desc_p2p.cpp dev_log.cpp dungeon.cpp empire_text_convert.cpp entity.cpp\
|
||||
entity_view.cpp event.cpp event_queue.cpp exchange.cpp file_loader.cpp fishing.cpp gm.cpp guild.cpp\
|
||||
guild_manager.cpp guild_war.cpp horse_rider.cpp horsename_manager.cpp input.cpp input_auth.cpp input_db.cpp\
|
||||
input_login.cpp input_main.cpp input_p2p.cpp port_boss_track.cpp port_attr_lock.cpp input_teen.cpp input_udp.cpp ip_ban.cpp\
|
||||
input_login.cpp input_main.cpp input_p2p.cpp port_boss_track.cpp ava2_channel.cpp new_mob_timer.cpp ava2_track.cpp ava2_ticket_shop.cpp ava2_itemshop.cpp port_attr_lock.cpp port_sash.cpp port_mount.cpp port_costume_attr.cpp port_pendant.cpp port_rings.cpp port_switchbot.cpp port_special_storage.cpp offline_shop.cpp offlineshop_manager.cpp offlineshop_search_manager.cpp port_offlineshop.cpp port_ava2_dungeon.cpp port_gaya.cpp port_economy.cpp input_teen.cpp input_udp.cpp ip_ban.cpp\
|
||||
item.cpp item_addon.cpp item_attribute.cpp item_manager.cpp item_manager_idrange.cpp locale.cpp\
|
||||
locale_service.cpp log.cpp login_data.cpp lzo_manager.cpp marriage.cpp matrix_card.cpp\
|
||||
messenger_manager.cpp mining.cpp mob_manager.cpp monarch.cpp motion.cpp over9refine.cpp p2p.cpp packet_info.cpp\
|
||||
@@ -123,4 +123,26 @@ tag:
|
||||
dep:
|
||||
makedepend -f Depend $(INCDIR) -I/usr/include/c++/3.3 -I/usr/include/c++/4.2 -p$(OBJDIR)/ $(CPPFILE) $(CFILE) $(MAINCPP) 2> /dev/null > Depend
|
||||
|
||||
# Native AVA2 feature includes are not present in older generated Depend files.
|
||||
$(OBJDIR)/char_item.o: ava2_chest.inc
|
||||
$(OBJDIR)/cmd_general.o: ava2_chest_commands.h ava2_pickup_commands.h
|
||||
|
||||
sinclude Depend
|
||||
|
||||
$(OBJDIR)/cmd_general.o: ava2_track_commands.h
|
||||
|
||||
# New AVA2 includes are absent from old generated Depend files.
|
||||
$(OBJDIR)/new_mob_timer.o $(OBJDIR)/main.o $(OBJDIR)/char_battle.o $(OBJDIR)/char_manager.o $(OBJDIR)/input_db.o $(OBJDIR)/input_p2p.o $(OBJDIR)/cmd_general.o: new_mob_timer.h
|
||||
$(OBJDIR)/ava2_track.o $(OBJDIR)/questlua_dungeon.o $(OBJDIR)/input_db.o $(OBJDIR)/cmd_general.o: ava2_track.h
|
||||
$(OBJDIR)/ava2_ticket_shop.o $(OBJDIR)/shop_manager.o $(OBJDIR)/cmd_general.o: ava2_ticket_shop.h
|
||||
|
||||
$(OBJDIR)/cmd_general.o $(OBJDIR)/ava2_track.o: port_dungeon_settings.h
|
||||
|
||||
$(OBJDIR)/cmd_general.o: ava2_attr_lock_commands.h port_attr_lock.h
|
||||
$(OBJDIR)/questlua_item.o: port_attr_lock.h
|
||||
|
||||
$(OBJDIR)/ava2_channel.o: ava2_channel.h ava2_channel_registry.h
|
||||
$(OBJDIR)/char.o $(OBJDIR)/cmd_general.o $(OBJDIR)/input_p2p.o $(OBJDIR)/p2p.o $(OBJDIR)/input_login.o: ava2_channel.h
|
||||
|
||||
$(OBJDIR)/cmd_general.o: port_features.h port_rank_runtime.h
|
||||
$(OBJDIR)/char_battle.o $(OBJDIR)/char_skill.o: port_magic_reduction.h
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "MarkManager.h"
|
||||
|
||||
#include "crc32.h"
|
||||
#include <sstream>
|
||||
|
||||
CGuildMarkImage * CGuildMarkManager::__NewImage()
|
||||
{
|
||||
@@ -47,29 +48,27 @@ void CGuildMarkManager::SetMarkPathPrefix(const char * prefix)
|
||||
// 마크 인덱스 불러오기 (서버에서만 사용)
|
||||
bool CGuildMarkManager::LoadMarkIndex()
|
||||
{
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "mark/%s_index", m_pathPrefix.c_str());
|
||||
FILE * fp = fopen(buf, "r");
|
||||
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
DWORD guildID;
|
||||
DWORD markID;
|
||||
|
||||
char line[256];
|
||||
|
||||
while (fgets(line, sizeof(line)-1, fp))
|
||||
{
|
||||
sscanf(line, "%u %u", &guildID, &markID);
|
||||
line[0] = '\0';
|
||||
AddMarkIDByGuildID(guildID, markID);
|
||||
}
|
||||
|
||||
LoadMarkImages();
|
||||
|
||||
fclose(fp);
|
||||
return true;
|
||||
char filename[64];snprintf(filename,sizeof(filename),"mark/%s_index",m_pathPrefix.c_str());
|
||||
FILE* file=fopen(filename,"r");if(!file)return false;
|
||||
std::map<DWORD,DWORD> staged;std::set<DWORD> used;char line[256];bool valid=true;
|
||||
while(true) {
|
||||
const long begin=ftell(file);if(begin<0){valid=false;break;}
|
||||
if(!fgets(line,sizeof(line),file))break;
|
||||
const long end=ftell(file);
|
||||
if(end<begin || end-begin>=static_cast<long>(sizeof(line))){valid=false;break;}
|
||||
const size_t length=static_cast<size_t>(end-begin);
|
||||
if(memchr(line,0,length) || (length==sizeof(line)-1 && line[length-1]!='\n')){valid=false;break;}
|
||||
std::istringstream fields(std::string(line,length));fields>>std::ws;if(fields.eof())continue;
|
||||
uint64_t guild=0,mark=0;std::string tail;
|
||||
if(!(fields>>guild>>mark)||fields>>tail || !guild || guild>UINT16_MAX ||
|
||||
mark>=MAX_IMAGE_COUNT*CGuildMarkImage::MARK_TOTAL_COUNT || staged.count(static_cast<DWORD>(guild)) ||
|
||||
!used.insert(static_cast<DWORD>(mark)).second){valid=false;break;}
|
||||
staged.emplace(static_cast<DWORD>(guild),static_cast<DWORD>(mark));
|
||||
}
|
||||
if(ferror(file))valid=false;fclose(file);if(!valid)return false;
|
||||
std::set<DWORD> free;
|
||||
for(DWORD id=0;id<MAX_IMAGE_COUNT*CGuildMarkImage::MARK_TOTAL_COUNT;++id)if(!used.count(id))free.insert(id);
|
||||
m_mapGID_MarkID.swap(staged);m_setFreeMarkID.swap(free);LoadMarkImages();return true;
|
||||
}
|
||||
|
||||
bool CGuildMarkManager::SaveMarkIndex()
|
||||
@@ -149,13 +148,11 @@ CGuildMarkImage * CGuildMarkManager::__GetImage(DWORD imgIdx)
|
||||
|
||||
bool CGuildMarkManager::AddMarkIDByGuildID(DWORD guildID, DWORD markID)
|
||||
{
|
||||
if (markID >= MAX_IMAGE_COUNT * CGuildMarkImage::MARK_TOTAL_COUNT)
|
||||
return false;
|
||||
|
||||
//sys_log(0, "MarkManager: guild_id=%d mark_id=%d", guildID, markID);
|
||||
m_mapGID_MarkID.insert(std::map<DWORD, DWORD>::value_type(guildID, markID));
|
||||
m_setFreeMarkID.erase(markID);
|
||||
return true;
|
||||
if(!guildID || guildID>UINT16_MAX || markID>=MAX_IMAGE_COUNT*CGuildMarkImage::MARK_TOTAL_COUNT)return false;
|
||||
const auto existing=m_mapGID_MarkID.find(guildID);
|
||||
if(existing!=m_mapGID_MarkID.end())return existing->second==markID;
|
||||
if(!m_setFreeMarkID.count(markID))return false;
|
||||
m_mapGID_MarkID.emplace(guildID,markID);m_setFreeMarkID.erase(markID);return true;
|
||||
}
|
||||
|
||||
DWORD CGuildMarkManager::GetMarkID(DWORD guildID)
|
||||
@@ -188,24 +185,24 @@ DWORD CGuildMarkManager::__AllocMarkID(DWORD guildID)
|
||||
|
||||
DWORD CGuildMarkManager::GetMarkImageCount() const
|
||||
{
|
||||
return m_mapIdx_Image.size();
|
||||
return static_cast<DWORD>(m_mapIdx_Image.size());
|
||||
}
|
||||
|
||||
DWORD CGuildMarkManager::GetMarkCount() const
|
||||
{
|
||||
return m_mapGID_MarkID.size();
|
||||
return static_cast<DWORD>(m_mapGID_MarkID.size());
|
||||
}
|
||||
|
||||
// SERVER
|
||||
void CGuildMarkManager::CopyMarkIdx(char * pcBuf) const
|
||||
bool CGuildMarkManager::CopyMarkIdx(char* buffer, size_t capacity) const
|
||||
{
|
||||
WORD * pwBuf = (WORD *) pcBuf;
|
||||
|
||||
for (std::map<DWORD, DWORD>::const_iterator it = m_mapGID_MarkID.begin(); it != m_mapGID_MarkID.end(); ++it)
|
||||
{
|
||||
*(pwBuf++) = it->first; // guild id
|
||||
*(pwBuf++) = it->second; // mark id
|
||||
}
|
||||
if(m_mapGID_MarkID.size()>capacity/(sizeof(WORD)*2) || (!buffer && !m_mapGID_MarkID.empty()))return false;
|
||||
for(const auto& entry:m_mapGID_MarkID)if(!entry.first || entry.first>UINT16_MAX || entry.second>=MAX_IMAGE_COUNT*CGuildMarkImage::MARK_TOTAL_COUNT)return false;
|
||||
for(const auto& entry:m_mapGID_MarkID) {
|
||||
const WORD guild=static_cast<WORD>(entry.first), mark=static_cast<WORD>(entry.second);
|
||||
memcpy(buffer,&guild,sizeof(guild));memcpy(buffer+sizeof(guild),&mark,sizeof(mark));buffer+=sizeof(WORD)*2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// SERVER
|
||||
@@ -218,7 +215,7 @@ DWORD CGuildMarkManager::SaveMark(DWORD guildID, BYTE * pbMarkImage)
|
||||
if ((idMark = __AllocMarkID(guildID)) == INVALID_MARK_ID)
|
||||
{
|
||||
sys_err("CGuildMarkManager: cannot alloc mark id %u", guildID);
|
||||
return false;
|
||||
return INVALID_MARK_ID;
|
||||
}
|
||||
else
|
||||
sys_log(0, "SaveMark: mark id alloc %u", idMark);
|
||||
|
||||
@@ -45,7 +45,7 @@ class CGuildMarkManager : public singleton<CGuildMarkManager>
|
||||
DWORD GetMarkID(DWORD guildID);
|
||||
|
||||
// SERVER
|
||||
void CopyMarkIdx(char * pcBuf) const;
|
||||
bool CopyMarkIdx(char* buffer, size_t capacity) const;
|
||||
DWORD SaveMark(DWORD guildID, BYTE * pbMarkImage);
|
||||
void DeleteMark(DWORD guildID);
|
||||
void GetDiffBlocks(DWORD imgIdx, const DWORD * crcList, std::map<BYTE, const SGuildMarkBlock *> & mapDiffBlocks);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "char_manager.h"
|
||||
#include "OXEvent.h"
|
||||
#include "desc.h"
|
||||
#include <limits>
|
||||
|
||||
bool COXEventManager::Initialize()
|
||||
{
|
||||
@@ -36,7 +37,7 @@ void COXEventManager::Destroy()
|
||||
|
||||
OXEventStatus COXEventManager::GetStatus()
|
||||
{
|
||||
BYTE ret = quest::CQuestManager::instance().GetEventFlag("oxevent_status");
|
||||
const int ret = quest::CQuestManager::instance().GetEventFlag("oxevent_status");
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
@@ -240,15 +241,16 @@ EVENTFUNC(oxevent_timer)
|
||||
bool COXEventManager::Quiz(unsigned char level, int timelimit)
|
||||
{
|
||||
if (m_vec_quiz.size() == 0) return false;
|
||||
if (level > m_vec_quiz.size()) level = m_vec_quiz.size() - 1;
|
||||
if (m_vec_quiz[level].size() <= 0) return false;
|
||||
const size_t selected = std::min(static_cast<size_t>(level), m_vec_quiz.size() - 1);
|
||||
const size_t count = m_vec_quiz[selected].size();
|
||||
if (!count || count > static_cast<size_t>(std::numeric_limits<int>::max())) return false;
|
||||
|
||||
if (timelimit < 0) timelimit = 30;
|
||||
|
||||
int idx = number(0, m_vec_quiz[level].size()-1);
|
||||
const int idx = number(0, static_cast<int>(count) - 1);
|
||||
|
||||
SendNoticeMap(LC_TEXT("문제 입니다."), OXEVENT_MAP_INDEX, true);
|
||||
SendNoticeMap(m_vec_quiz[level][idx].Quiz, OXEVENT_MAP_INDEX, true);
|
||||
SendNoticeMap(m_vec_quiz[selected][idx].Quiz, OXEVENT_MAP_INDEX, true);
|
||||
SendNoticeMap(LC_TEXT("맞으면 O, 틀리면 X로 이동해주세요"), OXEVENT_MAP_INDEX, true);
|
||||
|
||||
if (m_timedEvent != NULL) {
|
||||
@@ -257,14 +259,14 @@ bool COXEventManager::Quiz(unsigned char level, int timelimit)
|
||||
|
||||
OXEventInfoData* answer = AllocEventInfo<OXEventInfoData>();
|
||||
|
||||
answer->answer = m_vec_quiz[level][idx].answer;
|
||||
answer->answer = m_vec_quiz[selected][idx].answer;
|
||||
|
||||
timelimit -= 15;
|
||||
m_timedEvent = event_create(oxevent_timer, answer, PASSES_PER_SEC(timelimit));
|
||||
|
||||
SetStatus(OXEVENT_QUIZ);
|
||||
|
||||
m_vec_quiz[level].erase(m_vec_quiz[level].begin()+idx);
|
||||
m_vec_quiz[selected].erase(m_vec_quiz[selected].begin()+idx);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -327,7 +329,8 @@ bool COXEventManager::CheckAnswer(bool answer)
|
||||
|
||||
TPacketGCChat pack_chat;
|
||||
pack_chat.header = HEADER_GC_CHAT;
|
||||
pack_chat.size = sizeof(TPacketGCChat) + len;
|
||||
static_assert(sizeof(TPacketGCChat) + sizeof(chatbuf) <= UINT16_MAX, "bounded OX chat packet");
|
||||
pack_chat.size = static_cast<WORD>(sizeof(TPacketGCChat) + static_cast<size_t>(len));
|
||||
pack_chat.type = CHAT_TYPE_COMMAND;
|
||||
pack_chat.id = 0;
|
||||
|
||||
|
||||
+658
-519
File diff suppressed because it is too large
Load Diff
+72
-133
@@ -1,163 +1,102 @@
|
||||
#ifndef __HEADER_PET_SYSTEM__
|
||||
#define __HEADER_PET_SYSTEM__
|
||||
#ifndef __HEADER_PET_SYSTEM__
|
||||
#define __HEADER_PET_SYSTEM__
|
||||
|
||||
#include <unordered_map>
|
||||
#include "../../common/tables.h"
|
||||
|
||||
class CItem;
|
||||
class CHARACTER;
|
||||
|
||||
// TODO: 펫으로서의 능력치? 라던가 친밀도, 배고픔 기타등등... 수치
|
||||
struct SPetAbility
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class CPetActor //: public CHARACTER
|
||||
class CPetActor
|
||||
{
|
||||
public:
|
||||
enum EPetOptions
|
||||
{
|
||||
EPetOption_Followable = 1 << 0,
|
||||
EPetOption_Mountable = 1 << 1,
|
||||
EPetOption_Summonable = 1 << 2,
|
||||
EPetOption_Combatable = 1 << 3,
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
friend class CPetSystem;
|
||||
|
||||
CPetActor(LPCHARACTER owner, DWORD vnum, DWORD options = EPetOption_Followable | EPetOption_Summonable);
|
||||
// CPetActor(LPCHARACTER owner, DWORD vnum, const SPetAbility& petAbility, DWORD options = EPetOption_Followable | EPetOption_Summonable);
|
||||
|
||||
CPetActor(BYTE petType = 0);
|
||||
virtual ~CPetActor();
|
||||
|
||||
virtual bool Update(DWORD deltaTime);
|
||||
DWORD Summon(LPITEM summonItem, const char* petName, DWORD mobVnum);
|
||||
void Unsummon(bool isReal = true);
|
||||
|
||||
void GiveBuffSkill();
|
||||
void ClearBuffSkill();
|
||||
|
||||
BYTE GetType() const { return m_petType; }
|
||||
void SetType(const BYTE type) { m_petType = type; }
|
||||
|
||||
LPCHARACTER GetPet();
|
||||
bool IsSummoned();
|
||||
|
||||
void SetSummonItem(const DWORD pItemID) { m_dwSummonItemID = pItemID; }
|
||||
LPITEM GetSummonItem();
|
||||
|
||||
#ifdef ENABLE_NEW_PET_SYSTEM
|
||||
bool PointChange(BYTE byType, int amount, bool bBroadcast = false);
|
||||
BYTE GetMaxLevelByEvolution(BYTE evolution);
|
||||
DWORD GetNextExp();
|
||||
void IncreaseEvolve();
|
||||
bool IncreaseBonus(const BYTE bonusType, const BYTE bonusStep);
|
||||
bool IncreaseSkill(const BYTE skillIndex);
|
||||
BYTE CheckSkillIndex(LPITEM summonItem, BYTE skillIndex);
|
||||
BYTE CheckEmptyIndex(LPITEM summonItem);
|
||||
|
||||
long GetApplyValue(BYTE byIndex) const { return m_aApplies[byIndex].lValue; }
|
||||
void SetApplyValue(BYTE byIndex, long lValue) { m_aApplies[byIndex].lValue = lValue; }
|
||||
|
||||
BYTE GetSkillBookIndex(BYTE byIndex) const { return m_aSkills[byIndex].bType; }
|
||||
void SetSkillBookIndex(BYTE byIndex, BYTE byBookIndex) { m_aSkills[byIndex].bType = byBookIndex; }
|
||||
|
||||
short GetSkillApplyLevel(BYTE byIndex) const { return m_aSkills[byIndex].sLevel; }
|
||||
void SetSkillApplyLevel(BYTE byIndex, short sValue) { m_aSkills[byIndex].sLevel = sValue; }
|
||||
|
||||
long GetAge() const { return m_lAge; }
|
||||
void SetAge(long lAge) { m_lAge = lAge; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual bool _UpdateFollowAI(); ///< 주인을 따라다니는 AI 처리
|
||||
virtual bool _UpdatAloneActionAI(float fMinDist, float fMaxDist); ///< 주인 근처에서 혼자 노는 AI 처리
|
||||
BYTE m_petType;
|
||||
DWORD m_dwSummonItemID;
|
||||
DWORD m_pkPetVID;
|
||||
|
||||
/// @TODO
|
||||
//virtual bool _UpdateCombatAI();
|
||||
|
||||
private:
|
||||
bool Follow(float fMinDistance = 50.f);
|
||||
|
||||
public:
|
||||
LPCHARACTER GetCharacter() const { return m_pkChar; }
|
||||
LPCHARACTER GetOwner() const { return m_pkOwner; }
|
||||
DWORD GetVID() const { return m_dwVID; }
|
||||
DWORD GetVnum() const { return m_dwVnum; }
|
||||
|
||||
bool HasOption(EPetOptions option) const { return m_dwOptions & option; }
|
||||
|
||||
void SetName(const char* petName);
|
||||
|
||||
bool Mount();
|
||||
void Unmount();
|
||||
|
||||
DWORD Summon(const char* petName, LPITEM pSummonItem, bool bSpawnFar = false);
|
||||
void Unsummon();
|
||||
|
||||
bool IsSummoned() const { return 0 != m_pkChar; }
|
||||
void SetSummonItem (LPITEM pItem);
|
||||
DWORD GetSummonItemVID () { return m_dwSummonItemVID; }
|
||||
// 버프 주는 함수와 거두는 함수.
|
||||
// 이게 좀 괴랄한게, 서버가 ㅄ라서,
|
||||
// POINT_MOV_SPEED, POINT_ATT_SPEED, POINT_CAST_SPEED는 PointChange()란 함수만 써서 변경해 봐야 소용이 없는게,
|
||||
// PointChange() 이후에 어디선가 ComputePoints()를 하면 싹다 초기화되고,
|
||||
// 더 웃긴건, ComputePoints()를 부르지 않으면 클라의 POINT는 전혀 변하지 않는다는 거다.
|
||||
// 그래서 버프를 주는 것은 ComputePoints() 내부에서 petsystem->RefreshBuff()를 부르도록 하였고,
|
||||
// 버프를 빼는 것은 ClearBuff()를 부르고, ComputePoints를 하는 것으로 한다.
|
||||
void GiveBuff();
|
||||
void ClearBuff();
|
||||
|
||||
private:
|
||||
DWORD m_dwVnum;
|
||||
DWORD m_dwVID;
|
||||
DWORD m_dwOptions;
|
||||
DWORD m_dwLastActionTime;
|
||||
DWORD m_dwSummonItemVID;
|
||||
DWORD m_dwSummonItemVnum;
|
||||
|
||||
short m_originalMoveSpeed;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
LPCHARACTER m_pkChar; // Instance of pet(CHARACTER)
|
||||
LPCHARACTER m_pkOwner;
|
||||
|
||||
// SPetAbility m_petAbility; // 능력치
|
||||
#ifdef ENABLE_NEW_PET_SYSTEM
|
||||
BYTE m_byEvolution;
|
||||
long m_lDuration;
|
||||
long m_lMaxDuration;
|
||||
long m_lAge;
|
||||
TPetApply m_aApplies[PET_APPLY_MAX_NUM];
|
||||
TPetSkill m_aSkills[PET_SKILLS_MAX_NUM];
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class CPetSystem
|
||||
{
|
||||
public:
|
||||
typedef std::unordered_map<DWORD, CPetActor*> TPetActorMap; /// <VNUM, PetActor> map. (한 캐릭터가 같은 vnum의 펫을 여러개 가질 일이 있을까..??)
|
||||
|
||||
public:
|
||||
CPetSystem(LPCHARACTER owner);
|
||||
virtual ~CPetSystem();
|
||||
|
||||
CPetActor* GetByVID(DWORD vid) const;
|
||||
CPetActor* GetByVnum(DWORD vnum) const;
|
||||
LPPET GetByVID(DWORD vid) const;
|
||||
LPPET GetByID(DWORD itemID) const;
|
||||
|
||||
bool Update(DWORD deltaTime);
|
||||
void Destroy();
|
||||
size_t CountSummoned() const;
|
||||
|
||||
size_t CountSummoned() const; ///< 현재 소환된(실체화 된 캐릭터가 있는) 펫의 개수
|
||||
LPPET Summon(DWORD mobVnum, LPITEM pSummonItem, const char* petName, BYTE petType);
|
||||
void HandlePetCostumeItem();
|
||||
|
||||
public:
|
||||
void SetUpdatePeriod(DWORD ms);
|
||||
void DeletePet(DWORD itemID);
|
||||
void DeletePet(LPPET petActor);
|
||||
void ChangeGmPetStatus();
|
||||
|
||||
CPetActor* Summon(DWORD mobVnum, LPITEM pSummonItem, const char* petName, bool bSpawnFar, DWORD options = CPetActor::EPetOption_Followable | CPetActor::EPetOption_Summonable);
|
||||
BYTE PetItemSocketMax(DWORD itemVnum);
|
||||
|
||||
void Unsummon(DWORD mobVnum, bool bDeleteFromList = false);
|
||||
void Unsummon(CPetActor* petActor, bool bDeleteFromList = false);
|
||||
|
||||
// TODO: 진짜 펫 시스템이 들어갈 때 구현. (캐릭터가 보유한 펫의 정보를 추가할 때 라던가...)
|
||||
CPetActor* AddPet(DWORD mobVnum, const char* petName, const SPetAbility& ability, DWORD options = CPetActor::EPetOption_Followable | CPetActor::EPetOption_Summonable | CPetActor::EPetOption_Combatable);
|
||||
|
||||
void DeletePet(DWORD mobVnum);
|
||||
void DeletePet(CPetActor* petActor);
|
||||
void RefreshBuff();
|
||||
#ifdef ENABLE_NEW_PET_SYSTEM
|
||||
void PointChange(BYTE byType, int amount, bool bBroadcast = false);
|
||||
void HandleNewPetItem();
|
||||
LPPET GetNewPet();
|
||||
#endif
|
||||
|
||||
private:
|
||||
TPetActorMap m_petActorMap;
|
||||
LPCHARACTER m_pkOwner; ///< 펫 시스템의 Owner
|
||||
DWORD m_dwUpdatePeriod; ///< 업데이트 주기 (ms단위)
|
||||
DWORD m_dwLastUpdateTime;
|
||||
LPEVENT m_pkPetSystemUpdateEvent;
|
||||
std::unordered_map<DWORD, LPPET> m_petActorMap;
|
||||
LPCHARACTER m_pkOwner;
|
||||
};
|
||||
|
||||
/**
|
||||
// Summon Pet
|
||||
CPetSystem* petSystem = mainChar->GetPetSystem();
|
||||
CPetActor* petActor = petSystem->Summon(~~~);
|
||||
|
||||
DWORD petVID = petActor->GetVID();
|
||||
if (0 == petActor)
|
||||
{
|
||||
ERROR_LOG(...)
|
||||
};
|
||||
|
||||
|
||||
// Unsummon Pet
|
||||
petSystem->Unsummon(petVID);
|
||||
|
||||
// Mount Pet
|
||||
petActor->Mount()..
|
||||
|
||||
|
||||
CPetActor::Update(...)
|
||||
{
|
||||
// AI : Follow, actions, etc...
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#endif //__HEADER_PET_SYSTEM__
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,10 @@ class CAffect
|
||||
enum EAffectTypes
|
||||
{
|
||||
AFFECT_NONE,
|
||||
#ifdef ENABLE_OFFLINESHOP_SYSTEM
|
||||
AFFECT_DECORATION = 703,
|
||||
#endif
|
||||
AFFECT_AUTO_PICK_UP = 705,
|
||||
|
||||
AFFECT_MOV_SPEED = 200,
|
||||
AFFECT_ATT_SPEED,
|
||||
|
||||
@@ -715,6 +715,7 @@ bool AuctionManager::InsertItem (TPlayerItem* player_item)
|
||||
}
|
||||
item->SetSockets(player_item->alSockets);
|
||||
item->SetAttributes(player_item->aAttr);
|
||||
item->SetPortExtra(player_item->extra);
|
||||
item->SetWindow(AUCTION);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// Read-only presentation bridge: this port keeps AVA2 lock indices in an independent table.
|
||||
#include "port_attr_lock.h"
|
||||
#include <sstream>
|
||||
#include "exchange.h"
|
||||
#include "shop.h"
|
||||
#include "safebox.h"
|
||||
// Context IDs are presentation-only, never item window IDs or arbitrary owner IDs.
|
||||
static LPITEM Ava2AttrLockView(LPCHARACTER ch,unsigned view,unsigned cell,unsigned vid) {
|
||||
if (view==101 || view==102) {
|
||||
CExchange* own=ch->GetExchange();
|
||||
if (!own || own->GetOwner()!=ch || !own->GetCompany() || own->GetCompany()->GetCompany()!=own) return NULL;
|
||||
CExchange* side=view==101?own:own->GetCompany();
|
||||
LPITEM item=side->GetDisplayItem(cell);
|
||||
return item && item->GetOwner()==side->GetOwner() && item->IsExchanging()?item:NULL;
|
||||
}
|
||||
if (view==103) return ch->GetShop()?ch->GetShop()->GetGuestItem(ch,cell):NULL;
|
||||
if (view==104 || view==105) {
|
||||
CSafebox* box=view==104?ch->GetSafebox():ch->GetMall();
|
||||
return box && cell<SAFEBOX_MAX_NUM && box->IsValidPosition(cell)?box->Get(cell):NULL;
|
||||
}
|
||||
// do_view_equip is GM-only in the baseline. Never grant this to ordinary players.
|
||||
if (view==106 && ch->GetGMLevel()>GM_PLAYER && cell<WEAR_MAX_NUM) {
|
||||
LPCHARACTER owner=CHARACTER_MANAGER::instance().Find(vid);
|
||||
return owner && owner->IsPC()?owner->GetWear(cell):NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
ACMD(do_attr_lock_info) {
|
||||
if (!ch || !ch->IsPC()) return;
|
||||
unsigned token=0,window=0,cell=0,vid=0;std::string extra;std::istringstream args(argument);
|
||||
if (!(args>>token>>window>>cell) || token>2147483647 || window>255 || cell>65535) return;
|
||||
const bool view=window>=101 && window<=106;
|
||||
if (view ? !(args>>vid) : (window!=INVENTORY && window!=EQUIPMENT && window!=SWITCHBOT)) return;
|
||||
if ((args>>extra) || (window!=106 && vid)) return;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded()) return;
|
||||
const int now=get_global_time();
|
||||
if (ch->GetProtectTime("attr_lock_query")>now) return;
|
||||
ch->SetProtectTime("attr_lock_query",now+1);
|
||||
const TItemPos pos{BYTE(window),WORD(cell)};
|
||||
if (!view && (window==SWITCHBOT ? cell>=SWITCHBOT_SLOT_COUNT : cell>=INVENTORY_AND_EQUIP_SLOT_MAX)) return;
|
||||
LPITEM target=view?Ava2AttrLockView(ch,window,cell,vid):ch->GetItem(pos);int mask=0;
|
||||
if (target && PortAttrFilled(target)) {
|
||||
mask=PortAttrLockEffective(PortAttrLockGet(target),PortAttrFilled(target),target->GetProto() && target->GetProto()->sAddonType);
|
||||
if (!target->m_portAttrLockLoaded) mask=-1; // SQL failure is not an unlocked item.
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"AttrLockInfo %u %u %u %u %d",token,window,cell,target?target->GetVnum():0,mask);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "char.h"
|
||||
#include "desc.h"
|
||||
#include "p2p.h"
|
||||
#include "packet.h"
|
||||
#include "questmanager.h"
|
||||
#include "questpc.h"
|
||||
#include "ava2_channel.h"
|
||||
#include "ava2_channel_registry.h"
|
||||
static Ava2ChannelRegistry s_channels;
|
||||
void Ava2ChannelTick(){
|
||||
static long next=0;const long now=get_global_time();if(now<next)return;next=now+5;
|
||||
if(g_bChannel<1 || g_bChannel>7)return;
|
||||
const auto payload=Ava2ChannelRegistry::Encode(g_bChannel,mother_port,p2p_port,map_allow_list());
|
||||
if(payload.size()>2048)return;
|
||||
std::string wire(sizeof(TPacketGGRelay),'\0');auto* head=reinterpret_cast<TPacketGGRelay*>(&wire[0]);
|
||||
head->bHeader=HEADER_GG_RELAY;strlcpy(head->szName,"#ava2_channels",sizeof(head->szName));head->lSize=payload.size();
|
||||
wire+=payload;P2P_MANAGER::instance().Send(wire.data(),wire.size());
|
||||
}
|
||||
bool Ava2ChannelRelay(LPDESC d,const char* name,const char* data,long size){
|
||||
if(strcmp(name,"#ava2_channels"))return false;
|
||||
if(!s_channels.Receive(d->GetP2PHost(),d->GetP2PChannel(),d->GetP2PPort(),data,size,get_global_time()))
|
||||
sys_err("invalid channel route from P2P peer");
|
||||
return true;
|
||||
}
|
||||
void Ava2ChannelForget(LPDESC d){s_channels.Forget(d->GetP2PHost(),d->GetP2PPort());}
|
||||
bool Ava2ChannelRouteFor(unsigned channel,unsigned map,long& address,WORD& port){
|
||||
Ava2ChannelRoute r;if(!s_channels.Find(channel,map,get_global_time(),r))return false;
|
||||
const auto ip=inet_addr(r.host.c_str());if(ip==INADDR_NONE)return false;address=ip;port=WORD(r.game);return true;
|
||||
}
|
||||
void Ava2ChannelList(LPCHARACTER ch){
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc())return;
|
||||
auto channels=g_bChannel==99 ? std::vector<unsigned>() : s_channels.Channels(ch->GetMapIndex(),get_global_time());
|
||||
// Always include the local channel, even in private maps: native UI must not fall back to logout switching.
|
||||
if((g_bChannel>=1 && g_bChannel<=7) || g_bChannel==99)channels.push_back(g_bChannel);
|
||||
std::sort(channels.begin(),channels.end());channels.erase(std::unique(channels.begin(),channels.end()),channels.end());
|
||||
std::string list;for(auto id:channels){if(!list.empty())list+=",";list+=std::to_string(id);}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"ChannelList %u %s",unsigned(g_bChannel),list.empty()?"0":list.c_str());
|
||||
}
|
||||
bool Ava2ChannelAllowed(LPCHARACTER ch,unsigned channel){
|
||||
if(!ch || !ch->GetDesc() || channel<1 || channel>7 || channel==g_bChannel || g_bChannel==99 ||
|
||||
ch->GetMapIndex()>=10000 || ch->GetDungeon() || ch->GetWarMap() || ch->IsDead() || ch->IsStun() || !ch->CanHandleItem() || !ch->CanWarp())return false;
|
||||
// AVA2 do_cmd's blocked event/war maps.
|
||||
static const unsigned blocked[]={113,81,110,111,114,118,119,120,121,122,123,124,125,126,127,128,181,182,183,24,44,211,90,91,92};
|
||||
for(auto map:blocked)if(unsigned(ch->GetMapIndex())==map)return false;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
long addr=0;WORD port=0;return pc && pc->IsLoaded() && !pc->IsRunning() && Ava2ChannelRouteFor(channel,ch->GetMapIndex(),addr,port);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef AVA2_CHANNEL_H
|
||||
#define AVA2_CHANNEL_H
|
||||
void Ava2ChannelTick();
|
||||
bool Ava2ChannelRelay(LPDESC,const char*,const char*,long);
|
||||
void Ava2ChannelForget(LPDESC);
|
||||
bool Ava2ChannelRouteFor(unsigned channel,unsigned map,long& address,WORD& port);
|
||||
void Ava2ChannelList(LPCHARACTER);
|
||||
bool Ava2ChannelAllowed(LPCHARACTER,unsigned channel);
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef AVA2_CHANNEL_REGISTRY_H
|
||||
#define AVA2_CHANNEL_REGISTRY_H
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
// Trusted P2P peers announce actual map ownership; no assumptions about the farm's port spacing.
|
||||
struct Ava2ChannelRoute { std::string host;unsigned channel=0,game=0,p2p=0;std::set<unsigned> maps;long long seen=0; };
|
||||
class Ava2ChannelRegistry {
|
||||
std::map<std::string,Ava2ChannelRoute> peers;
|
||||
static std::string Key(const std::string& h,unsigned p){return h+":"+std::to_string(p);}
|
||||
public:
|
||||
void Forget(const std::string& host,unsigned port){peers.erase(Key(host,port));}
|
||||
void Prune(long long now){for(auto i=peers.begin();i!=peers.end();)if(i->second.seen+30<=now)i=peers.erase(i);else ++i;}
|
||||
static std::string Encode(unsigned channel,unsigned game,unsigned p2p,const std::vector<int>& maps){
|
||||
std::ostringstream out;out<<1<<' '<<channel<<' '<<game<<' '<<p2p<<' '<<maps.size();
|
||||
for(int map:maps)out<<' '<<map;return out.str();
|
||||
}
|
||||
bool Receive(const std::string& host,unsigned peerChannel,unsigned peerPort,const char* data,long size,long long now){
|
||||
if(!data || size<=0 || size>2048 || host.empty())return false;
|
||||
std::istringstream in(std::string(data,size));Ava2ChannelRoute r;unsigned version=0,count=0;std::string extra;
|
||||
if(!(in>>version>>r.channel>>r.game>>r.p2p>>count) || version!=1 || r.channel<1 || r.channel>7 ||
|
||||
r.channel!=peerChannel || !r.game || r.game>65535 || !r.p2p || r.p2p>65535 ||
|
||||
r.p2p!=peerPort || r.game==r.p2p || count>128)return false;
|
||||
for(unsigned i=0;i<count;++i){unsigned map=0;if(!(in>>map) || !map || map>=10000 || !r.maps.insert(map).second)return false;}
|
||||
if(in>>extra)return false;
|
||||
Prune(now);const auto key=Key(host,r.p2p);
|
||||
if(peers.size()>=128 && peers.find(key)==peers.end())return false;
|
||||
r.host=host;r.seen=now;peers[key]=r;return true;
|
||||
}
|
||||
bool Find(unsigned channel,unsigned map,long long now,Ava2ChannelRoute& out){
|
||||
Prune(now);bool found=false;
|
||||
for(const auto& pair:peers){const auto& r=pair.second;if(r.channel!=channel || !r.maps.count(map))continue;
|
||||
if(found)return false;out=r;found=true;}
|
||||
return found;
|
||||
}
|
||||
std::vector<unsigned> Channels(unsigned map,long long now){
|
||||
std::vector<unsigned> result;Ava2ChannelRoute r;
|
||||
for(unsigned channel=1;channel<=7;++channel)if(Find(channel,map,now,r))result.push_back(channel);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,269 @@
|
||||
// PORT: AVA2 ENABLE_MULTI_CHEST; see docs/FEATURE-AVA2-CHEST.md for adaptations.
|
||||
void CHARACTER::OpenChest(LPITEM item, WORD openCount)
|
||||
{
|
||||
// Validate the client supplied position before entering AVA2's batch reward path.
|
||||
if (!item || item->GetOwner()!=this || !openCount || item->GetType()!=ITEM_GIFTBOX ||
|
||||
item->IsEquipped() || item->IsExchanging() || item->isLocked() ||
|
||||
IsDead() || IsStun() || IsWarping() || IsObserverMode() || !CanHandleItem() ||
|
||||
GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen()) return;
|
||||
|
||||
for(int i=0;i<ITEM_LIMIT_MAX_NUM;++i)
|
||||
if(item->GetLimitType(i)==LIMIT_LEVEL && GetLevel()<item->GetLimitValue(i)) return;
|
||||
if(CArenaManager::instance().IsLimitedItem(GetMapIndex(),item->GetVnum())) return;
|
||||
const DWORD vnum=item->GetVnum();
|
||||
if(((vnum>51500 && vnum<52000) || (vnum>=50255 && vnum<=50260)) && !DragonSoul_IsQualified()) return;
|
||||
if(openCount > item->GetCount())
|
||||
openCount = item->GetCount();
|
||||
|
||||
if(openCount > 1000)
|
||||
openCount =1000;
|
||||
|
||||
std::map<DWORD, DWORD> dwItemVnums;
|
||||
const WORD openCountCache = openCount;
|
||||
if (GiveItemFromSpecialItemGroupNew(item->GetVnum(), openCount))
|
||||
{
|
||||
if(openCount != 0)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "chest_opened %u", unsigned(openCountCache-openCount));
|
||||
item->SetCount(item->GetCount() - (openCountCache-openCount));
|
||||
}
|
||||
else
|
||||
item->SetCount(item->GetCount() - openCountCache);
|
||||
}
|
||||
else
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "chest_error full");
|
||||
}
|
||||
bool CHARACTER::AutoGiveItemChest(LPITEM item, DWORD& itemCount, std::map<LPITEM, WORD>& vecUpdateItems)
|
||||
{
|
||||
int cell = -1;
|
||||
if (item->IsDragonSoul())
|
||||
cell = GetEmptyDragonSoulInventory(item);
|
||||
else
|
||||
cell = GetEmptyInventory(item->GetSize());
|
||||
|
||||
if (cell == -1)
|
||||
return false;
|
||||
|
||||
const DWORD itemVnum = item->GetVnum();
|
||||
WORD wCount = item->GetCount();
|
||||
|
||||
if (item->IsStackable() && item->GetType() != ITEM_BLEND)
|
||||
{
|
||||
for (auto it = vecUpdateItems.begin(); it != vecUpdateItems.end(); ++it)
|
||||
{
|
||||
LPITEM item2 = it->first;
|
||||
if (itemVnum == item2->GetVnum())
|
||||
{
|
||||
bool same=true;
|
||||
for(int j=0;j<ITEM_SOCKET_MAX_NUM;++j)
|
||||
if(item2->GetSocket(j)!=item->GetSocket(j)) same=false;
|
||||
if(!same) continue;
|
||||
const DWORD item2Count = item2->GetCount();
|
||||
const WORD bCount2 = MIN(ITEM_MAX_COUNT - item2Count, wCount);
|
||||
if (bCount2 > 0)
|
||||
{
|
||||
wCount -= bCount2;
|
||||
item2->SetCount(item2Count + bCount2);
|
||||
if (wCount == 0)
|
||||
{
|
||||
itemCount = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
|
||||
{
|
||||
LPITEM item2 = GetInventoryItem(i);
|
||||
if (!item2)
|
||||
continue;
|
||||
if (item2->GetVnum() == itemVnum)
|
||||
{
|
||||
BYTE j;
|
||||
for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
|
||||
if (item2->GetSocket(j) != item->GetSocket(j))
|
||||
break;
|
||||
if (j != ITEM_SOCKET_MAX_NUM)
|
||||
continue;
|
||||
const DWORD item2Count = item2->GetCount();
|
||||
const WORD bCount2 = MIN(ITEM_MAX_COUNT - item2Count, wCount);
|
||||
if (bCount2 > 0)
|
||||
{
|
||||
const auto itItem = vecUpdateItems.find(item2);
|
||||
if(itItem == vecUpdateItems.end())
|
||||
vecUpdateItems.emplace(item2, item2Count);
|
||||
wCount -= bCount2;
|
||||
item2->SetUpdateStatus(true);
|
||||
item2->SetCount(item2Count + bCount2);
|
||||
if (wCount == 0)
|
||||
{
|
||||
itemCount = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wCount > 0)
|
||||
{
|
||||
item->SetCount(wCount);
|
||||
if (item->IsDragonSoul())
|
||||
item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, cell));
|
||||
else
|
||||
item->AddToCharacter(this, TItemPos(INVENTORY, cell));
|
||||
|
||||
if(item->IsStackable())
|
||||
{
|
||||
const auto itItem = vecUpdateItems.find(item);
|
||||
if(itItem == vecUpdateItems.end())
|
||||
vecUpdateItems.emplace(item, wCount);
|
||||
}
|
||||
itemCount = wCount;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CHARACTER::GiveItemFromSpecialItemGroupNew(DWORD dwGroupNum, WORD& loopCount)
|
||||
{
|
||||
const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(dwGroupNum);
|
||||
if (!pGroup)
|
||||
{
|
||||
sys_err("cannot find special item group %d", dwGroupNum);
|
||||
return false;
|
||||
}
|
||||
std::map<DWORD, DWORD> vecItemCounts;
|
||||
std::map<LPITEM, WORD> vecUpdateItems;
|
||||
const WORD constCount = loopCount;
|
||||
WORD workCount = loopCount;
|
||||
|
||||
int returnCount = 5;
|
||||
|
||||
for (DWORD j = 0; j < constCount; ++j)
|
||||
{
|
||||
if (returnCount <= 0 || workCount <= 0)
|
||||
break;
|
||||
std::vector <int> idxes;
|
||||
const int n = pGroup->GetMultiIndex(idxes);
|
||||
|
||||
bool isOkey = false;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (returnCount <= 0 || (workCount <= 0 && !isOkey))
|
||||
break;
|
||||
|
||||
const int idx = idxes[i];
|
||||
const DWORD dwVnum = pGroup->GetVnum(idx);
|
||||
const DWORD dwEarnCount = pGroup->GetCount(idx);
|
||||
DWORD dwCount = pGroup->GetCount(idx);
|
||||
|
||||
switch (dwVnum)
|
||||
{
|
||||
case CSpecialItemGroup::GOLD:
|
||||
PointChange(POINT_GOLD, dwCount);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::POISON:
|
||||
AttackedByPoison(NULL);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::EXP:
|
||||
PointChange(POINT_EXP, dwCount);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::MOB:
|
||||
{
|
||||
LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(dwCount, GetMapIndex(), GetX() + number(-500, 500), GetY() + number(-500, 500), 0, true, -1);
|
||||
if (ch)
|
||||
ch->SetAggressive();
|
||||
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::MOB_GROUP:
|
||||
CHARACTER_MANAGER::instance().SpawnGroup(dwCount, GetMapIndex(), GetX() - number(300, 500), GetY() - number(300, 500), GetX() + number(300, 500), GetY() + number(300, 500), NULL, true);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::SLOW:
|
||||
AddAffect(AFFECT_SLOW, POINT_MOV_SPEED, -(int)dwCount, AFF_SLOW, 300, 0, true);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::DRAIN_HP:
|
||||
{
|
||||
int iDropHP = GetMaxHP() * dwCount / 100;
|
||||
iDropHP = MIN(iDropHP, GetHP() - 1);
|
||||
PointChange(POINT_HP, -iDropHP);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
// The selected base has 200-count stacks and byte item-count packets.
|
||||
// AVA2 rewards larger than a stack must be split, never silently clamped by CreateItem.
|
||||
DWORD remaining=dwEarnCount;
|
||||
while(remaining) {
|
||||
LPITEM item=ITEM_MANAGER::Instance().CreateItem(dwVnum,MIN(remaining,ITEM_MAX_COUNT));
|
||||
if(!item) { --returnCount; break; }
|
||||
const DWORD created=item->GetCount();
|
||||
DWORD count=created;
|
||||
if(!created || !AutoGiveItemChest(item,count,vecUpdateItems)) {
|
||||
M2_DESTROY_ITEM(item); --returnCount; break;
|
||||
}
|
||||
if(!isOkey) { isOkey=true; --workCount; }
|
||||
vecItemCounts[dwVnum]+=created;
|
||||
remaining-=MIN(remaining,created); // Non-stackable count=1; MAKECOUNT prototypes may create a larger minimum.
|
||||
if(!count) M2_DESTROY_ITEM(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = vecUpdateItems.begin(); it != vecUpdateItems.end(); ++it)
|
||||
{
|
||||
LPITEM item = it->first;
|
||||
item->SetUpdateStatus(false);
|
||||
if (item->GetCount() != it->second)
|
||||
item->UpdatePacket();
|
||||
|
||||
if (item->GetType() == ITEM_QUEST || item->GetType() == ITEM_MATERIAL)
|
||||
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item);
|
||||
}
|
||||
|
||||
for (auto it = vecItemCounts.begin(); it != vecItemCounts.end(); ++it)
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "chest_reward %u %u", it->first, it->second);
|
||||
|
||||
loopCount = workCount;
|
||||
return (workCount != constCount);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
// PORT: native AVA2 chest commands; old mt_chest is retained for older clients.
|
||||
|
||||
ACMD(do_chest_drop) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc()) return;
|
||||
std::istringstream input(argument); std::string w,c,n,extra;
|
||||
unsigned window=0,cell=0,count=0;
|
||||
if(!(input>>w>>c>>n) || (input>>extra) || !PortChestNumber(w,window) ||
|
||||
!PortChestNumber(c,cell) || !PortChestNumber(n,count) ||
|
||||
window!=INVENTORY || cell>=INVENTORY_MAX_NUM || !count) return;
|
||||
DWORD& last=g_portChestLastCommand[ch->GetPlayerID()];
|
||||
if(last && get_dword_time()-last<kPortChestGapMs) return;
|
||||
last=get_dword_time();
|
||||
ch->OpenChest(ch->GetItem(TItemPos(INVENTORY,cell)),WORD(MIN(count,1000u)));
|
||||
}
|
||||
ACMD(do_chestdrop) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc()) return;
|
||||
std::istringstream input(argument); std::string n,extra; unsigned vnum=0;
|
||||
if(!(input>>n) || (input>>extra) || n.size()>10 || n.find_first_not_of("0123456789")!=std::string::npos) return;
|
||||
unsigned long long wide=strtoull(n.c_str(),NULL,10);
|
||||
if(wide>0xffffffffULL) return;
|
||||
vnum=DWORD(wide);
|
||||
const TItemTable* proto=ITEM_MANAGER::instance().GetTable(vnum);
|
||||
if(!proto || proto->bType!=ITEM_GIFTBOX) return;
|
||||
const CSpecialItemGroup* group=ITEM_MANAGER::instance().GetSpecialItemGroup(vnum);
|
||||
const DWORD count=group?group->GetGroupSize():0;
|
||||
if(count>8190) return;
|
||||
TEMP_BUFFER buffer;
|
||||
TPacketGCChestDrop p; p.header=HEADER_GC_CHESTDROP;
|
||||
p.size=sizeof(p)+8+count*8;
|
||||
buffer.write(&p,sizeof(p)); buffer.write(&vnum,4); buffer.write(&count,4);
|
||||
for(DWORD i=0;i<count;++i) {
|
||||
const DWORD reward=group->GetVnum(i), amount=group->GetCount(i);
|
||||
buffer.write(&reward,4); buffer.write(&amount,4);
|
||||
}
|
||||
ch->GetDesc()->Packet(buffer.read_peek(),buffer.size());
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
#include "char.h"
|
||||
#include "desc.h"
|
||||
#include "desc_client.h"
|
||||
#include "desc_manager.h"
|
||||
#include "packet.h"
|
||||
#include "cmd.h"
|
||||
#include "ava2_itemshop.h"
|
||||
#include "../../common/ava2_itemshop.h"
|
||||
#include <sstream>
|
||||
#include <cctype>
|
||||
#include <map>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "char_manager.h"
|
||||
#include "questmanager.h"
|
||||
#include "config.h"
|
||||
#include "../../common/point_drop.h"
|
||||
#include "../../common/point_journal.h"
|
||||
|
||||
namespace {
|
||||
struct PendingPoints { Ava2ShopRequest request; unsigned handle; int attempts; time_t next; };
|
||||
std::map<std::string, PendingPoints> pendingPoints;
|
||||
LPEVENT pointRetryEvent = NULL;
|
||||
std::string s_pointLogPath = "log/point_rewards_pending.log";
|
||||
|
||||
PointJournal pointJournal;
|
||||
bool AppendDurableIntent(const Ava2ShopRequest& r){return pointJournal.Intent(r);}
|
||||
bool AppendDurableDone(const char* token,uint8_t status,uint32_t granted,int64_t balance){return pointJournal.Done(token,status,granted,balance);}
|
||||
|
||||
EVENTINFO(PointRetryInfo) {};
|
||||
EVENTFUNC(RetryPoints) {
|
||||
if(pointJournal.NeedsCompaction() && !pointJournal.Compact())sys_err("POINT_DROP: %s",pointJournal.Error().c_str());
|
||||
for(auto it=pendingPoints.begin();it!=pendingPoints.end();) {
|
||||
auto& p=it->second;
|
||||
if(get_global_time()<p.next){++it;continue;}
|
||||
if(p.attempts>=12) {
|
||||
sys_err("POINT_DROP: retry throttled account=%u token=%s attempts=%d",p.request.account,p.request.token,p.attempts);
|
||||
p.next=get_global_time()+60; // Throttled retry: resend every 60s, never silently drop!
|
||||
if(db_clientdesc) db_clientdesc->DBPacket(76,p.handle,&p.request,sizeof(p.request));
|
||||
++p.attempts;++it;
|
||||
continue;
|
||||
}
|
||||
if(db_clientdesc) db_clientdesc->DBPacket(76,p.handle,&p.request,sizeof(p.request));
|
||||
++p.attempts;p.next=get_global_time()+10;++it;
|
||||
}
|
||||
if(pendingPoints.empty()){pointRetryEvent=NULL;return 0;}
|
||||
return PASSES_PER_SEC(1);
|
||||
}
|
||||
bool PointReply(const Ava2ShopReply& reply,const char* data) {
|
||||
if(reply.size!=46 || uint8_t(data[0])!=9)return false;
|
||||
char token[33]={};memcpy(token,data+2,32);
|
||||
const auto found=pendingPoints.find(token);
|
||||
if(found==pendingPoints.end() || found->second.request.account!=reply.account || found->second.request.player!=reply.player)return true;
|
||||
const uint8_t status=uint8_t(data[1]);
|
||||
if(status==6 || status==8)return true; // Same durable token retries transaction/commit uncertainty.
|
||||
uint32_t amount=0;int64_t balance=0;memcpy(&amount,data+34,4);memcpy(&balance,data+38,8);
|
||||
if((status!=0 && status!=1 && status!=2 && status!=7) || balance<0 ||
|
||||
amount>found->second.request.count || (status!=0 && amount!=0)) {
|
||||
sys_err("POINT_DROP: malformed settlement result; keep durable token %s pending",token);
|
||||
return true;
|
||||
}
|
||||
if(!AppendDurableDone(token,status,amount,balance)){sys_err("POINT_DROP: %s",pointJournal.Error().c_str());return true;}
|
||||
pendingPoints.erase(found);
|
||||
auto ch=CHARACTER_MANAGER::instance().FindByPID(reply.player);
|
||||
if(status || !amount || balance<0 || !ch || !ch->GetDesc() || ch->GetDesc()->GetAccountTable().id!=reply.account)return true;
|
||||
const char* version=strstr(ch->GetDesc()->GetClientVersion(),"mt");
|
||||
if(version && atoi(version+2)>=20261021)
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTPOINTS %u %lld",amount,static_cast<long long>(balance));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Ava2PointDropSetLogPath(const std::string& path) {
|
||||
s_pointLogPath = path;
|
||||
}
|
||||
|
||||
const std::string& Ava2PointDropGetLogPath() {
|
||||
return s_pointLogPath;
|
||||
}
|
||||
|
||||
size_t Ava2PointPendingCount() {
|
||||
return pendingPoints.size();
|
||||
}
|
||||
|
||||
void Ava2PointDropInit() {
|
||||
std::map<std::string,Ava2ShopRequest> recovered;
|
||||
if(!pointJournal.Open(s_pointLogPath,recovered))sys_err("POINT_DROP: %s",pointJournal.Error().c_str());
|
||||
if(pointJournal.NeedsCompaction() && !pointJournal.Compact())sys_err("POINT_DROP: %s",pointJournal.Error().c_str());
|
||||
for(const auto& record:recovered){PendingPoints pending={record.second,0,1,get_global_time()+2};pendingPoints.emplace(record.first,pending);}
|
||||
if(!pendingPoints.empty()&&!pointRetryEvent)pointRetryEvent=event_create(RetryPoints,AllocEventInfo<PointRetryInfo>(),PASSES_PER_SEC(1));
|
||||
}
|
||||
|
||||
void Ava2PointDrop(CHARACTER* ch,CHARACTER* victim) {
|
||||
if(!ch || !victim || !ch->IsPC() || !ch->GetDesc() || victim->IsPC() || victim->IsPet() ||
|
||||
(!victim->IsMonster() && !victim->IsStone()))return;
|
||||
const auto rule=PortPointRule([](const std::string& key){return quest::CQuestManager::instance().GetEventFlag(key);},victim->IsStone());
|
||||
if(!rule.eligible(victim->GetLevel(),ch->GetLevel()) || number(1,10000)>rule.chance)return;
|
||||
if(!pointJournal.Ready()){sys_err("POINT_DROP: issuance paused: %s",pointJournal.Error().c_str());return;}
|
||||
Ava2ShopRequest p={};p.operation=3;p.account=ch->GetDesc()->GetAccountTable().id;p.player=ch->GetPlayerID();
|
||||
p.product=victim->GetRaceNum();p.count=number(rule.minimum,rule.maximum);p.expectedVnum=ch->GetLevel();
|
||||
static const uint64_t boot=[](){timeval t;gettimeofday(&t,NULL);return (uint64_t(t.tv_sec)*1000000+t.tv_usec) ^ (uint64_t(getpid())<<32);}();
|
||||
static uint64_t serial=0;
|
||||
snprintf(p.token,sizeof(p.token),"%016llx%016llx",static_cast<unsigned long long>(boot),static_cast<unsigned long long>(++serial));
|
||||
strlcpy(p.name,ch->GetName(),sizeof(p.name));
|
||||
if (!AppendDurableIntent(p)) {
|
||||
sys_err("POINT_DROP: failed to write durable log, drop aborted for account=%u token=%s", p.account, p.token);
|
||||
return;
|
||||
}
|
||||
PendingPoints pending={p,ch->GetDesc()->GetHandle(),1,get_global_time()+10};pendingPoints.emplace(p.token,pending);
|
||||
if(db_clientdesc) db_clientdesc->DBPacket(76,pending.handle,&p,sizeof(p));
|
||||
if(!pointRetryEvent)pointRetryEvent=event_create(RetryPoints,AllocEventInfo<PointRetryInfo>(),PASSES_PER_SEC(1));
|
||||
}
|
||||
ACMD(do_ishop) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc() || ch->IsWarping() || ch->IsDead())return;
|
||||
const char* version=strstr(ch->GetDesc()->GetClientVersion(),"mt");
|
||||
if(!version || atoi(version+2)<20261020) {ch->ChatPacket(CHAT_TYPE_INFO,"Please update your client to use the item shop.");return;}
|
||||
std::istringstream input(argument);std::string op,extra;input>>op;
|
||||
Ava2ShopRequest p={};p.account=ch->GetDesc()->GetAccountTable().id;p.player=ch->GetPlayerID();
|
||||
strlcpy(p.name,ch->GetName(),sizeof(p.name));strlcpy(p.ip,ch->GetDesc()->GetHostName(),sizeof(p.ip));
|
||||
if(op=="data") {p.operation=0;int revision=-1;if(!(input>>revision))return;}
|
||||
else if(op=="log")p.operation=1;
|
||||
else if(op=="buy") {
|
||||
p.operation=2;std::string token;
|
||||
if(!(input>>p.product>>p.count>>token>>p.expectedTotal>>p.expectedVnum) || !p.product || p.count<1 || p.count>20 || token.size()!=32 || p.expectedTotal<0 || p.expectedTotal>20000000000000LL || !p.expectedVnum)return;
|
||||
for(char c:token)if(!std::isxdigit(static_cast<unsigned char>(c)))return;
|
||||
strlcpy(p.token,token.c_str(),sizeof(p.token));
|
||||
} else return;
|
||||
if(input>>extra)return;
|
||||
const std::string throttle="ishop."+op;
|
||||
if(ch->GetProtectTime(throttle)>get_global_time())return;
|
||||
ch->SetProtectTime(throttle,get_global_time()+1);
|
||||
db_clientdesc->DBPacket(76,ch->GetDesc()->GetHandle(),&p,sizeof(p));
|
||||
}
|
||||
void Ava2ItemShopReply(unsigned long handle,const char* data) {
|
||||
Ava2ShopReply r;memcpy(&r,data,sizeof(r));
|
||||
if(PointReply(r,data+sizeof(r)))return;
|
||||
auto d=DESC_MANAGER::instance().FindByHandle(handle);
|
||||
if(!d || !d->IsPhase(PHASE_GAME) || !d->GetCharacter() || d->GetAccountTable().id!=r.account || d->GetCharacter()->GetPlayerID()!=r.player)return;
|
||||
#pragma pack(push,1)
|
||||
struct Header {uint8_t header;uint32_t size;};
|
||||
#pragma pack(pop)
|
||||
Header h={93,uint32_t(sizeof(Header)+r.size)};
|
||||
d->BufferedPacket(&h,sizeof(h));d->Packet(data+sizeof(r),r.size);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <cstddef>
|
||||
class CHARACTER;
|
||||
void Ava2ItemShopReply(unsigned long handle,const char* data);
|
||||
void Ava2PointDrop(CHARACTER* player, CHARACTER* victim);
|
||||
void Ava2PointDropInit();
|
||||
void Ava2PointDropSetLogPath(const std::string& path);
|
||||
const std::string& Ava2PointDropGetLogPath();
|
||||
size_t Ava2PointPendingCount();
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef METIN2_AVA2_NATIVE_PACKETS_H
|
||||
#define METIN2_AVA2_NATIVE_PACKETS_H
|
||||
#include <stdint.h>
|
||||
#pragma pack(push,1)
|
||||
struct TPacketCGAva2Drop {uint8_t header,subheader;int32_t vnum;};
|
||||
struct TPacketGCAva2Drop {uint8_t header,subheader;char name[100];uint32_t vnum,prob;int32_t count;};
|
||||
struct TPacketGCAva2Events {uint8_t header;uint32_t size;};
|
||||
struct TAva2Event {uint16_t id;uint8_t kind;uint32_t start,end;uint8_t empire,channel;uint32_t value[4];uint8_t active,onlyStart;char startText[25],endText[25];};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(TPacketCGAva2Drop)==6 && sizeof(TPacketGCAva2Drop)==114 && sizeof(TPacketGCAva2Events)==5 && sizeof(TAva2Event)==81,"AVA2 query wire sizes");
|
||||
class CHARACTER;
|
||||
void PortNativeDrop(CHARACTER*,const TPacketCGAva2Drop&);
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
// Included only by cmd_general.cpp; reads the same loaded tables/schedule as actual drops.
|
||||
#include "ava2_native_packets.h"
|
||||
#include <cstring>
|
||||
inline bool PortNativeClient(LPCHARACTER ch) {
|
||||
const char* mark=ch && ch->GetDesc()?strstr(ch->GetDesc()->GetClientVersion(),"mt"):NULL;
|
||||
return mark && atoi(mark+2)>=20261019;
|
||||
}
|
||||
|
||||
void PortNativeDrop(LPCHARACTER ch,const TPacketCGAva2Drop& request) {
|
||||
if (!ch || !ch->GetDesc() || !PortNativeClient(ch))return;
|
||||
if (request.subheader!=0 && request.subheader!=1 && request.subheader!=6 && request.subheader!=7 && request.subheader!=8 && request.subheader!=9 && request.subheader!=10)return;
|
||||
TPacketGCAva2Drop p={};p.header=220;
|
||||
if (request.subheader==0) {p.subheader=2;ch->GetDesc()->Packet(&p,sizeof(p));return;}
|
||||
if (request.vnum<=0)return;
|
||||
const int now=get_global_time();
|
||||
// Always finish a refused request so an untagged AVA2 response cannot poison the next query.
|
||||
p.subheader=4;ch->GetDesc()->Packet(&p,sizeof(p));
|
||||
if (ch->GetProtectTime("native_drop")>now) {p.subheader=6;ch->GetDesc()->Packet(&p,sizeof(p));return;}
|
||||
ch->SetProtectTime("native_drop",now+1);
|
||||
auto& manager=ITEM_MANAGER::instance();unsigned sent=0;bool overflow=false;
|
||||
auto send=[&](unsigned id,unsigned count,unsigned probability,const char* name) {
|
||||
if(!id || !count)return;
|
||||
if(sent>=4096){overflow=true;return;}
|
||||
memset(&p,0,sizeof(p));p.header=220;p.subheader=3;p.vnum=id;p.count=count;p.prob=probability;
|
||||
strlcpy(p.name,name?name:"",sizeof(p.name));ch->GetDesc()->Packet(&p,sizeof(p));++sent;
|
||||
};
|
||||
std::set<unsigned> family;unsigned next=request.vnum;
|
||||
for(unsigned i=0;i<256 && next && !family.count(next);++i) {
|
||||
const auto* t=manager.GetTable(next);if(!t)break;
|
||||
family.insert(next);next=(request.subheader==9 || request.subheader==10)?t->dwRefinedVnum:0;
|
||||
}
|
||||
if ((request.subheader==1 || request.subheader==9) && !family.empty()) {
|
||||
for(auto it=CMobManager::instance().begin();it!=CMobManager::instance().end();++it)
|
||||
for(const auto& row:manager.PortWikiDrops(it->first))
|
||||
if(family.count(row.item))send(it->first,row.count,0,it->second->m_table.szLocaleName);
|
||||
} else if ((request.subheader==8 || request.subheader==10) && !family.empty()) {
|
||||
for(const auto& table:manager.GetTable())
|
||||
if(table.bType==ITEM_GIFTBOX || table.bType==ITEM_TREASURE_BOX)
|
||||
for(const auto& row:manager.PortWikiChest(table.dwVnum))
|
||||
if(family.count(row.item))send(table.dwVnum,row.count,0,table.szLocaleName);
|
||||
} else if (request.subheader==6 || request.subheader==7) {
|
||||
const auto rows=request.subheader==6?manager.PortWikiDrops(request.vnum):manager.PortWikiChest(request.vnum);
|
||||
for(const auto& row:rows) {
|
||||
const auto* proto=manager.GetTable(row.item);
|
||||
// Conditional mob rates cannot be represented by the legacy percentage field.
|
||||
unsigned probability=row.rule==WIKI_SINGLE && row.total?unsigned(100ULL*row.weight/row.total):row.rule==WIKI_INDEPENDENT?row.weight:0;
|
||||
if(proto)send(row.item,row.count,probability,proto->szLocaleName);
|
||||
}
|
||||
}
|
||||
memset(&p,0,sizeof(p));p.header=220;p.subheader=overflow?6:5;ch->GetDesc()->Packet(&p,sizeof(p));
|
||||
}
|
||||
|
||||
ACMD(do_event_manager) {
|
||||
if(!ch || !ch->GetDesc() || !PortNativeClient(ch))return;
|
||||
std::istringstream input(argument);std::string action,extra;
|
||||
if(!(input>>action) || action!="info" || (input>>extra))return;
|
||||
const int now=get_global_time();
|
||||
if(ch->GetProtectTime("native_calendar")>now)return;
|
||||
ch->SetProtectTime("native_calendar",now+2);
|
||||
auto& schedule=PortCurrentEvents();
|
||||
if(!schedule.valid){ch->ChatPacket(CHAT_TYPE_COMMAND,"EventCalendarError unavailable");return;}
|
||||
const time_t stamp=now;struct tm current;gmtime_r(&stamp,¤t);
|
||||
std::map<unsigned,std::vector<TAva2Event>> days;
|
||||
unsigned ordinal=0;
|
||||
for(const auto& e:schedule.events) {
|
||||
++ordinal;
|
||||
const time_t start=e.start,end=e.end;struct tm st,et;gmtime_r(&start,&st);gmtime_r(&end,&et);
|
||||
// Include an ongoing interval which began in the previous month, on day one.
|
||||
const bool starts=st.tm_year==current.tm_year && st.tm_mon==current.tm_mon;
|
||||
const bool overlaps=start<=stamp && end>stamp;
|
||||
if(!starts && !overlaps)continue;
|
||||
TAva2Event event={};event.id=ordinal;event.kind=e.kind==1?8:20;
|
||||
event.start=e.start;event.end=e.end;event.empire=e.empire;event.channel=e.channel;
|
||||
event.active=e.Active(now,g_bChannel,ch->GetEmpire());
|
||||
strftime(event.startText,sizeof(event.startText),"%Y-%m-%d %H:%M:%S",&st);
|
||||
strftime(event.endText,sizeof(event.endText),"%Y-%m-%d %H:%M:%S",&et);
|
||||
days[starts?unsigned(st.tm_mday):1].push_back(event);
|
||||
}
|
||||
// The AVA2 event-manager payload is retained; GC214 avoids classic SHOP_SIGN=39.
|
||||
TPacketGCAva2Events header={214,uint32_t(sizeof(TPacketGCAva2Events)+6)};
|
||||
for(const auto& day:days)header.size+=2+day.second.size()*sizeof(TAva2Event);
|
||||
if(header.size>32768)return;
|
||||
TEMP_BUFFER out;out.write(&header,sizeof(header));
|
||||
const uint8_t sub=0,dayCount=days.size();out.write(&sub,1);out.write(&dayCount,1);out.write(&now,4);
|
||||
for(const auto& day:days) {
|
||||
// Per-day count is BYTE in AVA2. Reject overflow rather than wrapping its length.
|
||||
if(day.second.size()>255){ch->ChatPacket(CHAT_TYPE_COMMAND,"EventCalendarError overflow");return;}
|
||||
const uint8_t index=day.first,count=day.second.size();out.write(&index,1);out.write(&count,1);
|
||||
out.write(day.second.data(),day.second.size()*sizeof(TAva2Event));
|
||||
}
|
||||
ch->GetDesc()->Packet(out.read_peek(),out.size());
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "questpc.h"
|
||||
|
||||
ACMD(do_setpickupmode) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc()) return;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if(!pc || !pc->IsLoaded()) return; // QuestLoad sends the authoritative saved settings once ready.
|
||||
std::istringstream input(argument); std::string a,b,extra;
|
||||
if(!(input>>a)) { ch->ChatPacket(CHAT_TYPE_COMMAND,"PickUPMode %u %u",ch->GetPickUPMode(),ch->GetPickUPRarityMode());return; }
|
||||
if(!(input>>b) || (input>>extra) || a.size()>6 || b.size()>2 ||
|
||||
a.find_first_not_of("0123456789")!=std::string::npos || b.find_first_not_of("0123456789")!=std::string::npos) return;
|
||||
ch->ChangePickUPMode(strtoul(a.c_str(),NULL,10),strtoul(b.c_str(),NULL,10));
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// AVA2 player.shop/shop_item #12 snapshot. Isolated from existing NPC shop IDs.
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
#include "char.h"
|
||||
#include "item.h"
|
||||
#include "item_manager.h"
|
||||
#include "shop.h"
|
||||
#include "packet.h"
|
||||
#include "desc.h"
|
||||
#include "questmanager.h"
|
||||
#include "questpc.h"
|
||||
#include "ava2_ticket_shop.h"
|
||||
#include <memory>
|
||||
struct Ava2TicketOffer { DWORD vnum,count,currency,price; };
|
||||
static const Ava2TicketOffer kAva2Tickets[]={
|
||||
{25163,1,90011,10},{25164,1,90011,15},{25165,1,90012,15},{25166,1,90012,15},
|
||||
{25167,1,90010,20},{25168,1,90010,20},{25169,1,90010,30},{25170,1,90010,30}
|
||||
};
|
||||
#pragma pack(push,1)
|
||||
struct Ava2ShopPrice { DWORD vnum,count; };
|
||||
struct Ava2ShopStart { TPacketGCShopStart shop; Ava2ShopPrice prices[SHOP_HOST_ITEM_MAX_NUM]; };
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(Ava2ShopStart)==2204,"native currency shop payload");
|
||||
static_assert(sizeof(Ava2ShopPrice)==8,"AVA2 item price layout");
|
||||
class CAva2TicketShop : public CShop {
|
||||
public:
|
||||
bool Initialize() {
|
||||
TShopItemTable items[SHOP_HOST_ITEM_MAX_NUM]={};
|
||||
for (size_t i=0;i<sizeof(kAva2Tickets)/sizeof(kAva2Tickets[0]);++i) {
|
||||
if (!ITEM_MANAGER::instance().GetTable(kAva2Tickets[i].vnum) || !ITEM_MANAGER::instance().GetTable(kAva2Tickets[i].currency)) return false;
|
||||
items[i].vnum=kAva2Tickets[i].vnum;items[i].count=kAva2Tickets[i].count;
|
||||
}
|
||||
if (!Create(12,20381,items)) return false;
|
||||
for (auto& item:m_itemVector) item.price=0; // Gold must never be charged for an item-currency offer.
|
||||
return true;
|
||||
}
|
||||
bool AddGuest(LPCHARACTER ch,DWORD,bool) override {
|
||||
if (!ch || ch->GetShop() || ch->GetExchange()) return false;
|
||||
Ava2ShopStart start={};
|
||||
for (size_t i=0;i<sizeof(kAva2Tickets)/sizeof(kAva2Tickets[0]);++i) {
|
||||
// All eight original ticket prototypes occupy one grid cell.
|
||||
if (m_itemVector[i].vnum!=kAva2Tickets[i].vnum) return false;
|
||||
start.shop.items[i].vnum=kAva2Tickets[i].vnum;
|
||||
start.shop.items[i].count=kAva2Tickets[i].count;
|
||||
start.prices[i].vnum=kAva2Tickets[i].currency;
|
||||
start.prices[i].count=kAva2Tickets[i].price;
|
||||
}
|
||||
ch->SetShop(this);ch->SetShopOwner(ch);
|
||||
m_map_guest.insert(GuestMapType::value_type(ch,false));
|
||||
TPacketGCShop packet={};packet.header=HEADER_GC_SHOP;
|
||||
packet.subheader=SHOP_SUBHEADER_GC_START_ITEM_CURRENCY;packet.size=sizeof(packet)+sizeof(start);
|
||||
ch->GetDesc()->BufferedPacket(&packet,sizeof(packet));ch->GetDesc()->Packet(&start,sizeof(start));
|
||||
return true;
|
||||
}
|
||||
int Buy(LPCHARACTER ch,BYTE pos) override {
|
||||
if (!ch || ch->GetShop()!=this || ch->GetShopOwner()!=ch || m_map_guest.find(ch)==m_map_guest.end()) return SHOP_SUBHEADER_GC_END;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded() || pc->IsRunning() || !ch->CanHandleItem() || ch->IsDead() || ch->IsStun() || ch->IsWarping() || ch->GetExchange() || ch->GetMyShop() || ch->IsOpenSafebox() || ch->IsCubeOpen()) return SHOP_SUBHEADER_GC_END;
|
||||
if (pos>=sizeof(kAva2Tickets)/sizeof(kAva2Tickets[0])) return SHOP_SUBHEADER_GC_INVALID_POS;
|
||||
const auto& offer=kAva2Tickets[pos];
|
||||
// Same AVA2 item-currency branch, using the existing inventory range and item removal path.
|
||||
if (ch->CountSpecifyItem(offer.currency)<int(offer.price)) return SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM;
|
||||
const int result=CShop::Buy(ch,pos);
|
||||
// CShop::Buy synchronously validates/creates/places the ticket; it performs no quest callbacks.
|
||||
// The reward and currency differ, and no network event can interleave this game-thread operation.
|
||||
if (result==SHOP_SUBHEADER_GC_OK) { ch->RemoveSpecifyItem(offer.currency,offer.price);ch->Save(); }
|
||||
return result;
|
||||
}
|
||||
};
|
||||
static std::unique_ptr<CAva2TicketShop> s_ava2Tickets;
|
||||
bool Ava2IsTicketShop(CShop* shop) { return shop && shop==s_ava2Tickets.get(); }
|
||||
void Ava2DestroyTicketShop() { s_ava2Tickets.reset(); }
|
||||
bool Ava2OpenTicketShop(LPCHARACTER ch) {
|
||||
if (!ch || !ch->IsPC()) return false;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded() || pc->IsRunning() || !ch->CanHandleItem() || ch->IsDead() || ch->IsStun() || ch->IsWarping() || ch->GetShop() || ch->GetExchange() || ch->GetMyShop() || ch->IsOpenSafebox() || ch->IsCubeOpen()) return false;
|
||||
if (!s_ava2Tickets) {
|
||||
std::unique_ptr<CAva2TicketShop> shop(new CAva2TicketShop);
|
||||
if (!shop->Initialize()) return false;
|
||||
s_ava2Tickets=std::move(shop);
|
||||
}
|
||||
return s_ava2Tickets->AddGuest(ch,0,false);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef AVA2_TICKET_SHOP_H
|
||||
#define AVA2_TICKET_SHOP_H
|
||||
class CShop;
|
||||
bool Ava2IsTicketShop(CShop* shop);
|
||||
bool Ava2OpenTicketShop(LPCHARACTER ch);
|
||||
void Ava2DestroyTicketShop();
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
// AVA2 CHARACTER::GetDungeonCooldown protocol and quest flag precedence.
|
||||
#include "stdafx.h"
|
||||
#include "char.h"
|
||||
#include "utils.h"
|
||||
#include "questmanager.h"
|
||||
#include "questpc.h"
|
||||
#include "ava2_track.h"
|
||||
#include "port_dungeon_settings.h"
|
||||
void Ava2TrackDungeonInfo(LPCHARACTER ch, WORD boss)
|
||||
{
|
||||
if (!ch || !ch->IsPC()) return;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded()) return;
|
||||
const std::map<WORD,std::pair<std::string,std::string>> flags={
|
||||
{1093,{"deviltower_zone.cooldown","deviltower_zone.time"}},
|
||||
{2598,{"devilcatacomb_zone.cooldown","devilcatacomb_zone.time"}},
|
||||
{2493,{"dragonlair.cooldown","dragonlair.time"}},
|
||||
{6091,{"flame_dungeon.cooldown","flame_dungeon.time"}},
|
||||
{9018,{"ShipDefense.cooldown","ShipDefense.time"}},
|
||||
{6191,{"snow_dungeon.cooldown","snow_dungeon.time"}},
|
||||
{20442,{"MeleyDungeon.cooldown","MeleyDungeon.time"}},
|
||||
{2092,{"SpiderDungeon.cooldown","SpiderDungeon.time"}}
|
||||
};
|
||||
std::string text;
|
||||
for (const auto& row:flags) {
|
||||
if (boss!=65535 && boss!=row.first) continue;
|
||||
const int now=int(get_global_time());
|
||||
int cooldown=std::max(0,ch->GetQuestFlag(row.second.first)-now);
|
||||
const int reenter=std::max(0,ch->GetQuestFlag(row.second.second)-now);
|
||||
// Existing 40250 quests remain authoritative until their AVA2 replacements are installed.
|
||||
// These are cooldowns only: the entrance NPC still validates tickets, party and room ownership.
|
||||
auto& manager=quest::CQuestManager::instance();
|
||||
const char* legacyFlag=nullptr;int delay=0;
|
||||
if (row.first==2598 && manager.GetQuestIndexByName("devilcatacomb_zone")) {legacyFlag="devilcatacomb_zone.last_exit_time";delay=1800;}
|
||||
if (row.first==6091 && manager.GetQuestIndexByName("flame_dungeon")) {legacyFlag="flame_dungeon.exit_time";delay=1800;}
|
||||
if (row.first==2092 && manager.GetQuestIndexByName("spider_dungeon_3floor_boss")) legacyFlag="spider_dungeon_3floor_boss.retry_limit_time";
|
||||
if (legacyFlag) {
|
||||
const int flag=ch->GetQuestFlag(legacyFlag);
|
||||
if (flag>0) cooldown=std::max(cooldown,int(std::min(2147483647LL,std::max(0LL,static_cast<long long>(flag)+delay-now))));
|
||||
}
|
||||
if (row.first==2493 && !manager.GetQuestIndexByName("dragonlair") && manager.GetQuestIndexByName("dragon_lair_access")) {
|
||||
std::vector<unsigned> settings;
|
||||
// Do not execute Lua while the player is in a suspended quest coroutine.
|
||||
if (pc->IsRunning() || !PortDungeonSettings("dragon_lair_access","get_settings",{"cooldown_time"},settings) || !settings[0]) cooldown=-1;
|
||||
else cooldown=std::max(cooldown,int(std::min(2147483647LL,std::max(0LL,static_cast<long long>(manager.GetEventFlag("dragon_lair_time"))+settings[0]-now))));
|
||||
}
|
||||
// Send explicit zero as well, so an old/re-enter timer is cleared on refresh.
|
||||
const int left=cooldown<0?-1:cooldown?cooldown:reenter;
|
||||
text+=std::to_string(row.first)+"|"+std::to_string(left)+"|"+(cooldown>0?"0":reenter?"1":"0")+"#";
|
||||
if (text.size()+50>CHAT_MAX_LEN) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackDungeonInfo %s",text.c_str());text.clear();
|
||||
}
|
||||
}
|
||||
if (!text.empty()) ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackDungeonInfo %s",text.c_str());
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#ifndef AVA2_TRACK_H
|
||||
#define AVA2_TRACK_H
|
||||
void Ava2TrackDungeonInfo(LPCHARACTER ch, WORD boss=65535);
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
// Original AVA2 /track_window load + teleport. GM debug mutations are deliberately not player commands.
|
||||
#include "new_mob_timer.h"
|
||||
#include "ava2_track.h"
|
||||
#include <sstream>
|
||||
ACMD(do_track_window)
|
||||
{
|
||||
if (!ch || !ch->IsPC()) return;
|
||||
std::istringstream in(argument);std::string action,extra;
|
||||
if (!(in>>action)) return;
|
||||
if (action=="load") {
|
||||
const int now=get_global_time();
|
||||
if (ch->GetProtectTime("track_query")>now) return;
|
||||
ch->SetProtectTime("track_query",now+1);
|
||||
ch->SetProtectTime("track_dungeon",1);
|
||||
Ava2TrackDungeonInfo(ch);
|
||||
// The five original native UI IDs; no client-controlled scan or unbounded output.
|
||||
for (WORD id=0;id<5;++id) CNewMobTimer::instance().GetTrackData(ch,id);
|
||||
} else if (action=="teleport") {
|
||||
unsigned boss=0; if (!(in>>boss) || (in>>extra)) return;
|
||||
const PortTrackDestination* d=PortTrackFind(boss);
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
const char* error=nullptr;
|
||||
if (!d) error="unsupported";
|
||||
else if (ch->GetLevel()<d->minLevel || ch->GetLevel()>d->maxLevel) error="level";
|
||||
else if (!pc || !pc->IsLoaded() || pc->IsRunning() || ch->IsDead() || ch->IsStun() || ch->IsWarping() || !ch->CanHandleItem() || !ch->CanWarp()) error="busy";
|
||||
else if (!ch->WarpSet(d->x*100,d->y*100,0)) error="unavailable";
|
||||
if (error) ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackError %s",error);
|
||||
}
|
||||
}
|
||||
@@ -138,6 +138,12 @@ int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim)
|
||||
// PC일 경우 상대가 melee 몹일 경우 몹의 공격 거리가 최대 공격 거리
|
||||
if (false == victim->IsPC() && BATTLE_TYPE_MELEE == victim->GetMobBattleType())
|
||||
max = MAX(300, (int) (victim->GetMobAttackRange() * 1.15f));
|
||||
|
||||
// A boss body can be far wider than 300 (the hydra 6812 is out on the water and the deck
|
||||
// stops a player about 620 from its centre). The client already allows 500 from a boss
|
||||
// centre on its odd x/z test, so the server allows 800 for a boss.
|
||||
if (false == victim->IsPC() && victim->GetMobRank() >= MOB_RANK_BOSS)
|
||||
max = MAX(max, 800);
|
||||
}
|
||||
|
||||
if (distance > max)
|
||||
@@ -287,6 +293,20 @@ int CalcAttBonus(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, int iAtk)
|
||||
else if (pkVictim->IsRaceFlag(RACE_FLAG_TREE))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_TREE)) / 100;
|
||||
|
||||
// PORT AVA2 ELEMENT_NEW_BONUSES (talisman enchant), each flag on its own like AVA2; AVA2 forgot ICE.
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ELEC))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_ELEC)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_FIRE))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_FIRE)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ICE))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_ICE)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_WIND))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_WIND)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_EARTH))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_EARTH)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_DARK))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_DARK)) / 100;
|
||||
|
||||
if (pkVictim->GetMobRank() >= MOB_RANK_BOSS && !pkVictim->IsStone())
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_BOSS)) / 100;
|
||||
int monsterBonus = pkAttacker->GetPoint(POINT_ATTBONUS_MONSTER);
|
||||
@@ -389,6 +409,13 @@ void Item_GetDamage(LPITEM pkItem, int* pdamMin, int* pdamMax)
|
||||
|
||||
*pdamMin = pkItem->GetValue(3);
|
||||
*pdamMax = pkItem->GetValue(4);
|
||||
|
||||
int iMin, iMax, iMagMin, iMagMax;
|
||||
if (Sash_GetAbsorbedWeaponBonus(pkItem->GetOwner(), &iMin, &iMax, &iMagMin, &iMagMax))
|
||||
{
|
||||
*pdamMin += iMin;
|
||||
*pdamMax += iMax;
|
||||
}
|
||||
}
|
||||
|
||||
int CalcMeleeDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool bIgnoreDefense, bool bIgnoreTargetRating)
|
||||
|
||||
@@ -21,6 +21,7 @@ extern float CalcAttackRating(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool
|
||||
extern bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim);
|
||||
extern int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim);
|
||||
extern void battle_end(LPCHARACTER ch);
|
||||
extern bool Sash_GetAbsorbedWeaponBonus(LPCHARACTER ch, int * piMin, int * piMax, int * piMagMin, int * piMagMax);
|
||||
|
||||
extern bool battle_distance_valid_by_xy(long x, long y, long tx, long ty);
|
||||
extern bool battle_distance_valid(LPCHARACTER ch, LPCHARACTER victim);
|
||||
|
||||
+808
-294
File diff suppressed because it is too large
Load Diff
+433
-228
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "port_magic_reduction.h"
|
||||
#include "PetSystem.h"
|
||||
#include "new_mob_timer.h"
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "desc.h"
|
||||
@@ -40,6 +43,8 @@
|
||||
#include "BlueDragon.h"
|
||||
#include "DragonLair.h"
|
||||
#include <random>
|
||||
#include "port_battlepass_hooks.h"
|
||||
#include "ava2_itemshop.h"
|
||||
#include <algorithm>
|
||||
DWORD AdjustExpByLevel(const LPCHARACTER ch, const DWORD exp)
|
||||
{
|
||||
@@ -260,6 +265,13 @@ bool CHARACTER::Attack(LPCHARACTER pkVictim, BYTE bType)
|
||||
iRet = ComputeSkill(bType, pkVictim);
|
||||
}
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON, "when <vnum>.attack" quest event.
|
||||
if (IsPC() && (pkVictim->IsMonster() || pkVictim->IsStone()))
|
||||
{
|
||||
SetQuestNPCIDAttack(pkVictim->GetVID());
|
||||
quest::CQuestManager::instance().Attack(GetPlayerID(), pkVictim->GetRaceNum());
|
||||
}
|
||||
|
||||
//if (test_server && IsPC())
|
||||
// sys_log(0, "%s Attack %s type %u ret %d", GetName(), pkVictim->GetName(), bType, iRet);
|
||||
if (iRet == BATTLE_DAMAGE || iRet == BATTLE_DEAD)
|
||||
@@ -282,6 +294,7 @@ void CHARACTER::DeathPenalty(BYTE bTown)
|
||||
sys_log(1, "DEATH_PERNALY_CHECK(%s) town(%d)", GetName(), bTown);
|
||||
|
||||
Cube_close(this);
|
||||
CloseSash();
|
||||
|
||||
if (CBattleArena::instance().IsBattleArenaMap(GetMapIndex()) == true)
|
||||
{
|
||||
@@ -329,7 +342,7 @@ void CHARACTER::DeathPenalty(BYTE bTown)
|
||||
}
|
||||
// END_OF_NO_DEATH_PENALTY_BUG_FIX
|
||||
|
||||
int iLoss = ((GetNextExp() * aiExpLossPercents[MINMAX(1, GetLevel(), PLAYER_EXP_TABLE_MAX)]) / 100);
|
||||
int iLoss = (int) (((unsigned long long) GetNextExp() * aiExpLossPercents[MINMAX(1, GetLevel(), PLAYER_EXP_TABLE_MAX)]) / 100); // PORT: 64-bit, next exp up to 4.2e9
|
||||
|
||||
if (true == LC_IsYMIR())
|
||||
{
|
||||
@@ -708,9 +721,9 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
|
||||
|
||||
for (int i = 0; i < iSplitCount; ++i)
|
||||
{
|
||||
if (isAutoLoot)
|
||||
if (isAutoLoot && pkAttacker->GiveGold(iGold / iSplitCount))
|
||||
{
|
||||
pkAttacker->GiveGold(iGold / iSplitCount);
|
||||
// Successfully credited; otherwise keep the reward as a ground pile.
|
||||
}
|
||||
else if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold / iSplitCount)))
|
||||
{
|
||||
@@ -729,6 +742,21 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
|
||||
|
||||
void CHARACTER::Reward(bool bItemDrop)
|
||||
{
|
||||
// PORT: point ownership follows the highest present damage contributor even when EXP is zero.
|
||||
if(bItemDrop && !m_pointDropProcessed)
|
||||
{
|
||||
m_pointDropProcessed=true;
|
||||
LPCHARACTER pointOwner=NULL;int highestDamage=0;
|
||||
for(const auto& damage:m_map_kDamage)
|
||||
{
|
||||
LPCHARACTER attacker=CHARACTER_MANAGER::instance().Find(damage.first);
|
||||
if(!attacker || !attacker->IsPC() || attacker->GetMapIndex()!=GetMapIndex() ||
|
||||
DISTANCE_APPROX(GetX()-attacker->GetX(),GetY()-attacker->GetY())>5000)continue;
|
||||
if(damage.second.iTotalDamage>highestDamage){highestDamage=damage.second.iTotalDamage;pointOwner=attacker;}
|
||||
}
|
||||
Ava2PointDrop(pointOwner,this);
|
||||
}
|
||||
|
||||
if (GetRaceNum() == 5001) // 왜구는 돈을 무조건 드롭
|
||||
{
|
||||
PIXEL_POSITION pos;
|
||||
@@ -785,6 +813,8 @@ void CHARACTER::Reward(bool bItemDrop)
|
||||
pkAttacker->UpdateAlignment(2);
|
||||
|
||||
pkAttacker->SetQuestNPCID(GetVID());
|
||||
// PORT: battle pass kill, credited like the quest kill below (port_battlepass_runtime.h).
|
||||
PortBpKill(pkAttacker, this);
|
||||
quest::CQuestManager::instance().Kill(pkAttacker->GetPlayerID(), GetRaceNum());
|
||||
CHARACTER_MANAGER::instance().KillLog(GetRaceNum());
|
||||
|
||||
@@ -1197,6 +1227,7 @@ class FPartyAlignmentCompute
|
||||
|
||||
void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
|
||||
{
|
||||
if (!IsDead()) CNewMobTimer::instance().Dead(this,pkKiller);
|
||||
if (IsDead())
|
||||
return;
|
||||
|
||||
@@ -1522,6 +1553,9 @@ void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
|
||||
{
|
||||
Cube_close(this);
|
||||
}
|
||||
|
||||
if (IsPC())
|
||||
CloseSash();
|
||||
|
||||
CShopManager::instance().StopShopping(this);
|
||||
CloseMyShop();
|
||||
@@ -1606,6 +1640,7 @@ void CHARACTER::SendDamagePacket(LPCHARACTER pAttacker, int Damage, BYTE DamageF
|
||||
//
|
||||
bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // returns true if dead
|
||||
{
|
||||
if (!CNewMobTimer::instance().CheckDamage(pAttacker,this)) return false;
|
||||
if (DAMAGE_TYPE_MAGIC == type)
|
||||
{
|
||||
dam = (int)((float)dam * (100 + (pAttacker->GetPoint(POINT_MAGIC_ATT_BONUS_PER) + pAttacker->GetPoint(POINT_MELEE_MAGIC_ATT_BONUS_PER))) / 100.f + 0.5f);
|
||||
@@ -1700,6 +1735,13 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||
DAMAGE_CRITICAL = (1 << 5),
|
||||
};
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON. A Meley statue turned to stone (npc.set_protect_time "IsMeleyBlock").
|
||||
if (pAttacker && GetProtectTime("IsMeleyBlock") == 1)
|
||||
{
|
||||
SendDamagePacket(pAttacker, 0, DAMAGE_BLOCK);
|
||||
return false;
|
||||
}
|
||||
|
||||
//PROF_UNIT puAttr("Attr");
|
||||
|
||||
//
|
||||
@@ -2284,6 +2326,11 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||
//
|
||||
// !!!!!!!!! 실제 HP를 줄이는 부분 !!!!!!!!!
|
||||
//
|
||||
// PORT: AVA2 meley lair. Only the quest kills a statue (npc.dead_by_vnum); one hit past the last
|
||||
// stage's 30000 HP threshold (MeleyDungeon 6230.attack) left it dead and the lair stuck.
|
||||
if (GetRaceNum() == 6230 && dam >= GetHP())
|
||||
dam = MAX(0, GetHP() - 1);
|
||||
|
||||
if (!cannot_dead)
|
||||
{
|
||||
PointChange(POINT_HP, -dam, false);
|
||||
@@ -2501,6 +2548,12 @@ static void GiveExp(LPCHARACTER from, LPCHARACTER to, int iExp)
|
||||
|
||||
iExp = AdjustExpByLevel(to, iExp);
|
||||
|
||||
#ifdef ENABLE_NEW_PET_SYSTEM
|
||||
CPetSystem* pet = to->GetPetSystem();
|
||||
if (pet)
|
||||
pet->PointChange(POINT_PET_EXP, iExp * 5);
|
||||
#endif
|
||||
|
||||
to->PointChange(POINT_EXP, iExp, true);
|
||||
from->CreateFly(FLY_EXP, to);
|
||||
|
||||
@@ -2958,7 +3011,12 @@ class CFuncShoot
|
||||
NormalAttackAffect(m_me, pkVictim);
|
||||
|
||||
// 데미지 계산
|
||||
iDam = iDam * (100 - pkVictim->GetPoint(POINT_RESIST_MAGIC)) / 100;
|
||||
#ifdef ENABLE_MAGIC_REDUCTION_SYSTEM
|
||||
iDam = PortMagicDamageAfterResistance(iDam, pkVictim->GetPoint(POINT_RESIST_MAGIC),
|
||||
m_me->GetPoint(POINT_RESIST_MAGIC_REDUCTION), m_me->GetJob()==JOB_SURA);
|
||||
#else
|
||||
iDam = iDam * (100 - pkVictim->GetPoint(POINT_RESIST_MAGIC)) / 100;
|
||||
#endif
|
||||
|
||||
//sys_log(0, "%s arrow %s dam %d", m_me->GetName(), pkVictim->GetName(), iDam);
|
||||
|
||||
@@ -3638,7 +3696,8 @@ void CHARACTER::ChangeVictimByAggro(int iNewAggro, LPCHARACTER pNewVictim)
|
||||
if (itFind != m_map_kDamage.end())
|
||||
{
|
||||
m_iMaxAggro = iNewAggro;
|
||||
SetVictim(CHARACTER_MANAGER::instance().Find(itFind->first));
|
||||
if (!IsHydraMob()) // PORT: AVA2, hydra mobs keep hitting the mast
|
||||
SetVictim(CHARACTER_MANAGER::instance().Find(itFind->first));
|
||||
m_dwStateDuration = 1;
|
||||
}
|
||||
}
|
||||
@@ -3647,7 +3706,8 @@ void CHARACTER::ChangeVictimByAggro(int iNewAggro, LPCHARACTER pNewVictim)
|
||||
if (m_iMaxAggro < iNewAggro)
|
||||
{
|
||||
m_iMaxAggro = iNewAggro;
|
||||
SetVictim(pNewVictim);
|
||||
if (!IsHydraMob()) // PORT: AVA2, hydra mobs keep hitting the mast
|
||||
SetVictim(pNewVictim);
|
||||
m_dwStateDuration = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ int CHARACTER::ChangeEmpire(BYTE empire)
|
||||
|
||||
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(szQuery));
|
||||
|
||||
if (msg->Get()->uiAffectedRows > 0)
|
||||
if (msg->Get()->HasAffectedRows())
|
||||
{
|
||||
// 5. 제국 변경 이력을 추가한다.
|
||||
SetChangeEmpireCount();
|
||||
|
||||
@@ -265,6 +265,15 @@ DWORD CHARACTER::GetMyHorseVnum() const
|
||||
++delta;
|
||||
}
|
||||
|
||||
// AVA2 ENABLE_MOUNT_SKIN / ENABLE_MOUNT_COSTUME_SYSTEM: the worn skin, else the worn mount, is the horse
|
||||
LPITEM pkCostumeMountSkin = GetWear(WEAR_COSTUME_MOUNT_SKIN);
|
||||
if (pkCostumeMountSkin)
|
||||
return pkCostumeMountSkin->GetValue(0);
|
||||
|
||||
LPITEM pkCostumeMount = GetWear(WEAR_COSTUME_MOUNT);
|
||||
if (pkCostumeMount)
|
||||
return pkCostumeMount->GetValue(0);
|
||||
|
||||
return c_aHorseStat[GetHorseLevel()].iNPCRace + delta;
|
||||
}
|
||||
|
||||
|
||||
+1892
-638
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user