[FF7] command line tools for LGP archives - LGP/UnLGP (v.5)

  • Thread starter Thread starter Aali
  • Start date Start date
Status
Not open for further replies.
Well, I'm almost through and there are a few issues to resolve.

First and foremost, reading the count of objects in an LGP archive. Your code reads:
Code: [Select]
Code:
        Dim fs As FileStream = New FileStream(OpenedFile, FileMode.Open, FileAccess.Read)        Dim stream As New StreamReader(fs)        Dim b As Integer        stream.BaseStream.Seek(12, SeekOrigin.Begin)        For i = 0 To 3            Select Case i                Case 0                    b += stream.Read()                Case 1                    b += (stream.Read() * 256)                Case 2                    b += (stream.Read() * 65536)                Case 3                    b += (stream.Read() * 16777216)            End Select        Next        stream.Close()        fs.Close()        MsgBox("This file Contains " & b & " objects!")
Are you kidding, LeeHiOoO? Why have you added these redundant For...Next and Select...Case statements? There will be absolutely no difference if you delete them, like this:
Code: [Select]
Code:
        Dim fs As FileStream = New FileStream(OpenedFile, FileMode.Open, FileAccess.Read)        Dim stream As New StreamReader(fs)        Dim b As Integer        stream.BaseStream.Seek(12, SeekOrigin.Begin)                    b += stream.Read()                    b += (stream.Read() * 256)                    b += (stream.Read() * 65536)                    b += (stream.Read() * 16777216)        stream.Close()        fs.Close()        MsgBox("This file Contains " & b & " objects!")
However, both codes are inherently erroneous. Check this out: http://rapidshare.com/files/2684511...chives__as_reported_by_various_LGP_Tools.xlsx

This is a report that compares the count of objects inside various FF7 LGP Archives as reported by Aali/Kranmer UnLGP.exe v0.5 and your LGP_VBNET. As you can see, there are inconsistencies. Your LGP_VBNET reports wrong number of items for magic.lgp, flevel.lgp, chocobo.lgp, condor.lgp and world_us.lgp.

Basically, you are calculating the number of items in an unaligned self-composed Little-Endian manner. What's more is that you use a Text File Stream Reader to read bytes from a binary file, while you should have used a Binary Stream Reader to do so. Meanwhile, be careful not to read "Char" in UTF-8 formats.

The correct code to read the number of items is:
Code: [Select]
Code:
        Dim fs As FileStream = New FileStream(OpenedFile, FileMode.Open, FileAccess.Read)        Dim TheLGPFile As BinaryReader = New BinaryReader(fs, Encoding.GetEncoding(1252))        Dim tmp(12) As Byte        TheLGPFile.Read(tmp, 0, 12)        Dim LGPObjectsNum As Integer = TheLGPFile.ReadInt32()        TheLGPFile.Close()        fs.Close()        Return LGPObjectsNum
Here, try this update. I've implemented a debug routine to quickly read and compare the number of items in standard LGP archives of FF7 v1.02: http://rapidshare.com/files/268455952/LGP_VBNET_update_2_Fleet_Command.zip

There is also issues with user-interface too. Consider setting Tab Order properties appropriately. Also add shortcut for the most frequently used menu items (the way I did in case of Open...) but not all menu items need shortcuts. Try to use shortcuts which are familiar for Windows users. (Notepad is a good example that you can use)

And now:
Now, fix the structs and being implementing LGP_Stream class, DeLGP class, their file I/O methods and exception-catching code. Remember: LGP_Stream will have two descendants: DeLGP and EnLGP classes. While LGP_Stream performs generic functions, DeLGP and EnLGP classes will be variants of this class that perform specialized I/O, i.e. DeLGP class opens LGP files that already exist as read only. Meanwhile EnLGP class creates nonexistent empty LGP files with write access.

Currently, focus on DeLGP class and leave implementing EnLGP class for a later time. (You don't want to be buried under a thick layer of unused codes, do you?) For now, focus on creating an LGP extractor and focus more on creating underlying codes than User Interface. (But don't forget about it either.) Start by moving this count-reader code from your form code into LGP_Stream and DeLGP classes.

Remember: These I/O classes should have no User Interface items like message boxes. Have the methods of these classes to return error codes. Your form, which is currently in charge of user interface, and later, maybe other classes, are the only elements which should generate message boxes.

Let me see the results. If they were done properly, the most time-taking part is finished. (You'll probably need no help building the rest of the program on your own but I'll stick around.)

Oh, and whenever you feel you don't need to experiment with the debug code that I added, you can safely remove it and its Listbox1 and Menu item.

Good luck
 
Haha.. I didn't even notice the redundancy... so many codes in my head  :-P

Ok, the thing is... I'm just an amateur dealing with files. The only successful prog I've ever did was a software for Jukebox Machines, which I work with, and I didn't had to handle file streams issues... just wmp ocx stuff.
Also... I may say... I'm an amateur in general programming.... I didn't knew we had classes and functions to deal with binary stream. As I go learning stuff in here... I'm starting to think I'll need to start over the other prog I'm trying to do. So many stuff I didn't even knew about.

Another issue: I don't know nothing about encoding. UTF-8 , ANSI, Unicode... I can't tell the difference.

Can u take a look at my other prog?  :roll:
Of course it'll be a disaster when u open up the code... but it's just to show you how far I got without knowing a lot of stuff...


say there... can we continue this topic on this thread? (new update there)
I think our topic has nothing to do with this thread(until release) and we may be annoying ppl here.
 
