| 1 | cycrow | 1 | #ifndef __PACKAGES_H__
 | 
        
           |  |  | 2 | #define __PACKAGES_H__
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 | #include "SpkFile.h"
 | 
        
           |  |  | 5 | #include "GameExe.h"
 | 
        
           |  |  | 6 | #include "XspFile.h"
 | 
        
           |  |  | 7 | #include "archive/unzip.h"
 | 
        
           |  |  | 8 |   | 
        
           |  |  | 9 | #include "MultiSpkFile.h"
 | 
        
           |  |  | 10 | #include "VirtualFileSystem.h"
 | 
        
           | 88 | cycrow | 11 | #include "Utils/StringList.h"
 | 
        
           | 1 | cycrow | 12 |   | 
        
           | 93 | cycrow | 13 | #include "spkdefines.h"
 | 
        
           | 1 | cycrow | 14 |   | 
        
           |  |  | 15 | class CFileIO;
 | 
        
           |  |  | 16 |   | 
        
           | 93 | cycrow | 17 | namespace SPK {
 | 
        
           |  |  | 18 | 	class COriginalFiles;
 | 
        
           |  |  | 19 | }
 | 
        
           | 1 | cycrow | 20 |   | 
        
           | 93 | cycrow | 21 | using namespace SPK;
 | 
        
           | 1 | cycrow | 22 |   | 
        
           |  |  | 23 | class SPKEXPORT CPackages
 | 
        
           |  |  | 24 | {
 | 
        
           |  |  | 25 | public:
 | 
        
           | 121 | cycrow | 26 | 	static Utils::String ConvertLanguage(int lang);
 | 
        
           | 1 | cycrow | 27 | 	static SAvailablePackage *CreateAvailablePackageData(CBaseFile *package);
 | 
        
           | 197 | cycrow | 28 | 	static Utils::WString FormatAvailablePackageData(CBaseFile *package);
 | 
        
           |  |  | 29 | 	static Utils::WString FormatAvailablePackageData(SAvailablePackage *package);
 | 
        
           |  |  | 30 | 	static Utils::WString CreateFromPackagerScript(CPackages *packages, const Utils::WString &filename);
 | 
        
           |  |  | 31 | 	static int GeneratePackageUpdateData(const Utils::WString &dir, bool includeSingle = true);
 | 
        
           | 1 | cycrow | 32 |   | 
        
           |  |  | 33 | 	CPackages ();
 | 
        
           |  |  | 34 | 	~CPackages ();
 | 
        
           |  |  | 35 |   | 
        
           | 83 | cycrow | 36 | 	bool isOldDir(const Utils::String &dir);
 | 
        
           | 197 | cycrow | 37 | 	bool read(const Utils::WString &dir, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 38 | 	void startup(const Utils::WString &dir, const Utils::WString &tempDir, const Utils::WString &myDoc);
 | 
        
           |  |  | 39 | 	void startup(const Utils::WString &dir, const Utils::WString &tempDir, const Utils::WString &myDoc, const Utils::WString &mod);
 | 
        
           | 1 | cycrow | 40 |   | 
        
           | 129 | cycrow | 41 | 	bool extractAll(CBaseFile *baseFile, const Utils::String &dir, int game, bool includedir = true, CProgressInfo *progress = NULL) const;
 | 
        
           | 210 | cycrow | 42 | 	bool generatePackagerScript(CBaseFile *baseFile, bool wildcard, Utils::WStringList *list, int game, bool datafile = false) const;
 | 
        
           | 197 | cycrow | 43 | 	CBaseFile *loadPackagerScript(const Utils::WString &filename, int compression, Utils::WString (*askFunc)(const Utils::WString &), Utils::WStringList *malformedLines = NULL, Utils::WStringList *unknownCommands = NULL, Utils::WStringList *variables = NULL, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 44 | 	Utils::WStringList &getGlobals() { return _lGlobals; }
 | 
        
           |  |  | 45 | 	Utils::WStringList &getFakePatchOrder() { return _lFakePatchOrder; }
 | 
        
           |  |  | 46 | 	Utils::WString getCurrentDirectory() const;
 | 
        
           |  |  | 47 | 	static const Utils::WString &tempDirectory() { return m_sTempDir; }
 | 
        
           |  |  | 48 | 	const Utils::WString &myDocuments() { return m_sMyDoc; }
 | 
        
           | 1 | cycrow | 49 | 	CGameExe *GetGameExe() { return &m_gameExe; }
 | 
        
           |  |  | 50 | 	CLinkList<CBaseFile> *GetInstallPackageList() { return &m_lInstallList; }
 | 
        
           |  |  | 51 |   | 
        
           |  |  | 52 | 	// installing/uninstalling
 | 
        
           | 197 | cycrow | 53 | 	bool		installPackage(CBaseFile *package, Utils::WStringList *errors, CProgressInfo *progress = NULL, bool disabled = false);
 | 
        
           |  |  | 54 | 	CBaseFile		*openPackage(const Utils::WString &file, int *error, CProgressInfo *progress = NULL, int readtype = SPKREAD_ALL, int flags = READFLAG_NONE);
 | 
        
           |  |  | 55 | 	CMultiSpkFile	*openMultiPackage(const Utils::WString &file, int *error, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 56 | 	bool			 openMultiPackage(const Utils::WString &file, CLinkList<CBaseFile> *packageList, int *error, CProgressInfo *progress = NULL );
 | 
        
           | 1 | cycrow | 57 | 	int			CheckInstallPackage(CBaseFile *package, int check = IC_ALL);
 | 
        
           | 197 | cycrow | 58 | 	bool		removeFile(C_File *file, Utils::WStringList *errors = NULL);
 | 
        
           | 1 | cycrow | 59 | 	void		PrepareUninstallPackage(CBaseFile *package);
 | 
        
           | 197 | cycrow | 60 | 	bool		uninstallPreparedPackages(Utils::WStringList *errors, CProgressInfo *progress, CLinkList<CBaseFile> *uninstalledPackages = NULL, CLinkList<CBaseFile> *disabledPackages = NULL);
 | 
        
           | 1 | cycrow | 61 | 	void		ConvertOldPackage(CBaseFile *p);
 | 
        
           | 197 | cycrow | 62 | 	void		purgeUninstallScripts(CBaseFile *package, Utils::WStringList *errors);
 | 
        
           | 1 | cycrow | 63 | 	int 		PrepareInstallPackage(CBaseFile *package, bool disabled = false, bool force = false, int check = IC_ALL);
 | 
        
           | 197 | cycrow | 64 | 	int			installPreparedPackages(Utils::WStringList *errors, CProgressInfo *progress, CLinkList<CBaseFile> *errored, CLinkList<CBaseFile> *installedList = NULL);
 | 
        
           | 1 | cycrow | 65 | 	void		RemovePreparedInstall(CBaseFile *package);
 | 
        
           |  |  | 66 | 	int			GetNumPackagesInQueue() { return m_lInstallList.size(); }
 | 
        
           | 197 | cycrow | 67 | 	int			checkOpenPackage(const Utils::WString &file, int* error);
 | 
        
           | 133 | cycrow | 68 | 	bool		findAllNeededDependacies(CBaseFile *p, const CLinkList<CBaseFile> &packages, CLinkList<CBaseFile> *foundPackages, bool onlyEnabled = false, bool includePrepared = false) const;
 | 
        
           | 203 | cycrow | 69 | 	int			getMissingDependacies(CBaseFile *p, Utils::WStringList *list, bool onlyEnabled = false, bool includePrepared = false);
 | 
        
           | 170 | cycrow | 70 | 	size_t		getDownloadableDependacies(CBaseFile* p, std::vector<const SAvailablePackage*>& list, bool onlyEnabled = false, bool includePrepared = false) const;
 | 
        
           | 204 | cycrow | 71 | 	bool		checkInstalledDependacy(const Utils::WString &name, const Utils::WString &author, const Utils::WString &version, bool onlyEnabled = false, bool includePerpered = false) const;
 | 
        
           | 1 | cycrow | 72 | 	bool		CheckEnabledDependacy(CBaseFile *p);
 | 
        
           |  |  | 73 | 	int			GetDependacyList(CBaseFile *package, CLinkList<CBaseFile> *list);
 | 
        
           | 182 | cycrow | 74 | 	int			prepareMultiPackage(const Utils::String &file, CLinkList<CBaseFile> *errorPackageList, int *error, CProgressInfo *progress = 0);
 | 
        
           | 1 | cycrow | 75 |   | 
        
           |  |  | 76 | 	bool		IsOldPluginManager() { return m_bOldPlugin; }
 | 
        
           | 197 | cycrow | 77 | 	int			findPackageFiles(CLinkList<CBaseFile> &packages, const Utils::WString &dir);
 | 
        
           |  |  | 78 | 	int			findPackageDirectories(CLinkList<CBaseFile> &packages, const Utils::WString &dir);
 | 
        
           |  |  | 79 | 	int			findAllPackages(CLinkList<CBaseFile> &packages, const Utils::WString &dir);
 | 
        
           |  |  | 80 | 	size_t		updateFoundPackages(const Utils::WString& dir);
 | 
        
           |  |  | 81 | 	size_t		addFoundPackages(const Utils::WString& dir);
 | 
        
           | 1 | cycrow | 82 |   | 
        
           |  |  | 83 | 	// enable/disable
 | 
        
           | 197 | cycrow | 84 | 	bool enablePackage(CBaseFile *package, Utils::WStringList *errors, CProgressInfo *progress = NULL );
 | 
        
           |  |  | 85 | 	bool disablePackage(CBaseFile *package, Utils::WStringList *errors, CProgressInfo *progress = NULL );
 | 
        
           |  |  | 86 | 	bool disablePreparedPackages(Utils::WStringList *errors, CProgressInfo *progress, CLinkList<CBaseFile> *disabledPackages = NULL );
 | 
        
           |  |  | 87 | 	bool enablePreparedPackages(Utils::WStringList* errors, CProgressInfo* progress, CLinkList<CBaseFile>* enabledPackages = NULL);
 | 
        
           | 1 | cycrow | 88 | 	bool PrepareEnablePackage(CBaseFile *package);
 | 
        
           |  |  | 89 | 	bool PrepareDisablePackage(CBaseFile *package);
 | 
        
           |  |  | 90 | 	int  GetNumPackagesInEnabledQueue() { return m_lEnableList.size(); }
 | 
        
           |  |  | 91 | 	int  GetNumPackagesInDisabledQueue() { return m_lDisableList.size(); }
 | 
        
           |  |  | 92 | 	bool PrepareDisableForVanilla();
 | 
        
           |  |  | 93 | 	bool PrepareEnableLibrarys();
 | 
        
           |  |  | 94 | 	bool PrepareEnableFromVanilla();
 | 
        
           |  |  | 95 |   | 
        
           |  |  | 96 | 	void WriteData();
 | 
        
           | 197 | cycrow | 97 | 	bool closeDir(Utils::WStringList *errors = 0, CProgressInfo *progress = NULL, bool removedir = false);
 | 
        
           | 1 | cycrow | 98 | 	bool RestoreFakePatch();
 | 
        
           |  |  | 99 | 	bool ReadyFakePatch();
 | 
        
           | 197 | cycrow | 100 | 	bool checkValidPluginManagerFile(const Utils::WString &filename) const;
 | 
        
           |  |  | 101 | 	bool checkIfPluginManagerFile(const Utils::WString &filename) const;
 | 
        
           | 1 | cycrow | 102 |   | 
        
           |  |  | 103 | 	// package control
 | 
        
           |  |  | 104 | 	void UpdateUsedFiles(CLinkList<CBaseFile> *ignoreList = NULL, bool = true);
 | 
        
           |  |  | 105 | 	void UpdateSigned();
 | 
        
           |  |  | 106 | 	bool UpdatePackages(int doStatus = -1, bool individual = false);
 | 
        
           | 182 | cycrow | 107 | 	CBaseFile *findXspPackage(const Utils::String &id) const;
 | 
        
           | 203 | cycrow | 108 | 	CBaseFile *findSpkPackage(const Utils::WString &name, const Utils::WString &author) const;
 | 
        
           | 182 | cycrow | 109 | 	CArchiveFile *findArchivePackage(const Utils::String &name) const;
 | 
        
           | 197 | cycrow | 110 | 	CBaseFile* findPackage(const Utils::WString &name, const Utils::WString &author) const;
 | 
        
           | 182 | cycrow | 111 | 	CBaseFile *findFirstPackageWithFile(C_File *f) const;
 | 
        
           |  |  | 112 | 	CBaseFile *findNextPackageWithFile(CBaseFile *p, C_File *f) const;
 | 
        
           |  |  | 113 | 	CBaseFile *findPackage(CBaseFile *package) const;
 | 
        
           | 197 | cycrow | 114 | 	C_File *findFile(FileType filetype, const Utils::WString &filename, const Utils::WString &dir = Utils::WString::Null()) const;
 | 
        
           | 1 | cycrow | 115 | 	CBaseFile *FirstPackage() { return m_lPackages.First(); }
 | 
        
           |  |  | 116 | 	CBaseFile *NextPackage() { return m_lPackages.Next(); }
 | 
        
           |  |  | 117 | 	CBaseFile *GetFirstPackage() { if ( m_lPackages.Front() ) return m_lPackages.Front()->Data(); return NULL; }
 | 
        
           |  |  | 118 | 	CBaseFile *GetNextPackage(CBaseFile *from) 
 | 
        
           |  |  | 119 | 	{ 
 | 
        
           |  |  | 120 | 		bool found = false;
 | 
        
           |  |  | 121 | 		for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
 | 
        
           |  |  | 122 | 		{
 | 
        
           |  |  | 123 | 			if ( !node->Data() ) continue;
 | 
        
           |  |  | 124 | 			if ( node->Data() == from )
 | 
        
           |  |  | 125 | 				found = true;
 | 
        
           |  |  | 126 | 			else if ( found )
 | 
        
           |  |  | 127 | 				return node->Data();
 | 
        
           |  |  | 128 | 		}
 | 
        
           |  |  | 129 | 		return NULL; 
 | 
        
           |  |  | 130 | 	}
 | 
        
           |  |  | 131 | 	void Reset();
 | 
        
           |  |  | 132 | 	CBaseFile *GetPackageAt(int i) { return m_lPackages[i]; }
 | 
        
           | 197 | cycrow | 133 | 	Utils::WString selectedModName() const;
 | 
        
           |  |  | 134 | 	Utils::WString getModKey() const;
 | 
        
           | 1 | cycrow | 135 | 	void SetupWares();
 | 
        
           |  |  | 136 | 	void SetupShips();
 | 
        
           |  |  | 137 | 	void PurgeGameObjects();
 | 
        
           |  |  | 138 | 	void PurgeWares();
 | 
        
           |  |  | 139 | 	void PurgeShips();
 | 
        
           |  |  | 140 | 	void StartPackage() { m_pPackageNode = m_lPackages.Front(); }
 | 
        
           |  |  | 141 | 	void UpdatePackage(CBaseFile *p);
 | 
        
           |  |  | 142 | 	CBaseFile *GetCurrentPackage() { return (m_pPackageNode) ? m_pPackageNode->Data() : NULL; }
 | 
        
           |  |  | 143 | 	bool RemoveCurrentDirectory();
 | 
        
           |  |  | 144 | 	void RemoveCreatedFiles();
 | 
        
           |  |  | 145 | 	bool AnyUnusedShared();
 | 
        
           |  |  | 146 |   | 
        
           |  |  | 147 | 	// util functions
 | 
        
           | 197 | cycrow | 148 | 	void removeUnusedDirectories(const Utils::WStringList &dirs, Utils::WStringList* errors = NULL);
 | 
        
           |  |  | 149 | 	int  removeUninstallScripts(Utils::WStringList *errors = 0, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 150 | 	bool removeUninstallFile(C_File *file, Utils::WStringList *errors = 0);
 | 
        
           |  |  | 151 | 	int  removeUnusedSharedFiles(Utils::WStringList *errors = 0, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 152 | 	bool removeSharedFile(C_File *file, Utils::WStringList *errors = NULL);
 | 
        
           |  |  | 153 | 	void shufflePatchTo(C_File *file, int to, Utils::WStringList *errors);
 | 
        
           |  |  | 154 | 	void shuffleFakePatches(Utils::WStringList *errors);
 | 
        
           |  |  | 155 | 	void shuffleTextFiles(Utils::WStringList *errors);
 | 
        
           |  |  | 156 | 	int  findNextFakePatch(int start = 0, const Utils::WString &dir = Utils::WString::Null()) const;
 | 
        
           | 130 | cycrow | 157 | 	unsigned int  findNextTextFile(unsigned int start = 4) const;
 | 
        
           | 197 | cycrow | 158 | 	unsigned int  findNextTextFile(const Utils::WString &dir, unsigned int start = 4) const;
 | 
        
           |  |  | 159 | 	int  findLastFakePatch(int start = 99, const Utils::WString &dir = Utils::WString::Null()) const;
 | 
        
           |  |  | 160 | 	int  findLastTextFile(int start = 9999, const Utils::WString &dir = Utils::WString::Null()) const;
 | 
        
           | 1 | cycrow | 161 | 	int  FindLowestFakePatchInstalled();
 | 
        
           |  |  | 162 | 	void ReadGameLanguage(bool force = true);
 | 
        
           | 197 | cycrow | 163 | 	int	 removeAllPackages(Utils::WStringList *errors = NULL, CProgressInfo *progress = NULL);
 | 
        
           | 1 | cycrow | 164 | 	void AssignPackageNumbers();
 | 
        
           |  |  | 165 | 	int  GetChildPackages(CBaseFile *package, CLinkList<CBaseFile> *children, bool recursive = false);
 | 
        
           |  |  | 166 | 	int  GetAllPackageFiles(CBaseFile *package, CLinkList<C_File> *fileList, bool includeChild);
 | 
        
           |  |  | 167 | 	int	 GetAllPackageFiles(CLinkList<CBaseFile> *list, CLinkList<C_File> *fileList, bool includeChild);
 | 
        
           | 197 | cycrow | 168 | 	void addLogEntry(int type, const Utils::WString &args, Utils::WStringList* errors);
 | 
        
           | 196 | cycrow | 169 | 	Utils::WString findDataDir(const Utils::WString &dir, const Utils::WString &file);
 | 
        
           | 179 | cycrow | 170 | 	int  countPackages(int type, bool onlyEnabled) const;
 | 
        
           | 1 | cycrow | 171 | 	int  CountBuiltInPackages(bool onlyEnabled);
 | 
        
           | 197 | cycrow | 172 | 	bool isCurrentDir(const Utils::WString &dir) const;
 | 
        
           | 1 | cycrow | 173 | 	bool CheckOtherPackage(CBaseFile *package);
 | 
        
           |  |  | 174 | 	int CheckPreparedInstallRequired(CLinkList<CBaseFile> *list);
 | 
        
           | 197 | cycrow | 175 | 	static int ConvertWareType(wchar_t w);
 | 
        
           |  |  | 176 | 	static wchar_t ConvertWareTypeBack(int w);
 | 
        
           |  |  | 177 | 	Utils::WString logDirectory();
 | 
        
           |  |  | 178 | 	Utils::WString logDirectory(const Utils::WString &gameExe);
 | 
        
           |  |  | 179 | 	Utils::WString saveDirectory();
 | 
        
           | 126 | cycrow | 180 | 	void backupSaves() { backupSaves(m_bVanilla); }
 | 
        
           |  |  | 181 | 	void backupSaves(bool vanilla);
 | 
        
           |  |  | 182 | 	void restoreSaves() { restoreSaves(m_bVanilla); }
 | 
        
           |  |  | 183 | 	void restoreSaves(bool vanilla);
 | 
        
           | 197 | cycrow | 184 | 	bool unPackFile(const Utils::WString &filename, bool checkxml = true) const;
 | 
        
           |  |  | 185 | 	bool packFile(const Utils::WString &filename) const;
 | 
        
           |  |  | 186 | 	bool packFile(CFileIO* File, const Utils::WString &filename) const;
 | 
        
           |  |  | 187 | 	Utils::WString convertTextString(const Utils::WString &text);
 | 
        
           | 1 | cycrow | 188 | 	void LoadVirtualFileSystem();
 | 
        
           | 197 | cycrow | 189 | 	bool checkAccessRights(const Utils::WString &dir) const;
 | 
        
           |  |  | 190 | 	bool readTextPage(const Utils::WString &file, Utils::WStringList &list, bool search, int page) const;
 | 
        
           | 182 | cycrow | 191 | 	size_t loadShipData(const Utils::String& file, Utils::CStringList& list) const;
 | 
        
           | 197 | cycrow | 192 | 	FileType adjustFileType(const Utils::WString &name, FileType filetype) const;
 | 
        
           | 35 | cycrow | 193 | 	CXspFile *extractShip(const Utils::String &sCatFile, const Utils::String &sId, CProgressInfo *progress = NULL);
 | 
        
           | 182 | cycrow | 194 | 	Utils::String readShipData(const Utils::String &file, const Utils::String &entry) const;
 | 
        
           |  |  | 195 | 	bool isSamePackage(CBaseFile *p1, CBaseFile *p2) const;
 | 
        
           | 203 | cycrow | 196 | 	void applyFakePatchOrder(const Utils::WStringList &list);
 | 
        
           | 182 | cycrow | 197 | 	CBaseFile *createFromArchive(const Utils::String &filename, bool toInstall = false) const;
 | 
        
           |  |  | 198 | 	void readArchiveData(const char *buf, size_t len, CBaseFile *archive) const;
 | 
        
           |  |  | 199 | 	void readArchiveData(const Utils::String &filename, CBaseFile *archive) const;
 | 
        
           | 197 | cycrow | 200 | 	size_t verifyInstalledFiles(Utils::WStringList *missingFiles = nullptr, bool getPackages = true) const;
 | 
        
           |  |  | 201 | 	Utils::WString empWaresForGame(size_t *maxsize = NULL);
 | 
        
           | 88 | cycrow | 202 | 	void addEMPPriceOverride(int empId, int price);
 | 
        
           |  |  | 203 | 	void addEMPNotoOverride(int empId, int noto);
 | 
        
           |  |  | 204 | 	void addBuiltInWarePriceOverride(int empId, int price);
 | 
        
           |  |  | 205 | 	void addBuiltInWareNotoOverride(int empId, int noto);
 | 
        
           | 197 | cycrow | 206 | 	void addCustomWarePriceOverride(const Utils::WString &id, int price);
 | 
        
           |  |  | 207 | 	void addCustomWareNotoOverride(const Utils::WString &id, int noto);
 | 
        
           | 1 | cycrow | 208 |   | 
        
           |  |  | 209 | 	int GetCurrentGameFlags() { return m_iGameFlags; }
 | 
        
           |  |  | 210 |   | 
        
           | 197 | cycrow | 211 | 	void setCurrentDir(const Utils::WString &dir);
 | 
        
           | 1 | cycrow | 212 |   | 
        
           |  |  | 213 | 	// merge mods
 | 
        
           | 197 | cycrow | 214 | 	void getMergedFiles(Utils::WStringList &list, CCatFile *cat1, CCatFile *cat2) const;
 | 
        
           |  |  | 215 | 	bool canWeMerge(const Utils::WString &file) const;
 | 
        
           |  |  | 216 | 	bool mergeMods(CCatFile *mod1, CCatFile *mod2, const Utils::WString &outFile, Utils::WStringList *cantMerge) const;
 | 
        
           |  |  | 217 | 	bool needToMerge(const Utils::WString &file) const;
 | 
        
           |  |  | 218 | 	bool getModCompatabilityList(C_File *file, Utils::WStringList *list = NULL) const;
 | 
        
           |  |  | 219 | 	bool checkCompatabilityBetweenModFiles(C_File *from, C_File *to, Utils::WStringList *list = NULL) const;
 | 
        
           |  |  | 220 | 	bool checkCompatabilityBetweenMods(CBaseFile *from, CBaseFile *to, Utils::WStringList *list = NULL) const;
 | 
        
           |  |  | 221 | 	int checkCompatabilityAgainstPackages(CBaseFile *newFile, Utils::WStringList *list = NULL, CLinkList<CBaseFile> *packages = NULL) const;
 | 
        
           | 1 | cycrow | 222 |   | 
        
           | 182 | cycrow | 223 | 	Utils::String getLanguageName() const;
 | 
        
           |  |  | 224 | 	int			  getGameLanguage() const;
 | 
        
           | 197 | cycrow | 225 | 	int			  getGameLanguage(const Utils::WString &dir) const;
 | 
        
           |  |  | 226 | 	int			  getGameAddons(Utils::WStringList &exes) const;
 | 
        
           |  |  | 227 | 	int			  getGameAddons(Utils::WStringList &exes, const Utils::WString &dir) const;
 | 
        
           |  |  | 228 | 	Utils::WString getGameName() const;
 | 
        
           |  |  | 229 | 	Utils::WString getGameName(const Utils::WString &dir) const;
 | 
        
           |  |  | 230 | 	Utils::WString getGameVersionFromType(int game, int version, const Utils::WString &sVersion) const;
 | 
        
           |  |  | 231 | 	Utils::WString getGameNameFromType(int game) const;
 | 
        
           |  |  | 232 | 	Utils::WString getGameTypesString(CBaseFile *package, bool includeVersion) const;
 | 
        
           |  |  | 233 | 	Utils::WString getGameVersionString(CBaseFile *package) const;
 | 
        
           |  |  | 234 | 	Utils::WString getGameRunExe(const Utils::WString &dir) const;
 | 
        
           |  |  | 235 | 	Utils::WString getGameRunExe() const;
 | 
        
           |  |  | 236 | 	Utils::WString getProperDir() const;
 | 
        
           |  |  | 237 | 	Utils::WString getProperDir(const Utils::WString &dir) const;
 | 
        
           |  |  | 238 | 	Utils::WString getAddonDir() const;
 | 
        
           |  |  | 239 | 	Utils::WString getAddonDir(const Utils::WString &dir) const;
 | 
        
           | 1 | cycrow | 240 |   | 
        
           |  |  | 241 | 	// text files
 | 
        
           | 197 | cycrow | 242 | 	void CreateLanguageTextFiles(Utils::WStringList *errors = 0);
 | 
        
           |  |  | 243 | 	bool renameTextFile(const Utils::WString &textid, int languageid, Utils::WStringList *errors);
 | 
        
           |  |  | 244 | 	void addTextFileToScripts(C_File *file, const Utils::WString &textid);
 | 
        
           | 1 | cycrow | 245 | 	void CreatePluginManagerText();
 | 
        
           | 87 | cycrow | 246 | 	void createPluginManagerOpenText();
 | 
        
           | 1 | cycrow | 247 |   | 
        
           |  |  | 248 | 	// game control
 | 
        
           | 182 | cycrow | 249 | 	void createEMPFile(const Utils::String &progDir = Utils::String::Null());
 | 
        
           | 1 | cycrow | 250 | 	void CreateWareFiles();
 | 
        
           | 197 | cycrow | 251 | 	int  extractGameFile(const Utils::WString &aFilename, const Utils::WString &aTo, const Utils::WString &dir = Utils::WString::Null(), const Utils::WString &addon = Utils::WString::Null()) const;
 | 
        
           | 1 | cycrow | 252 | 	void CreateDummies();
 | 
        
           |  |  | 253 | 	void CreateComponants();
 | 
        
           |  |  | 254 | 	void CreateCutData();
 | 
        
           |  |  | 255 | 	void CreateBodies();
 | 
        
           |  |  | 256 | 	void CreateGlobals();
 | 
        
           |  |  | 257 | 	void CreateAnimations();
 | 
        
           |  |  | 258 | 	void CreateTShips();
 | 
        
           |  |  | 259 | 	void CreateCustomStarts();
 | 
        
           | 197 | cycrow | 260 | 	void addCreatedFile(const Utils::WString &file);
 | 
        
           | 88 | cycrow | 261 |   | 
        
           | 197 | cycrow | 262 | 	bool readGlobals(Utils::WStringList &globals) const;
 | 
        
           | 89 | cycrow | 263 | 	bool readWares(int iLang, CLinkList<SWareEntry> &list);
 | 
        
           |  |  | 264 | 	bool readCommands(int iLang, CLinkList<SCommandSlot> &list);
 | 
        
           |  |  | 265 | 	bool readWingCommands(int iLang, CLinkList<SCommandSlot> &list);
 | 
        
           | 88 | cycrow | 266 | 	int  empOveridePrice(int id);
 | 
        
           |  |  | 267 | 	bool empOverideNoto(int id, int *noto);
 | 
        
           |  |  | 268 | 	int  builtInWareOveridePrice(int id);
 | 
        
           |  |  | 269 | 	bool builtInWareOverideNoto(int id, int *noto);
 | 
        
           | 197 | cycrow | 270 | 	int  customWareOveridePrice(const Utils::WString &id);
 | 
        
           |  |  | 271 | 	bool customWareOverideNoto(const Utils::WString &id, int *noto);
 | 
        
           | 88 | cycrow | 272 | 	void removeEmpOverride(int pos);
 | 
        
           |  |  | 273 | 	void removeBuiltinWareOverride(int pos);
 | 
        
           | 197 | cycrow | 274 | 	void removeCustomWareOverride(const Utils::WString &id);
 | 
        
           | 1 | cycrow | 275 |   | 
        
           |  |  | 276 | 	// install text
 | 
        
           | 206 | cycrow | 277 | 	Utils::WString getInstallBeforeText(CBaseFile *package) const;
 | 
        
           |  |  | 278 | 	Utils::WString getInstallAfterText(CBaseFile *package) const;
 | 
        
           |  |  | 279 | 	Utils::WString getUninstallBeforeText(CBaseFile *package) const;
 | 
        
           |  |  | 280 | 	Utils::WString getUninstallAfterText(CBaseFile *package) const;
 | 
        
           | 1 | cycrow | 281 |   | 
        
           |  |  | 282 | 	//setting functions
 | 
        
           |  |  | 283 | 	void SetRenameText(bool b) { m_bRenameText = b; }
 | 
        
           |  |  | 284 | 	void SetLanguage(int i) { m_iLanguage = i; }
 | 
        
           |  |  | 285 | 	void SetAutoEnable(bool b) { m_bAutoEnableChild = b; }
 | 
        
           |  |  | 286 | 	void SetForceModInstall(bool b) { m_bForceModInstall = b; }
 | 
        
           | 197 | cycrow | 287 | 	void setTempDirectory(const Utils::WString &s) { m_sTempDir = s; }
 | 
        
           |  |  | 288 | 	void setMyDocuments(const Utils::WString &s) { m_sMyDoc = s; }
 | 
        
           | 1 | cycrow | 289 | 	void SetForceEMP(bool b) { m_bForceEMP = b; }
 | 
        
           |  |  | 290 | 	void SetSurpressProtectedWarning(bool b) { m_bSurpressProtectedWarning = b; }
 | 
        
           |  |  | 291 | 	void SurpressProtectedWarning() { m_bSurpressProtectedWarning = true; }
 | 
        
           |  |  | 292 | 	bool IsSupressProtectedWarning() { return m_bSurpressProtectedWarning; }
 | 
        
           |  |  | 293 |   | 
        
           |  |  | 294 | 	int GetLanguage() { return m_iLanguage; }
 | 
        
           |  |  | 295 | 	int GetGame() { return m_iGame; }
 | 
        
           |  |  | 296 | 	bool IsLoaded() { return m_bLoaded; }
 | 
        
           |  |  | 297 | 	bool IsVanilla() { return m_bVanilla; }
 | 
        
           |  |  | 298 | 	void SetVanilla(bool b);
 | 
        
           |  |  | 299 |   | 
        
           | 197 | cycrow | 300 | 	const Utils::WString &getMod() const { return m_sSetMod; }
 | 
        
           |  |  | 301 | 	void setMod(const Utils::WString& mod);
 | 
        
           | 126 | cycrow | 302 | 	void setSaveGameManager(bool managed);
 | 
        
           | 1 | cycrow | 303 |   | 
        
           |  |  | 304 | 	CBaseFile *GetEnabledMod() { return m_pEnabledMod; }
 | 
        
           |  |  | 305 |   | 
        
           |  |  | 306 | 	//errors
 | 
        
           |  |  | 307 | 	void ClearError() { m_iError = PKERR_NONE; }
 | 
        
           |  |  | 308 | 	int  GetError() { return m_iError; }
 | 
        
           |  |  | 309 |   | 
        
           | 164 | cycrow | 310 | 	CLinkList<CBaseFile>* PackageList() { return &m_lPackages; }
 | 
        
           | 161 | cycrow | 311 | 	CLinkList<SAvailablePackage> *getAvailablePackageList() { return &m_lAvailablePackages; }
 | 
        
           | 164 | cycrow | 312 | 	CLinkList<CBaseFile>* getFoundPackageList() { return &m_lFoundPackages; }
 | 
        
           | 1 | cycrow | 313 | 	bool AnyAvailablePackages(int type = -1);
 | 
        
           | 161 | cycrow | 314 | 	bool addAvailablePackage(SAvailablePackage *package);
 | 
        
           | 166 | cycrow | 315 | 	void saveAvailablePackages();
 | 
        
           |  |  | 316 | 	void readAvailablePackages();
 | 
        
           | 197 | cycrow | 317 | 	void parseAvailablePackage(const Utils::WString &str, const Utils::WString &webaddress = Utils::WString::Null());
 | 
        
           |  |  | 318 | 	const SAvailablePackage* findAvailablePackage(const Utils::WString& filename) const;
 | 
        
           |  |  | 319 | 	const SAvailablePackage* findAvailablePackage(const Utils::WString& name, const Utils::WString& author) const;
 | 
        
           |  |  | 320 | 	CBaseFile* findFoundPackage(const Utils::WString& name, const Utils::WString& author) const;
 | 
        
           | 205 | cycrow | 321 | 	int findAllServers(Utils::WStringList *list) const;
 | 
        
           | 1 | cycrow | 322 |   | 
        
           | 182 | cycrow | 323 | 	CBaseFile *findScriptByAuthor(const Utils::String &author, CBaseFile *prev = NULL);
 | 
        
           | 1 | cycrow | 324 | 	void RemoveFailedFiles();
 | 
        
           |  |  | 325 |   | 
        
           |  |  | 326 | private:
 | 
        
           | 179 | cycrow | 327 | 	size_t _createCockpits(Utils::CStringList &list);
 | 
        
           |  |  | 328 |   | 
        
           | 85 | cycrow | 329 | 	bool _checkForDisable(CBaseFile *package, bool disabled, CBaseFile *oldPackage);
 | 
        
           | 182 | cycrow | 330 | 	CBaseFile *_archive_fromRar(const Utils::String &filename, bool toInstall) const;
 | 
        
           |  |  | 331 | 	CBaseFile *_archive_fromZip(const Utils::String &filename, bool toInstall) const;
 | 
        
           | 50 | cycrow | 332 | 	void _addToFakePatch(CBaseFile *pPackage);
 | 
        
           | 56 | cycrow | 333 | 	int _gameTextNumber() const;
 | 
        
           | 197 | cycrow | 334 | 	void _addWareOverride(enum WareTypes type, int pos, const Utils::WString &id, int value, bool noto);
 | 
        
           |  |  | 335 | 	int _warePriceOverride(enum WareTypes type, int pos, const Utils::WString &id);
 | 
        
           |  |  | 336 | 	bool _wareNotoOverride(enum WareTypes type, int pos, const Utils::WString &id, int *noto);
 | 
        
           |  |  | 337 | 	void _removeWareOverride(enum WareTypes type, int pos, const Utils::WString &id);
 | 
        
           | 43 | cycrow | 338 |   | 
        
           |  |  | 339 | private:
 | 
        
           | 197 | cycrow | 340 | 	Utils::WString	m_sCurrentDir;
 | 
        
           |  |  | 341 | 	static Utils::WString	m_sTempDir;
 | 
        
           |  |  | 342 | 	Utils::WString			m_sMyDoc;
 | 
        
           |  |  | 343 | 	Utils::WString			m_sSetMod;
 | 
        
           |  |  | 344 | 	Utils::WString			_sSaveDir;
 | 
        
           | 125 | cycrow | 345 | 	GameDirectory *_pCurrentDir;
 | 
        
           | 1 | cycrow | 346 |   | 
        
           |  |  | 347 | 	// global files list
 | 
        
           |  |  | 348 | 	CLinkList<C_File>		m_lFiles;
 | 
        
           |  |  | 349 | 	CLinkList<CBaseFile>	m_lPackages;
 | 
        
           |  |  | 350 | 	CLinkList<C_File>		m_lUninstallFiles;
 | 
        
           |  |  | 351 | 	CLinkList<SGameWare>	m_lGameWares[WAREBUFFERS];
 | 
        
           |  |  | 352 | 	CLinkList<SGameShip>	m_lGameShips;
 | 
        
           | 88 | cycrow | 353 | 	CLinkList<SWarePriceOverride>	m_lWarePrices;
 | 
        
           | 164 | cycrow | 354 | 	CLinkList<CBaseFile>	m_lFoundPackages;
 | 
        
           | 93 | cycrow | 355 | 	COriginalFiles		   *_pOriginalFiles;
 | 
        
           | 1 | cycrow | 356 |   | 
        
           |  |  | 357 | 	// prepared lists
 | 
        
           |  |  | 358 | 	CLinkList<CBaseFile>	m_lInstallList; // install/uninstalling packages
 | 
        
           |  |  | 359 | 	CLinkList<CBaseFile>	m_lEnableList;  // enable packages
 | 
        
           |  |  | 360 | 	CLinkList<CBaseFile>	m_lDisableList; // disable packages
 | 
        
           |  |  | 361 |   | 
        
           | 197 | cycrow | 362 | 	Utils::WStringList		_lCreatedFiles; // list of files we've created
 | 
        
           |  |  | 363 | 	Utils::WStringList		_lNonRemovedFiles; // list of fiels that couldn't be removed for some reason
 | 
        
           |  |  | 364 | 	Utils::WStringList		_lGlobals; // global settigns that we want changed
 | 
        
           |  |  | 365 | 	Utils::WStringList		_lFakePatchOrder; // ordered fake patches
 | 
        
           | 1 | cycrow | 366 | 	CLinkList<SAvailablePackage> m_lAvailablePackages; // list of available packages online
 | 
        
           |  |  | 367 |   | 
        
           |  |  | 368 | 	CVirtualFileSystem		m_pGameVFS; // Games Virtual File System
 | 
        
           |  |  | 369 |   | 
        
           |  |  | 370 | 	CGameExe				m_gameExe;
 | 
        
           | 56 | cycrow | 371 | 	SGameExe				*m_pCurrentGameExe;
 | 
        
           | 1 | cycrow | 372 | 	CBaseFile			   *m_pEnabledMod;
 | 
        
           |  |  | 373 |   | 
        
           |  |  | 374 | 	// settings
 | 
        
           |  |  | 375 | 	bool		m_bRenameText;  // rename text files
 | 
        
           |  |  | 376 | 	bool		m_bAutoEnableChild;	// auto enable all children
 | 
        
           |  |  | 377 | 	bool		m_bForceModInstall; // allowsm ultiple mods to be installed
 | 
        
           |  |  | 378 | 	bool		m_bOldPlugin;		// if its loading data from the old plugin manager
 | 
        
           |  |  | 379 | 	bool		m_bLoadVFS;			// if we should load the virtual filesystem
 | 
        
           |  |  | 380 | 	int			m_iLanguage;	// Language id to use
 | 
        
           |  |  | 381 | 	int			m_iSaveGameManager; // Save game manager
 | 
        
           |  |  | 382 | 	bool		m_bSurpressProtectedWarning; // prevent checking for protected directory
 | 
        
           |  |  | 383 |   | 
        
           |  |  | 384 | 	int			m_iGame;		// the game the directory is
 | 
        
           |  |  | 385 | 	int			m_iGameVersion; // the version of the game (version position)
 | 
        
           | 197 | cycrow | 386 | 	Utils::WString	_sGameVersion; // the version of the game (full version)
 | 
        
           | 1 | cycrow | 387 | 	int			m_iGameFlags;	// the flags for the game from SGameExe
 | 
        
           |  |  | 388 | 	int			m_iMaxPatch;	// the maximum patch for the game
 | 
        
           |  |  | 389 |   | 
        
           |  |  | 390 | 	int			m_iSaveGame;
 | 
        
           |  |  | 391 | 	int			m_iError;
 | 
        
           |  |  | 392 | 	int			m_iLastUpdated;
 | 
        
           |  |  | 393 | 	int			m_iFakePatch;		// The current fake patch
 | 
        
           |  |  | 394 |   | 
        
           |  |  | 395 | 	bool		m_bVanilla;		// currently in vanilla mode, dont allow unsigned packages to be installed
 | 
        
           |  |  | 396 |   | 
        
           |  |  | 397 | 	bool		m_bLoaded;
 | 
        
           |  |  | 398 | 	bool		m_bRedo;
 | 
        
           |  |  | 399 | 	bool		m_bUsedWare;	// if we have used the ware files in the directory, not in a patch
 | 
        
           |  |  | 400 | 	bool		m_bRemoveDir;	// shall we remove direcotires;
 | 
        
           |  |  | 401 |   | 
        
           |  |  | 402 | 	int			m_iWareBuffer[WAREBUFFERS];	//Ware Buffers
 | 
        
           |  |  | 403 | 	int			m_iShipBuffer; //Ship Buffers
 | 
        
           |  |  | 404 |   | 
        
           |  |  | 405 | 	bool		m_bDisableVanilla;
 | 
        
           |  |  | 406 | 	bool		m_bForceEMP;
 | 
        
           |  |  | 407 |   | 
        
           |  |  | 408 | 	CListNode<CBaseFile>	*m_pPackageNode;
 | 
        
           |  |  | 409 | };
 | 
        
           |  |  | 410 |   | 
        
           |  |  | 411 | #endif // __PACKAGES_H__
 |