Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 47

Thread: Pak Files?

  1. #31

    Pak Files?

    I have written a pak editor that uses the same structure as Harry Hunt's, to compile the application you need delphi 7 and Jvcl component set, but the zip also contains the exe and a package.

    The source code is a bit of a mess, i havnt really had much time to clear it yet. And their is still a few problems i need to sort out with in it!

    The zip is 2.04mb : http://www.biocoders.org/kPak.zip

    I hope it helps.
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

  2. #32

    Pak Files?

    Hey thanks alot.
    I have a 2005 CRF 250 so &lt;^&gt;(&gt;&lt&lt;^&gt;
    <br />http://www.gtrpg.com/

  3. #33

    Pak Files?

    Why will this not work:

    [pascal]Function IsAPack(FileNametring):Boolean;
    Var Stream : TFileStream;
    Signature : String[6];
    Begin
    Result := False; // Prove me wrong!
    Stream := TFileStream.Create(FileName, fmOpenRead);
    Stream.Position := Stream.Size-6;
    Stream.ReadBuffer(Signature, 6);
    Stream.Free;
    If Signature = 'GTPACK' Then
    Result := True;
    End;[/pascal]
    I have a 2005 CRF 250 so &lt;^&gt;(&gt;&lt&lt;^&gt;
    <br />http://www.gtrpg.com/

  4. #34

    Pak Files?

    The above gives out GTPAC

    I dont know why.

    And also, how do i know how many headers I have?

    Currently i've come up with doing it like this... Im not sure how efficient it is:

    [pascal]public
    bob : Array of TPackageItem;
    end;[/pascal]


    [pascal]n := 1;
    While n <> 0 do
    begin
    SetLength(Bob, High(Bob)+2);
    Stream.ReadBuffer(Bob[High(Bob)],SizeOf(TPackageItem));
    If (Stream.Size - Stream.Position) < SizeOf(TPackageItem) Then n := 0;
    end;[/pascal]
    I have a 2005 CRF 250 so &lt;^&gt;(&gt;&lt&lt;^&gt;
    <br />http://www.gtrpg.com/

  5. #35

    Pak Files?

    a)
    try
    [pascal]
    function IsAPack(FileName: string): Boolean;
    var
    Stream: TFileStream;
    Signature: string[6];
    begin
    Result := False; // Prove me wrong!
    Stream := TFileStream.Create(FileName, fmOpenRead);
    Stream.Seek(SizeOf(Signature), soFromEnd);
    Stream.ReadBuffer(Signature, SizeOf(Signature));
    Stream.Free;
    if Signature = 'GTPACK' then
    Result := True;
    end;
    [/pascal]

    b)
    Your second question (how do you know how many headers you have) is answered by the image in my last post:
    Your package file should have the following structure: the actual files followed by a file table follow by a footer. The footer can consist of only two values, the Signature and a value "FileCount" which tells you how many files there are in your package. You'd then do something like

    [pascal]
    PackageStream.Seek(SizeOf(Signature) + SizeOf(Int64) + (FileCount * SizeOf(TPackageItem)), soFromEnd);
    for I := 1 to FileCount do
    begin
    Stream.Read(PackageItem, SizeOf(TPackageItem);
    // Add the package item to a list
    end;
    [/pascal]
    Ask me about the xcess game development kit

  6. #36

    Pak Files?

    I am not sure why, but when i do:

    [pascal]Stream.Seek(SizeOf(Signature), soFromEnd);[/pascal]

    The stream.position then becomes 125310 ... The file size is 125303

    So it's obviously adding 7 wich is sizeof(signature) ... This shouldnt be happening right?
    I have a 2005 CRF 250 so &lt;^&gt;(&gt;&lt&lt;^&gt;
    <br />http://www.gtrpg.com/

  7. #37

    Pak Files?

    This should be happening, soFromEnd does not reverse the direction ar anything, to seek back add a minus, Stream.Seek(-SizeOf(Signature), soFromEnd);

  8. #38

    Pak Files?

    damn, I forgot the minus. Sorry 'bout that!
    Ask me about the xcess game development kit

  9. #39

    Pak Files?

    Thanks paulius... and DAMN YOU Harry! Lol j/k! I was freaking out like my delphi was screwy or something... But yea, I started using a minus to see if it worked and it did... And anyway, I believe I have a pretty good understanding of filestreams in Delphi now, for wich I greatly thank you guys. I expect my packaging code to be finished by either tonight or tommarow. Thanks again!

    Just curious... I tried:

    [pascal]Var Signature tring[6]
    Begin
    Signature := 'GTPACK';
    ShowMessage(IntToStr(SizeOf(Signature)));
    End;[/pascal]
    And it returns '4' ... Shouldnt it return 6? 1 byter per character?
    I have a 2005 CRF 250 so &lt;^&gt;(&gt;&lt&lt;^&gt;
    <br />http://www.gtrpg.com/

  10. #40
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Pak Files?

    It should return 7 one for each Character and a single byte storing the lengeth of the string.

    Short Strings come from old Turbo Pascal days where the maximum length of a string was 255 characters. Each string was actually an array of characters with the zero index being a byte representing the length of the string. (This also allows you to do something like Password[1] to return the first character in the Password string)
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

Page 4 of 5 FirstFirst ... 2345 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •