From b6fec20dadaf71fc28961a4a6d720d1d665508e8 Mon Sep 17 00:00:00 2001 From: totycro Date: Tue, 19 Apr 2011 19:48:26 +0200 Subject: Added number of rounds parameter (unused) --- pacman-c++/server.cpp | 19 ++++++++++++++++++- pacman-c++/server.h | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'pacman-c++') diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index 07e4c72..4051807 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp @@ -11,7 +11,7 @@ Server::Server(QWidget *parent) : SceneHolder(parent), m_bindaddress(QHostAddress::Any), - m_port(Constants::Networking::port), m_numbots(0) + m_port(Constants::Networking::port), m_rounds(3), m_numbots(0), m_curRound(0) { /* determine max players by using order array */ for(m_maxplayers = 0; Color::order[m_maxplayers] != Color::none; ++m_maxplayers); @@ -26,6 +26,7 @@ bool Server::run() qDebug() << "[Server] Running server..."; qDebug() << "[Server] Max players:" << m_maxplayers; + qDebug() << "[Server] Number of rounds:" << m_rounds; qDebug() << "[Server] Number of bots:" << m_numbots; if (!waitForClientConnections()) return false; @@ -535,6 +536,10 @@ bool Server::parseCommandline() out << " --nocolorblocks" << endl << " Disable random colorized blocks" << endl << endl; + opt.setOption("rounds", 'r'); + out << " -r, --rounds [1..n]" << endl + << " Number of rounds to play" << endl + << endl; opt.setFlag("nocolorblocks"); out << " -h, --help" << endl << " Prints this help message" << endl; @@ -603,6 +608,18 @@ bool Server::parseCommandline() m_numbots = numbots; } + if (opt.getValue("rounds") != NULL) + { + bool ok; + unsigned int rounds = QString(opt.getValue("rounds")).toUInt(&ok); + if (!ok || rounds == 0) + { + qCritical() << "Invalid number of rounds: " << opt.getValue("rounds") << endl; + return false; + } + m_rounds = rounds; + } + this->setProperty("coloredblocks", !opt.getFlag("nocolorblocks")); return true; diff --git a/pacman-c++/server.h b/pacman-c++/server.h index 826c701..fd1b571 100644 --- a/pacman-c++/server.h +++ b/pacman-c++/server.h @@ -56,7 +56,11 @@ protected: QHostAddress m_bindaddress; unsigned int m_port; unsigned int m_maxplayers; + unsigned int m_rounds; // number of rounds (>= 1) unsigned int m_numbots; + + unsigned int m_curRound; // current round starting with 0 + }; #endif // SERVER_H -- cgit v1.2.3