mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 07:01:21 +02:00
- cleanup of masterserver global flag
- attempt to cut down on resources required for masterserver mode to minimize RAM
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#include "types.h"
|
||||
#include "pixmap.h"
|
||||
#include <stdexcept>
|
||||
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::runtime_error;
|
||||
@@ -75,6 +75,8 @@ BMPReader::BMPReader(): FileReader<Pixmap2D>(getExtensionsBmp()) {}
|
||||
*Path is used for printing error messages
|
||||
*@return <code>NULL</code> if the Pixmap2D could not be read, else the pixmap*/
|
||||
Pixmap2D* BMPReader::read(ifstream& in, const string& path, Pixmap2D* ret) const {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
|
||||
//read file header
|
||||
BitmapFileHeader fileHeader;
|
||||
in.read((char*)&fileHeader, sizeof(BitmapFileHeader));
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <jpeglib.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::runtime_error;
|
||||
@@ -71,6 +72,7 @@ static inline std::vector<string> getExtensions() {
|
||||
JPGReader::JPGReader(): FileReader<Pixmap2D>(getExtensions()) {}
|
||||
|
||||
Pixmap2D* JPGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
//Read file
|
||||
is.seekg(0, ios::end);
|
||||
size_t length = is.tellg();
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#include <stdexcept>
|
||||
#include <png.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::runtime_error;
|
||||
@@ -61,6 +61,7 @@ static inline std::vector<string> getExtensionsPng() {
|
||||
PNGReader::PNGReader(): FileReader<Pixmap2D>(getExtensionsPng()) {}
|
||||
|
||||
Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
//Read file
|
||||
is.seekg(0, ios::end);
|
||||
//size_t length = is.tellg();
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#include "pixmap.h"
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::runtime_error;
|
||||
@@ -66,6 +66,7 @@ static inline std::vector<string> getExtensionStrings() {
|
||||
TGAReader3D::TGAReader3D(): FileReader<Pixmap3D>(getExtensionStrings()) {}
|
||||
|
||||
Pixmap3D* TGAReader3D::read(ifstream& in, const string& path, Pixmap3D* ret) const {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
//read header
|
||||
TargaFileHeader fileHeader;
|
||||
in.read((char*)&fileHeader, sizeof(TargaFileHeader));
|
||||
|
@@ -157,6 +157,8 @@ float FontMetrics::getHeight(const string &str) const {
|
||||
// ===============================================
|
||||
|
||||
Font::Font(FontTextHandlerType type) {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
|
||||
inited = false;
|
||||
this->type = fontTypeName;
|
||||
width = 400;
|
||||
|
@@ -14,14 +14,17 @@
|
||||
#include "graphics_interface.h"
|
||||
#include "graphics_factory.h"
|
||||
#include <stdexcept>
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
namespace Shared { namespace Graphics {
|
||||
|
||||
// =====================================================
|
||||
// class FontManager
|
||||
// =====================================================
|
||||
FontManager::FontManager() {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
fonts.clear();
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,9 @@ namespace Shared{ namespace Graphics{
|
||||
// class InterpolationData
|
||||
// =====================================================
|
||||
|
||||
InterpolationData::InterpolationData(const Mesh *mesh){
|
||||
InterpolationData::InterpolationData(const Mesh *mesh) {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
|
||||
vertices= NULL;
|
||||
normals= NULL;
|
||||
|
||||
|
@@ -34,7 +34,7 @@ namespace Shared{ namespace Graphics{
|
||||
|
||||
using namespace Util;
|
||||
|
||||
bool Model::masterserverMode = false;
|
||||
//bool Model::masterserverMode = false;
|
||||
|
||||
// =====================================================
|
||||
// class Mesh
|
||||
@@ -711,6 +711,7 @@ void Mesh::deletePixels() {
|
||||
// ==================== constructor & destructor ====================
|
||||
|
||||
Model::Model() {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
meshCount = 0;
|
||||
meshes = NULL;
|
||||
textureManager = NULL;
|
||||
@@ -779,7 +780,7 @@ void Model::load(const string &path, bool deletePixMapAfterLoad,
|
||||
this->sourceLoader = (sourceLoader != NULL ? *sourceLoader : "");
|
||||
this->fileName = path;
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
string extension= path.substr(path.find_last_of('.') + 1);
|
||||
|
@@ -15,9 +15,12 @@
|
||||
#include "graphics_factory.h"
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
#include "util.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
// =====================================================
|
||||
@@ -25,6 +28,7 @@ namespace Shared{ namespace Graphics{
|
||||
// =====================================================
|
||||
|
||||
ModelManager::ModelManager(){
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
textureManager= NULL;
|
||||
}
|
||||
|
||||
|
@@ -42,6 +42,8 @@ ParticleSystem::ParticleSystem(int particleCount) {
|
||||
memoryObjectList[this]++;
|
||||
}
|
||||
|
||||
//assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
|
||||
//init particle vector
|
||||
blendMode= bmOne;
|
||||
//particles= new Particle[particleCount];
|
||||
@@ -1160,7 +1162,11 @@ void SplashParticleSystem::updateParticle(Particle *p){
|
||||
// ParticleManager
|
||||
// ===========================================================================
|
||||
|
||||
ParticleManager::~ParticleManager(){
|
||||
ParticleManager::ParticleManager() {
|
||||
//assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
}
|
||||
|
||||
ParticleManager::~ParticleManager() {
|
||||
end();
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -15,14 +15,21 @@
|
||||
|
||||
#include "graphics_interface.h"
|
||||
#include "graphics_factory.h"
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
// =====================================================
|
||||
// class ShaderManager
|
||||
// =====================================================
|
||||
|
||||
ShaderManager::ShaderManager() {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
}
|
||||
|
||||
ShaderManager::~ShaderManager(){
|
||||
}
|
||||
|
||||
|
@@ -17,15 +17,20 @@
|
||||
#include "graphics_interface.h"
|
||||
#include "graphics_factory.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
// =====================================================
|
||||
// class TextureManager
|
||||
// =====================================================
|
||||
|
||||
TextureManager::TextureManager(){
|
||||
TextureManager::TextureManager() {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
|
||||
textureFilter= Texture::fBilinear;
|
||||
maxAnisotropy= 1;
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
|
||||
int resW = PlatformCommon::Private::ScreenWidth;
|
||||
int resH = PlatformCommon::Private::ScreenHeight;
|
||||
|
||||
if(Window::getMasterserverMode() == false) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
|
||||
#ifndef WIN32
|
||||
string mg_icon_file = "";
|
||||
@@ -162,7 +162,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
}
|
||||
|
||||
if(Window::getMasterserverMode() == false) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
GLuint err = glewInit();
|
||||
if (GLEW_OK != err) {
|
||||
fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
|
||||
@@ -198,7 +198,7 @@ void PlatformContextGl::makeCurrent() {
|
||||
}
|
||||
|
||||
void PlatformContextGl::swapBuffers() {
|
||||
if(Window::getMasterserverMode() == false) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ int Window::lastShowMouseState = 0;
|
||||
|
||||
bool Window::tryVSynch = false;
|
||||
|
||||
bool Window::masterserverMode = false;
|
||||
//bool Window::masterserverMode = false;
|
||||
|
||||
// ========== PUBLIC ==========
|
||||
|
||||
@@ -408,7 +408,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
|
||||
if(stencilBits >= 0)
|
||||
newStencilBits = stencilBits;
|
||||
|
||||
if(Window::masterserverMode == false) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
if(fullscreen_anti_aliasing == true) {
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
|
||||
@@ -456,7 +456,7 @@ void Window::toggleFullscreen() {
|
||||
Use 0 for Height, Width, and Color Depth to keep the current values. */
|
||||
|
||||
if(Window::allowAltEnterFullscreenToggle == true) {
|
||||
if(Window::masterserverMode == false) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
SDL_Surface *cur_surface = SDL_GetVideoSurface();
|
||||
if(cur_surface != NULL) {
|
||||
Window::isFullScreen = !((cur_surface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN);
|
||||
@@ -532,7 +532,7 @@ void Window::toggleFullscreen() {
|
||||
if(Window::allowAltEnterFullscreenToggle == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(Window::masterserverMode == false) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
SDL_Surface *cur_surface = SDL_GetVideoSurface();
|
||||
if(cur_surface != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@@ -13,12 +13,13 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
namespace Shared { namespace Sound {
|
||||
|
||||
bool Sound::masterserverMode = false;
|
||||
//bool Sound::masterserverMode = false;
|
||||
|
||||
// =====================================================
|
||||
// class SoundInfo
|
||||
@@ -73,7 +74,7 @@ void StaticSound::load(const string &path) {
|
||||
|
||||
fileName = path;
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
string ext= path.substr(path.find_last_of('.')+1);
|
||||
@@ -110,7 +111,7 @@ void StrSound::open(const string &path) {
|
||||
|
||||
fileName = path;
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -121,7 +122,7 @@ void StrSound::open(const string &path) {
|
||||
}
|
||||
|
||||
uint32 StrSound::read(int8 *samples, uint32 size){
|
||||
if(this->masterserverMode == true) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -137,7 +138,7 @@ void StrSound::close(){
|
||||
}
|
||||
|
||||
void StrSound::restart(){
|
||||
if(this->masterserverMode == true) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -43,6 +43,7 @@ using namespace Shared::Util;
|
||||
|
||||
namespace Shared{ namespace Util{
|
||||
|
||||
bool GlobalStaticFlags::isNonGraphicalMode = false;
|
||||
// Init statics
|
||||
std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType> *SystemFlags::debugLogFileList = NULL;
|
||||
int SystemFlags::lockFile = -1;
|
||||
|
Reference in New Issue
Block a user