diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index e0923493b..aa3a9344c 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -6534,13 +6534,14 @@ void Renderer::loadConfig() { if(this->program == NULL) { throw megaglest_runtime_error("this->program == NULL"); } - //if(this->program != NULL) { - if(gammaValue!=0.0){ - this->program->getWindow()->setGamma(gammaValue); - SDL_SetGamma(gammaValue, gammaValue, gammaValue); + if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) { + //if(this->program != NULL) { + if(gammaValue != 0.0) { + this->program->getWindow()->setGamma(gammaValue); + SDL_SetGamma(gammaValue, gammaValue, gammaValue); + } + //} } - //} - //load shadows shadows= strToShadows(config.getString("Shadows")); if(shadows==sProjected || shadows==sShadowMapping){ diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index c7ecff65b..97b85702f 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -3311,6 +3311,9 @@ void Unit::removeBadHarvestPos(const Vec2i &value) { bool Unit::isBadHarvestPos(const Vec2i &value, bool checkPeerUnits) const { bool result = false; + if(badHarvestPosList.empty() == true) { + return result; + } std::map::const_iterator iter = badHarvestPosList.find(value); if(iter != badHarvestPosList.end()) { @@ -3322,6 +3325,7 @@ bool Unit::isBadHarvestPos(const Vec2i &value, bool checkPeerUnits) const { for(int i = 0; i < this->getFaction()->getUnitCount(); ++i) { Unit *peerUnit = this->getFaction()->getUnit(i); if( peerUnit != NULL && peerUnit->getId() != this->getId() && + peerUnit->getType()->hasCommandClass(ccHarvest) == true && peerUnit->getType()->getSize() <= this->getType()->getSize()) { if(peerUnit->isBadHarvestPos(value,false) == true) { result = true; diff --git a/source/shared_lib/include/util/leak_dumper.h b/source/shared_lib/include/util/leak_dumper.h index a836a89fc..41eb5da39 100644 --- a/source/shared_lib/include/util/leak_dumper.h +++ b/source/shared_lib/include/util/leak_dumper.h @@ -79,58 +79,94 @@ public: } #if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD) - inline static int getFileAndLine(void *address, char *file, size_t flen) { - int line=-1; - if(want_full_leak_stacktrace_line_numbers == true && AllocInfo::get_application_binary() != "") { - const int maxbufSize = 4096; - char buf[maxbufSize+1]=""; + inline static int getFileAndLine(char *function, void *address, char *file, size_t flen) { + int line=-1; + if(want_full_leak_stacktrace_line_numbers == true && AllocInfo::get_application_binary() != "") { + const int maxbufSize = 8094; + char buf[maxbufSize+1]=""; + //char *p=NULL; - // prepare command to be executed - // our program need to be passed after the -e parameter - //sprintf (buf, "/usr/bin/addr2line -C -e ./a.out -f -i %lx", addr); - sprintf(buf, "addr2line -C -e %s -f -i %p",AllocInfo::get_application_binary().c_str(),address); + // prepare command to be executed + // our program need to be passed after the -e parameter + //sprintf (buf, "/usr/bin/addr2line -C -e ./a.out -f -i %lx", addr); + sprintf(buf, "addr2line -C -e %s -f -i %p",AllocInfo::get_application_binary().c_str(),address); - FILE* f = popen (buf, "r"); - if (f == NULL) { - perror (buf); - return 0; - } - - // get function name - char *ret = fgets (buf, maxbufSize, f); - if(ret == NULL) { - pclose(f); - return 0; - } - - // get file and line - ret = fgets (buf, maxbufSize, f); - if(ret == NULL) { - pclose(f); - return 0; - } - - if(strlen(buf) > 0 && buf[0] != '?') { - //int l; - char *p = buf; - - // file name is until ':' - while(*p != 0 && *p != ':') { - p++; + FILE* f = popen (buf, "r"); + if (f == NULL) { + perror (buf); + return 0; } - *p++ = 0; - // after file name follows line number - strcpy (file , buf); - sscanf (p,"%d", &line); - } - else { - strcpy (file,"unknown"); - line = 0; - } - pclose(f); - } - return line; + if(function != NULL && function[0] != '\0') { + line = 0; + for(;function != NULL && function[0] != '\0';) { + // get function name + char *ret = fgets (buf, maxbufSize, f); + if(ret == NULL) { + pclose(f); + return line; + } + //printf("Looking for [%s] Found [%s]\n",function,ret); + if(strstr(ret,function) != NULL) { + break; + } + + // get file and line + ret = fgets (buf, maxbufSize, f); + if(ret == NULL) { + pclose(f); + return line; + } + + if(strlen(buf) > 0 && buf[0] != '?') { + //int l; + char *p = buf; + + // file name is until ':' + while(*p != 0 && *p != ':') { + p++; + } + + *p++ = 0; + // after file name follows line number + strcpy (file , buf); + sscanf (p,"%d", &line); + } + else { + strcpy (file,"unknown"); + line = 0; + } + } + } + + // get file and line + char *ret = fgets (buf, maxbufSize, f); + if(ret == NULL) { + pclose(f); + return line; + } + + if(strlen(buf) > 0 && buf[0] != '?') { + //int l; + char *p = buf; + + // file name is until ':' + while(*p != 0 && *p != ':') { + p++; + } + + *p++ = 0; + // after file name follows line number + strcpy (file , buf); + sscanf (p,"%d", &line); + } + else { + strcpy (file,"unknown"); + line = 0; + } + pclose(f); + } + return line; } #endif @@ -158,6 +194,8 @@ public: size_t sz = 8096; // just a guess, template names will go much wider char *function = static_cast(malloc(sz)); + function[0] = '\0'; + char *begin = 0; char *end = 0; @@ -201,7 +239,7 @@ public: if(want_full_leak_stacktrace_line_numbers == true && AllocInfo::get_application_binary() != "") { char file[8096]=""; - int line = getFileAndLine(lineAddress, file, 8096); + int line = getFileAndLine(function, lineAddress, file, 8096); if(line >= 0) { char lineBuf[1024]=""; sprintf(lineBuf,"%d",line); diff --git a/source/shared_lib/sources/platform/sdl/thread.cpp b/source/shared_lib/sources/platform/sdl/thread.cpp index b5d98098a..27b5418ab 100644 --- a/source/shared_lib/sources/platform/sdl/thread.cpp +++ b/source/shared_lib/sources/platform/sdl/thread.cpp @@ -258,13 +258,13 @@ void ReadWriteMutex::UnLockRead() { void ReadWriteMutex::LockWrite() { MutexSafeWrapper safeMutex(&mutex); uint32 totalLocks = maxReaders(); - for (int i = 0; i < totalLocks; ++i) { + for(unsigned int i = 0; i < totalLocks; ++i) { semaphore.waitTillSignalled(); } } void ReadWriteMutex::UnLockWrite() { uint32 totalLocks = maxReaders(); - for (int i = 0; i < totalLocks; ++i) { + for(unsigned int i = 0; i < totalLocks; ++i) { semaphore.signal(); } }