Kill off the issues with the map/dbcextractors - and a thanks to imbecile@lavabit for the comment about loadlib.h
Just now the intent was to get it sorted out, as we might merge the tools into one "datatool" for all of this stuff. --HG-- branch : trunk rename : src/tools/map_extractor/loadlib/adt.cpp => src/tools/map_extractor/adt.cpp rename : src/tools/map_extractor/loadlib/adt.h => src/tools/map_extractor/adt.h rename : src/tools/map_extractor/loadlib/loadlib.cpp => src/tools/map_extractor/loadlib.cpp rename : src/tools/map_extractor/loadlib/wdt.cpp => src/tools/map_extractor/wdt.cpp rename : src/tools/map_extractor/loadlib/wdt.h => src/tools/map_extractor/wdt.h
This commit is contained in:
1 parent
30a59b7b69
commit
7bf807aee4
8 files changed
+19
-49
No files matched your search
@@ -0,0 +1,65 @@
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
|
||||
#include "loadlib.h"
|
||||
#include "mpq_libmpq04.h"
|
||||
#include <cstdio>
|
||||
|
||||
class MPQFile;
|
||||
|
||||
FileLoader::FileLoader()
|
||||
{
|
||||
data = 0;
|
||||
data_size = 0;
|
||||
version = 0;
|
||||
}
|
||||
|
||||
FileLoader::~FileLoader()
|
||||
{
|
||||
free();
|
||||
}
|
||||
|
||||
bool FileLoader::loadFile(char *filename, bool log)
|
||||
{
|
||||
free();
|
||||
MPQFile mf(filename);
|
||||
if(mf.isEof())
|
||||
{
|
||||
if (log)
|
||||
printf("No such file %s\n", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
data_size = mf.getSize();
|
||||
|
||||
data = new uint8 [data_size];
|
||||
if (data)
|
||||
{
|
||||
mf.read(data, data_size);
|
||||
mf.close();
|
||||
if (prepareLoadedData())
|
||||
return true;
|
||||
}
|
||||
printf("Error loading %s", filename);
|
||||
mf.close();
|
||||
free();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileLoader::prepareLoadedData()
|
||||
{
|
||||
// Check version
|
||||
version = (file_MVER *) data;
|
||||
if (version->fcc != 'MVER')
|
||||
return false;
|
||||
if (version->ver != FILE_FORMAT_VERSION)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileLoader::free()
|
||||
{
|
||||
if (data) delete[] data;
|
||||
data = 0;
|
||||
data_size = 0;
|
||||
version = 0;
|
||||
}
|
||||
Reference in new issue
Block a user