void Data::deleteRoom(int id, bool refresh) { if (this->m_modifyReply) delete this->m_modifyReply; QUrl url = QUrl("http://szektam2.byethost3.com/deleteRoom.php"); PARAMS params; params.addQueryItem("username", Key::username()); params.addQueryItem("password", Key::password()); params.addQueryItem("id", QString::number(id)); QByteArray data; #if QT5 data.append(params.toString()); url.setQuery(params); #else data.append(params.encodedQuery()); #endif QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); this->m_modifyReply = this->m_manager->post(request, data); if (refresh) connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getRooms())); //connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(readReady())); }
void Data::modifyRooms(const QList<RoomData> &rds) { int n = rds.size(); if (n <= 0) return; if (this->m_modifyReply) delete this->m_modifyReply; QUrl url = QUrl("http://szektam2.byethost3.com/modifyRooms.php"); PARAMS params; params.addQueryItem("username", Key::username()); params.addQueryItem("password", Key::password()); params.addQueryItem("n", QString::number(n)); for (int i = 0; i < n; ++i) { const RoomData rd = rds[i]; params.addQueryItem(QString("id%1").arg(i), QString::number(rd.id)); params.addQueryItem(QString("name%1").arg(i), rd.name); params.addQueryItem(QString("shortName%1").arg(i), rd.shortName); params.addQueryItem(QString("chairs%1").arg(i), QString::number(rd.chairs)); } QByteArray data; #if QT5 data.append(params.toString()); url.setQuery(params); #else data.append(params.encodedQuery()); #endif QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); this->m_modifyReply = this->m_manager->post(request, data); connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getRooms())); //connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(readReady())); }
Room* House::getRoom(Floor* tile) { for (Room * room : getRooms()) { if (room->contains(tile)) { return room; } } return NULL; }
void * RoomManager::getMaxFilledRoom(char type) { Room ** rArr = (Room **)getRooms(type); Room * r = NULL; int id = -1; int curCount = -1; for (int i = 0; i < MAX_ONE_TYPE_ROOMS; i++) { r = rArr[i]; if (r->isOpen) if (r->curPlayersCount > curCount) { curCount = r->curPlayersCount; id = i; } } if (id < 0) return (void *)NULL; else return (void *)(rArr[id]); }