- 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 <iterator>
#include "core_data.h" #include "core_data.h"
#include "font_text.h" #include "font_text.h"
//#include "sound.h"
//#include "unicode/uclean.h" //#include "unicode/uclean.h"
// For gcc backtrace on crash! // For gcc backtrace on crash!
@ -2534,6 +2535,8 @@ int glestMain(int argc, char** argv) {
config.setString("FactorySound","None"); config.setString("FactorySound","None");
if(hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) { if(hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) {
Logger::getInstance().setMasterserverMode(true); Logger::getInstance().setMasterserverMode(true);
Model::setMasterserverMode(true);
Shared::Sound::Sound::setMasterserverMode(true);
} }
} }

View File

@ -176,6 +176,8 @@ private:
string fileName; string fileName;
string sourceLoader; string sourceLoader;
static bool masterserverMode;
public: public:
//constructor & destructor //constructor & destructor
Model(); Model();
@ -183,6 +185,8 @@ public:
virtual void init()= 0; virtual void init()= 0;
virtual void end()= 0; virtual void end()= 0;
static void setMasterserverMode(bool value) { masterserverMode=value; }
//data //data
void updateInterpolationData(float t, bool cycle); void updateInterpolationData(float t, bool cycle);
void updateInterpolationVertices(float t, bool cycle); void updateInterpolationVertices(float t, bool cycle);

View File

@ -54,17 +54,21 @@ public:
// class Sound // class Sound
// ===================================================== // =====================================================
class Sound{ class Sound {
protected: protected:
SoundFileLoader *soundFileLoader; SoundFileLoader *soundFileLoader;
SoundInfo info; SoundInfo info;
float volume; float volume;
string fileName; string fileName;
static bool masterserverMode;
public: public:
Sound(); Sound();
virtual ~Sound(){}; virtual ~Sound(){};
static void setMasterserverMode(bool value) { masterserverMode=value; }
const SoundInfo *getInfo() const {return &info;} const SoundInfo *getInfo() const {return &info;}
float getVolume() const {return volume;} float getVolume() const {return volume;}

View File

@ -34,6 +34,8 @@ namespace Shared{ namespace Graphics{
using namespace Util; using namespace Util;
bool Model::masterserverMode = false;
// ===================================================== // =====================================================
// class Mesh // class Mesh
// ===================================================== // =====================================================
@ -777,6 +779,9 @@ void Model::load(const string &path, bool deletePixMapAfterLoad,
this->sourceLoader = (sourceLoader != NULL ? *sourceLoader : ""); this->sourceLoader = (sourceLoader != NULL ? *sourceLoader : "");
this->fileName = path; this->fileName = path;
if(this->masterserverMode == true) {
return;
}
string extension= path.substr(path.find_last_of('.') + 1); string extension= path.substr(path.find_last_of('.') + 1);
if(extension=="g3d" || extension=="G3D") { if(extension=="g3d" || extension=="G3D") {
loadG3d(path,deletePixMapAfterLoad,loadedFileList, this->sourceLoader); loadG3d(path,deletePixMapAfterLoad,loadedFileList, this->sourceLoader);

View File

@ -16,12 +16,15 @@
#include "leak_dumper.h" #include "leak_dumper.h"
namespace Shared{ namespace Sound{ namespace Shared { namespace Sound {
bool Sound::masterserverMode = false;
// ===================================================== // =====================================================
// class SoundInfo // class SoundInfo
// ===================================================== // =====================================================
SoundInfo::SoundInfo(){ SoundInfo::SoundInfo() {
channels= 0; channels= 0;
samplesPerSecond= 0; samplesPerSecond= 0;
bitsPerSample= 0; bitsPerSample= 0;
@ -33,7 +36,7 @@ SoundInfo::SoundInfo(){
// class Sound // class Sound
// ===================================================== // =====================================================
Sound::Sound(){ Sound::Sound() {
volume= 0.0f; volume= 0.0f;
fileName = ""; fileName = "";
} }
@ -42,17 +45,17 @@ Sound::Sound(){
// class StaticSound // class StaticSound
// ===================================================== // =====================================================
StaticSound::StaticSound(){ StaticSound::StaticSound() {
samples= NULL; samples= NULL;
soundFileLoader = NULL; soundFileLoader = NULL;
fileName = ""; fileName = "";
} }
StaticSound::~StaticSound(){ StaticSound::~StaticSound() {
close(); close();
} }
void StaticSound::close(){ void StaticSound::close() {
if(samples != NULL) { if(samples != NULL) {
delete [] samples; delete [] samples;
samples = NULL; samples = NULL;
@ -65,11 +68,14 @@ void StaticSound::close(){
} }
} }
void StaticSound::load(const string &path){ void StaticSound::load(const string &path) {
close(); close();
fileName = path; fileName = path;
if(this->masterserverMode == true) {
return;
}
string ext= path.substr(path.find_last_of('.')+1); string ext= path.substr(path.find_last_of('.')+1);
soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext); soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext);
@ -89,21 +95,25 @@ void StaticSound::load(const string &path){
// class StrSound // class StrSound
// ===================================================== // =====================================================
StrSound::StrSound(){ StrSound::StrSound() {
soundFileLoader= NULL; soundFileLoader= NULL;
next= NULL; next= NULL;
fileName = ""; fileName = "";
} }
StrSound::~StrSound(){ StrSound::~StrSound() {
close(); close();
} }
void StrSound::open(const string &path){ void StrSound::open(const string &path) {
close(); close();
fileName = path; fileName = path;
if(this->masterserverMode == true) {
return;
}
string ext= path.substr(path.find_last_of('.')+1); string ext= path.substr(path.find_last_of('.')+1);
soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext); soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext);
@ -111,11 +121,15 @@ void StrSound::open(const string &path){
} }
uint32 StrSound::read(int8 *samples, uint32 size){ uint32 StrSound::read(int8 *samples, uint32 size){
if(this->masterserverMode == true) {
return 0;
}
return soundFileLoader->read(samples, size); return soundFileLoader->read(samples, size);
} }
void StrSound::close(){ void StrSound::close(){
if(soundFileLoader!=NULL){ if(soundFileLoader != NULL) {
soundFileLoader->close(); soundFileLoader->close();
delete soundFileLoader; delete soundFileLoader;
soundFileLoader= NULL; soundFileLoader= NULL;
@ -123,6 +137,10 @@ void StrSound::close(){
} }
void StrSound::restart(){ void StrSound::restart(){
if(this->masterserverMode == true) {
return;
}
soundFileLoader->restart(); soundFileLoader->restart();
} }