- 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))
|
||||
return Vec2i(-1,-1);
|
||||
|
||||
if(path.size() > max(250,pathLength*2)) {
|
||||
if(path.size() > max(300,pathLength*2)) {
|
||||
//if(path.size() > 2000) {
|
||||
//printf("path.size() > pathLength [%d]\n",pathLength);
|
||||
//return Vec2i(-1,-1);
|
||||
|
@ -1038,64 +1038,60 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
|||
//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());
|
||||
|
||||
//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 posOpen = (openPos(newPath, factions[unit->getFactionIndex()]) == false);
|
||||
//bool isFreeCell = map->isFreeCell(newPath,unit->getType()->getField());
|
||||
//bool canUnitMoveToCell = map->aproxCanMove(unit, node->pos, newPath);
|
||||
//bool posOpen = (openPos(newPath, factions[unit->getFactionIndex()]) == false);
|
||||
//bool isFreeCell = map->isFreeCell(newPath,unit->getType()->getField());
|
||||
|
||||
if(canAddNode.find(make_pair(node->pos,newPath)) == canAddNode.end()) {
|
||||
Node *newNode=NULL;
|
||||
if(addToOpenSet(unit, node, finalPos, newPath, nodeLimitReached, maxNodeCount,&newNode,false) == true) {
|
||||
//cameFrom = node->pos;
|
||||
cameFrom[newPath]=node->pos;
|
||||
foundQuickRoute = true;
|
||||
if(canAddNode.find(make_pair(node->pos,newPath)) == canAddNode.end()) {
|
||||
Node *newNode=NULL;
|
||||
if(addToOpenSet(unit, node, finalPos, newPath, nodeLimitReached, maxNodeCount,&newNode,false) == true) {
|
||||
//cameFrom = node->pos;
|
||||
cameFrom[newPath]=node->pos;
|
||||
foundQuickRoute = true;
|
||||
|
||||
if(path.size() > 1 && path[path.size()-1] == finalPos) {
|
||||
canAddEntirePath = true;
|
||||
for(unsigned int x = 1; x < path.size(); ++x) {
|
||||
Vec2i futureNode = path[x];
|
||||
|
||||
bool canUnitMoveToCell = map->aproxCanMoveSoon(unit, newNode->pos, futureNode);
|
||||
if(canUnitMoveToCell != true || openPos(futureNode, factions[unit->getFactionIndex()]) == true) {
|
||||
canAddEntirePath = false;
|
||||
canAddNode[make_pair(node->pos,futureNode)]=false;
|
||||
//printf("COULD NOT ADD ENTIRE PATH! canUnitMoveToCell = %d\n",canUnitMoveToCell);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(canAddEntirePath == true) {
|
||||
//printf("add node - ENTIRE PATH!\n");
|
||||
|
||||
if(path.size() > 1) {
|
||||
canAddEntirePath = true;
|
||||
for(unsigned int x = 1; x < path.size(); ++x) {
|
||||
Vec2i futureNode = path[x];
|
||||
|
||||
bool canUnitMoveToCell = map->aproxCanMoveSoon(unit, newNode->pos, futureNode);
|
||||
if(canUnitMoveToCell != true || openPos(futureNode, factions[unit->getFactionIndex()]) == true) {
|
||||
canAddEntirePath = false;
|
||||
canAddNode[make_pair(node->pos,futureNode)]=false;
|
||||
//printf("COULD NOT ADD ENTIRE PATH! canUnitMoveToCell = %d\n",canUnitMoveToCell);
|
||||
break;
|
||||
}
|
||||
Node *newNode2=NULL;
|
||||
addToOpenSet(unit, newNode, finalPos, futureNode, nodeLimitReached, maxNodeCount,&newNode2, true);
|
||||
newNode=newNode2;
|
||||
}
|
||||
if(canAddEntirePath == true) {
|
||||
//printf("add node - ENTIRE PATH!\n");
|
||||
|
||||
for(unsigned int x = 1; x < path.size(); ++x) {
|
||||
Vec2i futureNode = path[x];
|
||||
|
||||
Node *newNode2=NULL;
|
||||
addToOpenSet(unit, newNode, finalPos, futureNode, nodeLimitReached, maxNodeCount,&newNode2, true);
|
||||
newNode=newNode2;
|
||||
}
|
||||
|
||||
//Node *result = factions[unit->getFactionIndex()].openNodesList.begin()->second[0];
|
||||
//if(result->pos == finalPos || result->exploredCell == false) {
|
||||
// printf("Will break out of pathfinding now!\n");
|
||||
//}
|
||||
}
|
||||
//Node *result = factions[unit->getFactionIndex()].openNodesList.begin()->second[0];
|
||||
//if(result->pos == finalPos || result->exploredCell == false) {
|
||||
// printf("Will break out of pathfinding now!\n");
|
||||
//}
|
||||
}
|
||||
//printf("add node - current node [%s] next possible node [%s] canUnitMoveToCell [%d] posOpen [%d] isFreeCell [%d]\n",node->pos.getString().c_str(),newPath.getString().c_str(),canUnitMoveToCell,posOpen,isFreeCell);
|
||||
}
|
||||
else {
|
||||
//printf("COULD NOT add node - current node [%s] next possible node [%s] canUnitMoveToCell [%d] posOpen [%d] isFreeCell [%d]\n",node->pos.getString().c_str(),newPath.getString().c_str(),canUnitMoveToCell,posOpen,isFreeCell);
|
||||
canAddNode[make_pair(node->pos,newPath)]=false;
|
||||
}
|
||||
//printf("add node - current node [%s] next possible node [%s] canUnitMoveToCell [%d] posOpen [%d] isFreeCell [%d]\n",node->pos.getString().c_str(),newPath.getString().c_str(),canUnitMoveToCell,posOpen,isFreeCell);
|
||||
}
|
||||
else {
|
||||
//printf("COULD NOT add node - current node [%s] next possible node [%s] canUnitMoveToCell [%d] posOpen [%d] isFreeCell [%d]\n",node->pos.getString().c_str(),newPath.getString().c_str(),canUnitMoveToCell,posOpen,isFreeCell);
|
||||
canAddNode[make_pair(node->pos,newPath)]=false;
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
if(canAddEntirePath == true) {
|
||||
break;
|
||||
}
|
||||
|
||||
//if(canAddEntirePath == true) {
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
if(foundQuickRoute == false) {
|
||||
|
@ -1117,29 +1113,26 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
|||
//addToOpenSet (&astar, newNode, node);
|
||||
//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 posOpen = (openPos(newPath, factions[unit->getFactionIndex()]) == false);
|
||||
//bool isFreeCell = map->isFreeCell(newPath,unit->getType()->getField());
|
||||
//bool canUnitMoveToCell = map->aproxCanMove(unit, node->pos, newPath);
|
||||
//bool posOpen = (openPos(newPath, factions[unit->getFactionIndex()]) == false);
|
||||
//bool isFreeCell = map->isFreeCell(newPath,unit->getType()->getField());
|
||||
|
||||
if(canAddNode.find(make_pair(node->pos,newPath)) == canAddNode.end()) {
|
||||
Node *newNode=NULL;
|
||||
if(addToOpenSet(unit, node, finalPos, newPath, nodeLimitReached, maxNodeCount,&newNode, false) == true) {
|
||||
//cameFrom = node->pos;
|
||||
cameFrom[newPath]=node->pos;
|
||||
foundQuickRoute = true;
|
||||
if(canAddNode.find(make_pair(node->pos,newPath)) == canAddNode.end()) {
|
||||
Node *newNode=NULL;
|
||||
if(addToOpenSet(unit, node, finalPos, newPath, nodeLimitReached, maxNodeCount,&newNode, false) == true) {
|
||||
//cameFrom = node->pos;
|
||||
cameFrom[newPath]=node->pos;
|
||||
foundQuickRoute = true;
|
||||
|
||||
//printf("#2 add node - current node [%s] next possible node [%s] canUnitMoveToCell [%d] posOpen [%d] isFreeCell [%d]\n",node->pos.getString().c_str(),newPath.getString().c_str(),canUnitMoveToCell,posOpen,isFreeCell);
|
||||
}
|
||||
else {
|
||||
//printf("#2 COULD NOT add node - current node [%s] next possible node [%s] canUnitMoveToCell [%d] posOpen [%d] isFreeCell [%d]\n",node->pos.getString().c_str(),newPath.getString().c_str(),canUnitMoveToCell,posOpen,isFreeCell);
|
||||
canAddNode[make_pair(node->pos,newPath)]=false;
|
||||
}
|
||||
//printf("#2 add node - current node [%s] next possible node [%s] canUnitMoveToCell [%d] posOpen [%d] isFreeCell [%d]\n",node->pos.getString().c_str(),newPath.getString().c_str(),canUnitMoveToCell,posOpen,isFreeCell);
|
||||
}
|
||||
//}
|
||||
else {
|
||||
//printf("#2 COULD NOT add node - current node [%s] next possible node [%s] canUnitMoveToCell [%d] posOpen [%d] isFreeCell [%d]\n",node->pos.getString().c_str(),newPath.getString().c_str(),canUnitMoveToCell,posOpen,isFreeCell);
|
||||
canAddNode[make_pair(node->pos,newPath)]=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include <iterator>
|
||||
#include "core_data.h"
|
||||
#include "font_text.h"
|
||||
//#include "FileReader.h"
|
||||
//#include "JPGReader.h"
|
||||
//#include "sound.h"
|
||||
//#include "unicode/uclean.h"
|
||||
|
||||
|
@ -87,6 +89,7 @@ using namespace Shared::Util;
|
|||
using namespace Shared::Graphics;
|
||||
using namespace Shared::Graphics::Gl;
|
||||
using namespace Shared::Xml;
|
||||
using namespace Shared;
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
|
@ -160,17 +163,25 @@ static void cleanupProcessObjects() {
|
|||
//deleteMapValues(crcFactionPreviewTextureCache.begin(),crcFactionPreviewTextureCache.end());
|
||||
crcFactionPreviewTextureCache.clear();
|
||||
|
||||
printf("running threads = %lu\n",Thread::getThreadList().size());
|
||||
time_t elapsed = time(NULL);
|
||||
for(;Thread::getThreadList().size() > 0 &&
|
||||
difftime(time(NULL),elapsed) <= 10;) {
|
||||
sleep(0);
|
||||
sleep(10);
|
||||
}
|
||||
|
||||
SystemFlags::globalCleanupHTTP();
|
||||
CacheManager::cleanupMutexes();
|
||||
std::map<string, vector<FileReader<Pixmap2D> const * >* > &list2d = FileReader<Pixmap2D>::getFileReadersMap();
|
||||
//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__);
|
||||
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
||||
|
||||
SystemFlags::globalCleanupHTTP();
|
||||
CacheManager::cleanupMutexes();
|
||||
}
|
||||
|
||||
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)
|
||||
|
|
|
@ -645,6 +645,7 @@ void MenuStateCustomGame::cleanup() {
|
|||
}
|
||||
else {
|
||||
publishToMasterserverThread->signalQuit();
|
||||
sleep(0);
|
||||
if(publishToMasterserverThread->canShutdown(true) == true &&
|
||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||
delete publishToMasterserverThread;
|
||||
|
|
|
@ -273,23 +273,16 @@ T* FileReader<T>::readPath(const string& filepath, T* object) {
|
|||
template <typename T>
|
||||
FileReader<T>::FileReader(std::vector<string> extensions): extensions(extensions) {
|
||||
getFileReaders().push_back(this);
|
||||
//string const * nextExtension = extensions;
|
||||
std::vector<string> nextExtension = extensions;
|
||||
//while (((*nextExtension) != "")) {
|
||||
for(unsigned int i = 0; i < nextExtension.size(); ++i) {
|
||||
//vector<FileReader<T> const* >* curPossibleReaders = (getFileReadersMap())[*nextExtension];
|
||||
vector<FileReader<T> const* >* curPossibleReaders = (getFileReadersMap())[nextExtension[i]];
|
||||
if (curPossibleReaders == NULL) {
|
||||
//(getFileReadersMap())[*nextExtension] = (curPossibleReaders = new vector<FileReader<T> const *>());
|
||||
(getFileReadersMap())[nextExtension[i]] = (curPossibleReaders = new vector<FileReader<T> const *>());
|
||||
}
|
||||
curPossibleReaders->push_back(this);
|
||||
//++nextExtension;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**Gives a quick estimation of whether the specified file
|
||||
* can be read or not depending on the filename*/
|
||||
template <typename T>
|
||||
|
|
|
@ -561,6 +561,8 @@ UnitParticleSystem::UnitParticleSystem(int particleCount):
|
|||
|
||||
startTime = 0;
|
||||
endTime = 1;
|
||||
|
||||
radiusBasedStartenergy = false;
|
||||
}
|
||||
|
||||
UnitParticleSystem::~UnitParticleSystem(){
|
||||
|
|
|
@ -192,6 +192,13 @@ CURL *SystemFlags::initHTTP() {
|
|||
}
|
||||
|
||||
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) {
|
||||
SystemFlags::curl_global_init_called = false;
|
||||
//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(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__);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue