| 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"
 | 
        
           |  |  | 11 |   | 
        
           |  |  | 12 | enum {INSTALLERR_NONE, INSTALLERR_VERSION, INSTALLERR_INVALID, INSTALLERR_NOMULTI, INSTALLERR_NOSHIP, INSTALLERR_UNKNOWN, INSTALLERR_NOEXIST, INSTALLERR_OLD};
 | 
        
           |  |  | 13 | enum {INSTALLCHECK_OK, INSTALLCHECK_OLDVERSION, INSTALLCHECK_NOOTHERMOD, INSTALLCHECK_ALREADYQUEUED, INSTALLCHECK_WRONGGAME, INSTALLCHECK_WRONGVERSION, INSTALLCHECK_MODIFIED, INSTALLCHECK_NOSHIP};
 | 
        
           |  |  | 14 | enum {PROGRESS_ENABLEFILE, PROGRESS_SHUFFLEFAKE, PROGRESS_DISABLEFILE};
 | 
        
           |  |  | 15 | enum {PKERR_NONE, PKERR_NOPARENT, PKERR_MODIFIED, PKERR_MISSINGDEP, PKERR_NOOUTPUT, PKERR_DONTEXIST, PKERR_UNABLETOOPEN};
 | 
        
           |  |  | 16 | enum {WARETYPE_NONE, WARETYPE_DELETED, WARETYPE_ADDED, WARETYPE_DISABLED};
 | 
        
           |  |  | 17 | enum {WARES_BIO, WARES_ENERGY, WARES_FOOD, WARES_MINERAL, WARES_TECH, WARES_NATURAL, WAREBUFFERS};
 | 
        
           |  |  | 18 |   | 
        
           |  |  | 19 | #define IC_WRONGGAME		1
 | 
        
           |  |  | 20 | #define IC_WRONGVERSION		2
 | 
        
           |  |  | 21 | #define IC_OLDVERSION		4
 | 
        
           |  |  | 22 | #define IC_MODIFIED			8
 | 
        
           |  |  | 23 | #define IC_ALL				15
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 | #define PMTEXTFILE 901
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 | #define SHIPSTARTTEXT		500000
 | 
        
           |  |  | 28 | #define WARETEXTSTART		400000
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 | class CFileIO;
 | 
        
           |  |  | 31 |   | 
        
           |  |  | 32 | tstruct SGameWare {
 | 
        
           |  |  | 33 | 	char cType;
 | 
        
           |  |  | 34 | 	int iType;
 | 
        
           |  |  | 35 | 	int iText;
 | 
        
           |  |  | 36 | 	CyString sWareName;
 | 
        
           |  |  | 37 | 	int iPos;
 | 
        
           |  |  | 38 | 	SWares *pWare;
 | 
        
           |  |  | 39 | } SGameWare;
 | 
        
           |  |  | 40 |   | 
        
           |  |  | 41 | tstruct SGameShip {
 | 
        
           |  |  | 42 | 	int		  iType;
 | 
        
           |  |  | 43 | 	int		  iText;
 | 
        
           |  |  | 44 | 	int		  iPos;
 | 
        
           |  |  | 45 | 	CyString  sShipID;
 | 
        
           |  |  | 46 | 	CyString  sShipClass;
 | 
        
           |  |  | 47 | 	CXspFile *pPackage;
 | 
        
           |  |  | 48 | } SGameShip;
 | 
        
           |  |  | 49 |   | 
        
           |  |  | 50 | tstruct SBodies {
 | 
        
           |  |  | 51 | 	CyString	 sNumbers;
 | 
        
           |  |  | 52 | 	CyString	 sSection;
 | 
        
           |  |  | 53 | 	CyStringList lEntries;
 | 
        
           |  |  | 54 | } SBodes;
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 | tstruct SAvailablePackage {
 | 
        
           |  |  | 57 | 	CLinkList<SGameCompat> lGames;
 | 
        
           |  |  | 58 | 	int			iType;
 | 
        
           |  |  | 59 | 	int			iPluginType;
 | 
        
           |  |  | 60 | 	CyString	sName;
 | 
        
           |  |  | 61 | 	CyString	sAuthor;
 | 
        
           |  |  | 62 | 	CyString	sVersion;
 | 
        
           |  |  | 63 | 	CyString	sDesc;
 | 
        
           |  |  | 64 | 	CyString	sUpdated;
 | 
        
           |  |  | 65 | 	int			iEase;
 | 
        
           |  |  | 66 | 	int			iChanging;
 | 
        
           |  |  | 67 | 	int			iRec;
 | 
        
           |  |  | 68 | 	CyString	sFilename;
 | 
        
           |  |  | 69 | 	int			iScriptType;
 | 
        
           |  |  | 70 | 	bool		bSigned;
 | 
        
           |  |  | 71 | } SAvailablePackage;
 | 
        
           |  |  | 72 |   | 
        
           |  |  | 73 | class SPKEXPORT CPackages
 | 
        
           |  |  | 74 | {
 | 
        
           |  |  | 75 | public:
 | 
        
           |  |  | 76 | 	static CyString ConvertLanguage(int lang);
 | 
        
           |  |  | 77 | 	static SAvailablePackage *CreateAvailablePackageData(CBaseFile *package);
 | 
        
           |  |  | 78 | 	static CyString FormatAvailablePackageData(CBaseFile *package);
 | 
        
           |  |  | 79 | 	static CyString FormatAvailablePackageData(SAvailablePackage *package);
 | 
        
           |  |  | 80 | 	static CyString CreateFromPackagerScript(CyString filename);
 | 
        
           |  |  | 81 | 	static int GeneratePackageUpdateData(CyString dir, bool includeSingle = true);
 | 
        
           |  |  | 82 |   | 
        
           |  |  | 83 | 	CPackages ();
 | 
        
           |  |  | 84 | 	~CPackages ();
 | 
        
           |  |  | 85 |   | 
        
           |  |  | 86 | 	bool IsOldDir(CyString dir);
 | 
        
           |  |  | 87 | 	bool Read ( CyString dir, CProgressInfo *progress = NULL );
 | 
        
           |  |  | 88 | 	void Startup(CyString dir, CyString tempDir, CyString myDoc, CyString mod = NullString);
 | 
        
           |  |  | 89 |   | 
        
           |  |  | 90 | 	CBaseFile *LoadPackagerScript(CyString filename, int compression, CyString (*askFunc)(CyString), CyStringList *malformedLines = NULL, CyStringList *unknownCommands = NULL, CyStringList *variables = NULL);
 | 
        
           |  |  | 91 | 	CyStringList *GetGlobals() { return &m_lGlobals; }
 | 
        
           |  |  | 92 | 	CyStringList *GetFakePatchOrder() { return &m_lFakePatchOrder; }
 | 
        
           |  |  | 93 | 	CyString GetCurrentDirectory() { return m_sCurrentDir; }
 | 
        
           |  |  | 94 | 	CyString GetTempDirectory() { return m_sTempDir; }
 | 
        
           |  |  | 95 | 	CyString GetMyDocuments() { return m_sMyDoc; }
 | 
        
           |  |  | 96 | 	CGameExe *GetGameExe() { return &m_gameExe; }
 | 
        
           |  |  | 97 | 	CLinkList<CBaseFile> *GetInstallPackageList() { return &m_lInstallList; }
 | 
        
           |  |  | 98 |   | 
        
           |  |  | 99 | 	// installing/uninstalling
 | 
        
           |  |  | 100 | 	bool		InstallPackage ( CBaseFile *package, CyStringList *errors, CProgressInfo *progress = NULL, bool disabled = false );
 | 
        
           |  |  | 101 | 	CBaseFile		*OpenPackage ( CyString file, int *error, CProgressInfo *progress = NULL, int readtype = SPKREAD_ALL, int flags = READFLAG_NONE );
 | 
        
           |  |  | 102 | 	CMultiSpkFile	*OpenMultiPackage(CyString file, int *error, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 103 | 	bool		OpenMultiPackage ( CyString file, CLinkList<CBaseFile> *packageList, int *error, CProgressInfo *progress = NULL );
 | 
        
           |  |  | 104 | 	int			CheckInstallPackage(CBaseFile *package, int check = IC_ALL);
 | 
        
           |  |  | 105 | 	bool		RemoveFile(C_File *file, CyStringList *errors = NULL);
 | 
        
           |  |  | 106 | 	void		PrepareUninstallPackage(CBaseFile *package);
 | 
        
           |  |  | 107 | 	bool		UninstallPreparedPackages(CyStringList *errors, CProgressInfo *progress, CLinkList<CBaseFile> *uninstalledPackages = NULL, CLinkList<CBaseFile> *disabledPackages = NULL);
 | 
        
           |  |  | 108 | 	void		ConvertOldPackage(CBaseFile *p);
 | 
        
           |  |  | 109 | 	void		PurgeUninstallScripts(CBaseFile *package, CyStringList *errors);
 | 
        
           |  |  | 110 | 	int 		PrepareInstallPackage(CBaseFile *package, bool disabled = false, bool force = false, int check = IC_ALL);
 | 
        
           |  |  | 111 | 	int			InstallPreparedPackages(CyStringList *errors, CProgressInfo *progress, CLinkList<CBaseFile> *errored, CLinkList<CBaseFile> *installedList = NULL);
 | 
        
           |  |  | 112 | 	void		RemovePreparedInstall(CBaseFile *package);
 | 
        
           |  |  | 113 | 	int			GetNumPackagesInQueue() { return m_lInstallList.size(); }
 | 
        
           |  |  | 114 | 	int			CheckOpenPackage(CyString file, int *error);
 | 
        
           |  |  | 115 | 	int			GetMissingDependacies(CBaseFile *p, CyStringList *list, bool onlyEnabled = false, bool includePrepared = false);
 | 
        
           |  |  | 116 | 	bool		CheckInstalledDependacy(CyString name, CyString author, CyString version, bool onlyEnabled = false, bool includePerpered = false);
 | 
        
           |  |  | 117 | 	bool		CheckEnabledDependacy(CBaseFile *p);
 | 
        
           |  |  | 118 | 	int			GetDependacyList(CBaseFile *package, CLinkList<CBaseFile> *list);
 | 
        
           |  |  | 119 | 	int			PrepareMultiPackage ( CyString file, CLinkList<CBaseFile> *errorPackageList, int *error, CProgressInfo *progress = 0);
 | 
        
           |  |  | 120 |   | 
        
           |  |  | 121 | 	bool		IsOldPluginManager() { return m_bOldPlugin; }
 | 
        
           |  |  | 122 |   | 
        
           |  |  | 123 | 	// enable/disable
 | 
        
           |  |  | 124 | 	bool EnablePackage ( CBaseFile *package, CyStringList *errors, CProgressInfo *progress = NULL );
 | 
        
           |  |  | 125 | 	bool DisablePackage ( CBaseFile *package, CyStringList *errors, CProgressInfo *progress = NULL );
 | 
        
           |  |  | 126 | 	bool DisablePreparedPackages ( CyStringList *errors, CProgressInfo *progress, CLinkList<CBaseFile> *disabledPackages = NULL );
 | 
        
           |  |  | 127 | 	bool PrepareEnablePackage(CBaseFile *package);
 | 
        
           |  |  | 128 | 	bool PrepareDisablePackage(CBaseFile *package);
 | 
        
           |  |  | 129 | 	bool EnablePreparedPackages ( CyStringList *errors, CProgressInfo *progress, CLinkList<CBaseFile> *enabledPackages = NULL );
 | 
        
           |  |  | 130 | 	int  GetNumPackagesInEnabledQueue() { return m_lEnableList.size(); }
 | 
        
           |  |  | 131 | 	int  GetNumPackagesInDisabledQueue() { return m_lDisableList.size(); }
 | 
        
           |  |  | 132 | 	bool PrepareDisableForVanilla();
 | 
        
           |  |  | 133 | 	bool PrepareEnableLibrarys();
 | 
        
           |  |  | 134 | 	bool PrepareEnableFromVanilla();
 | 
        
           |  |  | 135 |   | 
        
           |  |  | 136 | 	void WriteData();
 | 
        
           |  |  | 137 | 	bool CloseDir ( CyStringList *errors = 0, CProgressInfo *progress = NULL, bool removedir = false );
 | 
        
           |  |  | 138 | 	bool RestoreFakePatch();
 | 
        
           |  |  | 139 | 	bool ReadyFakePatch();
 | 
        
           |  |  | 140 | 	bool CheckValidPluginManagerFile(CyString filename);
 | 
        
           |  |  | 141 | 	bool CheckIfPluginManagerFile(CyString filename);
 | 
        
           |  |  | 142 |   | 
        
           |  |  | 143 | 	// package control
 | 
        
           |  |  | 144 | 	void UpdateUsedFiles(CLinkList<CBaseFile> *ignoreList = NULL, bool = true);
 | 
        
           |  |  | 145 | 	void UpdateSigned();
 | 
        
           |  |  | 146 | 	bool UpdatePackages(int doStatus = -1, bool individual = false);
 | 
        
           |  |  | 147 | 	CBaseFile *FindXspPackage(CyString id);
 | 
        
           |  |  | 148 | 	CBaseFile *FindSpkPackage(CyString name, CyString author);
 | 
        
           |  |  | 149 | 	CArchiveFile *FindArchivePackage(CyString name);
 | 
        
           |  |  | 150 | 	CBaseFile *FindPackage(CyString name, CyString author);
 | 
        
           |  |  | 151 | 	CBaseFile *FindFirstPackageWithFile(C_File *f);
 | 
        
           |  |  | 152 | 	CBaseFile *FindNextPackageWithFile(CBaseFile *p, C_File *f);
 | 
        
           |  |  | 153 | 	CBaseFile *FindPackage(CBaseFile *package);
 | 
        
           |  |  | 154 | 	C_File *FindFile(int filetype, CyString filename, CyString dir = NullString);
 | 
        
           |  |  | 155 | 	CBaseFile *FirstPackage() { return m_lPackages.First(); }
 | 
        
           |  |  | 156 | 	CBaseFile *NextPackage() { return m_lPackages.Next(); }
 | 
        
           |  |  | 157 | 	CBaseFile *GetFirstPackage() { if ( m_lPackages.Front() ) return m_lPackages.Front()->Data(); return NULL; }
 | 
        
           |  |  | 158 | 	CBaseFile *GetNextPackage(CBaseFile *from) 
 | 
        
           |  |  | 159 | 	{ 
 | 
        
           |  |  | 160 | 		bool found = false;
 | 
        
           |  |  | 161 | 		for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
 | 
        
           |  |  | 162 | 		{
 | 
        
           |  |  | 163 | 			if ( !node->Data() ) continue;
 | 
        
           |  |  | 164 | 			if ( node->Data() == from )
 | 
        
           |  |  | 165 | 				found = true;
 | 
        
           |  |  | 166 | 			else if ( found )
 | 
        
           |  |  | 167 | 				return node->Data();
 | 
        
           |  |  | 168 | 		}
 | 
        
           |  |  | 169 | 		return NULL; 
 | 
        
           |  |  | 170 | 	}
 | 
        
           |  |  | 171 | 	void Reset();
 | 
        
           |  |  | 172 | 	CBaseFile *GetPackageAt(int i) { return m_lPackages[i]; }
 | 
        
           |  |  | 173 | 	CyString GetSelectedModName();
 | 
        
           |  |  | 174 | 	CyString GetModKey();
 | 
        
           |  |  | 175 | 	void SetupWares();
 | 
        
           |  |  | 176 | 	void SetupShips();
 | 
        
           |  |  | 177 | 	void PurgeGameObjects();
 | 
        
           |  |  | 178 | 	void PurgeWares();
 | 
        
           |  |  | 179 | 	void PurgeShips();
 | 
        
           |  |  | 180 | 	void StartPackage() { m_pPackageNode = m_lPackages.Front(); }
 | 
        
           |  |  | 181 | 	void UpdatePackage(CBaseFile *p);
 | 
        
           |  |  | 182 | 	CBaseFile *GetCurrentPackage() { return (m_pPackageNode) ? m_pPackageNode->Data() : NULL; }
 | 
        
           |  |  | 183 | 	bool RemoveCurrentDirectory();
 | 
        
           |  |  | 184 | 	void RemoveCreatedFiles();
 | 
        
           |  |  | 185 | 	bool AnyUnusedShared();
 | 
        
           |  |  | 186 |   | 
        
           |  |  | 187 | 	// util functions
 | 
        
           |  |  | 188 | 	void RemoveUnusedDirectories(CyStringList &dirs, CyStringList *errors = NULL);
 | 
        
           |  |  | 189 | 	int  RemoveUninstallScripts(CyStringList *errors = 0, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 190 | 	bool RemoveUninstallFile(C_File *file, CyStringList *errors = 0);
 | 
        
           |  |  | 191 | 	int  RemoveUnusedSharedFiles(CyStringList *errors = 0, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 192 | 	bool RemoveSharedFile(C_File *file, CyStringList *errors = NULL);
 | 
        
           |  |  | 193 | 	void ShufflePatchTo(C_File *file, int to, CyStringList *errors);
 | 
        
           |  |  | 194 | 	void ShuffleFakePatches(CyStringList *errors);
 | 
        
           |  |  | 195 | 	void ShuffleTextFiles(CyStringList *errors);
 | 
        
           |  |  | 196 | 	int  FindNextFakePatch(int start = 0, CyString dir = NullString);
 | 
        
           |  |  | 197 | 	int  FindNextTextFile(int start = 2, CyString dir = NullString);
 | 
        
           |  |  | 198 | 	int  FindLastFakePatch(int start = 99, CyString dir = NullString);
 | 
        
           |  |  | 199 | 	int  FindLastTextFile(int start = 9999, CyString dir = NullString);
 | 
        
           |  |  | 200 | 	int  FindLowestFakePatchInstalled();
 | 
        
           |  |  | 201 | 	void ReadGameLanguage(bool force = true);
 | 
        
           |  |  | 202 | 	int	 RemoveAllPackages(CyStringList *errors = NULL, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 203 | 	void AssignPackageNumbers();
 | 
        
           |  |  | 204 | 	int  GetChildPackages(CBaseFile *package, CLinkList<CBaseFile> *children, bool recursive = false);
 | 
        
           |  |  | 205 | 	int  GetAllPackageFiles(CBaseFile *package, CLinkList<C_File> *fileList, bool includeChild);
 | 
        
           |  |  | 206 | 	int	 GetAllPackageFiles(CLinkList<CBaseFile> *list, CLinkList<C_File> *fileList, bool includeChild);
 | 
        
           |  |  | 207 | 	void AddLogEntry(int type, CyString args, CyStringList *errors);
 | 
        
           |  |  | 208 | 	CyString FindDataDir(CyString dir, CyString file);
 | 
        
           |  |  | 209 | 	int  CountPackages(int type, bool onlyEnabled);
 | 
        
           |  |  | 210 | 	int  CountBuiltInPackages(bool onlyEnabled);
 | 
        
           |  |  | 211 | 	bool IsCurrentDir(CyString dir);
 | 
        
           |  |  | 212 | 	bool CheckOtherPackage(CBaseFile *package);
 | 
        
           |  |  | 213 | 	int CheckPreparedInstallRequired(CLinkList<CBaseFile> *list);
 | 
        
           |  |  | 214 | 	static int ConvertWareType(char w);
 | 
        
           |  |  | 215 | 	static char ConvertWareTypeBack(int w);
 | 
        
           |  |  | 216 | 	CyString GetLogDirectory();
 | 
        
           |  |  | 217 | 	CyString GetLogDirectory(CyString gameExe);
 | 
        
           |  |  | 218 | 	CyString GetSaveDirectory();
 | 
        
           |  |  | 219 | 	void BackupSaves() { BackupSaves(m_bVanilla); }
 | 
        
           |  |  | 220 | 	void BackupSaves(bool vanilla);
 | 
        
           |  |  | 221 | 	void RestoreSaves() { RestoreSaves(m_bVanilla); }
 | 
        
           |  |  | 222 | 	void RestoreSaves(bool vanilla);
 | 
        
           |  |  | 223 | 	bool UnPackFile(CyString filename, bool checkxml = true);
 | 
        
           |  |  | 224 | 	bool PackFile(CyString filename);
 | 
        
           |  |  | 225 | 	bool PackFile(CFileIO *File, CyString filename);
 | 
        
           |  |  | 226 | 	CyString ConvertTextString(CyString text);
 | 
        
           |  |  | 227 | 	void LoadVirtualFileSystem();
 | 
        
           |  |  | 228 | 	bool CheckAccessRights(CyString dir);
 | 
        
           |  |  | 229 | 	bool LoadShipData(CyString file, CyStringList *list);
 | 
        
           |  |  | 230 | 	bool ReadTextPage(CyString file, CyStringList *list, bool search, int page);
 | 
        
           |  |  | 231 | 	CyStringList *LoadShipData(CyString file);
 | 
        
           |  |  | 232 | 	CyStringList *ReadTextPage(CyString file, bool search, int page);
 | 
        
           |  |  | 233 | 	int AdjustFileType(CyString name, int filetype);
 | 
        
           |  |  | 234 | 	CXspFile *ExtractShip(CyString catfile, CyString id, CProgressInfo *progress = NULL);
 | 
        
           |  |  | 235 | 	CyString ReadShipData(CyString file, CyString entry);
 | 
        
           |  |  | 236 | 	bool IsSamePackage(CBaseFile *p1, CBaseFile *p2);
 | 
        
           |  |  | 237 | 	void ApplyFakePatchOrder(CyStringList *list);
 | 
        
           |  |  | 238 | 	CBaseFile *CreateFromArchive(CyString filename, bool toInstall = false );
 | 
        
           |  |  | 239 | 	void ReadArchiveData(const char *buf, size_t len, CBaseFile *archive);
 | 
        
           |  |  | 240 | 	void ReadArchiveData(CyString filename, CBaseFile *archive);
 | 
        
           |  |  | 241 | 	int VerifyInstalledFiles(CyStringList *missingFiles = NULL, bool getPackages = true);
 | 
        
           |  |  | 242 |   | 
        
           |  |  | 243 | 	int GetCurrentGameFlags() { return m_iGameFlags; }
 | 
        
           |  |  | 244 |   | 
        
           |  |  | 245 | 	void SetCurrentDir(CyString dir) { m_sCurrentDir = dir; }
 | 
        
           |  |  | 246 |   | 
        
           |  |  | 247 | 	// merge mods
 | 
        
           |  |  | 248 | 	CyStringList *GetMergedFiles(CCatFile *cat1, CCatFile *cat2);
 | 
        
           |  |  | 249 | 	bool CanWeMerge(CyString file);
 | 
        
           |  |  | 250 | 	bool MergeMods(CCatFile *mod1, CCatFile *mod2, CyString outFile, CyStringList *cantMerge);
 | 
        
           |  |  | 251 | 	bool NeedToMerge(CyString file);
 | 
        
           |  |  | 252 | 	CyStringList MergeTextFiles(CyStringList *files, CCatFile *mod1, CCatFile *mod2);
 | 
        
           |  |  | 253 | 	bool GetModCompatabilityList(C_File *file, CyStringList *list = NULL);
 | 
        
           |  |  | 254 | 	bool CheckCompatabilityBetweenModFiles(C_File *from, C_File *to, CyStringList *list = NULL);
 | 
        
           |  |  | 255 | 	bool CheckCompatabilityBetweenMods(CBaseFile *from, CBaseFile *to, CyStringList *list = NULL);
 | 
        
           |  |  | 256 | 	int CheckCompatabilityAgainstPackages(CBaseFile *newFile, CyStringList *list = NULL, CLinkList<CBaseFile> *packages = NULL);
 | 
        
           |  |  | 257 |   | 
        
           |  |  | 258 | 	CyString GetLanguageName();
 | 
        
           |  |  | 259 |   | 
        
           |  |  | 260 | 	int	GetGameLanguage(CyString dir = NullString);
 | 
        
           |  |  | 261 | 	int      GetGameAddons(CyStringList &exes, CyString dir = NullString);
 | 
        
           |  |  | 262 | 	CyString GetGameName(CyString dir = NullString);
 | 
        
           |  |  | 263 | 	CyString GetGameVersionFromType(int game, int version, CyString sVersion);
 | 
        
           |  |  | 264 | 	CyString GetGameNameFromType(int game);
 | 
        
           |  |  | 265 | 	CyString GetGameTypesString(CBaseFile *package, bool includeVersion);
 | 
        
           |  |  | 266 | 	CyString GetGameVersionString(CBaseFile *package);
 | 
        
           |  |  | 267 | 	CyString GetGameRunExe(CyString dir = NullString);
 | 
        
           |  |  | 268 | 	CyString GetProperDir(CyString dir = NullString);
 | 
        
           |  |  | 269 | 	CyString GetAddonDir(CyString dir = NullString);
 | 
        
           |  |  | 270 |   | 
        
           |  |  | 271 | 	// text files
 | 
        
           |  |  | 272 | 	void CreateLanguageTextFiles(CyStringList *errors = 0);
 | 
        
           |  |  | 273 | 	bool RenameTextFile(CyString textid, int languageid, CyStringList *errors);
 | 
        
           |  |  | 274 | 	void AddTextFileToScripts(C_File *file, CyString textid);
 | 
        
           |  |  | 275 | 	void CreatePluginManagerText();
 | 
        
           |  |  | 276 |   | 
        
           |  |  | 277 | 	// game control
 | 
        
           |  |  | 278 | 	void CreateEMPFile(CyString progDir = CyString::NullString);
 | 
        
           |  |  | 279 | 	void CreateWareFiles();
 | 
        
           |  |  | 280 | 	int ExtractGameFile(CyString aFilename, CyString aTo, CyString dir = NullString, CyString addon = NullString);
 | 
        
           |  |  | 281 | 	void CreateDummies();
 | 
        
           |  |  | 282 | 	void CreateComponants();
 | 
        
           |  |  | 283 | 	void CreateCutData();
 | 
        
           |  |  | 284 | 	void CreateBodies();
 | 
        
           |  |  | 285 | 	void CreateGlobals();
 | 
        
           |  |  | 286 | 	void CreateAnimations();
 | 
        
           |  |  | 287 | 	void CreateTShips();
 | 
        
           |  |  | 288 | 	CyStringList *CreateCockpits();
 | 
        
           |  |  | 289 | 	void CreateCustomStarts();
 | 
        
           |  |  | 290 | 	void AddCreatedFile(CyString file);
 | 
        
           |  |  | 291 | 	bool ReadGlobals(CyStringList &globals);
 | 
        
           |  |  | 292 |   | 
        
           |  |  | 293 | 	// install text
 | 
        
           |  |  | 294 | 	CyString GetInstallBeforeText(CBaseFile *package);
 | 
        
           |  |  | 295 | 	CyString GetInstallAfterText(CBaseFile *package);
 | 
        
           |  |  | 296 | 	CyString GetUninstallBeforeText(CBaseFile *package);
 | 
        
           |  |  | 297 | 	CyString GetUninstallAfterText(CBaseFile *package);
 | 
        
           |  |  | 298 |   | 
        
           |  |  | 299 | 	// original files
 | 
        
           |  |  | 300 | 	void StoreOriginalFiles(int filetype, CyString searchPath);
 | 
        
           |  |  | 301 | 	void AddOriginalFile(int filetype, CyString filename, CyString searchPath);
 | 
        
           |  |  | 302 | 	C_File *GetOriginalFile(C_File *file);
 | 
        
           |  |  | 303 | 	bool IsOriginalFile(C_File *file);
 | 
        
           |  |  | 304 | 	bool BackupOriginalFile(C_File *f, CyStringList *errors);
 | 
        
           |  |  | 305 |   | 
        
           |  |  | 306 | 	//setting functions
 | 
        
           |  |  | 307 | 	void SetRenameText(bool b) { m_bRenameText = b; }
 | 
        
           |  |  | 308 | 	void SetLanguage(int i) { m_iLanguage = i; }
 | 
        
           |  |  | 309 | 	void SetAutoEnable(bool b) { m_bAutoEnableChild = b; }
 | 
        
           |  |  | 310 | 	void SetForceModInstall(bool b) { m_bForceModInstall = b; }
 | 
        
           |  |  | 311 | 	void SetTempDirectory(CyString s) { m_sTempDir = s; }
 | 
        
           |  |  | 312 | 	void SetMyDocuments(CyString s) { m_sMyDoc = s; }
 | 
        
           |  |  | 313 | 	void SetForceEMP(bool b) { m_bForceEMP = b; }
 | 
        
           |  |  | 314 | 	void SetSurpressProtectedWarning(bool b) { m_bSurpressProtectedWarning = b; }
 | 
        
           |  |  | 315 | 	void SurpressProtectedWarning() { m_bSurpressProtectedWarning = true; }
 | 
        
           |  |  | 316 | 	bool IsSupressProtectedWarning() { return m_bSurpressProtectedWarning; }
 | 
        
           |  |  | 317 |   | 
        
           |  |  | 318 | 	int GetLanguage() { return m_iLanguage; }
 | 
        
           |  |  | 319 | 	int GetGame() { return m_iGame; }
 | 
        
           |  |  | 320 | 	bool IsLoaded() { return m_bLoaded; }
 | 
        
           |  |  | 321 | 	bool IsVanilla() { return m_bVanilla; }
 | 
        
           |  |  | 322 | 	void SetVanilla(bool b);
 | 
        
           |  |  | 323 |   | 
        
           |  |  | 324 | 	CyString GetSetMod() { return m_sSetMod; }
 | 
        
           |  |  | 325 | 	void SetMod(CyString mod) { 
 | 
        
           |  |  | 326 | 		if ( mod != "PluginManager" )
 | 
        
           |  |  | 327 | 			m_sSetMod = mod; 
 | 
        
           |  |  | 328 | 	}
 | 
        
           |  |  | 329 |   | 
        
           |  |  | 330 | 	CBaseFile *GetEnabledMod() { return m_pEnabledMod; }
 | 
        
           |  |  | 331 |   | 
        
           |  |  | 332 | 	//errors
 | 
        
           |  |  | 333 | 	void ClearError() { m_iError = PKERR_NONE; }
 | 
        
           |  |  | 334 | 	int  GetError() { return m_iError; }
 | 
        
           |  |  | 335 |   | 
        
           |  |  | 336 | 	CLinkList<CBaseFile> *PackageList() { return &m_lPackages; }
 | 
        
           |  |  | 337 | 	CLinkList<SAvailablePackage> *GetAvailablePackageList() { return &m_lAvailablePackages; }
 | 
        
           |  |  | 338 | 	bool AnyAvailablePackages(int type = -1);
 | 
        
           |  |  | 339 | 	bool AddAvailablePackage(SAvailablePackage *package);
 | 
        
           |  |  | 340 | 	void ParseAvailablePackage(CyString str, CyString webaddress = NullString);
 | 
        
           |  |  | 341 | 	SAvailablePackage *FindAvailablePackage(CyString &filename);
 | 
        
           |  |  | 342 | 	int FindAllServers(CyStringList *list);
 | 
        
           |  |  | 343 |   | 
        
           |  |  | 344 | 	CBaseFile *FindScriptByAuthor(CyString author, CBaseFile *prev = NULL);
 | 
        
           |  |  | 345 | 	void RemoveFailedFiles();
 | 
        
           |  |  | 346 |   | 
        
           |  |  | 347 | private:
 | 
        
           |  |  | 348 | 	CyString	m_sCurrentDir;
 | 
        
           |  |  | 349 | 	CyString	m_sTempDir;
 | 
        
           |  |  | 350 | 	CyString	m_sMyDoc;
 | 
        
           |  |  | 351 | 	CyString	m_sSetMod;
 | 
        
           |  |  | 352 | 	CyString	m_sActiveDir;
 | 
        
           |  |  | 353 |   | 
        
           |  |  | 354 | 	// global files list
 | 
        
           |  |  | 355 | 	CLinkList<C_File>		m_lFiles;
 | 
        
           |  |  | 356 | 	CLinkList<CBaseFile>	m_lPackages;
 | 
        
           |  |  | 357 | 	CLinkList<C_File>		m_lUninstallFiles;
 | 
        
           |  |  | 358 | 	CLinkList<C_File>		m_lOriginalFiles;
 | 
        
           |  |  | 359 | 	CLinkList<SGameWare>	m_lGameWares[WAREBUFFERS];
 | 
        
           |  |  | 360 | 	CLinkList<SGameShip>	m_lGameShips;
 | 
        
           |  |  | 361 |   | 
        
           |  |  | 362 | 	// prepared lists
 | 
        
           |  |  | 363 | 	CLinkList<CBaseFile>	m_lInstallList; // install/uninstalling packages
 | 
        
           |  |  | 364 | 	CLinkList<CBaseFile>	m_lEnableList;  // enable packages
 | 
        
           |  |  | 365 | 	CLinkList<CBaseFile>	m_lDisableList; // disable packages
 | 
        
           |  |  | 366 |   | 
        
           |  |  | 367 | 	CyStringList			m_lCreatedFiles; // list of files we've created
 | 
        
           |  |  | 368 | 	CyStringList			m_lNonRemovedFiles; // list of fiels that couldn't be removed for some reason
 | 
        
           |  |  | 369 | 	CyStringList			m_lGlobals; // global settigns that we want changed
 | 
        
           |  |  | 370 | 	CyStringList			m_lFakePatchOrder; // ordered fake patches
 | 
        
           |  |  | 371 | 	CLinkList<SAvailablePackage> m_lAvailablePackages; // list of available packages online
 | 
        
           |  |  | 372 |   | 
        
           |  |  | 373 | 	CVirtualFileSystem		m_pGameVFS; // Games Virtual File System
 | 
        
           |  |  | 374 |   | 
        
           |  |  | 375 | 	CGameExe				m_gameExe;
 | 
        
           |  |  | 376 | 	CBaseFile			   *m_pEnabledMod;
 | 
        
           |  |  | 377 |   | 
        
           |  |  | 378 | 	// settings
 | 
        
           |  |  | 379 | 	bool		m_bRenameText;  // rename text files
 | 
        
           |  |  | 380 | 	bool		m_bAutoEnableChild;	// auto enable all children
 | 
        
           |  |  | 381 | 	bool		m_bForceModInstall; // allowsm ultiple mods to be installed
 | 
        
           |  |  | 382 | 	bool		m_bOldPlugin;		// if its loading data from the old plugin manager
 | 
        
           |  |  | 383 | 	bool		m_bLoadVFS;			// if we should load the virtual filesystem
 | 
        
           |  |  | 384 | 	int			m_iLanguage;	// Language id to use
 | 
        
           |  |  | 385 | 	int			m_iSaveGameManager; // Save game manager
 | 
        
           |  |  | 386 | 	bool		m_bSurpressProtectedWarning; // prevent checking for protected directory
 | 
        
           |  |  | 387 |   | 
        
           |  |  | 388 | 	int			m_iGame;		// the game the directory is
 | 
        
           |  |  | 389 | 	int			m_iGameVersion; // the version of the game (version position)
 | 
        
           |  |  | 390 | 	CyString	m_sGameVersion; // the version of the game (full version)
 | 
        
           |  |  | 391 | 	int			m_iGameFlags;	// the flags for the game from SGameExe
 | 
        
           |  |  | 392 | 	int			m_iMaxPatch;	// the maximum patch for the game
 | 
        
           |  |  | 393 |   | 
        
           |  |  | 394 | 	int			m_iSaveGame;
 | 
        
           |  |  | 395 | 	int			m_iError;
 | 
        
           |  |  | 396 | 	int			m_iLastUpdated;
 | 
        
           |  |  | 397 | 	int			m_iFakePatch;		// The current fake patch
 | 
        
           |  |  | 398 |   | 
        
           |  |  | 399 | 	bool		m_bVanilla;		// currently in vanilla mode, dont allow unsigned packages to be installed
 | 
        
           |  |  | 400 |   | 
        
           |  |  | 401 | 	bool		m_bLoaded;
 | 
        
           |  |  | 402 | 	bool		m_bRedo;
 | 
        
           |  |  | 403 | 	bool		m_bUsedWare;	// if we have used the ware files in the directory, not in a patch
 | 
        
           |  |  | 404 | 	bool		m_bRemoveDir;	// shall we remove direcotires;
 | 
        
           |  |  | 405 |   | 
        
           |  |  | 406 | 	int			m_iWareBuffer[WAREBUFFERS];	//Ware Buffers
 | 
        
           |  |  | 407 | 	int			m_iShipBuffer; //Ship Buffers
 | 
        
           |  |  | 408 |   | 
        
           |  |  | 409 | 	bool		m_bDisableVanilla;
 | 
        
           |  |  | 410 | 	bool		m_bForceEMP;
 | 
        
           |  |  | 411 |   | 
        
           |  |  | 412 | 	CListNode<CBaseFile>	*m_pPackageNode;
 | 
        
           |  |  | 413 | };
 | 
        
           |  |  | 414 |   | 
        
           |  |  | 415 | #endif // __PACKAGES_H__
 |