- do not load models or sound files in headless server mode
This commit is contained in:
parent
f5c7eff49c
commit
5a79cad34b
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user