hopefully fix for tileset particle related crash in windows; particles must be removed from objects before the particle manager is cleared

This commit is contained in:
Titus Tscharntke
2011-03-06 22:50:04 +00:00
parent 273ab4c502
commit 4874d31ddd
5 changed files with 41 additions and 5 deletions

View File

@@ -52,19 +52,31 @@ Object::Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos) {
Object::~Object(){
Renderer &renderer= Renderer::getInstance();
renderer.removeObjectFromQuadCache(this);
if(stateCallback) {
stateCallback->removingObjectEvent(this);
//renderer.getGame()->getGui()->removeObject(this);
}
// fade(and by this remove) all unit particle systems
while(unitParticleSystems.empty() == false) {
unitParticleSystems.back()->fade();
unitParticleSystems.pop_back();
}
renderer.removeObjectFromQuadCache(this);
if(stateCallback) {
stateCallback->removingObjectEvent(this);
//renderer.getGame()->getGui()->removeObject(this);
}
delete resource;
}
void Object::end(){
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//Logger::getInstance().add("Object", true);
// set Objects to fading and remove them from list.
// its needed because otherwise they will be accessed from the destructor
while(unitParticleSystems.empty() == false) {
unitParticleSystems.back()->fade();
unitParticleSystems.pop_back();
}
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
void Object::initParticles(){
if(this->objectType==NULL) return;
if(this->objectType->hasParticles()){

View File

@@ -61,6 +61,7 @@ public:
Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos);
~Object();
void end(); //to kill particles
void initParticles();
static void setStateCallback(ObjectStateInterface *value) { stateCallback=value; }

View File

@@ -71,6 +71,13 @@ SurfaceCell::~SurfaceCell() {
delete object;
}
void SurfaceCell::end(){
if(object!=NULL){
object->end();
}
}
bool SurfaceCell::isFree() const {
return object==NULL || object->getWalkable();
}
@@ -126,6 +133,18 @@ Map::~Map() {
startLocations = NULL;
}
void Map::end(){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
Logger::getInstance().add("Map", true);
//read heightmap
for(int j = 0; j < surfaceH; ++j) {
for(int i = 0; i < surfaceW; ++i) {
getSurfaceCell(i, j)->end();
}
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
int Map::getSurfaceCellArraySize() const {
return (surfaceW * surfaceH);
}

View File

@@ -105,6 +105,7 @@ public:
SurfaceCell();
~SurfaceCell();
void end(); //to kill particles
//get
const Vec3f &getVertex() const {return vertex;}
float getHeight() const {return vertex.y;}
@@ -176,6 +177,7 @@ private:
public:
Map();
~Map();
void end(); //to kill particles
Checksum * getChecksumValue() { return &checksumValue; }
void init(Tileset *tileset);

View File

@@ -136,6 +136,8 @@ void World::end(){
factions.clear();
fogOfWarOverride = false;
map.end();
//stats will be deleted by BattleEnd
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}