Skip to content

Commit

Permalink
clang warning pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrelliCopter committed Mar 20, 2024
1 parent 696057b commit 417bc11
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ set_target_properties(tmx2gba PROPERTIES

# Enable strong warnings
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:Clang,AppleClang>:-Weverything>)
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Weverything -Wno-c++98-compat>)

target_link_libraries(tmx2gba
External::base64
Expand Down
2 changes: 0 additions & 2 deletions src/argparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ bool ArgParse::ArgParser::CheckParse(ArgParse::ParseErr err) const
case ParseErr::ARG_RANGE:
DisplayError("Argument out of range.", false);
return false;
default:
return false;
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ namespace ArgParse
{
struct Option
{
char flag;
bool required;
const char* argumentName;
const char* helpString;
char flag;
bool required;

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)
{
return { flag, true, name, help };
return { name, help, flag, false };
}
};

Expand Down Expand Up @@ -66,10 +66,10 @@ namespace ArgParse

class ParserState
{
bool expectArg = false;
int flagChar;
HandleOption handler;
const Options& options;
int flagChar;
bool expectArg = false;

public:
ParserState(HandleOption handler, const Options& options) noexcept
Expand Down
2 changes: 1 addition & 1 deletion src/swriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SWriter
if (col == 0)
aOut << "\t" << GccIsDumb::DatType<T>() << " ";

aOut << std::hex << (int)element;
aOut << std::hex << static_cast<int>(element);

if (i < aDat.size() - 1)
{
Expand Down
14 changes: 8 additions & 6 deletions src/tmx2gba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#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
{
Expand Down Expand Up @@ -195,7 +195,9 @@ int main(int argc, char** argv)

// Get name from file
//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;
if (slashPos != -1)
name = name.substr(slashPos + 1);
Expand Down Expand Up @@ -223,7 +225,7 @@ int main(int argc, char** argv)
{
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;

// Get flipped!
Expand Down Expand Up @@ -255,7 +257,7 @@ int main(int argc, char** argv)
gfxTiles = layerCls->GetData();
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);
}

Expand Down Expand Up @@ -285,8 +287,8 @@ int main(int argc, char** argv)
float x, y;
obj->GetPos(x, y);
objDat.push_back(it->second);
objDat.push_back((int)(x * 256.0f));
objDat.push_back((int)(y * 256.0f));
objDat.push_back(static_cast<int>(x * 256.0f));
objDat.push_back(static_cast<int>(y * 256.0f));
}

// Write objects
Expand Down
4 changes: 2 additions & 2 deletions src/tmxreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool TmxReader::DecodeMap(uint32_t* aOut, size_t aOutSize, const std::string& aB
// Decompress compressed data
auto dstSize = static_cast<mz_ulong>(aOutSize);
int res = uncompress(
(unsigned char*)aOut,
reinterpret_cast<unsigned char*>(aOut),
&dstSize,
reinterpret_cast<const unsigned char*>(decoded.data()),
static_cast<mz_ulong>(decoded.size()));
Expand Down Expand Up @@ -172,7 +172,7 @@ void TmxReader::Open(std::istream& aIn)

// Parse document
rapidxml::xml_document<> xDoc;
xDoc.parse<0>((char*)strXml.c_str());
xDoc.parse<0>(const_cast<char*>(strXml.c_str()));

// Get map node
auto xMap = xDoc.first_node("map");
Expand Down
1 change: 0 additions & 1 deletion src/tmxtileset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class TmxTileset
std::string mName;
std::string mSource;
uint32_t mFirstGid;

};

#endif//TMXTILESET_HPP

0 comments on commit 417bc11

Please sign in to comment.