Advertisement
fastman92

peds.col script to extract informations

Nov 19th, 2011
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. <?php
  2. function GetNULLPaddedString($string)
  3. {
  4. $newString = NULL;
  5. $i = 0;
  6.  
  7.     while ($i < strlen($string))
  8.     {
  9.     if(!ord($string{$i}))
  10.     break;
  11.    
  12.     $newString = $newString.$string{$i};
  13.     $i++;
  14.     }
  15. return $newString;
  16. }
  17.  
  18. if(!$fh = fopen('peds.col', 'r'))
  19. exit;
  20.  
  21. fseek($fh, 100);
  22.  
  23. $counter = 0;
  24. $version = NULL;
  25.  
  26.     do
  27.     {
  28.     $character = fread($fh, 1);
  29.         if($character == "\x23")
  30.         break;
  31.    
  32.     $version = $version.chr(ord($character)-23);
  33.     fseek($fh, 99, SEEK_CUR);
  34.    
  35.     ++$counter;
  36.     }
  37.     while ($counter < 26);
  38.    
  39. echo 'Version: '.$version."</br></br></br>";
  40. fseek($fh, 0);
  41. $position = 0;
  42.     while($FourCC = fread($fh, 4))
  43.     {
  44.     echo 'Position: 0x'.dechex($position)."</br>";
  45.     $SizeToAnEndOfThisCollision = unpack('Vx', fread($fh, 4));
  46.     $SizeToAnEndOfThisCollision = $SizeToAnEndOfThisCollision['x'];
  47.    
  48.     $CollisionName = GetNULLPaddedString(fread($fh, 24));
  49.  
  50.     echo 'Name: '.$CollisionName."</br>SizeToAnEndOfThisCollision: 0x".dechex($SizeToAnEndOfThisCollision)."</br></br>";
  51.     $position += $SizeToAnEndOfThisCollision + 8;
  52.     fseek($fh, $SizeToAnEndOfThisCollision - 24, SEEK_CUR);
  53.     }
  54.  
  55. fclose($fh);
  56. ?>
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement