From c984899f52f11d7148785c9a6cb377b23da87228 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Thu, 19 May 2016 15:55:02 +0200 Subject: Closes bug #2807. (And also cleans the code (a bit)) --- src/server/mainwindow/mainwindow.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index c21f2d6..453c8e0 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -190,7 +190,8 @@ float distance(QPoint a, QPoint b) { void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred) { qDebug() << "placeFrameInFreeSlot(preferred = " << preferred << ")"; - const QSize& clientSize = Global::getRooms()[Global::getCurrentRoom()]->clientSize; + const QSize& clientSize = Global::getCurrentRoom()->clientSize; + // TODO: Fix this qDebug() << "clientSize: " << &clientSize /* Get occupied cell of each frame and store status in an array */ bool grid[_tilesX][_tilesY]; memset(grid, 0, sizeof(bool) * _tilesX * _tilesY); // set everything to false @@ -222,7 +223,6 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred) } if (isFree) { QPoint freePos(x,y); - qDebug() << "found free: " << freePos; freePositions.push_back(freePos); } } @@ -252,8 +252,8 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred) ConnectionFrame* MainWindow::createFrame() { // Allocate and resize - int width = getTileWidthPx() * Global::getRooms()[Global::getCurrentRoom()]->clientSize.width(); - int height= getTileHeightPx() * Global::getRooms()[Global::getCurrentRoom()]->clientSize.height(); + int width = getTileWidthPx() * Global::getCurrentRoom()->clientSize.width(); + int height= getTileHeightPx() * Global::getCurrentRoom()->clientSize.height(); ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, width, height); _clientFrames.append(cf); @@ -272,7 +272,7 @@ ConnectionFrame* MainWindow::createFrame() ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint pxCoord, QPoint gridPosition) { // Allocate and resize - Room* room = Global::getRooms()[Global::getCurrentRoom()]; + const Room* room = Global::getCurrentRoom(); qDebug() << "createFrame, access room: " << room; int width = getTileWidthPx() * (room == NULL ? 1 : room->clientSize.width()); int height = getTileHeightPx() * (room == NULL ? 1 : room->clientSize.height()); @@ -562,11 +562,12 @@ AspectStatus checkAspectRatio(const QSize& frameSize, const QSize& gridSize) { */ void MainWindow::resizeEvent(QResizeEvent* e) { - Room* room = Global::getRooms()[Global::getCurrentRoom()]; + const Room* room = Global::getCurrentRoom(); + const QSize& clientSize = room->clientSize; - - if (room == NULL) {return; } /* Nothing to do here */ - QSize& clientSize = room->clientSize; + // TODO: Do I still need this? + // if (room == NULL) {return; } /* Nothing to do here */ + // QSize& clientSize = room->clientSize; if (ui->frmRoom->size().width() < 100 || ui->frmRoom->size().height() < 100 || _tilesX <= 0 || _tilesY <= 0) { return; } QSize newGridSize = room->gridSize; @@ -895,7 +896,7 @@ void MainWindow::onReloadRoomOk() } /* load background image */ - QString imgPath = Global::getRooms()[Global::getCurrentRoom()]->imagePath; + QString imgPath = Global::getCurrentRoom()->imagePath; if (imgPath == "") { /* set empty pixmap*/ QPixmap empty; -- cgit v1.2.3-55-g7522