Releases: artcfox/maze-generator
Experimental Win32 build
I had never compiled or tested it on Windows, but someone requested it in a comment on my YouTube video, and after some trial and error, I was able to compile it for Windows under Debian Linux using wine qt-opensource-windows-x86-mingw48_opengl-5.2.1.exe, but I had to make a few code changes to the code so it would compile. I had to run wine regedit and edit the PATH under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment to include the Qt bin directory C:\Qt\Qt5.2.1\5.2.1\mingw48_32\bin; and then I could run wine windeployqt.exe MazeGenerator.exe and then combine that dir with the DLLs it was linked to in order to get an executable that could run on Windows. There might be an easier way, but this is what I could quickly hack together.
These are the code changes I needed to make in order to get it to build for Windows:
diff --git a/Maze.c b/Maze.c
old mode 100755
new mode 100644
index c094d2e..5749daf
--- a/Maze.c
+++ b/Maze.c
@@ -71,7 +71,7 @@ MazeRef Maze_create(uint32_t *dims, uint32_t length, MazeCreateFlags flags) {
m->solution[i] = BitArray_create(m->totalPositions, false);
}
- srandom(time(0));
+ srand(time(0));
return m;
}
@@ -134,7 +134,7 @@ void Maze_generate(MazeRef m) {
m->needsNeighborCountRefreshed = false;
while (knockedOutWalls < m->totalPositions - 1) {
- uint32_t r = (uint32_t)( (float)(lotteryExtent - knockedOutWalls) * random() / (RAND_MAX + 1.0) ) + knockedOutWalls;
+ uint32_t r = (uint32_t)( (float)(lotteryExtent - knockedOutWalls) * rand() / (RAND_MAX + 1.0) ) + knockedOutWalls;
int32_t root1 = DisjSets_find(m->sets, m->lottery[r].cell1);
int32_t root2 = DisjSets_find(m->sets, m->lottery[r].cell2);
if (root1 != root2) {
@@ -152,7 +152,7 @@ void Maze_generate(MazeRef m) {
}
} else {
while (knockedOutWalls < m->totalPositions - 1) {
- uint32_t r = (uint32_t)( (float)(lotteryExtent - knockedOutWalls) * random() / (RAND_MAX + 1.0) ) + knockedOutWalls;
+ uint32_t r = (uint32_t)( (float)(lotteryExtent - knockedOutWalls) * rand() / (RAND_MAX + 1.0) ) + knockedOutWalls;
int root1 = DisjSets_find(m->sets, m->lottery[r].cell1);
int root2 = DisjSets_find(m->sets, m->lottery[r].cell2);
if (root1 != root2) {
diff --git a/MazeGenerator.pro b/MazeGenerator.pro
index 22917c7..68510bc 100644
--- a/MazeGenerator.pro
+++ b/MazeGenerator.pro
@@ -5,8 +5,10 @@
#-------------------------------------------------
QT += core gui printsupport
-QMAKE_LFLAGS = -no-pie
-
+#QMAKE_LFLAGS = -no-pie
+CONFIG += c++11
+QMAKE_CXXFLAGS += -std=c++11
+QMAKE_CFLAGS += -std=c11
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MazeGenerator
diff --git a/dragscrollarea.h b/dragscrollarea.h
index ef3e4c3..40bd76e 100644
--- a/dragscrollarea.h
+++ b/dragscrollarea.h
@@ -22,7 +22,7 @@ public:
NoDrag,
ScrollHandDrag
};
- Q_ENUM(DragMode)
+ //Q_ENUM(DragMode)
explicit DragScrollArea(QWidget *parent = nullptr);
diff --git a/mazewidget.cpp b/mazewidget.cpp
index 75899b0..7800661 100644
--- a/mazewidget.cpp
+++ b/mazewidget.cpp
@@ -501,9 +501,9 @@ void MazeWidget::paintSolution(QPainter *painter, const QRect &rect)
void MazeWidget::printMaze()
{
QPrinter printer;
- printer.setResolution(600);
- printer.setPageMargins(QMarginsF(0.25, 0.25, 0.25, 0.25), QPageLayout::Inch);
- printer.setPageSize(QPageSize(QPageSize::Letter));
+ //printer.setResolution(600);
+ //printer.setPageMargins(QMarginsF(0.25, 0.25, 0.25, 0.25), QPageLayout::Inch);
+ //printer.setPageSize(QPageSize(QPageSize::Letter));
if (QPrintDialog(&printer).exec() == QDialog::Accepted) {
QPainter painter;