Rev 196 | Rev 218 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include <spk.h>
void Error()
{
#ifdef _DEBUG
char pause;
scanf ( "%s", &pause );
#endif
exit(1);
}
/*
Main entry point to program
*/
int main ( int argc, char **argv )
{
printf ( "XModPatch V1.00 (SPK Library Version %.2f) 01/04/2011 Created by Cycrow\n\n", (float)GetLibraryVersion() );
Utils::WString cmd (argv[0]);
Utils::WString dir = CFileIO(cmd).dir();
cmd = CFileIO(cmd).filename();
bool verbose = false;
if ( argc < 3 )
{
wprintf ( L"Syntax: %s <modfile.cat> <diff file> [gamedirectory]\n", cmd.c_str() );
wprintf ( L"\t<modfile.cat>:\t\tThe mod file you want to create/add to\n" );
wprintf ( L"\t<diff file>:\t\tThe file to to read from\n" );
wprintf ( L"\t[gamedirectory]:\tThe game directory to compare the mod against, without this will assume current directory\n" );
}
else
{
// check for switches
int startPos = 1;
for ( startPos = 1; startPos < argc; startPos++ )
{
CyString checkFlags(argv[startPos]);
if ( !checkFlags.Left(1).Compare("-") )
break;
if ( checkFlags.Left(2) != "--" ) // not a single long flag (compare each character
{
checkFlags.ToLower();
for ( unsigned int i = 1; i < checkFlags.Length(); i++ )
{
switch (checkFlags[i])
{
case 'v':
verbose = true;
break;
}
}
}
else if ( checkFlags.Compare("--verbose") )
verbose = true;
}
Utils::String modfile(argv[startPos]);
Utils::String difffile(argv[startPos + 1]);
Utils::WString gamedir;
if ( argc > 3 ) gamedir = argv[startPos + 2];
if ( gamedir.empty() ) gamedir = L".";
gamedir = CFileIO(gamedir).fullFilename();
CModDiff Diff(gamedir.toString(), L"addon");
if ( !Diff.IsLoaded() )
{
wprintf (L"Error: Unable to load game directory, %s\n", gamedir.c_str());
Error();
}
Diff.ApplyMod(modfile);
wprintf ( L"Game Directory: '%s' loaded\n", gamedir.c_str());
if ( !Diff.ReadDiff(difffile) )
{
printf ("Error: Unable to load diff file, %s\n", difffile.c_str());
Error();
}
if ( !Diff.ApplyDiff(modfile) )
{
printf ("Error: Unable to write to mod file, %s\n", modfile.c_str());
Error();
}
printf("Diff has been applied to mod, %s\n", modfile.c_str());
}
#ifdef _DEBUG
char pause;
scanf ( "%s", &pause );
#endif
return 0;
}