Last edited:
^ I see. So, you'll have to boost your knowledge about Unicode. Let's see if I can find anything...

We can continue our dicsussion wherever you wish, even in that thread but I don't think halkun is going to like us doing this. You see, we're not off-topic here. And besides, we're not going to receive much feedback in there. But if you wish so... so be it.
 
Hi all.
From top to bottom what am I looking at here?
Can anyone give a straight answer on what exactly the binaries do and how to use them?
:3
 
"Binaries" here means "computer software" or "computer program".

The discussion here is about LGP Tools called "LGP.exe" and "UnLGP.exe" that Aali and Kranmer have created. Now, Aali didn't give us something that can be called a "computer program". Aali just give us their "source codes", instructions for the computer that if undergo a process called "compile", they will become a program, but are otherwise don't do anything. Kranmer finished Aali's work by compiling those source codes and producing "binaries" or the computer programs that you can run.

"UnLGP.exe" and "LGP.exe" (that Kranmer have produced from Aali's source codes) are "command-line" programs, meaning that they can only be run from within Command Prompt (a Windows program) or other such programs, by typing text commands. They are not like normal Windows programs (such as WinZip) that have graphic windows and menus and you can use with mouse.

So, LeeHiOoO decided to change Aali's source code into a normal Windows program. Its a tough job but it is almost finished.
 
What specifically do the exes do?

Unlgp extracts file x to folder y.  How do we know which file/folder?
 
"Exe" is the short form of "executable". Exe is another name for computer program.

You specify the file you'd like to extract by giving its full address to UnLGP.exe. That is, by typing it in front of the UnLGP.EXE in Command Prompt. UnLGP.exe does not accept any other parameter. It extracts the LGP archive, which you specified, into the "Current Folder", also known as "Working Folder".
 
Ah, well there's my hiccup.

I thought there was a step I was missing somewhere.
When I run the exes the command prompt flashes up then terminates.

I figured the exe itself was designed to extract/pack files in the same folder.

I'm running Windows 7x64, admin account UAC disabled.
I'll try different compatibilities.
 
put an LGP in the same folder as unlgp.exe then drag and drop it onto unlgp.

For lgp.exe you need to run it in command line something like this "C:\lgp.exe c:\new c:\battle.lgp"
 
@willis:

If you just open the binaries you won't have time to read the instructions because the command line shows it too fast and close.
If you want to read it, you need to open your command line(Start>RUN>"cmd") and navigate through your directories and open the exe from there...
(ie. type "C:\LGP Folder\lgp.exe" or wherever is your .exe at)
 
As a side note, UAC and admin privileges have nothing to do with UnLGP.exe. UnLGP.exe only needs read permission for the LGP file which it opens and write permission for the folder into which it extracts. (which means almost any folder on your computer except Program Files or Windows is OK for extraction.)

However, if you wish to reduce the amount of alerts that UAC triggers when copying into your Final Fantasy VII folder, I advise you to edit file permissions on "data" folder and give Full Access to Authenticated Users. Now, you can use your Standard (non-admin) User Account to manipulate your LGP files without UAC ever bothering you. No need to worry about security either because viruses never infect data files.

EDIT: The pronoun "you" in the above paragraph refers to general public.
 
Hmm.. I though "LGP Tools" name was already taken by Ficedula a long time ago. I don't think Aali came up to a name for his version. *confused*
Maybe he should, some people may get confused thinking is the same program. Unless it's the generic name "lpg/unlpg".

Nice documentation though! Gratz
 
Last edited:
I have a problem with unlgp:
1.lgp and unlgp.exe in C:\LGP\ folder
i was write a .bat file
Code: [Select]
Code:
CD /d "C:\lgp\1"UnLGP.exe "C:\lgp\1.lgp" pause
when I was open this .bat file command line say
Code: [Select]
Code:
C:\lgp>CD /d "C:\lgp\1"C:\lgp\1>UnLGP.exe "C:\lgp\1.lgp"'UnLGP.exe' is not recognized as an internal or external command,operable program or batch file.C:\lgp\1>pausePress any key to continue . . .
help
 
Last edited:
I have a problem with unlgp:
1.lgp and unlgp.exe in C:\LGP\ folder
i was write a .bat file
Code: [Select]
Code:
CD /d "C:\lgp\1"UnLGP.exe "C:\lgp\1.lgp" pause
when I was open this .bat file command line say
Code: [Select]
Code:
C:\lgp>CD /d "C:\lgp\1"C:\lgp\1>UnLGP.exe "C:\lgp\1.lgp"'UnLGP.exe' is not recognized as an internal or external command,operable program or batch file.C:\lgp\1>pausePress any key to continue . . .
help

do this instead
CD /d "C:\lgp\"
UnLGP.exe %cd%\1\1.lgp
pause
 
Last edited:
i was wrong
CD /d "C:\lgp\1"
UnLGP.exe C:\lgp\1.lgp
pause
that wont work. change the first line to this if you want it to work
CD /d "C:\lgp"

or you can put the unlgp.exe into the C:\lgp\1\ folder
 
i want to the unlgp extract the lgp archive into "C:\lgp\1" folder, its possible?
 
i want to the unlgp extract the lgp archive into "C:\lgp\1" folder, its possible?
unlgp will extract the files into whatever folder unlgp is in
so put unlgp and the lgp into C:\lgp\1
 
Status
Not open for further replies.
Back
Top