Hey,
because my english isn't the best, I'm not going to write much :/
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
char convertHexPair(char* hex) {
int sixteensDig = (hex[0] - 48) * 16;
int onesDig = hex[1];
if ( (onesDig >= 97) && (onesDig <= 102) )
onesDig -= 32;
if (onesDig < 65) {
return char(sixteensDig + onesDig - 48);
} else {
return char(sixteensDig + onesDig - 55);
}
}
int Hex2Dec(const char *sz)
{
int iResult;
sscanf(sz, "%x", &iResult);
return iResult;
}
int main(int argc, char *argv[])
{
if(argc != 5)
{
cout << "Not enough arguments";
return 1;
}
char replace = convertHexPair(argv[4]);
fstream out(argv[1], ios::in | ios::out | ios::binary);
out.seekp(atoi(argv[2]), ios::beg);
char original = out.peek();
if(!out) {
cout << "Cannot open file.";
return 1;
}
out.close();
fstream write(argv[1], ios::in | ios::out | ios::binary);
write.seekp(atoi(argv[2]), ios::beg);
write.put(convertHexPair(argv[4]));
return 0;
}
Put this code in a file with .cpp at the ending(for example main.cpp).
After this execute the following command
replace main.cpp with your file!
After that you can patch a DIF file in your game, but I would recommend to use this script:
Code:
echo "Please enter the name of the Dif"
diffile = read
cat "difs/$diffile"|while read line; do
cp game game.bak
./a.out $line | sed -e 's/://g'
done;
Put this script in a file named patch.sh
After that you can simply execute it via
and than you have to enter the name of the Dif file!
If you get errors, put the main.cpp & patch.sh in the path where you game file is and run again!
MfG
TheMarv