[nostalgia] Enable and fix several warnings

This commit is contained in:
Gary Talent 2019-03-30 17:15:21 -05:00
parent 05c0eb2f78
commit 5afe78d015
11 changed files with 53 additions and 33 deletions

View File

@ -29,7 +29,20 @@ endif()
if(NOT MSVC) if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdouble-promotion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-field-initializers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnull-dereference")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-variable")
if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
include(GBA) include(GBA)
@ -39,6 +52,8 @@ if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb-interwork") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb-interwork")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=arm7tdmi")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=arm7tdmi")
set(OX_USE_STDLIB OFF) set(OX_USE_STDLIB OFF)
endif() endif()

View File

@ -17,6 +17,8 @@ namespace studio {
class JsonOperator { class JsonOperator {
public: public:
virtual ~JsonOperator() = default;
virtual int op(QString fieldName, int *dest) = 0; virtual int op(QString fieldName, int *dest) = 0;
virtual int op(QString fieldName, bool *dest) = 0; virtual int op(QString fieldName, bool *dest) = 0;

View File

@ -55,15 +55,15 @@ int main(int argc, char **args) {
int err = 0; int err = 0;
QString json; QString json;
TestStruct ts = { TestStruct ts = {
.Bool = true, true,
.Int = 42, 42,
.Double = 42.42, 42.42,
.String = "Test String", "Test String",
.Struct = { {
.Bool = true, true,
.Int = 42, 42,
.Double = 42.42, 42.42,
.String = "Test String" "Test String"
} }
}; };
TestStruct tsOut; TestStruct tsOut;

View File

@ -28,12 +28,16 @@ struct Context {
}; };
struct EditorMaker { struct EditorMaker {
virtual ~EditorMaker() = default;
virtual QWidget *make(QString path, const Context *ctx) = 0; virtual QWidget *make(QString path, const Context *ctx) = 0;
}; };
class Plugin { class Plugin {
public: public:
virtual ~Plugin() = default;
virtual QVector<WizardMaker> newWizards(const Context *ctx); virtual QVector<WizardMaker> newWizards(const Context *ctx);
virtual QVector<WizardMaker> importWizards(const Context *ctx); virtual QVector<WizardMaker> importWizards(const Context *ctx);

View File

@ -35,7 +35,7 @@ int Project::openRomFs() {
auto buff = std::make_unique<uint8_t[]>(buffSize); auto buff = std::make_unique<uint8_t[]>(buffSize);
if (file.exists()) { if (file.exists()) {
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
if (file.read((char*) buff.get(), buffSize) > 0) { if (file.read(reinterpret_cast<char*>(buff.get()), buffSize) > 0) {
m_fsBuff = std::move(buff); m_fsBuff = std::move(buff);
if (m_fs.valid()) { if (m_fs.valid()) {
return 0; return 0;

View File

@ -66,13 +66,13 @@ int Project::writeObj(QString path, T *obj) const {
// write MetalClaw // write MetalClaw
size_t mcSize = 0; size_t mcSize = 0;
err |= ox::writeMC((uint8_t*) buff.data(), buffLen, obj, &mcSize); err |= ox::writeMC(reinterpret_cast<uint8_t*>(buff.data()), buffLen, obj, &mcSize);
if (err) { if (err) {
return err; return err;
} }
// write to FS // write to FS
err |= write(path, (uint8_t*) buff.data(), mcSize); err |= write(path, reinterpret_cast<uint8_t*>(buff.data()), mcSize);
if (err) { if (err) {
return err; return err;
} }

View File

@ -17,7 +17,7 @@ using namespace nostalgia::studio;
using namespace ox; using namespace ox;
int run(int argc, char **args) { int run(int argc, char **args) {
ClArgs clargs(argc, (const char**) args); ClArgs clargs(argc, const_cast<const char**>(args));
QString argProfilePath = clargs.getString("profile").c_str(); QString argProfilePath = clargs.getString("profile").c_str();
NostalgiaStudioProfile config; NostalgiaStudioProfile config;

View File

@ -151,7 +151,7 @@ void MainWindow::setupProjectExplorer() {
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
dock->setObjectName("Project Explorer"); dock->setObjectName("Project Explorer");
addDockWidget(Qt::LeftDockWidgetArea, dock); addDockWidget(Qt::LeftDockWidgetArea, dock);
resizeDocks({dock}, {(int) (width() * 0.25)}, Qt::Horizontal); resizeDocks({dock}, {static_cast<int>(width() * 0.25)}, Qt::Horizontal);
// setup tree view // setup tree view
m_projectExplorer = new QTreeView(dock); m_projectExplorer = new QTreeView(dock);

View File

@ -1,7 +1,3 @@
cmake_minimum_required(VERSION 2.8.11)
project(nost-pack)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
@ -25,4 +21,6 @@ install(
bin bin
) )
add_subdirectory(lib) add_subdirectory(lib)
add_subdirectory(pack)

View File

@ -9,6 +9,7 @@
#include <QColor> #include <QColor>
#include <QImage> #include <QImage>
#include <QMap> #include <QMap>
#include <QVector>
#include <ox/clargs/clargs.hpp> #include <ox/clargs/clargs.hpp>
#include <ox/fs/fs.hpp> #include <ox/fs/fs.hpp>
@ -22,10 +23,10 @@ using namespace ox;
using namespace nostalgia::core; using namespace nostalgia::core;
using namespace nostalgia::common; using namespace nostalgia::common;
uint16_t toGbaColor(QColor c) { [[nodiscard]] uint16_t toGbaColor(QColor c) {
auto r = ((uint32_t) c.red()) >> 3; const auto r = static_cast<uint32_t>(c.red()) >> 3;
auto g = ((uint32_t) c.green()) >> 3; const auto g = static_cast<uint32_t>(c.green()) >> 3;
auto b = ((uint32_t) c.blue()) >> 3; const auto b = static_cast<uint32_t>(c.blue()) >> 3;
return (r << 10) | (g << 5) | (b << 0); return (r << 10) | (g << 5) | (b << 0);
} }
@ -47,9 +48,9 @@ Error importTileSet(FileSystem *fs, QString romPath, QString importPath, int bpp
QMap<QRgb, int> colors; QMap<QRgb, int> colors;
auto tileCount = (src.width() * src.height()) / 64; auto tileCount = (src.width() * src.height()) / 64;
const auto imgDataBuffSize = sizeof(GbaImageData) + 1 + tileCount * 64; const auto imgDataBuffSize = sizeof(GbaImageData) + 1 + tileCount * 64;
uint8_t imgDataBuff[imgDataBuffSize]; QVector<uint8_t> imgDataBuff(imgDataBuffSize);
memset(&imgDataBuff, 0, imgDataBuffSize); memset(imgDataBuff.data(), 0, imgDataBuffSize);
GbaImageData *id = (GbaImageData*) imgDataBuff; GbaImageData *id = reinterpret_cast<GbaImageData*>(imgDataBuff.data());
id->header.bpp = bpp; id->header.bpp = bpp;
id->header.tileCount = tileCount; id->header.tileCount = tileCount;
int colorId = 0; int colorId = 0;
@ -84,7 +85,7 @@ Error importTileSet(FileSystem *fs, QString romPath, QString importPath, int bpp
} }
if (!err) { if (!err) {
err |= fs->write(romPath.toUtf8().data(), imgDataBuff, imgDataBuffSize); err |= fs->write(romPath.toUtf8().data(), imgDataBuff.data(), imgDataBuffSize);
} }
} else { } else {
err = 4; err = 4;

View File

@ -39,9 +39,9 @@ uint8_t *loadFileBuff(QString path, ::size_t *sizeOut = nullptr) {
} }
uint16_t toGbaColor(QColor c) { uint16_t toGbaColor(QColor c) {
auto r = ((uint32_t) c.red()) >> 3; auto r = static_cast<uint32_t>(c.red()) >> 3;
auto g = ((uint32_t) c.green()) >> 3; auto g = static_cast<uint32_t>(c.green()) >> 3;
auto b = ((uint32_t) c.blue()) >> 3; auto b = static_cast<uint32_t>(c.blue()) >> 3;
return (r << 10) | (g << 5) | (b << 0); return (r << 10) | (g << 5) | (b << 0);
} }
@ -76,9 +76,9 @@ int run(ClArgs args) {
QMap<QRgb, int> colors; QMap<QRgb, int> colors;
const auto imgDataBuffSize = sizeof(GbaImageData) + 1 + argTiles * 64; const auto imgDataBuffSize = sizeof(GbaImageData) + 1 + argTiles * 64;
uint8_t imgDataBuff[imgDataBuffSize]; QVector<uint8_t> imgDataBuff(imgDataBuffSize);
memset(&imgDataBuff, 0, imgDataBuffSize); memset(imgDataBuff.data(), 0, imgDataBuffSize);
GbaImageData *id = (GbaImageData*) imgDataBuff; auto id = reinterpret_cast<GbaImageData*>(imgDataBuff.data());
id->header.bpp = argBpp; id->header.bpp = argBpp;
id->header.tileCount = argTiles; id->header.tileCount = argTiles;
int colorId = 0; int colorId = 0;
@ -130,7 +130,7 @@ int run(ClArgs args) {
fsBuffSize = sizeNeeded; fsBuffSize = sizeNeeded;
} }
fsBuff = fs.buff(); // update fsBuff pointer in case there is a new buff fsBuff = fs.buff(); // update fsBuff pointer in case there is a new buff
err |= fs.write(argInode, imgDataBuff, imgDataBuffSize); err |= fs.write(argInode, imgDataBuff.data(), imgDataBuffSize);
if (!err) { if (!err) {
if (argCompact) { if (argCompact) {