- do not load models or sound files in headless server mode

This commit is contained in:
Mark Vejvoda
2011-09-26 05:29:52 +00:00
parent f5c7eff49c
commit 5a79cad34b
5 changed files with 46 additions and 12 deletions

View File

@@ -39,6 +39,7 @@
#include <iterator>
#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);
}
}

View File

@@ -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);

View File

@@ -61,10 +61,14 @@ protected:
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;}

View File

@@ -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);

View File

@@ -17,6 +17,9 @@
#include "leak_dumper.h"
namespace Shared { namespace Sound {
bool Sound::masterserverMode = false;
// =====================================================
// class SoundInfo
// =====================================================
@@ -70,6 +73,9 @@ void StaticSound::load(const string &path){
fileName = path;
if(this->masterserverMode == true) {
return;
}
string ext= path.substr(path.find_last_of('.')+1);
soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext);
@@ -104,6 +110,10 @@ void StrSound::open(const string &path){
fileName = path;
if(this->masterserverMode == true) {
return;
}
string ext= path.substr(path.find_last_of('.')+1);
soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext);
@@ -111,6 +121,10 @@ void StrSound::open(const string &path){
}
uint32 StrSound::read(int8 *samples, uint32 size){
if(this->masterserverMode == true) {
return 0;
}
return soundFileLoader->read(samples, size);
}
@@ -123,6 +137,10 @@ void StrSound::close(){
}
void StrSound::restart(){
if(this->masterserverMode == true) {
return;
}
soundFileLoader->restart();
}