1
0
mirror of https://github.com/ScrelliCopter/tmx2gba.git synced 2025-02-21 03:29:25 +11:00

clang warning pass

This commit is contained in:
2024-03-21 08:21:02 +11:00
parent 696057b5e6
commit 417bc11fae
7 changed files with 19 additions and 20 deletions

View File

@@ -15,9 +15,9 @@ set_target_properties(tmx2gba PROPERTIES
# Enable strong warnings # Enable strong warnings
target_compile_options(tmx2gba PRIVATE target_compile_options(tmx2gba PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/Wall> $<$<CXX_COMPILER_ID:MSVC>:/Wall>
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall -Wextra -pedantic> $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall -Wextra -pedantic>
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Weverything>) $<$<CXX_COMPILER_ID:Clang,AppleClang>:-Weverything -Wno-c++98-compat>)
target_link_libraries(tmx2gba target_link_libraries(tmx2gba
External::base64 External::base64

View File

@@ -151,8 +151,6 @@ bool ArgParse::ArgParser::CheckParse(ArgParse::ParseErr err) const
case ParseErr::ARG_RANGE: case ParseErr::ARG_RANGE:
DisplayError("Argument out of range.", false); DisplayError("Argument out of range.", false);
return false; return false;
default:
return false;
} }
} }

View File

@@ -16,18 +16,18 @@ namespace ArgParse
{ {
struct Option struct Option
{ {
char flag;
bool required;
const char* argumentName; const char* argumentName;
const char* helpString; const char* helpString;
char flag;
bool required;
static constexpr Option Optional(char flag, const char* name, const char* help) static constexpr Option Optional(char flag, const char* name, const char* help)
{ {
return { flag, false, name, help }; return { name, help, flag, false };
} }
static constexpr Option Required(char flag, const char* name, const char* help) static constexpr Option Required(char flag, const char* name, const char* help)
{ {
return { flag, true, name, help }; return { name, help, flag, false };
} }
}; };
@@ -66,10 +66,10 @@ namespace ArgParse
class ParserState class ParserState
{ {
bool expectArg = false;
int flagChar;
HandleOption handler; HandleOption handler;
const Options& options; const Options& options;
int flagChar;
bool expectArg = false;
public: public:
ParserState(HandleOption handler, const Options& options) noexcept ParserState(HandleOption handler, const Options& options) noexcept

View File

@@ -37,7 +37,7 @@ class SWriter
if (col == 0) if (col == 0)
aOut << "\t" << GccIsDumb::DatType<T>() << " "; aOut << "\t" << GccIsDumb::DatType<T>() << " ";
aOut << std::hex << (int)element; aOut << std::hex << static_cast<int>(element);
if (i < aDat.size() - 1) if (i < aDat.size() - 1)
{ {

View File

@@ -11,7 +11,7 @@
#include <algorithm> #include <algorithm>
const std::string versionStr = "tmx2gba version 0.3, (c) 2015-2022 a dinosaur"; static const char* versionStr = "tmx2gba version 0.3, (c) 2015-2022 a dinosaur";
struct Arguments struct Arguments
{ {
@@ -195,7 +195,9 @@ int main(int argc, char** argv)
// Get name from file // Get name from file
//TODO: properly sanitise //TODO: properly sanitise
int slashPos = std::max((int)p.outPath.find_last_of('/'), (int)p.outPath.find_last_of('\\')); int slashPos = std::max(
static_cast<int>(p.outPath.find_last_of('/')),
static_cast<int>(p.outPath.find_last_of('\\')));
std::string name = p.outPath; std::string name = p.outPath;
if (slashPos != -1) if (slashPos != -1)
name = name.substr(slashPos + 1); name = name.substr(slashPos + 1);
@@ -223,7 +225,7 @@ int main(int argc, char** argv)
{ {
uint32_t read = (*gfxTiles++); uint32_t read = (*gfxTiles++);
uint16_t tile = (uint16_t)std::max<int32_t>(0, tmx.LidFromGid(read & ~TmxLayer::FLIP_MASK) + p.offset); uint16_t tile = std::max<uint16_t>(0, tmx.LidFromGid(read & ~TmxLayer::FLIP_MASK) + p.offset);
uint8_t flags = 0x0; uint8_t flags = 0x0;
// Get flipped! // Get flipped!
@@ -255,7 +257,7 @@ int main(int argc, char** argv)
gfxTiles = layerCls->GetData(); gfxTiles = layerCls->GetData();
for (int i = 0; i < layerCls->GetWidth() * layerCls->GetHeight(); ++i) for (int i = 0; i < layerCls->GetWidth() * layerCls->GetHeight(); ++i)
{ {
uint8_t ucTile = (uint8_t)tmx.LidFromGid((*gfxTiles++) & ~TmxLayer::FLIP_MASK); uint8_t ucTile = static_cast<uint8_t>(tmx.LidFromGid((*gfxTiles++) & ~TmxLayer::FLIP_MASK));
collisionDat.push_back(ucTile); collisionDat.push_back(ucTile);
} }
@@ -285,8 +287,8 @@ int main(int argc, char** argv)
float x, y; float x, y;
obj->GetPos(x, y); obj->GetPos(x, y);
objDat.push_back(it->second); objDat.push_back(it->second);
objDat.push_back((int)(x * 256.0f)); objDat.push_back(static_cast<int>(x * 256.0f));
objDat.push_back((int)(y * 256.0f)); objDat.push_back(static_cast<int>(y * 256.0f));
} }
// Write objects // Write objects

View File

@@ -43,7 +43,7 @@ bool TmxReader::DecodeMap(uint32_t* aOut, size_t aOutSize, const std::string& aB
// Decompress compressed data // Decompress compressed data
auto dstSize = static_cast<mz_ulong>(aOutSize); auto dstSize = static_cast<mz_ulong>(aOutSize);
int res = uncompress( int res = uncompress(
(unsigned char*)aOut, reinterpret_cast<unsigned char*>(aOut),
&dstSize, &dstSize,
reinterpret_cast<const unsigned char*>(decoded.data()), reinterpret_cast<const unsigned char*>(decoded.data()),
static_cast<mz_ulong>(decoded.size())); static_cast<mz_ulong>(decoded.size()));
@@ -172,7 +172,7 @@ void TmxReader::Open(std::istream& aIn)
// Parse document // Parse document
rapidxml::xml_document<> xDoc; rapidxml::xml_document<> xDoc;
xDoc.parse<0>((char*)strXml.c_str()); xDoc.parse<0>(const_cast<char*>(strXml.c_str()));
// Get map node // Get map node
auto xMap = xDoc.first_node("map"); auto xMap = xDoc.first_node("map");

View File

@@ -23,7 +23,6 @@ private:
std::string mName; std::string mName;
std::string mSource; std::string mSource;
uint32_t mFirstGid; uint32_t mFirstGid;
}; };
#endif//TMXTILESET_HPP #endif//TMXTILESET_HPP