| Line 54... |
Line 54... |
| 54 |
break;
|
54 |
break;
|
| 55 |
|
55 |
|
| 56 |
CCatFile cat;
|
56 |
CCatFile cat;
|
| 57 |
if ( cat.Open(file + ".cat", m_sAddon, CATREAD_JUSTCONTENTS, false) == CATERR_NONE )
|
57 |
if ( cat.Open(file + ".cat", m_sAddon, CATREAD_JUSTCONTENTS, false) == CATERR_NONE )
|
| 58 |
{
|
58 |
{
|
| 59 |
for ( CListNode<SInCatFile> *c = cat.GetFiles()->Front(); c; c = c->next() )
|
59 |
for ( CListNode<SInCatFile> *c = cat.GetFiles()->Front(); c; c = c->next() ) {
|
| 60 |
{
|
- |
|
| 61 |
(*m_pMap)[CFileIO(c->Data()->sFile).GetFullFilename().ToLower().c_str()] = CyString(file + ".cat").c_str();
|
60 |
this->_addModFile(CFileIO(c->Data()->sFile).GetFullFilename().ToString(), CyString(file + ".cat").ToString(), m_pMap);
|
| 62 |
m_bLoaded = true;
|
61 |
m_bLoaded = true;
|
| 63 |
}
|
62 |
}
|
| 64 |
}
|
63 |
}
|
| 65 |
++number;
|
64 |
++number;
|
| 66 |
}
|
65 |
}
|
| 67 |
|
66 |
|
| 68 |
// now add all the extracted data
|
67 |
// add all the files from the mod
|
| 69 |
|
- |
|
| 70 |
if ( !mod.empty() )
|
68 |
if ( !mod.empty() )
|
| 71 |
this->addMod(mod);
|
69 |
this->addMod(mod);
|
| 72 |
|
70 |
|
| - |
|
71 |
// now add all the extracted data
|
| - |
|
72 |
this->_addDir(m_sDir, "");
|
| - |
|
73 |
|
| 73 |
return m_bLoaded;
|
74 |
return m_bLoaded;
|
| - |
|
75 |
}
|
| - |
|
76 |
|
| - |
|
77 |
|
| - |
|
78 |
void CVirtualFileSystem::_addDir(const Utils::String &sStart, const Utils::String &sDir)
|
| - |
|
79 |
{
|
| - |
|
80 |
CDirIO Dir(sStart + "/" + sDir);
|
| - |
|
81 |
CyStringList *list = Dir.DirList();
|
| - |
|
82 |
if ( list ) {
|
| - |
|
83 |
for ( SStringList *strNode = list->Head(); strNode; strNode = strNode->next ) {
|
| - |
|
84 |
if ( CDirIO(Dir.Dir(strNode->str)).IsDir() ) {
|
| - |
|
85 |
_addDir(sStart, sDir + "/" + strNode->str.ToString());
|
| - |
|
86 |
}
|
| - |
|
87 |
else if ( CFileIO(strNode->str).CheckFileExtension("cat") ) continue;
|
| - |
|
88 |
else if ( CFileIO(strNode->str).CheckFileExtension("dat") ) continue;
|
| - |
|
89 |
else {
|
| - |
|
90 |
this->_addFile(Dir.File(strNode->str).ToString(), Dir.File(strNode->str).ToString(), m_pMap);
|
| - |
|
91 |
}
|
| - |
|
92 |
}
|
| - |
|
93 |
}
|
| - |
|
94 |
}
|
| - |
|
95 |
|
| - |
|
96 |
void CVirtualFileSystem::_addFile(const Utils::String &sFile, const Utils::String &sDest, FileList *pList)
|
| - |
|
97 |
{
|
| - |
|
98 |
(*pList)[sFile.findReplace("\\", "/").findReplace("//", "/").lower()] = sDest.findReplace("//", "/");
|
| - |
|
99 |
}
|
| - |
|
100 |
void CVirtualFileSystem::_addModFile(const Utils::String &sFile, const Utils::String &sMod, FileList *pList)
|
| - |
|
101 |
{
|
| - |
|
102 |
this->_addFile(sFile, sMod + "::" + sFile, pList);
|
| 74 |
}
|
103 |
}
|
| 75 |
|
104 |
|
| 76 |
bool CVirtualFileSystem::loadMod(const Utils::String &mod)
|
105 |
bool CVirtualFileSystem::loadMod(const Utils::String &mod)
|
| 77 |
{
|
106 |
{
|
| 78 |
bool loaded = false;
|
107 |
bool loaded = false;
|
| 79 |
|
108 |
|
| 80 |
if ( !m_pModMap ) m_pModMap = new FileList;
|
109 |
if ( !m_pModMap ) m_pModMap = new FileList;
|
| 81 |
|
110 |
|
| 82 |
CCatFile cat;
|
111 |
CCatFile cat;
|
| 83 |
if ( CCatFile::Opened(cat.Open(mod, m_sAddon, CATREAD_JUSTCONTENTS, false), false) )
|
112 |
if ( CCatFile::Opened(cat.Open(mod, m_sAddon, CATREAD_JUSTCONTENTS, false), false) )
|
| 84 |
{
|
113 |
{
|
| 85 |
for ( CListNode<SInCatFile> *c = cat.GetFiles()->Front(); c; c = c->next() )
|
114 |
for ( CListNode<SInCatFile> *c = cat.GetFiles()->Front(); c; c = c->next() ) {
|
| 86 |
{
|
- |
|
| 87 |
(*m_pModMap)[CFileIO(c->Data()->sFile).GetFullFilename().ToLower().c_str()] = mod.c_str();
|
115 |
this->_addModFile(CFileIO(c->Data()->sFile).GetFullFilename().ToString(), mod, m_pModMap);
|
| 88 |
loaded = true;
|
116 |
loaded = true;
|
| 89 |
}
|
117 |
}
|
| 90 |
}
|
118 |
}
|
| 91 |
|
119 |
|
| 92 |
return loaded;
|
120 |
return loaded;
|
| 93 |
}
|
121 |
}
|
| 94 |
|
122 |
|
| 95 |
bool CVirtualFileSystem::addMod(const Utils::String &mod)
|
123 |
bool CVirtualFileSystem::addMod(const Utils::String &mod)
|
| 96 |
{
|
124 |
{
|
| Line 101... |
Line 129... |
| 101 |
CCatFile cat;
|
129 |
CCatFile cat;
|
| 102 |
if ( CCatFile::Opened(cat.Open(mod, m_sAddon, CATREAD_JUSTCONTENTS, false), false) )
|
130 |
if ( CCatFile::Opened(cat.Open(mod, m_sAddon, CATREAD_JUSTCONTENTS, false), false) )
|
| 103 |
{
|
131 |
{
|
| 104 |
for ( CListNode<SInCatFile> *c = cat.GetFiles()->Front(); c; c = c->next() )
|
132 |
for ( CListNode<SInCatFile> *c = cat.GetFiles()->Front(); c; c = c->next() )
|
| 105 |
{
|
133 |
{
|
| 106 |
(*m_pMap)[CFileIO(c->Data()->sFile).GetFullFilename().ToLower().c_str()] = mod.c_str();
|
134 |
this->_addModFile(CFileIO(c->Data()->sFile).GetFullFilename().ToString(), mod, m_pMap);
|
| 107 |
loaded = true;
|
135 |
loaded = true;
|
| 108 |
}
|
136 |
}
|
| 109 |
}
|
137 |
}
|
| 110 |
|
138 |
|
| 111 |
return loaded;
|
139 |
return loaded;
|
| Line 119... |
Line 147... |
| 119 |
if ( m_pModTexts ) {
|
147 |
if ( m_pModTexts ) {
|
| 120 |
if ( m_pModTexts->exists(iLang, iPage, iID) ) return m_pModTexts->exists(iLang, iPage, iID);
|
148 |
if ( m_pModTexts->exists(iLang, iPage, iID) ) return m_pModTexts->exists(iLang, iPage, iID);
|
| 121 |
}
|
149 |
}
|
| 122 |
|
150 |
|
| 123 |
return false;
|
151 |
return false;
|
| 124 |
}
|
152 |
}
|
| 125 |
|
153 |
|
| 126 |
Utils::String CVirtualFileSystem::findText(int iLang, int iPage, int iID) const
|
154 |
Utils::String CVirtualFileSystem::findText(int iLang, int iPage, int iID) const
|
| 127 |
{
|
155 |
{
|
| 128 |
if ( m_pTexts ) {
|
156 |
if ( m_pTexts ) {
|
| 129 |
if ( m_pTexts->exists(iLang, iPage, iID) ) return m_pTexts->get(iLang, iPage, iID);
|
157 |
if ( m_pTexts->exists(iLang, iPage, iID) ) return m_pTexts->get(iLang, iPage, iID);
|
| 130 |
}
|
158 |
}
|
| 131 |
if ( m_pModTexts ) {
|
159 |
if ( m_pModTexts ) {
|
| 132 |
if ( m_pModTexts->exists(iLang, iPage, iID) ) return m_pModTexts->get(iLang, iPage, iID);
|
160 |
if ( m_pModTexts->exists(iLang, iPage, iID) ) return m_pModTexts->get(iLang, iPage, iID);
|
| 133 |
}
|
161 |
}
|
| 134 |
|
162 |
|
| 135 |
return Utils::String("ReadText") + (long)iPage + "-" + (long)iID;
|
163 |
return Utils::String("ReadText") + (long)iPage + "-" + (long)iID;
|
| 136 |
}
|
164 |
}
|
| - |
|
165 |
|
| - |
|
166 |
bool CVirtualFileSystem::isFileAvailable(const Utils::String &file)
|
| - |
|
167 |
{
|
| - |
|
168 |
return !this->_findFile(file).empty();
|
| - |
|
169 |
}
|
| - |
|
170 |
|
| 137 |
Utils::String CVirtualFileSystem::findFile(const Utils::String &file)
|
171 |
Utils::String CVirtualFileSystem::_findFile(const Utils::String &file)
|
| 138 |
{
|
172 |
{
|
| - |
|
173 |
Utils::String toFile = file.findReplace("\\", "/").lower();
|
| - |
|
174 |
|
| 139 |
if ( m_pModMap && !m_pModMap->empty() ) {
|
175 |
if ( m_pModMap && !m_pModMap->empty() ) {
|
| 140 |
if ( !m_sAddon.empty() ) {
|
176 |
if ( !m_sAddon.empty() ) {
|
| 141 |
FileListItr aitr = m_pModMap->find(CFileIO(m_sAddon + "/" + file).GetFullFilename().ToLower().c_str());
|
177 |
FileListItr aitr = m_pModMap->find(CFileIO(m_sAddon + "/" + toFile).GetFullFilename().ToLower().c_str());
|
| 142 |
if ( aitr == m_pModMap->end() ) aitr = m_pModMap->find(CFileIO(_convertExtension(m_sAddon + "/" + file)).GetFullFilename().ToLower().c_str());
|
178 |
if ( aitr == m_pModMap->end() ) aitr = m_pModMap->find(CFileIO(_convertExtension(m_sAddon + "/" + toFile)).GetFullFilename().ToLower().c_str());
|
| 143 |
if ( aitr != m_pModMap->end() ) return aitr->second;
|
179 |
if ( aitr != m_pModMap->end() ) return aitr->second;
|
| 144 |
}
|
180 |
}
|
| 145 |
FileListItr itr = m_pModMap->find(CFileIO(file).GetFullFilename().ToLower().c_str());
|
181 |
FileListItr itr = m_pModMap->find(CFileIO(toFile).GetFullFilename().ToLower().c_str());
|
| 146 |
if ( itr == m_pModMap->end() ) itr = m_pModMap->find(CFileIO(_convertExtension(file)).GetFullFilename().ToLower().c_str());
|
182 |
if ( itr == m_pModMap->end() ) itr = m_pModMap->find(CFileIO(_convertExtension(toFile)).GetFullFilename().ToLower().c_str());
|
| 147 |
if ( itr != m_pModMap->end() ) return itr->second;
|
183 |
if ( itr != m_pModMap->end() ) return itr->second;
|
| 148 |
}
|
184 |
}
|
| 149 |
else if ( m_pMap && !m_pMap->empty() ) {
|
185 |
else if ( m_pMap && !m_pMap->empty() ) {
|
| 150 |
if ( !m_sAddon.empty() ) {
|
186 |
if ( !m_sAddon.empty() ) {
|
| 151 |
FileListItr aitr = m_pMap->find(CFileIO(m_sAddon + "/" + file).GetFullFilename().ToLower().c_str());
|
187 |
FileListItr aitr = m_pMap->find(CFileIO(m_sAddon + "/" + toFile).GetFullFilename().ToLower().c_str());
|
| 152 |
if ( aitr == m_pMap->end() ) aitr = m_pMap->find(CFileIO(_convertExtension(m_sAddon + "/" + file)).GetFullFilename().ToLower().c_str());
|
188 |
if ( aitr == m_pMap->end() ) aitr = m_pMap->find(CFileIO(_convertExtension(m_sAddon + "/" + file)).GetFullFilename().ToLower().c_str());
|
| 153 |
if ( aitr != m_pMap->end() ) return aitr->second;
|
189 |
if ( aitr != m_pMap->end() ) return aitr->second;
|
| 154 |
}
|
190 |
}
|
| 155 |
FileListItr itr = m_pMap->find(CFileIO(file).GetFullFilename().ToLower().c_str());
|
191 |
FileListItr itr = m_pMap->find(CFileIO(file).GetFullFilename().ToLower().c_str());
|
| 156 |
if ( itr == m_pMap->end() ) itr = m_pMap->find(CFileIO(_convertExtension(file)).GetFullFilename().ToLower().c_str());
|
192 |
if ( itr == m_pMap->end() ) itr = m_pMap->find(CFileIO(_convertExtension(file)).GetFullFilename().ToLower().c_str());
|
| Line 159... |
Line 195... |
| 159 |
return "";
|
195 |
return "";
|
| 160 |
}
|
196 |
}
|
| 161 |
|
197 |
|
| 162 |
bool CVirtualFileSystem::ExtractGameFile(const Utils::String &file, const Utils::String &to)
|
198 |
bool CVirtualFileSystem::ExtractGameFile(const Utils::String &file, const Utils::String &to)
|
| 163 |
{
|
199 |
{
|
| 164 |
Utils::String sIn = findFile(file);
|
200 |
Utils::String sIn = _findFile(file);
|
| - |
|
201 |
Utils::String sFile = file;
|
| - |
|
202 |
|
| 165 |
if ( sIn.empty() ) return false;
|
203 |
if ( sIn.empty() ) return false;
|
| - |
|
204 |
|
| - |
|
205 |
if ( sIn.isin("::") ) {
|
| - |
|
206 |
sFile = sIn.token("::", 2);
|
| - |
|
207 |
sIn = sIn.token("::", 1);
|
| - |
|
208 |
}
|
| 166 |
|
209 |
|
| 167 |
CCatFile catFile;
|
210 |
CCatFile catFile;
|
| 168 |
if ( catFile.Open(sIn, m_sAddon, CATREAD_CATDECRYPT, false) == CATERR_NONE )
|
211 |
if ( catFile.Open(sIn, m_sAddon, CATREAD_CATDECRYPT, false) == CATERR_NONE )
|
| 169 |
{
|
212 |
{
|
| 170 |
// check for the file
|
213 |
// check for the file
|