Example #1
0
 private static function decode_bkgnd($bkgnd_id)
 {
     $bkgnd_data = substr(HCImport::$contents, HCImport::$block_index['BKGD'][$bkgnd_id]['offset'], HCImport::$block_index['BKGD'][$bkgnd_id]['size']);
     $bkgnd = array();
     $fields = unpack('Nbmap/nflags', substr($bkgnd_data, 4, 6));
     $bkgnd['bmap_id'] = $fields['bmap'];
     $bkgnd['cant_delete'] = ($fields['flags'] & 0x4000) != 0;
     $bkgnd['hide_picture'] = ($fields['flags'] & 0x2000) != 0;
     $bkgnd['dont_search'] = ($fields['flags'] & 0x800) != 0;
     $fields = unpack('nparts/n3/npcc', substr($bkgnd_data, 24, 16));
     $part_count = $fields['parts'];
     $contents_count = $fields['pcc'];
     //print 'BKGD: '.$bkgnd['bkgnd_id'].' BMAP: '.$bkgnd['bmap_id'].'  PARTS:'.$part_count.
     //	'  PCC: '.$contents_count.'<br>';
     $offset = 38;
     $bkgnd['parts'] = HCImport::decode_parts($part_count, $bkgnd_data, $offset);
     $bkgnd['content'] = HCImport::decode_content($contents_count, $bkgnd_data, $offset);
     $bkgnd['name'] = HCImport::cstring(substr($bkgnd_data, $offset));
     $bkgnd['script'] = HCImport::cstring(substr($bkgnd_data, $offset + strlen($bkgnd['name'])));
     $bkgnd['name'] = HCImport::macroman_decode($bkgnd['name']);
     $bkgnd['script'] = HCImport::macroman_decode($bkgnd['script']);
     return $bkgnd;
 }