Subversion Repositories spk

Rev

Rev 196 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 196 Rev 197
Line 13... Line 13...
13
	int			iType;
13
	int			iType;
14
	int			iID;
14
	int			iID;
15
} SDiffEntry;
15
} SDiffEntry;
16
 
16
 
17
tstruct SDiffEntryAddition : SDiffEntry {
17
tstruct SDiffEntryAddition : SDiffEntry {
18
	Utils::String	sEntry;
18
	Utils::WString	sEntry;
19
	SDiffEntryAddition() { iType = DIFFTYPE_ADDITION; }
19
	SDiffEntryAddition() { iType = DIFFTYPE_ADDITION; }
20
} SDiffEntryAddition;
20
} SDiffEntryAddition;
21
 
21
 
22
tstruct SDiffEntryRemoval : SDiffEntry {
22
tstruct SDiffEntryRemoval : SDiffEntry {
23
	SDiffEntryRemoval() { iType = DIFFTYPE_REMOVAL; }
23
	SDiffEntryRemoval() { iType = DIFFTYPE_REMOVAL; }
24
} SDiffEntryRemoval;
24
} SDiffEntryRemoval;
25
 
25
 
26
tstruct SDiffEntryChange : SDiffEntry {
26
tstruct SDiffEntryChange : SDiffEntry {
27
	SDiffEntryChange() { iType = DIFFTYPE_CHANGE; }
27
	SDiffEntryChange() : iPos(0) { iType = DIFFTYPE_CHANGE; }
28
	int			iPos;
28
	int			iPos;
29
	Utils::String	sFrom;
29
	Utils::WString	sFrom;
30
	Utils::String	sEntry;
30
	Utils::WString	sEntry;
31
} SDiffEntryChange;
31
} SDiffEntryChange;
32
 
32
 
33
tstruct SDiffFile {
33
tstruct SDiffFile {
34
	Utils::String sFile;
34
	Utils::WString sFile;
35
	CLinkList<SDiffEntry> m_lEntries;
35
	CLinkList<SDiffEntry> m_lEntries;
36
} SDiffFile;
36
} SDiffFile;
37
 
37
 
38
enum {MDERR_NONE, MDERR_FILENOTFOUND, MDERR_CANTOPEN, MDERR_CANTOPENMOD};
38
enum {MDERR_NONE, MDERR_FILENOTFOUND, MDERR_CANTOPEN, MDERR_CANTOPENMOD};
39
 
39
 
Line 45... Line 45...
45
		MERGETYPE_TSHIPS,
45
		MERGETYPE_TSHIPS,
46
	};
46
	};
47
 
47
 
48
public:
48
public:
49
	// static
49
	// static
50
	static bool CanBeDiffed(const Utils::String &file);
50
	static bool CanBeDiffed(const Utils::WString &file);
51
 
51
 
52
	// constructors
52
	// constructors
53
	CModDiff(const Utils::String &dir, const Utils::String &sAddon, int maxPatch = 0);
53
	CModDiff(const Utils::WString &dir, const Utils::WString &sAddon, int maxPatch = 0);
54
	~CModDiff(void);
54
	~CModDiff(void);
55
 
55
 
56
	// public functions
56
	// public functions
57
	void SetTempDirectory(const Utils::String &temp) { m_sTempDir = temp; }
57
	void SetTempDirectory(const Utils::WString &temp) { m_sTempDir = temp; }
58
	bool LoadDirectory(const Utils::String &dir);
58
	bool LoadDirectory(const Utils::WString &dir);
59
	bool IsLoaded() { return m_bLoaded; }
59
	bool IsLoaded() { return m_bLoaded; }
60
	const Utils::String &GetDirectory() const { return m_sCurrentDir; }
60
	const Utils::WString &GetDirectory() const { return m_sCurrentDir; }
61
	bool CreateDiff(const Utils::String &mod);
61
	bool CreateDiff(const Utils::WString &mod);
62
	bool startDiff(const Utils::String &sModFile);
