Compare commits
6
Commits
5b8cc3069f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65db9fc365 | ||
|
|
275c7e5211 | ||
|
|
32831010c0 | ||
|
|
abda2c1cda | ||
|
|
2016f20d58 | ||
|
|
ec60c38492 |
@@ -1,4 +1,5 @@
|
|||||||
# Local metadata and generated build output
|
# Local metadata and generated build output
|
||||||
|
/build/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
._*
|
._*
|
||||||
__pycache__/
|
__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,300 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -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 @@
|
|||||||
# AVA2 属性锁定选择与展示
|
# AVA2 属性锁定选择与展示
|
||||||
|
|
||||||
2026-10-18;仅 sbtest,game SHA256 `a324f3d0646ce8e8579c34237bbdc54855be2d5578f54476a27005f0af364765`。正式服未变更。
|
2026-10-18;首次选择与自有提示验收使用 sbtest game `a324f3d0646ce8e8579c34237bbdc54855be2d5578f54476a27005f0af364765`;后续其他视图验收和当前版本见下节。正式服未变更。
|
||||||
|
|
||||||
补齐 AVA2 char_item.cpp 的材料使用契约:无目标使用 50348/50349 进入选择 quest,socket 0 保存1~5;拖放时锁定或解锁。选择返回按 ID 重新解析物品,校验所有者、库存与交易/角色状态。选择不扣材料,锁定只有持久保存成功才扣一张;数据库读取失败拒绝覆盖已有状态。处理放在时装/护符专用分支之前。独立 mt_item_attr_lock 表及现有 ChangeAttribute 保留算法继续使用。
|
补齐 AVA2 char_item.cpp 的材料使用契约:无目标使用 50348/50349 进入选择 quest,socket 0 保存1~5;拖放时锁定或解锁。选择返回按 ID 重新解析物品,校验所有者、库存与交易/角色状态。选择不扣材料,锁定只有持久保存成功才扣一张;数据库读取失败拒绝覆盖已有状态。处理放在时装/护符专用分支之前。独立 mt_item_attr_lock 表及现有 ChangeAttribute 保留算法继续使用。
|
||||||
|
|
||||||
@@ -10,4 +10,16 @@
|
|||||||
|
|
||||||
已实际验证选择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-*,勿纳入发布包。
|
已实际验证选择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 通过。还未闭合其他玩家/交易/商店锁定提示、物理输入和 Android 联机。客户端脚本在 OnUpdate 内操作重新登录触发的窗口遍历崩溃单独记录,不能计作重连通过。
|
直接函数测试 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,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资源包。
|
||||||
@@ -85,3 +85,5 @@ CG is registered in `packet_info.cpp` with `Set(..., true)` and GG with `Set(...
|
|||||||
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。
|
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真机按用户要求暂停。
|
同频道、未开放频道、倒计时取消和任务选择中拒绝均通过;另测换到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,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;
|
||||||
|
}
|
||||||
@@ -78,8 +78,12 @@ enum EItemTypes
|
|||||||
ITEM_BELT, //34 벨트
|
ITEM_BELT, //34 벨트
|
||||||
ITEM_SHINING, //35 AVA2 shining (not ported, keeps the AVA2 numbering)
|
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_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 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 EShiningSubTypes { SHINING_WEAPON, SHINING_ARMOR, SHINING_SPECIAL };
|
||||||
|
|
||||||
enum EMetinSubTypes
|
enum EMetinSubTypes
|
||||||
{
|
{
|
||||||
METIN_NORMAL,
|
METIN_NORMAL,
|
||||||
@@ -119,6 +123,9 @@ enum ECostumeSubTypes
|
|||||||
COSTUME_MOUNT = 2, // AVA2 mount costume (value0 = horse race)
|
COSTUME_MOUNT = 2, // AVA2 mount costume (value0 = horse race)
|
||||||
COSTUME_SASH = 3, // AVA2 sash (85001..85024)
|
COSTUME_SASH = 3, // AVA2 sash (85001..85024)
|
||||||
COSTUME_MOUNT_SKIN = 4, // AVA2 mount skin (value0 = horse race, needs COSTUME_MOUNT)
|
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,
|
COSTUME_NUM_TYPES,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ enum EMisc
|
|||||||
DRAGON_SOUL_REFINE_GRID_SIZE = 15,
|
DRAGON_SOUL_REFINE_GRID_SIZE = 15,
|
||||||
MAX_AMOUNT_OF_MALL_BONUS = 20,
|
MAX_AMOUNT_OF_MALL_BONUS = 20,
|
||||||
|
|
||||||
WEAR_MAX_NUM = 32,
|
WEAR_MAX_NUM = 40, // PORT: shop costume/pet/shining equipment.
|
||||||
|
|
||||||
//LIMIT_GOLD
|
//LIMIT_GOLD
|
||||||
GOLD_MAX = 2000000000,
|
GOLD_MAX = 2000000000,
|
||||||
@@ -144,7 +144,14 @@ enum EWearPositions
|
|||||||
WEAR_RINGS_1, // 28 : AVA2 new ring (ITEM_NEW_RINGS)
|
WEAR_RINGS_1, // 28 : AVA2 new ring (ITEM_NEW_RINGS)
|
||||||
WEAR_RINGS_2, // 29 : AVA2 new ring
|
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
|
enum EDragonSoulDeckType
|
||||||
|
|||||||
@@ -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,32 @@
|
|||||||
|
#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) {
|
||||||
|
std::memset(&extra,0,sizeof(extra));
|
||||||
|
if(!hex || !*hex)return true;
|
||||||
|
if(std::strlen(hex)!=sizeof(extra)*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*>(&extra);
|
||||||
|
for(unsigned i=0;i<sizeof(extra);++i){int a=nibble(hex[2*i]),b=nibble(hex[2*i+1]);if(a<0 || b<0){std::memset(&extra,0,sizeof(extra));return false;}p[i]=(a<<4)|b;}
|
||||||
|
extra.name[24]=0;return true;
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "port_item_extra.h"
|
||||||
#ifndef __INC_TABLES_H__
|
#ifndef __INC_TABLES_H__
|
||||||
#define __INC_TABLES_H__
|
#define __INC_TABLES_H__
|
||||||
|
|
||||||
@@ -398,6 +399,7 @@ typedef struct SPlayerItem
|
|||||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||||
|
|
||||||
DWORD owner;
|
DWORD owner;
|
||||||
|
PortItemExtra extra; // PORT: internal game/db state, not a classic client packet.
|
||||||
} TPlayerItem;
|
} TPlayerItem;
|
||||||
|
|
||||||
typedef struct SQuickslot
|
typedef struct SQuickslot
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ void AuctionManager::LoadAuctionItem()
|
|||||||
for (int i = 0; i < rows; ++i)
|
for (int i = 0; i < rows; ++i)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row = mysql_fetch_row(res);
|
MYSQL_ROW row = mysql_fetch_row(res);
|
||||||
TPlayerItem item;
|
TPlayerItem item={};
|
||||||
|
|
||||||
int cur = 0;
|
int cur = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,205 @@
|
|||||||
|
// 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 <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());
|
||||||
|
}
|
||||||
|
Ava2ShopProduct product(MYSQL_ROW r) {
|
||||||
|
Ava2ShopProduct p={};p.id=strtoul(r[0],0,10);p.vnum=strtoul(r[1],0,10);p.price=strtoll(r[2],0,10);p.discount=atoi(r[3]);p.expiry=atoi(r[4]);p.added=atoi(r[5]);p.sold=strtoll(r[6],0,10);p.weekly=atoi(r[7]);p.monthly=atoi(r[8]);p.stock=atoi(r[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);
|
||||||
|
auto engine=query("SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='port_point_rewards' AND ENGINE='InnoDB'");
|
||||||
|
if(validMob && !adb.empty() && transactional(adb) && ok(engine) && engine->Get()->uiNumRows==1 && atoi(mysql_fetch_row(engine->Get()->pSQLResult)[0])==1) {
|
||||||
|
Transaction tx;
|
||||||
|
if(tx.active) {
|
||||||
|
auto owner=query("SELECT account_id FROM player WHERE id="+decimal(r.player));
|
||||||
|
auto wallet=query("SELECT coins FROM "+adb+".account WHERE id="+aid+" FOR UPDATE");
|
||||||
|
if(ok(owner) && owner->Get()->uiNumRows==1 && strtoul(mysql_fetch_row(owner->Get()->pSQLResult)[0],0,10)==r.account && 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 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){granted=strtoul(row[3],0,10);status=0;}else status=7;
|
||||||
|
} else if(ok(previous)) {
|
||||||
|
if(!rule.eligible(mob->bLevel,r.expectedVnum) || r.count<uint32_t(rule.minimum) || r.count>uint32_t(rule.maximum))status=1;
|
||||||
|
else {
|
||||||
|
auto earned=query("SELECT COALESCE(SUM(amount),0) FROM port_point_rewards WHERE account_id="+aid+" AND reward_day=CURDATE()");
|
||||||
|
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)+",CURDATE())");
|
||||||
|
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);int cat=atoi(row[10]),sub=atoi(row[11]);
|
||||||
|
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[cat][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);
|
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];
|
char szItemQuery[QUERY_MAX_LEN + QUERY_MAX_LEN];
|
||||||
snprintf(szItemQuery, sizeof(szItemQuery), "REPLACE INTO item%s (%s) VALUES(%s)", GetTablePostfix(), szColumns, szValues);
|
snprintf(szItemQuery, sizeof(szItemQuery), "REPLACE INTO item%s (%s) VALUES(%s)", GetTablePostfix(), szColumns, szValues);
|
||||||
|
|
||||||
|
|||||||
@@ -581,7 +581,7 @@ void CClientManager::RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg)
|
|||||||
"attrtype3, attrvalue3, "
|
"attrtype3, attrvalue3, "
|
||||||
"attrtype4, attrvalue4, "
|
"attrtype4, attrvalue4, "
|
||||||
"attrtype5, attrvalue5, "
|
"attrtype5, attrvalue5, "
|
||||||
"attrtype6, attrvalue6 "
|
"attrtype6, attrvalue6, HEX(port_extra) "
|
||||||
"FROM item%s WHERE owner_id=%d AND window='%s'",
|
"FROM item%s WHERE owner_id=%d AND window='%s'",
|
||||||
GetTablePostfix(), pi->account_id, pi->ip[0] == 0 ? "SAFEBOX" : "MALL");
|
GetTablePostfix(), pi->account_id, pi->ip[0] == 0 ? "SAFEBOX" : "MALL");
|
||||||
|
|
||||||
@@ -673,7 +673,7 @@ void CClientManager::RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg)
|
|||||||
if ((iPos = grid.FindBlank(1, it->second->bSize)) == -1)
|
if ((iPos = grid.FindBlank(1, it->second->bSize)) == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
TPlayerItem item;
|
TPlayerItem item={};
|
||||||
memset(&item, 0, sizeof(TPlayerItem));
|
memset(&item, 0, sizeof(TPlayerItem));
|
||||||
|
|
||||||
// DWORD dwSocket2 = 0;
|
// DWORD dwSocket2 = 0;
|
||||||
@@ -1307,7 +1307,7 @@ void CClientManager::QUERY_ITEM_SAVE(CPeer * pkPeer, const char * c_pData)
|
|||||||
|
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
char szQuery[512];
|
char szQuery[2048];
|
||||||
|
|
||||||
snprintf(szQuery, sizeof(szQuery),
|
snprintf(szQuery, sizeof(szQuery),
|
||||||
"REPLACE INTO item%s (id, owner_id, window, pos, count, vnum, socket0, socket1, socket2, "
|
"REPLACE INTO item%s (id, owner_id, window, pos, count, vnum, socket0, socket1, socket2, "
|
||||||
@@ -1317,8 +1317,8 @@ void CClientManager::QUERY_ITEM_SAVE(CPeer * pkPeer, const char * c_pData)
|
|||||||
"attrtype3, attrvalue3, "
|
"attrtype3, attrvalue3, "
|
||||||
"attrtype4, attrvalue4, "
|
"attrtype4, attrvalue4, "
|
||||||
"attrtype5, attrvalue5, "
|
"attrtype5, attrvalue5, "
|
||||||
"attrtype6, attrvalue6) "
|
"attrtype6, attrvalue6, port_extra) "
|
||||||
"VALUES(%u, %u, %d, %d, %u, %u, %ld, %ld, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
|
"VALUES(%u, %u, %d, %d, %u, %u, %ld, %ld, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, X'%s')",
|
||||||
GetTablePostfix(),
|
GetTablePostfix(),
|
||||||
p->id,
|
p->id,
|
||||||
p->owner,
|
p->owner,
|
||||||
@@ -1335,7 +1335,7 @@ void CClientManager::QUERY_ITEM_SAVE(CPeer * pkPeer, const char * c_pData)
|
|||||||
p->aAttr[3].bType, p->aAttr[3].sValue,
|
p->aAttr[3].bType, p->aAttr[3].sValue,
|
||||||
p->aAttr[4].bType, p->aAttr[4].sValue,
|
p->aAttr[4].bType, p->aAttr[4].sValue,
|
||||||
p->aAttr[5].bType, p->aAttr[5].sValue,
|
p->aAttr[5].bType, p->aAttr[5].sValue,
|
||||||
p->aAttr[6].bType, p->aAttr[6].sValue);
|
p->aAttr[6].bType, p->aAttr[6].sValue, PortItemExtraHex(p->extra).c_str());
|
||||||
|
|
||||||
CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_SAVE, pkPeer->GetHandle(), NULL);
|
CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_SAVE, pkPeer->GetHandle(), NULL);
|
||||||
}
|
}
|
||||||
@@ -2327,7 +2327,9 @@ void CClientManager::ProcessPackets(CPeer * peer)
|
|||||||
|
|
||||||
switch (header)
|
switch (header)
|
||||||
{
|
{
|
||||||
case HEADER_GD_BOOT:
|
case 76:
|
||||||
|
Ava2ItemShop(peer,dwHandle,data,dwLength);break;
|
||||||
|
case HEADER_GD_BOOT:
|
||||||
QUERY_BOOT(peer, (TPacketGDBoot *) data);
|
QUERY_BOOT(peer, (TPacketGDBoot *) data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -4709,7 +4711,7 @@ void CClientManager::AuctionGetAuctionedItem (CPeer * peer, DWORD actor_id, DWOR
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TPlayerItem item;
|
TPlayerItem item={};
|
||||||
result = AuctionManager::instance().GetAuctionedItem(actor_id, item_id, item);
|
result = AuctionManager::instance().GetAuctionedItem(actor_id, item_id, item);
|
||||||
|
|
||||||
if (result <= AUCTION_FAIL)
|
if (result <= AUCTION_FAIL)
|
||||||
@@ -4749,7 +4751,7 @@ void CClientManager::AuctionBuySoldItem (CPeer * peer, DWORD actor_id, DWORD ite
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TPlayerItem item;
|
TPlayerItem item={};
|
||||||
result = AuctionManager::instance().BuySoldItem(actor_id, item_id, item);
|
result = AuctionManager::instance().BuySoldItem(actor_id, item_id, item);
|
||||||
|
|
||||||
if (result <= AUCTION_FAIL)
|
if (result <= AUCTION_FAIL)
|
||||||
@@ -4789,7 +4791,7 @@ void CClientManager::AuctionCancelAuction (CPeer * peer, DWORD actor_id, DWORD i
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TPlayerItem item;
|
TPlayerItem item={};
|
||||||
result = AuctionManager::instance().CancelAuction(actor_id, item_id, item);
|
result = AuctionManager::instance().CancelAuction(actor_id, item_id, item);
|
||||||
|
|
||||||
if (result <= AUCTION_FAIL)
|
if (result <= AUCTION_FAIL)
|
||||||
@@ -4829,7 +4831,7 @@ void CClientManager::AuctionCancelWish (CPeer * peer, DWORD actor_id, DWORD item
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TPlayerItem item;
|
TPlayerItem item={};
|
||||||
result = AuctionManager::instance().CancelWish(actor_id, item_num);
|
result = AuctionManager::instance().CancelWish(actor_id, item_num);
|
||||||
|
|
||||||
if (result <= AUCTION_FAIL)
|
if (result <= AUCTION_FAIL)
|
||||||
@@ -4868,7 +4870,7 @@ void CClientManager::AuctionCancelSale (CPeer * peer, DWORD actor_id, DWORD item
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TPlayerItem item;
|
TPlayerItem item={};
|
||||||
result = AuctionManager::instance().CancelSale(actor_id, item_id, item);
|
result = AuctionManager::instance().CancelSale(actor_id, item_id, item);
|
||||||
|
|
||||||
if (result <= AUCTION_FAIL)
|
if (result <= AUCTION_FAIL)
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
|
|||||||
int Process();
|
int Process();
|
||||||
|
|
||||||
void ProcessPackets(CPeer * peer);
|
void ProcessPackets(CPeer * peer);
|
||||||
|
void Ava2ItemShop(CPeer* peer, DWORD handle, const char* data, DWORD length);
|
||||||
|
|
||||||
CLoginData * GetLoginData(DWORD dwKey);
|
CLoginData * GetLoginData(DWORD dwKey);
|
||||||
CLoginData * GetLoginDataByLogin(const char * c_pszLogin);
|
CLoginData * GetLoginDataByLogin(const char * c_pszLogin);
|
||||||
|
|||||||
@@ -815,6 +815,8 @@ bool CClientManager::InitializeItemTable()
|
|||||||
// InitializeQuestItemTable();
|
// InitializeQuestItemTable();
|
||||||
// END_OF_QUEST_ITEM_PROTO_DISABLE
|
// 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();
|
m_map_itemTableByVnum.clear();
|
||||||
|
|
||||||
itertype(m_vec_itemTable) it = m_vec_itemTable.begin();
|
itertype(m_vec_itemTable) it = m_vec_itemTable.begin();
|
||||||
@@ -842,7 +844,6 @@ bool CClientManager::InitializeItemTable()
|
|||||||
|
|
||||||
m_map_itemTableByVnum.insert(std::map<DWORD, TItemTable *>::value_type(item_table->dwVnum, item_table));
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ bool CreateItemTableFromRes(MYSQL_RES * res, std::vector<TPlayerItem> * pVec, DW
|
|||||||
str_to_number(item.aAttr[j].sValue, row[cur++]);
|
str_to_number(item.aAttr[j].sValue, row[cur++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PortItemExtraRead(mysql_num_fields(res)>unsigned(cur)?row[cur]:NULL,item.extra);
|
||||||
item.owner = dwPID;
|
item.owner = dwPID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +322,7 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(szQuery, sizeof(szQuery),
|
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 "
|
"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)",
|
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d or window = %d)",
|
||||||
GetTablePostfix(), pTab->id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT);
|
GetTablePostfix(), pTab->id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT);
|
||||||
|
|
||||||
@@ -378,7 +379,7 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
|||||||
// ¾ÆÀÌÅÛ °¡Á®¿À±â
|
// ¾ÆÀÌÅÛ °¡Á®¿À±â
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
snprintf(queryStr, sizeof(queryStr),
|
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 "
|
"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)",
|
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d or window = %d)",
|
||||||
GetTablePostfix(), packet->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT);
|
GetTablePostfix(), packet->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT);
|
||||||
CDBManager::instance().ReturnQuery(queryStr, QID_ITEM, peer->GetHandle(), new ClientHandleInfo(dwHandle, packet->player_id));
|
CDBManager::instance().ReturnQuery(queryStr, QID_ITEM, peer->GetHandle(), new ClientHandleInfo(dwHandle, packet->player_id));
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class CDBManager : public singleton<CDBManager>
|
|||||||
|
|
||||||
void ReturnQuery(const char * c_pszQuery, int iType, DWORD dwIdent, void * pvData, int iSlot = SQL_PLAYER);
|
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 AsyncQuery(const char * c_pszQuery, int iSlot = SQL_PLAYER);
|
||||||
|
MYSQL* DirectHandle(int slot=SQL_PLAYER) { return m_directSQL[slot]->GetSQLHandle(); }
|
||||||
SQLMsg * DirectQuery(const char * c_pszQuery, int iSlot = SQL_PLAYER);
|
SQLMsg * DirectQuery(const char * c_pszQuery, int iSlot = SQL_PLAYER);
|
||||||
|
|
||||||
SQLMsg * PopResult();
|
SQLMsg * PopResult();
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ SRCS = Config.cpp NetBase.cpp Peer.cpp PeerBase.cpp Main.cpp Lock.cpp DBManager.
|
|||||||
ClientManagerBoot.cpp ClientManagerParty.cpp ClientManagerGuild.cpp GuildManager.cpp HB.cpp \
|
ClientManagerBoot.cpp ClientManagerParty.cpp ClientManagerGuild.cpp GuildManager.cpp HB.cpp \
|
||||||
PrivManager.cpp MoneyLog.cpp ItemAwardManager.cpp ClientManagerEventFlag.cpp Marriage.cpp \
|
PrivManager.cpp MoneyLog.cpp ItemAwardManager.cpp ClientManagerEventFlag.cpp Marriage.cpp \
|
||||||
Monarch.cpp BlockCountry.cpp ItemIDRangeManager.cpp ClientManagerHorseName.cpp version.cpp \
|
Monarch.cpp BlockCountry.cpp ItemIDRangeManager.cpp ClientManagerHorseName.cpp version.cpp \
|
||||||
AuctionManager.cpp ProtoReader.cpp CsvReader.cpp
|
AuctionManager.cpp ProtoReader.cpp CsvReader.cpp Ava2ItemShop.cpp
|
||||||
|
|
||||||
OBJS = $(SRCS:%.cpp=$(OBJDIR)/%.o)
|
OBJS = $(SRCS:%.cpp=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ int get_Item_Type_Value(string inputString)
|
|||||||
|
|
||||||
"ITEM_RING",
|
"ITEM_RING",
|
||||||
"ITEM_BELT", //35개 (EItemTypes 값으로 치면 34)
|
"ITEM_BELT", //35개 (EItemTypes 값으로 치면 34)
|
||||||
"ITEM_SHINING", "ITEM_NEW_RINGS", // AVA2 35 (not ported), 36 new rings
|
"ITEM_SHINING", "ITEM_NEW_RINGS", "ITEM_PET", // AVA2 35 (not ported), 36 new rings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -123,8 +123,10 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
|||||||
"RESOURCE_STONE", "RESOURCE_METIN", "RESOURCE_ORE" };
|
"RESOURCE_STONE", "RESOURCE_METIN", "RESOURCE_ORE" };
|
||||||
static string arSub16[] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_3", "UNIQUE_4", "UNIQUE_5",
|
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"};
|
"UNIQUE_6", "UNIQUE_7", "UNIQUE_8", "UNIQUE_9", "USE_SPECIAL"};
|
||||||
static string arSub28[] = { "COSTUME_BODY", "COSTUME_HAIR", "COSTUME_MOUNT", "COSTUME_SASH", "COSTUME_MOUNT_SKIN" };
|
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 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 arSub31[] = { "EXTRACT_DRAGON_SOUL", "EXTRACT_DRAGON_HEART" };
|
||||||
|
|
||||||
static string* arSubType[] = {0, //0
|
static string* arSubType[] = {0, //0
|
||||||
@@ -162,8 +164,9 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
|||||||
0, //32
|
0, //32
|
||||||
0, //33 반지
|
0, //33 반지
|
||||||
0, //34 벨트
|
0, //34 벨트
|
||||||
0, //35 ITEM_SHINING
|
arSub35, //35 ITEM_SHINING
|
||||||
0, //36 ITEM_NEW_RINGS
|
0, //36 ITEM_NEW_RINGS
|
||||||
|
arSub37, //37 ITEM_PET
|
||||||
};
|
};
|
||||||
static int arNumberOfSubtype[_countof(arSubType)] = {
|
static int arNumberOfSubtype[_countof(arSubType)] = {
|
||||||
0,
|
0,
|
||||||
@@ -201,8 +204,9 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
|||||||
0, // 32
|
0, // 32
|
||||||
0, // 33 반지
|
0, // 33 반지
|
||||||
0, // 34 벨트
|
0, // 34 벨트
|
||||||
0, // 35
|
sizeof(arSub35)/sizeof(arSub35[0]), // 35
|
||||||
0, // 36
|
0, // 36
|
||||||
|
sizeof(arSub37)/sizeof(arSub37[0]), // 37
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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\
|
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\
|
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\
|
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 ava2_channel.cpp new_mob_timer.cpp ava2_track.cpp ava2_ticket_shop.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_ava2_dungeon.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_ava2_dungeon.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\
|
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\
|
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\
|
messenger_manager.cpp mining.cpp mob_manager.cpp monarch.cpp motion.cpp over9refine.cpp p2p.cpp packet_info.cpp\
|
||||||
|
|||||||
@@ -715,6 +715,7 @@ bool AuctionManager::InsertItem (TPlayerItem* player_item)
|
|||||||
}
|
}
|
||||||
item->SetSockets(player_item->alSockets);
|
item->SetSockets(player_item->alSockets);
|
||||||
item->SetAttributes(player_item->aAttr);
|
item->SetAttributes(player_item->aAttr);
|
||||||
|
item->SetPortExtra(player_item->extra);
|
||||||
item->SetWindow(AUCTION);
|
item->SetWindow(AUCTION);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
#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 <unistd.h>
|
||||||
|
#include "char_manager.h"
|
||||||
|
#include "questmanager.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "../../common/point_drop.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
struct PendingPoints { Ava2ShopRequest request; unsigned handle; int attempts; time_t next; };
|
||||||
|
std::map<std::string, PendingPoints> pendingPoints;
|
||||||
|
LPEVENT pointRetryEvent = NULL;
|
||||||
|
EVENTINFO(PointRetryInfo) {};
|
||||||
|
EVENTFUNC(RetryPoints) {
|
||||||
|
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 exhausted account=%u token=%s",p.request.account,p.request.token);
|
||||||
|
it=pendingPoints.erase(it);continue;
|
||||||
|
}
|
||||||
|
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.
|
||||||
|
pendingPoints.erase(found);
|
||||||
|
uint32_t amount=0;int64_t balance=0;memcpy(&amount,data+34,4);memcpy(&balance,data+38,8);
|
||||||
|
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 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(pendingPoints.size()>=4096){sys_err("POINT_DROP: pending queue full");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));
|
||||||
|
PendingPoints pending={p,ch->GetDesc()->GetHandle(),1,get_global_time()+10};pendingPoints.emplace(p.token,pending);
|
||||||
|
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,4 @@
|
|||||||
|
#pragma once
|
||||||
|
class CHARACTER;
|
||||||
|
void Ava2ItemShopReply(unsigned long handle,const char* data);
|
||||||
|
void Ava2PointDrop(CHARACTER* player, CHARACTER* victim);
|
||||||
@@ -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());
|
||||||
|
}
|
||||||
@@ -242,6 +242,7 @@ void CHARACTER::Initialize()
|
|||||||
m_dwLastDeadTime = get_dword_time()-180000;
|
m_dwLastDeadTime = get_dword_time()-180000;
|
||||||
|
|
||||||
m_bSkipSave = false;
|
m_bSkipSave = false;
|
||||||
|
m_pointDropProcessed = false;
|
||||||
|
|
||||||
m_bItemLoaded = false;
|
m_bItemLoaded = false;
|
||||||
|
|
||||||
@@ -5723,6 +5724,7 @@ void CHARACTER::LoadSafebox(int iSize, DWORD dwGold, int iItemCount, TPlayerItem
|
|||||||
item->SetSkipSave(true);
|
item->SetSkipSave(true);
|
||||||
item->SetSockets(pItems->alSockets);
|
item->SetSockets(pItems->alSockets);
|
||||||
item->SetAttributes(pItems->aAttr);
|
item->SetAttributes(pItems->aAttr);
|
||||||
|
item->SetPortExtra(pItems->extra);
|
||||||
|
|
||||||
if (!m_pkSafebox->Add(pItems->pos, item))
|
if (!m_pkSafebox->Add(pItems->pos, item))
|
||||||
{
|
{
|
||||||
@@ -5818,6 +5820,7 @@ void CHARACTER::LoadMall(int iItemCount, TPlayerItem * pItems)
|
|||||||
item->SetSkipSave(true);
|
item->SetSkipSave(true);
|
||||||
item->SetSockets(pItems->alSockets);
|
item->SetSockets(pItems->alSockets);
|
||||||
item->SetAttributes(pItems->aAttr);
|
item->SetAttributes(pItems->aAttr);
|
||||||
|
item->SetPortExtra(pItems->extra);
|
||||||
|
|
||||||
if (!m_pkMall->Add(pItems->pos, item))
|
if (!m_pkMall->Add(pItems->pos, item))
|
||||||
M2_DESTROY_ITEM(item);
|
M2_DESTROY_ITEM(item);
|
||||||
|
|||||||
@@ -832,6 +832,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
|||||||
DWORD m_dwPlayStartTime;
|
DWORD m_dwPlayStartTime;
|
||||||
BYTE m_bAddChrState;
|
BYTE m_bAddChrState;
|
||||||
bool m_bSkipSave;
|
bool m_bSkipSave;
|
||||||
|
bool m_pointDropProcessed; // PORT: one point-roll per defeated entity.
|
||||||
std::string m_stMobile;
|
std::string m_stMobile;
|
||||||
char m_szMobileAuth[5];
|
char m_szMobileAuth[5];
|
||||||
BYTE m_bChatCounter;
|
BYTE m_bChatCounter;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#include "DragonLair.h"
|
#include "DragonLair.h"
|
||||||
#include <random>
|
#include <random>
|
||||||
#include "port_battlepass_hooks.h"
|
#include "port_battlepass_hooks.h"
|
||||||
|
#include "ava2_itemshop.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
DWORD AdjustExpByLevel(const LPCHARACTER ch, const DWORD exp)
|
DWORD AdjustExpByLevel(const LPCHARACTER ch, const DWORD exp)
|
||||||
{
|
{
|
||||||
@@ -739,6 +740,21 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
|
|||||||
|
|
||||||
void CHARACTER::Reward(bool bItemDrop)
|
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) // 왜구는 돈을 무조건 드롭
|
if (GetRaceNum() == 5001) // 왜구는 돈을 무조건 드롭
|
||||||
{
|
{
|
||||||
PIXEL_POSITION pos;
|
PIXEL_POSITION pos;
|
||||||
|
|||||||
@@ -494,6 +494,8 @@ void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PortAttrLockSend(this,pItem,Cell.window_type,Cell.cell);
|
||||||
|
if(pItem)PortItemExtraSend(this,pItem,Cell.window_type,Cell.cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
LPITEM CHARACTER::GetWear(BYTE bCell) const
|
LPITEM CHARACTER::GetWear(BYTE bCell) const
|
||||||
|
|||||||
@@ -15,12 +15,15 @@ ACMD(do_setpickupmode);
|
|||||||
ACMD(do_track_window);
|
ACMD(do_track_window);
|
||||||
ACMD(do_channel_list);
|
ACMD(do_channel_list);
|
||||||
ACMD(do_attr_lock_info);
|
ACMD(do_attr_lock_info);
|
||||||
|
ACMD(do_attr_lock_sync);
|
||||||
ACMD(do_open_shop);
|
ACMD(do_open_shop);
|
||||||
ACMD(do_port_chest);
|
ACMD(do_port_chest);
|
||||||
ACMD(do_chest_drop);
|
ACMD(do_chest_drop);
|
||||||
ACMD(do_chestdrop);
|
ACMD(do_chestdrop);
|
||||||
ACMD(do_port_vip);
|
ACMD(do_port_vip);
|
||||||
ACMD(do_port_bp);
|
ACMD(do_port_bp);
|
||||||
|
ACMD(do_battle_pass);
|
||||||
|
ACMD(do_event_manager);
|
||||||
ACMD(do_user_horse_ride);
|
ACMD(do_user_horse_ride);
|
||||||
ACMD(do_user_horse_back);
|
ACMD(do_user_horse_back);
|
||||||
ACMD(do_user_horse_feed);
|
ACMD(do_user_horse_feed);
|
||||||
@@ -291,9 +294,11 @@ ACMD (do_dragon_soul);
|
|||||||
ACMD (do_ds_list);
|
ACMD (do_ds_list);
|
||||||
ACMD (do_clear_affect);
|
ACMD (do_clear_affect);
|
||||||
|
|
||||||
|
ACMD(do_ishop);
|
||||||
struct command_info cmd_info[] =
|
struct command_info cmd_info[] =
|
||||||
{
|
{
|
||||||
{ "!RESERVED!", NULL, 0, POS_DEAD, GM_IMPLEMENTOR }, /* 반드시 이 것이 처음이어야 한다. */
|
{ "!RESERVED!", NULL, 0, POS_DEAD, GM_IMPLEMENTOR }, /* 반드시 이 것이 처음이어야 한다. */
|
||||||
|
{ "ishop", do_ishop, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "autohunt_pull", do_autohunt_pull, 0, POS_FIGHTING, GM_PLAYER },
|
{ "autohunt_pull", do_autohunt_pull, 0, POS_FIGHTING, GM_PLAYER },
|
||||||
{ "bio", do_port_biolog, 0, POS_DEAD, GM_PLAYER },
|
{ "bio", do_port_biolog, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "biolog", do_port_biolog, 0, POS_DEAD, GM_PLAYER },
|
{ "biolog", do_port_biolog, 0, POS_DEAD, GM_PLAYER },
|
||||||
@@ -615,13 +620,16 @@ struct command_info cmd_info[] =
|
|||||||
{ "channel_list",do_channel_list,0,POS_DEAD,GM_PLAYER },
|
{ "channel_list",do_channel_list,0,POS_DEAD,GM_PLAYER },
|
||||||
{ "move_channel",do_cmd,SCMD_CHANGE_CHANNEL,POS_DEAD,GM_PLAYER },
|
{ "move_channel",do_cmd,SCMD_CHANGE_CHANNEL,POS_DEAD,GM_PLAYER },
|
||||||
{ "attr_lock_info",do_attr_lock_info,0,POS_DEAD,GM_PLAYER },
|
{ "attr_lock_info",do_attr_lock_info,0,POS_DEAD,GM_PLAYER },
|
||||||
|
{ "attr_lock_sync",do_attr_lock_sync,0,POS_DEAD,GM_PLAYER },
|
||||||
{ "setpickupmode",do_setpickupmode,0,POS_DEAD,GM_PLAYER },
|
{ "setpickupmode",do_setpickupmode,0,POS_DEAD,GM_PLAYER },
|
||||||
{ "mt_pickup", do_port_pickup, 0, POS_DEAD, GM_PLAYER },
|
{ "mt_pickup", do_port_pickup, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "chest_drop", do_chest_drop, 0, POS_DEAD, GM_PLAYER },
|
{ "chest_drop", do_chest_drop, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "chestdrop", do_chestdrop, 0, POS_DEAD, GM_PLAYER },
|
{ "chestdrop", do_chestdrop, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "mt_chest", do_port_chest, 0, POS_DEAD, GM_PLAYER },
|
{ "mt_chest", do_port_chest, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "mt_vip", do_port_vip, 0, POS_DEAD, GM_PLAYER },
|
{ "mt_vip", do_port_vip, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "mt_bp", do_port_bp, 0, POS_DEAD, GM_PLAYER },
|
{ "event_manager", do_event_manager, 0, POS_DEAD, GM_PLAYER },
|
||||||
|
{ "battle_pass", do_battle_pass, 0, POS_DEAD, GM_PLAYER },
|
||||||
|
{ "mt_bp", do_port_bp, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "\n", NULL, 0, POS_DEAD, GM_IMPLEMENTOR } /* 반드시 이 것이 마지막이어야 한다. */
|
{ "\n", NULL, 0, POS_DEAD, GM_IMPLEMENTOR } /* 반드시 이 것이 마지막이어야 한다. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
#include "ava2_chest_commands.h"
|
#include "ava2_chest_commands.h"
|
||||||
#include "port_premium.h"
|
#include "port_premium.h"
|
||||||
#include "port_battlepass_runtime.h"
|
#include "port_battlepass_runtime.h"
|
||||||
|
#include "ava2_native_queries.h"
|
||||||
|
|
||||||
ACMD(do_port_vip)
|
ACMD(do_port_vip)
|
||||||
{
|
{
|
||||||
@@ -60,6 +61,8 @@ ACMD(do_port_vip)
|
|||||||
PortVipCommand(ch, argument);
|
PortVipCommand(ch, argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMD(do_battle_pass) { PortBpNativeCommand(ch,argument); }
|
||||||
|
|
||||||
// PORT: battle pass (port_battlepass_runtime.h)
|
// PORT: battle pass (port_battlepass_runtime.h)
|
||||||
ACMD(do_port_bp)
|
ACMD(do_port_bp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "ava2_itemshop.h"
|
||||||
|
#include "../../common/ava2_itemshop.h"
|
||||||
#include "new_mob_timer.h"
|
#include "new_mob_timer.h"
|
||||||
#include "ava2_track.h"
|
#include "ava2_track.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
@@ -254,7 +256,7 @@ void CInputDB::PlayerCreateSuccess(LPDESC d, const char * data)
|
|||||||
d->Packet(&pack, sizeof(TPacketGCPlayerCreateSuccess));
|
d->Packet(&pack, sizeof(TPacketGCPlayerCreateSuccess));
|
||||||
|
|
||||||
// 기본 무기와 귀환부를 지급
|
// 기본 무기와 귀환부를 지급
|
||||||
TPlayerItem t;
|
TPlayerItem t={};
|
||||||
memset(&t, 0, sizeof(t));
|
memset(&t, 0, sizeof(t));
|
||||||
|
|
||||||
if (china_event_server)
|
if (china_event_server)
|
||||||
@@ -1571,6 +1573,7 @@ void CInputDB::ItemLoad(LPDESC d, const char * c_pData)
|
|||||||
item->SetSkipSave(true);
|
item->SetSkipSave(true);
|
||||||
item->SetSockets(p->alSockets);
|
item->SetSockets(p->alSockets);
|
||||||
item->SetAttributes(p->aAttr);
|
item->SetAttributes(p->aAttr);
|
||||||
|
item->SetPortExtra(p->extra);
|
||||||
|
|
||||||
if ((p->window == INVENTORY && ch->GetInventoryItem(p->pos)) ||
|
if ((p->window == INVENTORY && ch->GetInventoryItem(p->pos)) ||
|
||||||
(p->window == EQUIPMENT && ch->GetWear(p->pos)))
|
(p->window == EQUIPMENT && ch->GetWear(p->pos)))
|
||||||
@@ -2285,7 +2288,9 @@ int CInputDB::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
|||||||
SafeboxChangePasswordAnswer(DESC_MANAGER::instance().FindByHandle(m_dwHandle), c_pData);
|
SafeboxChangePasswordAnswer(DESC_MANAGER::instance().FindByHandle(m_dwHandle), c_pData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HEADER_DG_MALL_LOAD:
|
case 76:
|
||||||
|
Ava2ItemShopReply(m_dwHandle,c_pData);break;
|
||||||
|
case HEADER_DG_MALL_LOAD:
|
||||||
MallLoad(DESC_MANAGER::instance().FindByHandle(m_dwHandle), c_pData);
|
MallLoad(DESC_MANAGER::instance().FindByHandle(m_dwHandle), c_pData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2599,7 +2604,9 @@ bool CInputDB::Process(LPDESC d, const void * orig, int bytes, int & r_iBytesPro
|
|||||||
|
|
||||||
const char * pRealData = (c_pData + 9);
|
const char * pRealData = (c_pData + 9);
|
||||||
|
|
||||||
if (Analyze(d, bHeader, pRealData) < 0)
|
if (bHeader==76 && (iSize<int(sizeof(Ava2ShopReply))+1 || iSize>32775 || reinterpret_cast<const Ava2ShopReply*>(pRealData)->size!=iSize-sizeof(Ava2ShopReply))) { d->SetPhase(PHASE_CLOSE);return true; }
|
||||||
|
|
||||||
|
if (Analyze(d, bHeader, pRealData) < 0)
|
||||||
{
|
{
|
||||||
sys_err("in InputDB: UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d, DESC: %d",
|
sys_err("in InputDB: UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d, DESC: %d",
|
||||||
bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft, d->GetSocket());
|
bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft, d->GetSocket());
|
||||||
|
|||||||
@@ -559,6 +559,13 @@ typedef struct SPacketGTLogin
|
|||||||
|
|
||||||
void CInputLogin::Entergame(LPDESC d, const char * data)
|
void CInputLogin::Entergame(LPDESC d, const char * data)
|
||||||
{
|
{
|
||||||
|
// PORT: wear40 moves dragon-soul/belt cells; older clients must not enter this world.
|
||||||
|
const char* revision=strstr(d->GetClientVersion(),"mt");
|
||||||
|
if(!revision || atoi(revision+2)<20261022)
|
||||||
|
{
|
||||||
|
if(d->GetCharacter())d->GetCharacter()->ChatPacket(CHAT_TYPE_INFO,"Please update the client before entering the game.");
|
||||||
|
d->DelayedDisconnect(1);return;
|
||||||
|
}
|
||||||
LPCHARACTER ch;
|
LPCHARACTER ch;
|
||||||
|
|
||||||
if (!(ch = d->GetCharacter()))
|
if (!(ch = d->GetCharacter()))
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
// #include "XTrapManager.h"
|
// #include "XTrapManager.h"
|
||||||
#include "DragonSoul.h"
|
#include "DragonSoul.h"
|
||||||
#include "port_switchbot.h"
|
#include "port_switchbot.h"
|
||||||
|
#include "ava2_native_packets.h"
|
||||||
|
|
||||||
extern void SendShout(const char * szText, BYTE bEmpire);
|
extern void SendShout(const char * szText, BYTE bEmpire);
|
||||||
extern int g_nPortalLimitTime;
|
extern int g_nPortalLimitTime;
|
||||||
@@ -3405,6 +3406,8 @@ int CInputMain::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
|||||||
Sash(ch, c_pData);
|
Sash(ch, c_pData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HEADER_CG_AVA2_DROP:
|
||||||
|
PortNativeDrop(ch,*reinterpret_cast<const TPacketCGAva2Drop*>(c_pData));break;
|
||||||
case HEADER_CG_SWITCHBOT:
|
case HEADER_CG_SWITCHBOT:
|
||||||
if ((iExtraLen = Switchbot(ch, c_pData, m_iBufferLeft)) < 0)
|
if ((iExtraLen = Switchbot(ch, c_pData, m_iBufferLeft)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "port_attr_lock.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "char.h"
|
#include "char.h"
|
||||||
@@ -50,6 +51,7 @@ void CItem::Initialize()
|
|||||||
m_pProto = NULL;
|
m_pProto = NULL;
|
||||||
m_bExchanging = false;
|
m_bExchanging = false;
|
||||||
memset(&m_alSockets, 0, sizeof(m_alSockets));
|
memset(&m_alSockets, 0, sizeof(m_alSockets));
|
||||||
|
memset(&m_portExtra,0,sizeof(m_portExtra));
|
||||||
memset(&m_aAttr, 0, sizeof(m_aAttr));
|
memset(&m_aAttr, 0, sizeof(m_aAttr));
|
||||||
m_portAttrLock = 0;
|
m_portAttrLock = 0;
|
||||||
m_portAttrLockLoaded = false;
|
m_portAttrLockLoaded = false;
|
||||||
@@ -228,6 +230,8 @@ void CItem::UpdatePacket()
|
|||||||
|
|
||||||
sys_log(2, "UpdatePacket %s -> %s", GetName(), m_pOwner->GetName());
|
sys_log(2, "UpdatePacket %s -> %s", GetName(), m_pOwner->GetName());
|
||||||
m_pOwner->GetDesc()->Packet(&pack, sizeof(pack));
|
m_pOwner->GetDesc()->Packet(&pack, sizeof(pack));
|
||||||
|
PortAttrLockSend(m_pOwner,this,GetWindow(),GetCell());
|
||||||
|
SendPortExtra();
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD CItem::GetCount()
|
DWORD CItem::GetCount()
|
||||||
@@ -1152,7 +1156,8 @@ void CItem::SetSockets(const long * c_al)
|
|||||||
|
|
||||||
void CItem::SetSocket(int i, long v, bool bLog)
|
void CItem::SetSocket(int i, long v, bool bLog)
|
||||||
{
|
{
|
||||||
assert(i < ITEM_SOCKET_MAX_NUM);
|
if(i>=3 && i<8){m_portExtra.sockets[i-3]=v;UpdatePacket();Save();return;}
|
||||||
|
if(i<0 || i>=ITEM_SOCKET_MAX_NUM)return;
|
||||||
m_alSockets[i] = v;
|
m_alSockets[i] = v;
|
||||||
UpdatePacket();
|
UpdatePacket();
|
||||||
Save();
|
Save();
|
||||||
@@ -2248,3 +2253,29 @@ bool CItem::IsSameSpecialGroup(const LPITEM item) const
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
void PortItemExtraSend(CHARACTER* owner,CItem* item,BYTE window,WORD cell)
|
||||||
|
{
|
||||||
|
if(!owner || !item || !owner->GetDesc())return;
|
||||||
|
const char* version=strstr(owner->GetDesc()->GetClientVersion(),"mt");
|
||||||
|
if(!version || atoi(version+2)<20261022)return;
|
||||||
|
#pragma pack(push,1)
|
||||||
|
struct Packet { uint8_t header;uint32_t size;uint8_t op,window;uint16_t cell;uint32_t vnum,id;PortItemExtra extra; };
|
||||||
|
#pragma pack(pop)
|
||||||
|
Packet p={93,sizeof(Packet),10,window,cell,item->GetVnum(),item->GetID(),item->GetPortExtra()};
|
||||||
|
owner->GetDesc()->Packet(&p,sizeof(p));
|
||||||
|
}
|
||||||
|
void CItem::SendPortExtra(){PortItemExtraSend(GetOwner(),this,GetWindow(),GetCell());}
|
||||||
|
|
||||||
|
|
||||||
|
void CItem::SetPortAttribute(int index, BYTE type, short value)
|
||||||
|
{
|
||||||
|
if(index<0 || index>=15)return;
|
||||||
|
if(index<7){SetForceAttribute(index,type,value);return;}
|
||||||
|
m_portExtra.types[index-7]=type;m_portExtra.values[index-7]=value;
|
||||||
|
UpdatePacket();Save();
|
||||||
|
}
|
||||||
|
void CItem::SetNewName(const char* name)
|
||||||
|
{
|
||||||
|
strlcpy(m_portExtra.name,name ? name : "",sizeof(m_portExtra.name));
|
||||||
|
UpdatePacket();Save();
|
||||||
|
}
|
||||||
|
|||||||
@@ -108,10 +108,20 @@ class CItem : public CEntity
|
|||||||
|
|
||||||
bool CreateSocket(BYTE bSlot, BYTE bGold);
|
bool CreateSocket(BYTE bSlot, BYTE bGold);
|
||||||
const long * GetSockets() { return &m_alSockets[0]; }
|
const long * GetSockets() { return &m_alSockets[0]; }
|
||||||
long GetSocket(int i) { return m_alSockets[i]; }
|
long GetSocket(int i) { return i>=0 && i<3 ? m_alSockets[i] : i>=3 && i<8 ? m_portExtra.sockets[i-3] : 0; }
|
||||||
|
|
||||||
void SetSockets(const long * al);
|
void SetSockets(const long * al);
|
||||||
void SetSocket(int i, long v, bool bLog = true);
|
void SetSocket(int i, long v, bool bLog = true);
|
||||||
|
const PortItemExtra& GetPortExtra() const { return m_portExtra; }
|
||||||
|
void SetPortExtra(const PortItemExtra& extra) { m_portExtra=extra; m_portExtra.name[24]=0; }
|
||||||
|
void SendPortExtra();
|
||||||
|
// PORT: AVA2 growth pets use fifteen skill slots; normal items retain seven.
|
||||||
|
BYTE GetPortAttributeType(int i) const { return i>=0 && i<7 ? m_aAttr[i].bType : i>=7 && i<15 ? m_portExtra.types[i-7] : 0; }
|
||||||
|
short GetPortAttributeValue(int i) const { return i>=0 && i<7 ? m_aAttr[i].sValue : i>=7 && i<15 ? m_portExtra.values[i-7] : 0; }
|
||||||
|
void SetPortAttribute(int i, BYTE type, short value);
|
||||||
|
const char* GetNewName() const { return m_portExtra.name; }
|
||||||
|
void SetNewName(const char* name);
|
||||||
|
|
||||||
|
|
||||||
int GetSocketCount();
|
int GetSocketCount();
|
||||||
bool AddSocket();
|
bool AddSocket();
|
||||||
@@ -288,6 +298,7 @@ class CItem : public CEntity
|
|||||||
|
|
||||||
bool m_bExchanging; ///< 현재 교환중 상태
|
bool m_bExchanging; ///< 현재 교환중 상태
|
||||||
|
|
||||||
|
PortItemExtra m_portExtra{};
|
||||||
long m_alSockets[ITEM_SOCKET_MAX_NUM]; // 아이템 소캣
|
long m_alSockets[ITEM_SOCKET_MAX_NUM]; // 아이템 소캣
|
||||||
TPlayerItemAttribute m_aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
TPlayerItemAttribute m_aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||||
|
|
||||||
@@ -346,3 +357,6 @@ int GetNewRingAttrMaxValue(BYTE bApply); // port_rings.cpp, 0 = not in the ring
|
|||||||
int GetPendantAttrMaxValue(BYTE bApply); // port_pendant.cpp, 0 = not in the talisman pool
|
int GetPendantAttrMaxValue(BYTE bApply); // port_pendant.cpp, 0 = not in the talisman pool
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// PORT: supplementary item metadata for AVA2 systems.
|
||||||
|
void PortItemExtraSend(CHARACTER* owner,CItem* item,BYTE window,WORD cell);
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ void ITEM_MANAGER::SaveSingleItem(LPITEM item)
|
|||||||
|
|
||||||
sys_log(1, "ITEM_SAVE %s:%d in %s window %d", item->GetName(), item->GetID(), item->GetOwner()->GetName(), item->GetWindow());
|
sys_log(1, "ITEM_SAVE %s:%d in %s window %d", item->GetName(), item->GetID(), item->GetOwner()->GetName(), item->GetWindow());
|
||||||
|
|
||||||
TPlayerItem t;
|
TPlayerItem t={};
|
||||||
|
|
||||||
t.id = item->GetID();
|
t.id = item->GetID();
|
||||||
t.window = item->GetWindow();
|
t.window = item->GetWindow();
|
||||||
@@ -464,6 +464,7 @@ void ITEM_MANAGER::SaveSingleItem(LPITEM item)
|
|||||||
t.owner = (t.window == SAFEBOX || t.window == MALL) ? item->GetOwner()->GetDesc()->GetAccountTable().id : item->GetOwner()->GetPlayerID();
|
t.owner = (t.window == SAFEBOX || t.window == MALL) ? item->GetOwner()->GetDesc()->GetAccountTable().id : item->GetOwner()->GetPlayerID();
|
||||||
thecore_memcpy(t.alSockets, item->GetSockets(), sizeof(t.alSockets));
|
thecore_memcpy(t.alSockets, item->GetSockets(), sizeof(t.alSockets));
|
||||||
thecore_memcpy(t.aAttr, item->GetAttributes(), sizeof(t.aAttr));
|
thecore_memcpy(t.aAttr, item->GetAttributes(), sizeof(t.aAttr));
|
||||||
|
t.extra=item->GetPortExtra();
|
||||||
|
|
||||||
db_clientdesc->DBPacketHeader(HEADER_GD_ITEM_SAVE, 0, sizeof(TPlayerItem));
|
db_clientdesc->DBPacketHeader(HEADER_GD_ITEM_SAVE, 0, sizeof(TPlayerItem));
|
||||||
db_clientdesc->Packet(&t, sizeof(TPlayerItem));
|
db_clientdesc->Packet(&t, sizeof(TPlayerItem));
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ enum
|
|||||||
HEADER_CG_DRAGON_SOUL_REFINE = 205,
|
HEADER_CG_DRAGON_SOUL_REFINE = 205,
|
||||||
HEADER_CG_STATE_CHECKER = 206,
|
HEADER_CG_STATE_CHECKER = 206,
|
||||||
HEADER_CG_SASH = 211, // AVA2 sash
|
HEADER_CG_SASH = 211, // AVA2 sash
|
||||||
|
HEADER_CG_AVA2_DROP = 215,
|
||||||
HEADER_CG_ITEMS_PICKUP = 235, // PORT: AVA2
|
HEADER_CG_ITEMS_PICKUP = 235, // PORT: AVA2
|
||||||
HEADER_CG_SWITCHBOT = 171, // AVA2 switchbot (port_switchbot.cpp)
|
HEADER_CG_SWITCHBOT = 171, // AVA2 switchbot (port_switchbot.cpp)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "ava2_native_packets.h"
|
||||||
#include "../../common/stl.h"
|
#include "../../common/stl.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "packet_info.h"
|
#include "packet_info.h"
|
||||||
@@ -230,6 +231,7 @@ CPacketInfoCG::CPacketInfoCG()
|
|||||||
Set(HEADER_CG_STATE_CHECKER, sizeof(BYTE), "ServerStateCheck", false);
|
Set(HEADER_CG_STATE_CHECKER, sizeof(BYTE), "ServerStateCheck", false);
|
||||||
Set(HEADER_CG_SASH, sizeof(TPacketSash), "Sash", true);
|
Set(HEADER_CG_SASH, sizeof(TPacketSash), "Sash", true);
|
||||||
Set(HEADER_CG_ITEMS_PICKUP,sizeof(TPacketCGItemsPickUp),"ItemsPickup",true);
|
Set(HEADER_CG_ITEMS_PICKUP,sizeof(TPacketCGItemsPickUp),"ItemsPickup",true);
|
||||||
|
Set(HEADER_CG_AVA2_DROP,sizeof(TPacketCGAva2Drop),"Ava2Drop",true);
|
||||||
Set(HEADER_CG_SWITCHBOT, sizeof(TPacketCGSwitchbot), "Switchbot", true);
|
Set(HEADER_CG_SWITCHBOT, sizeof(TPacketCGSwitchbot), "Switchbot", true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,36 @@
|
|||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "port_attr_lock.h"
|
#include "port_attr_lock.h"
|
||||||
|
#include "port_switchbot.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
void PortAttrLockSend(CHARACTER* ch,CItem* item,unsigned window,unsigned cell) {
|
||||||
|
if (!ch || !ch->GetDesc() || !SwitchbotHelper::IsClientSupported(ch)) return;
|
||||||
|
if (window!=INVENTORY && window!=EQUIPMENT && window!=SWITCHBOT) return;
|
||||||
|
int mask=0;
|
||||||
|
if (item && PortAttrFilled(item)) {
|
||||||
|
mask=PortAttrLockEffective(PortAttrLockGet(item),PortAttrFilled(item),item->GetProto() && item->GetProto()->sAddonType);
|
||||||
|
if (!item->m_portAttrLockLoaded) mask=-1;
|
||||||
|
}
|
||||||
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"AttrLockItem %u %u %u %d",window,cell,item?item->GetVnum():0,mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requested only after GameWindow.Open: item loading precedes the game's command receiver.
|
||||||
|
ACMD(do_attr_lock_sync) {
|
||||||
|
if (!ch || !ch->IsPC() || !SwitchbotHelper::IsClientSupported(ch)) return;
|
||||||
|
const int now=get_global_time();
|
||||||
|
if (ch->GetProtectTime("attr_lock_sync")>now) return;
|
||||||
|
ch->SetProtectTime("attr_lock_sync",now+2);
|
||||||
|
for (unsigned cell=0;cell<INVENTORY_AND_EQUIP_SLOT_MAX;++cell) {
|
||||||
|
LPITEM item=ch->GetItem(TItemPos(INVENTORY,cell));
|
||||||
|
if (item && item->GetCell()==cell) PortAttrLockSend(ch,item,INVENTORY,cell);
|
||||||
|
}
|
||||||
|
for (unsigned cell=0;cell<SWITCHBOT_SLOT_COUNT_REAL;++cell) {
|
||||||
|
LPITEM item=ch->GetItem(TItemPos(SWITCHBOT,cell));
|
||||||
|
if (item) PortAttrLockSend(ch,item,SWITCHBOT,cell);
|
||||||
|
}
|
||||||
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"AttrLockSync");
|
||||||
|
}
|
||||||
|
|
||||||
void PortAttrLockBoot() {
|
void PortAttrLockBoot() {
|
||||||
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(
|
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(
|
||||||
@@ -34,6 +64,7 @@ bool PortAttrLockSet(CHARACTER* ch,CItem* item,unsigned mask) {
|
|||||||
item->m_portAttrLock=BYTE(mask);item->m_portAttrLockLoaded=true;
|
item->m_portAttrLock=BYTE(mask);item->m_portAttrLockLoaded=true;
|
||||||
char hint[16];snprintf(hint,sizeof(hint),"%u",mask);
|
char hint[16];snprintf(hint,sizeof(hint),"%u",mask);
|
||||||
if(ch)LogManager::instance().ItemLog(ch,item,"ATTR_LOCK",hint);
|
if(ch)LogManager::instance().ItemLog(ch,item,"ATTR_LOCK",hint);
|
||||||
|
if (item->GetOwner()) PortAttrLockSend(item->GetOwner(),item,item->GetWindow(),item->GetCell());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ inline const char* PortAttrLockToggle(unsigned mask,unsigned slot,unsigned fille
|
|||||||
class CItem;
|
class CItem;
|
||||||
class CHARACTER;
|
class CHARACTER;
|
||||||
void PortAttrLockBoot();
|
void PortAttrLockBoot();
|
||||||
|
// Sent after the matching owner item packet; classic item layouts stay unchanged.
|
||||||
|
void PortAttrLockSend(CHARACTER* ch,CItem* item,unsigned window,unsigned cell);
|
||||||
bool PortAttrLockSelect(CHARACTER* ch,CItem* material,unsigned index);
|
bool PortAttrLockSelect(CHARACTER* ch,CItem* material,unsigned index);
|
||||||
// Cached on the item after the first lookup. A failed lookup returns 0 and is retried next time.
|
// Cached on the item after the first lookup. A failed lookup returns 0 and is retried next time.
|
||||||
unsigned PortAttrLockGet(CItem* item);
|
unsigned PortAttrLockGet(CItem* item);
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ private:
|
|||||||
// progress and the stored value is capped at the target by the database itself.
|
// progress and the stored value is capped at the target by the database itself.
|
||||||
struct PortBpState {
|
struct PortBpState {
|
||||||
unsigned season=0,generation=0;
|
unsigned season=0,generation=0;
|
||||||
bool loaded=false,watching=false,wantInfo=false;
|
bool loaded=false,watching=false,wantInfo=false,nativeUI=false;
|
||||||
unsigned long long base[kPortBpSlots+1]={},delta[kPortBpSlots+1]={},inflight[kPortBpSlots+1]={};
|
unsigned long long base[kPortBpSlots+1]={},delta[kPortBpSlots+1]={},inflight[kPortBpSlots+1]={};
|
||||||
std::set<unsigned> claimed; // slots; 0 = final
|
std::set<unsigned> claimed; // slots; 0 = final
|
||||||
unsigned playtimeMark=0; // get_dword_time() up to which play time has been counted
|
unsigned playtimeMark=0; // get_dword_time() up to which play time has been counted
|
||||||
|
|||||||
@@ -37,8 +37,29 @@ inline void PortBpSendRewards(std::string& line,const std::vector<PortBpReward>&
|
|||||||
for(const auto& r:rewards)line+=" "+std::to_string(r.vnum)+" "+std::to_string(r.count);
|
for(const auto& r:rewards)line+=" "+std::to_string(r.vnum)+" "+std::to_string(r.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AVA2 uiBattlePassEx is ENABLE_BATTLE_PASS (/battle_pass), distinct from the older GC230 UI.
|
||||||
|
inline unsigned PortBpNativeType(unsigned type) {
|
||||||
|
static const unsigned map[]={0,10,1,20,13,2,14,9,18,17};
|
||||||
|
return type<sizeof(map)/sizeof(map[0])?map[type]:0;
|
||||||
|
}
|
||||||
|
inline std::string PortBpNativeRewards(const std::vector<PortBpReward>& rewards) {
|
||||||
|
std::string text;
|
||||||
|
for (const auto& r:rewards) {if(!text.empty())text+="#";text+=std::to_string(r.vnum)+"|"+std::to_string(r.count);}
|
||||||
|
return text.empty()?"Empty":text;
|
||||||
|
}
|
||||||
|
inline void PortBpAutoGrant(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state);
|
||||||
|
inline void PortBpSendNative(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state) {
|
||||||
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"BattlePassClear");
|
||||||
|
const time_t stamp=get_global_time();struct tm date;localtime_r(&stamp,&date);
|
||||||
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"BattlePassPeriod %u",unsigned((date.tm_year+1900)*100+date.tm_mon+1));
|
||||||
|
for (const auto& m:season.missions)
|
||||||
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"BattlePassAppendMission %u %s %llu %llu %u %u",PortBpNativeType(m.type),PortBpNativeRewards(m.rewards).c_str(),state.Value(m),m.target,m.sub,m.slot);
|
||||||
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"BattlePassSetStatus %u %lld %s",PortBpAccess(ch),std::max(0LL,(long long)season.end-get_global_time()),PortBpNativeRewards(season.final).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
inline void PortBpSendInfo(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state) {
|
inline void PortBpSendInfo(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state) {
|
||||||
state.watching=true;state.wantInfo=false;
|
state.watching=true;state.wantInfo=false;
|
||||||
|
if (state.nativeUI) {PortBpSendNative(ch,season,state);return;}
|
||||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 season %u %u %u %lld %u",season.id,season.start,season.end,(long long)get_global_time(),unsigned(season.missions.size()));
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 season %u %u %u %lld %u",season.id,season.start,season.end,(long long)get_global_time(),unsigned(season.missions.size()));
|
||||||
const time_t serverNow=time_t(get_global_time());struct tm date;localtime_r(&serverNow,&date);
|
const time_t serverNow=time_t(get_global_time());struct tm date;localtime_r(&serverNow,&date);
|
||||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 access %u %u",PortBpAccess(ch),unsigned(date.tm_mon+1));
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 access %u %u",PortBpAccess(ch),unsigned(date.tm_mon+1));
|
||||||
@@ -67,7 +88,7 @@ inline void PortBpFlush(DWORD pid,PortBpState& state,const PortBpSeason* season)
|
|||||||
if(!state.loaded)state.inflight[m.slot]+=d;
|
if(!state.loaded)state.inflight[m.slot]+=d;
|
||||||
}
|
}
|
||||||
if(values.empty())return;
|
if(values.empty())return;
|
||||||
DBManager::instance().Query("INSERT INTO player.mt_battlepass_progress (pid,season,slot,value,target) VALUES %s "
|
DBManager::instance().Query("INSERT INTO mt_battlepass_progress (pid,season,slot,value,target) VALUES %s "
|
||||||
"ON DUPLICATE KEY UPDATE value=LEAST(value+VALUES(value),VALUES(target)),target=VALUES(target)",values.c_str());
|
"ON DUPLICATE KEY UPDATE value=LEAST(value+VALUES(value),VALUES(target)),target=VALUES(target)",values.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +101,7 @@ inline void PortBpLoad(DWORD pid,PortBpState& state) {
|
|||||||
auto it=PortBpStates().find(pid);
|
auto it=PortBpStates().find(pid);
|
||||||
if(it==PortBpStates().end() || it->second.generation!=generation || it->second.season!=season)return;
|
if(it==PortBpStates().end() || it->second.generation!=generation || it->second.season!=season)return;
|
||||||
PortBpState& state=it->second;
|
PortBpState& state=it->second;
|
||||||
if(!msg->Get()){sys_err("PORT_BP: load failed pid %u season %u",pid,season);return;}
|
if(!msg || msg->uiSQLErrno || !msg->Get()){sys_err("PORT_BP: load failed pid %u season %u",pid,season);return;}
|
||||||
unsigned long long stored[kPortBpSlots+1]={};
|
unsigned long long stored[kPortBpSlots+1]={};
|
||||||
for(unsigned i=0;i<msg->Get()->uiNumRows;++i) {
|
for(unsigned i=0;i<msg->Get()->uiNumRows;++i) {
|
||||||
MYSQL_ROW row=mysql_fetch_row(msg->Get()->pSQLResult);
|
MYSQL_ROW row=mysql_fetch_row(msg->Get()->pSQLResult);
|
||||||
@@ -94,12 +115,13 @@ inline void PortBpLoad(DWORD pid,PortBpState& state) {
|
|||||||
LPCHARACTER ch=CHARACTER_MANAGER::instance().FindByPID(pid);
|
LPCHARACTER ch=CHARACTER_MANAGER::instance().FindByPID(pid);
|
||||||
const PortBpSeason* now=PortBpConfigFile().Active(get_global_time());
|
const PortBpSeason* now=PortBpConfigFile().Active(get_global_time());
|
||||||
if(!ch || !now || now->id!=season)return;
|
if(!ch || !now || now->id!=season)return;
|
||||||
|
PortBpAutoGrant(ch,*now,state);
|
||||||
// PortBpNotify held back the done notices of events counted before the load; send those now.
|
// PortBpNotify held back the done notices of events counted before the load; send those now.
|
||||||
for(const auto& m:now->missions)
|
for(const auto& m:now->missions)
|
||||||
if(stored[m.slot]<m.target && state.Done(m))ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 done %u",m.slot);
|
if(stored[m.slot]<m.target && state.Done(m))ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 done %u",m.slot);
|
||||||
if(state.wantInfo)PortBpSendInfo(ch,*now,state);
|
if(state.wantInfo)PortBpSendInfo(ch,*now,state);
|
||||||
},"SELECT 'p',slot,value FROM player.mt_battlepass_progress WHERE pid=%u AND season=%u "
|
},"SELECT 'p',slot,value FROM mt_battlepass_progress WHERE pid=%u AND season=%u "
|
||||||
"UNION ALL SELECT 'c',slot,0 FROM player.mt_battlepass_claim WHERE pid=%u AND season=%u",pid,season,pid,season);
|
"UNION ALL SELECT 'c',slot,0 FROM mt_battlepass_claim WHERE pid=%u AND season=%u",pid,season,pid,season);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const PortBpSeason* PortBpFindSeason(unsigned id) {
|
inline const PortBpSeason* PortBpFindSeason(unsigned id) {
|
||||||
@@ -135,8 +157,11 @@ inline PortBpState* PortBpSync(LPCHARACTER ch,const PortBpSeason*& season) {
|
|||||||
inline void PortBpNotify(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state,const std::vector<unsigned>& changed,const std::vector<unsigned>& finished) {
|
inline void PortBpNotify(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state,const std::vector<unsigned>& changed,const std::vector<unsigned>& finished) {
|
||||||
if(state.watching)
|
if(state.watching)
|
||||||
for(unsigned slot:changed)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 progress %u %llu",slot,state.Value(*season.Slot(slot)));
|
for(unsigned slot:changed)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 progress %u %llu",slot,state.Value(*season.Slot(slot)));
|
||||||
|
if (state.nativeUI && state.watching)
|
||||||
|
for(unsigned slot:changed)ch->ChatPacket(CHAT_TYPE_COMMAND,"BattlePassSetMission %u %llu",PortBpNativeType(season.Slot(slot)->type),state.Value(*season.Slot(slot)));
|
||||||
if(!state.loaded)return; // values are not known yet; the window shows them once it is loaded
|
if(!state.loaded)return; // values are not known yet; the window shows them once it is loaded
|
||||||
for(unsigned slot:finished)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 done %u",slot);
|
for(unsigned slot:finished)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 done %u",slot);
|
||||||
|
if (!finished.empty())PortBpAutoGrant(ch,season,state);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void PortBpAccruePlaytime(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state) {
|
inline void PortBpAccruePlaytime(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state) {
|
||||||
@@ -201,6 +226,7 @@ inline const char* PortBpStacks(const std::vector<PortBpReward>& rewards,std::ve
|
|||||||
// /mt_bp 1 claim SLOT. The claim row is written first and synchronously; only the request that inserted it hands
|
// /mt_bp 1 claim SLOT. The claim row is written first and synchronously; only the request that inserted it hands
|
||||||
// out the items, into cells checked free beforehand, so retries, double clicks and other cores cannot pay twice.
|
// out the items, into cells checked free beforehand, so retries, double clicks and other cores cannot pay twice.
|
||||||
inline void PortBpClaim(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state,unsigned slot) {
|
inline void PortBpClaim(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state,unsigned slot) {
|
||||||
|
if(ch->IsDead() || ch->IsWarping() || !ch->CanHandleItem() || ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen()){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error busy");return;}
|
||||||
if(PortBpAccess(ch)!=1){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error ticket");return;}
|
if(PortBpAccess(ch)!=1){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error ticket");return;}
|
||||||
if(const char* error=PortBpClaimError(season,state,slot)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error %s",error);return;}
|
if(const char* error=PortBpClaimError(season,state,slot)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error %s",error);return;}
|
||||||
const std::vector<PortBpReward>& rewards=slot?season.Slot(slot)->rewards:season.final;
|
const std::vector<PortBpReward>& rewards=slot?season.Slot(slot)->rewards:season.final;
|
||||||
@@ -216,8 +242,8 @@ inline void PortBpClaim(LPCHARACTER ch,const PortBpSeason& season,PortBpState& s
|
|||||||
if(!PortBpFit(free,INVENTORY_PAGE_SIZE,5,sizes,cells)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error space");return;}
|
if(!PortBpFit(free,INVENTORY_PAGE_SIZE,5,sizes,cells)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error space");return;}
|
||||||
const DWORD pid=ch->GetPlayerID();
|
const DWORD pid=ch->GetPlayerID();
|
||||||
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(
|
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(
|
||||||
"INSERT IGNORE INTO player.mt_battlepass_claim (pid,season,slot,claimed_at) VALUES (%u,%u,%u,%lld)",pid,season.id,slot,(long long)get_global_time()));
|
"INSERT IGNORE INTO mt_battlepass_claim (pid,season,slot,claimed_at) VALUES (%u,%u,%u,%lld)",pid,season.id,slot,(long long)get_global_time()));
|
||||||
if(!msg || !msg->Get()){sys_err("PORT_BP: claim insert failed pid %u season %u slot %u",pid,season.id,slot);ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error db");return;}
|
if(!msg || msg->uiSQLErrno || !msg->Get()){sys_err("PORT_BP: claim insert failed pid %u season %u slot %u",pid,season.id,slot);ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error db");return;}
|
||||||
state.claimed.insert(slot);
|
state.claimed.insert(slot);
|
||||||
if(msg->Get()->uiAffectedRows!=1){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error claimed");return;}
|
if(msg->Get()->uiAffectedRows!=1){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error claimed");return;}
|
||||||
const std::string hint=std::to_string(season.id)+" "+std::to_string(slot);
|
const std::string hint=std::to_string(season.id)+" "+std::to_string(slot);
|
||||||
@@ -234,6 +260,18 @@ inline void PortBpClaim(LPCHARACTER ch,const PortBpSeason& season,PortBpState& s
|
|||||||
ch->Save();
|
ch->Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AVA2 grants mission rewards on completion. Existing unique claim rows are retained as the
|
||||||
|
// migration/idempotency boundary; full bags keep the mission claim pending for the next open.
|
||||||
|
inline void PortBpAutoGrant(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state) {
|
||||||
|
static std::set<DWORD> granting;
|
||||||
|
const DWORD pid=ch->GetPlayerID();
|
||||||
|
if (!state.nativeUI || !state.loaded || state.season!=season.id || PortBpAccess(ch)!=1 || granting.count(pid))return;
|
||||||
|
granting.insert(pid);
|
||||||
|
for (const auto& m:season.missions)
|
||||||
|
if (state.Done(m) && !state.claimed.count(m.slot))PortBpClaim(ch,season,state,m.slot);
|
||||||
|
granting.erase(pid);
|
||||||
|
}
|
||||||
|
|
||||||
// Explicit confirmation comes from the client; all identity, month, eligibility
|
// Explicit confirmation comes from the client; all identity, month, eligibility
|
||||||
// and consumption checks are authoritative here. Never turn an arbitrary quest
|
// and consumption checks are authoritative here. Never turn an arbitrary quest
|
||||||
// item into a ticket just because its value[0] happens to match the month.
|
// item into a ticket just because its value[0] happens to match the month.
|
||||||
@@ -253,8 +291,8 @@ inline void PortBpActivate(LPCHARACTER ch,const PortBpSeason& season,PortBpState
|
|||||||
// A free-pass installation may have old progress. Activation starts fresh,
|
// A free-pass installation may have old progress. Activation starts fresh,
|
||||||
// as clear_old_battlepass() does in the AVA2 quest. The ordered connection
|
// as clear_old_battlepass() does in the AVA2 quest. The ordered connection
|
||||||
// runs the deletes before the new load, including across a quick reconnect.
|
// runs the deletes before the new load, including across a quick reconnect.
|
||||||
DBManager::instance().Query("DELETE FROM player.mt_battlepass_progress WHERE pid=%u AND season=%u",ch->GetPlayerID(),season.id);
|
DBManager::instance().Query("DELETE FROM mt_battlepass_progress WHERE pid=%u AND season=%u",ch->GetPlayerID(),season.id);
|
||||||
DBManager::instance().Query("DELETE FROM player.mt_battlepass_claim WHERE pid=%u AND season=%u",ch->GetPlayerID(),season.id);
|
DBManager::instance().Query("DELETE FROM mt_battlepass_claim WHERE pid=%u AND season=%u",ch->GetPlayerID(),season.id);
|
||||||
state.Reset(season.id);state.playtimeMark=get_dword_time();state.wantInfo=true;
|
state.Reset(season.id);state.playtimeMark=get_dword_time();state.wantInfo=true;
|
||||||
ch->SetQuestFlag("mt_bp.ticket_period",(date.tm_year+1900)*100+date.tm_mon+1);
|
ch->SetQuestFlag("mt_bp.ticket_period",(date.tm_year+1900)*100+date.tm_mon+1);
|
||||||
ch->SetQuestFlag("mt_bp.ticket_status",1);
|
ch->SetQuestFlag("mt_bp.ticket_status",1);
|
||||||
@@ -289,4 +327,24 @@ inline void PortBpCommand(LPCHARACTER ch,const char* argument) {
|
|||||||
PortBpClaim(ch,*season,*state,unsigned(atoi(args[2].c_str())));
|
PortBpClaim(ch,*season,*state,unsigned(atoi(args[2].c_str())));
|
||||||
if(state->loaded)PortBpSendInfo(ch,*season,*state);
|
if(state->loaded)PortBpSendInfo(ch,*season,*state);
|
||||||
}
|
}
|
||||||
|
inline void PortBpNativeCommand(LPCHARACTER ch,const char* argument) {
|
||||||
|
if(!ch || !ch->IsPC() || !ch->GetDesc())return;
|
||||||
|
std::istringstream input(argument);std::string action,cell,vnum,extra;
|
||||||
|
if(!(input>>action))return;
|
||||||
|
const PortBpSeason* season=nullptr;PortBpState* state=PortBpSync(ch,season);
|
||||||
|
if(state)state->nativeUI=true;
|
||||||
|
if (state && state->lastCommand && get_dword_time()-state->lastCommand<kPortBpGapMs)return;
|
||||||
|
if (action=="info" && !(input>>extra)) {
|
||||||
|
if(state && state->loaded)PortBpAutoGrant(ch,*season,*state);
|
||||||
|
if(!state){ch->ChatPacket(CHAT_TYPE_COMMAND,"BattlePassClear");ch->ChatPacket(CHAT_TYPE_COMMAND,"BattlePassSetStatus 0 0 Empty");return;}
|
||||||
|
PortBpCommand(ch,"1 info");
|
||||||
|
} else if (action=="reward" && !(input>>extra)) {
|
||||||
|
if(!state)return;
|
||||||
|
PortBpAutoGrant(ch,*season,*state);
|
||||||
|
for (const auto& m:season->missions)if(!state->claimed.count(m.slot)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error incomplete");return;}
|
||||||
|
PortBpCommand(ch,"1 claim 0");
|
||||||
|
} else if (action=="activate" && (input>>cell>>vnum) && !(input>>extra)) {
|
||||||
|
PortBpCommand(ch,("1 activate "+cell+" "+vnum).c_str());
|
||||||
|
} else if (action=="close" && !(input>>extra) && state)state->watching=false;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
// - The attribute list has two pseudo sets after ATTRIBUTE_SET_MAX_NUM: 8 = rings (port_rings.cpp) and
|
// - The attribute list has two pseudo sets after ATTRIBUTE_SET_MAX_NUM: 8 = rings (port_rings.cpp) and
|
||||||
// 9 = talismans (port_pendant.cpp), whose pools are not in item_attr.
|
// 9 = talismans (port_pendant.cpp), whose pools are not in item_attr.
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "port_attr_lock.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "port_switchbot.h"
|
#include "port_switchbot.h"
|
||||||
#include "desc.h"
|
#include "desc.h"
|
||||||
@@ -474,6 +475,7 @@ void CSwitchbot::SendItemUpdate(LPCHARACTER ch, BYTE slot, LPITEM item)
|
|||||||
tmp_buf.write(&pack, sizeof(pack));
|
tmp_buf.write(&pack, sizeof(pack));
|
||||||
tmp_buf.write(&update, sizeof(update));
|
tmp_buf.write(&update, sizeof(update));
|
||||||
desc->Packet(tmp_buf.read_peek(), tmp_buf.size());
|
desc->Packet(tmp_buf.read_peek(), tmp_buf.size());
|
||||||
|
PortAttrLockSend(ch,item,SWITCHBOT,slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSwitchbotManager::~CSwitchbotManager()
|
CSwitchbotManager::~CSwitchbotManager()
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ bool CSafebox::Add(DWORD dwPos, LPITEM pkItem)
|
|||||||
thecore_memcpy(pack.aAttr, pkItem->GetAttributes(), sizeof(pack.aAttr));
|
thecore_memcpy(pack.aAttr, pkItem->GetAttributes(), sizeof(pack.aAttr));
|
||||||
|
|
||||||
m_pkChrOwner->GetDesc()->Packet(&pack, sizeof(pack));
|
m_pkChrOwner->GetDesc()->Packet(&pack, sizeof(pack));
|
||||||
|
PortItemExtraSend(m_pkChrOwner,pkItem,m_bWindowMode,dwPos);
|
||||||
sys_log(1, "SAFEBOX: ADD %s %s count %d", m_pkChrOwner->GetName(), pkItem->GetName(), pkItem->GetCount());
|
sys_log(1, "SAFEBOX: ADD %s %s count %d", m_pkChrOwner->GetName(), pkItem->GetName(), pkItem->GetCount());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Compile the owner snapshot sender, including client/window gates and failed DB reads."""
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess,tempfile
|
||||||
|
root=Path(__file__).resolve().parents[2]/'src/server/game/src'
|
||||||
|
s=(root/'port_attr_lock.cpp').read_text();s=s[s.index('void PortAttrLockSend('):s.index('\nvoid PortAttrLockBoot(')]
|
||||||
|
code=r'''
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
#define INVENTORY 1
|
||||||
|
#define EQUIPMENT 2
|
||||||
|
#define SWITCHBOT 7
|
||||||
|
#define CHAT_TYPE_COMMAND 1
|
||||||
|
#define ACMD(name) void name(CHARACTER* ch,const char* argument)
|
||||||
|
#define INVENTORY_AND_EQUIP_SLOT_MAX 300
|
||||||
|
#define SWITCHBOT_SLOT_COUNT_REAL 5
|
||||||
|
using LPITEM=struct CItem*;
|
||||||
|
struct TItemPos {unsigned window,cell;TItemPos(unsigned w,unsigned c):window(w),cell(c){}};
|
||||||
|
int get_global_time(){return 100;}
|
||||||
|
struct Proto {int sAddonType=0;};
|
||||||
|
struct CItem {unsigned vnum=19,mask=8,filled=31;bool m_portAttrLockLoaded=true;Proto proto;
|
||||||
|
unsigned GetCell(){return 159;}unsigned GetVnum(){return vnum;}unsigned GetAttributeType(unsigned i){return (filled>>i)&1;}Proto* GetProto(){return &proto;}};
|
||||||
|
struct CHARACTER {bool desc=true,supported=true;std::string reply;int protect=0,calls=0;CItem* item=nullptr;
|
||||||
|
bool IsPC(){return true;}int GetProtectTime(const char*){return protect;}void SetProtectTime(const char*,int n){protect=n;}
|
||||||
|
CItem* GetItem(TItemPos pos){return (pos.window==INVENTORY && (pos.cell==159 || pos.cell==160)) || (pos.window==SWITCHBOT && pos.cell==0)?item:nullptr;}
|
||||||
|
void* GetDesc(){return desc?this:nullptr;}
|
||||||
|
void ChatPacket(int,const char* fmt,...){++calls;char b[512];va_list a;va_start(a,fmt);vsnprintf(b,sizeof(b),fmt,a);va_end(a);reply=b;}};
|
||||||
|
#include "port_attr_lock.h"
|
||||||
|
unsigned PortAttrLockGet(CItem* item){return item->mask;}
|
||||||
|
struct SwitchbotHelper {static bool IsClientSupported(CHARACTER* ch){return ch->supported;}};
|
||||||
|
'''+s+r'''
|
||||||
|
int main(){
|
||||||
|
CHARACTER ch;CItem item;
|
||||||
|
PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 19 8");
|
||||||
|
PortAttrLockSend(&ch,&item,EQUIPMENT,229);assert(ch.reply=="AttrLockItem 2 229 19 8");
|
||||||
|
PortAttrLockSend(&ch,&item,SWITCHBOT,0);assert(ch.reply=="AttrLockItem 7 0 19 8");
|
||||||
|
PortAttrLockSend(&ch,nullptr,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 0 0");
|
||||||
|
item.mask=1;item.proto.sAddonType=1;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 19 3");
|
||||||
|
item.m_portAttrLockLoaded=false;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 19 -1");
|
||||||
|
item.filled=0;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 19 0");
|
||||||
|
ch.reply.clear();PortAttrLockSend(&ch,&item,3,0);assert(ch.reply.empty());
|
||||||
|
ch.supported=false;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply.empty());
|
||||||
|
ch.supported=true;ch.desc=false;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply.empty());
|
||||||
|
PortAttrLockSend(nullptr,&item,INVENTORY,159);
|
||||||
|
ch.desc=true;ch.item=&item;ch.calls=0;do_attr_lock_sync(&ch,"");assert(ch.calls==3 && ch.protect==102 && ch.reply=="AttrLockSync");
|
||||||
|
do_attr_lock_sync(&ch,"");assert(ch.calls==3); // repeated requests throttled, footprint cell 160 not duplicated
|
||||||
|
ch.protect=0;ch.supported=false;do_attr_lock_sync(&ch,"");assert(ch.calls==3);
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
with tempfile.TemporaryDirectory() as d:
|
||||||
|
p=Path(d);(p/'test.cpp').write_text(code)
|
||||||
|
subprocess.run(['c++','-std=c++17','-I'+str(root),str(p/'test.cpp'),'-o',str(p/'test')],check=True)
|
||||||
|
subprocess.run([str(p/'test')],check=True)
|
||||||
|
print('Attr lock owner snapshots: version/window gates, removal, addon pair and SQL failure: PASS')
|
||||||
@@ -71,7 +71,7 @@ static bool dbDown=false;
|
|||||||
using MYSQL_ROW=char**;
|
using MYSQL_ROW=char**;
|
||||||
struct Result{std::vector<std::vector<std::string>> rows;size_t next=0;std::vector<char*> cells;};
|
struct Result{std::vector<std::vector<std::string>> rows;size_t next=0;std::vector<char*> cells;};
|
||||||
struct SQLResult{unsigned uiNumRows=0,uiAffectedRows=0;Result* pSQLResult=nullptr;};
|
struct SQLResult{unsigned uiNumRows=0,uiAffectedRows=0;Result* pSQLResult=nullptr;};
|
||||||
struct SQLMsg{SQLResult result;Result data;bool ok=true;SQLResult* Get(){return ok?&result:nullptr;}};
|
struct SQLMsg{unsigned uiSQLErrno=0;SQLResult result;Result data;bool ok=true;SQLResult* Get(){return ok?&result:nullptr;}};
|
||||||
MYSQL_ROW mysql_fetch_row(Result* r){
|
MYSQL_ROW mysql_fetch_row(Result* r){
|
||||||
if(r->next>=r->rows.size())return nullptr;auto& row=r->rows[r->next++];r->cells.clear();
|
if(r->next>=r->rows.size())return nullptr;auto& row=r->rows[r->next++];r->cells.clear();
|
||||||
for(auto& c:row)r->cells.push_back(&c[0]);return r->cells.data();}
|
for(auto& c:row)r->cells.push_back(&c[0]);return r->cells.data();}
|
||||||
@@ -81,13 +81,13 @@ struct DBManager{
|
|||||||
static DBManager& instance(){static DBManager m;return m;}
|
static DBManager& instance(){static DBManager m;return m;}
|
||||||
void Query(const char* f,...){va_list a;va_start(a,f);std::string q=format(f,a);va_end(a);queries.push_back(q);
|
void Query(const char* f,...){va_list a;va_start(a,f);std::string q=format(f,a);va_end(a);queries.push_back(q);
|
||||||
queue.push_back([q]{
|
queue.push_back([q]{
|
||||||
if(q.rfind("DELETE FROM player.mt_battlepass_",0)==0){
|
if(q.rfind("DELETE FROM mt_battlepass_",0)==0){
|
||||||
unsigned p,s;const bool isProgress=q.find("_progress")!=std::string::npos;
|
unsigned p,s;const bool isProgress=q.find("_progress")!=std::string::npos;
|
||||||
sscanf(q.c_str()+std::string(isProgress?"DELETE FROM player.mt_battlepass_progress WHERE pid=":"DELETE FROM player.mt_battlepass_claim WHERE pid=").size(),"%u AND season=%u",&p,&s);
|
sscanf(q.c_str()+std::string(isProgress?"DELETE FROM mt_battlepass_progress WHERE pid=":"DELETE FROM mt_battlepass_claim WHERE pid=").size(),"%u AND season=%u",&p,&s);
|
||||||
if(isProgress){for(auto it=progress.begin();it!=progress.end();)if(std::get<0>(it->first)==p&&std::get<1>(it->first)==s)it=progress.erase(it);else ++it;}
|
if(isProgress){for(auto it=progress.begin();it!=progress.end();)if(std::get<0>(it->first)==p&&std::get<1>(it->first)==s)it=progress.erase(it);else ++it;}
|
||||||
else {for(auto it=claims.begin();it!=claims.end();)if(std::get<0>(*it)==p&&std::get<1>(*it)==s)it=claims.erase(it);else ++it;}return;
|
else {for(auto it=claims.begin();it!=claims.end();)if(std::get<0>(*it)==p&&std::get<1>(*it)==s)it=claims.erase(it);else ++it;}return;
|
||||||
}
|
}
|
||||||
assert(q.rfind("INSERT INTO player.mt_battlepass_progress (pid,season,slot,value,target) VALUES (",0)==0);
|
assert(q.rfind("INSERT INTO mt_battlepass_progress (pid,season,slot,value,target) VALUES (",0)==0);
|
||||||
assert(q.find("ON DUPLICATE KEY UPDATE value=LEAST(value+VALUES(value),VALUES(target)),target=VALUES(target)")!=std::string::npos);
|
assert(q.find("ON DUPLICATE KEY UPDATE value=LEAST(value+VALUES(value),VALUES(target)),target=VALUES(target)")!=std::string::npos);
|
||||||
const char* p=q.c_str()+q.find("VALUES (")+7;unsigned pid,season,slot;unsigned long long v,t;int n;
|
const char* p=q.c_str()+q.find("VALUES (")+7;unsigned pid,season,slot;unsigned long long v,t;int n;
|
||||||
while(sscanf(p,"(%u,%u,%u,%llu,%llu)%n",&pid,&season,&slot,&v,&t,&n)==5){
|
while(sscanf(p,"(%u,%u,%u,%llu,%llu)%n",&pid,&season,&slot,&v,&t,&n)==5){
|
||||||
@@ -95,8 +95,8 @@ struct DBManager{
|
|||||||
});}
|
});}
|
||||||
template<class F> void FuncQuery(F f,const char* fmt,...){va_list a;va_start(a,fmt);std::string q=format(fmt,a);va_end(a);queries.push_back(q);++selects;
|
template<class F> void FuncQuery(F f,const char* fmt,...){va_list a;va_start(a,fmt);std::string q=format(fmt,a);va_end(a);queries.push_back(q);++selects;
|
||||||
queue.push_back([f,q]{unsigned pid,season,pid2,season2;
|
queue.push_back([f,q]{unsigned pid,season,pid2,season2;
|
||||||
assert(sscanf(q.c_str(),"SELECT 'p',slot,value FROM player.mt_battlepass_progress WHERE pid=%u AND season=%u "
|
assert(sscanf(q.c_str(),"SELECT 'p',slot,value FROM mt_battlepass_progress WHERE pid=%u AND season=%u "
|
||||||
"UNION ALL SELECT 'c',slot,0 FROM player.mt_battlepass_claim WHERE pid=%u AND season=%u",&pid,&season,&pid2,&season2)==4);
|
"UNION ALL SELECT 'c',slot,0 FROM mt_battlepass_claim WHERE pid=%u AND season=%u",&pid,&season,&pid2,&season2)==4);
|
||||||
assert(pid==pid2 && season==season2);
|
assert(pid==pid2 && season==season2);
|
||||||
SQLMsg m;m.ok=!dbDown;m.result.pSQLResult=&m.data;
|
SQLMsg m;m.ok=!dbDown;m.result.pSQLResult=&m.data;
|
||||||
for(auto& e:progress)if(std::get<0>(e.first)==pid && std::get<1>(e.first)==season)
|
for(auto& e:progress)if(std::get<0>(e.first)==pid && std::get<1>(e.first)==season)
|
||||||
@@ -105,7 +105,7 @@ struct DBManager{
|
|||||||
m.result.uiNumRows=unsigned(m.data.rows.size());f(&m);});}
|
m.result.uiNumRows=unsigned(m.data.rows.size());f(&m);});}
|
||||||
SQLMsg* DirectQuery(const char* f,...){va_list a;va_start(a,f);std::string q=format(f,a);va_end(a);queries.push_back(q);
|
SQLMsg* DirectQuery(const char* f,...){va_list a;va_start(a,f);std::string q=format(f,a);va_end(a);queries.push_back(q);
|
||||||
SQLMsg* m=new SQLMsg;m->ok=!dbDown;unsigned pid,season,slot;long long at;
|
SQLMsg* m=new SQLMsg;m->ok=!dbDown;unsigned pid,season,slot;long long at;
|
||||||
assert(sscanf(q.c_str(),"INSERT IGNORE INTO player.mt_battlepass_claim (pid,season,slot,claimed_at) VALUES (%u,%u,%u,%lld)",&pid,&season,&slot,&at)==4 && at==now);
|
assert(sscanf(q.c_str(),"INSERT IGNORE INTO mt_battlepass_claim (pid,season,slot,claimed_at) VALUES (%u,%u,%u,%lld)",&pid,&season,&slot,&at)==4 && at==now);
|
||||||
if(m->ok)m->result.uiAffectedRows=claims.insert(std::make_tuple(pid,season,slot)).second?1:0;
|
if(m->ok)m->result.uiAffectedRows=claims.insert(std::make_tuple(pid,season,slot)).second?1:0;
|
||||||
return m;}
|
return m;}
|
||||||
void Run(){while(!queue.empty()){auto job=queue.front();queue.pop_front();job();}}
|
void Run(){while(!queue.empty()){auto job=queue.front();queue.pop_front();job();}}
|
||||||
@@ -284,6 +284,24 @@ int main(int argc,char** argv){
|
|||||||
tick();PortBpCommand(locked,"1 activate 3 25159");assert(Last(locked)=="MTBP1 error activated");
|
tick();PortBpCommand(locked,"1 activate 3 25159");assert(Last(locked)=="MTBP1 error activated");
|
||||||
Kill(locked,101);assert(PortBpStates()[20].delta[1]==1);
|
Kill(locked,101);assert(PortBpStates()[20].delta[1]==1);
|
||||||
locked->SetQuestFlag("mt_bp.ticket_period",202510);assert(PortBpAccess(locked)==0);
|
locked->SetQuestFlag("mt_bp.ticket_period",202510);assert(PortBpAccess(locked)==0);
|
||||||
|
|
||||||
|
// Native mode reuses existing progress/claims and automatically grants each mission once.
|
||||||
|
WriteConfig("MTBATTLEPASS 1\nseason 99 "+std::to_string(now-10)+" "+std::to_string(now+10000)+"\nmission 1 1 0 1 25041 1\nfinal 27992 1\n");tick(5001);
|
||||||
|
auto native=new CHARACTER;native->pid=31;online[31]=native;
|
||||||
|
PortBpNativeCommand(native,"info");db.Run();
|
||||||
|
assert(Said(native,"BattlePassClear") && Said(native,"BattlePassAppendMission 10 25041|1 0 1 0 1"));
|
||||||
|
Kill(native,101);assert(PortBpStates()[31].claimed.count(1) && claims.count(std::make_tuple(31u,99u,1u)));
|
||||||
|
auto paid=native->bag.size();tick();PortBpNativeCommand(native,"info");db.Run();assert(native->bag.size()==paid);
|
||||||
|
tick();PortBpNativeCommand(native,"reward");assert(PortBpStates()[31].claimed.count(0) && PortBpAccess(native)==2);
|
||||||
|
paid=native->bag.size();tick();PortBpNativeCommand(native,"reward");assert(native->bag.size()==paid);
|
||||||
|
auto migrated=new CHARACTER;migrated->pid=32;online[32]=migrated;
|
||||||
|
progress[std::make_tuple(32u,99u,1u)]={1,1};claims.insert(std::make_tuple(32u,99u,1u));
|
||||||
|
PortBpNativeCommand(migrated,"info");db.Run();assert(migrated->bag.empty() && PortBpStates()[32].claimed.count(1));
|
||||||
|
auto full=new CHARACTER;full->pid=33;online[33]=full;std::fill(full->used.begin(),full->used.end(),true);
|
||||||
|
progress[std::make_tuple(33u,99u,1u)]={1,1};PortBpNativeCommand(full,"info");db.Run();assert(!PortBpStates()[33].claimed.count(1));
|
||||||
|
std::fill(full->used.begin(),full->used.end(),false);tick();PortBpNativeCommand(full,"info");assert(PortBpStates()[33].claimed.count(1) && full->bag.size()==1);
|
||||||
|
for(const auto& sql:db.queries)assert(sql.find("player.")==std::string::npos);
|
||||||
|
|
||||||
// --- the file is removed: no season, nothing counted
|
// --- the file is removed: no season, nothing counted
|
||||||
std::remove((basePath+"/port_battlepass.tsv").c_str());tick(5001);mark=b->messages.size();
|
std::remove((basePath+"/port_battlepass.tsv").c_str());tick(5001);mark=b->messages.size();
|
||||||
PortBpCommand(b,"1 info");assert(Last(b)=="MTBP1 none");
|
PortBpCommand(b,"1 info");assert(Last(b)=="MTBP1 none");
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
"""Exercise paid item state round trips and inventory migration boundaries."""
|
||||||
|
import importlib.util
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
spec = importlib.util.spec_from_file_location(
|
||||||
|
'extended_items', ROOT/'tools/ava2-itemshop/migrate_extended_items.py')
|
||||||
|
migration = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(migration)
|
||||||
|
|
||||||
|
|
||||||
|
class ExtendedItems(unittest.TestCase):
|
||||||
|
def test_quickslot_boundaries(self):
|
||||||
|
positions = [0, 224, 225, 256, 257, 268, 269, 286, 287, 302, 303, 65535]
|
||||||
|
source = b''.join(bytes([1])+p.to_bytes(2, 'little') for p in positions)
|
||||||
|
# Skill and emotion quickslots may contain the same numeric positions.
|
||||||
|
source += bytes([2, 1, 1, 3, 31, 1]) + bytes(108-len(source)-6)
|
||||||
|
result = migration.quickslots(source)
|
||||||
|
expected = [0, 224, 225, 256, 265, 276, 269, 286, 295, 310, 303, 65535]
|
||||||
|
self.assertEqual([int.from_bytes(result[i+1:i+3], 'little')
|
||||||
|
for i in range(0, 36, 3)], expected)
|
||||||
|
self.assertEqual(result[36:], source[36:])
|
||||||
|
self.assertEqual(migration.quickslots(b''), b'')
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
migration.quickslots(bytes(107))
|
||||||
|
|
||||||
|
def test_extra_round_trip_and_corruption(self):
|
||||||
|
source = r'''
|
||||||
|
#include "src/server/common/port_item_extra.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <limits>
|
||||||
|
int main() {
|
||||||
|
PortItemExtra source={},decoded={};
|
||||||
|
source.sockets[0]=std::numeric_limits<int32_t>::min();
|
||||||
|
source.sockets[4]=std::numeric_limits<int32_t>::max();
|
||||||
|
source.types[0]=99;source.types[7]=255;
|
||||||
|
source.values[0]=-32768;source.values[7]=32767;
|
||||||
|
std::memcpy(source.name,"abcdefghijklmnopqrstuvwx",24);
|
||||||
|
auto hex=PortItemExtraHex(source);
|
||||||
|
assert(hex.size()==138);
|
||||||
|
assert(PortItemExtraRead(hex.c_str(),decoded));
|
||||||
|
assert(!std::memcmp(&source,&decoded,sizeof(source)));
|
||||||
|
// Empty DB values are pre-migration items and must load as empty state.
|
||||||
|
assert(PortItemExtraRead("",decoded));
|
||||||
|
PortItemExtra zero={};assert(!std::memcmp(&zero,&decoded,sizeof(zero)));
|
||||||
|
assert(!PortItemExtraRead("00",decoded));
|
||||||
|
hex[137]='g';assert(!PortItemExtraRead(hex.c_str(),decoded));
|
||||||
|
assert(!std::memcmp(&zero,&decoded,sizeof(zero)));
|
||||||
|
hex=std::string(138,'f');assert(PortItemExtraRead(hex.c_str(),decoded));
|
||||||
|
assert(decoded.name[24]==0);
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
cpp, exe = Path(tmp)/'extra.cpp', Path(tmp)/'extra'
|
||||||
|
cpp.write_text(source)
|
||||||
|
subprocess.run(['c++', '-std=c++17', '-I'+str(ROOT), str(cpp), '-o', str(exe)], check=True)
|
||||||
|
subprocess.run([str(exe)], check=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Compile the production wire and total-price helper, including malformed bounds."""
|
||||||
|
import subprocess,tempfile,unittest
|
||||||
|
from pathlib import Path
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
class ItemShop(unittest.TestCase):
|
||||||
|
def test_native_wire_and_integer_quantity_discount(self):
|
||||||
|
source=r'''
|
||||||
|
#include "src/server/common/ava2_itemshop.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
int main(){
|
||||||
|
static_assert(sizeof(Ava2ShopRequest)==103,"request");
|
||||||
|
static_assert(sizeof(Ava2ShopProduct)==49,"native catalogue");
|
||||||
|
static_assert(sizeof(Ava2ShopLog)==90,"native log");
|
||||||
|
int64_t price=123;
|
||||||
|
assert(Ava2ShopTotal(99,2,25,price) && price==148);
|
||||||
|
assert(Ava2ShopTotal(1,1,99,price) && price==0);
|
||||||
|
assert(Ava2ShopTotal(1000000000000LL,20,0,price) && price==20000000000000LL);
|
||||||
|
assert(!Ava2ShopTotal(-1,1,0,price));assert(!Ava2ShopTotal(1000000000001LL,1,0,price));
|
||||||
|
assert(!Ava2ShopTotal(1,0,0,price));assert(!Ava2ShopTotal(1,21,0,price));assert(!Ava2ShopTotal(1,1,101,price));
|
||||||
|
Ava2ShopProduct p={};p.id=0x01020304;p.vnum=71084;p.price=99;p.discount=25;p.stock=-1;
|
||||||
|
const unsigned char* bytes=reinterpret_cast<const unsigned char*>(&p);
|
||||||
|
assert(bytes[0]==4 && bytes[3]==1 && bytes[20]==25 && bytes[45]==255);
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
with tempfile.TemporaryDirectory() as d:
|
||||||
|
p=Path(d);(p/'test.cpp').write_text(source)
|
||||||
|
subprocess.run(['c++','-std=c++17','-I'+str(ROOT),str(p/'test.cpp'),'-o',str(p/'test')],check=True);subprocess.run([str(p/'test')],check=True)
|
||||||
|
def test_sorted_prototype_index_points_to_the_matching_item(self):
|
||||||
|
source=(ROOT/'src/server/db/src/ClientManagerBoot.cpp').read_bytes().decode('latin1')
|
||||||
|
body=source[source.index('bool CClientManager::InitializeItemTable()'):source.index('bool CClientManager::InitializeSkillTable()')]
|
||||||
|
start=body.rindex('// END_OF_QUEST_ITEM_PROTO_DISABLE')
|
||||||
|
tail=body[start:body.rfind('return true;')+len('return true;')]
|
||||||
|
harness=r"""
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
|
#define sys_log(...) ((void)0)
|
||||||
|
#define itertype(c) decltype(c)::iterator
|
||||||
|
using namespace std;
|
||||||
|
using DWORD=unsigned;
|
||||||
|
struct TItemTable { DWORD dwVnum;unsigned bType; };
|
||||||
|
struct FCompareVnum { bool operator()(const TItemTable& a,const TItemTable& b)const {return a.dwVnum<b.dwVnum;} };
|
||||||
|
struct Database {
|
||||||
|
vector<TItemTable> m_vec_itemTable={{71084,3},{54051,3},{1,0},{71502,28}};
|
||||||
|
map<DWORD,TItemTable*> m_map_itemTableByVnum;
|
||||||
|
bool Build() { BODY }
|
||||||
|
};
|
||||||
|
int main(){ Database db;assert(db.Build());for(auto& row:db.m_map_itemTableByVnum)assert(row.first==row.second->dwVnum);assert(db.m_map_itemTableByVnum[54051]->bType==3);assert(db.m_map_itemTableByVnum[71502]->bType==28); }
|
||||||
|
""".replace('BODY',tail)
|
||||||
|
with tempfile.TemporaryDirectory() as d:
|
||||||
|
p=Path(d);(p/'test.cpp').write_text(harness)
|
||||||
|
subprocess.run(['c++','-std=c++17',str(p/'test.cpp'),'-o',str(p/'test')],check=True)
|
||||||
|
subprocess.run([str(p/'test')],check=True)
|
||||||
|
|
||||||
|
if __name__=='__main__':unittest.main()
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
"""Run native drop/calendar handlers against loaded-table fixtures and real schedule rules."""
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess,tempfile
|
||||||
|
ROOT=Path(__file__).resolve().parents[2];SRC=ROOT/'src/server/game/src'
|
||||||
|
code=r'''
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
|
#include <ctime>
|
||||||
|
#include <algorithm>
|
||||||
|
#include "port_calendar.h"
|
||||||
|
static int now=1792390000;int get_global_time(){return now;}unsigned g_bChannel=5;
|
||||||
|
size_t strlcpy(char* out,const char* in,size_t n){size_t len=strlen(in);if(n){memcpy(out,in,std::min(len,n-1));out[std::min(len,n-1)]=0;}return len;}
|
||||||
|
struct Desc {std::string version="1215955205mt20261019";std::vector<std::string> packets;const char* GetClientVersion(){return version.c_str();}void Packet(const void* p,size_t n){packets.emplace_back((const char*)p,n);}};
|
||||||
|
struct Character {Desc desc;std::map<std::string,int> protect;unsigned empire=1;std::vector<std::string> commands;Desc* GetDesc(){return &desc;}unsigned GetEmpire(){return empire;}int GetProtectTime(const char* key){return protect[key];}void SetProtectTime(const char* key,int value){protect[key]=value;}void ChatPacket(int,const char* text){commands.emplace_back(text);}};
|
||||||
|
using LPCHARACTER=Character*;
|
||||||
|
#define ACMD(name) void name(LPCHARACTER ch,const char* argument)
|
||||||
|
enum {CHAT_TYPE_COMMAND=5,ITEM_GIFTBOX=23,ITEM_TREASURE_BOX=17,WIKI_SINGLE=1,WIKI_INDEPENDENT=2};
|
||||||
|
struct Proto {unsigned dwVnum,dwRefinedVnum,bType;char szLocaleName[32]="item";};
|
||||||
|
struct Row {unsigned item,count,rule,total,weight;};
|
||||||
|
struct Manager {std::vector<Proto> tables;std::map<unsigned,std::vector<Row>> mobs,chests;static Manager& instance(){static Manager m;return m;}const Proto* GetTable(unsigned id){for(auto& t:tables)if(t.dwVnum==id)return &t;return nullptr;}const std::vector<Proto>& GetTable(){return tables;}std::vector<Row> PortWikiDrops(unsigned id){return mobs[id];}std::vector<Row> PortWikiChest(unsigned id){return chests[id];}};
|
||||||
|
using ITEM_MANAGER=Manager;
|
||||||
|
struct Mob {Proto m_table;};
|
||||||
|
struct CMobManager {std::map<unsigned,Mob*> mobs;static CMobManager& instance(){static CMobManager m;return m;}auto begin(){return mobs.begin();}auto end(){return mobs.end();}};
|
||||||
|
PortCalendar schedule;PortCalendar& PortCurrentEvents(){return schedule;}
|
||||||
|
struct TEMP_BUFFER {std::string bytes;void write(const void* p,size_t n){bytes.append((const char*)p,n);}const char* read_peek(){return bytes.data();}size_t size(){return bytes.size();}};
|
||||||
|
#include "ava2_native_queries.h"
|
||||||
|
int main(){
|
||||||
|
static_assert(sizeof(TPacketCGAva2Drop)==6,"");static_assert(sizeof(TPacketGCAva2Drop)==114,"");static_assert(sizeof(TPacketGCAva2Events)==5,"");static_assert(sizeof(TAva2Event)==81,"");
|
||||||
|
Character c;auto& m=Manager::instance();m.tables={{19,20,1},{20,0,1},{500,0,ITEM_GIFTBOX}};
|
||||||
|
Mob mob;CMobManager::instance().mobs[101]=&mob;m.mobs[101]={{19,2,0,0,0},{20,1,0,0,0}};m.chests[500]={{19,1,WIKI_SINGLE,100,25}};
|
||||||
|
PortNativeDrop(&c,{215,6,101});assert(c.desc.packets.size()==4);TPacketGCAva2Drop row;memcpy(&row,c.desc.packets[1].data(),sizeof(row));assert(row.vnum==19 && row.count==2 && row.prob==0);
|
||||||
|
c.desc.packets.clear();PortNativeDrop(&c,{215,7,500});assert(c.desc.packets.size()==2 && (unsigned char)c.desc.packets.back()[1]==6); // refusal is not an empty result
|
||||||
|
++now;c.desc.packets.clear();PortNativeDrop(&c,{215,7,500});memcpy(&row,c.desc.packets[1].data(),sizeof(row));assert(row.vnum==19 && row.prob==25);
|
||||||
|
++now;c.desc.packets.clear();PortNativeDrop(&c,{215,9,19});assert(c.desc.packets.size()==4); // both refinements
|
||||||
|
c.desc.version="1215955205mt20261016";c.desc.packets.clear();PortNativeDrop(&c,{215,6,101});do_event_manager(&c,"info");assert(c.desc.packets.empty());c.desc.version="1215955205mt20261019";
|
||||||
|
schedule.valid=false;do_event_manager(&c,"info");assert(c.commands.back()=="EventCalendarError unavailable");now+=2;
|
||||||
|
schedule.valid=true;schedule.events={{1,1,unsigned(now-1),unsigned(now+60),5,1},{2,2,unsigned(now+60),unsigned(now+120),0,0}};
|
||||||
|
do_event_manager(&c,"info");assert(c.desc.packets.size()==1);const auto& wire=c.desc.packets.back();TPacketGCAva2Events head;memcpy(&head,wire.data(),5);assert(head.header==214 && head.size==wire.size());assert((unsigned char)wire[6]==1);TAva2Event event;memcpy(&event,wire.data()+13,81);assert(event.kind==8 && event.active==1 && strlen(event.startText)==19); // 5 header + 6 payload + 2 day header
|
||||||
|
now+=2;c.desc.packets.clear();c.empire=2;do_event_manager(&c,"info");memcpy(&event,c.desc.packets[0].data()+13,81);assert(event.active==0);
|
||||||
|
now+=2;c.desc.packets.clear();schedule.events.clear();do_event_manager(&c,"info");assert(c.desc.packets[0].size()==11 && c.desc.packets[0][6]==0);
|
||||||
|
++now;c.desc.packets.clear();m.mobs[101].assign(4097,{19,1,0,0,0});PortNativeDrop(&c,{215,6,101});assert(c.desc.packets.size()==4098 && (unsigned char)c.desc.packets.back()[1]==6);
|
||||||
|
puts("PASS: native packet widths, loaded drops, refine family, rate/overflow errors, version gate, actual scoped UTC calendar");
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
with tempfile.TemporaryDirectory(prefix='native-queries-') as d:
|
||||||
|
p=Path(d);(p/'test.cpp').write_text(code)
|
||||||
|
subprocess.run(['c++','-std=c++17','-Wall','-I'+str(SRC),str(p/'test.cpp'),'-o',str(p/'test')],check=True)
|
||||||
|
subprocess.run([str(p/'test')],check=True)
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
"""Compile the shipping eligibility/cap arithmetic, including boundary and overflow cases."""
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
|
||||||
|
|
||||||
|
class PointDrop(unittest.TestCase):
|
||||||
|
def test_approved_rules_and_cap(self):
|
||||||
|
flags = json.loads((ROOT/'tools/ava2-itemshop/points-wide.json').read_text())
|
||||||
|
entries = ','.join('{"%s",%d}' % entry for entry in flags.items())
|
||||||
|
source = r'''
|
||||||
|
#include "src/server/common/point_drop.h"
|
||||||
|
#include <map>
|
||||||
|
#include <cassert>
|
||||||
|
int main() {
|
||||||
|
std::map<std::string,int> flags={ENTRIES};
|
||||||
|
auto lookup=[&](const std::string& key){return flags[key];};
|
||||||
|
auto mob=PortPointRule(lookup,false),stone=PortPointRule(lookup,true);
|
||||||
|
assert(mob.chance==500 && mob.minimum==1 && mob.maximum==1);
|
||||||
|
assert(stone.chance==10000 && stone.minimum==3 && stone.maximum==8);
|
||||||
|
assert(mob.eligible(105,120));assert(!mob.eligible(104,120));
|
||||||
|
assert(stone.eligible(120,1));assert(!stone.eligible(0,1));
|
||||||
|
assert(!stone.eligible(120,0));
|
||||||
|
assert(PortPointDropAmount(8,498,500)==2);
|
||||||
|
assert(PortPointDropAmount(8,500,500)==0);
|
||||||
|
assert(PortPointDropAmount(8,UINT64_MAX,500)==0);
|
||||||
|
assert(PortPointDropAmount(8,UINT64_MAX,0)==8);
|
||||||
|
flags["points_mob_chance"]=0;assert(!PortPointRule(lookup,false).eligible(105,120));
|
||||||
|
flags["points_stone_chance"]=10001;assert(!PortPointRule(lookup,true).valid());
|
||||||
|
flags["points_stone_chance"]=10000;flags["points_stone_min"]=-1;
|
||||||
|
assert(!PortPointRule(lookup,true).valid());
|
||||||
|
flags["points_stone_min"]=9;flags["points_stone_max"]=3;
|
||||||
|
assert(!PortPointRule(lookup,true).valid());
|
||||||
|
}
|
||||||
|
'''.replace('ENTRIES', entries)
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
src = Path(tmp)/'test.cpp'
|
||||||
|
exe = Path(tmp)/'test'
|
||||||
|
src.write_text(source)
|
||||||
|
subprocess.run(['c++', '-std=c++17', '-I'+str(ROOT), str(src), '-o', str(exe)], check=True)
|
||||||
|
subprocess.run([str(exe)], check=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -103,8 +103,10 @@ if cpacket.is_file():
|
|||||||
assert 'static_assert(sizeof(TPacketCGSwitchbot) == 7 && sizeof(TPacketGCSwitchbot) == 7,' in client
|
assert 'static_assert(sizeof(TPacketCGSwitchbot) == 7 && sizeof(TPacketGCSwitchbot) == 7,' in client
|
||||||
stream=(CLIENT/'PythonNetworkStreamPhaseGame.cpp').read_bytes().decode('latin1')
|
stream=(CLIENT/'PythonNetworkStreamPhaseGame.cpp').read_bytes().decode('latin1')
|
||||||
# the EU branch (the one every locale.cfg build takes) keeps 1215955205 first for the atoi version check
|
# the EU branch (the one every locale.cfg build takes) keeps 1215955205 first for the atoi version check
|
||||||
assert 'strncpy(kVersionPacket.timestamp, "1215955205 mt20261016", sizeof(kVersionPacket.timestamp)-1);' in stream
|
modern=re.search(r'strncpy\(kVersionPacket.timestamp, "1215955205 mt(\d{8})"',stream)
|
||||||
assert 'strncpy(kVersionPacket.timestamp, "mt20261016", sizeof(kVersionPacket.timestamp)-1);' in stream
|
legacy=re.search(r'strncpy\(kVersionPacket.timestamp, "mt(\d{8})"',stream)
|
||||||
|
assert modern and legacy and modern.group(1)==legacy.group(1)
|
||||||
|
assert int(modern.group(1))>=20261016 # switchbot gate; newer features may advance this revision
|
||||||
pyswitch=(CLIENT/'PythonSwitchbot.h').read_bytes().decode('latin1')
|
pyswitch=(CLIENT/'PythonSwitchbot.h').read_bytes().decode('latin1')
|
||||||
ctable=pyswitch[pyswitch.index('struct TSwitchbotTable'):];ctable=ctable[:ctable.index('};')]
|
ctable=pyswitch[pyswitch.index('struct TSwitchbotTable'):];ctable=ctable[:ctable.index('};')]
|
||||||
assert re.findall(r'^\s*[A-Za-z_][\w:]*\s+(\w+)(?:\[[^;]*\])?;',ctable,re.M)==table,ctable
|
assert re.findall(r'^\s*[A-Za-z_][\w:]*\s+(\w+)(?:\[[^;]*\])?;',ctable,re.M)==table,ctable
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# Native AVA2 item shop
|
||||||
|
|
||||||
|
Active UI is `uiitemshopnew.py`. GC93 retains the native catalogue/log layouts;
|
||||||
|
GD/DG76 transports authenticated account/character requests to the DB coordinator.
|
||||||
|
Purchase requests add a durable random token and the confirmed item/total quote.
|
||||||
|
|
||||||
|
`data/ava2-itemshop/original-products.tsv` contains all 217 original offers recovered
|
||||||
|
from the supplied MySQL56 archive. `source.json` records hashes. No prices are invented.
|
||||||
|
`compatibility.json` records 55 absent prototypes, 55 ITEM_NONE placeholders and 107
|
||||||
|
actual types needing item-system verification. `verified-products.json` selects 49
|
||||||
|
existing implemented mount, mount-skin, fixed-enchant and third-hand products.
|
||||||
|
|
||||||
|
Generate migration SQL with explicit configured schema names, review it and back up
|
||||||
|
account/award data before executing it:
|
||||||
|
|
||||||
|
```
|
||||||
|
python3 tools/ava2-itemshop/migrate.py --player player_sb --account account_sb --output /tmp/itemshop.sql
|
||||||
|
python3 tools/ava2-itemshop/enable_verified.py --player player_sb --output /tmp/itemshop-enable.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
The migration uses InnoDB for account, catalogue, orders and awards. Account/player SQL
|
||||||
|
configurations must target the same MySQL host and port. Purchase failures leave all
|
||||||
|
four unchanged. A transaction temporarily disables reconnect and caps lock waits at
|
||||||
|
three seconds, restoring the original connection options afterwards. Unknown COMMIT
|
||||||
|
outcomes retry the same order. Unique `(account_id,token)` orders survive process restarts.
|
||||||
|
|
||||||
|
The old prototype loader indexed vector pointers before sorting; it now sorts before building the index so lookup keys always match their templates.
|
||||||
|
|
||||||
|
Awards use the existing mall redemption path; non-stackable purchases create separate
|
||||||
|
award rows. New clients use revision mt20261020. Legacy clients cannot request GC93.
|
||||||
|
No web recharge service or wheel reward service is enabled.
|
||||||
|
|
||||||
|
Acceptance evidence: `metin2-client/docs/AVA2-ITEMSHOP.md` and
|
||||||
|
`metin2-client/audit/evidence/itemshop/`.
|
||||||
|
|
||||||
|
## Production release, 2026-10-20 (server CEST)
|
||||||
|
|
||||||
|
203 now runs the verified sbtest game/db pair: game `56975b48aa2fd40389c57eab84d017b0a2518cf6e1b573d967bf239f4ae04aba`,
|
||||||
|
db `dc940401fe6ccc3410c8d90ce98d2a5bad2e2c023279665bcd664c008d011699`.
|
||||||
|
The deployment retains the existing native battle pass, wiki, calendar and other cumulative game changes.
|
||||||
|
The release delta is the native shop, DB prototype-index fix, transactional schema and
|
||||||
|
49 enabled original offers. The remaining 168 offers, recharge and wheel services stay disabled.
|
||||||
|
Production 70002 was still ITEM_NONE; its text/SQL prototype is now ITEM_USE/USE_SPECIAL,
|
||||||
|
matching the tested third-hand implementation. Other prototypes were not replaced with test data.
|
||||||
|
|
||||||
|
Deployment package: `/root/deploy-features/20261020-itemshop`.
|
||||||
|
Backup: `/root/backup-itemshop/20261020-014955` (old binaries, original prototype,
|
||||||
|
full account/player SQL dump and pre-deployment error-log offsets).
|
||||||
|
`deploy.py` gracefully stops game/auth, then db; backs up SQL before migration; starts
|
||||||
|
db first and then auth and all 13 production game cores. sbtest remains independent.
|
||||||
|
|
||||||
|
Read-only health check:
|
||||||
|
```
|
||||||
|
/usr/local/bin/python3.9 /root/deploy-features/20261020-itemshop/deploy.py check
|
||||||
|
```
|
||||||
|
Binary rollback:
|
||||||
|
```
|
||||||
|
/usr/local/bin/python3.9 /root/deploy-features/20261020-itemshop/deploy.py rollback --backup /root/backup-itemshop/20261020-014955
|
||||||
|
```
|
||||||
|
Rollback retains InnoDB, coins, orders, awards and the compatible third-hand prototype.
|
||||||
|
Never restore the pre-release SQL dump over subsequent player purchases.
|
||||||
|
|
||||||
|
CH1 acceptance with a temporary ordinary account verified all 49 catalogue entries/icons,
|
||||||
|
insufficient funds without an order, a 99-coin purchase, same-token replay without another
|
||||||
|
charge/order, purchase history and mall redemption into inventory. Test account, character,
|
||||||
|
coins, orders, awards and items were removed; its one test sale was subtracted without
|
||||||
|
resetting other sales. Existing players received no test currency. db/auth/13 cores remained
|
||||||
|
healthy after cleanup. macOS release bundle and connected Android client's APK/resources
|
||||||
|
were updated; Android in-game purchase acceptance is not claimed by this release.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Build game/db without either Makefile's production installation default."""
|
||||||
|
import argparse
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
p = argparse.ArgumentParser(description=__doc__)
|
||||||
|
p.add_argument('--source', type=Path, required=True, help='directory containing server/ and extern/')
|
||||||
|
p.add_argument('--output', type=Path, required=True)
|
||||||
|
p.add_argument('--target', choices=['game', 'db'], required=True)
|
||||||
|
p.add_argument('--jobs', type=int, default=1)
|
||||||
|
a = p.parse_args()
|
||||||
|
source, output = a.source.resolve(), a.output.resolve()
|
||||||
|
for destination in (output, (output/'bin').resolve(), (output/'work').resolve()):
|
||||||
|
if destination == Path('/usr/metin2/server') or Path('/usr/metin2/server') in destination.parents:
|
||||||
|
p.error('build outputs must not be inside the production server tree')
|
||||||
|
for name in ('bin', 'work', 'obj-'+a.target):
|
||||||
|
(output/name).mkdir(parents=True, exist_ok=True)
|
||||||
|
# DB uses DBDIR, game uses GAMEDIR. Always override both, even when building one target.
|
||||||
|
subprocess.run(['gmake', '-j%d' % max(1, a.jobs), 'BINDIR='+str(output/'work'),
|
||||||
|
'GAMEDIR='+str(output/'bin'), 'DBDIR='+str(output/'bin'),
|
||||||
|
'OBJDIR='+str(output/('obj-'+a.target))],
|
||||||
|
cwd=source/'server'/a.target/'src', check=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
#!/usr/local/bin/python3.9
|
||||||
|
"""Deploy the verified shop binaries and migration; retain economic rows on rollback."""
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
ROOT = Path('/usr/metin2/server')
|
||||||
|
PACKAGE = Path(__file__).resolve().parent
|
||||||
|
CORES = [ROOT/'auth'] + [ROOT/('channel%d/%s' % (ch, part))
|
||||||
|
for ch in range(1, 5) for part in ('first', 'game1', 'game2')] + [ROOT/'game99']
|
||||||
|
DB = ROOT/'db'
|
||||||
|
GAME_HASH = '56975b48aa2fd40389c57eab84d017b0a2518cf6e1b573d967bf239f4ae04aba'
|
||||||
|
DB_HASH = 'dc940401fe6ccc3410c8d90ce98d2a5bad2e2c023279665bcd664c008d011699'
|
||||||
|
|
||||||
|
|
||||||
|
def digest(path):
|
||||||
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def pid(core):
|
||||||
|
try:
|
||||||
|
value = int((core/'pid').read_text().strip())
|
||||||
|
os.kill(value, 0)
|
||||||
|
except (OSError, ValueError):
|
||||||
|
return 0
|
||||||
|
details = subprocess.check_output(['procstat', '-f', str(value)]).decode()
|
||||||
|
if not any(' cwd ' in line and str(core) in line for line in details.splitlines()):
|
||||||
|
raise RuntimeError('Unexpected pid owner: ' + str(core))
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def stop(cores):
|
||||||
|
pending = [pid(core) for core in cores]
|
||||||
|
for value in pending:
|
||||||
|
if value:
|
||||||
|
os.kill(value, signal.SIGHUP)
|
||||||
|
deadline = time.time() + 300
|
||||||
|
while any(pid(core) for core in cores):
|
||||||
|
if time.time() > deadline:
|
||||||
|
raise RuntimeError('Graceful stop timeout; no forced termination')
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
def listeners():
|
||||||
|
return subprocess.check_output(['sockstat', '-4', '-l', '-P', 'tcp']).decode()
|
||||||
|
|
||||||
|
|
||||||
|
def wait_for(cores, ports):
|
||||||
|
deadline = time.time() + 180
|
||||||
|
while True:
|
||||||
|
active = listeners()
|
||||||
|
if all(pid(c) for c in cores) and all(':%d ' % p in active for p in ports):
|
||||||
|
return
|
||||||
|
if time.time() > deadline:
|
||||||
|
raise RuntimeError('Start health check timed out')
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
def port(core):
|
||||||
|
return int(next(line.split(':', 1)[1] for line in
|
||||||
|
(core/'CONFIG').read_text().splitlines() if line.startswith('PORT:')))
|
||||||
|
|
||||||
|
|
||||||
|
def start():
|
||||||
|
if not pid(DB):
|
||||||
|
subprocess.run(['daemon', '-f', '-o', str(DB/'itemshop-deploy.stdout'), './db'], cwd=DB, check=True)
|
||||||
|
wait_for([DB], [15000])
|
||||||
|
for core in CORES:
|
||||||
|
if not pid(core):
|
||||||
|
executable = './auth' if core.name == 'auth' else './game'
|
||||||
|
subprocess.run(['daemon', '-f', '-o', str(core/'itemshop-deploy.stdout'), executable], cwd=core, check=True)
|
||||||
|
time.sleep(.3)
|
||||||
|
wait_for(CORES, [port(c) for c in CORES])
|
||||||
|
|
||||||
|
|
||||||
|
def mysql(sql):
|
||||||
|
return subprocess.check_output(['mysql', '-N'], input=sql.encode()).decode().strip()
|
||||||
|
|
||||||
|
|
||||||
|
def replace(source, target):
|
||||||
|
temporary = target.with_name(target.name + '.shop-new')
|
||||||
|
shutil.copy2(source, temporary)
|
||||||
|
temporary.chmod(0o755)
|
||||||
|
temporary.replace(target)
|
||||||
|
|
||||||
|
|
||||||
|
def report():
|
||||||
|
return {'game_sha256': digest(ROOT/'share/bin/game'),
|
||||||
|
'db_sha256': digest(ROOT/'share/bin/db'),
|
||||||
|
'pids': {str(c.relative_to(ROOT)): pid(c) for c in [DB]+CORES},
|
||||||
|
'enabled_products': mysql('SELECT COUNT(*) FROM player.ishop_data WHERE enabled=1;')}
|
||||||
|
|
||||||
|
|
||||||
|
def rollback(backup):
|
||||||
|
stop(CORES)
|
||||||
|
stop([DB])
|
||||||
|
replace(backup/'game', ROOT/'share/bin/game')
|
||||||
|
replace(backup/'db', ROOT/'share/bin/db')
|
||||||
|
# Keep InnoDB, coins, orders and awards. Reverting them could discard purchases.
|
||||||
|
# Keep the compatible 70002 prototype so already delivered items remain usable.
|
||||||
|
start()
|
||||||
|
print(json.dumps({'rollback': str(backup), **report()}), flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
def deploy():
|
||||||
|
candidate = Path('/root/deploy-features/20261018-ava2-parity/itemshop-build/bin')
|
||||||
|
if digest(candidate/'game') != GAME_HASH or digest(candidate/'db') != DB_HASH:
|
||||||
|
raise RuntimeError('Candidate binary hash mismatch')
|
||||||
|
if not all(pid(c) for c in [DB]+CORES):
|
||||||
|
raise RuntimeError('Production baseline is not healthy')
|
||||||
|
backup = Path('/root/backup-itemshop')/time.strftime('%Y%m%d-%H%M%S')
|
||||||
|
backup.mkdir(parents=True, mode=0o700)
|
||||||
|
for name in ('game', 'db'):
|
||||||
|
shutil.copy2(ROOT/'share/bin'/name, backup/name)
|
||||||
|
meta = {'before': {n: digest(backup/n) for n in ('game', 'db')},
|
||||||
|
'source_revision': '3283101',
|
||||||
|
'syserr_offsets': {str(c.relative_to(ROOT)): (c/'syserr').stat().st_size
|
||||||
|
if (c/'syserr').exists() else 0 for c in [DB]+CORES}}
|
||||||
|
(backup/'metadata.json').write_text(json.dumps(meta, indent=2)+'\n')
|
||||||
|
proto = (ROOT/'share/conf/item_proto.txt').resolve()
|
||||||
|
shutil.copy2(proto, backup/'item_proto.txt')
|
||||||
|
(PACKAGE/'LAST_BACKUP').write_text(str(backup)+'\n')
|
||||||
|
print('backup=' + str(backup), flush=True)
|
||||||
|
stop(CORES)
|
||||||
|
print('game/auth stopped gracefully', flush=True)
|
||||||
|
stop([DB])
|
||||||
|
print('db stopped gracefully', flush=True)
|
||||||
|
try:
|
||||||
|
with (backup/'account-player.sql').open('wb') as out:
|
||||||
|
subprocess.run(['mysqldump', '--lock-all-tables', '--routines', '--triggers',
|
||||||
|
'--databases', 'account', 'player'], stdout=out, check=True)
|
||||||
|
(backup/'account-player.sql').chmod(0o600)
|
||||||
|
print('account/player backup complete', flush=True)
|
||||||
|
lines = proto.read_bytes().splitlines(keepends=True)
|
||||||
|
changed = 0
|
||||||
|
for i, line in enumerate(lines):
|
||||||
|
if line.startswith(b'70002\t'):
|
||||||
|
row = line.rstrip(b'\r\n').split(b'\t')
|
||||||
|
row[2], row[3], row[7] = b'ITEM_USE', b'USE_SPECIAL', b'NONE'
|
||||||
|
lines[i] = b'\t'.join(row)+b'\n'
|
||||||
|
changed += 1
|
||||||
|
if changed != 1:
|
||||||
|
raise RuntimeError('Expected exactly one 70002 prototype')
|
||||||
|
proto.write_bytes(b''.join(lines))
|
||||||
|
mysql('UPDATE player.item_proto SET type=3,subtype=10,wearflag=0 WHERE vnum=70002;')
|
||||||
|
for name in ('migrate.sql', 'enable.sql'):
|
||||||
|
mysql((PACKAGE/name).read_text())
|
||||||
|
if mysql('SELECT COUNT(*) FROM player.ishop_data WHERE enabled=1;') != '49':
|
||||||
|
raise RuntimeError('Expected 49 verified products')
|
||||||
|
replace(candidate/'game', ROOT/'share/bin/game')
|
||||||
|
replace(candidate/'db', ROOT/'share/bin/db')
|
||||||
|
start()
|
||||||
|
result = report()
|
||||||
|
(backup/'DEPLOYED.json').write_text(json.dumps(result, indent=2)+'\n')
|
||||||
|
print(json.dumps(result), flush=True)
|
||||||
|
except Exception:
|
||||||
|
rollback(backup)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('action', choices=['deploy', 'check', 'rollback'])
|
||||||
|
parser.add_argument('--backup', type=Path)
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.action == 'deploy':
|
||||||
|
deploy()
|
||||||
|
elif args.action == 'check':
|
||||||
|
print(json.dumps(report()), flush=True)
|
||||||
|
else:
|
||||||
|
if not args.backup:
|
||||||
|
parser.error('rollback requires --backup')
|
||||||
|
rollback(args.backup)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Emit SQL enabling original offers backed by implemented item systems. Never executes SQL."""
|
||||||
|
import argparse,json,re
|
||||||
|
from pathlib import Path
|
||||||
|
p=argparse.ArgumentParser();p.add_argument('--player',required=True);p.add_argument('--output',type=Path,required=True);a=p.parse_args()
|
||||||
|
if not re.fullmatch('[A-Za-z0-9_]+',a.player):p.error('invalid schema')
|
||||||
|
root=Path(__file__).resolve().parents[2];rows=json.loads((root/'data/ava2-itemshop/verified-products.json').read_text())['products']
|
||||||
|
sql='USE `'+a.player+'`;\n'
|
||||||
|
for row in rows:
|
||||||
|
sql+='UPDATE ishop_data s JOIN item_proto p ON p.vnum=s.itemVnum SET s.enabled=1 WHERE s.id=%d AND s.itemVnum=%d AND p.type<>0;\n'%(row['id'],row['vnum'])
|
||||||
|
sql+='SELECT categoryType,categorySubType,COUNT(*) FROM ishop_data WHERE enabled=1 GROUP BY categoryType,categorySubType;\n'
|
||||||
|
a.output.parent.mkdir(parents=True,exist_ok=True);a.output.write_text(sql);print('SQL generated for',len(rows),'verified original offers; original prices preserved')
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Emit a reviewable migration for explicitly named isolated or production schemas.
|
||||||
|
Run mysql separately after backup. Native products are disabled until compatibility review.
|
||||||
|
"""
|
||||||
|
import argparse,re
|
||||||
|
from pathlib import Path
|
||||||
|
p=argparse.ArgumentParser();p.add_argument('--player',required=True);p.add_argument('--account',required=True);p.add_argument('--output',type=Path,required=True);a=p.parse_args()
|
||||||
|
for name in (a.player,a.account):
|
||||||
|
if not re.fullmatch('[A-Za-z0-9_]+',name):p.error('invalid schema')
|
||||||
|
sql=f'''USE `{a.player}`;
|
||||||
|
CREATE TABLE IF NOT EXISTS ishop_data (
|
||||||
|
id INT UNSIGNED PRIMARY KEY, categoryType INT NOT NULL, categorySubType INT NOT NULL,
|
||||||
|
itemVnum INT UNSIGNED NOT NULL,itemPrice BIGINT UNSIGNED NOT NULL,discount INT NOT NULL DEFAULT 0,
|
||||||
|
offerTime DATETIME NULL,addedTime DATETIME NULL,sellCount BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
week_limit INT NOT NULL DEFAULT 0,month_limit INT NOT NULL DEFAULT 0,maxSellCount INT NOT NULL DEFAULT -1,
|
||||||
|
enabled TINYINT NOT NULL DEFAULT 0
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
CREATE TABLE IF NOT EXISTS port_itemshop_orders (
|
||||||
|
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,account_id INT UNSIGNED NOT NULL,
|
||||||
|
token CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,product INT UNSIGNED NOT NULL,vnum INT UNSIGNED NOT NULL,
|
||||||
|
quantity INT UNSIGNED NOT NULL,paid BIGINT UNSIGNED NOT NULL,player_name VARCHAR(24) NOT NULL,ip VARCHAR(45) NOT NULL,
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
UNIQUE KEY request_once(account_id,token), KEY limits_by_account(account_id,product,created_at)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
CREATE TABLE IF NOT EXISTS port_point_rewards (
|
||||||
|
token CHAR(32) CHARACTER SET ascii COLLATE ascii_bin PRIMARY KEY,
|
||||||
|
account_id INT UNSIGNED NOT NULL,player_id INT UNSIGNED NOT NULL,vnum INT UNSIGNED NOT NULL,
|
||||||
|
requested INT UNSIGNED NOT NULL,amount INT UNSIGNED NOT NULL,reward_day DATE NOT NULL,
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
KEY daily_account(account_id,reward_day)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
ALTER TABLE ishop_data ENGINE=InnoDB;
|
||||||
|
ALTER TABLE item_award ENGINE=InnoDB;
|
||||||
|
ALTER TABLE `{a.account}`.account ENGINE=InnoDB;
|
||||||
|
'''
|
||||||
|
# Upgrade an existing native catalogue without replacing its products or sales history.
|
||||||
|
sql+="""SET @enabled_exists=(SELECT COUNT(*) FROM information_schema.columns WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ishop_data' AND COLUMN_NAME='enabled');
|
||||||
|
SET @ddl=IF(@enabled_exists=0,'ALTER TABLE ishop_data ADD enabled TINYINT NOT NULL DEFAULT 0','SELECT 1');
|
||||||
|
PREPARE shop_ddl FROM @ddl; EXECUTE shop_ddl; DEALLOCATE PREPARE shop_ddl;
|
||||||
|
"""
|
||||||
|
# Coins are added by a separate conditional step, since MySQL 5.6 lacks ADD IF NOT EXISTS.
|
||||||
|
sql+=f'''SET @column_exists=(SELECT COUNT(*) FROM information_schema.columns WHERE TABLE_SCHEMA='{a.account}' AND TABLE_NAME='account' AND COLUMN_NAME='coins');
|
||||||
|
SET @ddl=IF(@column_exists=0,'ALTER TABLE `{a.account}`.account ADD coins BIGINT UNSIGNED NOT NULL DEFAULT 0','SELECT 1');
|
||||||
|
PREPARE shop_ddl FROM @ddl; EXECUTE shop_ddl; DEALLOCATE PREPARE shop_ddl;
|
||||||
|
'''
|
||||||
|
source=Path(__file__).resolve().parents[2]/'data/ava2-itemshop/original-products.tsv'
|
||||||
|
for line in source.read_text().splitlines():
|
||||||
|
row=line.split('\t');assert len(row)==12
|
||||||
|
values=[str(int(v)) if i not in (6,7) else ('NULL' if v.startswith('0000') else "'"+v+"'") for i,v in enumerate(row)]
|
||||||
|
sql+='INSERT IGNORE INTO ishop_data(id,categoryType,categorySubType,itemVnum,itemPrice,discount,offerTime,addedTime,sellCount,week_limit,month_limit,maxSellCount) VALUES('+','.join(values)+');\n'
|
||||||
|
a.output.parent.mkdir(parents=True,exist_ok=True);a.output.write_text(sql)
|
||||||
|
print('217 native products imported disabled; review compatibility before enabling')
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Plan/apply the 32->40 wear-slot migration with cores/db stopped and a full backup.
|
||||||
|
|
||||||
|
The saved plan contains exact row IDs and before/after values. Reapplying that same plan
|
||||||
|
is safe after interruption; never regenerate a plan from partially migrated data.
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
NAME = 'ava2-shop-wear-40'
|
||||||
|
|
||||||
|
|
||||||
|
def quickslots(blob):
|
||||||
|
if not blob:
|
||||||
|
return blob
|
||||||
|
if len(blob) != 108:
|
||||||
|
raise ValueError('Expected 36 three-byte quick slots')
|
||||||
|
output = bytearray(blob)
|
||||||
|
for index in range(0, len(blob), 3):
|
||||||
|
kind, lo, hi = blob[index:index+3]
|
||||||
|
pos = lo | hi << 8
|
||||||
|
if kind == 1 and (257 <= pos <= 268 or 287 <= pos <= 302):
|
||||||
|
output[index+1:index+3] = (pos+8).to_bytes(2, 'little')
|
||||||
|
return bytes(output)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument('--player', required=True)
|
||||||
|
parser.add_argument('--plan', type=Path, required=True)
|
||||||
|
parser.add_argument('--apply', action='store_true')
|
||||||
|
args = parser.parse_args()
|
||||||
|
if not re.fullmatch('[A-Za-z0-9_]+', args.player):
|
||||||
|
parser.error('Invalid database name')
|
||||||
|
|
||||||
|
def sql(query):
|
||||||
|
result = subprocess.run(['mysql', '-N', '-B', args.player], input=query,
|
||||||
|
text=True, capture_output=True, check=True)
|
||||||
|
return [line.split('\t') for line in result.stdout.splitlines()]
|
||||||
|
|
||||||
|
sql('CREATE TABLE IF NOT EXISTS mt_migration(name VARCHAR(64) PRIMARY KEY,done DATETIME);')
|
||||||
|
if sql("SELECT name FROM mt_migration WHERE name='%s';" % NAME):
|
||||||
|
print(NAME + ': already applied')
|
||||||
|
return
|
||||||
|
if args.plan.exists():
|
||||||
|
plan = json.loads(args.plan.read_text())
|
||||||
|
if plan['schema'] != args.player:
|
||||||
|
raise RuntimeError('Plan belongs to another database')
|
||||||
|
else:
|
||||||
|
# Equipped DS cells are relative; belt cells in INVENTORY are absolute.
|
||||||
|
bad = sql("SELECT i.id FROM item i LEFT JOIN item_proto p ON i.vnum=p.vnum "
|
||||||
|
"WHERE i.window='EQUIPMENT' AND i.pos>=32 AND "
|
||||||
|
"(i.pos>43 OR p.type IS NULL OR p.type NOT IN (29,30));")
|
||||||
|
if bad:
|
||||||
|
raise RuntimeError('Unexpected occupied extended equipment cells; inspect before migration')
|
||||||
|
items = sql("SELECT id,pos FROM item WHERE (window='EQUIPMENT' AND pos BETWEEN 32 AND 43) "
|
||||||
|
"OR (window='INVENTORY' AND pos BETWEEN 287 AND 302) ORDER BY pos DESC;")
|
||||||
|
plan = {'schema': args.player, 'items': [[int(i), int(p), int(p)+8] for i, p in items],
|
||||||
|
'quickslots': []}
|
||||||
|
for table in ('player', 'player_deleted'):
|
||||||
|
for pid, value in sql('SELECT id,HEX(quickslot) FROM `%s`;' % table):
|
||||||
|
old = bytes.fromhex(value)
|
||||||
|
new = quickslots(old)
|
||||||
|
if old != new:
|
||||||
|
plan['quickslots'].append([table, int(pid), old.hex(), new.hex()])
|
||||||
|
args.plan.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
args.plan.write_text(json.dumps(plan, indent=2)+'\n')
|
||||||
|
args.plan.chmod(0o600)
|
||||||
|
print('planned items=%d quickslots=%d' % (len(plan['items']), len(plan['quickslots'])))
|
||||||
|
if not args.apply:
|
||||||
|
return
|
||||||
|
# Every update is conditional on its original value, allowing safe saved-plan replay.
|
||||||
|
for item, old, new in plan['items']:
|
||||||
|
row = sql('SELECT pos FROM item WHERE id=%d;' % item)
|
||||||
|
if row not in ([[str(old)]], [[str(new)]]):
|
||||||
|
raise RuntimeError('Item changed since planning; cores/db must stay stopped')
|
||||||
|
sql('UPDATE item SET pos=%d WHERE id=%d AND pos=%d;' % (new, item, old))
|
||||||
|
for table, pid, old, new in plan['quickslots']:
|
||||||
|
row = sql('SELECT HEX(quickslot) FROM `%s` WHERE id=%d;' % (table, pid))
|
||||||
|
if not row or row[0][0].lower() not in (old, new):
|
||||||
|
raise RuntimeError('Quickslot changed since planning')
|
||||||
|
sql("UPDATE `%s` SET quickslot=X'%s' WHERE id=%d AND HEX(quickslot)='%s';" %
|
||||||
|
(table, new, pid, old.upper()))
|
||||||
|
columns = sql("SELECT COLUMN_NAME FROM information_schema.columns WHERE TABLE_SCHEMA=DATABASE() "
|
||||||
|
"AND TABLE_NAME='item' AND COLUMN_NAME='port_extra';")
|
||||||
|
if not columns:
|
||||||
|
sql("ALTER TABLE item ADD port_extra VARBINARY(69) NOT NULL DEFAULT ''; ")
|
||||||
|
sql("INSERT INTO mt_migration(name,done) VALUES('%s',NOW());" % NAME)
|
||||||
|
print(NAME + ': applied; retain the saved plan for recovery')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"points_mob_chance": 500,
|
||||||
|
"points_mob_min": 1,
|
||||||
|
"points_mob_max": 1,
|
||||||
|
"points_stone_chance": 10000,
|
||||||
|
"points_stone_min": 3,
|
||||||
|
"points_stone_max": 8,
|
||||||
|
"points_min_level": 1,
|
||||||
|
"points_max_overlevel": 15,
|
||||||
|
"points_daily_cap": 500
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
-- PORT: battle pass tables (docs/FEATURE-BATTLEPASS.md). Idempotent; run once on the player database.
|
-- PORT: battle pass tables (docs/FEATURE-BATTLEPASS.md). Idempotent; run once on the player database.
|
||||||
-- Progress: one row per player, season and mission slot; the game adds deltas and MySQL caps them at target.
|
-- Progress: one row per player, season and mission slot; the game adds deltas and MySQL caps them at target.
|
||||||
CREATE TABLE IF NOT EXISTS player.mt_battlepass_progress (
|
CREATE TABLE IF NOT EXISTS mt_battlepass_progress (
|
||||||
pid INT UNSIGNED NOT NULL,
|
pid INT UNSIGNED NOT NULL,
|
||||||
season INT UNSIGNED NOT NULL,
|
season INT UNSIGNED NOT NULL,
|
||||||
slot TINYINT UNSIGNED NOT NULL,
|
slot TINYINT UNSIGNED NOT NULL,
|
||||||
@@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS player.mt_battlepass_progress (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||||
-- Claims: the primary key is the idempotency guard; only the request whose INSERT IGNORE adds the row pays out.
|
-- Claims: the primary key is the idempotency guard; only the request whose INSERT IGNORE adds the row pays out.
|
||||||
-- slot 0 is the final reward.
|
-- slot 0 is the final reward.
|
||||||
CREATE TABLE IF NOT EXISTS player.mt_battlepass_claim (
|
CREATE TABLE IF NOT EXISTS mt_battlepass_claim (
|
||||||
pid INT UNSIGNED NOT NULL,
|
pid INT UNSIGNED NOT NULL,
|
||||||
season INT UNSIGNED NOT NULL,
|
season INT UNSIGNED NOT NULL,
|
||||||
slot TINYINT UNSIGNED NOT NULL,
|
slot TINYINT UNSIGNED NOT NULL,
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/local/bin/python3.9
|
||||||
|
"""203 game-only deployment. Keep db running; back up first; retain earned claims on rollback."""
|
||||||
|
import argparse,hashlib,json,os,shutil,signal,subprocess,time
|
||||||
|
from pathlib import Path
|
||||||
|
ROOT=Path('/usr/metin2/server')
|
||||||
|
CORES=[ROOT/'auth']+[ROOT/('channel%d/%s'%(ch,part)) for ch in range(1,5) for part in ('first','game1','game2')]+[ROOT/'game99']
|
||||||
|
LIVE=ROOT/'share/bin/game';CAL=ROOT/'share/locale/newcibn/port_events.tsv'
|
||||||
|
def digest(path):return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
def alive(pid):
|
||||||
|
try:os.kill(pid,0);return True
|
||||||
|
except ProcessLookupError:return False
|
||||||
|
def pid(core):
|
||||||
|
try:return int((core/'pid').read_text().strip())
|
||||||
|
except (OSError,ValueError):return 0
|
||||||
|
def verified_pid(core):
|
||||||
|
value=pid(core)
|
||||||
|
if not value or not alive(value):return 0
|
||||||
|
details=subprocess.check_output(['procstat','-f',str(value)]).decode()
|
||||||
|
if not any(' cwd ' in line and str(core) in line for line in details.splitlines()):raise RuntimeError('Unexpected pid owner for '+str(core))
|
||||||
|
return value
|
||||||
|
def stop():
|
||||||
|
pending=[verified_pid(core) for core in CORES];pending=[p for p in pending if p]
|
||||||
|
for value in pending:os.kill(value,signal.SIGHUP)
|
||||||
|
deadline=time.time()+300
|
||||||
|
while any(alive(p) for p in pending):
|
||||||
|
if time.time()>deadline:raise RuntimeError('Graceful stop timed out; binary remains unchanged')
|
||||||
|
time.sleep(.5)
|
||||||
|
def port(core):
|
||||||
|
return int(next(line.split(':',1)[1] for line in (core/'CONFIG').read_text().splitlines() if line.startswith('PORT:')))
|
||||||
|
def start():
|
||||||
|
for core in CORES:
|
||||||
|
if verified_pid(core):continue
|
||||||
|
executable='./auth' if core.name=='auth' else './game'
|
||||||
|
subprocess.run(['daemon','-f','-o',str(core/'native-deploy.stdout'),executable],cwd=str(core),check=True)
|
||||||
|
time.sleep(.3)
|
||||||
|
deadline=time.time()+55
|
||||||
|
while True:
|
||||||
|
listeners=subprocess.check_output(['sockstat','-4','-l','-P','tcp']).decode()
|
||||||
|
missing=[str(core.relative_to(ROOT)) for core in CORES if not verified_pid(core) or (':%d '%port(core)) not in listeners]
|
||||||
|
if not missing:return
|
||||||
|
if time.time()>deadline:raise RuntimeError('Cores failed health check: '+','.join(missing))
|
||||||
|
time.sleep(1)
|
||||||
|
def replace(source):
|
||||||
|
target=LIVE.with_suffix('.native-new');shutil.copy2(source,target);target.chmod(0o755);target.replace(LIVE)
|
||||||
|
def report():
|
||||||
|
print(json.dumps({'game_sha256':digest(LIVE),'cores':{str(c.relative_to(ROOT)):verified_pid(c) for c in CORES},'db_running':alive(pid(ROOT/'db'))},sort_keys=True),flush=True)
|
||||||
|
def rollback(backup):
|
||||||
|
meta=json.loads((backup/'metadata.json').read_text());stop();replace(backup/'game')
|
||||||
|
# Progress/claim rows are intentionally retained: reverting them could pay rewards twice.
|
||||||
|
if not meta['calendar_existed'] and CAL.exists() and CAL.read_bytes()==b'MTCALENDAR 1\n':CAL.unlink()
|
||||||
|
start();report()
|
||||||
|
def deploy(candidate,expected,destination):
|
||||||
|
if digest(candidate)!=expected:raise RuntimeError('Staged candidate hash mismatch')
|
||||||
|
if not alive(pid(ROOT/'db')):raise RuntimeError('Production db is not running')
|
||||||
|
for core in CORES:verified_pid(core)
|
||||||
|
backup=destination/time.strftime('%Y%m%d-%H%M%S');backup.mkdir(parents=True,mode=0o700)
|
||||||
|
shutil.copy2(LIVE,backup/'game')
|
||||||
|
meta={'old_hash':digest(LIVE),'new_hash':expected,'calendar_existed':CAL.exists(),'syserr_offsets':{str(c.relative_to(ROOT)):(c/'syserr').stat().st_size if (c/'syserr').exists() else 0 for c in CORES}}
|
||||||
|
(backup/'metadata.json').write_text(json.dumps(meta,indent=2)+'\n')
|
||||||
|
for name in ('port_events.tsv','port_battlepass.tsv'):
|
||||||
|
f=CAL.parent/name
|
||||||
|
if f.exists():shutil.copy2(f,backup/name)
|
||||||
|
for table in ('mt_battlepass_progress','mt_battlepass_claim'):
|
||||||
|
data=subprocess.check_output(['mysqldump','--no-create-info','--complete-insert','--skip-add-locks','player',table]);f=backup/(table+'.sql');f.write_bytes(data);f.chmod(0o600)
|
||||||
|
print('backup='+str(backup),flush=True)
|
||||||
|
try:
|
||||||
|
stop()
|
||||||
|
replace(candidate)
|
||||||
|
if not CAL.exists():
|
||||||
|
temporary=CAL.with_suffix('.native-new');temporary.write_bytes(b'MTCALENDAR 1\n');temporary.replace(CAL)
|
||||||
|
start();report()
|
||||||
|
except Exception:
|
||||||
|
rollback(backup);raise
|
||||||
|
(backup/'DEPLOYED').write_text(expected+'\n')
|
||||||
|
print('deployed='+str(backup),flush=True)
|
||||||
|
if __name__=='__main__':
|
||||||
|
p=argparse.ArgumentParser();p.add_argument('action',choices=['check','deploy','rollback']);p.add_argument('--candidate',type=Path);p.add_argument('--sha256');p.add_argument('--backups',type=Path,default=Path('/root/backup-native-systems'));p.add_argument('--backup',type=Path);a=p.parse_args()
|
||||||
|
if a.action=='check':report()
|
||||||
|
elif a.action=='rollback':rollback(a.backup)
|
||||||
|
else:
|
||||||
|
if not a.candidate or not a.sha256:p.error('deploy requires --candidate and --sha256')
|
||||||
|
deploy(a.candidate,a.sha256,a.backups)
|
||||||
Reference in New Issue
Block a user