|
 |
|
|
|
|
|
GTA Modification Forums
Auto-Replace files in GTA3.img Command line software?
 |
|
 |
| |
Mister X  |
Posted: Tuesday, Aug 14 2012, 13:05
|
Square Civilian

Group: Members
Joined: Dec 25, 2007

|
| QUOTE (fastman92 @ Tuesday, Aug 14 2012, 11:13) | I have written IMG class for C++ that works with version 1 (GTA III, GTA SA) and version 2 (GTA SA) All you have to do is command-line tool, since i provide you a class only. http://www.mediafire.com/?sh0zzhfq4g7tcee |
Sorry but I'm not so good with C++ to make a complete application The code is very well written,but hard to understand for me (I studied c++ for only 6-7 months). All I want to do is replace 3 files (I know name of that,and they are disposed in the same folder of exutable) that are inside gta3.img. Can't compile it only to do this operation? Or at least tell me a VERY basic script to how open the gta3.img and do that.... I know it's a lot of work,but this would complete my mod,and off course I would be very happy This post has been edited by Mister X on Tuesday, Aug 14 2012, 13:09
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
fastman92  |
Posted: Tuesday, Aug 14 2012, 13:47
|
фастман92 | ف

Group: Members
Joined: Jul 28, 2009


|
Add this to project: #include "IMG.h" And add CPP file to Visual Studio source files, it's where you can add files, you list of files of project. Examples: Display file names in command line (requires <iostream> ) | CODE | IMG archive; archive.OpenArchive("gta3.img");
auto it = archive.begin();
while(it < archive.end()) { cout << it -> Name << endl;
it++; }
archive.CloseArchive(); |
Get file size of specified file by name: | CODE | IMG archive; archive.OpenArchive("gta3.img");
std::cout << "Size of stand.dff in bytes: " << archive.GetFileRefByName("stand.dff").GetFilesize() << endl;
archive.CloseArchive(); |
Add or replace file (if exists), requires #include <stdio.h> for fopen, fseek and ftell | CODE | IMG archive; archive.OpenArchive("gta3.img");
// Load whole file into memory FILE* fp = fopen("stand.dff", "r"); fseek(fp, 0, SEEK_END); // set position to end unsigned int FileSize = ftell(fp); // get current position, If it's on ending then it's filesize, right?
char* Buffer = new char[FileSize]; // allocate memory depending on FileSize, as much as it needs
fseek(fp, 0, SEEK_SET); // get back to beginning of file fread(Buffer, 1, FileSize, fp); archive.AddOrReplaceFile("stand.dff", Buffer, FileSize); delete Buffer; // Don't forget to deallocate memory, it's not neccessary now fclose(fp); // Don't forget to close file handle of standup.dff archive.CloseArchive(); // Don't forget to close archive. |
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|
|
|
|