Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.83 KB | None | 0 0
  1.     public function parse()
  2.     {
  3.         // https://github.com/stijnherfst/HiveWE/wiki/war3map.w3i---Map-Information (before version 28)
  4.         $this->data->version = $this->readLong();
  5.         $this->data->saves = $this->readLong();
  6.         $this->data->editorVersion = $this->readLong();
  7.         if ($this->data->version >= 28) {
  8.             // If the 16 bytes in the W3I you're talking about are the ones after the editor version, those represent the patch version: major, minor, patch, build
  9.             // All integers
  10.             $this->data->realVersion = $this->readTypedArray('long', 4);
  11.         }
  12.         $this->data->name = $this->readString();
  13.         $this->data->author = $this->readString();
  14.         $this->data->info = $this->readString();
  15.         $this->data->suggestedPlayers = $this->readString();
  16.  
  17.         // camera_bounds
  18.         $unusedBounds = $this->readTypedArray('float', 8);
  19.  
  20.         // camera_bounds_complements
  21.         list($a, $b, $c, $d) = $this->readTypedArray('long', 4);
  22.         $playableWidth = $this->readLong();
  23.         $playableHeight = $this->readLong();
  24.  
  25.         $this->data->fullWidth = $a + $playableWidth + $b;
  26.         $this->data->fullHeight = $c + $playableHeight + $d;
  27.         $this->data->playableWidth = $playableWidth;
  28.         $this->data->playableHeight = $playableHeight;
  29.  
  30.         $flags = $this->readLong(4);
  31.  
  32.         $this->data->flags = new \stdClass();
  33.         $this->data->flags->hideMiniMap = (bool) ($flags & 0x0001);
  34.         $this->data->flags->modifyAllyPriorities = (bool) ($flags & 0x0002);
  35.         $this->data->flags->meleeMap = (bool) ($flags & 0x0004);
  36.         $this->data->flags->playableMapSizeWasLarge = (bool) ($flags & 0x0008);
  37.         $this->data->flags->maskedAreaArePartiallyVisible = (bool) ($flags & 0x0010);
  38.         $this->data->flags->fixedPlayerSettingForCustomForces = (bool) ($flags & 0x0020);
  39.         $this->data->flags->useCustomForces = (bool) ($flags & 0x0040);
  40.         $this->data->flags->useCustomTechtree = (bool) ($flags & 0x0080);
  41.         $this->data->flags->useCustomAbilities = (bool) ($flags & 0x0100);
  42.         $this->data->flags->useCustomUpgrades = (bool) ($flags & 0x0200);
  43.         $this->data->flags->mapPropertiesMenuOpened = (bool) ($flags & 0x0400);
  44.         $this->data->flags->showWaterWavesOnCliffShores = (bool) ($flags & 0x0800);
  45.         $this->data->flags->showWaterWavesOnRollingShores = (bool) ($flags & 0x1000);
  46.  
  47.         $this->data->tileset = $this->readRaw(1);
  48.  
  49.         $this->data->loadingScreenNumber = $this->readLong();
  50.         if ($this->data->version >= 25) {
  51.             $this->data->loadingScreenModel = $this->readString();
  52.         }
  53.         $this->data->loadingScreenText = $this->readString();
  54.         $this->data->loadingScreenTitle = $this->readString();
  55.         $this->data->loadingScreenSubtitle = $this->readString();
  56.  
  57.         $this->data->gameDataSet = $this->readLong();
  58.  
  59.         if ($this->data->version >= 25) {
  60.             $this->data->prologueScreenModel = $this->readString();
  61.         }
  62.  
  63.         $this->data->prologueText = $this->readString();
  64.         $this->data->prologueTitle = $this->readString();
  65.         $this->data->prologueSubtitle = $this->readString();
  66.  
  67.         if ($this->data->version >= 25) {
  68.             $this->data->usesFog = $this->readLong();
  69.             $this->data->fogStartZHeight = $this->readFloat();
  70.             $this->data->fogEndZHeight = $this->readFloat();
  71.             $this->data->fogDensity = $this->readFloat();
  72.             $this->data->fogColorRed = $this->readRaw(1);
  73.             $this->data->fogColorGreen = $this->readRaw(1);
  74.             $this->data->fogColorBlue = $this->readRaw(1);
  75.             $this->data->fogColorAlpha = $this->readRaw(1);
  76.  
  77.             $this->data->weatherID = $this->readLong();
  78.             $this->data->customSoundEnvironment = $this->readString();
  79.             $this->data->customLightTileset = $this->readRaw(1);
  80.  
  81.             $this->data->waterColorRed = $this->readRaw(1);
  82.             $this->data->waterColorGreen = $this->readRaw(1);
  83.             $this->data->waterColorBlue = $this->readRaw(1);
  84.             $this->data->waterColorAlpha = $this->readRaw(1);
  85.         }
  86.  
  87.         if ($this->data->version >= 28) {
  88.             $this->data->isLua = $this->readLong();
  89.         }
  90.  
  91.         $this->data->players = $this->readLong();
  92.         // And more...
  93.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement