| 1 | cycrow | 1 | #ifndef __GAME_EXE_H__
 | 
        
           |  |  | 2 | #define __GAME_EXE_H__
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 | #include "lists.h"
 | 
        
           |  |  | 5 | #include "File.h"
 | 
        
           |  |  | 6 |   | 
        
           | 57 | cycrow | 7 | enum {
 | 
        
           |  |  | 8 | 	EXEFLAG_NONE			= 0,
 | 
        
           |  |  | 9 | 	EXEFLAG_TCTEXT			= 1,
 | 
        
           |  |  | 10 | 	EXEFLAG_MYDOCLOG		= 2,
 | 
        
           |  |  | 11 | 	EXEFLAG_NOXOR			= 4,
 | 
        
           |  |  | 12 | 	EXEFLAG_NOSAVESUBDIR	= 8,
 | 
        
           |  |  | 13 | 	EXEFLAG_ADDON			= 16,
 | 
        
           |  |  | 14 | };
 | 
        
           | 1 | cycrow | 15 |   | 
        
           | 233 | cycrow | 16 | #define EXE_VERSIONPOS			8
 | 
        
           | 1 | cycrow | 17 | #define EXE_VERSION_NAMESTART	(EXE_VERSIONPOS + 2)
 | 
        
           |  |  | 18 | #define EXE_VERSION_SIZESTART	(EXE_VERSIONPOS + 1)
 | 
        
           |  |  | 19 |   | 
        
           |  |  | 20 | tstruct SGameExeVersion {
 | 
        
           | 197 | cycrow | 21 | 	Utils::WString	sName;
 | 
        
           | 56 | cycrow | 22 | 	int				iName;
 | 
        
           | 197 | cycrow | 23 | 	Utils::WString	fVersion;
 | 
        
           | 1 | cycrow | 24 | 	CLinkList<int> lSize;
 | 
        
           |  |  | 25 | } SGameExeVersion;
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 | tstruct SGameExe {
 | 
        
           | 233 | cycrow | 28 | 	struct SGameExe() : iFlags(0), iMaxPatch(0), iName(0), iAudioStream(1), iAddonTo(0), iTextNum(0) { }
 | 
        
           | 197 | cycrow | 29 | 	Utils::WString sExe;
 | 
        
           |  |  | 30 | 	Utils::WString sName;
 | 
        
           |  |  | 31 | 	Utils::WString sModKey;
 | 
        
           | 1 | cycrow | 32 | 	int		 iFlags;
 | 
        
           |  |  | 33 | 	int		 iMaxPatch;
 | 
        
           |  |  | 34 | 	int		 iName;
 | 
        
           | 233 | cycrow | 35 | 	int		 iAudioStream;
 | 
        
           | 197 | cycrow | 36 | 	Utils::WString sMyDoc;
 | 
        
           |  |  | 37 | 	Utils::WString sAddon;
 | 
        
           | 1 | cycrow | 38 | 	int		 iAddonTo;
 | 
        
           | 56 | cycrow | 39 | 	int		 iTextNum;
 | 
        
           | 1 | cycrow | 40 | 	CLinkList<SGameExeVersion> lVersions;
 | 
        
           |  |  | 41 | } SGameExe;
 | 
        
           |  |  | 42 |   | 
        
           | 125 | cycrow | 43 | tstruct GameDirectory
 | 
        
           |  |  | 44 | {
 | 
        
           | 197 | cycrow | 45 | 	Utils::WString dir;
 | 
        
           |  |  | 46 | 	Utils::WString name;
 | 
        
           |  |  | 47 | 	Utils::WString version;
 | 
        
           | 125 | cycrow | 48 | 	int			  id;
 | 
        
           |  |  | 49 | 	int			  langid;
 | 
        
           | 197 | cycrow | 50 | 	Utils::WString langname;
 | 
        
           |  |  | 51 | 	Utils::WString logdir;
 | 
        
           |  |  | 52 | 	Utils::WString addon;
 | 
        
           |  |  | 53 | 	Utils::WString exe;
 | 
        
           |  |  | 54 | 	Utils::WString basename;
 | 
        
           | 125 | cycrow | 55 | } GameDirectory;
 | 
        
           |  |  | 56 |   | 
        
           | 1 | cycrow | 57 | class SPKEXPORT CGameExe 
 | 
        
           |  |  | 58 | {
 | 
        
           | 56 | cycrow | 59 | private:
 | 
        
           |  |  | 60 | 	CLinkList<SGameExe> m_lExe;
 | 
        
           |  |  | 61 |   | 
        
           | 1 | cycrow | 62 | public:
 | 
        
           |  |  | 63 | 	void Reset();
 | 
        
           |  |  | 64 |   | 
        
           | 197 | cycrow | 65 | 	void parseExe(const Utils::WString &line);
 | 
        
           |  |  | 66 | 	int  parseFlags(const Utils::WString &flags);
 | 
        
           |  |  | 67 | 	bool readFile(const Utils::WString &file);
 | 
        
           | 1 | cycrow | 68 |   | 
        
           | 197 | cycrow | 69 | 	int addExe(const Utils::WString &exe);
 | 
        
           |  |  | 70 | 	SGameExe *gameExe(const Utils::WString &exe) const;
 | 
        
           | 1 | cycrow | 71 |   | 
        
           | 197 | cycrow | 72 | 	int findVersion(const Utils::WString &exe, int size, Utils::WString *fVersion);
 | 
        
           | 1 | cycrow | 73 |   | 
        
           | 197 | cycrow | 74 | 	int findAddonType(const Utils::WString &gameExe) const;
 | 
        
           |  |  | 75 | 	int getGameType(const Utils::WString &gameExe) const;
 | 
        
           |  |  | 76 | 	int getGameVersion(const Utils::WString &gameExe, Utils::WString *fVersion) const;
 | 
        
           |  |  | 77 | 	bool getGameVersionName(const Utils::WString &gameExe, Utils::WString *versionName) const;
 | 
        
           |  |  | 78 | 	Utils::WString extractGameName(const Utils::WString &dir, Utils::WString *extra = nullptr) const;
 | 
        
           |  |  | 79 | 	Utils::WString gameRunExe(const Utils::WString &dir) const;
 | 
        
           |  |  | 80 | 	Utils::WString gameName(const Utils::WString &gameExe) const;
 | 
        
           |  |  | 81 | 	Utils::WString gameBaseName(const Utils::WString &gameExe) const;
 | 
        
           |  |  | 82 | 	Utils::WString gameNameFromType(int type) const;
 | 
        
           |  |  | 83 | 	Utils::WString gameVersionFromType(int game, int gameVersion, const Utils::WString &fGameVersion) const;
 | 
        
           |  |  | 84 | 	Utils::WString gameDir(const Utils::WString &dir) const;
 | 
        
           |  |  | 85 | 	Utils::WString properDir(const Utils::WString &dir) const;
 | 
        
           |  |  | 86 | 	Utils::WString addonDir(const Utils::WString &dir) const;
 | 
        
           |  |  | 87 | 	bool isAddon(const Utils::WString &ext) const;
 | 
        
           |  |  | 88 | 	int getTextID(const Utils::WString &dir) const;
 | 
        
           |  |  | 89 | 	int getGameAddons(const Utils::WString &dir, Utils::WStringList &exe) const;
 | 
        
           |  |  | 90 | 	int gameFlags(int game);
 | 
        
           |  |  | 91 | 	int maxPatch(int game);
 | 
        
           |  |  | 92 | 	Utils::WString getModKey(int game) const;
 | 
        
           |  |  | 93 | 	void getDirectoryData(GameDirectory *gameDir) const;
 | 
        
           | 1 | cycrow | 94 |   | 
        
           | 197 | cycrow | 95 | 	int convertGameType(int gametype, int *version);
 | 
        
           | 1 | cycrow | 96 |   | 
        
           | 197 | cycrow | 97 | 	int numGames() { return m_lExe.size(); }
 | 
        
           |  |  | 98 | 	SGameExe *game(int game) const;
 | 
        
           | 127 | cycrow | 99 | 	unsigned int gameCount() const;
 | 
        
           | 1 | cycrow | 100 |   | 
        
           |  |  | 101 | private:
 | 
        
           | 197 | cycrow | 102 | 	int _findExe(const Utils::WString &exe) const;
 | 
        
           |  |  | 103 | 	int _findVersion(int exe, int size, Utils::WString *fVersion) const;
 | 
        
           | 57 | cycrow | 104 |   | 
        
           | 197 | cycrow | 105 | 	void _setExeName(Utils::WString *sName, int *iName, const Utils::WString &n);
 | 
        
           |  |  | 106 | 	Utils::WString _textFileName(const Utils::WString &sGameDir) const;
 | 
        
           |  |  | 107 | 	Utils::WString _readTextFile(const Utils::WString &sGameDir) const;
 | 
        
           |  |  | 108 | 	Utils::WString _extractTextData(const Utils::WString &sData, long iPage, long iID, int iGameID) const;
 | 
        
           | 1 | cycrow | 109 | };
 | 
        
           |  |  | 110 |   | 
        
           |  |  | 111 |   | 
        
           |  |  | 112 | #endif //__GAME_EXE_H__
 |