GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch master (9269d3)
by Telyn
03:20
created
agents/PRAY/TagBlock.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      * @param $name The name of the block. Cannot be null.
26 26
      * @param $content The binary data this block contains. Can be null.
27 27
      * @param $flags The flags relating to this block. Should be zero or real flags.
28
-     * @param $type The block's 4-character type. Must be defined.
28
+     * @param string $type The block's 4-character type. Must be defined.
29 29
      */
30 30
     public function TagBlock($prayfile,$name,$content,$flags,$type) {
31 31
         parent::PrayBlock($prayfile,$name,$content,$flags,$type);
@@ -40,6 +40,7 @@  discard block
 block discarded – undo
40 40
     /**
41 41
      * Returns the tag's value as a string, or
42 42
      * nothing if the tag doesn't exist.
43
+     * @param string $key
43 44
      */
44 45
     public function GetTag($key) {
45 46
         $this->EnsureDecompiled();
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
      * @param $flags The flags relating to this block. Should be zero or real flags.
28 28
      * @param $type The block's 4-character type. Must be defined.
29 29
      */
30
-    public function TagBlock($prayfile,$name,$content,$flags,$type) {
31
-        parent::PrayBlock($prayfile,$name,$content,$flags,$type);
32
-        if($prayfile instanceof PRAYFile) {
33
-        } else if(is_array($prayfile)) {
30
+    public function TagBlock($prayfile, $name, $content, $flags, $type) {
31
+        parent::PrayBlock($prayfile, $name, $content, $flags, $type);
32
+        if ($prayfile instanceof PRAYFile) {
33
+        } else if (is_array($prayfile)) {
34 34
             $this->tags = $prayfile;
35 35
         }
36 36
     }
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function GetTag($key) {
45 45
         $this->EnsureDecompiled();
46
-        foreach($this->tags as $tk => $tv) {
47
-            if($key == $tk) {
46
+        foreach ($this->tags as $tk => $tv) {
47
+            if ($key == $tk) {
48 48
                 return $tv;
49 49
             }
50 50
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @param $tag Name of the tag to set
67 67
      * @param $value The value to set the tag to
68 68
      */
69
-    public function SetTag($tag,$value) {
69
+    public function SetTag($tag, $value) {
70 70
         $this->EnsureDecompiled();
71 71
         $this->tags[$tag] = $value;
72 72
     }
@@ -82,24 +82,24 @@  discard block
 block discarded – undo
82 82
         $compiled = '';
83 83
         $ints = array();
84 84
         $strings = array();
85
-        foreach($this->tags as $key=>$value) {
86
-            if(is_int($value)) {
85
+        foreach ($this->tags as $key=>$value) {
86
+            if (is_int($value)) {
87 87
                 $ints[$key] = $value;
88 88
             } else {
89 89
                 $strings[$key] = $value;
90 90
             }
91 91
         }
92
-        $compiled .= pack('V',sizeof($ints));
93
-        foreach($ints as $key=>$value) {
94
-            $compiled .= pack('V',strlen($key));
92
+        $compiled .= pack('V', sizeof($ints));
93
+        foreach ($ints as $key=>$value) {
94
+            $compiled .= pack('V', strlen($key));
95 95
             $compiled .= $key;
96
-            $compiled .= pack('V',$value);
96
+            $compiled .= pack('V', $value);
97 97
         }
98
-        $compiled .= pack('V',sizeof($strings));
99
-        foreach($strings as $key=>$value) {
100
-            $compiled .= pack('V',strlen($key));
98
+        $compiled .= pack('V', sizeof($strings));
99
+        foreach ($strings as $key=>$value) {
100
+            $compiled .= pack('V', strlen($key));
101 101
             $compiled .= $key;
102
-            $compiled .= pack('V',strlen($value));
102
+            $compiled .= pack('V', strlen($value));
103 103
             $compiled .= $value;
104 104
         }
105 105
         return $compiled;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         $blockReader = new StringReader($this->GetData());
115 115
         
116 116
         $numInts = $blockReader->ReadInt(4);
117
-        for($i=0;$i<$numInts;$i++) {
117
+        for ($i = 0; $i < $numInts; $i++) {
118 118
             $nameLength = $blockReader->ReadInt(4);
119 119
             $name = $blockReader->Read($nameLength);
120 120
             $int = $blockReader->ReadInt(4);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         
124 124
         
125 125
         $numStrings = $blockReader->ReadInt(4);
126
-        for($i=0;$i<$numStrings;$i++) {
126
+        for ($i = 0; $i < $numStrings; $i++) {
127 127
             $nameLength = $blockReader->ReadInt(4);
128 128
             $name = $blockReader->Read($nameLength);
129 129
             $stringLength = $blockReader->ReadInt(4);
Please login to merge, or discard this patch.
agents/PRAYFile.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 
58 58
     /// @brief Compiles the PRAYFile.
59 59
     /**
60
-     * @return A binary string containing the PRAYFile's contents.
60
+     * @return string binary string containing the PRAYFile's contents.
61 61
      */
62 62
     public function Compile() {
63 63
         $compiled = 'PRAY';
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     /// @cond INTERNAL_DOCS
13 13
 
14 14
     private $reader;
15
-    private $blocks=array();
15
+    private $blocks = array();
16 16
     private $parsed = false;
17 17
 
18 18
     /// @endcond
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
      * @param $reader The IReader to read from. If null, means this
24 24
      * is a user-generated PRAYFile.
25 25
      */
26
-    function PRAYFile($reader=null) {
26
+    function PRAYFile($reader = null) {
27 27
         $this->blocks = array();
28
-        if($reader instanceof IReader) {
28
+        if ($reader instanceof IReader) {
29 29
             $this->reader = $reader;
30 30
             $this->Parse();
31 31
         } else {
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 
38 38
     /// @brief Reads the PRAYFile stored in the reader. Called automatically.
39 39
     private function Parse() {
40
-        if(!$this->parsed) {
41
-            if($this->ParseHeader()) {
42
-                while($this->ParseBlockHeader()) {
40
+        if (!$this->parsed) {
41
+            if ($this->ParseHeader()) {
42
+                while ($this->ParseBlockHeader()) {
43 43
                 }
44 44
                 $this->parsed = true;
45 45
                 //print_r($this->blocks);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function Compile() {
63 63
         $compiled = 'PRAY';
64
-        foreach($this->blocks as $block) {
64
+        foreach ($this->blocks as $block) {
65 65
             $compiled .= $block->Compile();
66 66
         }
67 67
         return $compiled;
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
      * @param $block The PrayBlock to add.
73 73
      */
74 74
     public function AddBlock(PrayBlock $block) {
75
-        foreach($this->blocks as $checkBlock) {
76
-            if($checkBlock->GetName() == $block->GetName()) {
75
+        foreach ($this->blocks as $checkBlock) {
76
+            if ($checkBlock->GetName() == $block->GetName()) {
77 77
                 throw new Exception("PRAY Files cannot contain multiple blocks with the same name");
78 78
             }
79 79
         }
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
      * @param $type The type(s) of blocks to return, as the
89 89
      * PRAYBLOCK_TYPE_* constants. (see PrayBlock for block types)
90 90
      */
91
-    public function GetBlocks($type=FALSE) { //gets all blocks or one type of block
92
-        if(!$type) {
91
+    public function GetBlocks($type = FALSE) { //gets all blocks or one type of block
92
+        if (!$type) {
93 93
             return $this->blocks;
94 94
         } else {
95
-            if(is_string($type)) {
95
+            if (is_string($type)) {
96 96
                 $type = array($type);
97 97
             }
98 98
             $retblocks = array();
99
-            foreach($this->blocks as $block) {
100
-                if(in_array($block->GetType(),$type)) {
99
+            foreach ($this->blocks as $block) {
100
+                if (in_array($block->GetType(), $type)) {
101 101
                     $retblocks[] = $block;
102 102
                 }
103 103
             }
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
      * for a particular CreatureHistoryEvent, for example.
112 112
      */
113 113
     public function GetBlockByName($name) {
114
-        foreach($this->blocks as $blockid => $block) {
114
+        foreach ($this->blocks as $blockid => $block) {
115 115
 
116
-            if($block->GetName() == $name) {
116
+            if ($block->GetName() == $name) {
117 117
                 return $block;
118 118
             }
119 119
         }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      *  It's not much of a header, but it's a header nonetheless.
128 128
      */
129 129
     private function ParseHeader() {
130
-        if($this->reader->Read(4) == "PRAY") {
130
+        if ($this->reader->Read(4) == "PRAY") {
131 131
             return true;
132 132
         } else {
133 133
             return false;
@@ -143,28 +143,28 @@  discard block
 block discarded – undo
143 143
      */
144 144
     private function ParseBlockHeader() {
145 145
         $blocktype = $this->reader->Read(4);
146
-        if($blocktype=="") {
146
+        if ($blocktype == "") {
147 147
             return false;
148 148
         }
149 149
         $name = trim($this->reader->Read(128));
150
-        if($name=="") {
150
+        if ($name == "") {
151 151
             return false;
152 152
         }
153 153
         $length = $this->reader->ReadInt(4);
154
-        if($length===false) {
154
+        if ($length === false) {
155 155
             return false;
156 156
         }
157 157
         $fulllength = $this->reader->ReadInt(4); //full means uncompressed
158
-        if($fulllength===false) {
158
+        if ($fulllength === false) {
159 159
             return false;
160 160
         }
161 161
         $flags = $this->reader->ReadInt(4);
162
-        if($flags===false) {
162
+        if ($flags === false) {
163 163
             return false;
164 164
         }
165 165
 
166 166
         $content = $this->reader->Read($length);
167
-        $this->blocks[] = PrayBlock::MakePrayBlock($blocktype,$this,$name,$content,$flags);
167
+        $this->blocks[] = PrayBlock::MakePrayBlock($blocktype, $this, $name, $content, $flags);
168 168
 
169 169
         return true;
170 170
     }
Please login to merge, or discard this patch.
sprites/C16File.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
     }
54 54
     /// @brief Compiles the file's data into a C16 binary string
55 55
     /**
56
-     * @return A binary string containing the C16File's data.
56
+     * @return string binary string containing the C16File's data.
57 57
      */
58 58
     public function Compile() {
59 59
         $data = ''; 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -16,30 +16,30 @@  discard block
 block discarded – undo
16 16
      * If $reader is null, creates an empty C16File ready to add sprites to.
17 17
      * @param $reader The reader to read the sprites from. Can be null.
18 18
      */
19
-    public function C16File(IReader $reader=null)
19
+    public function C16File(IReader $reader = null)
20 20
     {
21
-        if($reader != null) {
21
+        if ($reader != null) {
22 22
             parent::SpriteFile('C16');
23 23
             $buffer = $reader->ReadInt(4);
24
-            if(($buffer & 1) == 1) {
24
+            if (($buffer & 1) == 1) {
25 25
                 $this->encoding = '565';
26 26
             } else {
27 27
                 $this->encoding = '555';
28 28
             }
29 29
 
30
-            if(($buffer & 2) == 0) { //buffer & 2 == 2 => RLE. buffer & 2 == 0 => non-RLE (same as s16 but not supported here because it's complex dude.
30
+            if (($buffer & 2) == 0) { //buffer & 2 == 2 => RLE. buffer & 2 == 0 => non-RLE (same as s16 but not supported here because it's complex dude.
31 31
                 throw new Exception('This file is probably a S16 masquerading as a C16!');
32
-            } else if($buffer > 3) {
32
+            } else if ($buffer > 3) {
33 33
                 throw new Exception('File encoding not recognised. ('.$buffer.')');
34 34
             }
35 35
 
36 36
             $buffer = $reader->ReadInt(2);
37
-            if($buffer < 1)
37
+            if ($buffer < 1)
38 38
                 throw new Exception('Sprite file appears to contain less than 1 frame.');
39 39
             $frameCount = $buffer;
40
-            for($x=0; $x < $frameCount; $x++)
40
+            for ($x = 0; $x < $frameCount; $x++)
41 41
             {
42
-                $this->AddFrame(new C16Frame($reader,$this->encoding));
42
+                $this->AddFrame(new C16Frame($reader, $this->encoding));
43 43
             }
44 44
         }
45 45
     }
@@ -58,30 +58,30 @@  discard block
 block discarded – undo
58 58
     public function Compile() {
59 59
         $data = ''; 
60 60
         $flags = 2; // 0b00 => 555 S16, 0b01 => 565 S16, 0b10 => 555 C16, 0b11 => 565 C16
61
-        if($this->encoding == '565') {
61
+        if ($this->encoding == '565') {
62 62
             $flags = $flags | 1;
63 63
         }
64
-        $data .= pack('V',$flags);
65
-        $data .= pack('v',$this->GetFrameCount());
64
+        $data .= pack('V', $flags);
65
+        $data .= pack('v', $this->GetFrameCount());
66 66
         $idata = '';
67 67
         $offset = 6+(8*$this->GetFrameCount());
68
-        foreach($this->GetFrames() as $frame) {
68
+        foreach ($this->GetFrames() as $frame) {
69 69
             $offset += ($frame->GetHeight()-1)*4;
70 70
         }
71 71
 
72
-        foreach($this->GetFrames() as $frame) {
73
-            $data .= pack('V',$offset);
74
-            $data .= pack('vv',$frame->GetWidth(),$frame->GetHeight());
72
+        foreach ($this->GetFrames() as $frame) {
73
+            $data .= pack('V', $offset);
74
+            $data .= pack('vv', $frame->GetWidth(), $frame->GetHeight());
75 75
 
76 76
             $framedata = $frame->Encode();
77 77
             $framebin = $framedata['data'];
78
-            foreach($framedata['lineoffsets'] as $lineoffset) {
79
-                $data .= pack('V',$lineoffset+$offset);
78
+            foreach ($framedata['lineoffsets'] as $lineoffset) {
79
+                $data .= pack('V', $lineoffset+$offset);
80 80
             }
81 81
             $offset += strlen($framebin); 
82 82
             $idata .= $framebin;
83 83
         }
84
-        return $data . $idata;
84
+        return $data.$idata;
85 85
     }
86 86
 
87 87
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@
 block discarded – undo
34 34
             }
35 35
 
36 36
             $buffer = $reader->ReadInt(2);
37
-            if($buffer < 1)
38
-                throw new Exception('Sprite file appears to contain less than 1 frame.');
37
+            if($buffer < 1) {
38
+                            throw new Exception('Sprite file appears to contain less than 1 frame.');
39
+            }
39 40
             $frameCount = $buffer;
40 41
             for($x=0; $x < $frameCount; $x++)
41 42
             {
Please login to merge, or discard this patch.
sprites/S16File.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 
56 56
     /// @brief Compiles the S16 file into a binary string.
57 57
     /**
58
-     * @return a binary string containing s16 data of whatever the
58
+     * @return string binary string containing s16 data of whatever the
59 59
      * current encoding set by SetEncoding() is. If you haven't set
60 60
      * it, it's most likely 565.
61 61
      */
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
         parent::SpriteFile('S16');
30 30
         $this->reader = $reader;
31 31
         $buffer = $this->reader->ReadInt(4);
32
-        if($buffer == 1) {
32
+        if ($buffer == 1) {
33 33
             $this->encoding = "565";
34
-        } else if($buffer == 0) {
34
+        } else if ($buffer == 0) {
35 35
             $this->encoding = "555";
36 36
         } else {
37 37
             throw new Exception("File encoding not recognised. (".$buffer.'|'.$this->reader->GetPosition().')');
38 38
         }
39 39
         $this->frameCount = $this->reader->ReadInt(2);
40
-        for($i=0; $i < $this->frameCount; $i++)
40
+        for ($i = 0; $i < $this->frameCount; $i++)
41 41
         {
42
-            $this->AddFrame(new S16Frame($this->reader,$this->encoding));
42
+            $this->AddFrame(new S16Frame($this->reader, $this->encoding));
43 43
         }
44 44
     }
45 45
     /// @brief Sets the encoding (555 or 565) of this s16 file.
@@ -69,22 +69,22 @@  discard block
 block discarded – undo
69 69
         // 0b01 => 565 S16,
70 70
         // 0b10 => 555 C16,
71 71
         // 0b11 => 565 C16
72
-        if($this->encoding == '565') {
72
+        if ($this->encoding == '565') {
73 73
             $flags = $flags | 1;
74 74
         }
75
-        $data .= pack('V',$flags);
76
-        $data .= pack('v',$this->GetFrameCount());
75
+        $data .= pack('V', $flags);
76
+        $data .= pack('v', $this->GetFrameCount());
77 77
         $idata = '';
78 78
         $offset = 6+(8*$this->GetFrameCount());
79
-        foreach($this->GetFrames() as $frame) {
80
-            $data .= pack('V',$offset);
81
-            $data .= pack('vv',$frame->GetWidth(),$frame->GetHeight());
79
+        foreach ($this->GetFrames() as $frame) {
80
+            $data .= pack('V', $offset);
81
+            $data .= pack('vv', $frame->GetWidth(), $frame->GetHeight());
82 82
 
83 83
             $framebin = $frame->Encode();
84 84
             $offset += strlen($framebin); 
85 85
             $idata .= $framebin;
86 86
         }
87
-        return $data . $idata;
87
+        return $data.$idata;
88 88
     }
89 89
 }
90 90
 ?>
Please login to merge, or discard this patch.
sprites/S16Frame.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
     /// @brief Encodes the image into s16 frame data.
42 42
     /**
43 43
      * @param $format 555 or 565.
44
-     * @return s16 image data in the format specified
44
+     * @return string image data in the format specified
45 45
      */
46 46
 
47 47
     public function Encode($format='565') {
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
     
18 18
     /// @brief Instantiate an S16Frame
19 19
     
20
-    public function S16Frame($reader,$encoding='565',$width=false,$height=false,$offset=false)
20
+    public function S16Frame($reader, $encoding = '565', $width = false, $height = false, $offset = false)
21 21
     {
22
-        if($reader instanceof IReader) {
22
+        if ($reader instanceof IReader) {
23 23
             $this->reader = $reader;
24 24
             $this->encoding = $encoding;
25
-            if($width === false || $height === false || $offset === false) {
25
+            if ($width === false || $height === false || $offset === false) {
26 26
                 $this->offset = $this->reader->ReadInt(4);
27 27
                 parent::SpriteFrame($this->reader->ReadInt(2), $this->reader->ReadInt(2));
28 28
             } else {
29
-                parent::SpriteFrame($width,$height);
29
+                parent::SpriteFrame($width, $height);
30 30
                 $this->offset = $offset;
31 31
             }
32
-        } else if(get_resource_type($reader) == 'gd') {
32
+        } else if (get_resource_type($reader) == 'gd') {
33 33
             $this->gdImage = $reader;
34 34
             $this->decoded = true;
35 35
             $this->encoding = $encoding;
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
      * @return s16 image data in the format specified
45 45
      */
46 46
 
47
-    public function Encode($format='565') {
47
+    public function Encode($format = '565') {
48 48
         $this->EnsureDecoded();
49 49
         $data = ''; 
50
-        for($y = 0; $y < $this->GetHeight(); $y++) {
51
-            for($x = 0; $x < $this->GetWidth(); $x++ ) {
50
+        for ($y = 0; $y < $this->GetHeight(); $y++) {
51
+            for ($x = 0; $x < $this->GetWidth(); $x++) {
52 52
 
53
-                $pixel = $this->GetPixel($x,$y);
54
-                if($pixel['red'] > 255 || $pixel['green'] > 255 || $pixel['blue'] > 255) {
53
+                $pixel = $this->GetPixel($x, $y);
54
+                if ($pixel['red'] > 255 || $pixel['green'] > 255 || $pixel['blue'] > 255) {
55 55
                     throw new Exception('Pixel colour out of range.');
56 56
                 }
57 57
                 $newpixel = 0;
58
-                if($this->encoding == '555') {
58
+                if ($this->encoding == '555') {
59 59
                     $newpixel = (($pixel['red'] << 7) & 0xF800) | (($pixel['green'] << 2) & 0x03E0) | (($pixel['blue'] >> 3) & 0x001F);
60 60
                 } else {
61 61
                     $newpixel = (($pixel['red'] << 8) & 0xF800) | (($pixel['green'] << 3) & 0x07E0) | (($pixel['blue'] >> 3) & 0x001F);
62 62
                 }
63
-                $data .= pack('v',$newpixel);
63
+                $data .= pack('v', $newpixel);
64 64
             }
65 65
         }
66 66
         return $data;
@@ -73,24 +73,24 @@  discard block
 block discarded – undo
73 73
      * TODO: Internal documentation S16Frame::Decode()
74 74
      */
75 75
     protected function Decode() {
76
-        if($this->decoded) { return $this->gdImage; }
76
+        if ($this->decoded) { return $this->gdImage; }
77 77
 
78 78
             $image = imagecreatetruecolor($this->GetWidth(),
79 79
                 $this->GetHeight());
80 80
         $this->reader->Seek($this->offset);
81
-        for($y = 0; $y < $this->GetHeight(); $y++)
81
+        for ($y = 0; $y < $this->GetHeight(); $y++)
82 82
         {
83
-            for($x = 0; $x < $this->GetWidth(); $x++)
83
+            for ($x = 0; $x < $this->GetWidth(); $x++)
84 84
             {
85 85
                 $pixel = $this->reader->ReadInt(2);
86 86
                 $red = 0; $green = 0; $blue = 0;
87
-                if($this->encoding == "565")
87
+                if ($this->encoding == "565")
88 88
                 {
89 89
                     $red   = ($pixel & 0xF800) >> 8;
90 90
                     $green = ($pixel & 0x07E0) >> 3;
91 91
                     $blue  = ($pixel & 0x001F) << 3;
92 92
                 }
93
-                else if($this->encoding == "555")
93
+                else if ($this->encoding == "555")
94 94
                 {
95 95
                     $red   = ($pixel & 0x7C00) >> 7;
96 96
                     $green = ($pixel & 0x03E0) >> 2;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,8 +89,7 @@
 block discarded – undo
89 89
                     $red   = ($pixel & 0xF800) >> 8;
90 90
                     $green = ($pixel & 0x07E0) >> 3;
91 91
                     $blue  = ($pixel & 0x001F) << 3;
92
-                }
93
-                else if($this->encoding == "555")
92
+                } else if($this->encoding == "555")
94 93
                 {
95 94
                     $red   = ($pixel & 0x7C00) >> 7;
96 95
                     $green = ($pixel & 0x03E0) >> 2;
Please login to merge, or discard this patch.
sprites/SPRFrame.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
      * Called automatically by SPRFile::Compile() \n
98 98
      * Generally end-users won't want a single frame of SPR data,
99 99
      * so add it to an SPRFile and call SPRFile::Compile().
100
-     * @return a binary string of SPR data.
100
+     * @return string binary string of SPR data.
101 101
      */
102 102
     public function Encode() {
103 103
         $data = '';
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,26 +25,26 @@  discard block
 block discarded – undo
25 25
      * @param $height Ignored when creating an SPRFrame from a GD image.
26 26
      * @param $offset How far through the IReader the SPRFrame is. May not ever be used.
27 27
      */
28
-    public function SPRFrame($reader,$width=0,$height=0,$offset=false) {
29
-        if($reader instanceof IReader) {
28
+    public function SPRFrame($reader, $width = 0, $height = 0, $offset = false) {
29
+        if ($reader instanceof IReader) {
30 30
             $this->reader = $reader;
31
-            parent::SpriteFrame($width,$height);
32
-            if($offset !== false) {
31
+            parent::SpriteFrame($width, $height);
32
+            if ($offset !== false) {
33 33
                 $this->offset = $offset;
34 34
             } else {
35 35
                 $this->offset = $this->reader->GetPosition();
36 36
             }
37 37
 
38 38
             //initialise palette if necessary.
39
-            if(empty(self::$sprToRGB)) {
39
+            if (empty(self::$sprToRGB)) {
40 40
                 $paletteReader = new FileReader(dirname(__FILE__).'/palette.dta');
41
-                for($i = 0;$i<256;$i++) {
42
-                    self::$sprToRGB[$i] = array('r'=>$paletteReader->ReadInt(1)*4,'g'=>$paletteReader->ReadInt(1)*4,'b'=>$paletteReader->ReadInt(1)*4);
41
+                for ($i = 0; $i < 256; $i++) {
42
+                    self::$sprToRGB[$i] = array('r'=>$paletteReader->ReadInt(1)*4, 'g'=>$paletteReader->ReadInt(1)*4, 'b'=>$paletteReader->ReadInt(1)*4);
43 43
                 }
44 44
                 unset($paletteReader);
45 45
             }
46
-        } else if(get_resource_type($reader) == 'gd') {
47
-            parent::SpriteFrame(imagesx($reader),imagesy($reader),true);
46
+        } else if (get_resource_type($reader) == 'gd') {
47
+            parent::SpriteFrame(imagesx($reader), imagesy($reader), true);
48 48
             $this->gdImage = $reader;
49 49
         } else {
50 50
             throw new Exception('$reader was not an IReader or a gd image.');
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
      * feel free to use it yourself, it's not going anywhere.
59 59
      */
60 60
     public function Flip() {
61
-        if($this->HasBeenDecoded()) {
61
+        if ($this->HasBeenDecoded()) {
62 62
             throw new Exception('Too late!');
63 63
             return;
64 64
         }
65 65
         $tempData = '';
66
-        for($i=($this->GetHeight()-1);$i>-1;$i--) {
67
-            $tempData .= $this->reader->GetSubString($this->offset+($this->GetWidth())*$i,($this->GetWidth()));
66
+        for ($i = ($this->GetHeight()-1); $i > -1; $i--) {
67
+            $tempData .= $this->reader->GetSubString($this->offset+($this->GetWidth())*$i, ($this->GetWidth()));
68 68
         }
69 69
         $this->reader = new StringReader($tempData);
70 70
         $this->offset = 0;
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
     protected function Decode() {    
79 79
         $image = imagecreatetruecolor($this->GetWidth(), $this->GetHeight());
80 80
         $this->reader->Seek($this->offset);
81
-        for($y = 0; $y < $this->GetHeight(); $y++)
81
+        for ($y = 0; $y < $this->GetHeight(); $y++)
82 82
         {
83
-            for($x = 0; $x < $this->GetWidth(); $x++)
83
+            for ($x = 0; $x < $this->GetWidth(); $x++)
84 84
             {
85 85
                 $colour = self::$sprToRGB[$this->reader->ReadInt(1)];
86
-                imagesetpixel($image,$x,$y,imagecolorallocate($image,$colour['r'],$colour['g'],$colour['b']));
86
+                imagesetpixel($image, $x, $y, imagecolorallocate($image, $colour['r'], $colour['g'], $colour['b']));
87 87
             }
88 88
         }
89 89
         $this->gdImage = $image;
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public function Encode() {
103 103
         $data = '';
104
-        for($y = 0; $y < $this->GetHeight(); $y++ ) {
105
-            for($x = 0; $x < $this->GetWidth(); $x++ ) {
104
+        for ($y = 0; $y < $this->GetHeight(); $y++) {
105
+            for ($x = 0; $x < $this->GetWidth(); $x++) {
106 106
                 $color = $this->GetPixel($x, $y);
107
-                $data .= pack('C',$this->RGBToSPR($color['red'], $color['green'], $color['blue']));
107
+                $data .= pack('C', $this->RGBToSPR($color['red'], $color['green'], $color['blue']));
108 108
             }
109 109
         }
110 110
         return $data;
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
      * Runs in O(n) time.
118 118
      */
119 119
 
120
-    private function RGBToSPR($r,$g,$b) {
120
+    private function RGBToSPR($r, $g, $b) {
121 121
         //start out with the maximum distance.
122
-        $minDistance = ($r^2) + ($g^2) + ($b^2);
122
+        $minDistance = ($r ^ 2)+($g ^ 2)+($b ^ 2);
123 123
         $minKey = 0;
124
-        foreach(self::$sprToRGB as $key => $colour) {
125
-            $distance = pow(($r-$colour['r']),2) +  pow(($g-$colour['g']),2) +  pow(($b-$colour['b']),2);
126
-            if($distance == 0) {
124
+        foreach (self::$sprToRGB as $key => $colour) {
125
+            $distance = pow(($r-$colour['r']), 2)+pow(($g-$colour['g']), 2)+pow(($b-$colour['b']), 2);
126
+            if ($distance == 0) {
127 127
                 return $key;
128 128
             } else if ($distance < $minDistance) {
129 129
                 $minKey = $key;
Please login to merge, or discard this patch.
sprites/SpriteFile.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,6 +11,9 @@  discard block
 block discarded – undo
11 11
 
12 12
   /// @cond INTERNAL_DOCS
13 13
   
14
+  /**
15
+   * @param string $filetype
16
+   */
14 17
   public function SpriteFile($filetype) {
15 18
     $this->spritefiletype = $filetype;
16 19
   }
@@ -102,7 +105,7 @@  discard block
 block discarded – undo
102 105
   /**
103 106
    * May be removed in a future release.
104 107
    * Use GetFrame($frame)->ToPNG() instead.
105
-   * @param $frame The 0-based index of the frame to delete.
108
+   * @param integer $frame The 0-based index of the frame to delete.
106 109
    * @return A binary string containing a PNG.
107 110
    */
108 111
   public function ToPNG($frame) {
Please login to merge, or discard this patch.
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -3,110 +3,110 @@
 block discarded – undo
3 3
 /// @brief Superclass for all SpriteFile types
4 4
 abstract class SpriteFile {
5 5
 
6
-  /// @cond INTERNAL_DOCS
6
+    /// @cond INTERNAL_DOCS
7 7
     
8
-  private $frames = array();
9
-  private $spritefiletype;
10
-  /// @endcond
8
+    private $frames = array();
9
+    private $spritefiletype;
10
+    /// @endcond
11 11
 
12
-  /// @cond INTERNAL_DOCS
12
+    /// @cond INTERNAL_DOCS
13 13
   
14
-  public function SpriteFile($filetype) {
14
+    public function SpriteFile($filetype) {
15 15
     $this->spritefiletype = $filetype;
16
-  }
17
-  /// @endcond
16
+    }
17
+    /// @endcond
18 18
 
19
-  /// @brief Gets a SpriteFrame from the SpriteFile.
20
-  /**
21
-   * @param $frame The 0-based index of the frame to get.
22
-   * @return A SpriteFrame
23
-   */
24
-  public function GetFrame($frame) {
25
-      return $this->frames[$frame];
26
-  }
27
-  /// @brief Gets the entire frame array.
28
-  /**
29
-   * @return An array of SpriteFrames
30
-   */
31
-  public function GetFrames() {
32
-      return $this->frames;
33
-  }
19
+    /// @brief Gets a SpriteFrame from the SpriteFile.
20
+    /**
21
+     * @param $frame The 0-based index of the frame to get.
22
+     * @return A SpriteFrame
23
+     */
24
+    public function GetFrame($frame) {
25
+        return $this->frames[$frame];
26
+    }
27
+    /// @brief Gets the entire frame array.
28
+    /**
29
+     * @return An array of SpriteFrames
30
+     */
31
+    public function GetFrames() {
32
+        return $this->frames;
33
+    }
34 34
 
35
-  /// @brief Compiles the SpriteFile into a binary string
36
-  /**
37
-   * @return A binary string containing the SpriteFile's data and frames.
38
-   */
39
-  public abstract function Compile();
35
+    /// @brief Compiles the SpriteFile into a binary string
36
+    /**
37
+     * @return A binary string containing the SpriteFile's data and frames.
38
+     */
39
+    public abstract function Compile();
40 40
 
41
-  /// @brief Adds a SpriteFrame to the SpriteFile
42
-  /**
43
-   * If necessary, this function converts the SpriteFrame to the
44
-   * correct format.
45
-   * At the moment, this can only add a SpriteFrame to the end of the
46
-   * SpriteFile. TODO: I aim to fix this by the CCSF 2011.
47
-   * @internal
48
-   * This process uses some magic which require all types of
49
-   * SpriteFile and SpriteFrame to use 3-character identifiers.
50
-   * This means that if you want to make your own sprite formats
51
-   * you'll need to override this function and provide all our magic
52
-   * plus your own.
53
-   * @endinternal
54
-   * @param $frame A SpriteFrame
55
-   * @param $position Where to put the frame. Currently un-used.
56
-   */
57
-  public function AddFrame(SpriteFrame $frame, $position=false) {
58
-      /*
41
+    /// @brief Adds a SpriteFrame to the SpriteFile
42
+    /**
43
+     * If necessary, this function converts the SpriteFrame to the
44
+     * correct format.
45
+     * At the moment, this can only add a SpriteFrame to the end of the
46
+     * SpriteFile. TODO: I aim to fix this by the CCSF 2011.
47
+     * @internal
48
+     * This process uses some magic which require all types of
49
+     * SpriteFile and SpriteFrame to use 3-character identifiers.
50
+     * This means that if you want to make your own sprite formats
51
+     * you'll need to override this function and provide all our magic
52
+     * plus your own.
53
+     * @endinternal
54
+     * @param $frame A SpriteFrame
55
+     * @param $position Where to put the frame. Currently un-used.
56
+     */
57
+    public function AddFrame(SpriteFrame $frame, $position=false) {
58
+        /*
59 59
       if($position === false) {
60 60
           $position = sizeof($this->frames);
61 61
       } else if($position < 0) {
62 62
           $position = sizeof($this->frames) - $position;
63 63
       }
64 64
       */
65
-      if($this->spritefiletype == substr(get_class($frame),0,3)) {
66
-          //$this->frames[$position] = $frame;
67
-          $this->frames[] = $frame;
68
-      } else {
69
-          //$this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype);
70
-          $this->frames[] = $frame->ToSpriteFrame($this->spritefiletype);
71
-      }
72
-  }
73
-  /// @brief Replaces a frame in the SpriteFile
74
-  /**
75
-   * Replaces the frame in the given position
76
-   * Uses the same magic as AddFrame
77
-   * @param $frame A SpriteFrame of any type.
78
-   * @param $position Which frame to replace. If negative, counts
79
-   * backwards from the end of the frames array.
80
-   */
81
-  public function ReplaceFrame(SpriteFrame $frame, $position) {
82
-      if($position < 0) {
83
-          $position = sizeof($this->frames) - $position;
84
-      }
85
-      $this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype);
86
-  }
87
-  /// @brief Gets the number of frames currently stored in this SpriteFile.
88
-  /**
89
-   * @return The number of frames
90
-   */
91
-  public function GetFrameCount() {
92
-      return sizeof($this->frames);
93
-  }
94
-  /// @brief Deletes the frame in the given position.
95
-  /**
96
-   * @param $frame The 0-based index of the frame to delete.
97
-   */
98
-  public function DeleteFrame($frame) {
99
-      unset($this->frames[$frame]);
100
-  }
101
-  /// @brief Converts the given frame to PNG. <strong>Deprecated.</strong>
102
-  /**
103
-   * May be removed in a future release.
104
-   * Use GetFrame($frame)->ToPNG() instead.
105
-   * @param $frame The 0-based index of the frame to delete.
106
-   * @return A binary string containing a PNG.
107
-   */
108
-  public function ToPNG($frame) {
109
-      return $this->frames[$frame]->ToPNG();
110
-  }
65
+        if($this->spritefiletype == substr(get_class($frame),0,3)) {
66
+            //$this->frames[$position] = $frame;
67
+            $this->frames[] = $frame;
68
+        } else {
69
+            //$this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype);
70
+            $this->frames[] = $frame->ToSpriteFrame($this->spritefiletype);
71
+        }
72
+    }
73
+    /// @brief Replaces a frame in the SpriteFile
74
+    /**
75
+     * Replaces the frame in the given position
76
+     * Uses the same magic as AddFrame
77
+     * @param $frame A SpriteFrame of any type.
78
+     * @param $position Which frame to replace. If negative, counts
79
+     * backwards from the end of the frames array.
80
+     */
81
+    public function ReplaceFrame(SpriteFrame $frame, $position) {
82
+        if($position < 0) {
83
+            $position = sizeof($this->frames) - $position;
84
+        }
85
+        $this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype);
86
+    }
87
+    /// @brief Gets the number of frames currently stored in this SpriteFile.
88
+    /**
89
+     * @return The number of frames
90
+     */
91
+    public function GetFrameCount() {
92
+        return sizeof($this->frames);
93
+    }
94
+    /// @brief Deletes the frame in the given position.
95
+    /**
96
+     * @param $frame The 0-based index of the frame to delete.
97
+     */
98
+    public function DeleteFrame($frame) {
99
+        unset($this->frames[$frame]);
100
+    }
101
+    /// @brief Converts the given frame to PNG. <strong>Deprecated.</strong>
102
+    /**
103
+     * May be removed in a future release.
104
+     * Use GetFrame($frame)->ToPNG() instead.
105
+     * @param $frame The 0-based index of the frame to delete.
106
+     * @return A binary string containing a PNG.
107
+     */
108
+    public function ToPNG($frame) {
109
+        return $this->frames[$frame]->ToPNG();
110
+    }
111 111
 }
112 112
 ?>
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
    * @param $frame A SpriteFrame
55 55
    * @param $position Where to put the frame. Currently un-used.
56 56
    */
57
-  public function AddFrame(SpriteFrame $frame, $position=false) {
57
+  public function AddFrame(SpriteFrame $frame, $position = false) {
58 58
       /*
59 59
       if($position === false) {
60 60
           $position = sizeof($this->frames);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
           $position = sizeof($this->frames) - $position;
63 63
       }
64 64
       */
65
-      if($this->spritefiletype == substr(get_class($frame),0,3)) {
65
+      if ($this->spritefiletype == substr(get_class($frame), 0, 3)) {
66 66
           //$this->frames[$position] = $frame;
67 67
           $this->frames[] = $frame;
68 68
       } else {
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
    * backwards from the end of the frames array.
80 80
    */
81 81
   public function ReplaceFrame(SpriteFrame $frame, $position) {
82
-      if($position < 0) {
83
-          $position = sizeof($this->frames) - $position;
82
+      if ($position < 0) {
83
+          $position = sizeof($this->frames)-$position;
84 84
       }
85 85
       $this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype);
86 86
   }
Please login to merge, or discard this patch.
sprites/SpriteFrame.php 3 patches
Doc Comments   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     /// @brief Gets the GD Image resource for this sprite frame.
43 43
     /// <strong> Deprecated</strong>
44 44
     /**
45
-     *  @return a GD image resource. See http://php.net/image 
45
+     *  @return resource GD image resource. See http://php.net/image 
46 46
      */
47 47
     public function GetGDImage() {
48 48
         $this->EnsureDecoded();
@@ -54,6 +54,10 @@  discard block
 block discarded – undo
54 54
         return $this->width;
55 55
     }
56 56
     /// @brief Gets the height of the frame in pixels
57
+
58
+    /**
59
+     * @return integer
60
+     */
57 61
     public function GetHeight() {
58 62
         return $this->height;
59 63
     }
@@ -69,8 +73,8 @@  discard block
 block discarded – undo
69 73
      *    [alpha] => 0 
70 74
      * )</pre>
71 75
      * @see http://php.net/imagecolorsforindex
72
-     * @param $x The x-coordinate of the pixel to get.
73
-     * @param $y The y-coordinate of the pixel to get.
76
+     * @param integer $x The x-coordinate of the pixel to get.
77
+     * @param integer $y The y-coordinate of the pixel to get.
74 78
      * @return An associative array containing the keys 'red','green','blue','alpha'.
75 79
      */
76 80
     public function GetPixel($x,$y) {
@@ -150,7 +154,7 @@  discard block
 block discarded – undo
150 154
 
151 155
     /// @brief Converts this SpriteFrame into a PNG.
152 156
     /**
153
-     * @return A binary string in PNG format, ready for output! :)
157
+     * @return string binary string in PNG format, ready for output! :)
154 158
      */
155 159
     public function ToPNG() {
156 160
         $this->EnsureDecoded();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
      * Width and height must both be non-zero.
23 23
      * @see C16Frame::C16Frame()
24 24
      */
25
-    public function SpriteFrame($width,$height,$decoded=false) {
26
-        if($width == 0) {
25
+    public function SpriteFrame($width, $height, $decoded = false) {
26
+        if ($width == 0) {
27 27
             throw new Exception('Zero width');
28
-        } else if($height == 0) {
28
+        } else if ($height == 0) {
29 29
             throw new Exception('Zero height');
30 30
         }
31 31
         $this->width = $width;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      * @param $y The y-coordinate of the pixel to get.
74 74
      * @return An associative array containing the keys 'red','green','blue','alpha'.
75 75
      */
76
-    public function GetPixel($x,$y) {
76
+    public function GetPixel($x, $y) {
77 77
         $this->EnsureDecoded();
78 78
         $colori = imagecolorat($this->gdImage, $x, $y);
79 79
         $color = imagecolorsforindex($this->gdImage, $colori);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      * @param $g The green component of the pixel. 0-255.
89 89
      * @param $b The blue component of the pixel. 0-255.
90 90
      */
91
-    public function SetPixel($x,$y,$r,$g,$b) {
91
+    public function SetPixel($x, $y, $r, $g, $b) {
92 92
         $this->EnsureDecoded();
93 93
         imagesetpixel($this->gdImage, $x, $y, imagecolorallocate($this->gdImage, $r, $g, $b));
94 94
     }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * if it does't already.
102 102
      */
103 103
     protected function EnsureDecoded() {
104
-        if(!$this->decoded)
104
+        if (!$this->decoded)
105 105
             $this->Decode();
106 106
 
107 107
         $this->decoded = true;
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public function ToSpriteFrame($type) {
135 135
         $this->EnsureDecoded();
136
-        if(substr(get_class($this),0,3) == $type && substr(get_class($this),3) == 'Frame') {
136
+        if (substr(get_class($this), 0, 3) == $type && substr(get_class($this), 3) == 'Frame') {
137 137
             return $this;
138 138
         }
139
-        switch($type) {
139
+        switch ($type) {
140 140
         case 'C16':
141 141
             return new C16Frame($this->GetGDImage());
142 142
         case 'S16':
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,8 +101,9 @@
 block discarded – undo
101 101
      * if it does't already.
102 102
      */
103 103
     protected function EnsureDecoded() {
104
-        if(!$this->decoded)
105
-            $this->Decode();
104
+        if(!$this->decoded) {
105
+                    $this->Decode();
106
+        }
106 107
 
107 108
         $this->decoded = true;
108 109
     }
Please login to merge, or discard this patch.
support/Archiver.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -12,6 +12,9 @@
 block discarded – undo
12 12
 		return false; //coming soon
13 13
 	}	
14 14
 }
15
+/**
16
+ * @param string $data
17
+ */
15 18
 function Archive($data,$filehandle=null) {
16 19
 	if(is_resource($filehandle)) {
17 20
 		return false;
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@
 block discarded – undo
1 1
 <?php
2 2
 function DeArchive($data) {
3
-	if(is_string($data)) {
4
-		if(substr($data,0,55) == "Creatures Evolution Engine - Archived information file.") {
5
-			$data = substr($data,strpos($data,chr(0x1A).chr(0x04))+2);
6
-			$data = gzuncompress($data);
7
-			return $data;
8
-		}
9
-		die('Couldn\'t dearchive -- Probably invalid file');
10
-		return false;
11
-	} else if(is_resource($data)) {
12
-		return false; //coming soon
13
-	}	
3
+    if(is_string($data)) {
4
+        if(substr($data,0,55) == "Creatures Evolution Engine - Archived information file.") {
5
+            $data = substr($data,strpos($data,chr(0x1A).chr(0x04))+2);
6
+            $data = gzuncompress($data);
7
+            return $data;
8
+        }
9
+        die('Couldn\'t dearchive -- Probably invalid file');
10
+        return false;
11
+    } else if(is_resource($data)) {
12
+        return false; //coming soon
13
+    }	
14 14
 }
15 15
 function Archive($data,$filehandle=null) {
16
-	if(is_resource($filehandle)) {
17
-		return false;
18
-	}
19
-	$data = gzcompress($data);
20
-	$data = "Creatures Evolution Engine - Archived information file. zLib 1.13 compressed.".chr(0x1A).chr(0x04).$data;
21
-	return $data;
16
+    if(is_resource($filehandle)) {
17
+        return false;
18
+    }
19
+    $data = gzcompress($data);
20
+    $data = "Creatures Evolution Engine - Archived information file. zLib 1.13 compressed.".chr(0x1A).chr(0x04).$data;
21
+    return $data;
22 22
 	
23 23
 }
24 24
 ?>
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php
2 2
 function DeArchive($data) {
3
-	if(is_string($data)) {
4
-		if(substr($data,0,55) == "Creatures Evolution Engine - Archived information file.") {
5
-			$data = substr($data,strpos($data,chr(0x1A).chr(0x04))+2);
3
+	if (is_string($data)) {
4
+		if (substr($data, 0, 55) == "Creatures Evolution Engine - Archived information file.") {
5
+			$data = substr($data, strpos($data, chr(0x1A).chr(0x04))+2);
6 6
 			$data = gzuncompress($data);
7 7
 			return $data;
8 8
 		}
9 9
 		die('Couldn\'t dearchive -- Probably invalid file');
10 10
 		return false;
11
-	} else if(is_resource($data)) {
11
+	} else if (is_resource($data)) {
12 12
 		return false; //coming soon
13 13
 	}	
14 14
 }
15
-function Archive($data,$filehandle=null) {
16
-	if(is_resource($filehandle)) {
15
+function Archive($data, $filehandle = null) {
16
+	if (is_resource($filehandle)) {
17 17
 		return false;
18 18
 	}
19 19
 	$data = gzcompress($data);
Please login to merge, or discard this patch.