aboutsummaryrefslogtreecommitdiff
path: root/src/tools/vmap4_extractor
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2013-05-28 17:37:10 +0200
committerShauren <shauren.trinity@gmail.com>2013-05-28 17:37:10 +0200
commit26a22dc3ab98538297f72b80dc12ed6e2295384f (patch)
tree3cdb5fa99cb2df6ebcb5f283120254afaa4898b1 /src/tools/vmap4_extractor
parent0938fdeeec47bca2304cd77be8169f61a0c23654 (diff)
Tools/Extractors: Fixed many false positive err=2 messages and fixed many compile warnings
Diffstat (limited to 'src/tools/vmap4_extractor')
-rw-r--r--src/tools/vmap4_extractor/adtfile.cpp2
-rw-r--r--src/tools/vmap4_extractor/dbcfile.h27
-rw-r--r--src/tools/vmap4_extractor/mpqfile.cpp11
-rw-r--r--src/tools/vmap4_extractor/mpqfile.h2
-rw-r--r--src/tools/vmap4_extractor/vmapexport.cpp79
5 files changed, 46 insertions, 75 deletions
diff --git a/src/tools/vmap4_extractor/adtfile.cpp b/src/tools/vmap4_extractor/adtfile.cpp
index a5193739440..652b162189b 100644
--- a/src/tools/vmap4_extractor/adtfile.cpp
+++ b/src/tools/vmap4_extractor/adtfile.cpp
@@ -76,7 +76,7 @@ char* GetExtension(char* FileName)
extern HANDLE WorldMpq;
-ADTFile::ADTFile(char* filename): ADT(WorldMpq, filename)
+ADTFile::ADTFile(char* filename) : ADT(WorldMpq, filename, false)
{
Adtfilename.append(filename);
}
diff --git a/src/tools/vmap4_extractor/dbcfile.h b/src/tools/vmap4_extractor/dbcfile.h
index 007ccb6cdcb..2c43cb1a808 100644
--- a/src/tools/vmap4_extractor/dbcfile.h
+++ b/src/tools/vmap4_extractor/dbcfile.h
@@ -56,22 +56,22 @@ class DBCFile
float getFloat(size_t field) const
{
assert(field < file._fieldCount);
- return *reinterpret_cast<float*>(offset+field*4);
+ return *reinterpret_cast<float*>(offset + field * 4);
}
unsigned int getUInt(size_t field) const
{
assert(field < file._fieldCount);
- return *reinterpret_cast<unsigned int*>(offset+field*4);
+ return *reinterpret_cast<unsigned int*>(offset + field * 4);
}
int getInt(size_t field) const
{
assert(field < file._fieldCount);
- return *reinterpret_cast<int*>(offset+field*4);
+ return *reinterpret_cast<int*>(offset + field * 4);
}
- const char *getString(size_t field) const
+ char const* getString(size_t field) const
{
assert(field < file._fieldCount);
size_t stringOffset = getUInt(field);
@@ -80,9 +80,9 @@ class DBCFile
}
private:
- Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {}
- unsigned char *offset;
- DBCFile &file;
+ Record(DBCFile& file, unsigned char* offset): file(file), offset(offset) {}
+ DBCFile& file;
+ unsigned char* offset;
friend class DBCFile;
friend class DBCFile::Iterator;
@@ -92,29 +92,30 @@ class DBCFile
class Iterator
{
public:
- Iterator(DBCFile &file, unsigned char *offset) : record(file, offset) { }
+ Iterator(DBCFile &file, unsigned char* offset) : record(file, offset) { }
/// Advance (prefix only)
- Iterator & operator++()
+ Iterator& operator++()
{
record.offset += record.file._recordSize;
return *this;
}
/// Return address of current instance
- Record const & operator*() const { return record; }
- const Record* operator->() const { return &record; }
+ Record const& operator*() const { return record; }
+ Record const* operator->() const { return &record; }
/// Comparison
- bool operator==(const Iterator &b) const
+ bool operator==(Iterator const& b) const
{
return record.offset == b.record.offset;
}
- bool operator!=(const Iterator &b) const
+ bool operator!=(Iterator const& b) const
{
return record.offset != b.record.offset;
}
+
private:
Record record;
};
diff --git a/src/tools/vmap4_extractor/mpqfile.cpp b/src/tools/vmap4_extractor/mpqfile.cpp
index 9f019f99f38..4e690aabee3 100644
--- a/src/tools/vmap4_extractor/mpqfile.cpp
+++ b/src/tools/vmap4_extractor/mpqfile.cpp
@@ -3,7 +3,7 @@
#include <cstdio>
#include "StormLib.h"
-MPQFile::MPQFile(HANDLE mpq, const char* filename):
+MPQFile::MPQFile(HANDLE mpq, const char* filename, bool warnNoExist /*= true*/) :
eof(false),
buffer(0),
pointer(0),
@@ -12,7 +12,8 @@ MPQFile::MPQFile(HANDLE mpq, const char* filename):
HANDLE file;
if (!SFileOpenFileEx(mpq, filename, SFILE_OPEN_PATCHED_FILE, &file))
{
- fprintf(stderr, "Can't open %s, err=%u!\n", filename, GetLastError());
+ if (warnNoExist || GetLastError() != ERROR_FILE_NOT_FOUND)
+ fprintf(stderr, "Can't open %s, err=%u!\n", filename, GetLastError());
eof = true;
return;
}
@@ -22,7 +23,7 @@ MPQFile::MPQFile(HANDLE mpq, const char* filename):
if (hi)
{
- fprintf(stderr, "Can't open %s, size[hi] = %u!\n", filename, (uint32)hi);
+ fprintf(stderr, "Can't open %s, size[hi] = %u!\n", filename, uint32(hi));
SFileCloseFile(file);
eof = true;
return;
@@ -30,7 +31,7 @@ MPQFile::MPQFile(HANDLE mpq, const char* filename):
if (size <= 1)
{
- fprintf(stderr, "Can't open %s, size = %u!\n", filename, size);
+ fprintf(stderr, "Can't open %s, size = %u!\n", filename, uint32(size));
SFileCloseFile(file);
eof = true;
return;
@@ -40,7 +41,7 @@ MPQFile::MPQFile(HANDLE mpq, const char* filename):
buffer = new char[size];
if (!SFileReadFile(file, buffer, size, &read) || size != read)
{
- fprintf(stderr, "Can't read %s, size=%u read=%u!\n", filename, size, read);
+ fprintf(stderr, "Can't read %s, size=%u read=%u!\n", filename, uint32(size), uint32(read));
SFileCloseFile(file);
eof = true;
return;
diff --git a/src/tools/vmap4_extractor/mpqfile.h b/src/tools/vmap4_extractor/mpqfile.h
index dfd1b713c97..e7379c4f7a0 100644
--- a/src/tools/vmap4_extractor/mpqfile.h
+++ b/src/tools/vmap4_extractor/mpqfile.h
@@ -54,7 +54,7 @@ class MPQFile
void operator=(const MPQFile &f);
public:
- MPQFile(HANDLE mpq, const char* filename); // filenames are not case sensitive
+ MPQFile(HANDLE mpq, const char* filename, bool warnNoExist = true); // filenames are not case sensitive
~MPQFile() { close(); }
size_t read(void* dest, size_t bytes);
size_t getSize() { return size; }
diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp
index bcbd705f834..84390a5fc9a 100644
--- a/src/tools/vmap4_extractor/vmapexport.cpp
+++ b/src/tools/vmap4_extractor/vmapexport.cpp
@@ -77,8 +77,19 @@ uint32 const Builds[] = {13164, 13205, 13287, 13329, 13596, 13623, 13914, 14007,
#define LAST_DBC_IN_DATA_BUILD 13623 // after this build mpqs with dbc are back to locale folder
#define NEW_BASE_SET_BUILD 15211
-char* const Locales[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU"};
-TCHAR* const LocalesT[] =
+#define LOCALES_COUNT 12
+
+char const* Locales[LOCALES_COUNT] =
+{
+ "enGB", "enUS",
+ "deDE", "esES",
+ "frFR", "koKR",
+ "zhCN", "zhTW",
+ "enCN", "enTW",
+ "esMX", "ruRU"
+};
+
+TCHAR const* LocalesT[LOCALES_COUNT] =
{
_T("enGB"), _T("enUS"),
_T("deDE"), _T("esES"),
@@ -88,8 +99,6 @@ TCHAR* const LocalesT[] =
_T("esMX"), _T("ruRU"),
};
-#define LOCALES_COUNT 12
-
typedef struct
{
char name[64];
@@ -117,10 +126,14 @@ bool LoadLocaleMPQFile(int locale)
if (!SFileOpenArchive(buff, 0, MPQ_OPEN_READ_ONLY, &LocaleMpq))
{
if (GetLastError() != ERROR_PATH_NOT_FOUND)
+ {
+ _tprintf(_T("Loading %s locale MPQs\n"), LocalesT[locale]);
_tprintf(_T("Cannot open archive %s\n"), buff);
+ }
return false;
}
+ _tprintf(_T("Loading %s locale MPQs\n"), LocalesT[locale]);
char const* prefix = NULL;
for (int i = 0; Builds[i] && Builds[i] <= CONF_TargetBuild; ++i)
{
@@ -149,6 +162,7 @@ bool LoadLocaleMPQFile(int locale)
}
}
+ printf("\n");
return true;
}
@@ -156,6 +170,7 @@ void LoadCommonMPQFiles(uint32 build)
{
TCHAR filename[512];
_stprintf(filename, _T("%sworld.MPQ"), input_path);
+ _tprintf(_T("Loading common MPQ files\n"));
if (!SFileOpenArchive(filename, 0, MPQ_OPEN_READ_ONLY, &WorldMpq))
{
if (GetLastError() != ERROR_PATH_NOT_FOUND)
@@ -178,29 +193,7 @@ void LoadCommonMPQFiles(uint32 build)
_tprintf(_T("Not found %s\n"), filename);
}
else
- {
_tprintf(_T("Loaded %s\n"), filename);
-
- bool found = false;
- int count = 0;
- SFILE_FIND_DATA data;
- HANDLE find = SFileFindFirstFile(WorldMpq, "*.*", &data, NULL);
- if (find != NULL)
- {
- do
- {
- ++count;
- if (data.dwFileFlags & MPQ_FILE_PATCH_FILE)
- {
- found = true;
- break;
- }
- }
- while (SFileFindNextFile(find, &data));
- }
- SFileFindClose(find);
- printf("Scanned %d files, found patch = %d\n", count, found);
- }
}
char const* prefix = NULL;
@@ -232,32 +225,10 @@ void LoadCommonMPQFiles(uint32 build)
continue;
}
else
- {
_tprintf(_T("Loaded %s\n"), filename);
-
-
- bool found = false;
- int count = 0;
- SFILE_FIND_DATA data;
- HANDLE find = SFileFindFirstFile(WorldMpq, "*.*", &data, NULL);
- if (find != NULL)
- {
- do
- {
- ++count;
- if (data.dwFileFlags & MPQ_FILE_PATCH_FILE)
- {
- found = true;
- break;
- }
- }
- while (SFileFindNextFile(find, &data));
- }
- SFileFindClose(find);
- printf("Scanned %d files, found patch = %d\n", count, found);
- }
}
+ printf("\n");
}
@@ -537,7 +508,7 @@ bool processArgv(int argc, char ** argv, const char *versionString)
printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n");
printf(" -l : large size, ~500MB more vmap data. (might contain more details)\n");
printf(" -d <path>: Path to the vector data source folder.\n");
- printf(" -b : target build (default %u)", CONF_TargetBuild);
+ printf(" -b : target build (default %u)\n", CONF_TargetBuild);
printf(" -? : This message.\n");
}
@@ -581,7 +552,7 @@ int main(int argc, char ** argv)
}
}
- printf("Extract %s. Beginning work ....\n",versionString);
+ printf("Extract %s. Beginning work ....\n\n",versionString);
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Create the working directory
if (mkdir(szWorkDirWmo
@@ -593,8 +564,6 @@ int main(int argc, char ** argv)
LoadCommonMPQFiles(CONF_TargetBuild);
- int FirstLocale = -1;
-
for (int i = 0; i < LOCALES_COUNT; ++i)
{
//Open MPQs
@@ -605,7 +574,7 @@ int main(int argc, char ** argv)
continue;
}
- printf("Detected and using locale locale: %s\n", Locales[i]);
+ printf("Detected and using locale: %s\n", Locales[i]);
break;
}
@@ -640,7 +609,7 @@ int main(int argc, char ** argv)
ParsMapFiles();
delete [] map_ids;
//nError = ERROR_SUCCESS;
- // Extract models, listed in DameObjectDisplayInfo.dbc
+ // Extract models, listed in GameObjectDisplayInfo.dbc
ExtractGameobjectModels();
}