Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function ReadByte($file) {
- return unpack("C", fgets($file,2))[1];
- }
- function ReadInt($file) {
- return unpack("i", fgets($file,5))[1];
- }
- function ReadString($file) {
- return trim(fgets($file));
- }
- $map = "de_cs2d";
- $file = fopen("$map.map", "r");
- // Header
- $header = ReadString($file);
- if ($header != "Unreal Software's Counter-Strike 2D Map File (max)") {
- exit("The header is not supported\n");
- }
- // 10 bytes for map settings
- ReadByte($file);
- $modifiers = ReadByte($file);
- ReadByte($file);
- ReadByte($file);
- ReadByte($file);
- ReadByte($file);
- ReadByte($file);
- ReadByte($file);
- ReadByte($file);
- ReadByte($file);
- // 10 ints for map settings
- ReadInt($file);
- ReadInt($file);
- ReadInt($file);
- ReadInt($file);
- ReadInt($file);
- ReadInt($file);
- ReadInt($file);
- ReadInt($file);
- ReadInt($file);
- ReadInt($file);
- // 10 strings for map settings
- ReadString($file);
- ReadString($file);
- ReadString($file);
- ReadString($file);
- ReadString($file);
- ReadString($file);
- ReadString($file);
- ReadString($file);
- ReadString($file);
- ReadString($file);
- // More map settings
- ReadString($file);
- ReadString($file);
- $tiles = ReadByte($file);
- $map_xsize = ReadInt($file);
- $map_ysize = ReadInt($file);
- ReadString($file);
- ReadInt($file);
- ReadInt($file);
- ReadByte($file);
- ReadByte($file);
- ReadByte($file);
- // Header Test
- $test = ReadString($file);
- if ($test != "ed.erawtfoslaernu") {
- exit("The header is corrupted\n");
- }
- // Tile Modes
- for ($i = 0; $i <= $tiles; $i++) {
- $mode = ReadByte($file);
- echo "$i = $mode\n";
- }
- // Map
- for ($x = 0; $x <= $map_xsize; $x++) {
- for ($y = 0; $y <= $map_ysize; $y++) {
- $tile = ReadByte($file);
- echo "$x|$y = $tile\n";
- }
- }
- // Modifiers
- if ($modifiers == 1) {
- exit("The modifiers are not supported\n");
- }
- // Entities
- $entity_count = ReadInt($file);
- for ($j = 1; $j <= $entity_count; $j++) {
- ReadString($file);
- $entity_type = ReadByte($file);
- $entity_x = ReadInt($file);
- $entity_y = ReadInt($file);
- ReadString($file);
- echo "$entity_x|$entity_y = $entity_type\n";
- for ($k = 1; $k <= 10; $k++) {
- ReadInt($file);
- ReadString($file);
- }
- }
- // End of file
- fclose($file);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement