Qhimm.com Forums

Final Fantasy 7 => FF7 Tools => Topic started by: Aali on 2009-07-12 16:00:49

Title: [FF7] command line tools for LGP archives - LGP/UnLGP (v.5)
Post by: Aali on 2009-07-12 16:00:49
In light of the recently discovered flaw in LGPTools, I decided to write my own tools to deal with LGP archives.

"lgp" creates an archive from a directory, "unlgp" unpacks an entire archive to the current directory

There's no GUI and they probably don't even compile on windows, but I'm sure it will be useful to someone.

Full source is available here: http://backup.ninjaloot.se/share/lgp-0.5.zip (http://backup.ninjaloot.se/share/lgp-0.5.zip)

I will not provide binaries, so don't ask.


--EDIT--

Both links were dead even, see below for binaries
Title: lgp/unlgp - command line tools for LGP archives
Post by: nfitc1 on 2009-07-16 13:13:38
By "recently discovered flaw", are you talking about the multiple duplicate file names or the fact that the area between the file header and the file data is unknown?
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-16 13:26:15
By "recently discovered flaw", are you talking about the multiple duplicate file names or the fact that the area between the file header and the file data is unknown?

It's not unknown, LGP Tools tries to write it, and messes it up. Specifically, underscores and minus signs as the first or second character of the filename will result in a broken lookup table (thats what it is) because LGP Tools doesn't know that these characters should get some special treatment when it comes to the lookup table. (As can be seen in lgp.h)
Title: lgp/unlgp - command line tools for LGP archives
Post by: Millenia on 2009-07-16 15:21:27
Can SOMEBODY please provide binaries? I'm a 3d artist, not a programmer, damn it :P
Title: lgp/unlgp - command line tools for LGP archives
Post by: nfitc1 on 2009-07-21 21:55:48
So I looked through it. You're saying that it's based entirely on the first two letters of the name of the file?

Also, your parts here:
Code: [Select]
158 toc.unknown1 = 14;
159 toc.unknown2 = 0;
160 toc.unknown3 = 0;
won't crash the game (I don't think), but I believe they have something to do with the files themselves. That unknown1 may be something like file properties while 2 and 3 are together one value having to do with duplicate file names.
It'll work with battle.lgp because it only uses the name of the file and they're all unique. Have you tried this with the others?
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-21 22:03:21
The lookup table is based on the first two letters, yes.

I have yet to see an LGP archive where those unknowns don't look like that, I'm not sure FF7 is even using them. Duplicate filenames could never work because FF7 always opens files by name only. (So if you really did have two files with the same name, it would only ever be able to find the first one)
Title: lgp/unlgp - command line tools for LGP archives
Post by: nfitc1 on 2009-07-21 22:37:27
I have yet to see an LGP archive where those unknowns don't look like that, I'm not sure FF7 is even using them. Duplicate filenames could never work because FF7 always opens files by name only. (So if you really did have two files with the same name, it would only ever be able to find the first one)

While that first unknown is most commonly 14, I've also seen it as 11 and even 3 on one file (I think). I'm not convinced it's being used either.

magic.lgp has duplicates all over the place. Open it in a hex editor. The two of the first three file names are "a.rsd". There are over 650 duplicate names (not to be confused with 650 files with the same name). This could possibly be explained that there are thousands of directories referenced by name in that same file. It's likely that some part of that table is referencing each file to one of those directories.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-21 23:21:08
Hmm, it does seem like I'll have to rethink my approach to this. FF7 seems to look for some files using two names, presumably one is used for the lookup table, while the other is the actual filename from the TOC.

Unfortunately this means that some of the original information was lost in the conversion to lgp archives, since there's no way to figure out which name is actually used to access a file, save for the first two characters used in the lookup table (and even then you have a conflict between k/l and _/-).

Expect a new version up soon that will handle this properly. For now, don't try to repack magic.lgp (field, char, battle and menu should work fine, the others I have not tested)

:EDIT:

Turns out my function for computing lookup values was still a bit off, numbers and periods were not handled properly. With that fixed, my previous theory about the lookup table still holds, the two first characters of the filename are used to find the file, nothing else. Unfortunately, that leaves the duplicate filenames mystery without a reasonable explanation. If only the filename is used to to find them, FF7 will simply open whichever file comes first in the TOC, leaving the other file inaccessible.

:EDIT #2:

Good news everyone!TM LGP files that do have subfolders provide a neat table of what goes where :-) Give me some time with this and soon enough these tools will be able to create/extract any kind of LGPs :-)

:EDIT #3:

Okay so it doesn't say exactly what goes where, it only specifies the folder name whenever there's a name conflict. Still, it's enough to (re)create a 1:1 copy of any existing LGP just from filesystem data.

:EDIT #4:

Only magic.lgp has name conflicts and the unlgp tool can now handle that properly, while the lgp tool is still missing some things. I also kind-of figured out what the last unknown means (unknown 2 & 3 is the offset into the conflict table), it's only ever 11 or 14, where 11 means it's a text file and 14 means it's a binary file. The game does not care about this field however, so just setting it to 14 for everything is fine.
Title: lgp/unlgp - command line tools for LGP archives
Post by: nfitc1 on 2009-07-22 12:36:07
Two questions:
1. How are 2/3 handled? Every file that shares a name with other file(s) also share this value.

Ex:
There are four "01.rsd" files in magic.lgp and they each have a 2/3 of 2. There are also four "01.p" files and they each have a 2/3 of 3. How does this get resolved exactly?

2. I'm also not certain that the unknown 1 is binary/text. The file deathlv5.hrc in magic.lgp was the first "11" file I found and it's the only .hrc in the magic.lgp. It is text, that's true. But then all the rsds would be text too and most of the .hrc files in char.lgp are "14" files. I do agree that the game doesn't care about this value, however.

It's not that I don't believe you, I just want to make sure I understand it all.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-22 12:52:23
Well I just figured the binary/text detection method was a bit crappy :-) While a bunch of text files are set to 14 as you say, I have not found any binary files set to 11.

unknown2/3 are actually one 16-bit value, an offset into the conflict table. Every offset into the conflict table has two or more path names, and each path has a TOC reference. If the path matches with the file you're trying to open, use that TOC entry, otherwise try the next path.

The conflict table is stored after the lookup table, starting with one 16-bit value indicating the number of conflicts present. For each of these, you first read another 16-bit value, this tells you how many paths are present for this conflict, then you read that many paths and their TOC indices (another 16-bit value).

It looks like this in the file:

[Number of conflicts (Let's say it's 2)][Number of paths for conflict 1 (Also 2)][<path>][<TOC index>][<path>][<TOC index>][Number of paths for conflict 2 (This one is 3)][<path>][<TOC index>][<path>][<TOC index>][<path>][<TOC index>]

FF7 then stores this information in a table of 4096 possible conflicts, each with a maximum of 255 paths.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-23 02:32:57
Check the repository for release 0.2b

This one should be able to unpack and repack any LGP archive in the game, including the elusive magic.lgp :-)

As an added bonus, you can now arrange files however you want in whatever subfolders you want, save for the conflicts in magic.lgp which have to stay in the right folder for FF7 to find them. (So, for example, you could arrange battle.lgp or char.lgp so that each separate model has its own subfolder, this will not affect the resulting LGP in any way)
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-23 16:23:02
Hi, Aali. Thanks for the new tool. I can't wait to compile and try it out. (Or at least I can't wait to find out what it is, how to compile it and how to try it out.) I'd highly appreciate if you give some insight as to the programming language with which the tool is written with or how to compile it. I'm looking at it and it is certainly neither of the programming languages that I know. (Yes, it looks like a bred of C but it is neither C# nor C++ Builder.)
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-23 16:31:47
It's just regular C. It was written for a linux environment, but it will work fine in cygwin. You could also make some small adjustments to make it work with MSVC/whatever windows compiler you might have.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-23 17:58:44
So, let me get this straight: I should rewrite your code and then compile it in Windows and do that every time you release a new version? Or is there a way to compile your code, as is, and then run it in Windows? Then, where does this Cygwin come into play?

By the way, I have question that might look dumb, so forgive me if I'm such an idiot, but why did you ever create a native Linux tool for a Windows game in the first place?

Thanks in advance.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-23 18:27:00
Rewrite? You could probably make it windows-compatible with a single preprocessor macro :-P

Cygwin is a complete unix environment for windows, so pretty much anything that compiles on linux will work with cygwin.
It would be quite silly to install cygwin just to run this one thing though, so if you don't have it, don't bother.

Why dev this on linux? It was convenient for me.
Title: lgp/unlgp - command line tools for LGP archives
Post by: nfitc1 on 2009-07-23 19:59:04
By the way, I have question that might look dumb, so forgive me if I'm such an idiot, but why did you ever create a native Linux tool for a Windows game in the first place?

'cause any of the good windows-based development platforms cost oodles of cash. Linux and Unix can compile C/C++ code just as well for free from just a simple text file.
I only have the 2008 .NET suite because I'm fortunate enough to work at a higher-education institution and we get MAJOR discounts on such software like that. There's no way I'd buy that professional license trash when the educational one works just fine for my needs.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-24 07:51:43
Rewrite? You could probably make it windows-compatible with a single preprocessor macro :-P

Cygwin is a complete unix environment for windows, so pretty much anything that compiles on linux will work with cygwin.
It would be quite silly to install cygwin just to run this one thing though, so if you don't have it, don't bother.

Why dev this on linux? It was convenient for me.
Thanks a bunch. I'll see what I can do. If I managed, do you mind if share the binaries with the rest of Qhimm community under Attribution-Share Alike-No Derivative Work terms?

By the way, I have question that might look dumb, so forgive me if I'm such an idiot, but why did you ever create a native Linux tool for a Windows game in the first place?
'cause any of the good windows-based development platforms cost oodles of cash. Linux and Unix can compile C/C++ code just as well for free from just a simple text file.
I'm afraid you are wrong. Visual Studio 2008 Express edition, CodeGear Delphi Lite and CodeGear C++ Builder Lite are all available free of charge. These free environment are fully capable of developing Windows applications.

Their only differences with their commercial editions are (1) lack advanced components such packages for developing Oracle database applications, Microsoft Office applications, MIDAS applications, 64-bit applications, mobile device applications, web applications (PHP or ASP.NET) as well as (2) advanced features such as source control, server development environments, profiling, advanced database connectivity, etc..

There are also other open-source development environments. We have lots of Java-based IDEs and compilers. There are myriads of C breeds.

Aali's answer however, was the logical and the acceptable one. Convenience is very important in software development. It simple takes millenia to develop a simple application with an inconvenient environment.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-24 12:05:37
You can do anything you want with it :-)

I would like to point out that Visual C++ Express lacks MFC, which is bad news for some people.
However if you're starting up a new project I don't see why on earth you'd choose to use MFC instead of a more portable API.
Title: lgp/unlgp - command line tools for LGP archives
Post by: arew264 on 2009-07-25 21:44:39
Eclipse + CDT + MinGW FTW!
I find this convenient because the same setup can be had on Linux, where it will use good ole GCC.

It is true that development is generally faster on Linux, if only because in many ways C/C++ in Windows are... Microsoft-ized. They add "safe" variants of the standard C library functions and then yell at you for not using them, and preprocessor directives must be used way more aggressively. Or such was my impression.
On the other hand, Linux development libraries can be installed quickly and painlessly, and you can have a full development environment inside of 10 minutes. None of this "ensure that your copy of Windows is genuine and download the Windows SDK" nonsense.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-26 08:20:38
 :x Spread your Anti-Microsoft or Anti-Linux propaganda somewhere else!  :x It is against the forum rules to verbally abuse either Microsoft or Unix-based products.

Besides, this thread is about Aali's LGP tool. If you have any question, suggestion or commentary about anything related to it, you are more than welcome to post. But anything else, especially verbal abuse, fancruft propaganda and the troubles of using pirated copies of software, is unwelcome.
Title: lgp/unlgp - command line tools for LGP archives
Post by: arew264 on 2009-07-26 16:35:25
That wasn't verbal abuse, that was simple statement of fact. Other programmers will say the same thing. I have respect for Microsoft, if only because Windows, as much as some people dislike it, is an excellent operating system with an uncompromising approach to usability. I love Linux, but it isn't for everyone. Windows has achieved that.

The question was raised as to why this tool hasn't been developed for Windows, and I was corroborating previous statements that development is easier on Linux. It is; that's the simple fact. If you think stating that is verbal abuse, then you're going to be offended for most of your life. I may have been harsher than I intended when I mentioned the SDK, but it's entirely true. To develop a Linux application, you download a few megabytes of development libraries and compilers. To develop on Windows, you download a DVD image (if I remember correctly, it was a full size DVD image) and use it to install the Windows SDK. This is a significant hinderance to development.
The other thing I left unsaid is that I find if easier to use the GCC MinGW compiler (basically GCC ported to Windows) to develop Windows applications than it is to develop them using Microsoft's tools when you plan to use good ole C rather than Microsoft Visual Basic or C#.

Now, if this is straight up C, I could look into porting it to Windows and possibly posting binaries if that would be useful.

EDIT: Also...
Quote
If you have any question, suggestion or commentary about anything related to it, you are more than welcome to post. But anything else, especially verbal abuse, fancruft propaganda and the troubles of using pirated copies of software, is unwelcome.
I could almost accuse you of verbal abuse for accusing me of being a verbal abuser, a propagandist, and a pirate in the same statement. I made it quite clear that DEVELOPMENT is easier on Linux. I never recommended it; I never said it was superior to Windows in any other way.
In fact, my first statement was a recommendation for an alternative development environment for Windows.
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-07-26 16:58:32
I don't think there is any doubt that you didn't verbally abuse anything. 

@FleetCommand, are there really forum rules against verbally abusing Microsoft or Unix?  I honestly never read the rules  :-P  I just lurked 6 months before posting.

Back to on topic, arew264, you said you think you could make a binary of this?
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-07-26 17:33:01
i have just built this and it works great (on XP SP3 anyway), i dont seem to be getting any errors in the app.log now looking for files that are there in flevel.lgp, thanks alot for this Aali it will be especially usefull now palmer is at the import+export stage.

EDIT:-

LGP 0.3b binaries compiled by me can be gotten here
http://www.mediafire.com/?iyvidgtm3y2
Title: lgp/unlgp - command line tools for LGP archives
Post by: m35 on 2009-07-26 17:44:14
Also just built these with MinGW on WinXP SP3 without errors. Didn't even need MSYS. Executed both lgp.exe and unlgp.exe without any arguments and they also ran without errors.

Code: [Select]
C:\lgp\make
cc -Wall  lgp.c -o lgp
cc -Wall  unlgp.c -o unlgp

C:\lgp\lgp
Usage: lgp <directory> <archive>

C:\lgp\unlgp
Usage: unlgp <archive>

Uploaded the 0.2b binaries here. They will be available as long as Google Page Creator is still available (it was supposed to shut down last month).

I also want to ensure no one is of the the misconception that VS Express, or any Windows dev environments, can be used without cost. They are dependent on other software that has a price tag of at least $100USD.


Edit:Oops, I am incorrect. My binary needed cygwin.dll. kranmer binary doesn't, which is much nicer.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-26 19:55:45
You should probably bundle the required .dlls as well.
I don't think people with cygwin already installed are going to need those binaries :-)
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-07-26 20:09:59
here is my binary that doesnt require the cygwin DLL (proberly because i didnt use cygwin i used MinGW)
http://www.mediafire.com/?mmdmjzfyatz
Title: lgp/unlgp - command line tools for LGP archives
Post by: m35 on 2009-07-27 05:11:54
You should probably bundle the required .dlls as well.
I don't think people with cygwin already installed are going to need those binaries :-)

Didn't think I needed to clarify, but like kranmer, I also didn't need cygwin to build the binaries (just used MinGW and make for MinGW).

Both kranmer and my binaries don't have any dependencies except MS Windows (and perhaps msvcrt*.dll, but most people should have that installed already).


Edit: Oops, I am incorrect. My binaries do need cygwin.dll. Pay no attention to this post.
Title: lgp/unlgp - command line tools for LGP archives
Post by: arew264 on 2009-07-27 05:23:29
I guess I don't need to worry about making a binary then.
MinGW is a much better solution to compiling applications on Windows than Cygwin.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-27 05:52:32
Didn't think I needed to clarify, but like kranmer, I also didn't need cygwin to build the binaries (just used MinGW and make for MinGW).

Both kranmer and my binaries don't have any dependencies except MS Windows (and perhaps msvcrt*.dll, but most people should have that installed already).

You didn't need to clarify, your binary needs cygwin1.dll, kranmers doesn't.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-27 06:12:03
Successfully compiled it under Microsoft C# Express! Compiled it under C++ but resulted in DEP errors so I skipped it. However, C# did the charm.

@Aali: Permission to build a Windows GUI version?
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-07-27 06:38:43
Successfully compiled it under Microsoft C# Express! Compiled it under C++ but resulted in DEP errors so I skipped it. However, C# did the charm.

@Aali: Permission to build a Windows GUI version?
If the source is made available, it's usually ok to do with it whatever you like :)
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-27 07:39:49
:lol: The source code will be included, if Aali gives permission, since it will be published under Attribution, Share-alike, No Derivative Work.

:lol: But what do you want the source code for, when I'm going to publish it under Attribution, Share Alike, No Derivative Work?

As a side note, consider reading http://forums.qhimm.com/index.php?topic=5834.0, subsection "Arrrr, matey! I downloaded FF7 and...".
Title: lgp/unlgp - command line tools for LGP archives
Post by: arew264 on 2009-07-27 08:00:22
No, he's saying that because Aali released his source, you're generally free to do what you want with it. Whether you need to release the source to anything you make depends on the license Aali is using.

Okay, why do you keep bringing up piracy? We're talking about LGP packing and unpacking utilities and nothing even related to piracy, so why are you posting this?
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-27 09:40:27
No, he's saying that because Aali released his source, you're generally free to do what you want with it. Whether you need to release the source to anything you make depends on the license Aali is using.
Last time I checked, he said "if the source is made available" not "since/when the source is made available". So, he is talking about my source code.

Okay, why do you keep bringing up piracy? We're talking about LGP packing and unpacking utilities and nothing even related to piracy, so why are you posting this?
It was not to you! And it was not about piracy. Obesebear has already asked me to "chill out %50" and so I posted that link just for a funny mention of employing BY-SA-ND. It was certainly not about Microsoft, Piracy or WGA. So, stop attacking other people.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-27 14:21:37
Well, this is the license; do whatever you want with it, unless I ask you to stop. Also give some credit. :-P
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-07-27 16:02:35
No, he's saying that because Aali released his source, you're generally free to do what you want with it. Whether you need to release the source to anything you make depends on the license Aali is using.
Last time I checked, he said "if the source is made available" not "since/when the source is made available". So, he is talking about my source code.
Actually I was talking about Aali's source code.  In hindsight, maybe I should have said since
The reason I said IF is because I was generalizing ANY source code made available.  Sorry about the misunderstanding :P
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-29 06:24:29
Well, this is the license; do whatever you want with it, unless I ask you to stop. Also give some credit. :-P
What? Propertiary Subsidiary license?  :-o

Well, I didn't expect it, celebrated one. Although, no hard feelings, you are the owner of your own work. Still, this type of license is so unprecendented amongst Linux applications...

So... there will be no Windows GUI version, then. But at least I still have my .NET console application binaries licensed under CC-BY-SA-ND. Besides, I think this licensing example serves as a great example of reality for likes of arew264.

Thanks anyway.
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-07-29 06:32:13
He's saying it doesn't have a license.
All he wants from you is to give him credit
Title: lgp/unlgp - command line tools for LGP archives
Post by: arew264 on 2009-07-29 06:48:07
Why is everything such a big deal with you? He's not naming a specific license because there isn't one. If you can make it better, make it better. If you can make it more accessible, make it more accessible. If you want to add a GUI to make it more user friendly, I highly doubt Aali will raise any protest. He didn't post the source code so he could wave it in front of you, he posted it because others can build on his work.

And seriously, stop with the side remarks about Linux and me. Linux applications can be closed source as well, in fact, I run my main development desktop with closed source NVidia video drivers. That's reality. The open source ATI drivers for my laptop are way better than the closed source ones. That's reality as well.
I mentioned WGA because it's another level of irritation between me and getting work done, not because I endorse any form of piracy. I run legal copies of Windows, I just don't like to have to prove it every time.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-29 07:14:43
He's saying it doesn't have a license.
All he wants from you is to give him credit
No he is saying:
Well, this is the license; do whatever you want with it, unless I ask you to stop. Also give some credit. :-P
Come on man, take it easy. Aali did a good job and he feels protective about it, so much that does not think a less strict license like CC-BY-SA-ND (which also gives proper credit) is enough. I repeat, He has the right to. And well...  :| I have the right to not develop a Windows GUI version under these conditions.
Why is everything such a big deal with you? He's not naming a specific license because there isn't one. If you can make it better, make it better. I you can make it more accessible, make it more accessible. If you want to add a GUI to make it more user friendly, I highly doubt Aali will raise any protest. He didn't post the source code so he could wave it in front of you, he posted it because others can build on his work.

And seriously, stop with the side remarks about Linux and me. Linux applications can be closed source as well, in fact, I run my main development desktop with closed source NVidia video drivers. That's reality. The open source ATI drivers for my laptop are way better than the closed source ones. That's reality as well.
I mentioned WGA because it's another level of irritation between me and getting work done, not because I endorse any form of piracy. I run legal copies of Windows, I just don't like to have to prove it every time.
:-o I didn't mean any of what you said, because if I wanted to mean so, I'd have written it so. I meant exactly what I wrote: People, even celebrated people like Aali, feel protective of their own work and they have the right to. I did not meantion anything about WGA, Microsoft, Open-source, Piracy or anything else.

So, please stop acting offensive. Seriously, if you have a problem with Microsoft or WGA, keep them away from this forum.
Title: lgp/unlgp - command line tools for LGP archives
Post by: arew264 on 2009-07-29 07:20:23
No, this isn't me being angry, this is me being irritated and perplexed.
You previously claimed I was insulting Microsoft and suggesting piracy, and in that last post you tried to poke an insult at Linux and claimed that I needed to find "reality." I don't care how you feel about Linux or anything else, just don't throw in side remarks that insult me and the software I choose to use and then claim you didn't say anything. It's unprofessional, if nothing else.
And now I really am off topic. Ah well, it had to be done.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Hellbringer616 on 2009-07-29 07:25:59
anywaaayyy...

About this GUI version, do you plan to release it? Sorry if you answered already, i didn't wanna read all this licensing thing i don't understand
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-07-29 08:07:56
^ Just let me calm down, dear hellbringer616. Currently, I feel like leaving this forum and never post again.

EDIT: Not that you guys miss me. I've been usless commentator, haven't I?
Title: lgp/unlgp - command line tools for LGP archives
Post by: Hellbringer616 on 2009-07-29 08:09:07
no problem, i was just wondering if you were releasing it or just keeping it for you.

By all means take your time, i don't like rushing anyone here :-D
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-07-29 17:46:39
FleetCommand,  you really need to chill.  You seem to have a good grasp of the English language but you also seem to have trouble understanding implications.   Aali doesn't care if you use his source code to make a GUI. 

In the unlikely case you completely bastardize it and break laws, he will ask you to stop.

He also wants you to mention in the readme that it was his source code you used.   I'm sure he will clear this up once he reads all of this

Really guys, it's the internet.  Just calm down

Edited for clarity
Title: lgp/unlgp - command line tools for LGP archives
Post by: arew264 on 2009-07-29 17:49:26
EDIT: Not that you guys miss me. I've been usless commentator, haven't I?

That is simply not the case. You wanted to make something that would make this tool more useful, and we've had... misunderstandings. Nothing more.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-07-29 18:10:43
FleetCommand: If you make a program that kills peoples dogs based on my code, I won't be too happy about it (but very impressed that you managed to kill dogs with a piece of software)
Unless you do something incredibly broken and/or offensive and put my name on it, I don't care what you do with the code.
It's not like I can enforce any of these "demands" anyway, so just don't be an ass and we'll be cool.
Title: lgp/unlgp - command line tools for LGP archives
Post by: halkun on 2009-07-30 06:04:34
Geez, I take a day off to fix my car and you guys crap all over this thread. Honestly, I can't take my eyes away from this forum for a minute...

Knock it off, all of you!

Well, this is the license; do whatever you want with it, unless I ask you to stop. Also give some credit. :-P

If you have a problem with this, I suggest you take it elsewhere.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-08-08 15:11:01
Check the repo for an important update.
For some reason I never noticed that the lgp tool couldn't make archives from anything but the current directory.
It was also not closing some file handles, but that never caused any noticeable issues.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-08-08 18:33:02
Thanks for the update Aali.
0.3b binary compiled by me can be gotten here.
http://www.mediafire.com/?iyvidgtm3y2
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-09 06:14:17
Thanks a bunch for notification, Aali. It's highly appreciated. (I just uninstalled TortosiseHg, having assumed the repository is never updated again; so it was a life-saving notification)

Now refactoring and rebuilding...
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-08-10 05:40:09
Hmmm... I'm having some trouble with creating a magic.lgp
I've extracted all it's files and folders and combined them into a folder entitled NEW.  I then put NEW in my C: and ran C:\new\lgp C:\new C:\new\magic.lgp

