Difference between revisions of "Talk:DBPF/Source Code"

From SimsWiki
Jump to: navigation, search
 
m
Line 32: Line 32:
  
 
So, if I created a routine to read the whole sequence (except that the DIR does not read the offset), and then checked if the file is compressed using an overloaded "==" operator, would it be wrong? I think it might improve the readability of the code. [[User:Albmont|Albmont]] 15:36, 1 January 2007 (EST)
 
So, if I created a routine to read the whole sequence (except that the DIR does not read the offset), and then checked if the file is compressed using an overloaded "==" operator, would it be wrong? I think it might improve the readability of the code. [[User:Albmont|Albmont]] 15:36, 1 January 2007 (EST)
 +
 +
You could certainly create a function to grab those 4 things and return them in an array.  It's duplicate code becuase, essentially, it's duplicate data - as we discussed on the DBPF page, it doesn't neccesarily make sense from a coders point of view. :)  [[User:Delphy|Delphy]] 16:13, 1 January 2007 (EST)

Revision as of 23:13, 1 January 2007

Me again :-) I will ask something about this code.

When you read the Index, this sequence of operations is used:

  $indexData[$i]['typeID'] = $this->revhex($this->strhex(fread($handle, 4)));
  $indexData[$i]['groupID'] = $this->revhex($this->strhex(fread($handle, 4)));
  $indexData[$i]['instanceID'] = $this->revhex($this->strhex(fread($handle, 4)));

  if ($this->indexMajorVersion == "7") && ($this->indexMinorVersion == "1")) {
    $indexData[$i]['instanceID2'] = $this->revhex($this->strhex(fread($handle, 4)));
  }
  $indexData[$i]['offset'] = $this->read_UL4($handle);
  $indexData[$i]['filesize'] = $this->read_UL4($handle);
  $indexData[$i]['compressed'] = false;
  $indexData[$i]['truesize'] = 0;

and then, when you read the DIR resource, almost exactly the same sequence is done:

  $typeID = $this->revhex($this->strhex(fread($handle, 4)));
  $groupID = $this->revhex($this->strhex(fread($handle, 4)));
  $instanceID = $this->revhex($this->strhex(fread($handle, 4)));
  if (($this->indexMajorVersion == "7") && ($this->indexMinorVersion == "1")) {
    $instanceID2 = $this->revhex($this->strhex(fread($handle, 4)));
  }
  $filesize_nc = $this->read_UL4($handle);

and finally you check if the file is compressed by comparing the fields.

So, if I created a routine to read the whole sequence (except that the DIR does not read the offset), and then checked if the file is compressed using an overloaded "==" operator, would it be wrong? I think it might improve the readability of the code. Albmont 15:36, 1 January 2007 (EST)

You could certainly create a function to grab those 4 things and return them in an array. It's duplicate code becuase, essentially, it's duplicate data - as we discussed on the DBPF page, it doesn't neccesarily make sense from a coders point of view. :) Delphy 16:13, 1 January 2007 (EST)

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox