diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 5e220d4a8..996afd588 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -39,6 +39,7 @@ #include #include "core_data.h" #include "font_text.h" +//#include "sound.h" //#include "unicode/uclean.h" // For gcc backtrace on crash! @@ -2534,6 +2535,8 @@ int glestMain(int argc, char** argv) { config.setString("FactorySound","None"); if(hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) { Logger::getInstance().setMasterserverMode(true); + Model::setMasterserverMode(true); + Shared::Sound::Sound::setMasterserverMode(true); } } diff --git a/source/shared_lib/include/graphics/model.h b/source/shared_lib/include/graphics/model.h index 6b4ba4be1..cdc011c1c 100644 --- a/source/shared_lib/include/graphics/model.h +++ b/source/shared_lib/include/graphics/model.h @@ -176,6 +176,8 @@ private: string fileName; string sourceLoader; + static bool masterserverMode; + public: //constructor & destructor Model(); @@ -183,6 +185,8 @@ public: virtual void init()= 0; virtual void end()= 0; + static void setMasterserverMode(bool value) { masterserverMode=value; } + //data void updateInterpolationData(float t, bool cycle); void updateInterpolationVertices(float t, bool cycle); diff --git a/source/shared_lib/include/sound/sound.h b/source/shared_lib/include/sound/sound.h index 205b829b7..8e35579eb 100644 --- a/source/shared_lib/include/sound/sound.h +++ b/source/shared_lib/include/sound/sound.h @@ -54,17 +54,21 @@ public: // class Sound // ===================================================== -class Sound{ +class Sound { protected: SoundFileLoader *soundFileLoader; SoundInfo info; float volume; string fileName; + static bool masterserverMode; + public: Sound(); virtual ~Sound(){}; + static void setMasterserverMode(bool value) { masterserverMode=value; } + const SoundInfo *getInfo() const {return &info;} float getVolume() const {return volume;} diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index 8a1a584fe..50ae449ec 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -34,6 +34,8 @@ namespace Shared{ namespace Graphics{ using namespace Util; +bool Model::masterserverMode = false; + // ===================================================== // class Mesh // ===================================================== @@ -777,6 +779,9 @@ void Model::load(const string &path, bool deletePixMapAfterLoad, this->sourceLoader = (sourceLoader != NULL ? *sourceLoader : ""); this->fileName = path; + if(this->masterserverMode == true) { + return; + } string extension= path.substr(path.find_last_of('.') + 1); if(extension=="g3d" || extension=="G3D") { loadG3d(path,deletePixMapAfterLoad,loadedFileList, this->sourceLoader); diff --git a/source/shared_lib/sources/sound/sound.cpp b/source/shared_lib/sources/sound/sound.cpp index 66172c4ef..3ca3f9054 100644 --- a/source/shared_lib/sources/sound/sound.cpp +++ b/source/shared_lib/sources/sound/sound.cpp @@ -16,12 +16,15 @@ #include "leak_dumper.h" -namespace Shared{ namespace Sound{ +namespace Shared { namespace Sound { + +bool Sound::masterserverMode = false; + // ===================================================== // class SoundInfo // ===================================================== -SoundInfo::SoundInfo(){ +SoundInfo::SoundInfo() { channels= 0; samplesPerSecond= 0; bitsPerSample= 0; @@ -33,7 +36,7 @@ SoundInfo::SoundInfo(){ // class Sound // ===================================================== -Sound::Sound(){ +Sound::Sound() { volume= 0.0f; fileName = ""; } @@ -42,17 +45,17 @@ Sound::Sound(){ // class StaticSound // ===================================================== -StaticSound::StaticSound(){ +StaticSound::StaticSound() { samples= NULL; soundFileLoader = NULL; fileName = ""; } -StaticSound::~StaticSound(){ +StaticSound::~StaticSound() { close(); } -void StaticSound::close(){ +void StaticSound::close() { if(samples != NULL) { delete [] samples; samples = NULL; @@ -65,11 +68,14 @@ void StaticSound::close(){ } } -void StaticSound::load(const string &path){ +void StaticSound::load(const string &path) { close(); fileName = path; + if(this->masterserverMode == true) { + return; + } string ext= path.substr(path.find_last_of('.')+1); soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext); @@ -89,21 +95,25 @@ void StaticSound::load(const string &path){ // class StrSound // ===================================================== -StrSound::StrSound(){ +StrSound::StrSound() { soundFileLoader= NULL; next= NULL; fileName = ""; } -StrSound::~StrSound(){ +StrSound::~StrSound() { close(); } -void StrSound::open(const string &path){ +void StrSound::open(const string &path) { close(); fileName = path; + if(this->masterserverMode == true) { + return; + } + string ext= path.substr(path.find_last_of('.')+1); soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext); @@ -111,11 +121,15 @@ void StrSound::open(const string &path){ } uint32 StrSound::read(int8 *samples, uint32 size){ + if(this->masterserverMode == true) { + return 0; + } + return soundFileLoader->read(samples, size); } void StrSound::close(){ - if(soundFileLoader!=NULL){ + if(soundFileLoader != NULL) { soundFileLoader->close(); delete soundFileLoader; soundFileLoader= NULL; @@ -123,6 +137,10 @@ void StrSound::close(){ } void StrSound::restart(){ + if(this->masterserverMode == true) { + return; + } + soundFileLoader->restart(); }