1 | <?php namespace FreedomCore\TrinityCore\Support\DB2Reader\Commands; |
||
12 | class SyncStructures extends Command |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * The console command name. |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $name = 'db2:structure:sync'; |
||
20 | |||
21 | /** |
||
22 | * @inheritdoc |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $signature = 'db2:structure:sync {--build=25549}'; |
||
26 | |||
27 | /** |
||
28 | * The console command description. |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $description = 'Synchronize structures with TrinityCore Github Repository'; |
||
32 | |||
33 | /** |
||
34 | * Game Build Number |
||
35 | * @var null|int |
||
36 | */ |
||
37 | protected $build = null; |
||
38 | |||
39 | /** |
||
40 | * Github Content |
||
41 | * @var null|string |
||
42 | */ |
||
43 | protected $content = null; |
||
44 | |||
45 | /** |
||
46 | * Where structures will be saved |
||
47 | * @var null|string |
||
48 | */ |
||
49 | protected $saveLocation = null; |
||
50 | |||
51 | /** |
||
52 | * Array of parsed structures |
||
53 | * @var array |
||
54 | */ |
||
55 | protected $structures = []; |
||
56 | |||
57 | /** |
||
58 | * Structure Info Array |
||
59 | * @var array |
||
60 | */ |
||
61 | protected $structureInfo = [ |
||
62 | 'name' => null, |
||
63 | 'start' => null, |
||
64 | 'end' => null, |
||
65 | 'fields' => [] |
||
66 | ]; |
||
67 | |||
68 | /** |
||
69 | * Array for items which require to be replaced |
||
70 | * @var array |
||
71 | */ |
||
72 | protected $replaceArray = [ |
||
73 | 'LocalizedString*', |
||
74 | 'uint32', |
||
75 | 'uint16', |
||
76 | 'uint8', |
||
77 | 'int32', |
||
78 | 'int16', |
||
79 | 'int8', |
||
80 | 'float', |
||
81 | ';', |
||
82 | 'char', |
||
83 | 'const*', |
||
84 | 'const', |
||
85 | 'DBCPosition3D', |
||
86 | 'DBCPosition2D' |
||
87 | ]; |
||
88 | |||
89 | /** |
||
90 | * Fire Installation |
||
91 | * @return mixed |
||
92 | */ |
||
93 | public function fire() |
||
97 | |||
98 | /** |
||
99 | * Handle Installation |
||
100 | */ |
||
101 | public function handle() |
||
109 | |||
110 | /** |
||
111 | * Load Source Code |
||
112 | */ |
||
113 | private function loadSourceCode() |
||
120 | |||
121 | /** |
||
122 | * Get text between two strings |
||
123 | * @param string $string |
||
124 | * @param string $start |
||
125 | * @param string $end |
||
126 | * @return string |
||
127 | */ |
||
128 | private function getBetween(string $string, string $start, string $end) : string |
||
139 | |||
140 | /** |
||
141 | * Prepare Structures |
||
142 | */ |
||
143 | private function prepareStructures() |
||
191 | |||
192 | /** |
||
193 | * Save Structures |
||
194 | */ |
||
195 | private function saveStructures() |
||
211 | |||
212 | /** |
||
213 | * Convert field names to appropriate ones |
||
214 | * @param string $fieldName |
||
215 | * @return mixed|string |
||
216 | */ |
||
217 | private function convertNames(string $fieldName) |
||
229 | |||
230 | /** |
||
231 | * Replace known issues with fields names |
||
232 | * @param string $fieldName |
||
233 | * @return mixed|string |
||
234 | */ |
||
235 | private function replaceKnown(string $fieldName) |
||
252 | } |
||
253 |