Skip to content

Commit

Permalink
CRITICAL: Fixed tile combination code
Browse files Browse the repository at this point in the history
  • Loading branch information
MightyPrinny committed Dec 3, 2021
1 parent 0a8409f commit e20db9b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/plugins/gmx/gmxplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ bool GmxPlugin::write(const Map *map, const QString &fileName)
stream.writeStartElement("tiles");
int depthOff = 0;
int layerCount = 0;
std::unordered_map <ulong, QPoint> processedTiles;
std::unordered_map <long, QPoint> processedTiles;
processedTiles.reserve((map->width()*map->height())/2);


Expand Down Expand Up @@ -1388,7 +1388,7 @@ bool GmxPlugin::write(const Map *map, const QString &fileName)
&& (tile->width() == map->tileWidth()) && (tile->height() == map->tileHeight()))
{
int maxCheckXOff = tstColumns-1 - xInTilesetGrid;
int maxCheckYOff= tstRows-1 - yInTilesetGrid;
int maxCheckYOff = tstRows-1 - yInTilesetGrid;

int combineXRight = 0;
int combineYBottom = 0;
Expand Down Expand Up @@ -1429,6 +1429,7 @@ bool GmxPlugin::write(const Map *map, const QString &fileName)
&& (sTileYInGrid == (yInTilesetGrid + checkY)))
{
currentArea = ((checkX+1)*(checkY+1));

acceptedTile = true;
if(currentArea > combineArea)
{
Expand All @@ -1444,11 +1445,16 @@ bool GmxPlugin::write(const Map *map, const QString &fileName)
rowJump = false;
if(!acceptedTile)
{
if(checkX > 0)
maxCheckXOff = checkX-1;
else
maxCheckXOff = 0;
if(!prevAccepted)
{
maxCheckXOff = -1;
maxCheckYOff = -1;
}

prevAccepted = false;
break;
}
Expand Down Expand Up @@ -1496,7 +1502,7 @@ bool GmxPlugin::write(const Map *map, const QString &fileName)
{
pixelX += map->tileWidth();
}
qDebug() << tile->width();

}
if(tile->height() > map->tileHeight())
{
Expand All @@ -1507,7 +1513,7 @@ bool GmxPlugin::write(const Map *map, const QString &fileName)
{
pixelY += map->tileHeight();
}
qDebug() << tile->height();

}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/tiled/tilesetdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QCoreApplication>
#include <QFileInfo>
#include <QUndoStack>
#include <preferences.h>

namespace Tiled {
namespace Internal {
Expand Down
2 changes: 1 addition & 1 deletion tiled.qbs.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.0, 2021-12-02T22:48:41. -->
<!-- Written by QtCreator 4.10.0, 2021-12-02T22:52:40. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down

0 comments on commit e20db9b

Please sign in to comment.