refactor(src/common): remove unused imports (#19506)

* refactor(src/common): remove unused imports

* fix: build

* chore: fix build

* chore: size_t -> std::size_t

* chore: fix fuckup from previous commit

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build with std::size_t

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build

* chore: fix build
This commit is contained in:
Francesco Borzì
2024-07-31 01:06:46 +02:00
committed by GitHub
parent 06a608d244
commit 02a05fbd4c
200 changed files with 522 additions and 581 deletions

View File

@@ -245,9 +245,9 @@ uint32 ReadBuild(int locale)
std::string text = std::string(m.getPointer(), m.getSize());
m.close();
size_t pos = text.find("version=\"");
size_t pos1 = pos + strlen("version=\"");
size_t pos2 = text.find("\"", pos1);
std::size_t pos = text.find("version=\"");
std::size_t pos1 = pos + strlen("version=\"");
std::size_t pos2 = text.find("\"", pos1);
if (pos == text.npos || pos2 == text.npos || pos1 >= pos2)
{
printf("Fatal error: Invalid %s file format!\n", filename.c_str());
@@ -277,7 +277,7 @@ uint32 ReadMapDBC()
exit(1);
}
size_t map_count = dbc.getRecordCount();
std::size_t map_count = dbc.getRecordCount();
map_ids.resize(map_count);
for (uint32 x = 0; x < map_count; ++x)
{
@@ -1094,12 +1094,12 @@ void ExtractCameraFiles(int locale, bool basicLocale)
// get camera file list from DBC
std::vector<std::string> camerafiles;
size_t cam_count = camdbc.getRecordCount();
std::size_t cam_count = camdbc.getRecordCount();
for (size_t i = 0; i < cam_count; ++i)
for (std::size_t i = 0; i < cam_count; ++i)
{
std::string camFile(camdbc.getRecord(i).getString(1));
size_t loc = camFile.find(".mdx");
std::size_t loc = camFile.find(".mdx");
if (loc != std::string::npos)
{
camFile.replace(loc, 4, ".m2");

View File

@@ -58,7 +58,7 @@ bool DBCFile::open()
data = new unsigned char[recordSize * recordCount + stringSize];
stringTable = data + recordSize * recordCount;
size_t data_size = recordSize * recordCount + stringSize;
std::size_t data_size = recordSize * recordCount + stringSize;
if (f.read(data, data_size) != data_size)
return false;
f.close();
@@ -69,18 +69,18 @@ DBCFile::~DBCFile()
delete [] data;
}
DBCFile::Record DBCFile::getRecord(size_t id)
DBCFile::Record DBCFile::getRecord(std::size_t id)
{
assert(data);
return Record(*this, data + id * recordSize);
}
size_t DBCFile::getMaxId()
std::size_t DBCFile::getMaxId()
{
assert(data);
size_t maxId = 0;
for (size_t i = 0; i < getRecordCount(); ++i)
std::size_t maxId = 0;
for (std::size_t i = 0; i < getRecordCount(); ++i)
{
if (maxId < getRecord(i).getUInt(0))
maxId = getRecord(i).getUInt(0);

View File

@@ -53,25 +53,25 @@ public:
class Record // cppcheck-suppress ctuOneDefinitionRuleViolation
{
public:
[[nodiscard]] float getFloat(size_t field) const
[[nodiscard]] float getFloat(std::size_t field) const
{
assert(field < file.fieldCount);
return *reinterpret_cast<float*>(offset + field * 4);
}
[[nodiscard]] unsigned int getUInt(size_t field) const
[[nodiscard]] unsigned int getUInt(std::size_t field) const
{
assert(field < file.fieldCount);
return *reinterpret_cast<unsigned int*>(offset + field * 4);
}
[[nodiscard]] int getInt(size_t field) const
[[nodiscard]] int getInt(std::size_t field) const
{
assert(field < file.fieldCount);
return *reinterpret_cast<int*>(offset + field * 4);
}
[[nodiscard]] const char* getString(size_t field) const
[[nodiscard]] const char* getString(std::size_t field) const
{
assert(field < file.fieldCount);
size_t stringOffset = getUInt(field);
std::size_t stringOffset = getUInt(field);
assert(stringOffset < file.stringSize);
return reinterpret_cast<char*>(file.stringTable + stringOffset);
}
@@ -116,21 +116,21 @@ public:
};
// Get record by id
Record getRecord(size_t id);
Record getRecord(std::size_t id);
/// Get begin iterator over records
Iterator begin();
/// Get begin iterator over records
Iterator end();
/// Trivial
[[nodiscard]] size_t getRecordCount() const { return recordCount;}
[[nodiscard]] size_t getFieldCount() const { return fieldCount; }
size_t getMaxId();
[[nodiscard]] std::size_t getRecordCount() const { return recordCount;}
[[nodiscard]] std::size_t getFieldCount() const { return fieldCount; }
std::size_t getMaxId();
private:
std::string filename;
size_t recordSize;
size_t recordCount;
size_t fieldCount;
size_t stringSize;
std::size_t recordSize;
std::size_t recordCount;
std::size_t fieldCount;
std::size_t stringSize;
unsigned char* data;
unsigned char* stringTable;
};

View File

@@ -93,12 +93,12 @@ MPQFile::MPQFile(const char* filename):
buffer = nullptr;
}
size_t MPQFile::read(void* dest, size_t bytes)
std::size_t MPQFile::read(void* dest, std::size_t bytes)
{
if (eof) return 0;
size_t rpos = pointer + bytes;
if (rpos > size_t(size))
std::size_t rpos = pointer + bytes;
if (rpos > std::size_t(size))
{
bytes = size - pointer;
eof = true;

View File

@@ -85,9 +85,9 @@ class MPQFile
public:
MPQFile(const char* filename); // filenames are not case sensitive
~MPQFile() { close(); }
size_t read(void* dest, size_t bytes);
size_t getSize() { return size; }
size_t getPos() { return pointer; }
std::size_t read(void* dest, std::size_t bytes);
std::size_t getSize() { return size; }
std::size_t getPos() { return pointer; }
char* getBuffer() { return buffer; }
char* getPointer() { return buffer + pointer; }
bool isEof() { return eof; }

View File

@@ -42,12 +42,12 @@ char* GetPlainName(char* FileName)
return FileName;
}
void fixnamen(char* name, size_t len)
void fixnamen(char* name, std::size_t len)
{
if (len < 3)
return;
for (size_t i = 0; i < len - 3; i++)
for (std::size_t i = 0; i < len - 3; i++)
{
if (i > 0 && name[i] >= 'A' && name[i] <= 'Z' && isalpha(name[i - 1]))
name[i] |= 0x20;
@@ -56,16 +56,16 @@ void fixnamen(char* name, size_t len)
}
//extension in lowercase
for (size_t i = len - 3; i < len; i++)
for (std::size_t i = len - 3; i < len; i++)
name[i] |= 0x20;
}
void fixname2(char* name, size_t len)
void fixname2(char* name, std::size_t len)
{
if (len < 3)
return;
for (size_t i = 0; i < len - 3; i++)
for (std::size_t i = 0; i < len - 3; i++)
if (name[i] == ' ')
name[i] = '_';
}
@@ -105,7 +105,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
flipcc(fourcc);
fourcc[4] = 0;
size_t nextpos = _file.getPos() + size;
std::size_t nextpos = _file.getPos() + size;
if (!strcmp(fourcc, "MCIN"))
{

View File

@@ -75,8 +75,8 @@ public:
const char* GetPlainName(const char* FileName);
char* GetPlainName(char* FileName);
char* GetExtension(char* FileName);
void fixnamen(char* name, size_t len);
void fixname2(char* name, size_t len);
//void fixMapNamen(char *name, size_t len);
void fixnamen(char* name, std::size_t len);
void fixname2(char* name, std::size_t len);
//void fixMapNamen(char *name, std::size_t len);
#endif

View File

@@ -76,7 +76,7 @@ DBCFile::~DBCFile()
delete [] data;
}
DBCFile::Record DBCFile::getRecord(size_t id)
DBCFile::Record DBCFile::getRecord(std::std::size_t id)
{
assert(data);
return Record(*this, data + id * recordSize);

View File

@@ -64,30 +64,30 @@ public:
offset = r.offset;
return *this;
}
[[nodiscard]] float getFloat(size_t field) const
[[nodiscard]] float getFloat(std::size_t field) const
{
assert(field < file.fieldCount);
return *reinterpret_cast<float*>(offset + field * 4);
}
[[nodiscard]] unsigned int getUInt(size_t field) const
[[nodiscard]] unsigned int getUInt(std::size_t field) const
{
assert(field < file.fieldCount);
return *reinterpret_cast<unsigned int*>(offset + (field * 4));
}
[[nodiscard]] int getInt(size_t field) const
[[nodiscard]] int getInt(std::size_t field) const
{
assert(field < file.fieldCount);
return *reinterpret_cast<int*>(offset + field * 4);
}
[[nodiscard]] unsigned char getByte(size_t ofs) const
[[nodiscard]] unsigned char getByte(std::size_t ofs) const
{
assert(ofs < file.recordSize);
return *reinterpret_cast<unsigned char*>(offset + ofs);
}
[[nodiscard]] const char* getString(size_t field) const
[[nodiscard]] const char* getString(std::size_t field) const
{
assert(field < file.fieldCount);
size_t stringOffset = getUInt(field);
std::size_t stringOffset = getUInt(field);
assert(stringOffset < file.stringSize);
//char * tmp = (char*)file.stringTable + stringOffset;
//unsigned char * tmp2 = file.stringTable + stringOffset;
@@ -134,21 +134,21 @@ public:
};
// Get record by id
Record getRecord(size_t id);
Record getRecord(std::size_t id);
/// Get begin iterator over records
Iterator begin();
/// Get begin iterator over records
Iterator end();
/// Trivial
[[nodiscard]] size_t getRecordCount() const { return recordCount;}
[[nodiscard]] size_t getFieldCount() const { return fieldCount; }
[[nodiscard]] std::size_t getRecordCount() const { return recordCount;}
[[nodiscard]] std::size_t getFieldCount() const { return fieldCount; }
private:
std::string filename;
size_t recordSize;
size_t recordCount;
size_t fieldCount;
size_t stringSize;
std::size_t recordSize;
std::size_t recordCount;
std::size_t fieldCount;
std::size_t stringSize;
unsigned char* data;
unsigned char* stringTable;
};

View File

@@ -99,12 +99,12 @@ MPQFile::MPQFile(const char* filename):
buffer = nullptr;
}
size_t MPQFile::read(void* dest, size_t bytes)
std::size_t MPQFile::read(void* dest, std::size_t bytes)
{
if (eof) return 0;
size_t rpos = pointer + bytes;
if (rpos > size_t(size))
std::size_t rpos = pointer + bytes;
if (rpos > std::size_t(size))
{
bytes = size - pointer;
eof = true;

View File

@@ -86,9 +86,9 @@ class MPQFile
public:
MPQFile(const char* filename); // filenames are not case sensitive
~MPQFile() { close(); }
size_t read(void* dest, size_t bytes);
size_t getSize() { return size; }
size_t getPos() { return pointer; }
std::size_t read(void* dest, std::size_t bytes);
std::size_t getSize() { return size; }
std::size_t getPos() { return pointer; }
char* getBuffer() { return buffer; }
char* getPointer() { return buffer + pointer; }
bool isEof() { return eof; }

View File

@@ -485,7 +485,7 @@ int main(int argc, char** argv)
map_ids[x].id = dbc->getRecord(x).getUInt(0);
char const* map_name = dbc->getRecord(x).getString(1);
size_t max_map_name_length = sizeof(map_ids[x].name);
std::size_t max_map_name_length = sizeof(map_ids[x].name);
if (strlen(map_name) >= max_map_name_length)
{
delete dbc;

View File

@@ -63,7 +63,7 @@ bool WDTFile::init(uint32 mapId)
flipcc(fourcc);
fourcc[4] = 0;
size_t nextpos = _file.getPos() + size;
std::size_t nextpos = _file.getPos() + size;
if (!strcmp(fourcc, "MAIN"))
{

View File

@@ -56,7 +56,7 @@ bool WMORoot::open()
flipcc(fourcc);
fourcc[4] = 0;
size_t nextpos = f.getPos() + size;
std::size_t nextpos = f.getPos() + size;
if (!strcmp(fourcc, "MOHD")) // header
{
@@ -185,7 +185,7 @@ bool WMOGroup::open(WMORoot* rootWMO)
size = 68;
}
fourcc[4] = 0;
size_t nextpos = f.getPos() + size;
std::size_t nextpos = f.getPos() + size;
LiquEx_size = 0;
liquflags = 0;