|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace cyberinferno\Cabal\Helpers; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class Character |
|
7
|
|
|
* |
|
8
|
|
|
* Contains methods helpful to decode character information |
|
9
|
|
|
* |
|
10
|
|
|
* @package cyberinferno\Cabal\Helpers |
|
11
|
|
|
* @author Karthik P |
|
12
|
|
|
*/ |
|
13
|
|
|
class Character |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* Encode style |
|
17
|
|
|
* |
|
18
|
|
|
* @param int $gender |
|
19
|
|
|
* @param int $aura |
|
20
|
|
|
* @param int $hair |
|
21
|
|
|
* @param int $hairColor |
|
22
|
|
|
* @param int $face |
|
23
|
|
|
* @param int $classRank |
|
24
|
|
|
* @param int $class |
|
25
|
|
|
* @return int |
|
26
|
|
|
*/ |
|
27
|
3 |
|
public static function EncodeStyle($gender, $aura, $hair, $hairColor, $face, $classRank, $class) |
|
28
|
|
|
{ |
|
29
|
3 |
|
$return = 0; |
|
30
|
3 |
|
$return += $gender * hexdec("4000000"); |
|
31
|
3 |
|
$return += $aura * hexdec("400000") / 2; |
|
32
|
3 |
|
$return += $hair * hexdec("20000"); |
|
33
|
3 |
|
$return += $hairColor * hexdec("2000"); |
|
34
|
3 |
|
$return += $face * hexdec("100"); |
|
35
|
3 |
|
$return += $classRank * 8; |
|
36
|
3 |
|
$return += $class; |
|
37
|
3 |
|
return $return; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Decode style |
|
42
|
|
|
* |
|
43
|
|
|
* @param int $styleCode |
|
44
|
|
|
* @return array |
|
45
|
|
|
*/ |
|
46
|
3 |
|
public static function DecodeStyle($styleCode) |
|
47
|
|
|
{ |
|
48
|
3 |
|
$style = []; |
|
49
|
3 |
|
$style['gender'] = intval($styleCode / hexdec("4000000")); |
|
50
|
3 |
|
$style['aura'] = intval(($styleCode % hexdec("4000000")) / hexdec("200000")); |
|
51
|
3 |
|
$style['hair'] = intval(($styleCode % hexdec("200000")) / hexdec("20000")); |
|
52
|
3 |
|
$style['hairColor'] = intval(($styleCode % hexdec("20000")) / hexdec("2000")); |
|
53
|
3 |
|
$style['face'] = intval(($styleCode % hexdec("2000")) / hexdec("100")); |
|
54
|
3 |
|
$style['rank'] = intval(($styleCode % hexdec("100")) / 8); |
|
55
|
3 |
|
$style['class'] = ($styleCode / 1 & 7); |
|
56
|
3 |
|
return $style; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Encode position |
|
61
|
|
|
* |
|
62
|
|
|
* @param int $x |
|
63
|
|
|
* @param int $y |
|
64
|
|
|
* @return int |
|
65
|
|
|
*/ |
|
66
|
3 |
|
public static function EncodePosition($x, $y) |
|
67
|
|
|
{ |
|
68
|
3 |
|
return ($x << 16) | $y; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Decode position |
|
73
|
|
|
* |
|
74
|
|
|
* @param int $pos |
|
75
|
|
|
* @return array |
|
76
|
|
|
*/ |
|
77
|
3 |
|
public static function DecodePosition($pos) |
|
78
|
|
|
{ |
|
79
|
3 |
|
$position = []; |
|
80
|
3 |
|
$position['x'] = ($pos >> 16); |
|
81
|
3 |
|
$position['y'] = $pos ^ ($position['x'] << 16); |
|
82
|
3 |
|
return $position; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Decode binary item listing like inventory data or warehouse data |
|
87
|
|
|
* |
|
88
|
|
|
* @param string $itemString |
|
89
|
|
|
* @return array |
|
90
|
|
|
*/ |
|
91
|
3 |
|
public static function DecodeBinaryItemList($itemString) |
|
92
|
|
|
{ |
|
93
|
3 |
|
$items = []; |
|
94
|
3 |
|
if (substr($itemString, 0, 2) == '0x') { |
|
95
|
3 |
|
$start = 2; |
|
96
|
|
|
} else { |
|
97
|
3 |
|
$start = 0; |
|
98
|
|
|
} |
|
99
|
3 |
|
for ($i = $start; $i < strlen($itemString); $i += 36) { |
|
100
|
3 |
|
$items[] = [ |
|
101
|
3 |
|
'itemCode' => hexdec((new self())->convertToBigEndian(substr($itemString, $i, 6))), |
|
102
|
3 |
|
'itemOption' => hexdec((new self())->convertToBigEndian(substr($itemString, $i + 16, 8))), |
|
103
|
3 |
|
'itemInventorySlot' => hexdec((new self())->convertToBigEndian(substr($itemString, $i + 24, 2))) + 1 |
|
104
|
|
|
]; |
|
105
|
|
|
} |
|
106
|
3 |
|
return $items; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Convert little endian hex string to big endian hex string |
|
111
|
|
|
* |
|
112
|
|
|
* @param string Little endian HEX string |
|
|
|
|
|
|
113
|
|
|
* |
|
114
|
|
|
* @return string |
|
115
|
|
|
*/ |
|
116
|
3 |
|
private function convertToBigEndian($endian) |
|
117
|
|
|
{ |
|
118
|
3 |
|
if (strlen($endian) % 2 != 0) { |
|
119
|
|
|
$endian = '0' . $endian; |
|
120
|
|
|
} |
|
121
|
3 |
|
return implode('', array_reverse(str_split($endian, 2))); |
|
122
|
|
|
} |
|
123
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths