mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
Tools/VMAPs: Fix extractor crash when some .mpq files does not exist (#18130)
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "mpq_libmpq04.h"
|
||||
#include <deque>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
|
||||
ArchiveSet gOpenArchives;
|
||||
|
||||
@@ -52,6 +53,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);
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
mpq_archive_s *mpq_a;
|
||||
|
||||
MPQArchive(const char* filename);
|
||||
~MPQArchive() { close(); }
|
||||
~MPQArchive() { if (isOpened()) close(); }
|
||||
|
||||
void GetFileListTo(std::vector<std::string>& filelist) {
|
||||
uint32_t filenum;
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
|
||||
private:
|
||||
void close();
|
||||
bool isOpened() const;
|
||||
};
|
||||
typedef std::deque<MPQArchive*> ArchiveSet;
|
||||
|
||||
@@ -95,13 +96,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
|
||||
|
||||
Reference in New Issue
Block a user