62
	bool startDiff(const Utils::String &sModFile);
63
	bool doDiff(const Utils::String &sModFile);
63
	bool doDiff(const Utils::WString &sModFile);
64
	SDiffFile *diffFile(const Utils::String &baseFile, const  Utils::String &modFile, const Utils::String &fileType);
64
	SDiffFile *diffFile(const Utils::WString &baseFile, const  Utils::WString &modFile, const Utils::WString &fileType);
65
	void Clean();
65
	void Clean();
66
	bool WriteDiff(const Utils::String &file);
66
	bool WriteDiff(const Utils::String &file);
67
	bool ReadDiff(const Utils::String &file);
67
	bool ReadDiff(const Utils::String &file);
68
	bool ApplyDiff(const Utils::String &mod);
68
	bool ApplyDiff(const Utils::String &mod);
69
	bool ApplyMod(const Utils::String &mod);
69
	bool ApplyMod(const Utils::String &mod);
Line 74... Line 74...
74
	void ClearError() { m_iError = MDERR_NONE; }
74
	void ClearError() { m_iError = MDERR_NONE; }
75
	int Error() { return m_iError; }
75
	int Error() { return m_iError; }
76
 
76
 
77
private:
77
private:
78
	// private functions
78
	// private functions
79
	int _amountPosition(const Utils::String &fileType);
79
	int _amountPosition(const Utils::WString &fileType);
80
	bool _isLineComplete(const Utils::String &line, const Utils::String &fileType, bool first);
80
	bool _isLineComplete(const Utils::WString &line, const Utils::WString &fileType, bool first);
81
	bool _readGameFile(const Utils::String &file, Utils::CStringList &lines, int *id);
81
	bool _readGameFile(const Utils::WString &file, Utils::WStringList &lines, int *id);
82
	void _compareLine(const Utils::String &line1, const Utils::String &line2, int type, int id, SDiffFile *diffFile);
82
	void _compareLine(const Utils::WString &line1, const Utils::WString &line2, int type, int id, SDiffFile *diffFile);
83
	bool _validFile(const Utils::String &file);
83
	bool _validFile(const Utils::WString &file);
84
 
84
 
85
	void _adjustFile(const Utils::String &sFile, SDiffFile *pDiff, bool bReverse);
85
	void _adjustFile(const Utils::WString &sFile, SDiffFile *pDiff, bool bReverse);
86
	bool _adjustTShips(SDiffFile *pDiff, bool bReserve);
86
	bool _adjustTShips(SDiffFile *pDiff, bool bReserve);
87
	int _specialType(const Utils::WString &sFile) const;
87
	int _specialType(const Utils::WString &sFile) const;
88
	Utils::String _extractFile(const Utils::String &sFile, const Utils::String &sTo);
88
	Utils::WString _extractFile(const Utils::WString &sFile, const Utils::WString &sTo);
89
 
89
 
90
	// Variables
90
	// Variables
91
	Utils::String m_sAddon;
91
	Utils::WString m_sAddon;
92
	Utils::String m_sCurrentDir;		// the current game directory (that the VFS is opened too)
92
	Utils::WString m_sCurrentDir;		// the current game directory (that the VFS is opened too)
93
	Utils::String m_sTempDir;				// temporary dir (used to write temporary files to)
93
	Utils::WString m_sTempDir;				// temporary dir (used to write temporary files to)
94
 
94
 
95
	CVirtualFileSystem m_fileSystem;	// the VFS of the game directory (for finding the files to use)
95
	CVirtualFileSystem m_fileSystem;	// the VFS of the game directory (for finding the files to use)
96
	CLinkList<SDiffFile> m_lFiles;		// list of files that have changed
96
	CLinkList<SDiffFile> m_lFiles;		// list of files that have changed
97
 
97
 
98
	bool	m_bLoaded;					// if the directory is loaded and ready to be diffed
98
	bool	m_bLoaded;					// if the directory is loaded and ready to be diffed