From ff536f6d76acd8a7daaf0a8ca27c2ec3f0f42be9 Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 11 Apr 2011 13:17:27 +0200 Subject: create and use Constants::server --- pacman-c++/audio.cpp | 26 ++++++++++++++------------ pacman-c++/constants.h | 7 +++++-- pacman-c++/server.cpp | 4 +++- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/pacman-c++/audio.cpp b/pacman-c++/audio.cpp index d74445a..8726899 100644 --- a/pacman-c++/audio.cpp +++ b/pacman-c++/audio.cpp @@ -1,4 +1,5 @@ #include "audio.h" +#include "constants.h" #include #include #include @@ -13,18 +14,19 @@ bool AudioManager::m_working = false; AudioManager::AudioManager() : m_muted(true) { -#ifdef SERVER - qDebug() << "Server has no sound" -#else - preload(); - - AudioPlayer *firstplayer = new AudioPlayer(this); - firstplayer->test(m_sounds[Sound::WakaWaka]); - m_working = firstplayer->m_working; - m_players.append(firstplayer); - - m_muted = false; -#endif // SERVER + if (Constants::server) + qDebug() << "Server has no sound"; + else + { + preload(); + + AudioPlayer *firstplayer = new AudioPlayer(this); + firstplayer->test(m_sounds[Sound::WakaWaka]); + m_working = firstplayer->m_working; + m_players.append(firstplayer); + + m_muted = false; + } } AudioManager *AudioManager::self() diff --git a/pacman-c++/constants.h b/pacman-c++/constants.h index aacc964..90963fe 100644 --- a/pacman-c++/constants.h +++ b/pacman-c++/constants.h @@ -15,13 +15,16 @@ namespace Constants { const unsigned int sprite_margin = 2; const unsigned int sprite_offset = 20; const unsigned int tick = 250; // ms + static bool server = false; - namespace Networking { + namespace Networking + { const unsigned int port = 7321; const unsigned int connection_timeout = 3000; } - namespace Game { + namespace Game + { const unsigned int bonus_point_value = 100; const unsigned int point_value = 10; } diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index 4656238..18ec8fa 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp @@ -9,6 +9,7 @@ Server::Server(QWidget *parent) : SceneHolder(parent) { + qDebug() << "waiting for clients"; waitForClientConnections(); qDebug() << "clients connected"; @@ -193,6 +194,7 @@ void Server::keyPressUpdate() } } + int main(int argc, char ** argv) { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -203,7 +205,7 @@ int main(int argc, char ** argv) qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); + Constants::server = true; Server Server; - return app.exec(); } -- cgit v1.2.3