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; }