summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-08-03 16:08:51 +0200
committerSimon Rettberg2018-08-03 16:08:51 +0200
commit5b2c7bbd4a628469bab4cbf7468067855e21e784 (patch)
tree36450010f0dd9e2472b2603f8df6163468e66392
parent[server] Fix reload room button size (diff)
downloadpvs2-5b2c7bbd4a628469bab4cbf7468067855e21e784.tar.gz
pvs2-5b2c7bbd4a628469bab4cbf7468067855e21e784.tar.xz
pvs2-5b2c7bbd4a628469bab4cbf7468067855e21e784.zip
[server] Fix snap to grid for call with ignored frame param
-rw-r--r--src/server/mainwindow/mainwindow.cpp19
-rw-r--r--src/server/mainwindow/mainwindow.h2
2 files changed, 3 insertions, 18 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 17bfdb2..ec69a4c 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -220,7 +220,7 @@ MainWindow::~MainWindow()
}
/** Squared euclidean distance (why is this not implemented in QPoint?) */
-int distance(QPoint a, QPoint b)
+static int distance(QPoint a, QPoint b)
{
const int dx = a.x() - b.x();
const int dy = a.y() - b.y();
@@ -228,14 +228,6 @@ int distance(QPoint a, QPoint b)
return sum;
}
-int distance(QPointF a, QPointF b)
-{
- const qreal dx = a.x() - b.x();
- const qreal dy = a.y() - b.y();
- const qreal sum = dx * dx + dy * dy;
- return int(sum);
-}
-
/**
* \brief: find the closest available frame.
*
@@ -249,16 +241,9 @@ int distance(QPointF a, QPointF b)
* @param toIgnore, ignore this connectionframe when considering free slots
* @return the free slot
*/
-QPoint MainWindow::closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIgnore)
+QPoint MainWindow::closestFreeSlot(const QPoint preferredPixels, const ConnectionFrame* toIgnore)
{
const bool pickFirstOne = ( preferredPixels == QPoint(-1, -1) );
- if (!pickFirstOne && toIgnore != nullptr) {
- // Check if we're already in the desired location and skip all the checks
- QPoint desired = QPoint(preferredPixels.x() / getTileWidthPx(), preferredPixels.y() / getTileHeightPx());
- if (desired == toIgnore->getGridPosition()) {
- return desired;
- }
- }
const QSize& clientSize = serverApp->getCurrentRoom()->clientSize;
#define GRID(X,Y) (grid[((X) * _tilesY) + (Y)])
bool *grid = new bool[_tilesX * _tilesY];
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index a8bf974..86499af 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -75,7 +75,7 @@ private:
int _lastClientCount;
- QPoint closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIgnore);
+ QPoint closestFreeSlot(const QPoint preferredPixels, const ConnectionFrame* toIgnore);
void placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred = QPoint(-1, -1));
ConnectionFrame* createFrame(const QString &computerId = QString(), const QPoint *gridPosition = nullptr, bool fromRoomplan = false);
void savePosition(ConnectionFrame *cf);