@@ -16,8 +16,8 @@ |
||
| 16 | 16 | * @param $content This block's content. |
| 17 | 17 | * @param $flags Any flags this block may have |
| 18 | 18 | */ |
| 19 | - public function CREABlock($prayfile,$name,$content,$flags) { |
|
| 20 | - parent::CreaturesArchiveBlock($prayfile,$name,$content,$flags,PRAY_BLOCK_CREA); |
|
| 19 | + public function CREABlock($prayfile, $name, $content, $flags) { |
|
| 20 | + parent::CreaturesArchiveBlock($prayfile, $name, $content, $flags, PRAY_BLOCK_CREA); |
|
| 21 | 21 | } |
| 22 | 22 | /// @cond INTERNAL_DOCS |
| 23 | 23 | |
@@ -24,31 +24,31 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | //@{ |
| 26 | 26 | /** Value: 'AGNT' */ |
| 27 | -define('PRAY_BLOCK_AGNT','AGNT'); |
|
| 27 | +define('PRAY_BLOCK_AGNT', 'AGNT'); |
|
| 28 | 28 | /** Value: 'CREA' */ |
| 29 | -define('PRAY_BLOCK_CREA','CREA'); |
|
| 29 | +define('PRAY_BLOCK_CREA', 'CREA'); |
|
| 30 | 30 | /** Value: 'DFAM' */ |
| 31 | -define('PRAY_BLOCK_DFAM','DFAM'); |
|
| 31 | +define('PRAY_BLOCK_DFAM', 'DFAM'); |
|
| 32 | 32 | /** Value: 'DSAG' */ |
| 33 | -define('PRAY_BLOCK_DSAG','DSAG'); |
|
| 33 | +define('PRAY_BLOCK_DSAG', 'DSAG'); |
|
| 34 | 34 | /** Value: 'DSEX' */ |
| 35 | -define('PRAY_BLOCK_DSEX','DSEX'); |
|
| 35 | +define('PRAY_BLOCK_DSEX', 'DSEX'); |
|
| 36 | 36 | /** Value: 'EGG' */ |
| 37 | -define('PRAY_BLOCK_EGGS' ,'EGGS' ); |
|
| 37 | +define('PRAY_BLOCK_EGGS', 'EGGS'); |
|
| 38 | 38 | /** Value: 'EXPC' */ |
| 39 | -define('PRAY_BLOCK_EXPC','EXPC'); |
|
| 39 | +define('PRAY_BLOCK_EXPC', 'EXPC'); |
|
| 40 | 40 | /** Value: 'FILE' */ |
| 41 | -define('PRAY_BLOCK_FILE','FILE'); |
|
| 41 | +define('PRAY_BLOCK_FILE', 'FILE'); |
|
| 42 | 42 | /** Value: 'GENE' */ |
| 43 | -define('PRAY_BLOCK_GENE','GENE'); |
|
| 43 | +define('PRAY_BLOCK_GENE', 'GENE'); |
|
| 44 | 44 | /** Value: 'GLST' */ |
| 45 | -define('PRAY_BLOCK_GLST','GLST'); |
|
| 45 | +define('PRAY_BLOCK_GLST', 'GLST'); |
|
| 46 | 46 | /** Value: 'LIVE' */ |
| 47 | -define('PRAY_BLOCK_LIVE','LIVE'); |
|
| 47 | +define('PRAY_BLOCK_LIVE', 'LIVE'); |
|
| 48 | 48 | /** Value: 'PHOT' */ |
| 49 | -define('PRAY_BLOCK_PHOT','PHOT'); |
|
| 49 | +define('PRAY_BLOCK_PHOT', 'PHOT'); |
|
| 50 | 50 | /** Value: 'SFAM' */ |
| 51 | -define('PRAY_BLOCK_SFAM','SFAM'); |
|
| 51 | +define('PRAY_BLOCK_SFAM', 'SFAM'); |
|
| 52 | 52 | //@} |
| 53 | 53 | |
| 54 | 54 | /** @name Flags |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | ///@{ |
| 58 | 58 | /** Value: 1*/ |
| 59 | 59 | ///Whether or not the block is zLib compressed. |
| 60 | -define('PRAY_FLAG_ZLIB_COMPRESSED',1); |
|
| 60 | +define('PRAY_FLAG_ZLIB_COMPRESSED', 1); |
|
| 61 | 61 | ///@} |
| 62 | 62 | |
| 63 | 63 | /// @brief Abstract class to represent PRAY blocks |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | * @param $flags A 1-byte integer containing the flags this PrayBlock has set |
| 84 | 84 | * @param $type The type of the PrayBlock as a PRAY_BLOCK_* constant. Must be a four-character string. |
| 85 | 85 | */ |
| 86 | - public function PrayBlock($prayfile,$name,$content,$flags,$type) { |
|
| 87 | - if(strlen($type) != 4) { |
|
| 86 | + public function PrayBlock($prayfile, $name, $content, $flags, $type) { |
|
| 87 | + if (strlen($type) != 4) { |
|
| 88 | 88 | throw new Exception('Invalid PRAY block type: '.$type); |
| 89 | 89 | } |
| 90 | - if($prayfile instanceof PRAYFile) { |
|
| 90 | + if ($prayfile instanceof PRAYFile) { |
|
| 91 | 91 | $this->prayfile = $prayfile; |
| 92 | 92 | $this->decompiled = false; |
| 93 | 93 | } else { |
@@ -105,18 +105,18 @@ discard block |
||
| 105 | 105 | * @param $length length of the data that will be written to the block |
| 106 | 106 | * @param $uncompressedlength length of the data when uncompressed, etc. |
| 107 | 107 | */ |
| 108 | - protected function EncodeBlockHeader($length,$uncompressedlength=false) { |
|
| 108 | + protected function EncodeBlockHeader($length, $uncompressedlength = false) { |
|
| 109 | 109 | $compiled = $this->GetType(); |
| 110 | - $compiled .= substr($this->GetName(),0,128); |
|
| 111 | - $len = 128 - strlen($this->GetName()); |
|
| 110 | + $compiled .= substr($this->GetName(), 0, 128); |
|
| 111 | + $len = 128-strlen($this->GetName()); |
|
| 112 | 112 | |
| 113 | - for($i=0;$i<$len;$i++) { |
|
| 113 | + for ($i = 0; $i < $len; $i++) { |
|
| 114 | 114 | $compiled .= pack('x'); |
| 115 | 115 | } |
| 116 | - if($uncompressedlength === false) { |
|
| 116 | + if ($uncompressedlength === false) { |
|
| 117 | 117 | $uncompressedlength = $length; |
| 118 | 118 | } |
| 119 | - $compiled .= pack('VVV',$length,$uncompressedlength,$this->flags); |
|
| 119 | + $compiled .= pack('VVV', $length, $uncompressedlength, $this->flags); |
|
| 120 | 120 | return $compiled; |
| 121 | 121 | } |
| 122 | 122 | /// @endcond |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @return the data, having been transformed. |
| 131 | 131 | */ |
| 132 | 132 | protected function PerformFlagOperations($data) { |
| 133 | - if($this->IsFlagSet(PRAY_FLAG_ZLIB_COMPRESSED)) { |
|
| 133 | + if ($this->IsFlagSet(PRAY_FLAG_ZLIB_COMPRESSED)) { |
|
| 134 | 134 | $data = gzcompress($data); |
| 135 | 135 | } |
| 136 | 136 | return $data; |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | * return the PRAY block's binary data. |
| 152 | 152 | */ |
| 153 | 153 | public function GetData() { |
| 154 | - if($this->decompiled) { |
|
| 154 | + if ($this->decompiled) { |
|
| 155 | 155 | throw new Exception('Can\'t get data on a decompiled PRAYBlock. It must be compiled first'); |
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | - if($this->IsFlagSet(PRAY_FLAG_ZLIB_COMPRESSED)) { |
|
| 158 | + if ($this->IsFlagSet(PRAY_FLAG_ZLIB_COMPRESSED)) { |
|
| 159 | 159 | $this->content = gzuncompress($this->content); |
| 160 | 160 | $this->SetFlagsOff(PRAY_FLAG_ZLIB_COMPRESSED); |
| 161 | 161 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * Call this function at the beginning of every function that returns data in superclasses so that data decoding is automatic. |
| 234 | 234 | */ |
| 235 | 235 | protected function EnsureDecompiled() { |
| 236 | - if($this->decompiled) { |
|
| 236 | + if ($this->decompiled) { |
|
| 237 | 237 | return; |
| 238 | 238 | } else { |
| 239 | 239 | $this->DecompileBlockData(); |
@@ -251,18 +251,18 @@ discard block |
||
| 251 | 251 | * This function is mainly intended for use by PRAYFiles. |
| 252 | 252 | */ |
| 253 | 253 | public function Compile() { |
| 254 | - if($this->decompiled) { |
|
| 254 | + if ($this->decompiled) { |
|
| 255 | 255 | $data = $this->CompileBlockData(); |
| 256 | 256 | $uclength = strlen($data); |
| 257 | 257 | $data = $this->PerformFlagOperations($data); |
| 258 | - $compiled = $this->EncodeBlockHeader(strlen($data),$uclength); |
|
| 258 | + $compiled = $this->EncodeBlockHeader(strlen($data), $uclength); |
|
| 259 | 259 | $compiled .= $data; |
| 260 | 260 | $this->content = $data; |
| 261 | 261 | $this->decompiled = false; |
| 262 | 262 | return $compiled; |
| 263 | 263 | } else { |
| 264 | 264 | $data = $this->PerformFlagOperations($this->content); |
| 265 | - $compiled = $this->EncodeBlockHeader(strlen($this->content),strlen($data)); |
|
| 265 | + $compiled = $this->EncodeBlockHeader(strlen($this->content), strlen($data)); |
|
| 266 | 266 | $compiled .= $this->content; |
| 267 | 267 | return $compiled; |
| 268 | 268 | } |
@@ -293,50 +293,50 @@ discard block |
||
| 293 | 293 | * @param $flags The flags given to this PRAYBlock as an integer. |
| 294 | 294 | * return An object that is an instance of a subclass of PrayBlock. |
| 295 | 295 | */ |
| 296 | - public static function MakePrayBlock($blocktype,PRAYFile $prayfile,$name,$content,$flags) { |
|
| 297 | - switch($blocktype) { |
|
| 296 | + public static function MakePrayBlock($blocktype, PRAYFile $prayfile, $name, $content, $flags) { |
|
| 297 | + switch ($blocktype) { |
|
| 298 | 298 | //agents |
| 299 | 299 | case PRAY_BLOCK_AGNT: |
| 300 | - return new AGNTBlock($prayfile,$name,$content,$flags); |
|
| 300 | + return new AGNTBlock($prayfile, $name, $content, $flags); |
|
| 301 | 301 | case PRAY_BLOCK_DSAG: |
| 302 | - return new DSAGBlock($prayfile,$name,$content,$flags); |
|
| 302 | + return new DSAGBlock($prayfile, $name, $content, $flags); |
|
| 303 | 303 | case PRAY_BLOCK_LIVE: |
| 304 | - return new LIVEBlock($prayfile,$name,$content,$flags); //sea monkeys agent files. |
|
| 304 | + return new LIVEBlock($prayfile, $name, $content, $flags); //sea monkeys agent files. |
|
| 305 | 305 | |
| 306 | 306 | //egg |
| 307 | 307 | case PRAY_BLOCK_EGGS: |
| 308 | - return new EGGSBlock($prayfile,$name,$content,$flags); |
|
| 308 | + return new EGGSBlock($prayfile, $name, $content, $flags); |
|
| 309 | 309 | |
| 310 | 310 | //starter families |
| 311 | 311 | case PRAY_BLOCK_DFAM: |
| 312 | - return new DFAMBlock($prayfile,$name,$content,$flags); |
|
| 312 | + return new DFAMBlock($prayfile, $name, $content, $flags); |
|
| 313 | 313 | case PRAY_BLOCK_SFAM: |
| 314 | - return new SFAMBlock($prayfile,$name,$content,$flags); |
|
| 314 | + return new SFAMBlock($prayfile, $name, $content, $flags); |
|
| 315 | 315 | |
| 316 | 316 | //exported creatures |
| 317 | 317 | case PRAY_BLOCK_EXPC: |
| 318 | - return new EXPCBlock($prayfile,$name,$content,$flags); |
|
| 318 | + return new EXPCBlock($prayfile, $name, $content, $flags); |
|
| 319 | 319 | case PRAY_BLOCK_DSEX: |
| 320 | - return new DSEXBlock($prayfile,$name,$content,$flags); |
|
| 320 | + return new DSEXBlock($prayfile, $name, $content, $flags); |
|
| 321 | 321 | |
| 322 | 322 | case PRAY_BLOCK_CREA: |
| 323 | - return new CREABlock($prayfile,$name,$content,$flags); |
|
| 323 | + return new CREABlock($prayfile, $name, $content, $flags); |
|
| 324 | 324 | |
| 325 | 325 | //creature photos |
| 326 | 326 | case PRAY_BLOCK_PHOT: |
| 327 | - return new PHOTBlock($prayfile,$name,$content,$flags); |
|
| 327 | + return new PHOTBlock($prayfile, $name, $content, $flags); |
|
| 328 | 328 | |
| 329 | 329 | //creature history |
| 330 | 330 | case PRAY_BLOCK_GLST: |
| 331 | - return new GLSTBlock($prayfile,$name,$content,$flags); |
|
| 331 | + return new GLSTBlock($prayfile, $name, $content, $flags); |
|
| 332 | 332 | |
| 333 | 333 | //creature genetics |
| 334 | 334 | case PRAY_BLOCK_GENE: |
| 335 | - return new GENEBlock($prayfile,$name,$content,$flags); |
|
| 335 | + return new GENEBlock($prayfile, $name, $content, $flags); |
|
| 336 | 336 | |
| 337 | 337 | //files |
| 338 | 338 | case PRAY_BLOCK_FILE: |
| 339 | - return new FILEBlock($prayfile,$name,$content,$flags); |
|
| 339 | + return new FILEBlock($prayfile, $name, $content, $flags); |
|
| 340 | 340 | |
| 341 | 341 | default: |
| 342 | 342 | return null; |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | * @param $flags Any flags this block may have. I think this is a |
| 20 | 20 | * single byte. Check http://www.creatureswiki.net/wiki/PRAY |
| 21 | 21 | */ |
| 22 | - public function EGGSBlock($prayfile,$name,$content,$flags) { |
|
| 23 | - parent::TagBlock($prayfile,$name,$content,$flags,PRAY_BLOCK_EGGS); |
|
| 22 | + public function EGGSBlock($prayfile, $name, $content, $flags) { |
|
| 23 | + parent::TagBlock($prayfile, $name, $content, $flags, PRAY_BLOCK_EGGS); |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | |
@@ -20,8 +20,8 @@ |
||
| 20 | 20 | * @param $flags The block's flags. See PrayBlock. |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | - public function LIVEBlock($prayfile,$name,$content,$flags) { |
|
| 24 | - parent::TagBlock($prayfile,$name,$content,$flags,PRAY_BLOCK_LIVE); |
|
| 23 | + public function LIVEBlock($prayfile, $name, $content, $flags) { |
|
| 24 | + parent::TagBlock($prayfile, $name, $content, $flags, PRAY_BLOCK_LIVE); |
|
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -20,21 +20,21 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | ///@{ |
| 22 | 22 | /// Value: 1 |
| 23 | -define('PRAY_DEPENDENCY_SOUND',1); |
|
| 23 | +define('PRAY_DEPENDENCY_SOUND', 1); |
|
| 24 | 24 | /// Value: 2 |
| 25 | -define('PRAY_DEPENDENCY_IMAGE',2); |
|
| 25 | +define('PRAY_DEPENDENCY_IMAGE', 2); |
|
| 26 | 26 | /// Value: 3 |
| 27 | -define('PRAY_DEPENDENCY_GENE',3); |
|
| 27 | +define('PRAY_DEPENDENCY_GENE', 3); |
|
| 28 | 28 | /// Value: 4 |
| 29 | -define('PRAY_DEPENDENCY_BODYDATA',4); |
|
| 29 | +define('PRAY_DEPENDENCY_BODYDATA', 4); |
|
| 30 | 30 | /// Value: 5 |
| 31 | -define('PRAY_DEPENDENCY_OVERLAY',5); |
|
| 31 | +define('PRAY_DEPENDENCY_OVERLAY', 5); |
|
| 32 | 32 | /// Value: 6 |
| 33 | -define('PRAY_DEPENDENCY_BACKGROUND',6); |
|
| 33 | +define('PRAY_DEPENDENCY_BACKGROUND', 6); |
|
| 34 | 34 | /// Value: 7 |
| 35 | -define('PRAY_DEPENDENCY_CATALOGUE',7); |
|
| 35 | +define('PRAY_DEPENDENCY_CATALOGUE', 7); |
|
| 36 | 36 | /// Value: 10 |
| 37 | -define('PRAY_DEPENDENCY_CREATURE',10); |
|
| 37 | +define('PRAY_DEPENDENCY_CREATURE', 10); |
|
| 38 | 38 | //@} |
| 39 | 39 | |
| 40 | 40 | /// @brief Dependency class used in various PrayBlocks. |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param $category One of the PRAY_DEPENDENCY_* constants |
| 55 | 55 | * @param $filename The name of the file this dependency relates to. |
| 56 | 56 | */ |
| 57 | - public function PrayDependency($category,$filename) { |
|
| 57 | + public function PrayDependency($category, $filename) { |
|
| 58 | 58 | $this->category = $category; |
| 59 | 59 | $this->filename = $filename; |
| 60 | 60 | } |
@@ -36,8 +36,8 @@ |
||
| 36 | 36 | * @param $content The binary data of this block. May be null. |
| 37 | 37 | * @param $flags The block's flags |
| 38 | 38 | */ |
| 39 | - public function EXPCBlock($prayfile,$name,$content,$flags) { |
|
| 40 | - parent::TagBlock($prayfile,$name,$content,$flags,PRAY_BLOCK_EXPC); |
|
| 39 | + public function EXPCBlock($prayfile, $name, $content, $flags) { |
|
| 40 | + parent::TagBlock($prayfile, $name, $content, $flags, PRAY_BLOCK_EXPC); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /// @brief Gets the age of the creature |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | * @param $name The block's name. |
| 23 | 23 | * @param $content The content of the block as a binary string. |
| 24 | 24 | */ |
| 25 | - public function BinaryBlock($type,$name,$content) { |
|
| 26 | - parent::PrayBlock(null,$name,'',0,$type); |
|
| 25 | + public function BinaryBlock($type, $name, $content) { |
|
| 26 | + parent::PrayBlock(null, $name, '', 0, $type); |
|
| 27 | 27 | $this->binarydata = $content; |
| 28 | 28 | } |
| 29 | 29 | /// @brief Compile the BinaryBlock |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | * @param $flags the flags of this block |
| 18 | 18 | * @param $type This block's type as one of the PRAY_BLOCK_* constants |
| 19 | 19 | */ |
| 20 | - public function CreaturesArchiveBlock(&$prayfile,$name,$content,$flags,$type) { |
|
| 21 | - parent::PrayBlock($prayfile,$name,$content,$flags,$type); |
|
| 22 | - if($prayfile instanceof PRAYFile) { |
|
| 23 | - if(!$this->DeArchive()) { |
|
| 20 | + public function CreaturesArchiveBlock(&$prayfile, $name, $content, $flags, $type) { |
|
| 21 | + parent::PrayBlock($prayfile, $name, $content, $flags, $type); |
|
| 22 | + if ($prayfile instanceof PRAYFile) { |
|
| 23 | + if (!$this->DeArchive()) { |
|
| 24 | 24 | throw new Exception('De-Archiving failed, block probably wasn\'t a CreaturesArchive type'); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | /// DeArchives this block |
| 31 | 31 | private function DeArchive() { |
| 32 | 32 | $content = $this->GetData(); |
| 33 | - if($content{0} == 'C') { |
|
| 33 | + if ($content{0} == 'C') { |
|
| 34 | 34 | $content = DeArchive($content); |
| 35 | - if($content !== false) {
|
|
| 35 | + if ($content !== false) {
|
|
| 36 | 36 | $this->SetData($content); |
| 37 | 37 | return true; |
| 38 | 38 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | ///@{ |
| 11 | 11 | |
| 12 | 12 | /** Value: 0 */ |
| 13 | -define('GLST_FORMAT_UNKNOWN',0); |
|
| 13 | +define('GLST_FORMAT_UNKNOWN', 0); |
|
| 14 | 14 | /** Value: 1 */ |
| 15 | -define('GLST_FORMAT_C3',1); |
|
| 15 | +define('GLST_FORMAT_C3', 1); |
|
| 16 | 16 | /** Value: 2 */ |
| 17 | -define('GLST_FORMAT_DS',2); |
|
| 17 | +define('GLST_FORMAT_DS', 2); |
|
| 18 | 18 | //@} |
| 19 | 19 | |
| 20 | 20 | /// @brief PRAY Block for Creature History Data. |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | * @param $content The binary data of this file block. |
| 39 | 39 | * @param $flags The block's flags. See PrayBlock. |
| 40 | 40 | */ |
| 41 | - public function GLSTBlock($object,$name,$content,$flags) { |
|
| 42 | - parent::CreaturesArchiveBlock($object,$name,$content,$flags,PRAY_BLOCK_GLST); |
|
| 43 | - if($object instanceof PRAYFile) { |
|
| 41 | + public function GLSTBlock($object, $name, $content, $flags) { |
|
| 42 | + parent::CreaturesArchiveBlock($object, $name, $content, $flags, PRAY_BLOCK_GLST); |
|
| 43 | + if ($object instanceof PRAYFile) { |
|
| 44 | 44 | //Do nothing! Decoding is automated later now :) |
| 45 | - } else if($object instanceof CreatureHistory) { |
|
| 45 | + } else if ($object instanceof CreatureHistory) { |
|
| 46 | 46 | $this->history = $object; |
| 47 | 47 | } else { |
| 48 | 48 | throw new Exception('Couldn\'t create a GLST block. :('); |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | /// @brief Tries to work out which game this GLSTBlock is from |
| 53 | 53 | private function GuessFormat() { |
| 54 | 54 | //if I don't know |
| 55 | - if($this->format == GLST_FORMAT_UNKNOWN) { |
|
| 55 | + if ($this->format == GLST_FORMAT_UNKNOWN) { |
|
| 56 | 56 | //ask $prayfile if it exists. (look for DSEX, otherwise C3) |
| 57 | - if($this->prayfile != null) { |
|
| 57 | + if ($this->prayfile != null) { |
|
| 58 | 58 | //prayfile should know |
| 59 | - if(sizeof($this->prayfile->GetBlocks(PRAY_BLOCK_DSEX)) > 0) { |
|
| 59 | + if (sizeof($this->prayfile->GetBlocks(PRAY_BLOCK_DSEX)) > 0) { |
|
| 60 | 60 | $format = GLST_FORMAT_DS; |
| 61 | 61 | } else { |
| 62 | 62 | $format = GLST_FORMAT_C3; |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function GetPHOTBlockName(CreatureHistoryEvent $event) { |
| 93 | 93 | $photoname = $event->GetPhotoGraph(); |
| 94 | - if(empty($photoname)) { |
|
| 94 | + if (empty($photoname)) { |
|
| 95 | 95 | return null; |
| 96 | 96 | } |
| 97 | - if($this->format == GLST_FORMAT_DS) { |
|
| 97 | + if ($this->format == GLST_FORMAT_DS) { |
|
| 98 | 98 | return $photoname.'.DSEX.photo'; |
| 99 | 99 | } else { |
| 100 | 100 | return $photoname.'.photo'; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * and handle errors. |
| 110 | 110 | */ |
| 111 | 111 | public function GetPhotoBlock(CreatureHistoryEvent $event) { |
| 112 | - if($this->GetPrayFile() instanceof PRAYFile) { |
|
| 112 | + if ($this->GetPrayFile() instanceof PRAYFile) { |
|
| 113 | 113 | return $block = $this->GetPrayFile()->GetBlockByName($this->GetPHOTBlockName()); |
| 114 | 114 | } else { |
| 115 | 115 | throw new Exception("This GLSTBlock is not connected to a PRAYFile."); |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | protected function DecompileBlockData() { |
| 124 | 124 | $reader = new StringReader($this->GetData()); |
| 125 | 125 | $firstchar = $reader->Read(1); |
| 126 | - if($firstchar == chr(0x27)) { //apostrophe thing |
|
| 126 | + if ($firstchar == chr(0x27)) { //apostrophe thing |
|
| 127 | 127 | //ds |
| 128 | 128 | $this->format = GLST_FORMAT_DS; |
| 129 | - } else if($firstchar == chr(0x0C)) { //control character |
|
| 129 | + } else if ($firstchar == chr(0x0C)) { //control character |
|
| 130 | 130 | //c3 |
| 131 | 131 | $this->format = GLST_FORMAT_C3; |
| 132 | 132 | } else { |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | //the first four bytes including $firstchar are probably one integer used to identify the game used. |
| 136 | 136 | //We read the first one above and now we're skipping the next three. |
| 137 | 137 | $reader->Skip(3); // 3 nulls. |
| 138 | - if($reader->ReadInt(4)!=1) { //Always 1, don't know why. |
|
| 138 | + if ($reader->ReadInt(4) != 1) { //Always 1, don't know why. |
|
| 139 | 139 | throw new Exception('Either the GLST Block is corrupt or I don\'t understand what the 2nd set of 4 bytes mean.'); |
| 140 | 140 | return false; |
| 141 | 141 | } |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | $species = $reader->ReadInt(4); |
| 148 | 148 | $eventslength = $reader->ReadInt(4); |
| 149 | 149 | |
| 150 | - $this->history = new CreatureHistory($moniker,$name,$gender,$genus,$species); |
|
| 151 | - if(!isset($eventslength)) { |
|
| 150 | + $this->history = new CreatureHistory($moniker, $name, $gender, $genus, $species); |
|
| 151 | + if (!isset($eventslength)) { |
|
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | - for($i=0;$i<$eventslength;$i++) { |
|
| 154 | + for ($i = 0; $i < $eventslength; $i++) { |
|
| 155 | 155 | $this->DecodeEvent($reader); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | $mutations = $reader->ReadInt(4); |
| 160 | 160 | $crossovers = $reader->ReadInt(4); |
| 161 | 161 | |
| 162 | - $this->history->SetMutationsAndCrossovers($mutations,$crossovers); |
|
| 162 | + $this->history->SetMutationsAndCrossovers($mutations, $crossovers); |
|
| 163 | 163 | |
| 164 | - if($this->format == GLST_FORMAT_DS) { |
|
| 164 | + if ($this->format == GLST_FORMAT_DS) { |
|
| 165 | 165 | $unknown1 = $reader->ReadInt(4); |
| 166 | - $warpveteran = (($reader->ReadInt(4)==1)?1:0); |
|
| 166 | + $warpveteran = (($reader->ReadInt(4) == 1) ? 1 : 0); |
|
| 167 | 167 | $unknown2 = $reader->Read($reader->ReadInt(4)); |
| 168 | - $this->history->SetDSUnknowns($unknown1,$unknown2); |
|
| 168 | + $this->history->SetDSUnknowns($unknown1, $unknown2); |
|
| 169 | 169 | $this->history->SetWarpVeteran($warpveteran); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | private function DecodeEvent($reader) { |
| 176 | 176 | $eventNumber = $reader->ReadInt(4); |
| 177 | 177 | //echo 'Event '.$eventNumber."\n"; |
| 178 | - if($eventNumber < 18) { |
|
| 178 | + if ($eventNumber < 18) { |
|
| 179 | 179 | $eventnumber = $eventNumber; |
| 180 | 180 | $worldtime = $reader->ReadInt(4); |
| 181 | 181 | $creatureage = $reader->ReadInt(4); |
@@ -187,14 +187,14 @@ discard block |
||
| 187 | 187 | $photograph = $reader->Read($reader->ReadInt(4)); |
| 188 | 188 | $worldname = $reader->Read($reader->ReadInt(4)); |
| 189 | 189 | $worldUID = $reader->Read($reader->ReadInt(4)); |
| 190 | - $event = new CreatureHistoryEvent($eventnumber,$worldtime,$creatureage, |
|
| 191 | - $timestamp,$lifestage,$moniker,$moniker2,$usertext,$photograph, |
|
| 192 | - $worldname,$worldUID); |
|
| 193 | - if($this->format == GLST_FORMAT_DS) { |
|
| 190 | + $event = new CreatureHistoryEvent($eventnumber, $worldtime, $creatureage, |
|
| 191 | + $timestamp, $lifestage, $moniker, $moniker2, $usertext, $photograph, |
|
| 192 | + $worldname, $worldUID); |
|
| 193 | + if ($this->format == GLST_FORMAT_DS) { |
|
| 194 | 194 | $DSUser = $reader->Read($reader->ReadInt(4)); |
| 195 | 195 | $unknown1 = $reader->ReadInt(4); |
| 196 | 196 | $unknown2 = $reader->ReadInt(4); |
| 197 | - $event->AddDSInfo($DSUser,$unknown1,$unknown2); |
|
| 197 | + $event->AddDSInfo($DSUser, $unknown1, $unknown2); |
|
| 198 | 198 | } |
| 199 | 199 | $this->history->AddEvent($event); |
| 200 | 200 | return true; |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | * @param $format One of the GLST_FORMAT_* constants |
| 209 | 209 | * @return The compiled block data for Compile() |
| 210 | 210 | */ |
| 211 | - protected function CompileBlockData($format=GLST_FORMAT_UNKNOWN) { |
|
| 211 | + protected function CompileBlockData($format = GLST_FORMAT_UNKNOWN) { |
|
| 212 | 212 | //if you don't know |
| 213 | - if($format == GLST_FORMAT_UNKNOWN) { |
|
| 213 | + if ($format == GLST_FORMAT_UNKNOWN) { |
|
| 214 | 214 | $format = $this->GuessFormat(); |
| 215 | 215 | } |
| 216 | 216 | $compiled = Archive($this->history->Compile($format)); |