QUOTE(BroodKiller @ Mar 27 2006, 02:25 PM)
Thanks for the offer, ShadowFlare, I would greatly appreciate such functionality being implemented into DatEd, but there do is a problem I see. If you look into the DatEd's source code, you will notice that a basic MPQ Import (import-to-DatEdit of course) function does exist there, just that it is not used. Reason? It keeps crashing, no matter what MPQ-handling library do I use: SFMPQAPI, lmpqapi, stormlib - whatever. I already mentioned this in some other thread, IIRC. The crash happens when calling the SFileReadFile function. I asked Quantam about it some time ago, and he suggested that it has to do with the pointers used in this function call, but the said pointers have been declared just a few code lines before, so there can be nothing wrong with them, as to my knowledge. If you do manage to solve this problem somehow, I'd greatly appreciate this.
I would have tried doing what you're saying long ago, if only that problem wouldn't appear.
[right][snapback]454404[/snapback][/right]
Well, you wouldn't necessarily have to read the file in your own code when using GRPAPI, since it can read directly from MPQ archives. To do this, you must open the archive using Storm.dll, or you can change all references to storm.dll in grpapi.dll to sfmpq.dll (with a hex editor) so that you only have to use one dll for mpq's. After doing this, while you have the archive open you can just call LoadGrp to load the graphics straight from the mpq, like this for example: HANDLE hGrp = LoadGrp("unit\\zerg\\devour.grp"); Then it will attempt to load it from any open archives. BTW, for this you could also make use of the priority parameter of SFileOpenArchive so that it can search through the open archives in a certain order.
I'll look through your code and see if I can find where your mpq problems are (if that code is in there).
-EDIT-
Ah, I found your problem. It's a very simple one; you forgot to allocate space for reading the file into memory and assign the pointer to your buffer variable.
QUOTE(Doodle77(MM) @ Mar 27 2006, 02:54 PM)
One problem with this, what if you want your special mod's gfx to display instead of the default?
Just a note, DatEdit runs perfectly in Linux (Ubuntu 5.10) using WINE. The only troubles it has is that the interface is a little messy.
[right][snapback]454433[/snapback][/right]
This can actually be done without actually even needing an extra function call, because of how grpapi handles opening files with the LoadGrp function. The archive simply needs to be open first, or the file needs to be in the same path relative to the program as it is in the mpq, so for example if DatEdit was in C:\DatEdit\ and it called LoadGrp("unit\\zerg\\devour.grp"), grpapi would first look for C:\DatEdit\unit\zerg\devour.grp then if it didn't find it, it would search in order all open archives.