- getting fanatical about memory cleanup so that valgrind output is more useful
This commit is contained in:
parent
b57fb0ff39
commit
77a2fa7d48
|
@ -589,7 +589,7 @@ Vec2i PathFinder::jump(Vec2i dest, direction dir, Vec2i start,std::vector<Vec2i>
|
||||||
if (!isEnterable(coord))
|
if (!isEnterable(coord))
|
||||||
return Vec2i(-1,-1);
|
return Vec2i(-1,-1);
|
||||||
|
|
||||||
if(path.size() > max(250,pathLength*2)) {
|
if(path.size() > max(300,pathLength*2)) {
|
||||||
//if(path.size() > 2000) {
|
//if(path.size() > 2000) {
|
||||||
//printf("path.size() > pathLength [%d]\n",pathLength);
|
//printf("path.size() > pathLength [%d]\n",pathLength);
|
||||||
//return Vec2i(-1,-1);
|
//return Vec2i(-1,-1);
|
||||||
|
@ -1038,8 +1038,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
//addToOpenSet (&astar, newNode, node);
|
//addToOpenSet (&astar, newNode, node);
|
||||||
//printf("JPS #2 node->pos [%s] newNode [%s] path.size() [%d] pos [%s]\n",node->pos.getString().c_str(),newNode.getString().c_str(),(int)path.size(),path[0].getString().c_str());
|
//printf("JPS #2 node->pos [%s] newNode [%s] path.size() [%d] pos [%s]\n",node->pos.getString().c_str(),newNode.getString().c_str(),(int)path.size(),path[0].getString().c_str());
|
||||||
|
|
||||||
//for(unsigned int ipath = 0; ipath < path.size(); ++ipath) {
|
|
||||||
//for(unsigned int ipath = 0; ipath < 1; ++ipath) {
|
|
||||||
Vec2i newPath = path[0];
|
Vec2i newPath = path[0];
|
||||||
|
|
||||||
//bool canUnitMoveToCell = map->aproxCanMove(unit, node->pos, newPath);
|
//bool canUnitMoveToCell = map->aproxCanMove(unit, node->pos, newPath);
|
||||||
|
@ -1053,7 +1051,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
cameFrom[newPath]=node->pos;
|
cameFrom[newPath]=node->pos;
|
||||||
foundQuickRoute = true;
|
foundQuickRoute = true;
|
||||||
|
|
||||||
if(path.size() > 1) {
|
if(path.size() > 1 && path[path.size()-1] == finalPos) {
|
||||||
canAddEntirePath = true;
|
canAddEntirePath = true;
|
||||||
for(unsigned int x = 1; x < path.size(); ++x) {
|
for(unsigned int x = 1; x < path.size(); ++x) {
|
||||||
Vec2i futureNode = path[x];
|
Vec2i futureNode = path[x];
|
||||||
|
@ -1091,11 +1089,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if(canAddEntirePath == true) {
|
||||||
|
// break;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if(canAddEntirePath == true) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(foundQuickRoute == false) {
|
if(foundQuickRoute == false) {
|
||||||
|
@ -1117,8 +1113,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
//addToOpenSet (&astar, newNode, node);
|
//addToOpenSet (&astar, newNode, node);
|
||||||
//printf("JPS #3 node->pos [%s] newNode [%s]\n",node->pos.getString().c_str(),newNode.getString().c_str());
|
//printf("JPS #3 node->pos [%s] newNode [%s]\n",node->pos.getString().c_str(),newNode.getString().c_str());
|
||||||
|
|
||||||
//for(unsigned int ipath = 0; ipath < path.size(); ++ipath) {
|
|
||||||
//for(unsigned int ipath = 0; ipath < 1; ++ipath) {
|
|
||||||
Vec2i newPath = newNode;
|
Vec2i newPath = newNode;
|
||||||
|
|
||||||
//bool canUnitMoveToCell = map->aproxCanMove(unit, node->pos, newPath);
|
//bool canUnitMoveToCell = map->aproxCanMove(unit, node->pos, newPath);
|
||||||
|
@ -1139,7 +1133,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
canAddNode[make_pair(node->pos,newPath)]=false;
|
canAddNode[make_pair(node->pos,newPath)]=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include "core_data.h"
|
#include "core_data.h"
|
||||||
#include "font_text.h"
|
#include "font_text.h"
|
||||||
|
//#include "FileReader.h"
|
||||||
|
//#include "JPGReader.h"
|
||||||
//#include "sound.h"
|
//#include "sound.h"
|
||||||
//#include "unicode/uclean.h"
|
//#include "unicode/uclean.h"
|
||||||
|
|
||||||
|
@ -87,6 +89,7 @@ using namespace Shared::Util;
|
||||||
using namespace Shared::Graphics;
|
using namespace Shared::Graphics;
|
||||||
using namespace Shared::Graphics::Gl;
|
using namespace Shared::Graphics::Gl;
|
||||||
using namespace Shared::Xml;
|
using namespace Shared::Xml;
|
||||||
|
using namespace Shared;
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
@ -160,17 +163,25 @@ static void cleanupProcessObjects() {
|
||||||
//deleteMapValues(crcFactionPreviewTextureCache.begin(),crcFactionPreviewTextureCache.end());
|
//deleteMapValues(crcFactionPreviewTextureCache.begin(),crcFactionPreviewTextureCache.end());
|
||||||
crcFactionPreviewTextureCache.clear();
|
crcFactionPreviewTextureCache.clear();
|
||||||
|
|
||||||
|
printf("running threads = %lu\n",Thread::getThreadList().size());
|
||||||
time_t elapsed = time(NULL);
|
time_t elapsed = time(NULL);
|
||||||
for(;Thread::getThreadList().size() > 0 &&
|
for(;Thread::getThreadList().size() > 0 &&
|
||||||
difftime(time(NULL),elapsed) <= 10;) {
|
difftime(time(NULL),elapsed) <= 10;) {
|
||||||
sleep(0);
|
sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::globalCleanupHTTP();
|
std::map<string, vector<FileReader<Pixmap2D> const * >* > &list2d = FileReader<Pixmap2D>::getFileReadersMap();
|
||||||
CacheManager::cleanupMutexes();
|
//printf("list2d = %lu\n",list2d.size());
|
||||||
|
deleteMapValues(list2d.begin(),list2d.end());
|
||||||
|
std::map<string, vector<FileReader<Pixmap3D> const * >* > &list3d = FileReader<Pixmap3D>::getFileReadersMap();
|
||||||
|
//printf("list3d = %lu\n",list3d.size());
|
||||||
|
deleteMapValues(list3d.begin(),list3d.end());
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
||||||
|
|
||||||
|
SystemFlags::globalCleanupHTTP();
|
||||||
|
CacheManager::cleanupMutexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)
|
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)
|
||||||
|
|
|
@ -645,6 +645,7 @@ void MenuStateCustomGame::cleanup() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
publishToMasterserverThread->signalQuit();
|
publishToMasterserverThread->signalQuit();
|
||||||
|
sleep(0);
|
||||||
if(publishToMasterserverThread->canShutdown(true) == true &&
|
if(publishToMasterserverThread->canShutdown(true) == true &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
|
|
|
@ -273,23 +273,16 @@ T* FileReader<T>::readPath(const string& filepath, T* object) {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FileReader<T>::FileReader(std::vector<string> extensions): extensions(extensions) {
|
FileReader<T>::FileReader(std::vector<string> extensions): extensions(extensions) {
|
||||||
getFileReaders().push_back(this);
|
getFileReaders().push_back(this);
|
||||||
//string const * nextExtension = extensions;
|
|
||||||
std::vector<string> nextExtension = extensions;
|
std::vector<string> nextExtension = extensions;
|
||||||
//while (((*nextExtension) != "")) {
|
|
||||||
for(unsigned int i = 0; i < nextExtension.size(); ++i) {
|
for(unsigned int i = 0; i < nextExtension.size(); ++i) {
|
||||||
//vector<FileReader<T> const* >* curPossibleReaders = (getFileReadersMap())[*nextExtension];
|
|
||||||
vector<FileReader<T> const* >* curPossibleReaders = (getFileReadersMap())[nextExtension[i]];
|
vector<FileReader<T> const* >* curPossibleReaders = (getFileReadersMap())[nextExtension[i]];
|
||||||
if (curPossibleReaders == NULL) {
|
if (curPossibleReaders == NULL) {
|
||||||
//(getFileReadersMap())[*nextExtension] = (curPossibleReaders = new vector<FileReader<T> const *>());
|
|
||||||
(getFileReadersMap())[nextExtension[i]] = (curPossibleReaders = new vector<FileReader<T> const *>());
|
(getFileReadersMap())[nextExtension[i]] = (curPossibleReaders = new vector<FileReader<T> const *>());
|
||||||
}
|
}
|
||||||
curPossibleReaders->push_back(this);
|
curPossibleReaders->push_back(this);
|
||||||
//++nextExtension;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**Gives a quick estimation of whether the specified file
|
/**Gives a quick estimation of whether the specified file
|
||||||
* can be read or not depending on the filename*/
|
* can be read or not depending on the filename*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -561,6 +561,8 @@ UnitParticleSystem::UnitParticleSystem(int particleCount):
|
||||||
|
|
||||||
startTime = 0;
|
startTime = 0;
|
||||||
endTime = 1;
|
endTime = 1;
|
||||||
|
|
||||||
|
radiusBasedStartenergy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnitParticleSystem::~UnitParticleSystem(){
|
UnitParticleSystem::~UnitParticleSystem(){
|
||||||
|
|
|
@ -192,6 +192,13 @@ CURL *SystemFlags::initHTTP() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemFlags::globalCleanupHTTP() {
|
void SystemFlags::globalCleanupHTTP() {
|
||||||
|
|
||||||
|
if(curl_handle != NULL) {
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::cleanupHTTP(&curl_handle, true);
|
||||||
|
curl_handle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(SystemFlags::curl_global_init_called == true) {
|
if(SystemFlags::curl_global_init_called == true) {
|
||||||
SystemFlags::curl_global_init_called = false;
|
SystemFlags::curl_global_init_called = false;
|
||||||
//printf("HTTP cleanup\n");
|
//printf("HTTP cleanup\n");
|
||||||
|
@ -297,14 +304,7 @@ SystemFlags::~SystemFlags() {
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(curl_handle != NULL) {
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
SystemFlags::cleanupHTTP(&curl_handle, true);
|
|
||||||
curl_handle = NULL;
|
|
||||||
}
|
|
||||||
if(SystemFlags::curl_global_init_called == true) {
|
|
||||||
SystemFlags::globalCleanupHTTP();
|
SystemFlags::globalCleanupHTTP();
|
||||||
}
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user