I keep getting an error saying
Could not stat input file: data
Number of files to add: 2806
Successfully created archive with 2806 file(s) out of 2807 file(s) total.


What gives?  It recognizes the "ff7" folder, but has a problem once it reaches the "ff7" subfolder "data".   Is this a problem with the compile, or user error?

Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-08-10 06:08:43
Bah, I broke it :-P

Now it doesn't take subfolders instead. Shame on me for not testing that.

:EDIT:

Let's try this again, another important update is in the repo :-P
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-08-10 06:20:07
Great work. Thanks for the update again Aali. Just tested and seems to work fine with subfolders now.
And here is the latest binary compiled by me
http://www.mediafire.com/?oyvmiely1wg
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-08-10 06:42:10
Seems to be fixed.  One thing I did notice though that wasn't happening with .3.   When I run UnLGP.exe  (using a drag and drop)  the ff7 folder of magic.lgp now gets put in the C: instead of with the rest of the files.

I'm going to go test the in-game now
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-08-10 07:08:42
unlgp didn't change with 0.4b

You should of course discard any broken archives created with 0.3b

:EDIT:

Nevermind, I broke it again :/
FF7 may or may not accept the archive, but both lgp and unlgp are doing things they shouldn't be doing.
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-08-10 07:23:44
I found the problem.  I used .4 unlgp to extract all the files of the original magic.lgp, and everything seems to have worked beautifully.
I then used lgp to create a new magic.lgp, and again, everything seems to work

It's once I use unlgp on the newly created magic.lgp that the ff7 folder defaults to being put in the C:.  Also, if I'm not mistaken, some of the files are being placed in different locations within the magic.lgp

I've been working on editing odin, and originally all his files are in the main section of the .lgp.  So I replace those files with my new ones (that work using LGPTools A <> B replace) and create the new magic.lgp.  Upon using UnLGP on this new one, however, those files are either missing, or have been relocated somewhere else. 

It's getting late so I will see if I can find them sometime tomorrow.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-08-10 07:25:58
Third time's a charm; pushed another update. This one should not create those semi-broken lgps and unlgp should no longer barf on the same semi-broken files.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-10 08:24:15
Is it safe to say "Nice work, thank you, Aali"? ;) Just kidding. Thanks for your attention. May the God forgive me for uninstalling TortoiseHg...

Now refactoring and recompiling. For historic reason, I'm going to keep the whole repository.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-08-10 08:28:07
Wow so many updates in 1 day, great work Aali.
0.5b compiled binary compiled by me
http://www.mediafire.com/?zz2adyze5km
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-08-10 08:30:48
Wow so many updates in 1 day, great work Aali.
0.5b compiled binary compiled by me
http://www.mediafire.com/?zz2adyze5km

Yeah.. except the only reason there were so many updates today is that I couldn't get it right the first time and didn't test it properly :-P
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-10 08:36:19
^ Don't worry about not getting it right, Celebrated One. They say "Failure is not the antonym of success; it is a component of great achivements."

By the way, the version numbering is a bit suggestive, as they are sub-zero. Tell us Aali, are you planning a major release? A major v1.0 or something?
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-08-10 08:39:58
lol. Well its still good to see active updates even if its just fixing things.
Also FleetCommand so you really need TortoiseHG for this project ? since its only 4 src files its just as fast to just download the RAW files in your internet explorer (or whatever you use for browsing the internet) then save them to the same folder and you wont have to install any extra programs.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-10 08:57:08
^ Oh, I know that, Kranmer. It was implicit speech.

By the way, thank you too, Kranmer. Thank you for providing the forum with up-to-date executable LGP/UNLGP. I believe you too deserve being thanked.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-08-10 09:02:29
well i would have liked to have created a GUI for this but there is just 1 very small problem. I dont know how.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-10 09:11:40
If that is all your problem, ... Maybe I can tell you how... I don't develop a GUI version myself for the reason mentioned above but it is against no law to tell others how to do that.

But first and foremost, do you know any visual/RAD programming languages? Such as Delphi or C#?
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-08-10 09:50:50
not really, i have learned a little of most but i cant actually fully code in any language (i am more of an editor of existing code and compiler then a creator). i doubt i would be able to make one so i think i will just forget about it and just use the normal command line system for now but thanks for the offer anyway.
I just wish there was a way of making a generic GUI that could run any DOS cmd using somthing simple like a script or somthing along those lines so that it could be used with any DOS program.
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-08-10 15:34:37
Third time's a charm; pushed another update. This one should not create those semi-broken lgps and unlgp should no longer barf on the same semi-broken files.

Lol, I'll go ahead and test this one (in-game too) and post back with my results.  Thanks to both of you, Aali and Kranmer, for being so quick to update the command line  :-)

EDIT
Hurrah! Everything in magic.lgp is working flawlessly with the .5 release :D

Also, I thought this little document would be handy for some of the less computer savvy http://www.mediafire.com/download.php?kwlvlyzjz2y (http://www.mediafire.com/download.php?kwlvlyzjz2y)
Title: lgp/unlgp - command line tools for LGP archives
Post by: LeeHiOoO on 2009-08-10 17:47:50
I would do a GUI if I know how to [2]

