From 58ba349f19f98fe3af5332188f5d3dfe4d076807 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 19 Apr 2011 23:03:50 +0200 Subject: nicer method of ending rounds --- pacman-c++/server.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'pacman-c++/server.cpp') diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index f2c0f1c..72ee995 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp @@ -31,7 +31,7 @@ bool Server::run() if (!waitForClientConnections()) return false; - initRoundMap(true); + initRoundMap(); m_tickTimer = new QTimer(this); connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); @@ -484,6 +484,7 @@ void Server::keyPressUpdate() void Server::onRoundFinished() { + // TODO: call this when a pacman get's eaten foreach(Actor *actor, m_actors) actor->finishRound(); @@ -495,8 +496,10 @@ void Server::onRoundFinished() m_tickTimer->stop(); } -void Server::initRoundMap(bool firstPacket) +void Server::initRoundMap() { + /* delete actors first */ + removeActors(); /* create new map */ Transmission::map_t map = Util::createDemoMap(); @@ -516,12 +519,11 @@ void Server::initRoundMap(bool firstPacket) } updateMap(map); - sendUpdate(map, firstPacket); + sendUpdate(map, true); Util::deleteMap(map); map = NULL; - if (firstPacket) - connect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished())); + connect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished()), Qt::UniqueConnection); } bool Server::parseCommandline() -- cgit v1.2.3