Subversion Repositories spk

Rev

Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
#include <spk.h>
2
 
3
void Error()
4
{
5
#ifdef _DEBUG
6
	char pause;
7
	scanf ( "%s", &pause );
8
#endif
9
	exit(1);
10
}
11
/*
12
	Main entry point to program
13
*/
14
int main ( int argc, char **argv )
15
{
16
	printf ( "XModPatch V1.00 (SPK Library Version %.2f) 01/04/2011 Created by Cycrow\n\n", (float)GetLibraryVersion() );
17
 
18
	CyString cmd (argv[0]);
19
	CyString dir = CFileIO(cmd).GetDir();
20
	cmd = CFileIO(cmd).GetFilename();
21
 
22
	bool verbose = false;
23
 
24
	if ( argc < 3 )
25
	{
26
		printf ( "Syntax: %s <modfile.cat> <diff file> [gamedirectory]\n", cmd.c_str() );
27
		printf ( "\t<modfile.cat>:\t\tThe mod file you want to create/add to\n" );
28
		printf ( "\t<diff file>:\t\tThe file to to read from\n" );
29
		printf ( "\t[gamedirectory]:\tThe game directory to compare the mod against, without this will assume current directory\n" );
30
	}
31
	else
32
	{
33
	// check for switches
34
		int startPos = 1;
35
		for ( startPos = 1; startPos < argc; startPos++ )
36
		{
37
			CyString checkFlags(argv[startPos]);
38
			if ( !checkFlags.Left(1).Compare("-") )
39
				break;
40
 
41
			if ( checkFlags.Left(2) != "--" ) // not a single long flag (compare each character
42
			{
43
				checkFlags.ToLower();
44
				for ( unsigned int i = 1; i < checkFlags.Length(); i++ )
45
				{
46
					switch (checkFlags[i])
47
					{
48
						case 'v':
49
							verbose = true;
50
							break;
51
					}
52
				}
53
			}
54
			else if ( checkFlags.Compare("--verbose") )
55
				verbose = true;
56
		}
57
 
58
		CyString modfile(argv[startPos]);
59
		CyString difffile(argv[startPos + 1]);
60
		CyString gamedir;
61
		if ( argc > 3 ) gamedir = argv[startPos + 2];
62
		if ( gamedir.Empty() ) gamedir = ".";
63
		gamedir = CFileIO(gamedir).GetFullFilename();
64
 
65
		CModDiff Diff(gamedir);
66
		if ( !Diff.IsLoaded() ) 
67
		{
68
			printf  ("Error: Unable to load game directory, %s\n", gamedir.c_str());
69
			Error();
70
		}
71
 
72
		Diff.ApplyMod(modfile);
73
 
74
		printf ( "Game Directory: '%s' loaded\n", gamedir.c_str());
75
		if ( !Diff.ReadDiff(difffile) )
76
		{
77
			printf ("Error: Unable to load diff file, %s\n", difffile.c_str());
78
			Error();
79
		}
80
 
81
		if ( !Diff.ApplyDiff(modfile) )
82
		{
83
			printf ("Error: Unable to write to mod file, %s\n", modfile.c_str());
84
			Error();
85
		}
86
 
87
		printf("Diff has been applied to mod, %s\n", modfile.c_str());
88
	}
89
 
90
#ifdef _DEBUG
91
	char pause;
92
	scanf ( "%s", &pause );
93
#endif
94
	return 0;
95
}