I can only code in vb tho...  :-(
Title: lgp/unlgp - command line tools for LGP archives
Post by: Cyber Light on 2009-08-11 08:20:25
I create new in C put magic.lgp and unlgp.exe in this folder, drag and drop magic.lgp into unlgp.exe and i see this, not have anything continue.  :oops:
(http://i200.photobucket.com/albums/aa301/votinh193/untitled-2.png)
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-08-11 10:45:07
Ultimate Dragon after a long time that screen should disappear and you should be left with the files. If they are not in the same folder there is a high chance it will have extracted to a either your root (for example the root of your C drive) or it will extract to C:\Documents and Settings\user (user will be whatever your username is) i aint 100% sure why this is but can be gotten around if you use a command after you extract if you dont drag and drop.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Cyber Light on 2009-08-11 15:24:38
Thank you kranmer. I create .bat file like this and it work  :-)
unlgp.bat
Code: [Select]
unlgp magic.lgplgp.bat
Code: [Select]
lgp magiclgp magic.lgp
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-13 05:04:03
I would do a GUI if I know how to [2]

I can only code in vb tho...  :-(
Got your message too. Do you know anything about C, C++, or C#? At least, can your read and understand LGP Tools code?
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2009-08-13 05:12:00
FleetCommand, are you still creating a GUI for these?
Title: lgp/unlgp - command line tools for LGP archives
Post by: LeeHiOoO on 2009-08-14 18:48:21
Got your message too. Do you know anything about C, C++, or C#? At least, can your read and understand LGP Tools code?

I don't know C neither C++.
Some C# i may understand as it's quite like vb.net.
If i can understand lgp tools code? well, some parts yes... some dont. I'll try to figure now..
If u r willing to help me add @ msn.  :-)
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-15 04:49:50
I don't know C neither C++.
Some C# i may understand as it's quite like vb.net.
If i can understand lgp tools code? well, some parts yes... some dont. I'll try to figure now..
Then your job is much tougher than that of someone like Kramner but still possible. If you are persistent, then let's get started.

First and foremost, you must start learning a bit of C/C++ so that you at least have a grasp of struct data types and of reading and writing from a structured file the way LGP Tools does. (Otherwise, the only way I can help you will be to embed me into your brain.) Why don't you start with Microsoft Express training material on C++? There are quite a few guides there.

After that, I'll lay out the details of encapsulating the file I/O into appropriate classes (which is the tough part of the work) and help you binding them into a GUI (which should be easy, given the fact you already know VB.NET.)
Quote
If u r willing to help me add @ msn.  :-)
I'm afraid that's not an option. I cannot be disrupted during the work hours. We should keep the discussion in this thread (which is relevant) as much as possible. I'll check it everyday after returning from work.
Title: lgp/unlgp - command line tools for LGP archives
Post by: LeeHiOoO on 2009-08-15 15:04:43
@ Fleet Command :

Understanding of structured data types also manipulating structures data : DONE!


