aboutsummaryrefslogtreecommitdiff
path: root/src/tools/map_extractor
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
committerariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
commit85a7d5ce9ac68b30da2277cc91d4b70358f1880d (patch)
treedf3d2084ee2e35008903c03178039b9c986e2d08 /src/tools/map_extractor
parent052fc24315ace866ea1cf610e85df119b68100c9 (diff)
Core: ported headers cleanup from master branch
Diffstat (limited to 'src/tools/map_extractor')
-rw-r--r--src/tools/map_extractor/CMakeLists.txt4
-rw-r--r--src/tools/map_extractor/System.cpp58
-rw-r--r--src/tools/map_extractor/dbcfile.cpp2
-rw-r--r--src/tools/map_extractor/dbcfile.h6
-rw-r--r--src/tools/map_extractor/mpq_libmpq.cpp4
-rw-r--r--src/tools/map_extractor/mpq_libmpq04.h12
6 files changed, 44 insertions, 42 deletions
diff --git a/src/tools/map_extractor/CMakeLists.txt b/src/tools/map_extractor/CMakeLists.txt
index 52da3adf127..87ad3ff5089 100644
--- a/src/tools/map_extractor/CMakeLists.txt
+++ b/src/tools/map_extractor/CMakeLists.txt
@@ -13,6 +13,10 @@ CollectSourceFiles(
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE_SOURCES)
+if (WIN32)
+ list(APPEND PRIVATE_SOURCES ${sources_windows})
+endif()
+
add_executable(mapextractor
${PRIVATE_SOURCES}
)
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index c681e669ebe..1fbf831e20f 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -16,8 +16,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define _CRT_SECURE_NO_DEPRECATE
-
#include <stdio.h>
#include <deque>
#include <set>
@@ -25,6 +23,7 @@
#include <fstream>
#include "dbcfile.h"
+#include "Banner.h"
#include "mpq_libmpq04.h"
#include "StringFormat.h"
@@ -84,7 +83,7 @@ const char *CONF_mpq_list[]={
"patch-5.MPQ",
};
-static const char* const langs[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" };
+static char const* const langs[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" };
#define LANG_COUNT 12
void CreateDir(boost::filesystem::path const& path)
@@ -122,7 +121,7 @@ void HandleArgs(int argc, char * arg[])
if(arg[c][0] != '-')
Usage(arg[0]);
- switch(arg[c][1])
+ switch (arg[c][1])
{
case 'i':
if (c + 1 < argc && strlen(arg[c + 1]) < MAX_PATH_LENGTH) // all ok
@@ -143,16 +142,16 @@ void HandleArgs(int argc, char * arg[])
Usage(arg[0]);
break;
case 'f':
- if(c + 1 < argc) // all ok
- CONF_allow_float_to_int=atoi(arg[(c++) + 1])!=0;
+ if (c + 1 < argc) // all ok
+ CONF_allow_float_to_int = atoi(arg[(c++) + 1]) != 0;
else
Usage(arg[0]);
break;
case 'e':
- if(c + 1 < argc) // all ok
+ if (c + 1 < argc) // all ok
{
- CONF_extract=atoi(arg[(c++) + 1]);
- if(!(CONF_extract > 0 && CONF_extract < 8))
+ CONF_extract = atoi(arg[(c++) + 1]);
+ if (!(CONF_extract > 0 && CONF_extract < 8))
Usage(arg[0]);
}
else
@@ -216,7 +215,7 @@ uint32 ReadMapDBC()
{
map_ids[x].id = dbc.getRecord(x).getUInt(0);
- const char* map_name = dbc.getRecord(x).getString(1);
+ char const* map_name = dbc.getRecord(x).getString(1);
size_t max_map_name_length = sizeof(map_ids[x].name);
if (strlen(map_name) >= max_map_name_length)
{
@@ -567,12 +566,12 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
float diff = maxHeight - minHeight;
if (diff < CONF_float_to_int8_limit) // As uint8 (max accuracy = CONF_float_to_int8_limit/256)
{
- heightHeader.flags|=MAP_HEIGHT_AS_INT8;
+ heightHeader.flags |= MAP_HEIGHT_AS_INT8;
step = selectUInt8StepStore(diff);
}
- else if (diff<CONF_float_to_int16_limit) // As uint16 (max accuracy = CONF_float_to_int16_limit/65536)
+ else if (diff < CONF_float_to_int16_limit) // As uint16 (max accuracy = CONF_float_to_int16_limit/65536)
{
- heightHeader.flags|=MAP_HEIGHT_AS_INT16;
+ heightHeader.flags |= MAP_HEIGHT_AS_INT16;
step = selectUInt16StepStore(diff);
}
}
@@ -852,30 +851,30 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
return false;
}
- outFile.write(reinterpret_cast<const char*>(&map), sizeof(map));
+ outFile.write(reinterpret_cast<char const*>(&map), sizeof(map));
// Store area data
- outFile.write(reinterpret_cast<const char*>(&areaHeader), sizeof(areaHeader));
+ outFile.write(reinterpret_cast<char const*>(&areaHeader), sizeof(areaHeader));
if (!(areaHeader.flags & MAP_AREA_NO_AREA))
- outFile.write(reinterpret_cast<const char*>(area_ids), sizeof(area_ids));
+ outFile.write(reinterpret_cast<char const*>(area_ids), sizeof(area_ids));
// Store height data
- outFile.write(reinterpret_cast<const char*>(&heightHeader), sizeof(heightHeader));
+ outFile.write(reinterpret_cast<char const*>(&heightHeader), sizeof(heightHeader));
if (!(heightHeader.flags & MAP_HEIGHT_NO_HEIGHT))
{
if (heightHeader.flags & MAP_HEIGHT_AS_INT16)
{
- outFile.write(reinterpret_cast<const char*>(uint16_V9), sizeof(uint16_V9));
- outFile.write(reinterpret_cast<const char*>(uint16_V8), sizeof(uint16_V8));
+ outFile.write(reinterpret_cast<char const*>(uint16_V9), sizeof(uint16_V9));
+ outFile.write(reinterpret_cast<char const*>(uint16_V8), sizeof(uint16_V8));
}
else if (heightHeader.flags & MAP_HEIGHT_AS_INT8)
{
- outFile.write(reinterpret_cast<const char*>(uint8_V9), sizeof(uint8_V9));
- outFile.write(reinterpret_cast<const char*>(uint8_V8), sizeof(uint8_V8));
+ outFile.write(reinterpret_cast<char const*>(uint8_V9), sizeof(uint8_V9));
+ outFile.write(reinterpret_cast<char const*>(uint8_V8), sizeof(uint8_V8));
}
else
{
- outFile.write(reinterpret_cast<const char*>(V9), sizeof(V9));
- outFile.write(reinterpret_cast<const char*>(V8), sizeof(V8));
+ outFile.write(reinterpret_cast<char const*>(V9), sizeof(V9));
+ outFile.write(reinterpret_cast<char const*>(V8), sizeof(V8));
}
}
@@ -888,24 +887,24 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
// Store liquid data if need
if (map.liquidMapOffset)
{
- outFile.write(reinterpret_cast<const char*>(&liquidHeader), sizeof(liquidHeader));
+ outFile.write(reinterpret_cast<char const*>(&liquidHeader), sizeof(liquidHeader));
if (!(liquidHeader.flags&MAP_LIQUID_NO_TYPE))
{
- outFile.write(reinterpret_cast<const char*>(liquid_entry), sizeof(liquid_entry));
- outFile.write(reinterpret_cast<const char*>(liquid_flags), sizeof(liquid_flags));
+ outFile.write(reinterpret_cast<char const*>(liquid_entry), sizeof(liquid_entry));
+ outFile.write(reinterpret_cast<char const*>(liquid_flags), sizeof(liquid_flags));
}
if (!(liquidHeader.flags&MAP_LIQUID_NO_HEIGHT))
{
for (int y = 0; y < liquidHeader.height; y++)
- outFile.write(reinterpret_cast<const char*>(&liquid_height[y + liquidHeader.offsetY][liquidHeader.offsetX]), sizeof(float) * liquidHeader.width);
+ outFile.write(reinterpret_cast<char const*>(&liquid_height[y + liquidHeader.offsetY][liquidHeader.offsetX]), sizeof(float) * liquidHeader.width);
}
}
// store hole data
if (hasHoles)
- outFile.write(reinterpret_cast<const char*>(holes), map.holesSize);
+ outFile.write(reinterpret_cast<char const*>(holes), map.holesSize);
outFile.close();
return true;
@@ -1114,8 +1113,7 @@ inline void CloseMPQFiles()
int main(int argc, char * arg[])
{
- printf("Map & DBC Extractor\n");
- printf("===================\n\n");
+ Trinity::Banner::Show("Map & DBC Extractor", [](char const* text) { printf("%s\n", text); }, nullptr);
HandleArgs(argc, arg);
diff --git a/src/tools/map_extractor/dbcfile.cpp b/src/tools/map_extractor/dbcfile.cpp
index b8a504877a3..25ded3e6c60 100644
--- a/src/tools/map_extractor/dbcfile.cpp
+++ b/src/tools/map_extractor/dbcfile.cpp
@@ -22,7 +22,7 @@
#include "mpq_libmpq04.h"
DBCFile::DBCFile(const std::string& filename):
- filename(filename), recordSize(0), recordCount(0), fieldCount(0), stringSize(0), data(NULL), stringTable(NULL)
+ filename(filename), recordSize(0), recordCount(0), fieldCount(0), stringSize(0), data(nullptr), stringTable(nullptr)
{
}
diff --git a/src/tools/map_extractor/dbcfile.h b/src/tools/map_extractor/dbcfile.h
index f490544d9d6..5130469b5f3 100644
--- a/src/tools/map_extractor/dbcfile.h
+++ b/src/tools/map_extractor/dbcfile.h
@@ -99,15 +99,15 @@ public:
}
/// Return address of current instance
Record const & operator*() const { return record; }
- const Record* operator->() const {
+ 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;
}
diff --git a/src/tools/map_extractor/mpq_libmpq.cpp b/src/tools/map_extractor/mpq_libmpq.cpp
index 5891a1be49b..120fa9731b7 100644
--- a/src/tools/map_extractor/mpq_libmpq.cpp
+++ b/src/tools/map_extractor/mpq_libmpq.cpp
@@ -22,7 +22,7 @@
ArchiveSet gOpenArchives;
-MPQArchive::MPQArchive(const char* filename)
+MPQArchive::MPQArchive(char const* filename)
{
int result = libmpq__archive_open(&mpq_a, filename, -1);
printf("Opening %s\n", filename);
@@ -58,7 +58,7 @@ void MPQArchive::close()
libmpq__archive_close(mpq_a);
}
-MPQFile::MPQFile(const char* filename):
+MPQFile::MPQFile(char const* filename):
eof(false),
buffer(0),
pointer(0),
diff --git a/src/tools/map_extractor/mpq_libmpq04.h b/src/tools/map_extractor/mpq_libmpq04.h
index b03ae7b7639..589ce0b31d1 100644
--- a/src/tools/map_extractor/mpq_libmpq04.h
+++ b/src/tools/map_extractor/mpq_libmpq04.h
@@ -33,7 +33,7 @@ class MPQArchive
public:
mpq_archive_s *mpq_a;
- MPQArchive(const char* filename);
+ MPQArchive(char const* filename);
~MPQArchive() { close(); }
void close();
@@ -53,13 +53,13 @@ public:
token = strtok( buffer, seps );
uint32 counter = 0;
- while ((token != NULL) && (counter < size)) {
+ while ((token != nullptr) && (counter < size)) {
//cout << token << endl;
token[strlen(token) - 1] = 0;
std::string s = token;
filelist.push_back(s);
counter += strlen(token) + 2;
- token = strtok(NULL, seps);
+ token = strtok(nullptr, seps);
}
delete[] buffer;
@@ -75,11 +75,11 @@ class MPQFile
libmpq__off_t pointer,size;
// disable copying
- MPQFile(const MPQFile& /*f*/) {}
- void operator=(const MPQFile& /*f*/) {}
+ MPQFile(MPQFile const& /*f*/) = delete;
+ void operator=(MPQFile const& /*f*/) = delete;
public:
- MPQFile(const char* filename); // filenames are not case sensitive
+ MPQFile(char const* filename); // filenames are not case sensitive
~MPQFile() { close(); }
size_t read(void* dest, size_t bytes);
size_t getSize() { return size; }