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