fix(Tools/vmaps): Fix extractor crash when some .mpq files does not exist (#11976)

* .

* Clion event trace

* .
This commit is contained in:
IntelligentQuantum
2022-10-02 00:13:06 +03:30
committed by GitHub
parent 34b714639c
commit a7c4c04e5a
2 changed files with 13 additions and 8 deletions

View File

@@ -18,6 +18,7 @@
#include "mpq_libmpq04.h"
#include <cstdio>
#include <deque>
#include <algorithm>
ArchiveSet gOpenArchives;
@@ -53,6 +54,11 @@ MPQArchive::MPQArchive(const char* filename)
gOpenArchives.push_front(this);
}
bool MPQArchive::isOpened() const
{
return std::find(gOpenArchives.begin(), gOpenArchives.end(), this) != gOpenArchives.end();
}
void MPQArchive::close()
{
//gOpenArchives.erase(erase(&mpq_a);

View File

@@ -34,7 +34,7 @@ public:
mpq_archive_s* mpq_a;
MPQArchive(const char* filename);
void close();
~MPQArchive() { if (isOpened()) close(); }
void GetFileListTo(vector<string>& filelist)
{
@@ -65,6 +65,10 @@ public:
delete[] buffer;
}
private:
void close();
bool isOpened() const;
};
typedef std::deque<MPQArchive*> ArchiveSet;
@@ -95,13 +99,8 @@ public:
inline void flipcc(char* fcc)
{
char t;
t = fcc[0];
fcc[0] = fcc[3];
fcc[3] = t;
t = fcc[1];
fcc[1] = fcc[2];
fcc[2] = t;
std::swap(fcc[0], fcc[3]);
std::swap(fcc[1], fcc[2]);
}
#endif