@@ -9,8 +9,7 @@ |
||
| 9 | 9 | class C3CAOSVariables { |
| 10 | 10 | /// @brief Returns an array of tokens. |
| 11 | 11 | public static function GetTokens() { |
| 12 | - return array |
|
| 13 | - ( |
|
| 12 | + return array( |
|
| 14 | 13 | //agents |
| 15 | 14 | 'abba', |
| 16 | 15 | 'carr', |
@@ -6,8 +6,7 @@ |
||
| 6 | 6 | class C3CAOSCommands { |
| 7 | 7 | /// @brief Returns an array of tokens. |
| 8 | 8 | public static function GetTokens() { |
| 9 | - return array |
|
| 10 | - ( |
|
| 9 | + return array( |
|
| 11 | 10 | 'alph', |
| 12 | 11 | 'anim', |
| 13 | 12 | 'amms', |
@@ -10,10 +10,10 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | ///@{ |
| 12 | 12 | /** Value: 1 */ |
| 13 | -define('CREATUREHISTORY_GENDER_MALE',1); |
|
| 13 | +define('CREATUREHISTORY_GENDER_MALE', 1); |
|
| 14 | 14 | |
| 15 | 15 | /** Value: 2 */ |
| 16 | -define('CREATUREHISTORY_GENDER_FEMALE',2); |
|
| 16 | +define('CREATUREHISTORY_GENDER_FEMALE', 2); |
|
| 17 | 17 | ///@} |
| 18 | 18 | |
| 19 | 19 | /// @brief Class representing a creature's history. |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param $genus The creature's genus (Grendel, ettin, norn, geat) |
| 50 | 50 | * @param $species The creature's species (unsure of purpose) |
| 51 | 51 | */ |
| 52 | - public function CreatureHistory($moniker,$name,$gender,$genus,$species) { |
|
| 52 | + public function CreatureHistory($moniker, $name, $gender, $genus, $species) { |
|
| 53 | 53 | $this->moniker = $moniker; |
| 54 | 54 | $this->name = $name; |
| 55 | 55 | $this->gender = $gender; |
@@ -62,29 +62,29 @@ discard block |
||
| 62 | 62 | * @param $format GLST_FORMAT_C3 or GLST_FORMAT_DS. |
| 63 | 63 | * @return A binary string ready for archiving and putting in a GLST block. |
| 64 | 64 | */ |
| 65 | - public function Compile($format=GLST_FORMAT_C3) { |
|
| 65 | + public function Compile($format = GLST_FORMAT_C3) { |
|
| 66 | 66 | $data = ''; |
| 67 | - if($format != GLST_FORMAT_C3 && $format != GLST_FORMAT_DS) { |
|
| 67 | + if ($format != GLST_FORMAT_C3 && $format != GLST_FORMAT_DS) { |
|
| 68 | 68 | $format = $this->GuessFormat(); |
| 69 | 69 | } |
| 70 | - if($format == GLST_FORMAT_DS) { |
|
| 71 | - $data = pack('V',0x27); |
|
| 70 | + if ($format == GLST_FORMAT_DS) { |
|
| 71 | + $data = pack('V', 0x27); |
|
| 72 | 72 | } else { |
| 73 | - $data = pack('V',0x0C); |
|
| 73 | + $data = pack('V', 0x0C); |
|
| 74 | 74 | } |
| 75 | - $data .= pack('V',1); |
|
| 76 | - $data .= pack('V',32).$this->moniker; |
|
| 77 | - $data .= pack('V',32).$this->moniker; //yeah, twice. Dunno why, CL are bonkers. |
|
| 78 | - $data .= pack('V',strlen($this->name)).$this->name; |
|
| 79 | - $data .= pack('VVVV',$this->gender,$this->genus,$this->species,count($this->events)); |
|
| 80 | - foreach($this->events as $event) { |
|
| 75 | + $data .= pack('V', 1); |
|
| 76 | + $data .= pack('V', 32).$this->moniker; |
|
| 77 | + $data .= pack('V', 32).$this->moniker; //yeah, twice. Dunno why, CL are bonkers. |
|
| 78 | + $data .= pack('V', strlen($this->name)).$this->name; |
|
| 79 | + $data .= pack('VVVV', $this->gender, $this->genus, $this->species, count($this->events)); |
|
| 80 | + foreach ($this->events as $event) { |
|
| 81 | 81 | $data .= $event->Compile($format); |
| 82 | 82 | } |
| 83 | - $data .= pack('V',$this->mutations); |
|
| 84 | - $data .= pack('V',$this->crossoverpoints); |
|
| 85 | - if($format == GLST_FORMAT_DS) { |
|
| 86 | - $data .= pack('V',$this->unknown1); |
|
| 87 | - $data .= pack('V',strlen($this->unknown2)).$this->unknown2; |
|
| 83 | + $data .= pack('V', $this->mutations); |
|
| 84 | + $data .= pack('V', $this->crossoverpoints); |
|
| 85 | + if ($format == GLST_FORMAT_DS) { |
|
| 86 | + $data .= pack('V', $this->unknown1); |
|
| 87 | + $data .= pack('V', strlen($this->unknown2)).$this->unknown2; |
|
| 88 | 88 | } |
| 89 | 89 | return $data; |
| 90 | 90 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @return GLST_FORMAT_DS or GLST_FORMAT_C3. |
| 97 | 97 | */ |
| 98 | 98 | public function GuessFormat() { |
| 99 | - return (isset($this->unknown1))?GLST_FORMAT_DS:GLST_FORMAT_C3; |
|
| 99 | + return (isset($this->unknown1)) ? GLST_FORMAT_DS : GLST_FORMAT_C3; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /// @brief Adds an event to the end of a history. |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function GetEventsByType($type) { |
| 145 | 145 | $matchingEvents = array(); |
| 146 | - foreach($this->events as $event) { |
|
| 147 | - if($event->GetEventType() == $type) { |
|
| 146 | + foreach ($this->events as $event) { |
|
| 147 | + if ($event->GetEventType() == $type) { |
|
| 148 | 148 | $matchingEvents[] = $event; |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | * @return 0 for failure, the generation of the creature otherwise. |
| 173 | 173 | */ |
| 174 | 174 | public function GetCreatureGenerationNumber() { |
| 175 | - if($pos = strpos('_',$this->moniker) == -1) { |
|
| 175 | + if ($pos = strpos('_', $this->moniker) == -1) { |
|
| 176 | 176 | return 0; |
| 177 | 177 | } else { |
| 178 | - $firstbit = substr($this->moniker,0,$pos); |
|
| 179 | - if(is_numeric($firstbit)) { |
|
| 178 | + $firstbit = substr($this->moniker, 0, $pos); |
|
| 179 | + if (is_numeric($firstbit)) { |
|
| 180 | 180 | return $firstbit+0; |
| 181 | 181 | } |
| 182 | 182 | return 0; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | return $this->crossoverpoints; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - public function SetMutationsAndCrossovers($mutations,$crossovers) { |
|
| 221 | + public function SetMutationsAndCrossovers($mutations, $crossovers) { |
|
| 222 | 222 | $this->mutations = $mutations; |
| 223 | 223 | $this->crossoverpoints = $crossovers; |
| 224 | 224 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param $unknown1 First unknown variable |
| 232 | 232 | * @param $unknown2 Second unknown variable |
| 233 | 233 | */ |
| 234 | - public function SetDSUnknowns($unknown1,$unknown2) { |
|
| 234 | + public function SetDSUnknowns($unknown1, $unknown2) { |
|
| 235 | 235 | $this->unknown1 = $unknown1; |
| 236 | 236 | $this->unknown2 = $unknown2; |
| 237 | 237 | } |
@@ -15,68 +15,68 @@ discard block |
||
| 15 | 15 | //@{ |
| 16 | 16 | /** I was conceived by kisspopping or artificial insemination. \n |
| 17 | 17 | * Value: 0 */ |
| 18 | -define('CREATUREHISTORY_EVENT_CONCEIVED',0); |
|
| 18 | +define('CREATUREHISTORY_EVENT_CONCEIVED', 0); |
|
| 19 | 19 | /** I was spliced from two other creatures \n |
| 20 | 20 | * Value: 1 */ |
| 21 | -define('CREATUREHISTORY_EVENT_SPLICED',1); |
|
| 21 | +define('CREATUREHISTORY_EVENT_SPLICED', 1); |
|
| 22 | 22 | /** I was created by someone with a genetics kit \n |
| 23 | 23 | * Value: 2 */ |
| 24 | -define('CREATUREHISTORY_EVENT_ENGINEERED',2); |
|
| 24 | +define('CREATUREHISTORY_EVENT_ENGINEERED', 2); |
|
| 25 | 25 | /** I hatched out of my egg. \n |
| 26 | 26 | * Value: 3 */ |
| 27 | -define('CREATUREHISTORY_EVENT_HATCHED',3); |
|
| 27 | +define('CREATUREHISTORY_EVENT_HATCHED', 3); |
|
| 28 | 28 | /** |
| 29 | 29 | * CreatureHistoryEvent::GetLifestage will tell you what lifestage I |
| 30 | 30 | * am now. \n\n |
| 31 | 31 | * Value: 4 |
| 32 | 32 | */ |
| 33 | -define('CREATUREHISTORY_EVENT_AGED',4); |
|
| 33 | +define('CREATUREHISTORY_EVENT_AGED', 4); |
|
| 34 | 34 | /** I was exported from this world \n |
| 35 | 35 | * Value: 5 */ |
| 36 | -define('CREATUREHISTORY_EVENT_EXPORTED',5); |
|
| 36 | +define('CREATUREHISTORY_EVENT_EXPORTED', 5); |
|
| 37 | 37 | /** I joined this world \n |
| 38 | 38 | * Value: 6 */ |
| 39 | -define('CREATUREHISTORY_EVENT_IMPORTED',6); |
|
| 39 | +define('CREATUREHISTORY_EVENT_IMPORTED', 6); |
|
| 40 | 40 | /** My journey through life ended. \n |
| 41 | 41 | * Value: 7 */ |
| 42 | -define('CREATUREHISTORY_EVENT_DIED',7); |
|
| 42 | +define('CREATUREHISTORY_EVENT_DIED', 7); |
|
| 43 | 43 | /** I became pregnant. \n |
| 44 | 44 | * Value: 8 */ |
| 45 | -define('CREATUREHISTORY_EVENT_BECAMEPREGNANT',8); |
|
| 45 | +define('CREATUREHISTORY_EVENT_BECAMEPREGNANT', 8); |
|
| 46 | 46 | /** I made someone else pregnant. \n |
| 47 | 47 | * Value: 9 */ |
| 48 | -define('CREATUREHISTORY_EVENT_IMPREGNATED',9); |
|
| 48 | +define('CREATUREHISTORY_EVENT_IMPREGNATED', 9); |
|
| 49 | 49 | /** My child hatched from its egg! \n |
| 50 | 50 | * Value: 10 */ |
| 51 | -define('CREATUREHISTORY_EVENT_CHILDBORN',10); |
|
| 51 | +define('CREATUREHISTORY_EVENT_CHILDBORN', 10); |
|
| 52 | 52 | /** My mum laid my egg. \n |
| 53 | 53 | * Value: 11 */ |
| 54 | -define('CREATUREHISTORY_EVENT_MUMLAIDMYEGG',11); |
|
| 54 | +define('CREATUREHISTORY_EVENT_MUMLAIDMYEGG', 11); |
|
| 55 | 55 | /** I laid an egg I was carrying. \n |
| 56 | 56 | * Value: 12 */ |
| 57 | -define('CREATUREHISTORY_EVENT_LAIDEGG',12); |
|
| 57 | +define('CREATUREHISTORY_EVENT_LAIDEGG', 12); |
|
| 58 | 58 | /** A photo was taken of me. \n |
| 59 | 59 | * Value: 13 */ |
| 60 | -define('CREATUREHISTORY_EVENT_PHOTOTAKEN',13); |
|
| 60 | +define('CREATUREHISTORY_EVENT_PHOTOTAKEN', 13); |
|
| 61 | 61 | /** |
| 62 | 62 | * I was made by cloning another creature \n |
| 63 | 63 | * This happens when you export a creature then import it more than |
| 64 | 64 | * once. \n |
| 65 | 65 | * Value: 14 |
| 66 | 66 | */ |
| 67 | -define('CREATUREHISTORY_EVENT_IAMCLONED',14); |
|
| 67 | +define('CREATUREHISTORY_EVENT_IAMCLONED', 14); |
|
| 68 | 68 | /** Another creature was made by cloning me. \n |
| 69 | 69 | * This happens when you export a creature then import it more than |
| 70 | 70 | * once. \n |
| 71 | 71 | * Value: 15 |
| 72 | 72 | */ |
| 73 | -define('CREATUREHISTORY_EVENT_CLONEDME',15); |
|
| 73 | +define('CREATUREHISTORY_EVENT_CLONEDME', 15); |
|
| 74 | 74 | /** I left this world through the warp \n |
| 75 | 75 | * Value: 16 */ |
| 76 | -define('CREATUREHISTORY_EVENT_WARPEDOUT',16); |
|
| 76 | +define('CREATUREHISTORY_EVENT_WARPEDOUT', 16); |
|
| 77 | 77 | /** I entered this world through the warp \n |
| 78 | 78 | * Value: 17 */ |
| 79 | -define('CREATUREHISTORY_EVENT_WARPEDIN',17); |
|
| 79 | +define('CREATUREHISTORY_EVENT_WARPEDIN', 17); |
|
| 80 | 80 | //@} |
| 81 | 81 | |
| 82 | 82 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param $worldname The name of the world the creature was inhabiting at the time of this event |
| 127 | 127 | * @param $worldUID The UID of the world the creature was inhabiting at the the time of this event |
| 128 | 128 | */ |
| 129 | - public function CreatureHistoryEvent($eventtype,$worldtime,$creatureage,$timestamp,$lifestage,$moniker1,$moniker2,$usertext,$photograph,$worldname,$worldUID) { |
|
| 129 | + public function CreatureHistoryEvent($eventtype, $worldtime, $creatureage, $timestamp, $lifestage, $moniker1, $moniker2, $usertext, $photograph, $worldname, $worldUID) { |
|
| 130 | 130 | $this->eventtype = $eventtype; |
| 131 | 131 | $this->worldtime = $worldtime; |
| 132 | 132 | $this->creatureage = $creatureage; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param $unknown1 I don't know! But it comes right after the DSUID in the GLST format. |
| 147 | 147 | * @param $unknown2 I don't know! But it comes right after unknown1. |
| 148 | 148 | */ |
| 149 | - public function AddDSInfo($DSUserID,$unknown1,$unknown2) { |
|
| 149 | + public function AddDSInfo($DSUserID, $unknown1, $unknown2) { |
|
| 150 | 150 | $this->dockingstationuser = $DSUserID; |
| 151 | 151 | $this->unknown1 = $unknown1; |
| 152 | 152 | $this->unknown2 = $unknown2; |
@@ -161,16 +161,16 @@ discard block |
||
| 161 | 161 | * @return A binary string containing GLST data ready to be put into a GLST history. |
| 162 | 162 | */ |
| 163 | 163 | public function Compile($format) { |
| 164 | - $data = pack('VVVVV',$this->eventtype,$this->worldtime,$this->creatureage,$this->timestamp,$this->lifestage); |
|
| 165 | - $data .= pack('V',strlen($this->moniker1)).$this->moniker1; |
|
| 166 | - $data .= pack('V',strlen($this->moniker2)).$this->moniker2; |
|
| 167 | - $data .= pack('V',strlen($this->usertext)).$this->usertext; |
|
| 168 | - $data .= pack('V',strlen($this->photograph)).$this->photograph; |
|
| 169 | - $data .= pack('V',strlen($this->worldname)).$this->worldname; |
|
| 170 | - $data .= pack('V',strlen($this->worldUID)).$this->worldUID; |
|
| 171 | - if($format == GLST_FORMAT_DS) { |
|
| 172 | - $data .= pack('V',strlen($this->dockingstationuser)).$this->dockingstationuser; |
|
| 173 | - $data .= pack('VV',$this->unknown1,$this->unknown2); |
|
| 164 | + $data = pack('VVVVV', $this->eventtype, $this->worldtime, $this->creatureage, $this->timestamp, $this->lifestage); |
|
| 165 | + $data .= pack('V', strlen($this->moniker1)).$this->moniker1; |
|
| 166 | + $data .= pack('V', strlen($this->moniker2)).$this->moniker2; |
|
| 167 | + $data .= pack('V', strlen($this->usertext)).$this->usertext; |
|
| 168 | + $data .= pack('V', strlen($this->photograph)).$this->photograph; |
|
| 169 | + $data .= pack('V', strlen($this->worldname)).$this->worldname; |
|
| 170 | + $data .= pack('V', strlen($this->worldUID)).$this->worldUID; |
|
| 171 | + if ($format == GLST_FORMAT_DS) { |
|
| 172 | + $data .= pack('V', strlen($this->dockingstationuser)).$this->dockingstationuser; |
|
| 173 | + $data .= pack('VV', $this->unknown1, $this->unknown2); |
|
| 174 | 174 | } |
| 175 | 175 | return $data; |
| 176 | 176 | } |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | //@{ |
| 14 | 14 | /** Sprite dependency - 'sprite' */ |
| 15 | -define('DEPENDENCY_SPRITE','sprite'); |
|
| 15 | +define('DEPENDENCY_SPRITE', 'sprite'); |
|
| 16 | 16 | /** Sound dependency - 'sound' */ |
| 17 | -define('DEPENDENCY_SOUND','sound'); |
|
| 17 | +define('DEPENDENCY_SOUND', 'sound'); |
|
| 18 | 18 | //@} |
| 19 | 19 | |
| 20 | 20 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param $agentName The name of the agent (as displayed in the C2 injector) |
| 55 | 55 | * @param $agentDescription The description of the agent (as displayed in the C2 injector) |
| 56 | 56 | */ |
| 57 | - public function COBAgentBlock($agentName,$agentDescription) { |
|
| 57 | + public function COBAgentBlock($agentName, $agentDescription) { |
|
| 58 | 58 | parent::COBBlock(COB_BLOCK_AGENT); |
| 59 | 59 | $this->agentName = $agentName; |
| 60 | 60 | $this->agentDescription = $agentDescription; |
@@ -115,10 +115,10 @@ discard block |
||
| 115 | 115 | * above. |
| 116 | 116 | * @return An array of COBDependency objects |
| 117 | 117 | */ |
| 118 | - public function GetDependencies($type=null) { |
|
| 118 | + public function GetDependencies($type = null) { |
|
| 119 | 119 | $dependenciesToReturn = array(); |
| 120 | - foreach($this->dependencies as $dependency) { |
|
| 121 | - if($type == null || $type == $dependency->GetType()) { |
|
| 120 | + foreach ($this->dependencies as $dependency) { |
|
| 121 | + if ($type == null || $type == $dependency->GetType()) { |
|
| 122 | 122 | $dependenciesToReturn[] = $dependency; |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param $dependency The COBDependency to add. |
| 154 | 154 | */ |
| 155 | 155 | public function AddDependency(COBDependency $dependency) { |
| 156 | - if(!in_array($dependency->GetDependencyName(),$this->dependencies)) { |
|
| 156 | + if (!in_array($dependency->GetDependencyName(), $this->dependencies)) { |
|
| 157 | 157 | $this->dependencies[] = $dependency; |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param $time The date this agent was last injected as a UNIX timestamp |
| 184 | 184 | */ |
| 185 | 185 | public function SetLastUsageDate($time) { |
| 186 | - if($time > time()) { |
|
| 186 | + if ($time > time()) { |
|
| 187 | 187 | return false; |
| 188 | 188 | } else { |
| 189 | 189 | $this->lastUsageDate = $time; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param $reserved2 The second reserved variable |
| 218 | 218 | * @param $reserved3 The third reserved variable |
| 219 | 219 | */ |
| 220 | - public function SetReserved($reserved1,$reserved2,$reserved3) { |
|
| 220 | + public function SetReserved($reserved1, $reserved2, $reserved3) { |
|
| 221 | 221 | $this->reserved1 = $reserved1; |
| 222 | 222 | $this->reserved2 = $reserved2; |
| 223 | 223 | $this->reserved3 = $reserved3; |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | /** @param $frame The thumbnail as a SpriteFrame |
| 227 | 227 | */ |
| 228 | 228 | public function SetThumbnail(SpriteFrame $frame) { |
| 229 | - if($this->thumbnail != null) { |
|
| 229 | + if ($this->thumbnail != null) { |
|
| 230 | 230 | throw new Exception('Thumbnail already added'); |
| 231 | 231 | } |
| 232 | 232 | $this->thumbnail = $frame; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * @param IReader $reader A StringReader or FileReader for the RCB |
| 238 | 238 | */ |
| 239 | 239 | public function AddC1RemoveScriptFromRCB(IReader $reader) { |
| 240 | - if($this->removeScript != '') { |
|
| 240 | + if ($this->removeScript != '') { |
|
| 241 | 241 | throw new Exception('Script already added!'); |
| 242 | 242 | } |
| 243 | 243 | $rcb = new COB($reader); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public static function CreateFromReaderC2(IReader $reader) { |
| 255 | 255 | $quantityAvailable = $reader->ReadInt(2); |
| 256 | - if($quantityAvailable == 0xffff) { |
|
| 256 | + if ($quantityAvailable == 0xffff) { |
|
| 257 | 257 | $quantityAvailable = -1; |
| 258 | 258 | } |
| 259 | 259 | $lastUsageDate = $reader->ReadInt(4); |
@@ -262,50 +262,50 @@ discard block |
||
| 262 | 262 | $expiryDay = $reader->ReadInt(1); |
| 263 | 263 | $expiryMonth = $reader->ReadInt(1); |
| 264 | 264 | $expiryYear = $reader->ReadInt(2); |
| 265 | - $expiryDate = mktime(0,0,0,$expiryMonth,$expiryDay,$expiryYear); |
|
| 265 | + $expiryDate = mktime(0, 0, 0, $expiryMonth, $expiryDay, $expiryYear); |
|
| 266 | 266 | |
| 267 | - $reserved = array($reader->ReadInt(4),$reader->ReadInt(4),$reader->ReadInt(4)); |
|
| 267 | + $reserved = array($reader->ReadInt(4), $reader->ReadInt(4), $reader->ReadInt(4)); |
|
| 268 | 268 | |
| 269 | 269 | $agentName = $reader->ReadCString(); |
| 270 | 270 | $agentDescription = $reader->ReadCString(); |
| 271 | 271 | |
| 272 | - $installScript = str_replace(',',"\n",$reader->ReadCString()); |
|
| 273 | - $removeScript = str_replace(',',"\n",$reader->ReadCString()); |
|
| 272 | + $installScript = str_replace(',', "\n", $reader->ReadCString()); |
|
| 273 | + $removeScript = str_replace(',', "\n", $reader->ReadCString()); |
|
| 274 | 274 | |
| 275 | 275 | $numEventScripts = $reader->ReadInt(2); |
| 276 | 276 | |
| 277 | 277 | $eventScripts = array(); |
| 278 | 278 | |
| 279 | - for($i=0;$i<$numEventScripts;$i++) { |
|
| 280 | - $eventScripts[] = str_replace(',',"\n",$reader->ReadCString()); |
|
| 279 | + for ($i = 0; $i < $numEventScripts; $i++) { |
|
| 280 | + $eventScripts[] = str_replace(',', "\n", $reader->ReadCString()); |
|
| 281 | 281 | } |
| 282 | 282 | $numDependencies = $reader->ReadInt(2); |
| 283 | 283 | $dependencies = array(); |
| 284 | 284 | |
| 285 | - for($i=0;$i<$numDependencies;$i++) { |
|
| 286 | - $type = ($reader->ReadInt(2) == 0)?DEPENDENCY_SPRITE:DEPENDENCY_SOUND; |
|
| 285 | + for ($i = 0; $i < $numDependencies; $i++) { |
|
| 286 | + $type = ($reader->ReadInt(2) == 0) ? DEPENDENCY_SPRITE : DEPENDENCY_SOUND; |
|
| 287 | 287 | $name = $reader->ReadCString(); |
| 288 | - $dependencies[] = new COBDependency($type,$name); |
|
| 288 | + $dependencies[] = new COBDependency($type, $name); |
|
| 289 | 289 | } |
| 290 | 290 | $thumbWidth = $reader->ReadInt(2); |
| 291 | 291 | $thumbHeight = $reader->ReadInt(2); |
| 292 | 292 | |
| 293 | - $thumbnail = new S16Frame($reader,'565',$thumbWidth,$thumbHeight,$reader->GetPosition()); |
|
| 293 | + $thumbnail = new S16Frame($reader, '565', $thumbWidth, $thumbHeight, $reader->GetPosition()); |
|
| 294 | 294 | $reader->Skip($thumbHeight*$thumbWidth*2); |
| 295 | 295 | |
| 296 | 296 | //parsing finished, onto making an AgentBlock. |
| 297 | - $agentBlock = new COBAgentBlock($agentName,$agentDescription); |
|
| 297 | + $agentBlock = new COBAgentBlock($agentName, $agentDescription); |
|
| 298 | 298 | $agentBlock->AddQuantityAvailable($quantityAvailable); |
| 299 | 299 | $agentBlock->AddReuseInterval($reuseInterval); |
| 300 | 300 | $agentBlock->AddExpiryDate($expiryDate); |
| 301 | 301 | $agentBlock->AddLastUsageDate($lastUsageDate); |
| 302 | - $agentBlock->AddReserved($reserved[0],$reserved[1],$reserved[2]); |
|
| 302 | + $agentBlock->AddReserved($reserved[0], $reserved[1], $reserved[2]); |
|
| 303 | 303 | $agentBlock->AddInstallScript($installScript); |
| 304 | 304 | $agentBlock->AddRemoveScript($removeScript); |
| 305 | - foreach($eventScripts as $eventScript) { |
|
| 305 | + foreach ($eventScripts as $eventScript) { |
|
| 306 | 306 | $agentBlock->AddEventScript($eventScript); |
| 307 | 307 | } |
| 308 | - foreach($dependencies as $dependency) { |
|
| 308 | + foreach ($dependencies as $dependency) { |
|
| 309 | 309 | $agentBlock->AddDependency($dependency); |
| 310 | 310 | } |
| 311 | 311 | $agentBlock->AddThumbnail($thumbnail); |
@@ -319,27 +319,27 @@ discard block |
||
| 319 | 319 | * |
| 320 | 320 | */ |
| 321 | 321 | public static function CreateFromReaderC1(IReader $reader) { |
| 322 | - $quantityAvailable = $reader->ReadInt(2); |
|
| 322 | + $quantityAvailable = $reader->ReadInt(2); |
|
| 323 | 323 | $expires_month = $reader->ReadInt(4); |
| 324 | 324 | $expires_day = $reader->ReadInt(4); |
| 325 | 325 | $expires_year = $reader->ReadInt(4); |
| 326 | - $expiryDate = mktime(0,0,0,$expires_month,$expires_day,$expires_year); |
|
| 326 | + $expiryDate = mktime(0, 0, 0, $expires_month, $expires_day, $expires_year); |
|
| 327 | 327 | |
| 328 | 328 | $numObjectScripts = $reader->ReadInt(2); |
| 329 | 329 | $numInstallScripts = $reader->ReadInt(2); |
| 330 | 330 | $quantityUsed = $reader->ReadInt(4); |
| 331 | 331 | $objectScripts = array(); |
| 332 | - for($i=0;$i<$numObjectScripts;$i++) { |
|
| 332 | + for ($i = 0; $i < $numObjectScripts; $i++) { |
|
| 333 | 333 | $scriptsize = $reader->ReadInt(1); |
| 334 | - if($scriptsize == 255) { |
|
| 334 | + if ($scriptsize == 255) { |
|
| 335 | 335 | $scriptsize = $reader->ReadInt(2); |
| 336 | 336 | } |
| 337 | 337 | $objectScripts[$i] = $reader->Read($scriptsize); |
| 338 | 338 | } |
| 339 | 339 | $installScripts = array(); |
| 340 | - for($i=0;$i<$numInstallScripts;$i++) { |
|
| 340 | + for ($i = 0; $i < $numInstallScripts; $i++) { |
|
| 341 | 341 | $scriptsize = $reader->ReadInt(1); |
| 342 | - if($scriptsize == 255) { |
|
| 342 | + if ($scriptsize == 255) { |
|
| 343 | 343 | $scriptsize = $reader->ReadInt(2); |
| 344 | 344 | } |
| 345 | 345 | $installScripts[$i] = $reader->Read($scriptsize); |
@@ -348,23 +348,23 @@ discard block |
||
| 348 | 348 | $pictureHeight = $reader->ReadInt(4); |
| 349 | 349 | $unknown = $reader->ReadInt(2); |
| 350 | 350 | $sprframe = null; |
| 351 | - if($pictureWidth > 0 || $pictureHeight > 0) { |
|
| 352 | - $sprframe = new SPRFrame($reader,$pictureWidth,$pictureHeight); |
|
| 351 | + if ($pictureWidth > 0 || $pictureHeight > 0) { |
|
| 352 | + $sprframe = new SPRFrame($reader, $pictureWidth, $pictureHeight); |
|
| 353 | 353 | $sprframe->Flip(); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | $agentName = $reader->Read($reader->ReadInt(1)); |
| 357 | 357 | |
| 358 | - $agentBlock = new COBAgentBlock($agentName,''); |
|
| 358 | + $agentBlock = new COBAgentBlock($agentName, ''); |
|
| 359 | 359 | $agentBlock->AddQuantityAvailable($quantityAvailable); |
| 360 | 360 | $agentBlock->AddExpiryDate($expiryDate); |
| 361 | - if($sprframe != null) { |
|
| 361 | + if ($sprframe != null) { |
|
| 362 | 362 | $agentBlock->AddThumbnail($sprframe); |
| 363 | 363 | } |
| 364 | - foreach($objectScripts as $objectScript) { |
|
| 364 | + foreach ($objectScripts as $objectScript) { |
|
| 365 | 365 | $agentBlock->AddEventScript($objectScript); |
| 366 | 366 | } |
| 367 | - $agentBlock->AddInstallScript(implode("\n*c2ephp Install script seperator\n",$installScripts)); |
|
| 367 | + $agentBlock->AddInstallScript(implode("\n*c2ephp Install script seperator\n", $installScripts)); |
|
| 368 | 368 | return $agentBlock; |
| 369 | 369 | } |
| 370 | 370 | /// @endcond |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | /** @param $type The type of dependency ('sprite' or 'sound'). |
| 384 | 384 | * @param $name The name of the dependency (four characters, no file extension) |
| 385 | 385 | */ |
| 386 | - public function COBDependency($type,$name) { |
|
| 386 | + public function COBDependency($type, $name) { |
|
| 387 | 387 | $this->type = $type; |
| 388 | 388 | $this->name = $name; |
| 389 | 389 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param $name The file name (including extension) |
| 21 | 21 | * @param $contents The contents of the file |
| 22 | 22 | */ |
| 23 | - public function COBFileBlock($type,$name,$contents) { |
|
| 23 | + public function COBFileBlock($type, $name, $contents) { |
|
| 24 | 24 | parent::COBBlock(COB_BLOCK_FILE); |
| 25 | 25 | $this->fileType = $type; |
| 26 | 26 | $this->fileName = $name; |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | * @param $reader The reader the data's coming from |
| 71 | 71 | */ |
| 72 | 72 | public static function CreateFromReader(IReader $reader) { |
| 73 | - $type = ($reader->ReadInt(2)==0)?'sprite':'sound'; |
|
| 73 | + $type = ($reader->ReadInt(2) == 0) ? 'sprite' : 'sound'; |
|
| 74 | 74 | $reserved = $reader->ReadInt(4); |
| 75 | 75 | $size = $reader->ReadInt(4); |
| 76 | 76 | $fileName = $reader->ReadCString(); |
| 77 | 77 | $contents = $reader->Read($size); |
| 78 | - $block = new COBFileBlock($type,$fileName,$contents); |
|
| 78 | + $block = new COBFileBlock($type, $fileName, $contents); |
|
| 79 | 79 | $block->AddReserved($reserved); |
| 80 | 80 | return $block; |
| 81 | 81 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @param $version The version number of this COB (integer) |
| 28 | 28 | * @param $revision the COB's revision number (integer) |
| 29 | 29 | */ |
| 30 | - public function COBAuthorBlock($authorName,$authorEmail,$authorURL,$authorComments,$creationTime,$version,$revision) { |
|
| 30 | + public function COBAuthorBlock($authorName, $authorEmail, $authorURL, $authorComments, $creationTime, $version, $revision) { |
|
| 31 | 31 | parent::COBBlock(COB_BLOCK_AUTHOR); |
| 32 | 32 | $this->authorName = $authorName; |
| 33 | 33 | $this->authorEmail = $authorEmail; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $creationDay = $reader->ReadInt(1); |
| 109 | 109 | $creationMonth = $reader->ReadInt(1); |
| 110 | 110 | $creationYear = $reader->ReadInt(2); |
| 111 | - $timestamp = mktime(0,0,0,$creationMonth,$creationDay,$creationYear); |
|
| 111 | + $timestamp = mktime(0, 0, 0, $creationMonth, $creationDay, $creationYear); |
|
| 112 | 112 | $version = $reader->ReadInt(1); |
| 113 | 113 | $revision = $reader->ReadInt(1); |
| 114 | 114 | $authorName = $reader->ReadCString(); |
@@ -5,11 +5,11 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | ///@{ |
| 7 | 7 | /// @brief Agent Block - 'agnt' |
| 8 | -define('COB_BLOCK_AGENT','agnt'); |
|
| 8 | +define('COB_BLOCK_AGENT', 'agnt'); |
|
| 9 | 9 | /// @brief File Block - 'file' |
| 10 | -define('COB_BLOCK_FILE','file'); |
|
| 10 | +define('COB_BLOCK_FILE', 'file'); |
|
| 11 | 11 | /// @brief Author Block - 'auth' |
| 12 | -define('COB_BLOCK_AUTHOR','auth'); |
|
| 12 | +define('COB_BLOCK_AUTHOR', 'auth'); |
|
| 13 | 13 | ///@} |
| 14 | 14 | |
| 15 | 15 | /// @brief The base COB block class |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param $type What type of COBBlock it is. Must be a 4-character string. |
| 24 | 24 | */ |
| 25 | 25 | public function COBBlock($type) { |
| 26 | - if(strlen($type) != 4) { |
|
| 26 | + if (strlen($type) != 4) { |
|
| 27 | 27 | throw new Exception('Invalid COB block type: '.$type); |
| 28 | 28 | } |
| 29 | 29 | $this->type = $type; |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | * @param $type The four-character type of the block |
| 16 | 16 | * @param $contents The contents of the block |
| 17 | 17 | */ |
| 18 | - public function COBUnknownBlock($type,$contents) { |
|
| 18 | + public function COBUnknownBlock($type, $contents) { |
|
| 19 | 19 | parent::COBBlock($type); |
| 20 | 20 | } |
| 21 | 21 | |