Guest User

xtyp_objs_v1.php

a guest
Jan 21st, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.48 KB | None | 0 0
  1. <?php
  2.  
  3. // xtyp_objs_v1.php
  4.  
  5. ini_set('memory_limit', '900M');
  6. ini_set('display_errors', '1');
  7.  
  8. $files = explode("\n", `dir /b /s *.xtyp`);
  9. $section_const = "\x11\x11\x33\x33";
  10. $objs_code = "\x82\xD6\xFC\x83";
  11.  
  12. print "f0, f1, f2, f3, ";
  13. print "bound_min_x, bound_min_y, bound_min_z, ";
  14. print "bound_max_x, bound_max_y, bound_max_z, ";
  15. print "sphere_x, sphere_y, sphere_z, ";
  16. print "sphere_radius, draw_dist, model, texture, ";
  17. print "f4, f5, f6, f7, ";
  18. print "f8, f9, f10, f11\r\n";
  19.  
  20. foreach ($files as $file)
  21. {
  22.     if (!is_file($file)) continue;
  23.     $data = file_get_contents($file);
  24.     if ($data !== false)
  25.     {
  26.         // parse section list
  27.         $loffset = fix_offset(substr($data, 0x40, 4));
  28.         while (substr($data, $loffset + 0xc, 4) == $section_const)
  29.         {
  30.             $code = substr($data, $loffset + 0x0, 4);
  31.             $ssize = parse_int(substr($data, $loffset + 0x4, 4));
  32.             $soffset = fix_offset(substr($data, $loffset + 0x8, 4));
  33.            
  34.             // parse objs section
  35.             if ($code == $objs_code)
  36.             {
  37.                 $size_parsed = 0;
  38.                 while ($size_parsed + 0x70 <= $ssize)
  39.                 {
  40.                     $f0 = strtoupper( bin2hex(substr($data, $soffset + 0x0, 4)) );
  41.                     $f1 = strtoupper( bin2hex(substr($data, $soffset + 0x4, 4)) );
  42.                     $f2 = strtoupper( bin2hex(substr($data, $soffset + 0x8, 4)) );
  43.                     $f3 = strtoupper( bin2hex(substr($data, $soffset + 0xc, 4)) );
  44.                     printf("%s, %s, %s, %s, ", $f0, $f1, $f2, $f3);
  45.                    
  46.                     $x = parse_float(substr($data, $soffset + 0x10, 4));
  47.                     $y = parse_float(substr($data, $soffset + 0x14, 4));
  48.                     $z = parse_float(substr($data, $soffset + 0x18, 4));
  49.                     printf("%.4f, %.4f, %.4f, ", $x, $y, $z);
  50.                    
  51.                     $x = parse_float(substr($data, $soffset + 0x20, 4));
  52.                     $y = parse_float(substr($data, $soffset + 0x24, 4));
  53.                     $z = parse_float(substr($data, $soffset + 0x28, 4));
  54.                     printf("%.4f, %.4f, %.4f, ", $x, $y, $z);
  55.                    
  56.                     $x = parse_float(substr($data, $soffset + 0x30, 4));
  57.                     $y = parse_float(substr($data, $soffset + 0x34, 4));
  58.                     $z = parse_float(substr($data, $soffset + 0x38, 4));
  59.                     printf("%.4f, %.4f, %.4f, ", $x, $y, $z);
  60.                    
  61.                     $r = parse_float(substr($data, $soffset + 0x40, 4));
  62.                     $dd = parse_float(substr($data, $soffset + 0x44, 4));
  63.                     $mh = "0x" . strtoupper( bin2hex(substr($data, $soffset + 0x48, 4)) );
  64.                     $th = "0x" . strtoupper( bin2hex(substr($data, $soffset + 0x4c, 4)) );
  65.                     printf("%.4f, %.4f, %s, %s, ", $r, $dd, $mh, $th);
  66.                    
  67.                     $f0 = strtoupper( bin2hex(substr($data, $soffset + 0x50, 4)) );
  68.                     $f1 = strtoupper( bin2hex(substr($data, $soffset + 0x54, 4)) );
  69.                     $f2 = strtoupper( bin2hex(substr($data, $soffset + 0x58, 4)) );
  70.                     $f3 = strtoupper( bin2hex(substr($data, $soffset + 0x5c, 4)) );
  71.                     printf("%s, %s, %s, %s, ", $f0, $f1, $f2, $f3);
  72.                    
  73.                     $f0 = strtoupper( bin2hex(substr($data, $soffset + 0x60, 4)) );
  74.                     $f1 = strtoupper( bin2hex(substr($data, $soffset + 0x64, 4)) );
  75.                     $f2 = strtoupper( bin2hex(substr($data, $soffset + 0x68, 4)) );
  76.                     $f3 = strtoupper( bin2hex(substr($data, $soffset + 0x6c, 4)) );
  77.                     printf("%s, %s, %s, %s\r\n", $f0, $f1, $f2, $f3);              
  78.                    
  79.                     $soffset += 0x70;
  80.                     $size_parsed += 0x70;
  81.                 }
  82.             }
  83.            
  84.             $loffset += 0x10;
  85.         }
  86.     }
  87. }
  88.  
  89. // takes 0x50XXXXXX offset and fixes it to file offset
  90. function fix_offset($data)
  91. {
  92.     $data[0] = "\x00";
  93.     return 0x10 + array_pop(unpack("N", $data));
  94. }
  95.  
  96. function parse_int($data)
  97. {
  98.     return array_pop(unpack("N", $data));
  99. }
  100.    
  101. function parse_float($data)
  102. {
  103.     return array_pop(unpack("f", strrev($data)));
  104. }
  105.  
  106. ?>
Advertisement
Add Comment
Please, Sign In to add comment