Jump to content
  • 0

PHP read ACT file


CaioVictor

Question


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  75
  • Reputation:   0
  • Joined:  05/26/12
  • Last Seen:  

Hi rAthena ^^'

 

First excuse my English.

 

I have a problem in the PHP code below:


	$this->header = unpack('a2header/cversion/x/SmovementCount', fread($act, 10));

	$this->movements = array();

	for ($nMovement = 0; $nMovement < $this->header['movementCount']; $nMovement++) {
		$movementHeader = unpack('LframeCount', fread($act, 4));

		$this->movements[] = new ActionMovement($movementHeader);

		for ($nFrame = 0; $nFrame < $movementHeader['frameCount']; $nFrame++) {
			fseek( $act, 20, SEEK_CUR );

			$frameHeader = unpack('LlayerCount', fread($act, 4));

			$this
				->getMovement($nMovement)
				->addFrame(new ActionFrame($frameHeader, $this->getSprite()));

			for ($nLayer = 0; $nLayer < $frameHeader['layerCount']; $nLayer++) {
				$layerHeader = unpack('lxOffset/lyOffset/LsprFrame/Lmirror/Cred/Cgreen/Cblue/Calpha', fread($act, 14));

				if($this->header['version'] >= 2){
					$layerHeader += unpack('fxScale', fread($act, 4));
				}else{
					$layerHeader['xScale'] = 0;
				}

				if($this->header['version'] >= 4){
					$layerHeader += unpack('fyScale', fread($act, 4));
				}else{
					$layerHeader['yScale'] = $layerHeader['xScale'];
				}

				$layerHeader += unpack('Lrotation/LsprType', fread($act, 8));

				if($this->header['version'] >= 5){
					$layerHeader += unpack('LxSize/LySize', fread($act, 8));
				}

			}

			$frameData = unpack('LsoundFrame', fread($act, 4));
            
                        extract(unpack('lnumExtraInfo', fread($act, 4)));
                        for( $i=0; $i<$numExtraInfo; ++$i ){
                            $frameData += unpack('x4/VxExtra/VyExtra/x4', fread($act, 10));
                        }
		}
	}

	$this->header += unpack('LsoundCount', fread($act, 4));

	$this->sound = array();

	for ($nSound = 0; $nSound < $this->header['soundCount']; $nSound++) {
		$this->sound[] = array_pop(unpack('a40', fread($act, 28)));
	}

 

This code is working perfectly, including wiki Oboro ACT but in the case of  Kagerou ACT, returns the following error:

Warning: unpack() [<a href='function.unpack'>function.unpack</a>]: Type L: not enough input, need 4, have 0 in ...

 

That is relating the following line:

$layerHeader += unpack('Lrotation/LsprType', fread($act, 8));

 

I know that the code is not the best one, but can anyone help me fix?

 

 

Any help will be greatly appreciated.
 

Att,

CaioVictor.

Edited by CaioVictor
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...