From 0b8c71119d0ce749fa55b2620e945a1e4ddf1d76 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Fri, 14 Sep 2018 18:37:36 -0500 Subject: [PATCH] Fix warnings --- block.cpp | 5 +- blockdata.cpp | 4 +- editor.cpp | 175 ++++++++++++++++++++++------------------------- editor.h | 68 +++++++++--------- event.cpp | 8 +-- event.h | 3 + heallocation.cpp | 20 +++--- heallocation.h | 6 +- mainwindow.cpp | 30 ++++---- mainwindow.h | 2 +- map.cpp | 126 ++++++---------------------------- map.h | 26 +++---- parseutil.cpp | 2 +- project.cpp | 11 ++- tileset.cpp | 4 +- 15 files changed, 194 insertions(+), 296 deletions(-) diff --git a/block.cpp b/block.cpp index 144ba2de..ceff25da 100755 --- a/block.cpp +++ b/block.cpp @@ -17,7 +17,10 @@ Block::Block(const Block &block) { } uint16_t Block::rawValue() { - return (tile & 0x3ff) + ((collision & 0x3) << 10) + ((elevation & 0xf) << 12); + return static_cast( + (tile & 0x3ff) + + ((collision & 0x3) << 10) + + ((elevation & 0xf) << 12)); } bool Block::operator ==(Block other) { diff --git a/blockdata.cpp b/blockdata.cpp index eb99ea65..10901741 100755 --- a/blockdata.cpp +++ b/blockdata.cpp @@ -20,8 +20,8 @@ QByteArray Blockdata::serialize() { for (int i = 0; i < blocks->length(); i++) { Block block = blocks->value(i); uint16_t word = block.rawValue(); - data.append(word & 0xff); - data.append((word >> 8) & 0xff); + data.append(static_cast(word & 0xff)); + data.append(static_cast((word >> 8) & 0xff)); } return data; } diff --git a/editor.cpp b/editor.cpp index 17909121..d3853b91 100755 --- a/editor.cpp +++ b/editor.cpp @@ -5,7 +5,7 @@ #include #include -bool selectingEvent = false; +static bool selectingEvent = false; Editor::Editor(Ui::MainWindow* ui) { @@ -107,7 +107,8 @@ void Editor::setEditingConnections() { ui->label_NumConnections->setText(QString::number(map->connections.length())); setConnectionsVisibility(false); setDiveEmergeControls(); - setConnectionEditControlsEnabled(selected_connection_item != NULL); + bool controlsEnabled = selected_connection_item != nullptr; + setConnectionEditControlsEnabled(controlsEnabled); if (selected_connection_item) { onConnectionOffsetChanged(selected_connection_item->connection->offset.toInt()); setConnectionMap(selected_connection_item->connection->map_name); @@ -258,7 +259,7 @@ void Editor::setConnectionEditControlsEnabled(bool enabled) { ui->spinBox_ConnectionOffset->setEnabled(enabled); if (!enabled) { - setConnectionEditControlValues(0); + setConnectionEditControlValues(nullptr); } } @@ -326,7 +327,7 @@ void Editor::setMap(QString map_name) { } if (project) { map = project->loadMap(map_name); - connect(map, &Map::paintTileChanged, [=](Map *map) { + connect(map, &Map::paintTileChanged, [=]() { lastSelectedMetatilesFromMap = false; redrawCurrentMetatilesSelection(); }); @@ -561,7 +562,7 @@ void Editor::displayMapConnections() { } delete item; } - selected_connection_item = NULL; + selected_connection_item = nullptr; connection_edit_items.clear(); for (Connection *connection : map->connections) { @@ -756,8 +757,7 @@ void Editor::updateMirroredConnection(Connection* connection, QString originalDi QString oppositeDirection = oppositeDirections.value(originalDirection); // Find the matching connection in the connected map. - QMap *mapcache = project->map_cache; - Connection* mirrorConnection = NULL; + Connection* mirrorConnection = nullptr; Map* otherMap = project->getMap(originalMapName); for (Connection* conn : otherMap->connections) { if (conn->direction == oppositeDirection && conn->map_name == map->name) { @@ -777,7 +777,7 @@ void Editor::updateMirroredConnection(Connection* connection, QString originalDi if (mirrorConnection) { otherMap->connections.removeOne(mirrorConnection); delete mirrorConnection; - mirrorConnection = NULL; + mirrorConnection = nullptr; otherMap = project->getMap(connection->map_name); } } @@ -806,7 +806,7 @@ void Editor::removeCurrentConnection() { delete selected_connection_item; } - selected_connection_item = NULL; + selected_connection_item = nullptr; setConnectionEditControlsEnabled(false); ui->spinBox_ConnectionOffset->setValue(0); ui->label_NumConnections->setText(QString::number(map->connections.length())); @@ -830,7 +830,7 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) { return; } - Connection* connection = NULL; + Connection* connection = nullptr; for (Connection* conn : map->connections) { if (conn->direction == direction) { connection = conn; @@ -888,7 +888,7 @@ void Editor::toggleBorderVisibility(bool visible) this->setConnectionsVisibility(visible); } -void MetatilesPixmapItem::paintTileChanged(Map *map) { +void MetatilesPixmapItem::paintTileChanged() { draw(); } @@ -897,8 +897,8 @@ void MetatilesPixmapItem::draw() { } void MetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) { - int x = ((int)pos.x()) / 16; - int y = ((int)pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; int width = pixmap().width() / 16; int height = pixmap().height() / 16; if (x < 0 || x >= width || y < 0 || y >= height) { @@ -912,13 +912,13 @@ void MetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) { void MetatilesPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { updateCurHoveredMetatile(event->pos()); } -void MetatilesPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { +void MetatilesPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) { map->clearHoveredMetatile(); } void MetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { QPointF pos = event->pos(); - int x = ((int)pos.x()) / 16; - int y = ((int)pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; map->paint_metatile_initial_x = x; map->paint_metatile_initial_y = y; updateSelection(event->pos()); @@ -931,8 +931,8 @@ void MetatilesPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { updateSelection(event->pos()); } void MetatilesPixmapItem::updateSelection(QPointF pos) { - int x = ((int)pos.x()) / 16; - int y = ((int)pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; int width = pixmap().width() / 16; int height = pixmap().height() / 16; if ((x >= 0 && x < width) && (y >=0 && y < height)) { @@ -943,19 +943,19 @@ void MetatilesPixmapItem::updateSelection(QPointF pos) { map->paint_tile_height = abs(map->paint_metatile_initial_y - y) + 1; map->setSelectedMetatilesFromTilePicker(); - emit map->paintTileChanged(map); + emit map->paintTileChanged(); } } void BorderMetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { QPointF pos = event->pos(); - int x = ((int)pos.x()) / 16; - int y = ((int)pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; for (int i = 0; i < map->selected_metatiles_width && (i + x) < 2; i++) { for (int j = 0; j < map->selected_metatiles_height && (j + y) < 2; j++) { int blockIndex = (j + y) * 2 + (i + x); - int tile = map->selected_metatiles->at(j * map->selected_metatiles_width + i); + uint16_t tile = map->selected_metatiles->at(j * map->selected_metatiles_width + i); (*map->layout->border->blocks)[blockIndex].tile = tile; } } @@ -1007,8 +1007,8 @@ void CurrentSelectedMetatilesPixmapItem::draw() { void MovementPermissionsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent* event) { QPointF pos = event->pos(); - int x = ((int)pos.x()) / 32; - int y = ((int)pos.y()) / 32; + int x = static_cast(pos.x()) / 32; + int y = static_cast(pos.y()) / 32; int width = pixmap().width() / 32; int height = pixmap().height() / 32; @@ -1028,8 +1028,8 @@ void MovementPermissionsPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* } void MovementPermissionsPixmapItem::updateCurHoveredMetatile(QPointF pos) { - int x = ((int)pos.x()) / 32; - int y = ((int)pos.y()) / 32; + int x = static_cast(pos.x()) / 32; + int y = static_cast(pos.y()) / 32; int width = pixmap().width() / 32; int height = pixmap().height() / 32; @@ -1090,10 +1090,10 @@ QVariant ConnectionPixmapItem::itemChange(GraphicsItemChange change, const QVari return QGraphicsItem::itemChange(change, value); } } -void ConnectionPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent* event) { +void ConnectionPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *) { emit connectionItemSelected(this); } -void ConnectionPixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) { +void ConnectionPixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) { emit connectionItemDoubleClicked(this); } @@ -1103,8 +1103,8 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) { map->commit(); } else { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; // Paint onto the map. bool smartPathsEnabled = event->modifiers() & Qt::ShiftModifier; @@ -1125,8 +1125,8 @@ void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) { map->commit(); } else { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; if (event->type() == QEvent::GraphicsSceneMousePress) { selection_origin = QPoint(x, y); @@ -1138,8 +1138,6 @@ void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) { Blockdata *backupBlockdata = map->layout->blockdata->copy(); for (int i = 0; i < map->getWidth(); i++) for (int j = 0; j < map->getHeight(); j++) { - int srcX = i; - int srcY = j; int destX = i + xDelta; int destY = j + yDelta; if (destX < 0) @@ -1215,7 +1213,7 @@ void MapPixmapItem::paintSmartPath(int x, int y) { if (map->selected_metatiles_width != 3 || map->selected_metatiles_height != 3) return; // Shift to the middle tile of the smart path selection. - int openTile = map->selected_metatiles->at(4); + uint16_t openTile = map->selected_metatiles->at(4); // Fill the region with the open tile. for (int i = 0; i <= 1; i++) @@ -1274,8 +1272,8 @@ void MapPixmapItem::paintSmartPath(int x, int y) { void MapPixmapItem::updateMetatileSelection(QGraphicsSceneMouseEvent *event) { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; // Snap point to within map bounds. if (x < 0) x = 0; @@ -1328,8 +1326,8 @@ void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) { map->commit(); } else { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; Block *block = map->getBlock(x, y); int tile = map->selected_metatiles->first(); if (block && block->tile != tile) { @@ -1354,7 +1352,7 @@ void MapPixmapItem::_floodFill(int initialX, int initialY) { int y = point.y(); Block *block = map->getBlock(x, y); - if (block == NULL) { + if (!block) { continue; } @@ -1364,8 +1362,8 @@ void MapPixmapItem::_floodFill(int initialX, int initialY) { int j = yDiff % map->selected_metatiles_height; if (i < 0) i = map->selected_metatiles_width + i; if (j < 0) j = map->selected_metatiles_height + j; - int tile = map->selected_metatiles->at(j * map->selected_metatiles_width + i); - uint old_tile = block->tile; + uint16_t tile = map->selected_metatiles->at(j * map->selected_metatiles_width + i); + uint16_t old_tile = block->tile; if (old_tile == tile) { continue; } @@ -1392,7 +1390,7 @@ void MapPixmapItem::_floodFillSmartPath(int initialX, int initialY) { if (map->selected_metatiles_width != 3 || map->selected_metatiles_height != 3) return; // Shift to the middle tile of the smart path selection. - int openTile = map->selected_metatiles->at(4); + uint16_t openTile = map->selected_metatiles->at(4); // Flood fill the region with the open tile. QList todo; @@ -1403,11 +1401,11 @@ void MapPixmapItem::_floodFillSmartPath(int initialX, int initialY) { int y = point.y(); Block *block = map->getBlock(x, y); - if (block == NULL) { + if (!block) { continue; } - uint old_tile = block->tile; + uint16_t old_tile = block->tile; if (old_tile == openTile) { continue; } @@ -1430,8 +1428,9 @@ void MapPixmapItem::_floodFillSmartPath(int initialX, int initialY) { // Go back and resolve the flood-filled edge tiles. // Mark tiles as visited while we go. - bool visited[map->getWidth() * map->getHeight()]; - for (int i = 0; i < sizeof visited; i++) + int numMetatiles = map->getWidth() * map->getHeight(); + bool *visited = new bool[numMetatiles]; + for (int i = 0; i < numMetatiles; i++) visited[i] = false; todo.append(QPoint(initialX, initialY)); @@ -1442,7 +1441,7 @@ void MapPixmapItem::_floodFillSmartPath(int initialX, int initialY) { visited[x + y * map->getWidth()] = true; Block *block = map->getBlock(x, y); - if (block == NULL) { + if (!block) { continue; } @@ -1483,12 +1482,14 @@ void MapPixmapItem::_floodFillSmartPath(int initialX, int initialY) { visited[x + (y - 1) * map->getWidth()] = true; } } + + delete[] visited; } void MapPixmapItem::pick(QGraphicsSceneMouseEvent *event) { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; Block *block = map->getBlock(x, y); if (block) { map->paint_tile_index = map->getDisplayedBlockIndex(block->tile); @@ -1496,14 +1497,14 @@ void MapPixmapItem::pick(QGraphicsSceneMouseEvent *event) { map->paint_tile_height = 1; map->setSelectedMetatilesFromTilePicker(); - emit map->paintTileChanged(map); + emit map->paintTileChanged(); } } void MapPixmapItem::select(QGraphicsSceneMouseEvent *event) { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; if (event->type() == QEvent::GraphicsSceneMousePress) { selection_origin = QPoint(x, y); selection.clear(); @@ -1539,8 +1540,8 @@ void MapPixmapItem::draw(bool ignoreCache) { } void MapPixmapItem::updateCurHoveredTile(QPointF pos) { - int x = ((int)pos.x()) / 16; - int y = ((int)pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; int blockIndex = y * map->getWidth() + x; if (x < 0 || x >= map->getWidth() || y < 0 || y >= map->getHeight()) { map->clearHoveredTile(); @@ -1562,7 +1563,7 @@ void MapPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { setCursor(editor->cursor); } } -void MapPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { +void MapPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) { map->clearHoveredTile(); if (editor->ui->actionBetter_Cursors->isChecked()){ unsetCursor(); @@ -1570,8 +1571,8 @@ void MapPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { } void MapPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { QPointF pos = event->pos(); - int x = ((int)pos.x()) / 16; - int y = ((int)pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; map->paint_tile_initial_x = x; map->paint_tile_initial_y = y; emit mouseEvent(event, this); @@ -1603,16 +1604,12 @@ void CollisionPixmapItem::draw(bool ignoreCache) { void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) { if (map) { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; Block *block = map->getBlock(x, y); if (block) { - if (map->paint_collision >= 0) { - block->collision = map->paint_collision; - } - if (map->paint_elevation >= 0) { - block->elevation = map->paint_elevation; - } + block->collision = map->paint_collision; + block->elevation = map->paint_elevation; map->_setBlock(x, y, *block); } if (event->type() == QEvent::GraphicsSceneMouseRelease) { @@ -1625,25 +1622,17 @@ void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) { void CollisionPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) { if (map) { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; - bool collision = map->paint_collision >= 0; - bool elevation = map->paint_elevation >= 0; - if (collision && elevation) { - map->floodFillCollisionElevation(x, y, map->paint_collision, map->paint_elevation); - } else if (collision) { - map->floodFillCollision(x, y, map->paint_collision); - } else if (elevation) { - map->floodFillElevation(x, y, map->paint_elevation); - } + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; + map->floodFillCollisionElevation(x, y, map->paint_collision, map->paint_elevation); draw(); } } void CollisionPixmapItem::pick(QGraphicsSceneMouseEvent *event) { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; Block *block = map->getBlock(x, y); if (block) { map->paint_collision = block->collision; @@ -1654,8 +1643,8 @@ void CollisionPixmapItem::pick(QGraphicsSceneMouseEvent *event) { void CollisionPixmapItem::updateMovementPermissionSelection(QGraphicsSceneMouseEvent *event) { QPointF pos = event->pos(); - int x = (int)(pos.x()) / 16; - int y = (int)(pos.y()) / 16; + int x = static_cast(pos.x()) / 16; + int y = static_cast(pos.y()) / 16; // Snap point to within map bounds. if (x < 0) x = 0; @@ -1663,17 +1652,16 @@ void CollisionPixmapItem::updateMovementPermissionSelection(QGraphicsSceneMouseE if (y < 0) y = 0; if (y >= map->getHeight()) y = map->getHeight() - 1; - int collision = map->getBlock(x, y)->collision; - int elevation = map->getBlock(x, y)->elevation; - map->paint_collision = collision; - map->paint_elevation = elevation; + Block *block = map->getBlock(x, y); + map->paint_collision = block->collision; + map->paint_elevation = block->elevation; editor->collision_metatiles_item->draw(); } void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) { active = true; - last_x = (mouse->pos().x() + this->pos().x()) / 16; - last_y = (mouse->pos().y() + this->pos().y()) / 16; + last_x = static_cast(mouse->pos().x() + this->pos().x()) / 16; + last_y = static_cast(mouse->pos().y() + this->pos().y()) / 16; this->editor->selectMapEvent(this, mouse->modifiers() & Qt::ControlModifier); this->editor->updateSelectedEvents(); selectingEvent = true; @@ -1689,8 +1677,8 @@ void DraggablePixmapItem::move(int x, int y) { void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) { if (active) { - int x = (mouse->pos().x() + this->pos().x()) / 16; - int y = (mouse->pos().y() + this->pos().y()) / 16; + int x = static_cast(mouse->pos().x() + this->pos().x()) / 16; + int y = static_cast(mouse->pos().y() + this->pos().y()) / 16; if (x != last_x || y != last_y) { if (editor->selected_events->contains(this)) { for (DraggablePixmapItem *item : *editor->selected_events) { @@ -1706,11 +1694,11 @@ void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) { } } -void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouse) { +void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *) { active = false; } -void DraggablePixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouse) { +void DraggablePixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) { if (this->event->get("event_type") == EventType::Warp) { emit editor->warpEventDoubleClicked(this->event->get("destination_map_name"), this->event->get("destination_warp")); } @@ -1720,7 +1708,7 @@ QList *Editor::getObjects() { QList *list = new QList; for (Event *event : map->getAllEvents()) { for (QGraphicsItem *child : events_group->childItems()) { - DraggablePixmapItem *item = (DraggablePixmapItem *)child; + DraggablePixmapItem *item = static_cast(child); if (item->event == event) { list->append(item); break; @@ -1779,10 +1767,9 @@ DraggablePixmapItem* Editor::addNewEvent(QString event_type) { map->addEvent(event); project->loadEventPixmaps(map->getAllEvents()); DraggablePixmapItem *object = addMapEvent(event); - return object; } - return NULL; + return nullptr; } void Editor::deleteEvent(Event *event) { diff --git a/editor.h b/editor.h index ab09c365..61e40d29 100755 --- a/editor.h +++ b/editor.h @@ -30,9 +30,9 @@ public: Editor(Ui::MainWindow* ui); public: Ui::MainWindow* ui; - QObject *parent = NULL; - Project *project = NULL; - Map *map = NULL; + QObject *parent = nullptr; + Project *project = nullptr; + Map *map = nullptr; void saveProject(); void save(); void undo(); @@ -79,35 +79,35 @@ public: void redrawObject(DraggablePixmapItem *item); QList *getObjects(); - QGraphicsScene *scene = NULL; - QGraphicsPixmapItem *current_view = NULL; - MapPixmapItem *map_item = NULL; - ConnectionPixmapItem* selected_connection_item = NULL; + QGraphicsScene *scene = nullptr; + QGraphicsPixmapItem *current_view = nullptr; + MapPixmapItem *map_item = nullptr; + ConnectionPixmapItem* selected_connection_item = nullptr; QList connection_items; QList connection_edit_items; - CollisionPixmapItem *collision_item = NULL; - QGraphicsItemGroup *events_group = NULL; + CollisionPixmapItem *collision_item = nullptr; + QGraphicsItemGroup *events_group = nullptr; QList borderItems; QList gridLines; - QGraphicsScene *scene_metatiles = NULL; - QGraphicsScene *scene_current_metatile_selection = NULL; - QGraphicsScene *scene_selected_border_metatiles = NULL; - QGraphicsScene *scene_collision_metatiles = NULL; - QGraphicsScene *scene_elevation_metatiles = NULL; - MetatilesPixmapItem *metatiles_item = NULL; + QGraphicsScene *scene_metatiles = nullptr; + QGraphicsScene *scene_current_metatile_selection = nullptr; + QGraphicsScene *scene_selected_border_metatiles = nullptr; + QGraphicsScene *scene_collision_metatiles = nullptr; + QGraphicsScene *scene_elevation_metatiles = nullptr; + MetatilesPixmapItem *metatiles_item = nullptr; - BorderMetatilesPixmapItem *selected_border_metatiles_item = NULL; - CurrentSelectedMetatilesPixmapItem *scene_current_metatile_selection_item = NULL; - MovementPermissionsPixmapItem *collision_metatiles_item = NULL; + BorderMetatilesPixmapItem *selected_border_metatiles_item = nullptr; + CurrentSelectedMetatilesPixmapItem *scene_current_metatile_selection_item = nullptr; + MovementPermissionsPixmapItem *collision_metatiles_item = nullptr; - QList *events = NULL; - QList *selected_events = NULL; + QList *events = nullptr; + QList *selected_events = nullptr; bool lastSelectedMetatilesFromMap = false; int copiedMetatileSelectionWidth = 0; int copiedMetatileSelectionHeight = 0; - QList *copiedMetatileSelection = new QList; + QList *copiedMetatileSelection = new QList; QString map_edit_mode; QString prev_edit_mode; @@ -166,9 +166,9 @@ class DraggablePixmapItem : public QObject, public QGraphicsPixmapItem { public: DraggablePixmapItem(QPixmap pixmap): QGraphicsPixmapItem(pixmap) { } - Editor *editor = NULL; - Event *event = NULL; - QGraphicsItemAnimation *pos_anim = NULL; + Editor *editor = nullptr; + Event *event = nullptr; + QGraphicsItemAnimation *pos_anim = nullptr; DraggablePixmapItem(Event *event_, Editor *editor_) : QGraphicsPixmapItem(event_->pixmap) { event = event_; editor = editor_; @@ -257,8 +257,8 @@ class MapPixmapItem : public QObject, public QGraphicsPixmapItem { public: MapPixmapItem(QPixmap pixmap): QGraphicsPixmapItem(pixmap) { } - Map *map = NULL; - Editor *editor = NULL; + Map *map = nullptr; + Editor *editor = nullptr; MapPixmapItem(Map *map_, Editor *editor_) { map = map_; editor = editor_; @@ -335,7 +335,7 @@ public: QPixmap newPixmap = basePixmap.copy(0, 0, basePixmap.width(), basePixmap.height()); if (opacity < 1) { QPainter painter(&newPixmap); - int alpha = (int)(255 * (1 - opacity)); + int alpha = static_cast(255 * (1 - opacity)); painter.fillRect(0, 0, newPixmap.width(), newPixmap.height(), QColor(0, 0, 0, alpha)); painter.end(); } @@ -366,16 +366,16 @@ public: MetatilesPixmapItem(Map *map_) { map = map_; setAcceptHoverEvents(true); - connect(map, SIGNAL(paintTileChanged(Map*)), this, SLOT(paintTileChanged(Map *))); + connect(map, SIGNAL(paintTileChanged()), this, SLOT(paintTileChanged())); } - Map* map = NULL; + Map* map = nullptr; virtual void draw(); private: void updateSelection(QPointF pos); protected: virtual void updateCurHoveredMetatile(QPointF pos); private slots: - void paintTileChanged(Map *map); + void paintTileChanged(); protected: void hoverMoveEvent(QGraphicsSceneHoverEvent*); void hoverLeaveEvent(QGraphicsSceneHoverEvent*); @@ -391,7 +391,7 @@ public: map = map_; setAcceptHoverEvents(true); } - Map* map = NULL; + Map* map = nullptr; virtual void draw(); signals: void borderMetatilesChanged(); @@ -405,7 +405,7 @@ public: CurrentSelectedMetatilesPixmapItem(Map *map_) { map = map_; } - Map* map = NULL; + Map* map = nullptr; virtual void draw(); }; @@ -415,7 +415,7 @@ public: MovementPermissionsPixmapItem(Map *map_): MetatilesPixmapItem(map_) { connect(map, SIGNAL(paintCollisionChanged(Map*)), this, SLOT(paintCollisionChanged(Map *))); } - virtual void pick(uint collision, uint elevation) { + virtual void pick(int collision, int elevation) { map->paint_collision = collision; map->paint_elevation = elevation; draw(); @@ -429,7 +429,7 @@ protected: void mouseReleaseEvent(QGraphicsSceneMouseEvent*); virtual void updateCurHoveredMetatile(QPointF pos); private slots: - void paintCollisionChanged(Map *map) { + void paintCollisionChanged(Map *) { draw(); } }; diff --git a/event.cpp b/event.cpp index a1c6f5e4..ee05ed08 100755 --- a/event.cpp +++ b/event.cpp @@ -142,8 +142,8 @@ QString Event::buildObjectEventMacro(int item_index) { int radius_x = this->getInt("radius_x"); int radius_y = this->getInt("radius_y"); - uint16_t x = this->getInt("x"); - uint16_t y = this->getInt("y"); + uint16_t x = this->getU16("x"); + uint16_t y = this->getU16("y"); QString text = ""; text += QString("\tobject_event %1").arg(item_index + 1); @@ -185,8 +185,8 @@ HealLocation Event::buildHealLocation() catch(...) { hl.index = 0; } - hl.x = this->get("x").toInt(); - hl.y = this->get("y").toInt(); + hl.x = this->getU16("x"); + hl.y = this->getU16("y"); return hl; } diff --git a/event.h b/event.h index fc71e8a7..fcb54d24 100755 --- a/event.h +++ b/event.h @@ -46,6 +46,9 @@ public: int getInt(QString key) { return values.value(key).toInt(nullptr, 0); } + uint16_t getU16(QString key) { + return values.value(key).toUShort(nullptr, 0); + } void put(QString key, int value) { put(key, QString("%1").arg(value)); } diff --git a/heallocation.cpp b/heallocation.cpp index 7652b96a..f611098d 100644 --- a/heallocation.cpp +++ b/heallocation.cpp @@ -1,19 +1,15 @@ #include "heallocation.h" -//HealLocation::HealLocation() {} - -HealLocation::HealLocation(QString map, int i, size_t x0, size_t y0) { - - name = map; - index = i; - x = x0; - y = y0; - +HealLocation::HealLocation(QString map, int i, uint16_t x, uint16_t y) +{ + this->name = map; + this->index = i; + this->x = x; + this->y = y; } -QDebug operator<<(QDebug debug, const HealLocation &hl) { - +QDebug operator<<(QDebug debug, const HealLocation &hl) +{ debug << "HealLocation_" + hl.name << "(" << hl.x << ',' << hl.y << ")"; return debug; - } diff --git a/heallocation.h b/heallocation.h index bf01b30a..14571a3d 100644 --- a/heallocation.h +++ b/heallocation.h @@ -8,15 +8,15 @@ class HealLocation { public: HealLocation()=default; - HealLocation(QString, int, size_t, size_t); + HealLocation(QString, int, uint16_t, uint16_t); friend QDebug operator<<(QDebug debug, const HealLocation &hl); public: //QString group; QString name; int index; - size_t x; - size_t y; + uint16_t x; + uint16_t y; }; diff --git a/mainwindow.cpp b/mainwindow.cpp index 1b05d0f1..be578b65 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -81,8 +81,8 @@ void MainWindow::openProject(QString dir) { setStatusBarMessage(QString("Opening project %1").arg(dir)); bool already_open = ( - (editor != NULL && editor != nullptr) - && (editor->project != NULL && editor->project != nullptr) + (editor && editor != nullptr) + && (editor->project && editor->project != nullptr) && (editor->project->root == dir) ); if (!already_open) { @@ -168,7 +168,7 @@ void MainWindow::setMap(QString map_name) { setWindowTitle(map_name + " - " + editor->project->getProjectTitle() + " - porymap"); connect(editor->map, SIGNAL(mapChanged(Map*)), this, SLOT(onMapChanged(Map *))); - connect(editor->map, SIGNAL(mapNeedsRedrawing(Map*)), this, SLOT(onMapNeedsRedrawing(Map *))); + connect(editor->map, SIGNAL(mapNeedsRedrawing()), this, SLOT(onMapNeedsRedrawing())); connect(editor->map, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusBarMessage(QString))); setRecentMap(map_name); @@ -182,16 +182,16 @@ void MainWindow::redrawMapScene() ui->graphicsView_Map->setScene(editor->scene); ui->graphicsView_Map->setSceneRect(editor->scene->sceneRect()); - ui->graphicsView_Map->setFixedSize(editor->scene->width() + 2, editor->scene->height() + 2); + ui->graphicsView_Map->setFixedSize(static_cast(editor->scene->width()) + 2, static_cast(editor->scene->height()) + 2); ui->graphicsView_Objects_Map->setScene(editor->scene); ui->graphicsView_Objects_Map->setSceneRect(editor->scene->sceneRect()); - ui->graphicsView_Objects_Map->setFixedSize(editor->scene->width() + 2, editor->scene->height() + 2); + ui->graphicsView_Objects_Map->setFixedSize(static_cast(editor->scene->width()) + 2, static_cast(editor->scene->height()) + 2); ui->graphicsView_Objects_Map->editor = editor; ui->graphicsView_Connections->setScene(editor->scene); ui->graphicsView_Connections->setSceneRect(editor->scene->sceneRect()); - ui->graphicsView_Connections->setFixedSize(editor->scene->width() + 2, editor->scene->height() + 2); + ui->graphicsView_Connections->setFixedSize(static_cast(editor->scene->width()) + 2, static_cast(editor->scene->height()) + 2); ui->graphicsView_Metatiles->setScene(editor->scene_metatiles); //ui->graphicsView_Metatiles->setSceneRect(editor->scene_metatiles->sceneRect()); @@ -508,7 +508,6 @@ void MainWindow::on_mapList_activated(const QModelIndex &index) if (!data.isNull()) { setMap(data.toString()); } - //updateMapList(); } void MainWindow::markAllEdited(QAbstractItemModel *model) { @@ -652,18 +651,17 @@ void MainWindow::on_actionMap_Shift_triggered() void MainWindow::scaleMapView(int s) { editor->map->scale_exp += s; - double base = (double)editor->map->scale_base; + double base = editor->map->scale_base; double exp = editor->map->scale_exp; double sfactor = pow(base,s); ui->graphicsView_Map->scale(sfactor,sfactor); ui->graphicsView_Objects_Map->scale(sfactor,sfactor); - ui->graphicsView_Map->setFixedSize((editor->scene->width() + 2) * pow(base,exp), - (editor->scene->height() + 2) * pow(base,exp)); - - ui->graphicsView_Objects_Map->setFixedSize((editor->scene->width() + 2) * pow(base,exp), - (editor->scene->height() + 2) * pow(base,exp)); + int width = static_cast((editor->scene->width() + 2) * pow(base,exp)); + int height = static_cast((editor->scene->height() + 2) * pow(base,exp)); + ui->graphicsView_Map->setFixedSize(width, height); + ui->graphicsView_Objects_Map->setFixedSize(width, height); } void MainWindow::addNewEvent(QString event_type) @@ -680,7 +678,7 @@ void MainWindow::addNewEvent(QString event_type) // Should probably just pass layout and let the editor work it out void MainWindow::updateSelectedObjects() { QList *all_events = editor->getObjects(); - QList *events = NULL; + QList *events = nullptr; if (editor->selected_events && editor->selected_events->length()) { events = editor->selected_events; @@ -1054,7 +1052,7 @@ void MainWindow::onMapChanged(Map *map) { updateMapList(); } -void MainWindow::onMapNeedsRedrawing(Map *map) { +void MainWindow::onMapNeedsRedrawing() { redrawMapScene(); } @@ -1168,7 +1166,7 @@ void MainWindow::on_pushButton_clicked() if (dialog.exec() == QDialog::Accepted) { editor->map->setDimensions(widthSpinBox->value(), heightSpinBox->value()); editor->map->commit(); - onMapNeedsRedrawing(editor->map); + onMapNeedsRedrawing(); } } diff --git a/mainwindow.h b/mainwindow.h index b020ee52..c2f26b89 100755 --- a/mainwindow.h +++ b/mainwindow.h @@ -41,7 +41,7 @@ private slots: void onLoadMapRequested(QString, QString); void onMapChanged(Map *map); - void onMapNeedsRedrawing(Map *map); + void onMapNeedsRedrawing(); void on_action_Save_triggered(); void on_tabWidget_2_currentChanged(int index); diff --git a/map.cpp b/map.cpp index 626724f2..721d4b17 100755 --- a/map.cpp +++ b/map.cpp @@ -14,7 +14,7 @@ Map::Map(QObject *parent) : QObject(parent) paint_elevation = 3; selected_metatiles_width = 1; selected_metatiles_height = 1; - selected_metatiles = new QList; + selected_metatiles = new QList; selected_metatiles->append(1); } @@ -64,11 +64,11 @@ int Map::getHeight() { return layout->height.toInt(nullptr, 0); } -int Map::getSelectedBlockIndex(int index) { +uint16_t Map::getSelectedBlockIndex(int index) { if (index < layout->tileset_primary->metatiles->length()) { - return index; + return static_cast(index); } else { - return 0x200 + (index - layout->tileset_primary->metatiles->length()); + return 0x200 + static_cast(index - layout->tileset_primary->metatiles->length()); } } @@ -92,24 +92,19 @@ QImage Map::getCollisionMetatileImage(int collision, int elevation) { } bool Map::blockChanged(int i, Blockdata *cache) { - if (cache == NULL || cache == nullptr) { + if (!cache) return true; - } - if (layout->blockdata == NULL || layout->blockdata == nullptr) { + if (!layout->blockdata) return true; - } - if (cache->blocks == NULL || cache->blocks == nullptr) { + if (!cache->blocks) return true; - } - if (layout->blockdata->blocks == NULL || layout->blockdata->blocks == nullptr) { + if (!layout->blockdata->blocks) return true; - } - if (cache->blocks->length() <= i) { + if (cache->blocks->length() <= i) return true; - } - if (layout->blockdata->blocks->length() <= i) { + if (layout->blockdata->blocks->length() <= i) return true; - } + return layout->blockdata->blocks->value(i) != cache->blocks->value(i); } @@ -389,13 +384,12 @@ void Map::setDimensions(int newWidth, int newHeight, bool setNewBlockdata) { Block* Map::getBlock(int x, int y) { if (layout->blockdata && layout->blockdata->blocks) { - if (x >= 0 && x < getWidth()) - if (y >= 0 && y < getHeight()) { + if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) { int i = y * getWidth() + x; return new Block(layout->blockdata->blocks->value(i)); } } - return NULL; + return nullptr; } void Map::_setBlock(int x, int y, Block block) { @@ -405,7 +399,7 @@ void Map::_setBlock(int x, int y, Block block) { } } -void Map::_floodFillCollision(int x, int y, uint collision) { +void Map::_floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation) { QList todo; todo.append(QPoint(x, y)); while (todo.length()) { @@ -413,79 +407,16 @@ void Map::_floodFillCollision(int x, int y, uint collision) { x = point.x(); y = point.y(); Block *block = getBlock(x, y); - if (block == NULL) { + if (!block) { continue; } - uint old_coll = block->collision; - if (old_coll == collision) { - continue; - } - block->collision = collision; - _setBlock(x, y, *block); - if ((block = getBlock(x + 1, y)) && block->collision == old_coll) { - todo.append(QPoint(x + 1, y)); - } - if ((block = getBlock(x - 1, y)) && block->collision == old_coll) { - todo.append(QPoint(x - 1, y)); - } - if ((block = getBlock(x, y + 1)) && block->collision == old_coll) { - todo.append(QPoint(x, y + 1)); - } - if ((block = getBlock(x, y - 1)) && block->collision == old_coll) { - todo.append(QPoint(x, y - 1)); - } - } -} -void Map::_floodFillElevation(int x, int y, uint elevation) { - QList todo; - todo.append(QPoint(x, y)); - while (todo.length()) { - QPoint point = todo.takeAt(0); - x = point.x(); - y = point.y(); - Block *block = getBlock(x, y); - if (block == NULL) { - continue; - } - uint old_z = block->elevation; - if (old_z == elevation) { - continue; - } - Block block_(*block); - block_.elevation = elevation; - _setBlock(x, y, block_); - if ((block = getBlock(x + 1, y)) && block->elevation == old_z) { - todo.append(QPoint(x + 1, y)); - } - if ((block = getBlock(x - 1, y)) && block->elevation == old_z) { - todo.append(QPoint(x - 1, y)); - } - if ((block = getBlock(x, y + 1)) && block->elevation == old_z) { - todo.append(QPoint(x, y + 1)); - } - if ((block = getBlock(x, y - 1)) && block->elevation == old_z) { - todo.append(QPoint(x, y - 1)); - } - } -} - -void Map::_floodFillCollisionElevation(int x, int y, uint collision, uint elevation) { - QList todo; - todo.append(QPoint(x, y)); - while (todo.length()) { - QPoint point = todo.takeAt(0); - x = point.x(); - y = point.y(); - Block *block = getBlock(x, y); - if (block == NULL) { - continue; - } uint old_coll = block->collision; uint old_elev = block->elevation; if (old_coll == collision && old_elev == elevation) { continue; } + block->collision = collision; block->elevation = elevation; _setBlock(x, y, *block); @@ -515,7 +446,7 @@ void Map::undo() { if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight()) { this->setDimensions(commit->layoutWidth, commit->layoutHeight, false); - emit mapNeedsRedrawing(this); + emit mapNeedsRedrawing(); } emit mapChanged(this); @@ -532,7 +463,7 @@ void Map::redo() { if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight()) { this->setDimensions(commit->layoutWidth, commit->layoutHeight, false); - emit mapNeedsRedrawing(this); + emit mapNeedsRedrawing(); } emit mapChanged(this); @@ -562,22 +493,7 @@ void Map::setBlock(int x, int y, Block block) { } } -void Map::floodFillCollision(int x, int y, uint collision) { - Block *block = getBlock(x, y); - if (block && block->collision != collision) { - _floodFillCollision(x, y, collision); - commit(); - } -} - -void Map::floodFillElevation(int x, int y, uint elevation) { - Block *block = getBlock(x, y); - if (block && block->elevation != elevation) { - _floodFillElevation(x, y, elevation); - commit(); - } -} -void Map::floodFillCollisionElevation(int x, int y, uint collision, uint elevation) { +void Map::floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation) { Block *block = getBlock(x, y); if (block && (block->collision != collision || block->elevation != elevation)) { _floodFillCollisionElevation(x, y, collision, elevation); @@ -620,7 +536,7 @@ void Map::clearHoveredTile() { } void Map::hoveredMetatileChanged(int blockIndex) { - int tile = getSelectedBlockIndex(blockIndex); + uint16_t tile = getSelectedBlockIndex(blockIndex); emit statusBarMessage(QString("Metatile: 0x%1") .arg(QString("%1").arg(tile, 3, 16, QChar('0')).toUpper())); } @@ -655,7 +571,7 @@ void Map::setSelectedMetatilesFromTilePicker() { this->selected_metatiles->clear(); for (int j = 0; j < this->paint_tile_height; j++) { for (int i = 0; i < this->paint_tile_width; i++) { - int metatile = this->getSelectedBlockIndex(this->paint_tile_index + i + (j * 8)); + uint16_t metatile = this->getSelectedBlockIndex(this->paint_tile_index + i + (j * 8)); this->selected_metatiles->append(metatile); } } diff --git a/map.h b/map.h index b41c97c4..f2e1ff2d 100755 --- a/map.h +++ b/map.h @@ -14,9 +14,9 @@ class HistoryItem { public: Blockdata *metatiles; - short layoutWidth; - short layoutHeight; - HistoryItem(Blockdata *metatiles_, short layoutWidth_, short layoutHeight_) { + int layoutWidth; + int layoutHeight; + HistoryItem(Blockdata *metatiles_, int layoutWidth_, int layoutHeight_) { this->metatiles = metatiles_; this->layoutWidth = layoutWidth_; this->layoutHeight = layoutHeight_; @@ -150,7 +150,7 @@ public: static QString bgEventsLabelFromName(QString mapName); int getWidth(); int getHeight(); - int getSelectedBlockIndex(int); + uint16_t getSelectedBlockIndex(int); int getDisplayedBlockIndex(int); QPixmap render(bool ignoreCache); QPixmap renderMetatiles(); @@ -180,20 +180,16 @@ public: int paint_tile_initial_y; int selected_metatiles_width; int selected_metatiles_height; - QList *selected_metatiles = NULL; - int paint_collision; - int paint_elevation; + QList *selected_metatiles = nullptr; + uint16_t paint_collision; + uint16_t paint_elevation; Block *getBlock(int x, int y); void setBlock(int x, int y, Block block); void _setBlock(int x, int y, Block block); - void floodFillCollision(int x, int y, uint collision); - void _floodFillCollision(int x, int y, uint collision); - void floodFillElevation(int x, int y, uint elevation); - void _floodFillElevation(int x, int y, uint elevation); - void floodFillCollisionElevation(int x, int y, uint collision, uint elevation); - void _floodFillCollisionElevation(int x, int y, uint collision, uint elevation); + void floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation); + void _floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation); History history; void undo(); @@ -223,10 +219,10 @@ public: void setSelectedMetatilesFromTilePicker(); signals: - void paintTileChanged(Map *map); + void paintTileChanged(); void paintCollisionChanged(Map *map); void mapChanged(Map *map); - void mapNeedsRedrawing(Map *map); + void mapNeedsRedrawing(); void statusBarMessage(QString); public slots: diff --git a/parseutil.cpp b/parseutil.cpp index 15c24b16..4ff232f6 100755 --- a/parseutil.cpp +++ b/parseutil.cpp @@ -78,7 +78,7 @@ QList* ParseUtil::parseHealLocs(QString text) { for (auto line : lines){ if (line.contains("MAP_GROUP")){ QList li = line.replace(" ","").chopped(2).remove('{').split(','); - HealLocation hloc = HealLocation(li[1].remove("MAP_NUM(").remove(")"), i, li[2].toInt(), li[3].toInt()); + HealLocation hloc = HealLocation(li[1].remove("MAP_NUM(").remove(")"), i, li[2].toUShort(), li[3].toUShort()); parsed->append(hloc); i++; } diff --git a/project.cpp b/project.cpp index 5bd0d2bb..b01d6aa5 100755 --- a/project.cpp +++ b/project.cpp @@ -267,7 +267,6 @@ void Project::updateMapsWithConnections(Map *map) { } void Project::readMapLayoutsTable() { - int curIndex = 1; QString layoutsText = readTextFile(getMapLayoutsTableFilepath()); QList* values = parseAsm(layoutsText); bool inLayoutPointers = false; @@ -311,7 +310,7 @@ QStringList* Project::readLayoutValues(QString layoutLabel) { QString layoutText = readTextFile(getMapLayoutFilepath(layoutLabel)); if (layoutText.isNull()) { - return NULL; + return nullptr; } QStringList *layoutValues = getLabelValues(parser->parseAsm(layoutText), layoutLabel); @@ -326,7 +325,7 @@ QStringList* Project::readLayoutValues(QString layoutLabel) { if (layoutValues->size() != 8) { qDebug() << "Error: Unexpected number of properties in layout '" << layoutLabel << "'"; - return NULL; + return nullptr; } return layoutValues; @@ -340,7 +339,7 @@ void Project::readMapLayout(Map* map) { MapLayout *layout; if (!mapLayouts.contains(map->layout_label)) { QStringList *layoutValues = readLayoutValues(map->layout->label); - if (layoutValues == NULL) { + if (!layoutValues) { return; } @@ -372,7 +371,7 @@ void Project::readAllMapLayouts() { for (int i = 0; i < mapLayoutsTable.size(); i++) { QString layoutLabel = mapLayoutsTable[i]; QStringList *layoutValues = readLayoutValues(layoutLabel); - if (layoutValues == NULL) { + if (!layoutValues) { return; } @@ -885,7 +884,7 @@ Blockdata* Project::readBlockdata(QString path) { if (file.open(QIODevice::ReadOnly)) { QByteArray data = file.readAll(); for (int i = 0; (i + 1) < data.length(); i += 2) { - uint16_t word = (data[i] & 0xff) + ((data[i + 1] & 0xff) << 8); + uint16_t word = static_cast((data[i] & 0xff) + ((data[i + 1] & 0xff) << 8)); blockdata->addBlock(word); } } else { diff --git a/tileset.cpp b/tileset.cpp index 1e73708f..7538075c 100755 --- a/tileset.cpp +++ b/tileset.cpp @@ -72,9 +72,9 @@ Metatile* Metatile::getMetatile(int index, Tileset *primaryTileset, Tileset *sec Tileset *tileset = Metatile::getBlockTileset(index, primaryTileset, secondaryTileset); int local_index = Metatile::getBlockIndex(index); if (!tileset || !tileset->metatiles) { - return NULL; + return nullptr; } - Metatile *metatile = tileset->metatiles->value(local_index, NULL); + Metatile *metatile = tileset->metatiles->value(local_index, nullptr); return metatile; }