Also... I've just realized I can use that for the issue I'm having in my prog in this (http://forums.qhimm.com/index.php?topic=8841.0) thread.  :-o
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-16 07:06:22
OUTSTANDING! I didn't expect you to do it in such a short time.

So, now you have complete understanding of this part of code, right?
Code: [Select]
struct toc_entry
{
char name[20];
unsigned int offset;
unsigned char unknown1;
unsigned short conflict;
__attribute__((__packed__));

struct file_header
{
char name[20];
unsigned int size;
} __attribute__((__packed__));

struct lookup_table_entry
{
unsigned short toc_offset;
unsigned short num_files;
} __attribute__((__packed__));

struct conflict_entry
{
char name[128];
unsigned short toc_index;
} __attribute__((__packed__));

Especially, you do know what does __attribute__((__packed__)) actually do, right?

Good, now let's start with building classes. At first, I advise you to initially build an application that only extracts files from LGP, then expand it to one that also archives files into LGP. But a precaution: I know C# and Delphi very well but I don't remember anything about VB.NET anymore. But I'm going to assume VB.NET is only grammatically different from C#. (At least for our purpose.) If it isn't, let me know and we'll try to resolve any conflict.

(I don't know why my eyes hurts...)

Start by building a test program that opens LGP archive, counts the number of files in it and announces the count in a message box. Then, you'll expand it into a full-fledged LGP extractor. For now, download lgp.c, unlgp.c, lgp.h and MinGW. (You'll need some of MinGW source codes, such as stat.h.) Also, start a Visual Basic project (Windows Form) and put a Menu Bar on it with just a File menu and an Open command. Put an Open Dialog Box into the form and set its properties, so it can open "LGP Archive (*.LGP)" and "All files (*.*)".

Create a DeLGP class. (Are classes case-sensitive in VB.NET too? In C#, they are. In Delphi, they aren't.) Class constructor gets one parameter: the whole path to the LGP file. The constructor checks whether the file exists, whether NTFS permissions on it allows read-only access and opens the file as read-only. (Don't implement the opening of the file yet.)

Then, the main job: Build a LGPStream class as a Structured Storage class and add a File Stream plus the structs in LGP.h to it. You are not going to have the benefit of using packed structs, so prepare for extra job when reading and writing structs. There is a reason for that: The precious Unicode! You are going to read non-unicode strings from archive but write Unicode strings to disk, and vice versa. (Aali's LGP Tools read non-unicode and write non-unicode. You don't do this.)

Once you are done, let me see how you've done this critical part. Meanwhile, I'll be downloading a Visual Basic 2008 Express, just in case.
Title: lgp/unlgp - command line tools for LGP archives
Post by: LeeHiOoO on 2009-08-16 14:09:35
I'm quite sure I'm not doing it right at classes code, but whatever.. that's what I've got so far

LGP_VBNET_TEST (http://www.4shared.com/file/125411538/eef38950/LGP_VBNET_-_08161103.html)
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-17 04:53:08
Man, you are better than me.

Just started to verify it. I'm not yet through, but I've spotted the first flaw: You defined whatever data that was defined as "char" and "unsigned char" in Aali's code as "char" in your own code, which is wrong. In C and C++ "char", "signed char" and "unsigned char" are only 8-bits long while in .NET, they are 16-bits long and store Unicode characters. Consider using "System.SByte" (or its VB.NET equivalent) instead of "char" and "System.Byte" (or its VB.NET equivalent) instead of "unsigned char".

I'm getting busy right now, but don't worry, if I ever died, you're better than me.

EDIT: Oh, forgot to mention: You'll be using either a bit of type-casting (Byte -> Char or vice versa) or unpacked data read/write of bytes in 16-bit aligned manner. I prefer type casting.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-17 18:47:23
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]
        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]
        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/268451194/Counts_of_objects_in_LGP_archives__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]
        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
Title: lgp/unlgp - command line tools for LGP archives
Post by: LeeHiOoO on 2009-08-18 00:04:13
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 (http://forums.qhimm.com/index.php?topic=8841.0) thread? (new update there)
I think our topic has nothing to do with this thread(until release) and we may be annoying ppl here.

Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-20 07:17:19
^ 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.
Title: lgp/unlgp - command line tools for LGP archives
Post by: willis936 on 2009-08-24 06:46:18
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
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-24 07:23:36
"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.
Title: lgp/unlgp - command line tools for LGP archives
Post by: willis936 on 2009-08-24 07:45:01
What specifically do the exes do?

Unlgp extracts file x to folder y.  How do we know which file/folder?
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-24 08:33:10
"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".
Title: lgp/unlgp - command line tools for LGP archives
Post by: willis936 on 2009-08-24 16:24:43
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.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Hellbringer616 on 2009-08-24 16:31:28
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"
Title: lgp/unlgp - command line tools for LGP archives
Post by: LeeHiOoO on 2009-08-25 00:13:31
@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)
Title: lgp/unlgp - command line tools for LGP archives
Post by: willis936 on 2009-08-25 02:34:02
Aha, I got it working now.

Thanks guys!  :-D
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-25 12:28:49
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.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-27 08:41:03
I have created some documentation for LGP Tools v0.5. I hope you guys find it useful.

Here it is:

You are going to need Microsoft Word or Microsoft Word Viewer (free) to view the documentation. But I guess 90% of people should have no problem opening it. But for the other 10%, I've prepared the documentation in alternative formats:
Title: lgp/unlgp - command line tools for LGP archives
Post by: LeeHiOoO on 2009-08-28 12:09:51
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
Title: lgp/unlgp - command line tools for LGP archives
Post by: Shuffle on 2009-08-28 15:08:50
I have a problem with unlgp:
1.lgp and unlgp.exe in C:\LGP\ folder
i was write a .bat file
Code: [Select]
CD /d "C:\lgp\1"
UnLGP.exe "C:\lgp\1.lgp"
pause
when I was open this .bat file command line say
Code: [Select]
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>pause
Press any key to continue . . .
help
Title: lgp/unlgp - command line tools for LGP archives
Post by: sl1982 on 2009-08-28 15:44:42
I have a problem with unlgp:
1.lgp and unlgp.exe in C:\LGP\ folder
i was write a .bat file
Code: [Select]
CD /d "C:\lgp\1"
UnLGP.exe "C:\lgp\1.lgp"
pause
when I was open this .bat file command line say
Code: [Select]
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>pause
Press any key to continue . . .
help



do this instead
CD /d "C:\lgp\"
UnLGP.exe %cd%\1\1.lgp
pause
Title: lgp/unlgp - command line tools for LGP archives
Post by: Shuffle on 2009-08-28 16:22:03
i was wrong
CD /d "C:\lgp\1"
UnLGP.exe C:\lgp\1.lgp
pause
Title: lgp/unlgp - command line tools for LGP archives
Post by: sl1982 on 2009-08-28 16:24:56
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
Title: lgp/unlgp - command line tools for LGP archives
Post by: Shuffle on 2009-08-28 16:28:44
i want to the unlgp extract the lgp archive into "C:\lgp\1" folder, its possible?
Title: lgp/unlgp - command line tools for LGP archives
Post by: sl1982 on 2009-08-28 16:34:03
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
Title: lgp/unlgp - command line tools for LGP archives
Post by: Shuffle on 2009-08-28 16:40:44
thanks
Title: lgp/unlgp - command line tools for LGP archives
Post by: Fleet Command on 2009-08-28 21:14:34
To extracts 1.lgp, which resides in "c:\lgp", into "c:\lgp\1\", you must have entered the following commands:

In Command Prompt:
Code: [Select]
cd /d "c:\lgp\1"
"c:\lgp\unlgp.exe" "c:\lgp\1.lgp"

Windows PowerShell:
Code: [Select]
set-location 'c:\lgp\1'
& 'c:\lgp\unlgp.exe' 'c:\lgp\1.lgp'


unlgp will extract the files into whatever folder unlgp is in
so put unlgp and the lgp into C:\lgp\1
I'm afraid that's wrong. (See above.) It is possible to have UnLGP.exe write files to a folder in which unlgp.exe does not exist. All you have to do is to specify the full path to UnLGP.exe. UnLGP.exe writes the contents into current folder.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Shuffle on 2009-08-29 18:29:29
To extracts 1.lgp, which resides in "c:\lgp", into "c:\lgp\1\", you must have entered the following commands:

In Command Prompt:
Code: [Select]
cd /d "c:\lgp\1"
"c:\lgp\unlgp.exe" "c:\lgp\1.lgp"

Windows PowerShell:
Code: [Select]
set-location 'c:\lgp\1'
& 'c:\lgp\unlgp.exe' 'c:\lgp\1.lgp'


unlgp will extract the files into whatever folder unlgp is in
so put unlgp and the lgp into C:\lgp\1
I'm afraid that's wrong. (See above.) It is possible to have UnLGP.exe write files to a folder in which unlgp.exe does not exist. All you have to do is to specify the full path to UnLGP.exe. UnLGP.exe writes the contents into current folder.
Big thanks!
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2009-09-07 19:39:33
Hi guys. I have decided to put all the files needed to compile LGP/UNLGP into a archive so that people who dont even know anything about compiling source code can compile Aali's code with ease. I will still continue to build the binaries as they are updated anyway but i thought that it might be a good idea to put this up here anyway so other people build the code if they want to.

Ok first you can get all the files needed to compile the source code here (also its 138mb uncompressed but its 16MB compressed which took a while to do)
http://www.mediafire.com/?ziwdnzum4mn
This is all the files needed to compile LGP/UNLGP in a self extracting file so run it once and extract it
PLEASE NOTE YOU MUST EXTRACT TO A FOLDER WITHOUT SPACES. so for example C:\ would be fine but C:\Program Files\ is NOT fine because it has a space.
Also for the rest of this guide i will be using C:\ for an example but if you put it somwhere else thats fine.

Now Then you have extracted the compiler to C:\ so go to the "compiler" folder on your C drive and run MSYS once then close it. (we do this to create the folder needed for future steps)

Now you need the source code from page 1. This can be gotten many ways but the easyist is to go to
http://backup.ninjaloot.se:8000
then click on "BROWSE" then click on each file in turn and then right click on "RAW" and "SAVE TARGET AS" and save all 4 files the same way to your "C:\compiler\home\username\" folder
(also the above statement is using "Internet Exporer" and also the "username" part of the path is always different for everyone so just put there what the name of the folder in your MSYS folder)

Now Aali's source code is in C:\compiler\home\username\ you now need to open MAKEFILE with "Notepad" or any editor and look for the words
cc
replace both lots of cc with
gcc
then save the "MAKEFILE"

Now open "MSYS" in "C:\compiler" again and type
make

Now it will compile LGP/UNLGP binaries (EXE files) and your done.


Also you may get a WARNING in MSYS when making the binaries you can ignore this. It is a warning and not a error and doesnt appear to have any effect on the program.

And if this is to compilcated i will try to make it simpler but i presonally feel its very straight forward as is.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Vegeta_Ss4 on 2009-09-11 08:51:30
I have encountered this warning when i tried to compile the Release 0.5b with mingw on win32 OS.

Code: [Select]
>make all
gcc -Wall  lgp.c -o lgp
gcc -Wall  unlgp.c -o unlgp
unlgp.c: In function `main':
unlgp.c:163: warning: implicit declaration of function `mkdir'

I have fixed adding the following line in file unlgp.c in order to prevent that warning:

Code: [Select]
int mkdir(const char *pathname, mode_t mode);


Just before the main function. So finally the result will be:
Code: [Select]
int mkdir(const char *pathname, mode_t mode);

int main(int argc, char *argv[])

That's All. I hope you find useful this info.

Bye.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2009-09-11 09:13:57
You get an A for effort, but that is really not the way to solve that problem.
Find the correct header file and #include it, if it's compatible with other build environments I'll add it to the repo.
Title: lgp/unlgp - command line tools for LGP archives
Post by: pyrozen on 2009-10-18 16:55:47
any updates on creating a GUI for this utility?  I know it was discussed earlier but i haven't heard anything since.

lee
Title: lgp/unlgp - command line tools for LGP archives
Post by: arew264 on 2009-12-14 00:54:54
any updates on creating a GUI for this utility?  I know it was discussed earlier but i haven't heard anything since.

lee

If there's still interest, I could look into it after this week.

LeeHiOoO was working on one in VB, but that seems to have stalled.
Title: lgp/unlgp - command line tools for LGP archives
Post by: Hellbringer616 on 2009-12-21 11:35:31
So is there any improving this at all? I seem to have never run into any issues to speak of. Should we update this to v1.0 and call it good? :-D
Title: lgp/unlgp - command line tools for LGP archives
Post by: sithlord48 on 2010-02-27 20:13:50
kranmer, thanks for the ez compile set up . for windows. i plan to release an installer based on on the most recent source code that i have (0.5 i think) should be released soon provided aali's does not object to it.....

EDIT: installer for windows / linux can be found at the page below
http://dopplereffect.shacknet.nu/lgp_tools_multipack_by_sithlord48-1.0.zip

EDIT#2 updated link was broken
Title: lgp/unlgp - command line tools for LGP archives
Post by: obesebear on 2010-05-17 16:20:28
I know I know

Now then,  Aali, I think there may be a problem with the program compiling the flevel.lgp.   I haven't tried it myself, but others have claimed it becomes corrupt when trying to edit a modified one.
Title: lgp/unlgp - command line tools for LGP archives
Post by: LeeHiOoO on 2010-05-26 03:09:40
Is source not available anymore? =/
Title: lgp/unlgp - command line tools for LGP archives
Post by: Kranmer on 2010-05-26 08:19:45
Is source not available anymore? =/

Well Aali's website for the source has been down for awhile but if you want it i have still have the latest source (0.5) i have uploaded it here for you
http://www.mediafire.com/?zhoeiydtwtq
Title: Re: lgp/unlgp - command line tools for LGP archives
Post by: Aali on 2010-06-11 00:19:11
Hmm, the source was not supposed to be down.. The mercurial repository is no longer necessary though so I will probably just provide a .zip archive.
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: sithlord48 on 2010-11-15 20:27:21
the link is long dead, please use
http://dopplereffect.shacknet.nu/lgp_tools_multipack_by_sithlord48-1.0.zip
instead
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: Wutai Clan on 2011-04-11 10:57:26
I wrote a GUI frontend for this tool, but unlgp.exe needs to be updated to take this format.

unlgp.exe SourceLGP DestinationFolder

That way it will work properly with my frontend, and allow the user to select a destination folder for the extracted files. (As it is, it just dumps them in the same folder as my tool.)

(The GUI is written in C#, and will require the .Net Framework  v3.5, which most ppl already have.. I will also include the source code, and give permission for anyone to maintain the GUI if I'm not around to do so.)

I won't include the original tools, unless given permission, as it stands, my GUI is a standalone app, and requires you to download and install lgp.exe\unlgp.exe to the same directory as it's .exe file. (But with permission, I could pack them either in the same archive, or even inside the .exe itself, to help keep things more tidy, but, that would make updating the tools themselves a bit more work, because they would need repacked into the GUI tool, etc,.)
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: Aali on 2011-04-11 12:18:03
Surely you could just set the working directory before executing unlgp? :)

Its not that its difficult for me to make that change but it would take a while before I get around to it.
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: Wutai Clan on 2011-04-11 12:48:09
Nvm.
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: nomad805 on 2012-02-21 21:35:36
can someone please tell me how to use this imma noob lol i tried using the aalis lgp with the gui front end but it duznt unpack everything i notice...like my battle lgp is over a gigabyte but when i unpack it its less than 100 mb idk what im doing wrong lol
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: Bosola on 2012-02-21 21:58:24
can someone please tell me how to use this imma noob lol i tried using the aalis lgp with the gui front end but it duznt unpack everything i notice...like my battle lgp is over a gigabyte but when i unpack it its less than 100 mb idk what im doing wrong lol

Firstly, this thread pertains to the old version of LGP/unLGP - the thread for the new tools is this (http://"http://forums.qhimm.com/index.php?topic=12831") one, though you've already posted in it.

Secondly, don't cross-post the same question to multiple threads.
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: LeonhartGR on 2012-02-21 21:59:51
Firstly, this thread pertains to the old version of LGP/unLGP - the thread for the new tools is this (http://"http://forums.qhimm.com/index.php?topic=12831") one, though you've already posted in it.

Secondly, don't cross-post the same question to multiple threads.

Ahhh... link doesn't work :)
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: UGerstl on 2012-02-21 22:22:00
This link should work: http://forums.qhimm.com/index.php?topic=12831
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: LeonhartGR on 2012-02-21 22:33:29
This link should work: http://forums.qhimm.com/index.php?topic=12831

Oh! I dl this already. Can't get it to work in windows 7 i need to open cmd probably, that's why I was using lgp tools until i got a corrupted magic.lgp
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: UGerstl on 2012-02-21 23:04:14
The lgp tools (with GUI) are well known for corrupting files.
Title: Re: LGP/UnLGP - command line tools for LGP archives [v.5]
Post by: DLPB_ on 2012-02-24 07:36:11
can someone please tell me how to use this imma noob lol i tried using the aalis lgp with the gui front end but it duznt unpack everything i notice...like my battle lgp is over a gigabyte but when i unpack it its less than 100 mb idk what im doing wrong lol

Yeah, it is called google.  Yes it really can help you, it did me years ago too.  Help is good for people who have exhausted other lines of inquiry, not those who just can't be arsed trying.  Look up "command line programs" and then use the program on this thread.

Luksy's command line program which is modified from this one (with a few fixes) is also good start.