- in headless mode skip call to set window icon

This commit is contained in:
Mark Vejvoda 2011-09-27 17:15:56 +00:00
parent ec554ffffb
commit 21005cc1e7
5 changed files with 72 additions and 72 deletions

View File

@ -83,6 +83,7 @@ PathFinder::~PathFinder() {
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
factions[i].nodePool.clear();
}
factions.clear();
map=NULL;
}

View File

@ -21,10 +21,12 @@
#include "game_constants.h"
#include "command_type.h"
#include "base_thread.h"
#include <set>
#include "leak_dumper.h"
using std::map;
using std::vector;
using std::set;
using Shared::Graphics::Texture2D;
using namespace Shared::PlatformCommon;
@ -132,10 +134,20 @@ private:
std::map<int,SwitchTeamVote> switchTeamVotes;
int currentSwitchTeamVoteFactionIndex;
set<int> livingUnits;
set<Unit*> livingUnitsp;
public:
Faction();
~Faction();
void addLivingUnits(int id) { livingUnits.insert(id); }
void addLivingUnitsp(Unit *unit) { livingUnitsp.insert(unit); }
bool isUnitInLivingUnitsp(Unit *unit) { return (livingUnitsp.find(unit) != livingUnitsp.end()); }
void deleteLivingUnits(int id) { livingUnits.erase(id); }
void deleteLivingUnitsp(Unit *unit) { livingUnitsp.erase(unit); }
void init(
FactionType *factionType, ControlType control, TechTree *techTree, Game *game,
int factionIndex, int teamIndex, int startLocationIndex, bool thisFaction, bool giveResources);

View File

@ -241,8 +241,8 @@ const int Unit::maxDeadCount= 1000; //time in until the corpse disapears - shoul
const float Unit::highlightTime= 0.5f;
const int Unit::invalidId= -1;
set<int> Unit::livingUnits;
set<Unit*> Unit::livingUnitsp;
//set<int> Unit::livingUnits;
//set<Unit*> Unit::livingUnitsp;
// ============================ Constructor & destructor =============================
@ -342,8 +342,8 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, const UnitType
this->currSkill = getType()->getFirstStOfClass(scStop);
this->currentAttackBoostOriginatorEffect.skillType = this->currSkill;
livingUnits.insert(id);
livingUnitsp.insert(this);
this->faction->addLivingUnits(id);
this->faction->addLivingUnitsp(this);
addItemToVault(&this->hp,this->hp);
addItemToVault(&this->ep,this->ep);
@ -359,17 +359,9 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, const UnitType
Unit::~Unit() {
badHarvestPosList.clear();
//Just to be sure, should already be removed
if (livingUnits.erase(id)) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//Only an error if not called at end
}
this->faction->deleteLivingUnits(id);
this->faction->deleteLivingUnitsp(this);
//Just to be sure, should already be removed
if (livingUnitsp.erase(this)) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
//remove commands
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexCommands,mutexOwnerId);
@ -1206,7 +1198,7 @@ CommandResult Unit::finishCommand() {
this->unitPath->clear();
while (commands.empty() == false) {
if (commands.front()->getUnit() != NULL && livingUnitsp.find(commands.front()->getUnit()) == livingUnitsp.end()) {
if (commands.front()->getUnit() != NULL && this->faction->isUnitInLivingUnitsp(commands.front()->getUnit()) == false) {
safeMutex.Lock();
delete commands.front();
commands.erase(commands.begin());
@ -1326,8 +1318,8 @@ void Unit::undertake() {
//unitUpdater->clearUnitPrecache(this);
unitUpdater->removeUnitPrecache(this);
livingUnits.erase(id);
livingUnitsp.erase(this);
this->faction->deleteLivingUnits(id);
this->faction->deleteLivingUnitsp(this);
faction->removeUnit(this);
}

View File

@ -16,7 +16,6 @@
#include "particle.h"
#include "skill_type.h"
#include "game_constants.h"
#include <set>
#include "platform_common.h"
#include <vector>
#include "leak_dumper.h"
@ -33,8 +32,6 @@ using Shared::Graphics::Model;
using Shared::PlatformCommon::Chrono;
using Shared::PlatformCommon::ValueCheckerVault;
using std::set;
class Map;
class Faction;
class Unit;
@ -271,10 +268,6 @@ public:
static const float highlightTime;
static const int invalidId;
static set<int> livingUnits;
static set<Unit*> livingUnitsp;
private:
const int id;
int hp;

View File

@ -65,55 +65,57 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
int resW = PlatformCommon::Private::ScreenWidth;
int resH = PlatformCommon::Private::ScreenHeight;
#ifndef WIN32
string mg_icon_file = "";
#if defined(CUSTOM_DATA_INSTALL_PATH_VALUE)
if(fileExists(CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp")) {
mg_icon_file = CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp";
}
#endif
if(mg_icon_file == "" && fileExists("megaglest.bmp")) {
mg_icon_file = "megaglest.bmp";
}
if(mg_icon_file != "") {
if(icon != NULL) {
SDL_FreeSurface(icon);
icon = NULL;
}
icon = SDL_LoadBMP(mg_icon_file.c_str());
//SDL_Surface *icon = IMG_Load("megaglest.ico");
//#if !defined(MACOSX)
// Set Icon (must be done before any sdl_setvideomode call)
// But don't set it on OS X, as we use a nicer external icon there.
//#if WORDS_BIGENDIAN
// SDL_Surface* icon= SDL_CreateRGBSurfaceFrom((void*)logo,32,32,8,128,0xff000000,0x00ff0000,0x0000ff00,0);
//#else
// SDL_Surface* icon= SDL_CreateRGBSurfaceFrom((void*)logo,32,32,32,128,0x000000ff,0x0000ff00,0x00ff0000,0xff000000);
//#endif
//printf("In [%s::%s Line: %d] icon = %p\n",__FILE__,__FUNCTION__,__LINE__,icon);
if(icon == NULL) {
printf("Error: %s\n", SDL_GetError());
}
if(icon != NULL) {
SDL_WM_SetIcon(icon, NULL);
}
}
#endif
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",__FILE__,__FUNCTION__,__LINE__,resW,resH,colorBits);
if(screen != NULL) {
SDL_FreeSurface(screen);
screen = NULL;
}
if(Window::getMasterserverMode() == false) {
#ifndef WIN32
string mg_icon_file = "";
#if defined(CUSTOM_DATA_INSTALL_PATH_VALUE)
if(fileExists(CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp")) {
mg_icon_file = CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp";
}
#endif
if(mg_icon_file == "" && fileExists("megaglest.bmp")) {
mg_icon_file = "megaglest.bmp";
}
if(mg_icon_file != "") {
if(icon != NULL) {
SDL_FreeSurface(icon);
icon = NULL;
}
icon = SDL_LoadBMP(mg_icon_file.c_str());
//SDL_Surface *icon = IMG_Load("megaglest.ico");
//#if !defined(MACOSX)
// Set Icon (must be done before any sdl_setvideomode call)
// But don't set it on OS X, as we use a nicer external icon there.
//#if WORDS_BIGENDIAN
// SDL_Surface* icon= SDL_CreateRGBSurfaceFrom((void*)logo,32,32,8,128,0xff000000,0x00ff0000,0x0000ff00,0);
//#else
// SDL_Surface* icon= SDL_CreateRGBSurfaceFrom((void*)logo,32,32,32,128,0x000000ff,0x0000ff00,0x00ff0000,0xff000000);
//#endif
//printf("In [%s::%s Line: %d] icon = %p\n",__FILE__,__FUNCTION__,__LINE__,icon);
if(icon == NULL) {
printf("Error: %s\n", SDL_GetError());
}
if(icon != NULL) {
SDL_WM_SetIcon(icon, NULL);
}
}
#endif
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",__FILE__,__FUNCTION__,__LINE__,resW,resH,colorBits);
if(screen != NULL) {
SDL_FreeSurface(screen);
screen = NULL;
}
screen = SDL_SetVideoMode(resW, resH, colorBits, flags);
if(screen == 0) {
std::ostringstream msg;