[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)
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-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-variable")
if(NOSTALGIA_BUILD_TYPE STREQUAL "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} -mthumb-interwork")
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)
endif()

View File

@ -17,6 +17,8 @@ namespace studio {
class JsonOperator {
public:
virtual ~JsonOperator() = default;
virtual int op(QString fieldName, int *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;
QString json;
TestStruct ts = {
.Bool = true,
.Int = 42,
.Double = 42.42,
.String = "Test String",
.Struct = {
.Bool = true,
.Int = 42,
.Double = 42.42,
.String = "Test String"
true,
42,
42.42,
"Test String",
{
true,
42,
42.42,
"Test String"
}
};
TestStruct tsOut;

View File

@ -28,12 +28,16 @@ struct Context {
};
struct EditorMaker {
virtual ~EditorMaker() = default;
virtual QWidget *make(QString path, const Context *ctx) = 0;
};
class Plugin {
public:
virtual ~Plugin() = default;
virtual QVector<WizardMaker> newWizards(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);
if (file.exists()) {
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);
if (m_fs.valid()) {
return 0;

View File

@ -66,13 +66,13 @@ int Project::writeObj(QString path, T *obj) const {
// write MetalClaw
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) {
return err;
}
// write to FS
err |= write(path, (uint8_t*) buff.data(), mcSize);
err |= write(path, reinterpret_cast<uint8_t*>(buff.data()), mcSize);
if (err) {
return err;
}

View File

@ -17,7 +17,7 @@ using namespace nostalgia::studio;
using namespace ox;
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();
NostalgiaStudioProfile config;

View File

@ -151,7 +151,7 @@ void MainWindow::setupProjectExplorer() {
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
dock->setObjectName("Project Explorer");
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
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_AUTOMOC ON)
@ -25,4 +21,6 @@ install(
bin
)
add_subdirectory(lib)
add_subdirectory(pack)

View File

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

View File

@ -39,9 +39,9 @@ uint8_t *loadFileBuff(QString path, ::size_t *sizeOut = nullptr) {
}
uint16_t toGbaColor(QColor c) {
auto r = ((uint32_t) c.red()) >> 3;
auto g = ((uint32_t) c.green()) >> 3;
auto b = ((uint32_t) c.blue()) >> 3;
auto r = static_cast<uint32_t>(c.red()) >> 3;
auto g = static_cast<uint32_t>(c.green()) >> 3;
auto b = static_cast<uint32_t>(c.blue()) >> 3;
return (r << 10) | (g << 5) | (b << 0);
}
@ -76,9 +76,9 @@ int run(ClArgs args) {
QMap<QRgb, int> colors;
const auto imgDataBuffSize = sizeof(GbaImageData) + 1 + argTiles * 64;
uint8_t imgDataBuff[imgDataBuffSize];
memset(&imgDataBuff, 0, imgDataBuffSize);
GbaImageData *id = (GbaImageData*) imgDataBuff;
QVector<uint8_t> imgDataBuff(imgDataBuffSize);
memset(imgDataBuff.data(), 0, imgDataBuffSize);
auto id = reinterpret_cast<GbaImageData*>(imgDataBuff.data());
id->header.bpp = argBpp;
id->header.tileCount = argTiles;
int colorId = 0;
@ -130,7 +130,7 @@ int run(ClArgs args) {
fsBuffSize = sizeNeeded;
}
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 (argCompact) {