"; $filePath = "D:\Diablo II\MODS\ironman-dev\save\Barb.d2s"; $fp = fopen($filePath, "rb"); function strtobits(string $str): string { $ret = ""; for ($i = 0; $i < strlen($str); ++$i) { $ord = ord($str[$i]); for ($bitnum = 7; $bitnum >= 0; --$bitnum) { if ($ord & (1 << $bitnum)) { $ret .= "1"; } else { $ret .= "0"; } } } return $ret; } foreach ($qNorm as $k => $v) { fseek($fp, $k); $questsNorm[$k] = fread($fp, 2); } foreach ($qNM as $k => $v) { fseek($fp, $k); $questsNM[$k] = fread($fp, 2); } foreach ($qHell as $k => $v) { fseek($fp, $k); $questsHell[$k] = fread($fp, 2); } foreach ($offsets as $k => $v) { fseek($fp, $k); $data[$k] = fread($fp, $v); } $charData['Identifier'] = bin2hex($data[0]); $charData['VersionID'] = unpack('l', $data[4])[1]; // 96 is v1.10+ - check out $charData['Filesize'] = round(unpack('l', $data[8])[1] / 1024, 2) . " KB"; // 1.41 KB (1,447 bytes) - checks out // $charData['Checksum'] = bin2hex($data['12']); // $charData['Activeweapon'] = unpack('l', $data['16']); $charData['CharacterName'] = ($data[20]); $charData['CharacterStatus'] = array_filter(str_split(strtobits($data[36]))); foreach ($charData['CharacterStatus'] as $k => $v) { $str .= ($characterStatus[$k]) . " "; } $charData['CharacterStatus'] = $str; // $charData['Characterprogression'] = bindec($data['37']); $charData['CharacterClass'] = $class[unpack('C', $data[40])[1]]; $charData['CharacterLevel'] = unpack('C', $data[43])[1]; $charData['Lastplayed'] = gmdate("Y-m-d\TH:i:s\Z", unpack('I', $data[48])[0]); // $charData['Assignedskills'] = (unpack('i16', $data['56'])); $charData['LeftmousebuttonskillID'] = $skills[unpack('i', $data[120])[1]]; $charData['RightmousebuttonskillID'] = $skills[unpack('i', $data[124])[1]]; $charData['LeftswapmousebuttonskillID'] = $skills[unpack('i', $data[128])[1]]; $charData['RightswapmousebuttonskillID'] = $skills[unpack('i', $data[132])[1]]; // $charData['Charactermenuappearance'] = unpack('i', $data[136]); $x = str_split(strtobits($data[168]), 8); $onDifficulty['Norm'] = $x[0][0]; $onDifficulty['NM'] = $x[1][0]; $onDifficulty['Hell'] = $x[2][0]; $charData['Difficulty'] = array_filter($onDifficulty); //$charData['MapID'] = $data['171']; //$charData['Mercenarydead'] = unpack('i', $data['177']); //$charData['MercenaryID'] = $data['179']; //$charData['MercenaryNameID'] = $data['183']; //$charData['Mercenarytype'] = $data['185']; //$charData['Mercenaryexperience'] = $data['187']; foreach ($questsNorm as $k => $v) { $x = array_filter(str_split(strtobits($v), 8)); if ($x[0][0]) { $quests[] = ($qNorm[$k] . " => " . (($x[0][0])) . "
"); } } foreach ($questsNM as $k => $v) { $x = array_filter(str_split(strtobits($v), 8)); if ($x[0][0]) { $quests[] = ($qNM[$k] . " => " . (($x[0][0])) . "
"); } } foreach ($questsHell as $k => $v) { $x = array_filter(str_split(strtobits($v), 8)); if ($x[0][0]) { $quests[] = ($qHell[$k] . " => " . (($x[0][0])) . "
"); } } $charData['Quests'] = $quests; $charData['Waypoints'] = $data[633]; $charData['NPCIntroductions'] = $data[714]; print_r($charData); // $charData['Unknown'] = $data['44']; // $charData['Unknown'] = $data['52']; // $charData['Unknown'] = $data['175']; // $charData['Unknown'] = $data['191'];