fix(Tools/vmaps): Fix extractor crash when some .mpq files does not exist (#11976)
* . * Clion event trace * .
This commit is contained in:
committed by
GitHub
parent
34b714639c
commit
a7c4c04e5a
@@ -18,6 +18,7 @@
|
|||||||
#include "mpq_libmpq04.h"
|
#include "mpq_libmpq04.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
ArchiveSet gOpenArchives;
|
ArchiveSet gOpenArchives;
|
||||||
|
|
||||||
@@ -53,6 +54,11 @@ MPQArchive::MPQArchive(const char* filename)
|
|||||||
gOpenArchives.push_front(this);
|
gOpenArchives.push_front(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MPQArchive::isOpened() const
|
||||||
|
{
|
||||||
|
return std::find(gOpenArchives.begin(), gOpenArchives.end(), this) != gOpenArchives.end();
|
||||||
|
}
|
||||||
|
|
||||||
void MPQArchive::close()
|
void MPQArchive::close()
|
||||||
{
|
{
|
||||||
//gOpenArchives.erase(erase(&mpq_a);
|
//gOpenArchives.erase(erase(&mpq_a);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
mpq_archive_s* mpq_a;
|
mpq_archive_s* mpq_a;
|
||||||
|
|
||||||
MPQArchive(const char* filename);
|
MPQArchive(const char* filename);
|
||||||
void close();
|
~MPQArchive() { if (isOpened()) close(); }
|
||||||
|
|
||||||
void GetFileListTo(vector<string>& filelist)
|
void GetFileListTo(vector<string>& filelist)
|
||||||
{
|
{
|
||||||
@@ -65,6 +65,10 @@ public:
|
|||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void close();
|
||||||
|
bool isOpened() const;
|
||||||
};
|
};
|
||||||
typedef std::deque<MPQArchive*> ArchiveSet;
|
typedef std::deque<MPQArchive*> ArchiveSet;
|
||||||
|
|
||||||
@@ -95,13 +99,8 @@ public:
|
|||||||
|
|
||||||
inline void flipcc(char* fcc)
|
inline void flipcc(char* fcc)
|
||||||
{
|
{
|
||||||
char t;
|
std::swap(fcc[0], fcc[3]);
|
||||||
t = fcc[0];
|
std::swap(fcc[1], fcc[2]);
|
||||||
fcc[0] = fcc[3];
|
|
||||||
fcc[3] = t;
|
|
||||||
t = fcc[1];
|
|
||||||
fcc[1] = fcc[2];
|
|
||||||
fcc[2] = t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user